July 24, 201510 yr Hi, I've been reading through a lot of random tutorials and snippets trying to find things about looting items and how to use the api properly for that. I would appreciate any help with how people set-up looting kills and eating food to heal in combat scripts. I don't need full explanations, just maybe someones code to look at or maybe the proper API functions to use. Thanks
July 24, 201510 yr Take a look at GroundItems and Skills in the API. You could eat based off the percent of health they have with: if(myPlayer().getHealth() <= 30) { //change 30 to lowest percent you will tolerate //code here } Or you could check the current health using: if(getSkills().getDynamic(Skill.HITPOINTS) <= 25)) { //change 25 to lowest health you will tolerate //code here } Did not post loot example since there may be better ways. For Black Dragons script I was working on, I checked based off what items were on the ground. Problem with that is other players leaving loot on the ground.Hope this helped a bit. Edited July 24, 201510 yr by bob10
July 24, 201510 yr Author This is exactly what I was looking for. Thank you so much. Yeah, I'd like to know how people set-up loot your own kills. Edit - So that code grabs the health of your player, do I then manipulate inventory/entity API to find and eat a specified food? Edited July 24, 201510 yr by Embarrassment
July 24, 201510 yr This is exactly what I was looking for. Thank you so much. Yeah, I'd like to know how people set-up loot your own kills. Edit - So that code grabs the health of your player, do I then manipulate inventory/entity API to find and eat a specified food? Sorry, meant to check back soon. To eat a specific food: getInventory().getItem(379).interact("Eat"); // using int getInventory().getItem("Lobster").interact("Eat"); // using String getInventory().getItemInSlot(0).interact("Eat"); // slot Eat from a variety of foods: *Twin showed me Filters. Like using when needed. @SuppressWarnings("unchecked") getInventory().getItem(new Filter<Item>() { @Override public boolean match(Item item) { return item != null && food_list.contains(item.getName()); //food_list = list formed based on foods the user entered } }); Edited July 24, 201510 yr by bob10
July 24, 201510 yr Filters Scare people. String[] foods = new String[]{"Trout", "Salmon", "Lobster", "ect"}; Item food = getInventory().getItem(foods);
July 24, 201510 yr Filters Scare people. String[] foods = new String[]{"Trout", "Salmon", "Lobster", "ect"}; Item food = getInventory().getItem(foods); Oh, that is a quick, clean way to use instead.
July 24, 201510 yr Author This is everything I needed. Thank you guys for being so helpful. Edit - Still looking for some information on looting individual kills. Trying to make a bot that doesn't run around like a chicken with it's head cut-off grabbing things. Cheers. Working on combat script for multiple monster types in obscure places. IE (not alkharid, not cows, not stronghold). Edited July 24, 201510 yr by Embarrassment
July 24, 201510 yr This is everything I needed. Thank you guys for being so helpful. Edit - Still looking for some information on looting individual kills. Trying to make a bot that doesn't run around like a chicken with it's head cut-off grabbing things. Cheers. Working on combat script for multiple monster types in obscure places. IE (not alkharid, not cows, not stronghold). Would recommend looking at the mobs position when it dies (there will be an animation for it), and wait until there are GroundItems for it. Also, use filters when possible. They're really good!
Create an account or sign in to comment