All pastes #278277 Raw Edit

Mine

public text v1 · immutable
·published 2006-12-13 23:19 UTC
rendered paste body
import impsoft.nexus.bots.arga.methods.ArgaRandom;
import impsoft.nexus.bots.arga.scriptsobjects.GroundItem;
import impsoft.nexus.bots.arga.scriptsobjects.Tile;

public class AxeHead extends ArgaRandom {
    public static final int[] axeTypesGround = new int[] { 509, 511, 513, 515,
            517, 519, 521, 6744 }; // Subtract one for inventory

    public static final int[] pickTypesGround = new int[] { 481, 483, 485, 487,
            489, 491 };

    public static final int pickHandle = 466;

    public static final int axeHandle = 492;

    int idx = -1;

    boolean axe = false;

    Tile target = null;

    int type = -1;

    int progress = 0;

    @Override
    public boolean startUp() {
        for (int i : getInventoryArray()) {
            if (i == pickHandle || i == axeHandle) {
                log("Lost an axe/pick head! Activating random!");
                idx = i;
                axe = (i == axeHandle);
                progress = 0;
                return true;
            }
        }
        return false;
    }

    @Override
    public void random() throws InterruptedException {
        int sleep = 0;
        while ((sleep = ARGARANDOMWRAPPER()) != -1) {
            sleep(sleep);
        }
    }

    public int ARGARANDOMWRAPPER() throws InterruptedException {
        if (target == null) {
            if (axe) {
                GroundItem[] found = getGroundItemsByType(axeTypesGround);
                if (found != null && found.length > 0) {
                    target = found[0].getPosition();
                    log("Axe head found: " + found[0].getPosition());
                    type = found[0].getID() - 1;
                }
            } else {
                GroundItem[] found = getGroundItemsByType(pickTypesGround);
                if (found != null && found.length > 0) {
                    target = found[0].getPosition();
                    log("Pick head found: " + found[0].getPosition());
                    type = found[0].getID() - 1;
                }
            }
        } else {
            switch (progress) {
            case 0:
                for (int i = 0; i < getInventoryArray().length; i++) {
                    if (getInventoryArray()[i] == type) {
                        log("Entering phase 2: Reattachal!");
                        progress++;
                        return 500;
                    }
                }
                Tile tonscreen = tileToScreen(target, 0);
                log("Target: " + tonscreen);
                if (tonscreen.x < 5 || tonscreen.y < 5) {
                    log("Shit its off the screen, will figure walking later...");
                    log("Exiting..");
                    return -1;
                }
                clickAction(tonscreen, "Take");
                return random(500, 1000);
            case 1:
                log("Would reattach right here");
                return -1;
            }
        }
        return -1;
    }

}