Jump to content

Better fighting method?


Recommended Posts

Posted

Hi, I am using the following as my fighting part of my script: 

Was wondering if there were any additions people would make to improve this?

if (!getCombat().isFighting()) { //not in combat
    if (warrior != null) { //if it exists
        if (warrior.interact("Attack")) { //attack
            new ConditionalSleep(3000, 600) { //sleep for 3 seconds or until the condition is true
                @Override
                public boolean condition() throws InterruptedException {
                    return getCombat().isFighting();
                }
            }.sleep();
        }
    }
}
Posted

Also you could always take advantage of the return value of the conditional sleep to determine what to do if the interaction for whatever reason fails (misclick, ...)

e.g:

if (!getCombat().isFighting()) { //not in combat
    if (warrior != null) { //if it exists
        if (warrior.interact("Attack") && new ConditionalSleep(3000, 600) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getCombat().isFighting();
                }
            }.sleep()) { log("Success!");
        } else log("Fail :(");
    }
}

 

  • Like 1
Posted
1 hour ago, Apaec said:

Also you could always take advantage of the return value of the conditional sleep to determine what to do if the interaction for whatever reason fails (misclick, ...)

e.g:


if (!getCombat().isFighting()) { //not in combat
    if (warrior != null) { //if it exists
        if (warrior.interact("Attack") && new ConditionalSleep(3000, 600) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getCombat().isFighting();
                }
            }.sleep()) { log("Success!");
        } else log("Fail :(");
    }
}

 

ah fair enough :)

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