Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Any snippets for eating/walking while in combat?

Featured Replies

Just wondering if anyone has anything that i can take some inspiration from for the anti pk portion of my script.

Use Async events and break the web walker event when you need to eat.

Edited by FushigiBot

Found something you might be able to use. Someone posted this snippet a while back and I had it saved on my PC. If this snippet is yours, lmk so that I can credit you.

Custom class

Quote
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.event.WebWalkEvent;
import org.osbot.rs07.utility.ConditionalSleep2;

public class CustomWebWalk extends WebWalkEvent {

    private AsyncWalkEvent asyncWalkEvent;

    public CustomWebWalk(Position position) {
        super(position);
    }

    @Override
    public void onStart() {
        asyncWalkEvent = new AsyncWalkEvent();
        execute(asyncWalkEvent);
    }

    @Override
    public int execute() throws InterruptedException {
        if (asyncWalkEvent.isLooping()) {
            // Async is still looping, dont let the web walker execute
            return 600;
        }
        return super.execute();
    }

    @Override
    public void onEnd() throws InterruptedException {
        // End the async event and wait for it to finish
        asyncWalkEvent.setFinished();
        ConditionalSleep2.sleep(5000, asyncWalkEvent::hasCompleted);
    }

}

Then just set the action here

Quote
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.event.Event;

public class AsyncWalkEvent extends Event {

    private volatile boolean finished = false;

    private volatile boolean isLooping = false;

    public AsyncWalkEvent() {
        setAsync();
    }

    @Override
    public int execute() throws InterruptedException {
        if (canPerformAction()) {
            // Map destination is far enough away, we can perform some actions
            isLooping = true;
            if (shouldDoAction()) {
                // do action
            } else {
                // any other necessary action
            }
            isLooping = false;
        }
        return 600;
    }

    @Override
    public void onEnd() throws InterruptedException {
        finished = true;
    }

    public boolean isLooping() {
        return isLooping;
    }

    public boolean hasCompleted() {
        return finished;
    }

    private boolean canPerformAction() {
        // Only allow the actions to start if the map destination is far enough away
        Position dest = getMap().getDestination();
        if (dest == null) return false;
        int dist = getMap().distance(dest);
        return dist < 20 && dist > 7;
    }

}

 

  • Author
1 hour ago, FushigiBot said:

Found something you might be able to use. Someone posted this snippet a while back and I had it saved on my PC. If this snippet is yours, lmk so that I can credit you.

Custom class

Then just set the action here

 

Thanks might come in useful! Not going to use webwalker though gonna use pathwalk 

10 minutes ago, saintpaul1 said:

Thanks might come in useful! Not going to use webwalker though gonna use pathwalk 

Keep in mind that anything other than the web walker and you have to write object interactions as well (door opening, etc).


Since pathwalker uses the local walker, make sure to make it break when the position its trying to get to becomes  unreachable. Otherwise it will get stuck trying to reach it from, say, lumby or death's office, if you get pked.

  • Author
7 hours ago, FushigiBot said:

Keep in mind that anything other than the web walker and you have to write object interactions as well (door opening, etc).


Since pathwalker uses the local walker, make sure to make it break when the position its trying to get to becomes  unreachable. Otherwise it will get stuck trying to reach it from, say, lumby or death's office, if you get pked.

thanks mate

  • 1 month later...
On 4/19/2023 at 2:29 PM, FushigiBot said:

Found something you might be able to use. Someone posted this snippet a while back and I had it saved on my PC. If this snippet is yours, lmk so that I can credit you.

Custom class

Then just set the action here

 

How can i execute the customwebwalk from my main class?

 


import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;



@ScriptManifest(name = "Skeleton", author = "Alek", version = 1.0, info = "", logo = "")

public class Main extends Script {

    CustomWebWalk customWebWalk;
    @Override
    public void onStart() {
        //Code here will execute before the loop is started
        Position destination = new Position(3144, 3485, 0); // Replace with desired destination coordinates
        customWebWalk = new CustomWebWalk(destination);
        customWebWalk.exchangeContext(getBot());
        customWebWalk.onStart();
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (customWebWalk != null) {
            execute(customWebWalk);
        } else {
            log("Web walk null");
        }
        return 100; //The amount of time in milliseconds before the loop starts over

    }

}

Something like this?

 

edit: i got it to execute but in asyncwalkevent class canperformaction is false.

 

    private boolean canPerformAction() {
        // Only allow the actions to start if the map destination is far enough away
        Position dest = getMap().getDestination();
        if (dest == null) return false;
        int dist = getMap().distance(dest);
        return dist < 20 && dist > 7;
    }

Im trying to walk to edgeville from grand exchange.

Final edit: got it to work :)

Edited by shaba123

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.