All pastes #1453630 Raw Edit

LumbFlaxSpinnerUs.java

public javascript v1 · immutable
#1453630 ·published 2009-06-09 13:53 UTC
rendered paste body
//            mehhh's Private Lumbridge Flax Spinner//              -  -  -  -  -  -  -  -  -  -  -  -//         From using/buying this script, the buyer agrees to://              - Not redistribute this script to any other site or leak it to any other site.//              - That this script is property of mehhh.import java.awt.*;import java.util.ArrayList;import com.speljohan.rsbot.bot.*;import com.speljohan.rsbot.event.events.ServerMessageEvent;import com.speljohan.rsbot.event.listeners.*;import com.speljohan.rsbot.script.*;import com.speljohan.rsbot.script.wrappers.*;    public class LumbFlaxSpinnerUs extends Script implements PaintListener, ServerMessageListener {    public RSTile[] deathToCastlePath = {new RSTile(3214, 3215), new RSTile(3206, 3210)};        boolean proggy = false;    long startTime = System.currentTimeMillis();    int stringsBanked = 0;    int bankFail = 0;    int bankNPC = 4907;    private RSTile LADDER     = new RSTile(3209, 9616);        final int FLAX_ID = 1779;    final int BOW_STRING_ID = 1777;    final int DOOR_CLOSE_ID = 36844;    final int DOOR_CLOSE_ID1 = 36830;    final int BOW_STRING_CHILD_ID = 17;    final int[] SPINNING_WHEEL_ID = {36970, 36785};    final int SPINNING_INTERFACE_ID = 459;    final int[] BANK_ID = {36786, 36831};    private void pause() {        wait(random(200, 300));    }        public RSTile bankBoothTile = new RSTile(3208, 3220);        final Color BG = new Color(0, 0, 0, 100);    final Color WHITE = new Color(255, 255, 255, 255);    final RSTile STAIRCASE_TILE2 = new RSTile(3206, 3210);    final RSTile bankTile = new RSTile(3208, 3220);    final RSTile BOOTH_TILE = new RSTile(3208, 3221);    final RSTile DOOR_CLOSE_TILE = new RSTile(3207, 3214);    final RSTile DOOR_CLOSE_TILE1 = new RSTile(3208, 3212);    final RSTile STAIRCASE_TILE = new RSTile(3205, 3208);    final RSTile STAIRCASE_TILE1 = new RSTile(3204, 3207);    final RSTile DEATH_TILE = new RSTile(3214, 3214);    final RSTile DEATH_TILE1 = new RSTile(3206, 3210);    public String getName() {        return "LumbFlaxSpinnerUs";    }    public double getVersion() {        return 6.2;    }    public String getAuthor() {        return "mehhh/..:loading:../Mike";    }    public String getScriptCategory() {        return "Crafting";    }    public String getScriptDescription() {        return "<html>\n" + "<head></head>\n" + "<body>\n" + "<center>"        + "<h2>"        + getName()        + "</h2>"        + "</center>\n"        + "<b>Author:</b> "        + getAuthor()        + "<br/>\n"        + "<b>Version:</b> "        + getVersion()        + "<br/>\n"        + "<br/>\n"        + "<b>Starting Location:</b> Lumbridge Bank & put Flax in <b><u>FIFTH</u></b> bank slot.<br/>"        + "<b>Function:</b> Spins Flax."        + "<br/>"        + "<b>Version Notes:</b> "        + "<ul>"        + "<li>"        + "<b>6.1:</b> Small edits"        + "<br>"        + " - Logs off when out of flax now."        + "<li>"        + "<b>6.0:</b> Final Version (NOT)"        + "<br>"        + " - Tuned up the script."        + "<br>"        + " - Should run back into bank if misclicked out of the bank."        + "<li>"        + "<b>5.8:</b> Re-fixed Deathwalk"        + "<br>"        + " - Fix and edited deathwalk so it works and that it is better than before."        + "<br>"        + " - Should run back into bank if misclicked out of the bank. (NEEDS FEEDBACK AGAIN)"        + "<li>"        + "<b>5.7:</b> Fastest and New Features (NEEDS FEEDBACK AGAIN)"        + "<br>"        + " - Fastest the script can possibly run."        + "<br>"        + " - Should run back into bank if misclicked out of the bank. (NEEDS FEEDBACK AGAIN)"        + "<br>"        + " - Should run back into Lumbridge Castle when dead. (NEEDS FEEDBACK)"        + "<li>"        + "<b>5.6:</b> Small Edits and New Feature (UNTESTED, NEED FEEDBACK)"        + "<br>"        + " - Script should perform a little bit faster."        + "<br>"        + " - Should run back into bank if misclicked out of the bank. (NEED FEEDBACK)"        + "<li>"        + "<b>5.5:</b> Faster script"        + "<br>"        + " - Script should perform a faster."        + "<li>"        + "<b>5.4:</b> Fixed Deathwalk"        + "<br>"        + " - Fixed up deathwalk so it walks much better and is more accurate."        + "<li>"        + "<b>5.3:</b> Removed Beeps"        + "<br>"        + " - Removed annoying beeps that would cause Rsbot to go white screen and continuously beep."        + "<li>"        + "<b>5.2:</b> Poison Detection"        + "<br>"        + " - Now if poisoned, climbs up the stairs and waits for 3-4 minutes then climb back down."        + "<li>"        + "<b>5.0:</b> GLOBAL DEATHWALK"        + "<br>"        + " - Now can start the script anywhere in the world."        + "<br>"        + " - Deathwalk from anywhere in Runescape."        + "</li>" + "<li>" + "<b>4.*:</b> mehhh's Release Versions" + "</li>"        + " - Now shows profit made."        + "<br>"        + " - Runs to spinner and banks a LOT better."        + "<br>"        + " - Editted so then that it withdraws in fifth bank slot."        + "<br>"        + " - Added a new spinner ID."        + "</li>" + "<li>" + "<b>3.*:</b> mehhh's Release Versions" + "</li>"        + " - Recolored paint for more visibility."        + "<br>"        + " - Fixed not going upstairs when being attacked. (credits to <i>alowaniak</i> for combat detection)"        + "<br>"        + " - Fixed getting stuck on stairs, spinning room, and in bank."        + "<br>"        + " - Fixed running into the spinning room after opening the door."        + "<br>"        + " - Banks a LOT better."        + "<br>"        + " - Runs away from combat -- credits to <i>alowaniak</i>."        + "</li>" + "<li>" + "<b>0.*:</b> Beta Versions" + "</li>" +                "</ul>" + "</body>\n" + "</html>";    }    public boolean onStart(String[] args) {        bankFail = 0;        proggy = true;        tries2 = 0;        startTime = System.currentTimeMillis();        stringsBanked = 0;        Bot.getEventManager().addListener(PaintListener.class, this);        Bot.getEventManager().addListener(ServerMessageListener.class, this);        return true;    }    public void logoutFor(int i) {}    public void onFinish() {        Bot.getEventManager().removeListener(PaintListener.class, this);        Bot.getEventManager().removeListener(ServerMessageListener.class, this);    }    public RSTile bankTile() {        return new RSTile(random(3208, 3209), random(3220, 3220));    }        public RSTile deathTile() {        return new RSTile(random(3214, 3215), random(3213, 3217));    }    public RSTile staircaseTile() {        return new RSTile(random(3205, 3207), random(3205, 3209));    }        public RSTile staircaseTile1() {        return new RSTile(random(3205, 3206), random(3209, 3209));    }        public RSTile ladderTile() {        return new RSTile(random(3208, 3208), random(9615, 9618));    }        public RSTile doorCloseTile() {        return new RSTile(random(3208, 3208), random(3212, 3212));    }    public boolean isInSpinningRoom() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3208 && myX <= 3212 && myY >= 3211 && myY <= 3217                && getPlane() == 1) {            return true;        }                return false;    }        public boolean isInChefRoom() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3205 && myX <= 3212 && myY >= 3212 && myY <= 3217                && getPlane() == 0) {            return true;        }                return false;    }    public boolean isInBasement() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3208 && myX <= 3219 && myY >= 9615 && myY <= 9624                && getPlane() == 0) {            return true;        }                return false;    }    public boolean isInBank() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3207 && myX <= 3209 && myY >= 3215 && myY <= 3220                && getPlane() == 2) {            return true;        }        return false;    }        public boolean isOutside1() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3205 && myX <= 3206 && myY >= 3212 && myY <= 3223                && getPlane() == 2) {            return true;        }        return false;    }        public boolean isOutside2() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3209 && myX <= 3213 && myY >= 3223 && myY <= 3225                && getPlane() == 2) {            return true;        }        return false;    }        public boolean isOutside3() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3211 && myX <= 3213 && myY >= 3215 && myY <= 3222                && getPlane() == 2) {            return true;        }        return false;    }        public boolean isOutside4() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3205 && myX <= 3213 && myY >= 3212 && myY <= 3214                && getPlane() == 2) {            return true;        }        return false;    }        public boolean isOutside5() {        RSTile myLocation = getMyPlayer().getLocation();        int myX = myLocation.getX();        int myY = myLocation.getY();        if (myX >= 3205 && myX <= 3207 && myY >= 3224 && myY <= 3229                && getPlane() == 2) {            return true;        }        return false;    }    public RSTile spinningRoomTile() {        return new RSTile(random(3209, 3210), random(3213, 3213));    }    public RSTile outsideDoor() {        return new RSTile(random(3205, 3207), random(3208, 3216));    }    public boolean isDoorClosed() {        if (getPlane() == 1 && !isInSpinningRoom()) {            if (Calculations.canReach(spinningRoomTile(), true)) {                return false;            }        }        if (getPlane() == 1 && isInSpinningRoom()) {            if (Calculations.canReach(staircaseTile(), true)) {                return false;            }        }        return true;    }        public boolean isChefDoorClosed() {        if (getPlane() == 0 && !isInChefRoom()) {            if (Calculations.canReach(doorCloseTile(), true)) {                return false;            }        }        if (getPlane() == 0 && isInChefRoom()) {            if (Calculations.canReach(staircaseTile1(), true)) {                return false;            }        }        return true;    }    public boolean walkToTile(RSTile tile) {        if (walkPathMM2(generatePath(tile), 17)) {            return true;        }                return false;    }    public int flaxCount() {        return getInventoryCount(FLAX_ID);    }    public int bowstringCount() {        return getInventoryCount(BOW_STRING_ID);    }        public boolean isInArea(int maxX, int minY, int minX, int maxY) {        int x = getMyPlayer().getLocation().getX();        int y = getMyPlayer().getLocation().getY();        if (x >= minX && x <= maxX                && y >= minY && y <= maxY) {            return true;        }        return false;    }    public int loop() {        if(!isLoggedIn()) {            return random(100, 200);        }        if (getEnergy() >= random(60, 100)) {            setRun(true);            wait(random(400, 500));        }        try {            if (getMyPlayer().isMoving()) {                wait(random(25,50));                return random(20, 25);            }            int height = getPlane();            if (!RSInterface.getInterface(SPINNING_INTERFACE_ID).isValid()) {                if (flaxCount() == 0) {                    atInterface(SPINNING_INTERFACE_ID, 12);                } else if (!bank.getInterface().isValid()) {                    if (getEnergy() >= random(60, 100)) {                        setRun(true);                    }                }            }            //credits to alowaniak            //thanks to alowaniak            if(getMyPlayer().isInCombat()) {                    log("Avoiding combat...");                if(getPlane() == 1) {                    if(canReach(STAIRCASE_TILE, true)) {                        if(!tileOnScreen(new RSTile(STAIRCASE_TILE.getX() - 1, STAIRCASE_TILE.getY()))) {                            walkTileMM(STAIRCASE_TILE);                        } else {                            atTile(STAIRCASE_TILE, "up");                        }                    } else {                        openDoor(getObjectAt(DOOR_CLOSE_TILE));                        log("Opening door to avoid combat...");                    }                    return random(300, 600);                } else if(getPlane() == 2) {                    if(!tileOnScreen(STAIRCASE_TILE)) {                        walkTileMM(STAIRCASE_TILE);                    } else {                        atTile(STAIRCASE_TILE, "down");                    }                    return random(300, 600);                }            }            //----------------------------------------            //----------------------------------------            if (height == 0) {                if (isInBasement()) {                    if (!walkToTile(ladderTile())) {                        wait(random(10000, 12000));                    }                    if (!atTile(LADDER, "up")) {                        turnToTile(LADDER);                         return random(9200, 9500);                    }                }            }            if (isInChefRoom()) {                if(canReach(STAIRCASE_TILE2, true)) {                    if(!tileOnScreen(new RSTile(STAIRCASE_TILE2.getX(), STAIRCASE_TILE2.getY() - 1))) {                        walkTileMM(STAIRCASE_TILE2);                    }                } else {                    walkTileMM(new RSTile(3208, 3212));                    wait(random(5000, 5200));                    openDoor1(getObjectAt(DOOR_CLOSE_TILE1));                    log("Opening door from chef room to stairs...");                    wait(random(300, 500));                    walkTileMM(STAIRCASE_TILE2);                    wait(random(1000, 1200));                }                if (!atTile(STAIRCASE_TILE1, "up")) {                    turnToTile(STAIRCASE_TILE1);                }            }            if (height == 0) {                if (distanceTo(new RSTile(3226, 3224)) >= 26) {                    //thanks to alowaniak                    //credits to alowaniak                    if(isLoggedIn()) {                        openTab(TAB_MAGIC);                        wait(random(1200, 1500));                        castSomeSpell(0);                        wait(random(3000, 4000));                        if(getMyPlayer().getAnimation() != -1) {                            tries2 = 0;                            return random(20000, 22000);                        }                        else if(tries2 <= 8) {                            tries2 ++;                            return random(1000, 3000);                        }                        log("Got lost and couldn't do home tele.");                        log("Will stop script now.");                        stopAllScripts();                        return -1;                    }                    //----------------------------------------                    //----------------------------------------                } else {                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE.getX(), DEATH_TILE.getY()))) {                        walkTileMM(DEATH_TILE);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE1.getX(), DEATH_TILE1.getY()))) {                        walkTileMM(DEATH_TILE1);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                }            }            if (height == 1) {                if (distanceTo(new RSTile(3226, 3224)) >= 53) {                    //thanks to alowaniak                    //credits to alowaniak                    if(isLoggedIn()) {                        openTab(TAB_MAGIC);                        wait(random(1200, 1500));                        castSomeSpell(0);                        wait(random(3000, 4000));                        if(getMyPlayer().getAnimation() != -1) {                            tries2 = 0;                            return random(20000, 22000);                        }                        else if(tries2 <= 8) {                            tries2 ++;                            return random(1000, 3000);                        }                        log("Got lost and couldn't do home tele.");                        log("Will stop script now.");                        stopAllScripts();                        return -1;                    }                    //----------------------------------------                    //----------------------------------------                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE.getX(), DEATH_TILE.getY()))) {                        walkTileMM(DEATH_TILE);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE1.getX(), DEATH_TILE1.getY()))) {                        walkTileMM(DEATH_TILE1);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                }            }            if (height == 2) {                if (distanceTo(new RSTile(3226, 3224)) >= 52) {                    //thanks to alowaniak                    //credits to alowaniak                    if(isLoggedIn()) {                        openTab(TAB_MAGIC);                        wait(random(1200, 1500));                        castSomeSpell(0);                        wait(random(3000, 4000));                        if(getMyPlayer().getAnimation() != -1) {                            tries2 = 0;                            return random(20000, 22000);                        }                        else if(tries2 <= 8) {                            tries2 ++;                            return random(1000, 3000);                        }                        log("Got lost and couldn't do home tele.");                        log("Will stop script now.");                        stopAllScripts();                        return -1;                    }                    //----------------------------------------                    //----------------------------------------                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE.getX(), DEATH_TILE.getY()))) {                        walkTileMM(DEATH_TILE);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE1.getX(), DEATH_TILE1.getY()))) {                        walkTileMM(DEATH_TILE1);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                }            }            if (height == 3) {                if (distanceTo(new RSTile(3226, 3224)) >= 52) {                    //thanks to alowaniak                    //credits to alowaniak                    if(isLoggedIn()) {                        openTab(TAB_MAGIC);                        wait(random(1200, 1500));                        castSomeSpell(0);                        wait(random(3000, 4000));                        if(getMyPlayer().getAnimation() != -1) {                            tries2 = 0;                            return random(20000, 22000);                        }                        else if(tries2 <= 8) {                            tries2 ++;                            return random(1000, 3000);                        }                        log("Got lost and couldn't do home tele.");                        log("Will stop script now.");                        stopAllScripts();                        return -1;                    }                    //----------------------------------------                    //----------------------------------------                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE.getX(), DEATH_TILE.getY()))) {                        walkTileMM(DEATH_TILE);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if(!tileOnScreen(new RSTile(DEATH_TILE1.getX(), DEATH_TILE1.getY()))) {                        walkTileMM(DEATH_TILE1);                        wait(random(300, 500));                    }                    wait(random(10500, 10700));                    if (!atTile(STAIRCASE_TILE1, "up")) {                        turnToTile(STAIRCASE_TILE1);                    }                }            }            if (height == 1 && distanceTo(new RSTile(3226, 3224)) <= 52) {                if (flaxCount() > 0 || getMyPlayer().isInCombat()) {                    if (!isInSpinningRoom()) {                        if (isDoorClosed()) {                            if (walkToTile(outsideDoor())) {                                RSObject door = getObjectAt(DOOR_CLOSE_TILE);                                if (door == null                                        || door.getID() != DOOR_CLOSE_ID) {                                    return random(200, 300);                                }                                atDoor(door, "east", "Open");                                return random(250, 300);                            }                        } else {                            walkTileMM(new RSTile((3209 + random(0,1)), (3213 - random(0,1))));                        }                    } else {                        for (int i = 0; i <= 10; i++) {                            if (getMyPlayer().getAnimation() != -1) {                                return random(150, 200);                            } else {                                wait(random(100, 150));                            }                        }                        if (flaxCount() == 0) {                            return random(150, 200);                        }                        if (RSInterface.getInterface(SPINNING_INTERFACE_ID)                                .isValid()) {                            atInterface(SPINNING_INTERFACE_ID,                                    BOW_STRING_CHILD_ID, "all");                            return random(150, 200);                        }                        RSObject spinner = findObject(SPINNING_WHEEL_ID);                        if (spinner == null) {                            return random(150, 200);                        }                        if (!atObject(spinner, "Spin Spinning Wheel")) {                            turnToTile(spinner.getLocation());                            return random(50, 100);                        }                        return random(150, 200);                    }                } else {                    if (isDoorClosed()) {                        RSObject door = getObjectAt(DOOR_CLOSE_TILE);                        if (door == null || door.getID() != DOOR_CLOSE_ID) {                            return random(200, 300);                        }                        atDoor(door, "east", "Open");                        return random(250, 300);                    }                    if (!walkToTile(staircaseTile())) {                        return random(100, 200);                    }                    if (!atTile(STAIRCASE_TILE, "up")) {                        turnToTile(STAIRCASE_TILE);                    }                }            }            if(height == 2 && distanceTo(new RSTile(3226, 3224)) <= 52) {                if (flaxCount() > 0) {                    if (!walkToTile(staircaseTile())) {                        return random(100, 200);                    }                    if (!atTile(STAIRCASE_TILE, "down")) {                        turnToTile(STAIRCASE_TILE);                    }                } else {                    if (isInBank()) {                        if (bank.getInterface().isValid()) {                            int temp = bowstringCount();                            if (bank.depositAllExcept(FLAX_ID)) {                                stringsBanked += temp;                                pause();                                pause();                                clickMouse(random(218, 238), random(95, 120), false);                                pause();                                if (!getTopText().contains("flax")) {                                    bankFail++;                                    if (bankFail >= 20) {                                        log("Banking failed. Possibly ran out of flax!");                                        wait(random(500, 1000));                                        bank.close();                                        wait(random(1050, 1200));                                         logout();                                        stopAllScripts();                                        return -1;                                    }                                    return random(350, 400);                                }                                if (atMenu("All")) {                                    bankFail = 0;                                    return random(650, 675);                                }                            }                        }                        if (!atTile(BOOTH_TILE, "Use-quickly")) {                            return random(100, 200);                        }                    } else {                        if (!isOutside1()) {                            walkToTile(bankTile());                            return random(100, 200);                        }                        if (!isOutside2()) {                            walkToTile(bankTile());                            return random(100, 200);                        }                        if (!isOutside3()) {                            walkToTile(bankTile());                            return random(100, 200);                        }                        if (!isOutside4()) {                            walkToTile(bankTile());                            return random(100, 200);                        }                        if (!isOutside5()) {                            walkToTile(bankTile());                            return random(100, 200);                        }                        walkToTile(bankTile());                        return random(100, 200);                    }                }            }        } catch (Exception e) {            e.printStackTrace();        }        return random(575, 600);    }    //thanks    //to    //alowaniak    public void openDoor(RSObject door) {            walkTileMM(door.getLocation());            setCameraRotation(random(40, 141));                    atDoor(door, "east", "Open");            }    //----------------------------------------    //----------------------------------------        //thanks    //to    //alowaniak    public void openDoor1(RSObject door) {            walkTileMM(door.getLocation());            setCameraRotation(random(40, 141));                    atDoor(door, "south", "Open");            }    //----------------------------------------    //----------------------------------------        int tries2;    public boolean castSomeSpell(int spell) {            if (getCurrentTab() != TAB_MAGIC) {            openTab(TAB_MAGIC);            return false;        }        if(spell == 19)            spell = 60;        else if(spell == 61) {            spell = 63;        } else if(spell >= 30) {                   spell--;        }        if(spell >= 64) {            return false;        }        if(!RSInterface.getInterface(192).isValid())            return false;        return atSpellInterface(spell, "cast");    }    //thanks    //to    //alowaniak    public boolean atSpellInterface(int spell, String actionContains) {        RSInterfaceChild i = RSInterface.getChildInterface(192, spell);        if (!i.isValid()) return false;        Rectangle pos = i.getArea();        if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1) return false;        moveMouse((int) random(pos.getMinX(), pos.getMaxX()), (int) random(pos.getMinY(), pos.getMaxY()));        clickMouse(true);        return true;    }    //----------------------------------------    //----------------------------------------        int string = 190;    int flax = 90;        public void onRepaint(Graphics g) {        if (isLoggedIn() && proggy == true) {            long millis = System.currentTimeMillis() - startTime;            long seconds2 = millis / 1000;            long hours = millis / (1000 * 60 * 60);            millis -= hours * 1000 * 60 * 60;            long minutes = millis / (1000 * 60);            millis -= minutes * 1000 * 60;            long seconds = millis / 1000;            String hoursString = "";            String minutesString = "";            String secondsString = seconds + "";            String type = "seconds";            if (minutes > 0) {                minutesString = minutes + ":";                type = "minutes";            }            if (hours > 0) {                hoursString = hours + ":";                type = "hours";            }            if (minutesString.length() == 1) {                minutesString = "0" + minutesString;            }            if (hoursString.length() == 1) {                hoursString = "0" + hoursString;            }            if (secondsString.length() == 1) {                secondsString = "0" + secondsString;            }            int x = 18;            int y = 18;            g.setColor(BG);            g.fill3DRect(12, 23, 360, 123, true);            g.setColor(WHITE);            g.drawString( getName() + " v" + getVersion() + " by " + getAuthor(), x, y += 20);            g.drawString("Running for " + hoursString + minutesString + secondsString + " " + type + ".", x, y += 20);            g.drawString("Profit if flax is bought: " + ((stringsBanked * string) - (stringsBanked * flax)) + ".", x, y += 20);            g.drawString("Profit if flax is picked: " + (stringsBanked * string) + ".", x, y += 20);            g.drawString("Spun " + (stringsBanked + getInventoryCount(BOW_STRING_ID)) + " flax.", x, y += 20);            if (seconds2 != 0) {                g.drawString("Averaging " + (stringsBanked + getInventoryCount(BOW_STRING_ID)) * 3600 / seconds2 + " strings per hour.", x, y += 20);            }        }    }        public void serverMessageRecieved(ServerMessageEvent e) {        String message = e.getMessage().toLowerCase();        if (message.contains("You need to wait another ")                && message.contains(" to cast this spell.")) {            int num = Integer.parseInt(message.split(" ")[5]);            logoutFor(num * 1000 * 60 * 60);        }        stringsBanked += getInventoryCount(BOW_STRING_ID);        if(message.contains("flax")) {            log("Sorry, we don't have any more have enough flax to spin. Trying again..");        }        if(message.contains("poisoned")) {            if(getPlane() == 1) {                if(canReach(STAIRCASE_TILE, true)) {                    if(!tileOnScreen(new RSTile(STAIRCASE_TILE.getX() - 1, STAIRCASE_TILE.getY()))) {                        walkTileMM(STAIRCASE_TILE);                    } else {                        atTile(STAIRCASE_TILE, "up");                    }                } else {                    openDoor(getObjectAt(DOOR_CLOSE_TILE));                    log("Opening door to avoid combat...");                }                wait(random(3*60*1000,4*60*1000));                log("Poison wore off.");            } else if(getPlane() == 2) {                if(!tileOnScreen(STAIRCASE_TILE)) {                    walkTileMM(STAIRCASE_TILE);                } else {                    atTile(STAIRCASE_TILE, "down");                }            }        }    }    public int getAngleToCoordinates(int x2, int y2) {        int x1 = getMyPlayer().getLocation().getX();        int y1 = getMyPlayer().getLocation().getY();        int x = x1 - x2;        int y = y1 - y2;        double angle = Math.toDegrees(Math.atan2(x, y));        if (x == 0 && y > 0) {            angle = 180;        }        if (x < 0 && y == 0) {            angle = 90;        }        if (x == 0 && y < 0) {            angle = 0;        }        if (x < 0 && y == 0) {            angle = 270;        }        if (x < 0 && y > 0) {            angle += 270;        }        if (x > 0 && y > 0) {            angle += 90;        }        if (x < 0 && y < 0) {            angle = Math.abs(angle) - 180;        }        if (x > 0 && y < 0) {            angle = Math.abs(angle) + 270;        }        if (angle < 0) {            angle = 360 + angle;        }        if (angle >= 360) {            angle -= 360;        }        return (int) angle;    }    public void turnToTile(RSTile tile) {        int angle = getAngleToCoordinates(tile.getX(), tile.getY());        angle = angle + random(-20, 20);        if (angle < 0) {            angle = 360 + angle;        }        if (angle >= 360) {            angle -= 360;        }        setCameraRotation2(angle);    }        public void setMaxAltitude() {          Bot.getInputManager().pressKey((char) 38);          wait(random(500,1000));          Bot.getInputManager().releaseKey((char) 38);    }    public void setCameraRotation2(int degrees) {        // Made by aftermath. Was suggested into SVN and i just added it into        // here until somebody does the right thing        char left = 37;        char right = 39;        char whichDir = left;        int start = getCameraAngle();        if (start < 180) {            start += 360;        }        if (degrees < 180) {            degrees += 360;        }        if (degrees > start) {            if (degrees - 180 < start) {                whichDir = right;            }        } else if (start > degrees) {            if (start - 180 >= degrees) {                whichDir = right;            }        }            degrees %= 360;        Bot.getInputManager().pressKey(whichDir);        int timeWaited = 0;        while (getCameraAngle() > degrees + 5 || getCameraAngle() < degrees - 5) {            wait(10);            timeWaited += 10;            if (timeWaited > 500) {                int time = timeWaited - 500;                if (time == 0) {                    Bot.getInputManager().pressKey(whichDir);                } else if (time % 40 == 0) {                    Bot.getInputManager().pressKey(whichDir);                }            }        }        Bot.getInputManager().releaseKey(whichDir);    }    public RSTile[] generatePath(RSTile tile) {        return generatePath(tile.getX(), tile.getY());    }    public RSTile[] generatePath(int destinationX, int destinationY) { // Most        // credits        // go to        // aftermath...        // I        // asked        // for a        // theory        // and        // he        // gives        // me        // the        // whole        // method.        // ~Mike        int startX = getMyPlayer().getLocation().getX();        int startY = getMyPlayer().getLocation().getY();        double dx, dy;        ArrayList<RSTile> list = new ArrayList<RSTile>();        list.add(new RSTile(startX, startY));        while (Math.hypot(destinationY - startY, destinationX - startX) > 8) {            dx = destinationX - startX;            dy = destinationY - startY;            int gamble = random(14, 17);            while (Math.hypot(dx, dy) > gamble) {                dx *= .95;                dy *= .95;            }            startX += (int) dx;            startY += (int) dy;            list.add(new RSTile(startX, startY));        }        list.add(new RSTile(destinationX, destinationY));        return list.toArray(new RSTile[list.size()]);    }    public String getTopText() {        return getMenuItems().get(0).toLowerCase();    }    RSTile current2 = null;    public boolean walkPathMM2(RSTile[] path, int maxDist) {        try {            RSTile next = nextTile(path, maxDist);            if (next != null && !next.equals(current2)) {                walkTileMM(next);                current2 = next;                return false;            } else if (next != null && next.equals(current2)) {                return false;            }        } catch (Exception e) {            return false;        }        return true;    }    public RSTile nextTile2(RSTile[] path, int maxDist) {        RSTile cur = getMyPlayer().getLocation();        for (int i = path.length - 1; i >= 0; i--) {            if (distanceBetween(cur, path[i]) <= maxDist) {                return path[i];            }        }        return null;    }}