Famous Scripts
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Scripts for RSBot made by Famous
 
HomePortalLatest imagesRegisterLog in
New scripts being created everyday! Go to GameKiller.net!

 

 TnTOaksChopper! [FAST & FLAWLESS!]

Go down 
AuthorMessage
PkerThatOwnz




Posts : 1
Join date : 2010-06-19

TnTOaksChopper! [FAST & FLAWLESS!] Empty
PostSubject: TnTOaksChopper! [FAST & FLAWLESS!]   TnTOaksChopper! [FAST & FLAWLESS!] EmptySat Jun 19, 2010 1:49 pm

TnTOaksChopper! [Fast & Flawless!]

NOTE: DO NOT OVERNIGHT THIS script, I REPEAT, DO NOT OVERNIGHT THIS script!

As this is one of my newest scripts, I don't think that this script is strong enough for overnighting, I will remove this notice once I have tested it(overnighted it) and when I think that the script is flawless and strong enough for overnighting.

Please post your progress reports and I'll add them here!



NEARLY 6 HOUR PROGRESS REPORT!!
TnTOaksChopper! [FAST & FLAWLESS!] Proggyy




TnTOaksChopper! [FAST & FLAWLESS!] 1276792661
TnTOaksChopper! [FAST & FLAWLESS!] 1276792725



Thanks to Miksuking for suggesting this script.


If you have any encountered any bugs, please post them here.

The script should be started in Varrock West Bank or the Oak chopping area near it. NOTE: It will not walk to any of those 2 areas by itself! So please start at the places I have told you above!



If anyone wants to update or fix the script, or use any of my code, please ask me first and then do so. Thank you.

Update log:
Code:
V1.0: Released script.


V1.1: Fixed misclicks.


V1.2: Fixed the NPC behind door bug, fixed the Failing to notice new tree bug.

Due to many people asking me, I've finally added this:
SAVE IT AS "TnTOaksChopper.java", YES, IT MUST BE EXACTLY THE SAME WAY AS IT IS WRITTEN THERE.
Either get the script here:
http://www.pastie.org/1007708.txt

Or here:
Code:
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.text.DecimalFormat;
import java.util.Map;

import org.rsbot.accessors.Model;
import org.rsbot.accessors.RSAnimable;
import org.rsbot.bot.Bot;
import org.rsbot.bot.input.Mouse;
import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.event.listeners.ServerMessageListener;
import org.rsbot.script.Calculations;
import org.rsbot.script.Constants;
import org.rsbot.script.script;
import org.rsbot.script.scriptManifest;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;

@scriptManifest(authors = { "PkerThatOwnz, Gribonn53" }, category = "Woodcutting", name = "TnTOaksChopper", version = 1.2, description = ("[/b][b][size=29]TnTOakChopper made by PkerThatOwnz![/size][/b][b]"
        + "[/b][b]Start the script at Varrock West Bank or near the Oaks![/b][b]"))
public class TnTOaksChopper extends script implements PaintListener,
        ServerMessageListener {

    public int[] axeID = { 1349, 1351, 1353, 1355, 1357, 1359, 1361, 6739,
            13470 };
    public RSTile[] treesToBank = { new RSTile(3169, 3423),
            new RSTile(3175, 3428), new RSTile(3185, 3430),
            new RSTile(3182, 3436) };
    public RSTile[] bankToTrees = reversePath(treesToBank);
    public RSTile bankTile = new RSTile(3182, 3436);
    public RSTile treeTileNW = new RSTile(3158, 3422);
    public RSTile treeTileSE = new RSTile(3171, 3409);
    public RSTile treeTile = new RSTile(3169, 3423);
    public int oakID = 1281;
    public int oaksChopped;
    public int nextrandomenergy;
    public int[] bankBooth = { 11402 };

    protected int getMouseSpeed() {
        return random(3, 5);
    }

    public boolean onStart(Map args) {
        log("Thank you for using my script! :D");
        nextrandomenergy = random(35, 50);
        y = 4;
        yMenu = 28;
        paintTop = true;
        // checkUpdate();
        startTime = System.currentTimeMillis();
        setCameraAltitude(false);
        return true;
    }

    public int antiBan() {
        final int gamble = random(1, 15);
        final int x = random(0, 750);
        final int y = random(0, 500);
        final int xx = random(554, 710);
        final int yy = random(230, 444);
        final int screenx = random(1, 510);
        final int screeny = random(1, 450);
        switch (gamble) {
        case 1:
            return random(500, 750);
        case 2:
            moveMouse(x, y);
            return random(500, 750);
        case 3:
            openTab(Constants.TAB_INVENTORY);
            return random(200, 400);
        case 4:
            if (getMyPlayer().isMoving()) {
                return random(750, 1000);
            }
        case 5:
            moveMouse(x, y);
            int checkTime = 0;
            long lastCheck = 0;
            if (System.currentTimeMillis() - lastCheck >= checkTime) {
                lastCheck = System.currentTimeMillis();
                checkTime = random(60000, 180000);
            }
        case 6:
            if (getCurrentTab() != Constants.TAB_STATS) {
                openTab(Constants.TAB_STATS);
                moveMouse(xx, yy);
                return random(500, 800);
            }
        case 7:
            if (random(1, 8) == 2) {
                int angle = getCameraAngle() + random(-90, 90);
                if (angle < 0) {
                    angle = 0;
                }
                if (angle > 359) {
                    angle = 0;
                }
                setCameraRotation(angle);
            }
            return random(500, 750);
        case 8:
            moveMouse(screenx, screeny);
            return random(100, 320);
        case 9:
            moveMouse(screenx, screeny);
            return random(100, 320);
        case 10:
            randomTab();
            wait(random(4000, 6000));
            return random(120, 250);
        case 11:
            wait(random(4000, 6000));
            moveMouse(screenx, screeny);
            return random(100, 320);
        case 12:
            wait(random(4000, 6000));
            moveMouse(screenx, screeny);
            return random(100, 320);
        case 13:
            wait(random(4500, 7000));
            moveMouse(screenx, screeny);
            return random(100, 320);
        }
        return random(500, 750);

    }

    public int randomTab() {
        final int random1 = random(1, 23);
        switch (random1) {
        case 1:
            openTab(Constants.TAB_STATS);
            return random(100, 500);
        case 2:
            openTab(Constants.TAB_ATTACK);
            return random(100, 500);
        case 3:
            openTab(Constants.TAB_QUESTS);
            return random(100, 500);
        case 4:
            openTab(Constants.TAB_EQUIPMENT);
            return random(100, 500);
        case 5:
            openTab(Constants.TAB_INVENTORY);
            return random(100, 500);
        case 6:
            openTab(Constants.TAB_PRAYER);
            return random(100, 500);
        case 7:
            openTab(Constants.TAB_MAGIC);
            return random(100, 500);
        case 8:
            openTab(Constants.TAB_SUMMONING);
            return random(100, 500);
        case 9:
            openTab(Constants.TAB_FRIENDS);
            return random(100, 500);
        case 10:
            openTab(Constants.TAB_IGNORE);
            return random(100, 500);
        case 11:
            openTab(Constants.TAB_CLAN);
            return random(100, 500);
        case 12:
            openTab(Constants.TAB_CONTROLS);
            return random(100, 500);
        case 13:
            openTab(Constants.TAB_MUSIC);
            return random(100, 500);
        case 14:
            openTab(Constants.TAB_OPTIONS);
            return random(100, 500);
        }
        return random(100, 300);

    }

    @Override
    public int loop() {
        setCameraAltitude(true);
        if (getEnergy() > nextrandomenergy) {
            setRun(true);
            nextrandomenergy = random(35, 50);
        }
        if (isInventoryFull()) {
            if (atBank()) {
                status = "Banking";
                useBank();
            } else {
                status = "Walking to bank";
                walk(treesToBank);
                useBank();
            }
        } else {

            if (atTree()) {
                status = "Chopping";
                chopping();
            } else {
                status = "Walking to trees";
                walk(bankToTrees);
                chopping();
            }

        }
        return random(50, 150);
    }

    public boolean atBank() {
        return distanceTo(bankTile) <= 5;
    }

    public boolean atTree() {
        return isInArea(treeTileNW, treeTileSE);
    }

    private boolean isEmpty() {
        return getInventoryCount() == 0;
    }

    public boolean isInArea(RSTile NW, RSTile SE) {
        final int playerX = getMyPlayer().getLocation().getX();
        final int playerY = getMyPlayer().getLocation().getY();
        return playerX >= NW.getX() && playerX <= SE.getX()
                && playerY >= SE.getY() && playerY <= NW.getY();
    }
   
    boolean clickObjectTree(RSObject obj1,String action) {
          if (!(obj1.getObject() instanceof RSAnimable)) {
              return atTree(obj1, action);
          }else{
              moveMouse(getModelPoint(obj1), 3, 3);
              return atMenu(action);
          }
    }
   
    private Point getModelPoint(RSObject obj) {
        Model model = obj.getModel();
        RSAnimable animable = (RSAnimable) obj.getObject();
        Point[] screenCoords = new Point[model.getXPoints().length];
        for (int i = 0; i < screenCoords.length; i++) {
            int x = model.getXPoints()[i] + animable.getX();
            int z = model.getZPoints()[i] + animable.getY();
            int y = model.getYPoints()[i]
                    + Calculations.tileHeight(animable.getX(), animable.getY());
            screenCoords[i] = Calculations.w2s(x, y, z);
        }
        return screenCoords[random(0, screenCoords.length)];
    }

    public boolean chopping() {
        if (getMyPlayer().getAnimation() == -1) {
            final RSObject Tree = getNearestObjectByID(oakID);
            if (Tree != null) {
                if (distanceTo(Tree) <= 5) {
                    at4Tiles(Tree, "Chop");
                } else {
                    walkTo(Tree.getLocation());
                }
            }
        } else {
            antiBan();
        }
        return true;

    }

    public int walk(RSTile[] path) {
        if (distanceTo(getDestination()) < random(5, 12)
                || distanceTo(getDestination()) > 40) {
            if (!walkPathMM(path)) {
                walkToClosestTile(randomizePath(path, 2, 2));
                return random(100, 200);
            }
        }
        return 0;
    }

    public boolean at4Tiles(RSObject obj, String action) {
        RSTile map[][] = new RSTile[5][5];
        for (int x = 0; x < 4; x++) {
            for (int y = 0; y < 4; y++) {
                RSObject fObj = getObjectAt(obj.getLocation().getX() - 2 + x,
                        obj.getLocation().getY() - 2 + y);
                if (fObj != null && fObj.getID() == obj.getID()) {
                    map[x][y] = fObj.getLocation();
                }
            }
        }
        RSTile tTile = null;
        int tx = 0;
        int ty = 0;
        for (int x = 0; x <= 3; x++) {
            for (int y = 0; y <= 3; y++) {
                if (map[x][y] != null && map[x + 1][y] != null
                        && map[x][y + 1] != null && map[x + 1][y + 1] != null) {
                    if (map[x][y].equals(obj.getLocation())
                            || map[x + 1][y].equals(obj.getLocation())
                            || map[x][y + 1].equals(obj.getLocation())
                            || map[x + 1][y + 1].equals(obj.getLocation())) {
                        tTile = map[x][y];
                        tx = x;
                        ty = y;
                        break;
                    }
                }
            }
        }

        if (tTile == null) {
            return false;
        }
        int xSum = 0;
        int ySum = 0;

        for (int x = 0; x <= 1; x++) {
            for (int y = 0; y <= 1; y++) {
                xSum += (int) map[tx + x][ty + y].getScreenLocation().getX();
                ySum += (int) map[tx + x][ty + y].getScreenLocation().getY();
            }
        }
        moveMouse(xSum / 4 + random(-2, 2), ySum / 4 + random(-2, 2));
        return atMenu(action);
    }

    private boolean useBank() {

        if (!isEmpty()) {
            bank.depositAllExcept(axeID);
        }

        final RSObject banker = getNearestObjectByID(bankBooth);
        if (banker != null) {
            if (distanceTo(banker.getLocation()) <= 7) {
                if (bank.isOpen()) {
                    bank.depositAllExcept(axeID);
                    wait(random(150, 250));
                } else {
                    bank.open();
                    wait(random(150, 250));
                }
            } else {
                if (getEnergy() >= nextrandomenergy) {
                    setRun(true);
                }
                if (distanceTo(getDestination()) < random(5, 12))
                    ;

                return true;
            }
        }
        return true;
    }

    // Paint stuff
    public DecimalFormat df = new DecimalFormat("#");
    public boolean showPaint = true, showAveraging, showGained, showStatInfo,
            paintTop = true, added = false, end = false;
    public int startXP;
    public long startTime;
    public int oakXP;
    public int y;
    public int yMenu;
    public int oaksHour;
    public int levelsGained;
    public int oaks = 0;
    public String status;

    @Override
    public void onRepaint(Graphics g) {
        ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        if (showPaint == true) {
            if (isLoggedIn()) {
                int xpGained = 0;
                if (startXP == 0) {
                    startXP = skills
                            .getCurrentSkillExp(Constants.STAT_WOODCUTTING);
                }
                int xpLeft = skills
                        .getXPToNextLevel(Constants.STAT_WOODCUTTING);
                xpGained = skills
                        .getCurrentSkillExp(Constants.STAT_WOODCUTTING)
                        - startXP;
                long millis = System.currentTimeMillis() - startTime;
                long hours = millis / (1000 * 60 * 60);
                millis -= hours * (1000 * 60 * 60);
                long minutes = millis / (1000 * 60);
                millis -= minutes * (1000 * 60);
                long seconds = millis / 1000;
                float xpsec = 0;
                if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
                    xpsec = ((float) xpGained)
                            / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
                }
                float xpmin = xpsec * 60;
                float xphour = xpmin * 60;
                final int oaksHour = (int) ((oakID) * 3600000D / (System
                        .currentTimeMillis() - startTime));
                g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
                if (showGained == true) {
                    if (paintTop) {
                        g.setColor(new Color(0, 0, 0, 150));
                        g.fillRoundRect(200, yMenu, 150, 82, 0, 0);
                        g.setColor(Color.white);
                        g.drawString("XP Gained: " + xpGained, 208, yMenu + 18);
                        g.drawString("Levels Gained: " + levelsGained, 208,
                                yMenu + 36);
                        g
                                .drawString(
                                        "Current level: "
                                                + skills
                                                        .getCurrentSkillLevel(Constants.STAT_WOODCUTTING),
                                        208, yMenu + 54);
                        g.drawString("Oaks chopped: " + oaksChopped, 208,
                                yMenu + 72);
                    } else {
                        g.setColor(new Color(0, 0, 0, 150));
                        g.fillRoundRect(200, yMenu - 18, 150, 82, 0, 0);
                        g.setColor(Color.white);
                        g.drawString("XP Gained: " + xpGained, 208, yMenu);
                        g.drawString("Levels Gained: " + levelsGained, 208,
                                yMenu + 18);
                        g
                                .drawString(
                                        "Current level: "
                                                + skills
                                                        .getCurrentSkillLevel(Constants.STAT_WOODCUTTING),
                                        208, yMenu + 36);
                        g.drawString("Oaks chopped: " + oaksChopped, 208,
                                yMenu + 54);
                    }
                }
                if (showAveraging == true) {
                    g.setColor(new Color(0, 0, 0, 150));
                    g.fillRoundRect(286, yMenu, 200, 64, 0, 0);
                    g.setColor(Color.white);
                    g.drawString("Time running: " + hours + ":" + minutes + ":"
                            + seconds, 294, yMenu + 18);
                    g.drawString("XP Hour: " + (int) xphour, 294, yMenu + 36);
                    g.drawString("Oaks/Hour: " + oaksHour, 294, yMenu + 54);
                }
                final int percent = skills
                        .getPercentToNextLevel(Constants.STAT_WOODCUTTING);
                g.setColor(new Color(0, 0, 0, 150));
                g.fillRoundRect(4, y, 511, 24, 0, 0);
                g.setColor(Color.white);
                g.draw3DRect(4, y, 511, 24, true);
                g.setColor(new Color(149, 7, 17, 200));
                g.fillRoundRect(7, y + 2, 100, 20, 0, 0);
                g.setColor(new Color(0, 79, 0, 200));
                g.fillRoundRect(7, y + 2, percent, 20, 0, 0);
                g.setColor(Color.black);
                g.drawRect(7, y + 2, 100, 20);
                g.setColor(Color.white);
                g.drawString(percent + "% Done", 117, y + 17);
                g.draw3DRect(200, y, 1, 24, true);
                g.drawString("Gained", 220, y + 17);
                g.draw3DRect(285, y, 1, 24, true);
                g.drawString("Averaging", 305, y + 17);
                g.draw3DRect(390, y, 1, 24, true);
                g.setFont(new Font("Trebuchet MS", Font.BOLD, 14));
                g.drawString("" + status, 400, y + 17);
                if (showStatInfo == true) {
                    g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
                    int oaksTillNextLevel = 0;
                    Mouse m = Bot.getClient().getMouse();
                    if (oakXP != 0) {
                        oaksTillNextLevel = Integer.parseInt(df.format(xpLeft
                                / oakXP));
                        if ((xpLeft / oakXP) > oaksTillNextLevel) {
                            oaksTillNextLevel += 1;
                        }
                    }
                    g.setColor(new Color(0, 0, 0, 205));
                    if (paintTop) {
                        g.fillRect(m.x, m.y, 200, 115);
                        g.setColor(Color.white);
                        g.drawString("WOODCUTTING", m.x + 15, m.y + 30);
                        g
                                .drawString(
                                        "Level: "
                                                + skills
                                                        .getCurrentSkillLevel(Constants.STAT_WOODCUTTING),
                                        m.x + 15, m.y + 45);
                        g
                                .drawString(
                                        "Xp: "
                                                + skills
                                                        .getCurrentSkillExp(Constants.STAT_WOODCUTTING),
                                        m.x + 15, m.y + 60);
                        g.drawString("Xp Till Next level: " + xpLeft, m.x + 15,
                                m.y + 75);
                        g
                                .drawString(
                                        "% Till Next Level: "
                                                + skills
                                                        .getPercentToNextLevel(Constants.STAT_WOODCUTTING),
                                        m.x + 15, m.y + 90);
                        g.drawString("Oaks Till Next Level: "
                                + oaksTillNextLevel, m.x + 15, m.y + 105);
                    } else {
                        g.fillRect(m.x, m.y - 115, 200, 115);
                        g.setColor(Color.white);
                        g.drawString("WOODCUTTING", m.x + 15, m.y - 90);
                        g
                                .drawString(
                                        "Level: "
                                                + skills
                                                        .getCurrentSkillLevel(Constants.STAT_WOODCUTTING),
                                        m.x + 15, m.y - 75);
                        g
                                .drawString(
                                        "Xp: "
                                                + skills
                                                        .getCurrentSkillExp(Constants.STAT_WOODCUTTING),
                                        m.x + 15, m.y - 60);
                        g.drawString("Xp Till Next level: " + xpLeft, m.x + 15,
                                m.y - 45);
                        g
                                .drawString(
                                        "% To Next Level: "
                                                + skills
                                                        .getPercentToNextLevel(Constants.STAT_WOODCUTTING),
                                        m.x + 15, m.y - 30);
                        g.drawString("Oaks Till Next Level: "
                                + oaksTillNextLevel, m.x + 15, m.y - 15);
                    }
                }
                Mouse m = Bot.getClient().getMouse();
                if (m.x >= 200 && m.x < 200 + 85 && m.y >= y && m.y < y + 24) {
                    showGained = true;
                } else {
                    if (end == false) {
                        showGained = false;
                    }
                }
                if (m.x >= 286 && m.x < 286 + 105 && m.y >= y && m.y < y + 24) {
                    showAveraging = true;
                } else {
                    showAveraging = false;
                }
                if (m.x >= 7 && m.x < 7 + 100 && m.y >= y + 2
                        && m.y < y + 2 + 20) {
                    showStatInfo = true;
                } else {
                    showStatInfo = false;
                }
            }
            if (oakXP == 0
                    && !added
                    && skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING)
                            - startXP != 0) {
                oakXP = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING)
                        - startXP;
                added = true;
            }
        }
    }

    public void onFinish() {
        log("Sell your oaks and get some $$$!");
        long millis = System.currentTimeMillis() - startTime;
        long hours = millis / (1000 * 60 * 60);
        millis -= hours * (1000 * 60 * 60);
        long minutes = millis / (1000 * 60);
        millis -= minutes * (1000 * 60);
        long seconds = millis / 1000;

    }

    @Override
    public void serverMessageRecieved(final ServerMessageEvent e) {
        final String serverString = e.getMessage();
        if (serverString.contains("You get some")) {
            oaksChopped++;
        }
        if (serverString.contains("You've just advanced")) {
            levelsGained++;
        }

    }

}

Known bugs:
1. Wanders off into Varrock.
2. Sometimes misclicks normal trees(Don't worry, it banks them too).



Credits:

35% to gribonn53 for EVERYTHING!
60% to me for making the script.
5% to pk purewcer for helping me out with some of my problems.


Progress Reports:
TnTOaksChopper! [FAST & FLAWLESS!] 2i0t81s
TnTOaksChopper! [FAST & FLAWLESS!] 10wpgy1
TnTOaksChopper! [FAST & FLAWLESS!] E1ap13


Donations are appreciated!

Please donate to Haris_Toffic@hotmail.com
Back to top Go down
 
TnTOaksChopper! [FAST & FLAWLESS!]
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Famous Scripts :: Scripts :: Woodcutting-
Jump to: