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.

Drop jugs after drinking wines

Featured Replies

Hey guys, so I've got this bit where the bot drinks wines but I want it to drop the jugs directly after drinking. 

if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) {
    log("Drinking");
    getInventory().interact("Drink", "Jug of wine");
    if (getInventory().contains("Jug")) {
        log("Dropping");
        getInventory().interact("Drop", "Jug");

This is what I've got so far but it only works sometimes other times it just ignores the jug after drinking. What would be a better way to do this?

Always put a sleep and an if conditional after an action:

if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) {
  log("Drinking");
  if(getInventory().interact("Drink", "Jug of wine")){
    Sleep.sleepUntil(() -> getInventory().contains("Jug"), 2400, 1200);

    if (getInventory().contains("Jug")) {
      log("Dropping");

      if(getInventory().interact("Drop", "Jug")){
        Sleep.sleepUntil(() -> (!getInventory().contains("Jug")), 2400, 1200);
      }
    }
  }
}

Get this Sleep with Lambda expressions here: 

 

Edited by Heiz

You could also do it the other way around. First check if you have any jugs in the inventory, then drop them. After than you have the condition for jug of wine in inventory and health percentage -> drink

3 hours ago, KingBo said:

if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) {
    log("Drinking");
    getInventory().interact("Drink", "Jug of wine");
    if (getInventory().contains("Jug")) {
        log("Dropping");
        getInventory().interact("Drop", "Jug");

Always try to keep it 1 interaction per cycle of the onLoop. So to do that here you can do as the guy said above by reversing the order.

	if (getInventory().contains("Jug")) {
            log("Dropping");
            if (getInventory().dropAll("Jug")) {
                ConditionalSleep2.sleep(1200, ()-> !getInventory().contains("Jug"));
            }
        } else if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) {
            log("Drinking");
            if (getInventory().interact("Drink", "Jug of wine")) {
                //Depends on your needs but you can sleep or not here
                ConditionalSleep2.sleep(1200, ()-> myPlayer().getHealthPercent() > 60);
            }
        }

But if you want it purely done after drinking then you will have to do it Heiz way or put the check and dropping of "Jug" at the top of your onLoop.



P.S.

3 hours ago, KingBo said:

This is what I've got so far but it only works sometimes other times it just ignores the jug after drinking. What would be a better way to do this?

Reason it ignores the Jug btw is because every game tick is ~600ms, so when you drank the wine you were also checking for Jug on the same game tick. It would take a game tick for the game to make the wine go from Jug of wine to Jug.

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.