Jump to content

PathWalk break


Recommended Posts

Posted

Why are you converting all of your webWalks?

WalkPath only uses the local loaded map to walk and it also can not interact with any objects while walking.

So if you need to walk a long distance that might need to interact with a gate, door or stairs you'd more than likely need to use webWalk.

To set a break condition for a webWalk take a look at https://osbot.org/api/org/osbot/rs07/event/WebWalkEvent.html

To set a break condition for a WalkingEvent take a look at https://osbot.org/api/org/osbot/rs07/event/WalkingEvent.html

Posted
15 hours ago, d0zza said:

Why are you converting all of your webWalks?

WalkPath only uses the local loaded map to walk and it also can not interact with any objects while walking.

So if you need to walk a long distance that might need to interact with a gate, door or stairs you'd more than likely need to use webWalk.

To set a break condition for a webWalk take a look at https://osbot.org/api/org/osbot/rs07/event/WebWalkEvent.html

To set a break condition for a WalkingEvent take a look at https://osbot.org/api/org/osbot/rs07/event/WalkingEvent.html

Because webWalk is using too much RAM and my paths do not require object interaction. I know breaking conditions are possible for both walkingEvents and webWalking but why not for pathWalking?

Posted
6 hours ago, Zummy said:

Because webWalk is using too much RAM and my paths do not require object interaction. I know breaking conditions are possible for both walkingEvents and webWalking but why not for pathWalking?

You could try creating a path:

ArrayList<Position> path

and then use WalkingEvent to traverse to each point.

Posted
12 minutes ago, Zummy said:

WalkingEvent only accepts a single Position, not a list or array.

Look at these examples

public boolean walkToDestination(final Position dest, final BooleanSupplier bc, final boolean walkExact){
        WalkingEvent walkingEvent = new WalkingEvent(dest);
        walkingEvent.setEnergyThreshold(10);
        walkingEvent.setBreakCondition(new Condition() {
            @Override
            public boolean evaluate() {
                return bc.getAsBoolean();
            }
        });
        if (walkExact)
            walkingEvent.setMinDistanceThreshold(0);
        return getScript().execute(walkingEvent).hasFinished();
    }

    public boolean walkToDestination(final Position[] positions, final BooleanSupplier bc, final boolean walkExact){
        WalkingEvent walkingEvent = new WalkingEvent();
        walkingEvent.setPath(new LinkedList<>(Arrays.asList(positions)));
        walkingEvent.setBreakCondition(new Condition() {
            @Override
            public boolean evaluate() {
                return bc.getAsBoolean();
            }
        });
        if (walkExact)
            walkingEvent.setMinDistanceThreshold(0);
        walkingEvent.setMiniMapDistanceThreshold(0);
        walkingEvent.setEnergyThreshold(random(5, 15));
        return getScript().execute(walkingEvent).hasFinished();
    }

    public boolean walkToDestination(LinkedList<Position> path, BooleanSupplier bc, boolean walkExact) {
        WalkingEvent walkingEvent = new WalkingEvent();
        walkingEvent.setPath(path);
        walkingEvent.setBreakCondition(new Condition() {
            @Override
            public boolean evaluate() {
                return bc.getAsBoolean();
            }
        });
        if (walkExact)
            walkingEvent.setMinDistanceThreshold(0);
        walkingEvent.setMiniMapDistanceThreshold(0);
        return getScript().execute(walkingEvent).hasFinished();
    }

 

  • Like 1
Posted
On 8/31/2018 at 12:01 AM, dreameo said:

... -.-

You can look at Chris's example or literally do what I said..

For each Position.. use the WalkingEvent until there are no more positions..

I'm sorry you're right, I followed a tutorial which looked pretty official on this forum that stated you could only use 1 position for walkingEvents.
I tried using a list of positions regardless but couldn't figure it out so I thought the guy was telling the truth.

On 8/30/2018 at 11:36 PM, Chris said:

Look at these examples

Thanks Chris!

  • Like 1
Posted
8 hours ago, Zummy said:

I'm sorry you're right, I followed a tutorial which looked pretty official on this forum that stated you could only use 1 position for walkingEvents.
I tried using a list of positions regardless but couldn't figure it out so I thought the guy was telling the truth.

Thanks Chris!

Code:

Spoiler

private boolean walk(){
        WalkingEvent walkingEvent;

        for(Position position : path)
        {
            walkingEvent = new WalkingEvent(position);
            Event event = getBot().getEventExecutor().execute(walkingEvent);

            if(event.hasFailed())
            {
                return false;
            }
            else
            {
                path.remove(position);
            }
        }

        return true;
    }

So I just tried that and it seems to work fine. You just fill in whatever break condition you want. (You need to keep a temporary path so that as you traverse to each node, you delete it and then continue to next -> really depends on how you write your logic to START the walker)

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