Jump to content

Checking distance between two positions?


Salty as fuck

Recommended Posts

position.distance() will not work properly if you want accurate long distance checks because that's just an application of Pythagora's algorithm and does not take into account plane difference, links or obstacles at all.

 

map.realDistance(Position position) should take into consideration all the above situations. You could also try walking.webWalk(Position... positions) as that walks to the closest of the given positions since you mentioned you only want to walk. 

  • Like 1
Link to comment
Share on other sites

position.distance() will not work properly if you want accurate long distance checks because that's just an application of Pythagora's algorithm and does not take into account plane difference, links or obstacles at all.

 

map.realDistance(Position position) should take into consideration all the above situations. You could also try walking.webWalk(Position... positions) as that walks to the closest of the given positions since you mentioned you only want to walk. 

 

However realdistance seems to be off a lot.

I tried using it to find the real closest goblin (like one next to you but behind the fence would actually be further away to run to it)

However it mostly doesn't seem to actually pick the closest one, it looked fairly random

Link to comment
Share on other sites

However realdistance seems to be off a lot.

I tried using it to find the real closest goblin (like one next to you but behind the fence would actually be further away to run to it)

However it mostly doesn't seem to actually pick the closest one, it looked fairly random

It seems to be working fine for me but I haven't tested it much. If you don't trust OSBot's realDistance() method you can try implementing A* with collision flags and getting the length of the path and you should get the same result.

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