ULTIMATE GUIDE

LoG iN

ULTIMATE GUIDE


    AlekzMasterChopper may be bugged

    Share

    Turk4life321
    Admin

    Posts : 41
    Join date : 2009-08-09
    Location : In Saims Room *cough*

    AlekzMasterChopper may be bugged

    Post  Turk4life321 on Fri Jan 01, 2010 4:44 am

    import java.awt.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;

    import javax.swing.JOptionPane;
    import javax.swing.JFileChooser;

    import org.rsbot.event.listeners.*;
    import org.rsbot.script.*;
    import org.rsbot.script.wrappers.*;
    import org.rsbot.event.events.ServerMessageEvent;
    import org.rsbot.event.listeners.ServerMessageListener;
    import org.rsbot.event.listeners.PaintListener;

    @ScriptManifest(authors = { "Alekz" }, category = "Woodcutting", name = "Alekz Master Chopper", version = 0.01, description = ""
    + "<html>"
    + "<body style=\"background-color:#333333;\">"
    + "<center>"
    + "<font color=\"#FFFFFF\">"
    + "Start near your selected tree, anywhere on world map."
    + "<br><br>"
    + "Tree:<br>"
    + "<select name=\"Tree\">"
    + "<option>Normal Tree</option>"
    + "<option>Oak Tree</option>"
    + "<option>Willow Tree</option>"
    + "<option>Maple Tree</option>"
    + "<option>Yew Tree</option>"
    + "</select>"
    + "<br><br>"
    /* + "Interactive paint?<br>"
    + "<select name=\"intPaint\">"
    + "<option>Yes</option>"
    + "<option>No</option>"
    + "</select>"
    + "<br><br>" */
    + "Axe in inventory?<br>"
    + "<select name=\"axeInvent\">"
    + "<option>Yes</option>"
    + "<option>No</option>"
    + "</center>"
    + "</body>"
    + "</html>")
    public class AlekzMasterChopper extends Script implements PaintListener {

    public int[] logItems = { 1511, 1521, 1519, 1517, 1515 };
    public double[] xpPerLog = { 25, 37.5, 67.5, 100, 175 };

    public int invCount, treeSelection, logArray, startLevel, startXP, state;

    private int mouseSpeed = 10;

    public long startTime;

    public boolean interactivePaint;

    public int loop() {
    if (getInventoryCount(logItems[logArray]) == invCount) {
    state = 1;
    try {
    dropAll(logItems[logArray]);
    } catch (IndexOutOfBoundsException e) {
    return 40;
    }
    }
    if (!inventoryContains(-1)) {
    dropAll(logItems[logArray]);
    state = 1;
    }

    if (getMyPlayer().getAnimation() == -1) {
    state = 2;
    cutTree();
    } else {
    if (random(5,90) > 70)
    antiBan();
    }
    return random(400,900);
    }

    public double toNearestNumber(double x) {
    double i = x;
    while (i > 1) {
    i -= 1.0;
    }
    if (i < 0.5)
    x -= i;
    else
    x += 1.0-i;

    return x;
    }

    public void antiBan() {
    int randomInt = random(1,10);
    if (randomInt > 7)
    moveMouse(random(0,762), random(0,550));
    else if (randomInt < 3)
    setCameraRotation(random(1,359));
    else if (randomInt < 5 && randomInt > 2)
    setCameraAltitude(false);
    else if (randomInt > 5 && randomInt < 6)
    setCameraAltitude(true);
    else {
    openTab(TAB_STATS);
    moveMouse(random(661, 713), random(392, 418));
    wait(random(100,300));
    }
    }

    public boolean onStart(Map <String, String> args) {
    startTime = System.currentTimeMillis();
    startLevel = skills.getCurrentSkillLevel(STAT_WOODCUTTING);
    startXP = skills.getCurrentSkillExp(STAT_WOODCUTTING);
    /*if (args.get("intPaint").equals("Yes"))
    interactivePaint = true;
    else
    interactivePaint = false;*/

    if (args.get("Tree").equals("Normal Tree"))
    logArray = 0;
    else if (args.get("Tree").equals("Oak Tree"))
    logArray = 1;
    else if (args.get("Tree").equals("Willow Tree"))
    logArray = 2;
    else if (args.get("Tree").equals("Maple Tree"))
    logArray = 3;
    else if (args.get("Tree").equals("Yew Tree"))
    logArray = 4;
    else {
    log("No tree defined, stopping script.");
    return false;
    }

    if (args.get("axeInvent").equals("Yes"))
    invCount = 27;
    else
    invCount = 28;


    try {
    log("Checking for updates");
    URLConnection url = new URL("http://alekzatrsbot.webs.com/ScriptVersions/ChopperVersion.txt").openConnection();
    BufferedReader reader = new BufferedReader(new InputStreamReader(url.getInputStream()));
    if (Double.parseDouble(reader.readLine()) > 1.75){
    log("You have an old version of the script!");
    log("Updating...please wait.");
    BufferedReader in = null;
    BufferedWriter out = null;
    JOptionPane.showMessageDialog(null, "Please choose 'AlekzMasterChopper.java' in your scripts folder and hit 'Open'");
    JFileChooser fc = new JFileChooser();
    if(fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){
    url = new URL("http://alekzatrsbot.webs.com/scripts/AlekzMasterChopper.java").openConnection();
    in = new BufferedReader(new InputStreamReader(url.getInputStream()));
    out = new BufferedWriter(new FileWriter(fc.getSelectedFile().getPath()));
    String inp;
    while((inp = in.readLine()) != null){
    out.write(inp);
    out.newLine();
    out.flush();
    }
    }
    } else {
    log("You have the latest version of the script!");
    }
    if (reader != null)
    reader.close();
    } catch (IOException e) {
    log("Problem getting version.");
    stopScript();
    }

    return true;
    }

    public void cutTree() {
    RSObject Tree = getNearestObjectByID(-1);
    int RandomInt = random(1,10);
    switch (logArray) {
    case 0:
    Tree = getNearestObjectByID(random(1276, 1280));
    break;
    case 1:
    Tree = getNearestObjectByID(random(1281, 1282));
    break;
    case 2:
    if (RandomInt > 5)
    Tree = getNearestObjectByID(5551);
    else
    Tree = getNearestObjectByID(5553);
    break;
    case 3:
    Tree = getNearestObjectByID(random(1307, 1308));
    break;
    case 4:
    Tree = getNearestObjectByID(1309);
    break;
    }
    if (Tree != null)
    atTree(Tree, "Chop down");
    else
    cutTree();

    }

    @SuppressWarnings("IndexOutOfBounds")
    public void dropAll(int item) {
    try {
    while (inventoryContains(item)) {
    atInventoryItem(item, "rop");
    wait(random(90, 170));
    }
    } catch (IndexOutOfBoundsException e) {
    ;
    }
    }

    public boolean atTree(final RSObject tree, final String action) {
    int mouseToX;
    int mouseToY;
    try {
    RSTile treeLoc = tree.getLocation();
    if (getObjectAt(treeLoc.getX()+1, treeLoc.getY()+1) == tree) {
    mouseToX = ((treeLoc.getX()+treeLoc.getX()+1)/2);
    mouseToY = ((treeLoc.getY()+treeLoc.getY()+2)/2);
    } else if (getObjectAt(treeLoc.getX()-1, treeLoc.getY()+1) == tree) {
    mouseToX = ((treeLoc.getX()+treeLoc.getX()-1)/2);
    mouseToY = ((treeLoc.getY()+treeLoc.getY()+2)/2);
    } else if (getObjectAt(treeLoc.getX()+1, treeLoc.getY()-1) == tree) {
    mouseToX = ((treeLoc.getX()+treeLoc.getX()+1)/2);
    mouseToY = ((treeLoc.getY()+treeLoc.getY()-2)/2);
    } else if (getObjectAt(treeLoc.getX()-1, treeLoc.getY()-1) == tree) {
    mouseToX = ((treeLoc.getX()+treeLoc.getX()-1)/2);
    mouseToY = ((treeLoc.getY()+treeLoc.getY()-2)/2);
    } else {
    mouseToX = treeLoc.getX();
    mouseToY = treeLoc.getY();
    }

    Point mouseMoveLoc = Calculations.tileToScreen(mouseToX, mouseToY, 10);

    if (mouseMoveLoc.x < 763 && mouseMoveLoc.x > 0
    && mouseMoveLoc.y < 503 && mouseMoveLoc.y > 0) {
    moveMouse(mouseMoveLoc.x, mouseMoveLoc.y);
    return atMenu(action);
    } else {
    wait(900);
    cutTree();
    }
    } catch (final Exception e) {
    return false;
    }
    return true;
    }

    public void onRepaint(Graphics g) {
    int X, Y;
    long gainedXP = skills.getCurrentSkillExp(STAT_WOODCUTTING)-startXP;
    long gainedLevels = skills.getCurrentSkillLevel(STAT_WOODCUTTING)-startLevel;
    long runTime = 0, hours = 0, minutes = 0, seconds = 0, xpPerHour = 0;
    long secondsToLevel = 0, minutesTillLevel = 0, hoursTillLevel = 0;
    double logsChopped = gainedXP/xpPerLog[logArray];
    runTime = System.currentTimeMillis() - startTime;
    if (gainedXP != 0) {
    xpPerHour = gainedXP * 3600 / (runTime / 1000);

    hoursTillLevel = (skills.getXPToNextLevel(STAT_WOODCUTTING)/xpPerHour);
    secondsToLevel = hoursTillLevel * 60 * 60;
    hoursTillLevel = 0;
    do {
    minutesTillLevel++;
    secondsToLevel -= 60;
    } while (secondsToLevel >= 60);
    do {
    hoursTillLevel++;
    minutesTillLevel -= 60;
    } while (minutesTillLevel >= 60);

    }

    seconds = runTime / 1000;
    if (seconds >= 60) {
    minutes = seconds / 60;
    seconds -= minutes * 60;
    }
    while (minutes >= 60) {
    hours++;
    minutes -= 60;
    }
    g.setColor(Color.WHITE);
    Point MouseLoc = getMouseLocation();
    g.drawLine(0, MouseLoc.y, 762, MouseLoc.y);
    g.drawLine(MouseLoc.x, 0, MouseLoc.x, 510);
    //if (interactivePaint == false) {
    g.setColor(new Color(255, 255, 255, 170));
    g.fillRect(550, 205, 732-550, 462-205);
    g.setColor(Color.WHITE);
    g.drawRect(550, 205, 732-550, 462-205);
    g.setColor(new Color(25, 25, 25, 255));
    X = 555;
    Y = 223;
    g.drawString("Alekz Master Chopper", X, Y);
    Y += 7;
    g.setColor(Color.WHITE);
    g.drawLine(550, Y, 732, Y);
    g.setColor(new Color(25, 25, 25, 255));
    Y += 15;
    g.drawString("Runtime: " +hours+ ":" +minutes+ ":" +seconds, X, Y);
    Y += 7;
    g.setColor(Color.WHITE);
    g.drawLine(550, Y, 732, Y);
    g.setColor(new Color(25, 25, 25, 255));
    Y += 15;
    g.drawString("Woodcutting Level: " +skills.getCurrentSkillLevel(STAT_WOODCUTTING), X, Y);
    Y += 15;
    g.drawString("Levels Gained: " +gainedLevels, X, Y);
    Y += 7;
    g.setColor(Color.WHITE);
    g.drawLine(550, Y, 732, Y);
    Y += 15;
    g.setColor(new Color(25, 25, 25, 255));
    g.drawString("Woodcutting Exp: " +skills.getCurrentSkillExp(STAT_WOODCUTTING), X, Y);
    Y += 15;
    g.drawString("Gained Exp: " +gainedXP, X, Y);
    Y += 7;
    g.setColor(Color.WHITE);
    g.drawLine(550, Y, 732, Y);
    Y += 15;
    g.setColor(new Color(25, 25, 25, 255));
    g.drawString("Exp per hour: " +xpPerHour, X, Y);
    Y += 15;
    g.drawString("Chopped: " +toNearestNumber(logsChopped), X, Y);
    Y += 15;
    g.drawString("Approx. hours until level up: " +hoursTillLevel, X, Y);
    Y += 7;
    g.setColor(Color.WHITE);
    g.drawLine(550, Y, 732, Y);
    if (state == 1) {
    g.setColor(new Color(0, 0, 0, 90));
    g.fill3DRect(562, 400, 661-500, 611-590, true);
    g.setColor(new Color(170, 0, 0, 90));
    g.fill3DRect(562, 436, 661-500, 611-590, true);
    g.setColor(Color.WHITE);
    g.drawString("Chopping...", 612, 415);
    g.drawString("Dropping...", 612, 451);
    } else if (state == 2) {
    g.setColor(new Color(170, 0, 0, 90));
    g.fill3DRect(562, 400, 661-500, 611-590, true);
    g.setColor(new Color(0, 0, 0, 90));
    g.fill3DRect(562, 436, 661-500, 611-590, true);
    g.setColor(Color.WHITE);
    g.drawString("Chopping...", 612, 415);
    g.drawString("Dropping...", 612, 451);
    } else {
    g.setColor(new Color(0, 0, 0, 90));
    g.fill3DRect(562, 400, 661-500, 611-590, true);
    g.setColor(new Color(0, 0, 0, 90));
    g.fill3DRect(562, 436, 661-500, 611-590, true);
    g.setColor(Color.WHITE);
    g.drawString("Chopping...", 612, 415);
    g.drawString("Dropping...", 612, 451);
    }
    //}
    }

    }

      Current date/time is Sat Nov 18, 2017 3:17 pm