Embarrassment Posted July 24, 2015 Share Posted July 24, 2015 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 Quote Link to comment Share on other sites More sharing options...
bob10 Posted July 24, 2015 Share Posted July 24, 2015 (edited) 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, 2015 by bob10 2 Quote Link to comment Share on other sites More sharing options...
Embarrassment Posted July 24, 2015 Author Share Posted July 24, 2015 (edited) 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, 2015 by Embarrassment Quote Link to comment Share on other sites More sharing options...
OSBOT Jack Posted July 24, 2015 Share Posted July 24, 2015 I hope to see your scripts on the SDN soon @embarrassment! Quote Link to comment Share on other sites More sharing options...
Embarrassment Posted July 24, 2015 Author Share Posted July 24, 2015 I'm definitely doing my best to learn. Quote Link to comment Share on other sites More sharing options...
bob10 Posted July 24, 2015 Share Posted July 24, 2015 (edited) 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, 2015 by bob10 Quote Link to comment Share on other sites More sharing options...
Isolate Posted July 24, 2015 Share Posted July 24, 2015 Filters Scare people. String[] foods = new String[]{"Trout", "Salmon", "Lobster", "ect"}; Item food = getInventory().getItem(foods); Quote Link to comment Share on other sites More sharing options...
bob10 Posted July 24, 2015 Share Posted July 24, 2015 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. Quote Link to comment Share on other sites More sharing options...
Embarrassment Posted July 24, 2015 Author Share Posted July 24, 2015 (edited) 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, 2015 by Embarrassment Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted July 24, 2015 Share Posted July 24, 2015 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! Quote Link to comment Share on other sites More sharing options...