Jump to content

Drop jugs after drinking wines


KingBo

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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