Jump to content

PathWalk break


Zummy

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

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