Jump to content

Accurate walking


Recommended Posts

Posted

I've noticed recently that localWalker#walk won't actually always take you to the position that you want to walk to, but rather will go to one in the nearby area. This can cause bugs, for example if you define an area that is the inside of a certain building, and then you call localWalker#walk and pass it this area, then you might end up walking to one of the squares outside of the building because of this inaccuracy.

 

It occurs because the default walking event has a distance threshold of 2, so any square within 2 squares of the one you pass to the function is considered a valid walk target. If you need walking that is accurate to the square, then you can change this threshold to 0.

Position targetPosition = new Position(3400,3200,0);
WalkingEvent w = new WalkingEvent(targetPosition);
w.setMiniMapDistanceThreshold(0);
w.setMinDistanceThreshold(0);
script.execute(w);

This will always walk to the exact square you give.

 

By using custom events like this, you can also control whether the event blocks. So if you need asynchronous walking (which can be useful) then you can do this before you execute it: 

w.setAsync();
  • Like 5

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