- Joined
- Feb 9, 2019
- Messages
- 44
- Thread Author
- #1
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!
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;
}