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.

aHopper - add basic world hopping utilities to your script

Featured Replies

Probably not very useful, but I needed a way to manage my world jumps so I wrote this. Maybe someone will find this helpful. Modify world list to suit your needs.
 
Usage:

aHopper.jumpTo(301) // These two instructions do the same thing.
aHopper.jumpTo(1)   // aHopper is agnostic to the real server number vs. the used server number.

// Now we are on world 301. aHopper handles boundary worlds.
aHopper.jumpToPrev() // Now we will jump to 394.
aHopper.jumpToNext() // Now we will jump to 301.

// aHopper keeps track of how many times we have jumped during this runtime.
aHopper.isNextHopMultipleOf(5) // returns true

// aHopper will update when it begins to try jumping, the following instruction will complete.
aHopper.jumpTo(hopTarget);
new cSleep(() -> getWorlds().getCurrentWorld() == aHopper.getCurrWorld(), 2500).sleep(); // cSleep not included, go look at Explv's explanation of lambda expressions.

 

import org.osbot.rs07.script.MethodProvider;

public final class aHopper {

    private int[] rsbFree = {
            1, 8,
            16,
            26,
            35,
            81, 82, 83, 84, 85,
            93, 94};
    private int[] f2pWorlds = rsbFree;

    private int baseWorldIndex, currWorldIndex;
    private int totalJumps = 0;

    protected MethodProvider methods;

    public aHopper(MethodProvider methods) {
        this.methods = methods;
        for (int i = 0; i < rsbFree.length - 1; i++) {
            f2pWorlds[i] += 300;
        }
        baseWorldIndex = currWorldIndex = getWorldIndex(methods.getWorlds().getCurrentWorld());
    }

    // Private methods
    private int getWorldIndex(int world) {
        if (world > 300) {
            for (int i = 0; i < f2pWorlds.length; i++) {
                if (world == f2pWorlds[i]) {
                    return i;
                }
            }
        } else if (world > 0) {
            for (int i = 0; i < f2pWorlds.length; i++) {
                if (world == rsbFree[i]) {
                    return i;
                }
            }
        }
        return -1;
    }

    private int getNextWorldIndex() {
        currWorldIndex = getWorldIndex(methods.getWorlds().getCurrentWorld());
        if (++currWorldIndex - baseWorldIndex == rsbFree.length - 1)
            currWorldIndex = 0;
        return currWorldIndex;
    }

    private int getPrevWorldIndex() {
        currWorldIndex = getWorldIndex(methods.getWorlds().getCurrentWorld());
        if (currWorldIndex == 0) {
            currWorldIndex = rsbFree[rsbFree.length - 1];
        } else {
            currWorldIndex--;
        }
        return currWorldIndex;
    }

    // Accessors
    public int getCurrWorld() {
        return f2pWorlds[currWorldIndex];
    }
    public int getTotalJumps() {
        return totalJumps;
    }

    // Status
    boolean isNextHopMultipleOf(int n) {
        if ((totalJumps + 1) % n == 0) {
            return true;
        }
        return false;
    }

    // World Hopping
    void jumpToNext() {
        methods.getWorlds().hop(rsbFree[getNextWorldIndex()]);
        totalJumps++;
        methods.log("Attempting jump to next world...");
    }
    void jumpToPrev() {
        methods.getWorlds().hop(rsbFree[getPrevWorldIndex()]);
        totalJumps++;
        methods.log("Attempting to jump to previous world...");
    }
    boolean jumpTo(int n) {
        if (getWorldIndex(n) != -1) {
            methods.getWorlds().hop(n);
            currWorldIndex = getWorldIndex(n);
            return true;
        }
        return false;
    }
}

Edited by Solzhenitsyn

Tried to use it like this but it just skyrocketed my CPU and made OSBOT unusable.

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

import static org.osbot.rs07.script.MethodProvider.random;

/**import org.osbot.rs07.api.map.Area;
 import org.osbot.rs07.api.map.constants.Banks;
 import org.osbot.rs07.api.model.Entity;
 import org.osbot.rs07.api.model.NPC;
 import org.osbot.rs07.script.Script;
 import org.osbot.rs07.utility.ConditionalSleep;

 import static org.osbot.rs07.script.MethodProvider.random;

 /**
 * Created by tek on 8/14/2016.
 */
public class WorldHopTask extends Task {
    private aHopper aHopper;







    public WorldHopTask(Script script) {
        super(script);
    }

    @[member=Override]
    public boolean verify() {
        return !script.getInventory().contains("Trout");
    }

    @[member=Override]
    public int execute() {
        script.log("No trout in inventory, hopping worlds");

        aHopper.jumpTo(316);




        return random(1200,6400);
    }

    @[member=Override]
    public String describe() {
        return "Mining bro";
    }
}



import org.osbot.rs07.script.Script;

public abstract class Task {
    // The script instance
    protected Script script;

    public Task(Script script) {
        this.script = script;
    }

    /**
     * @return if this Task should execute.
     */
    public abstract boolean verify();

    /**
     * Executes this Task.
     *
     * @return sleep time after this task ends.
     */
    public abstract int execute() throws InterruptedException;

    /**
     * @return a description of the current Task.
     */
    public abstract String describe();
}

Anything I may be doing wrong?

 

 

  • Author

I broke it when I changed something before posting, going to take it down and reupload when I figure out what I broke.

Sorry.

Edit: @@dontbuzz
Fixed, added a line in the ctor in the wrong order. oops.

always test before uploading feels.png

Edited by Solzhenitsyn

Can't wait till it tries to hop to a DMM world or a PVP world feels.png

  • 1 month later...

Can't wait till it tries to hop to a DMM world or a PVP world feels.png

 

Then you create a new class that when it hops to a PVP/DMM world that it instantly log out and connect to another world smile.png.

Edited by qwd2

Then you create a new class that when it hops to a PVP/DMM world that it instantly log out and connect to another world smile.png.

 

You could avoid it from joining one of those types of world.

Leechers will copy code and be surprised when they find themselves dead in a PVP world boge.png

 

Also i do have a snippet on here that handles it look it up.

Edited by House

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.