Jump to content

Accurate walking


Normangorman

Recommended Posts

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
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.
Note: Your post will require moderator approval before it will be visible.

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