Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • How to make a combat method that doesn't suck


    Recommended Posts

    We all use combat methods that get the player in combat and player interacting !=null


    The problem with these is that they are awful. When in combat they will frequently return false because of the few tick delay between attacking and getting attacked and then run off trying to attack something else.

    I don't know how you get around this over at dreambot, but here is how I did it.

    (basically adds a delay after after not in combat to avoid the bot returning false for incombat method, thus not running around clicking shit)




    make a bool for incombat and isrunning

     public boolean isruning;
        public boolean inCombatBool = false; 

    next in your onstart method, make a new thread that does the following

    isruning = true;
    Thread t = new Thread(() -> {
                int x = 0;
                while (isruning) {
                    if ((getLocalPlayer().isInCombat() && getLocalPlayer().getInteractingCharacter() != null) || getLocalPlayer().getAnimation() != -1) {
                        inCombatBool = true;
                    } else if (x > 8) {
                        inCombatBool = false;
                        x = 0;
                    try {
                    } catch (InterruptedException e) {

    now in your loop 

    if (!inCombatBool) {
                sleep(Calculations.random(3000, 4000));

    and the method being called 

     public void attack() {
            NPC slayerTask = getNpcs().closest(npc -> npc != null && npc.getName() != null && !npc.isInCombat());
            if (slayerTask != null) {
                if (slayerTask.interact("Attack")) {
                    sleepUntil(() -> getLocalPlayer().isInCombat() || getLocalPlayer().getInteractingCharacter() != null, Calculations.random(5000, 7000));

    lastly on your onExit

        public void onExit() {
            isruning = false;



    Link to comment
    Share on other sites

    • 4 months later...
    • 6 months later...

    Hey, I just finished trying this out and it's unfortunately not waiting long enough before attacking the next NPC. I have tried increasing the delay but it doesn't seem to be working.


    Also, the part of the code 




    Had to make a 


    private void changeStatus(String attacking) {



    to function properly.



    I am pretty sure nothing is incorrect from yours. I did not copy and paste it so I could get a better understanding of it and for the most part I get it.


    I little bit of help on the matter would be awesome?


    Edit: I fixed it! :]

    Link to comment
    Share on other sites


    This topic is now archived and is closed to further replies.

    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.