Jump to content
scriptersteve

Better fighting method?

Recommended Posts

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();
        }
    }
}
Link to comment
Share on other sites

11 minutes ago, El_Maestro said:

This is a great start. As APA said, if it works there is no problems! If you want to decrease the delay between individual npc interactions make your own isFighting() method that takes an npc as a parameter.

Would this help you think or the inbuilt one good enough?

Link to comment
Share on other sites

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

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 :)

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.

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