Developer Maxi Posted June 5, 2013 Developer Posted June 5, 2013 Today I finally got around to finishing up the world hopping system. This was also a nice moment to bring the random management system in to action. For anyone interested in the random management system in action code wise for the world hopping system, here you go: package org.osbot.script.rs2.ui; import org.osbot.engine.Bot; import org.osbot.script.mouse.RectangleDestination; import org.osbot.script.rs2.randoms.RandomBehaviourHook; import org.osbot.script.rs2.randoms.RandomManager; import org.osbot.utility.Gaussian; import java.awt.*; import java.util.ArrayList; import java.util.Map; /** * Created with IntelliJ IDEA. * User: Maxime * Date: 26-05-13 * Time: 19:24 * To change this template use File | Settings | File Templates. */ public class WorldHopper { private final Bot bot; private boolean isHopping = false; private int nextWorld = -1; public WorldHopper(Bot bot) { this.bot = bot; } /** * Logs you out and changes hops to the world specified. This method does not take in to account full worlds yet, * so hopping to a full world will fail. * @param world Worlds range from 301 to 378 but remember that the worlds * 307, 315, 323, 324, 331, 332, 347, 348, 355, 356, 363, 364, 371, 372 * do not exist. */ public void hopWorld(int world) throws InterruptedException { nextWorld = world; isHopping = true; bot.getScript().randomManager.registerHook(hook); while (bot.getClient().getLoginState() != 10) { if (bot.getScript().logoutTab.logOut()) { Thread.sleep(500 + Gaussian.random(300, 300)); } } } private static enum State { GO_TO_SELECTION, WORLD_SELECTION, UNHOOK; } private RandomBehaviourHook hook = new RandomBehaviourHook(RandomManager.LOGIN_SCRIPT) { private State state = null; @Override public String getName() { return "World Hopping"; } public void scan() { if (!isHopping || bot.getClient().getLoginState() != 10 || nextWorld == -1) { state = State.UNHOOK; return; } if (bot.getClient().getColorPicker().isColorAt(54, 294, Color.BLACK)) { state = State.WORLD_SELECTION; return; } else { if (bot.getClient().getCurrentWorld() == nextWorld) { state = State.UNHOOK; } else { state = State.GO_TO_SELECTION; } } } /** * The main loop logic. This will continue until shouldActivate() returns true or * -1 is returned. * * @return The time to sleep until the next loop. * @throws InterruptedException */ @Override public int onLoop() throws InterruptedException { scan(); switch (state) { case GO_TO_SELECTION: bot.getClient().moveMouseTo(new RectangleDestination(new Rectangle(12, 466, 86, 26)), false, true, false); return 600 + gRandom(200, 200); case WORLD_SELECTION: Rectangle dest = getWorldMouseDestination(nextWorld); bot.getClient().moveMouseTo(new RectangleDestination(dest), false, true, false); return 600 + gRandom(200, 200); case UNHOOK: nextWorld = -1; isHopping = false; bot.getRandomManager().unregisterHook(RandomManager.LOGIN_SCRIPT); return -1; default: return 500 + gRandom(500, 500); } } @Override public void onExit() { isHopping = false; nextWorld = -1; } }; /** * Calculates the rectangle of the destination to click a world. * @param world The specified world in the range of 301 - 378 * @return The rectangle used for the mouse destination */ private Rectangle getWorldMouseDestination(int world) { ****** } ***** static { ***** } } Furthermore I started on a breaking system. You will be able to set your break settings per saved account profile, which will then be used if you enable it. Expect both updates to be released tonight or tomorrow, Sincerely, OSBot.org 4
SXForce Posted June 5, 2013 Posted June 5, 2013 (edited) Just what i needed! Thanks! Edit: About the breaks: can a script writer modify these settings? For example: if you have a fighter bot, you want to do something before the bot takes a break. Is this a random hook too? (RandomManager.BREAK or something?) Edited June 5, 2013 by SXForce
Wizard Posted June 5, 2013 Posted June 5, 2013 Awesome, cant wait for this. would be helpful for my Rare hunting script :3
BotRS123 Posted June 11, 2013 Posted June 11, 2013 Can't wait until this can consider full worlds. You should include two methods, nextWorld()/hopNextWorld() and randomWorld()/hopRandomWorld().
Brutus Posted June 11, 2013 Posted June 11, 2013 Sounds great but will it support like say if someone was botting in a members area and the bot chose a f2p world would it switch or would it get stuck trying to keep logging in?