Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.event.KeyEvent;
- import java.util.Map;
- import org.rsbot.bot.Bot;
- 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 = { "Moran429" }, category = "Woodcutting", name = "MapleChopper", version = 1.0, description = "<html><head>"
- + "</head><body>"
- + "<center>"
- + "<b><font size=\"6\" color=\"Green\">"
- + "Moran429's"
- + "<br></br>"
- + "Maple Chopper"
- + "</font></b>"
- + "<font size=\"5\">"
- + "<br></br>"
- + "<br></br>"
- + "V1.0"
- + "<br></br>"
- + "<br></br>"
- + "<i><font size=\"4\" color=\"black\">Chops and banks maples behind Seer's Village bank.</font></i>"
- + "<br></br>"
- + "<br></br>"
- + "Start the script wielding or carrying the hatchet you will use anywhere between bank and maples."
- + "<br></br>" + "</body></html>"
- )
- public class MapleChopper extends Script implements PaintListener, ServerMessageListener {
- MapleChopperAntiBan antiban;
- Thread t;
- public int profitPerLog = 34;
- public int totalProfit;
- public int lastExp;
- public int chopped;
- public int exp;
- public int xpGained;
- public int startExp;
- public long startTime = System.currentTimeMillis();
- public int bankerID [] = {};
- public int hatchetID [] = {6739,1359, 1357, 1361, 1351, 1349, 1355, 1353};
- public int mapleLogsID = 1517;
- RSObject mapleTree;
- public RSTile bankerTile = new RSTile(2724, 3493);
- public RSTile chopTile = new RSTile (2729, 3500);
- RSTile[] bankToMaples = {new RSTile(2724, 3493),
- new RSTile(2726, 3489), new RSTile(2726, 3485),
- new RSTile(2731, 3489), new RSTile(2731, 3495),
- new RSTile(2729, 3500)};
- public RSTile maplesToBank [] = reversePath(bankToMaples);
- public int speed = 16;
- public void getMouseSpeed(final int speed) {
- this.speed = speed;
- getMouseSpeed();
- }
- public boolean onStart(final Map<String, String> args){
- startTime = System.currentTimeMillis();
- log("Check the thread page for updates.");
- antiban = new MapleChopperAntiBan();
- t = new Thread(antiban);
- return true;
- }
- public void onFinish(){
- log("You chopped " + chopped + " maple logs.");
- log("That's about " + totalProfit + " gold.");
- antiban.stopThread = true;
- return;
- }
- public boolean chop(){
- mapleTree = getNearestObjectByID(1307);
- if(getMyPlayer().isMoving()){
- wait(random(500,1000));
- }
- if(mapleTree == null) {
- wait(random(300,500));
- }if(mapleTree != null){
- atTree(mapleTree, "Chop");
- wait(random(5000,10000));
- }
- return true;
- }
- public boolean deposit(){
- if(getMyPlayer().isMoving()){
- wait(random(5000,10000));
- }if(bank.isOpen()){
- bank.depositAllExcept(hatchetID);
- bank.close();
- }
- if(!bank.isOpen()){
- bank.open();
- }if(bankerID == null){
- wait(random(1000,5000));
- }
- return inventoryEmptyExcept(hatchetID);
- }
- public boolean walkToMaples(){
- if (distanceTo(chopTile) > 8) {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(bankToMaples)) {
- walkToClosestTile(bankToMaples);
- }
- }
- }
- return true;
- }
- public boolean walkToBank(){
- if (distanceTo(bankerTile) > 8) {
- if (distanceTo(getDestination()) < random(5, 12)
- || distanceTo(getDestination()) > 40) {
- if (!walkPathMM(maplesToBank)) {
- walkToClosestTile(maplesToBank);
- }
- }
- }
- return true;
- }
- public boolean atTree(final RSObject tree, final String action) {
- final RSTile loc1 = mapleTree.getLocation();
- final RSTile loc4 = new RSTile(loc1.getX() + 1, loc1.getY() + 1);
- final Point sloc1 = Calculations.tileToScreen(loc1.getX(), loc1.getY(),
- 10);
- final Point sloc2 = Calculations.tileToScreen(loc4.getX(), loc4.getY(),
- 10);
- final Point screenLoc = new Point((sloc1.x + sloc2.x) / 2,
- (sloc1.y + sloc2.y) / 2);
- if (screenLoc.x == -1 || screenLoc.y == -1) {
- return false;
- }
- moveMouse(screenLoc, 3, 3);
- return atMenu("Chop down");
- }
- @Override
- public int loop() {
- if (!t.isAlive()) {
- t.start();
- log("AntiBan initialized!");
- }if(!isInventoryFull()){
- walkToMaples();
- atTree(mapleTree, "Chop down");}
- if(isInventoryFull()){
- walkToBank();
- deposit();
- }
- return random(100,300);
- }
- private class MapleChopperAntiBan implements Runnable {
- public boolean stopThread;
- public void run() {
- while (!stopThread) {
- try {
- if (random(0, 15) == 0) {
- final char[] LR = new char[] { KeyEvent.VK_LEFT,
- KeyEvent.VK_RIGHT };
- final char[] UD = new char[] { KeyEvent.VK_DOWN,
- KeyEvent.VK_UP };
- final char[] LRUD = new char[] { KeyEvent.VK_LEFT,
- KeyEvent.VK_RIGHT, KeyEvent.VK_UP,
- KeyEvent.VK_UP };
- final int random2 = random(0, 2);
- final int random1 = random(0, 2);
- final int random4 = random(0, 4);
- if (random(0, 3) == 0) {
- Bot.getInputManager().pressKey(LR[random1]);
- Thread.sleep(random(100, 400));
- Bot.getInputManager().pressKey(UD[random2]);
- Thread.sleep(random(300, 600));
- Bot.getInputManager().releaseKey(UD[random2]);
- Thread.sleep(random(100, 400));
- Bot.getInputManager().releaseKey(LR[random1]);
- } else {
- Bot.getInputManager().pressKey(LRUD[random4]);
- if (random4 > 1) {
- Thread.sleep(random(300, 600));
- } else {
- Thread.sleep(random(500, 900));
- }
- Bot.getInputManager().releaseKey(LRUD[random4]);
- }
- } else {
- Thread.sleep(random(200, 2000));
- }
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
- @Override
- public void onRepaint(Graphics g) {
- if (isLoggedIn()) {
- if ( startExp == 0) {
- startExp = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING);
- }
- xpGained = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING) - startExp;
- 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;
- totalProfit = profitPerLog * chopped;
- g.setColor(Color.red);
- g.drawRect(35, 30, 235, 65);
- g.fillRect(35, 30, 235, 65);
- g.setFont(new Font("Bradley Hand ITC", Font.BOLD, 18));
- g.setColor(Color.green);
- g.drawString("Ran for " + hours + ":" + minutes + ":" + seconds + "." , 45, 45);
- g.drawString("Cut " + chopped + " maple logs", 45, 60);
- g.drawString("Gained " + xpGained + " experience", 45, 75);
- g.drawString("Gained about " + totalProfit + " gold", 45, 90);
- }
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent e) {
- final String message = e.getMessage();
- if (message.contains("You get some maple logs.")) {
- chopped++;
- }
- }
- }
Add Comment
Please, Sign In to add comment