Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question How to "attack" enemies more accurately

Joined
Feb 9, 2019
Messages
44
Hi Team,

At this stage I have been writing a bot to attack and have noticed that that the cursor has a habit of float around other many objects except my target. I am looking to see what method I can use to get a more consistent interaction with the target. I have seen in a few scripts that they do the camera follow and try to move closer to the target thus increasing the physical size of the character on the screen.

My code thus far for attack an Imp for example is like so. My loop that calls this function simply checks to see that my character is idle, not moving and has no target before doing any of the below.

Looking forward to suggestions!

Code:
Npc npc = Npcs.newQuery().names("Imp").within(new Area.Circular(Players.getLocal().getPosition(), 15)).actions("Attack").reachable().results().nearest();
            if (npc != null) {
                //System.out.println(npc.toString());
                //npc.click();
                if (npc.distanceTo(Players.getLocal().getPosition()) > 7) {
                    final RegionPath path = RegionPath.buildTo(npc.getPosition());
                   
                    if (path != null) { // IMPORTANT: if the path should be null, the pathbuilder could not manage to build a path with the given region, so always nullcheck!
                        path.step();
                        System.out.println("Walking to Imp");
                    }
                    else {
                        System.out.println("Couldn't walk to imp?");
                    }
                }
                else {
                    boolean complete = npc.interact("Attack");
                    if (complete) {
                        System.out.println("--------Now attacking imp");
                    }
                    else {
                        System.out.println("Attack failed");
                    }
                }
                Execution.delay(600);
                return true;
            }
            else {
                return false;
            }
 
Joined
Nov 28, 2015
Messages
1,855
It could be that Clouse is acting up. Try using a different mouse path gen like MLP

Code:
public void onStart(String... args) {
    Mouse.setPathGenerator(Mouse.MLP_PATH_GENERATOR);
}
 
Joined
Feb 17, 2019
Messages
29
It could be that Clouse is acting up. Try using a different mouse path gen like MLP

Code:
public void onStart(String... args) {
    Mouse.setPathGenerator(Mouse.MLP_PATH_GENERATOR);
}

What exactly does this do? I imagine it changes the way the mouse path is generated, but is MLP an alternative to Clouse?
 
Bot Consultant
Joined
Nov 17, 2014
Messages
304
What exactly does this do? I imagine it changes the way the mouse path is generated, but is MLP an alternative to Clouse?
Correct it is an alternative, and the way paths are generated are different. There is far more accuracy and precision when interacting with stuff
 
Joined
Feb 9, 2019
Messages
44
Why wouldn't this be standard then? Does it take more computation or something?

Specifically I found that the mouse was hovering over the enemy without clicking on them. I got greater success when I moved closer to the npc.

I am now having issues trying to click use on raw fish and click on a fire :( then clicking the menu pop-up options. Might make another post about that one though.
 
#1 Fabric Cleaner
Joined
Mar 18, 2017
Messages
393
Why wouldn't this be standard then? Does it take more computation or something?

Specifically I found that the mouse was hovering over the enemy without clicking on them. I got greater success when I moved closer to the npc.

I am now having issues trying to click use on raw fish and click on a fire :( then clicking the menu pop-up options. Might make another post about that one though.
Try using the Interact method, i’ve found click to be a little buggy sometimes as well.
 
Top