Jump to content

Determining the length of a WalkingEvent or WebWalkEvent path before actually walking it


Crimcinder

Recommended Posts

Hey I was trying to write a script that favors the "closest" node of a resource to gather, either ore or trees, but I ran into the issue of my bot running 60 tiles spaces away because he wanted to go around a fence to a tree that was technically closer after cut the last tree, when there were plenty of other trees closer to the first one he cut. I recognize that I can just make him search for a closer tree as he starts moving but now I've fallen down the rabbit hole of wanting to be able to find the length of a path/route made by webwalking or local walking functions. Is this even possible? From what I can tell when we create a walking event you can call, for example with a WebWalkEvent, the getPositions() method but only after you call execute(WebWalkEvent cleverName). This will of course make the bot take the path, and then return the list of positions of the path it just took. If we can find the list of positions that make up the route before the bot walks it, how can this be done? At this point I'm contemplating writing my own pathing script but I know that's a huge undertaking I was hoping to avoid... Thanks for any help!

Link to comment
Share on other sites

You can use the LocalPathFinder class to generate the path your character will take when walking to a position https://osbot.org/api/org/osbot/rs07/api/util/LocalPathFinder.html

Although if you just want find the closest object based on the actual path, you can pass the realDistance = true parameter to the closest() method call. This will generate the path and compare lengths for you https://osbot.org/api/org/osbot/rs07/api/EntityAPI.html#closest-boolean-java.lang.String...-

  • Heart 1
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...