Solzhenitsyn Posted August 17, 2016 Share Posted August 17, 2016 (edited) 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 August 21, 2016 by Solzhenitsyn Quote Link to comment Share on other sites More sharing options...
dontbuzz Posted August 17, 2016 Share Posted August 17, 2016 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? Quote Link to comment Share on other sites More sharing options...
Solzhenitsyn Posted August 17, 2016 Author Share Posted August 17, 2016 (edited) 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: @@dontbuzzFixed, added a line in the ctor in the wrong order. oops.always test before uploading Edited August 17, 2016 by Solzhenitsyn 3 Quote Link to comment Share on other sites More sharing options...
House Posted August 20, 2016 Share Posted August 20, 2016 Can't wait till it tries to hop to a DMM world or a PVP world Quote Link to comment Share on other sites More sharing options...
qwd2 Posted September 22, 2016 Share Posted September 22, 2016 (edited) Can't wait till it tries to hop to a DMM world or a PVP world 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 . Edited September 22, 2016 by qwd2 Quote Link to comment Share on other sites More sharing options...
House Posted September 22, 2016 Share Posted September 22, 2016 (edited) 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 . 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 Also i do have a snippet on here that handles it look it up. Edited September 22, 2016 by House Quote Link to comment Share on other sites More sharing options...