Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Looking for Code/Snippet/Advice with Looting/Healing

Featured Replies

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

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 by bob10

  • 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 by Embarrassment

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 by bob10

 

 

Filters Scare people.

 String[] foods = new String[]{"Trout", "Salmon", "Lobster", "ect"};
        Item food = getInventory().getItem(foods);

 

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.

  • 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 by Embarrassment

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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.