Jump to content

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


Recommended Posts

Posted

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!

Posted

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

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