Jump to content

Drop jugs after drinking wines


Recommended Posts

Posted

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?

Posted (edited)

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
Posted
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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...