Jump to content

World hopper + break system


Maxi

Recommended Posts

  • Developer

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

  • Like 4
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...