All pastes #1721790 Raw Edit

dayan

public text v1 · immutable
#1721790 ·published 2009-12-20 22:50 UTC
rendered paste body
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.awt.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.*;
import java.util.List;
import java.util.logging.Level;
import javax.accessibility.*;
import javax.swing.*;

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.*;
import org.rsbot.script.Calculations;
import org.rsbot.script.Constants;
import org.rsbot.script.Script;
import org.rsbot.script.GEItemInfo;
import org.rsbot.script.ScriptManifest; 
import org.rsbot.script.wrappers.*;
import org.rsbot.script.wrappers.RSInterface;
import org.rsbot.script.wrappers.RSInterfaceChild;
import org.rsbot.script.wrappers.RSInterfaceComponent;
import org.rsbot.script.wrappers.RSItemTile;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.util.ScreenshotUtil;


@ScriptManifest(authors = {"Christian133"}, category = "Mining", name = "RuniteDestroyer", version = 1.00,
description = "<html>" +
"<head>" +
"<style type=\"text/css\"> hr {color: sienna} p {margin-left: 20px} body {background-image: url(\"http://i40.tinypic.com/2je4pyp.jpg\")}</style>" +
"</head>" +
"<body>" +
"<center>" +
"<body color=red>" +
"<font color=red>" +
"<h2><font color=red>Runite Destroyer v" + 1.00 + "</h2><br>" +
"<b><font color=red>Author: </b>" + "<font color=red>Christian133<br>\n" +
" <h1><font color=red>Don't get banned =)</h1>" +
"<font color=red>Start script in Keldagrim Bank with pick equiped or this wont work!<br>" +
"<br>" +
"<font color=red>Disable the Break Handler, this bot takes 5-10min breaks after every 60-90 min.<br>" +
"<br>" +
"<font color=red>Options:  " +
"<b><font color=red>&nbsp;&nbsp;&nbsp;Timeout: </b><input type=\"text\" name=\"timeout\" value=\"3000\"/>(Increase this if there are any problems)<br>" +
"<b><font color=red>Antiban value: </b><br>" +
"<input type=\"text\" name=\"AntiBan\" value=\"750\"><br>" +
"<b><font color=red>Multiplier value</b><br>" +
"<input type=\"text\" name=\"Multiplier\" value=\"45\"><br>" +
"</center>" +
"</body>" +
"</html>")

public class RuniteDestroyer extends Script implements PaintListener, ServerMessageListener {

  private final ScriptManifest scriptInfo = getClass().getAnnotation(ScriptManifest.class);

  //////////////////////////////////////////////
      //////CONTROLS HOW FAR THE MOUSE GOES SEARCHING!
      public int Multiplier = 45;
      /////////CONTROLS HOW OFTEN THE ANTIBAN ACTIVATES
      /////////BIGGER NUMBER = LESS OFTEN.  KEEP IT OVER 12
      public int AntibanControl = 750;
      //////////////////////////////////////////////

  private int runite1Available = 45069;
  private int runite2Available = 45070;
  private int runiteGone = 37700;
  public int bankBooth = 6084;
  private RSTile bankSpot = new RSTile(2838,10207);
  private RSTile mineSpot = new RSTile(2871,10260);
  public boolean breakingOn = false;
  public boolean hasBroke = false;
  public long breakTime = 0;
  private int timeout = 3000;
  private int runiteCount = 0;
  private int rubyCount = 0;
  private int diamondCount = 0;
  private int sapphireCount = 0;
  private int emeraldCount = 0;
  private RSTile bankTile = null;
  private RSTile mineTile = null;
  public int numMined = 0;
  public int String = 451;
//On start  

  public boolean onStart(Map<String, String> args) {
    if(!isLoggedIn()) {
      login();
      int i=0;
      while(!isLoggedIn()&& i<=50){
        wait(1000);
        i++;
      }
      if(!isLoggedIn()){
        return false;
      }
    }
    AntibanControl = Integer.parseInt(args.get("AntiBan"));
    timeout = Integer.parseInt(args.get("timeout"));
    return true;
  }

//On Finish  

  public void onFinish() {
    Bot.getEventManager().removeListener(PaintListener.class, this);
    Bot.getEventManager().removeListener(ServerMessageListener.class, this);
    ScreenshotUtil.takeScreenshot(true);
    log("Mined: " + numMined);
  }  


//bankNow

  public boolean bankNow() {  
        if (distanceTo(bankSpot) > 10)
      walkTileMM(bankSpot);  

    RSObject banker=getNearestObjectByID(bankBooth);
    if(banker!=null){
      atObject(banker,"Use-quickly");
    }

    if (!bank.isOpen()) {
          wait(random(100, 200));
          int failCount = 0;
          while (!bank.isOpen() && failCount < 20) {
            wait(random(50, 100));
            failCount++;
          }
          if(failCount>19){
            return true;
          }
    } 
    if (bank.isOpen()) {

      bank.depositAll();
    }
    return false;
    }

//Mine Now(Item Number)

  public boolean mineNow(int rockID) {
    RSObject rockToMine=getNearestObjectByID(rockID);
    if(rockToMine==null) {
      return false;
    } else {
      atObject(rockToMine,"Mine");
      return true;
    }   
  }

// goToBank()

  public boolean goToBank() {
    walkTo(bankSpot);
    return true;
  }

// goToMine()

  public boolean goToMine() {
    walkTo(mineSpot);
    return true;
  }

// atBank()?

  public boolean atBank() {
    if (distanceTo(bankSpot) >= 6) {
      return false;
    } else if (distanceTo(bankSpot) >= 1) {
      walkTo(bankSpot);
      wait(random(3000,5000));//215
      if(atBank()){
        return true;
      }
      return true;
    } else {
      return true;
    }
  }

//atMine()?

  public boolean atMine() {
    if (distanceTo(mineSpot) >= 6) {
      return false;
    } else if (distanceTo(mineSpot) >= 1) {
      return true;
    }
    return true;
  }

// check animation

  public boolean CheckAnimation() {
          for (int i = 0; i < 5; i++) {
              if (getMyPlayer().getAnimation() != -1) {
                  return true;
              }
            wait(random(80, 180));
          }
          return false;
  }

// check if inventory is full

  public boolean isFull(){
    if (getInventoryCount() < 28){
      return false;
    } else {
      return true;
    }
  }

// hopWorlds() needs to be stolen

  public boolean worldHop() {

                wait(random(1000, 2000));

                if (isLoggedIn()) {
                        logout();
                        while (isLoggedIn()) {
                                wait(random(200, 400));
                        }
                }
                final int x = random(345, 415);
                final int y = random(242, 250);

                moveMouse(x, y);
                wait(random(100, 200));
                if (mouseInArea(453, 250, 307, 237)) {
                        clickMouse(true);
                } else {
                        worldHop();
                }

                wait(random(1000, 2000));

                final int x2 = random(84, 296);
                final int y2 = random(148, 450);

                moveMouse(x2, y2);
                wait(random(100, 200));
                clickMouse(true);
                wait(random(100, 200));

                boolean didWeLogIn = true;

                if (RSInterface.getInterface(744).getChild(468).isValid()) {

                        final String RSText = RSInterface.getInterface(744).getChild(468).getText();

                        if (RSText.equals("World 1")) {
                                didWeLogIn = false;
                        } else if (RSText.equals("World 2")) {
                                didWeLogIn = false;
                        } else if (RSText.equals("World 3")) {
                                didWeLogIn = false;
                        } else if (RSText.equals("World 144")) {
                                didWeLogIn = false;
                        } else if (RSText.equals("World 44")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 65")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 26")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 86")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 124")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 18")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 72")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 137")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 136")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 57")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 32")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 21")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 17")) {
                                didWeLogIn = false;
                        } else if (RSText.equals("World 31")) {
                                didWeLogIn = false;
                        } else if (RSText.equals("World 9")) {
                                didWeLogIn = false;
                        } else if (RSText.equals("World 6")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("PvP")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 113")) {
                                didWeLogIn = false;
                        } else if (RSText.contains("World 114")) {
                                didWeLogIn = false;
                        }

                        if (!didWeLogIn) {
                                return worldHop();
                        }
                }
                return isLoginScreen();
        }

//Checks Mouse Location

  public boolean mouseInArea(int x, int y, int xx, int yy) {
    int x3 = input.getX();
    int y3 = input.getY();

    if (x3 < x && x3 > xx && y3 < y && y3 > yy) {
      return true;
    } else {
      return false;
    }
  }

// checkForRocks() returns rock id or -1  

  public int checkForRocks() {
    RSObject rocky = getNearestObjectByID(runite1Available);
    if(rocky == null){
      rocky = getNearestObjectByID(runite2Available);
      if(rocky == null){
        return -1;
      } else {
        return runite2Available;
      }
    } else {
      return runite1Available;
    }
  }

//Check size of an array

  public int getSize(RSItem[] a) {
    RSItem test = a[0];
    int sizeOfArray = 0;
    if(test!=null){
      while (test!=null) {
        sizeOfArray++;
        test=a[(sizeOfArray)];  
      }
      return (sizeOfArray+1);
    }
    return sizeOfArray;
  }

// loop here goes nothin

  public int loop() {

    if(!isLoggedIn()) {
      return random(2500,3000);
    }
    if (isFull()){
      if(goToBank()){
        if(bankNow()){
          return random(100,300);
        } else {
          wait(1000);
          return random(150,500);
        }
      } else { 
        wait(1000);
        return random(500,800);
      }
    } else if(atMine()) {
      int rockNum = checkForRocks();
      if(rockNum == -1) {
        if (worldHop()) {
          wait(random(1000,2000));
          return random(400,800);
        } else {
          return random(250,600);
        }
      } else {
        if(mineNow(rockNum)) {
          wait(2000);
          int timeWaited=0;
          while(CheckAnimation()&& timeWaited <= random(25,45)){
            wait(1000);
            timeWaited++;
          }
          return random(670,1080);
        }
        return random(560,1280);
      }
    } else if(goToMine()) {
      return random(400,800);
    } else {
      return random(300,599);
    }
  //Thats all i can think of...
  }

// if i get a server message...

   public void serverMessageRecieved(final ServerMessageEvent arg0) {
          final String serverString = arg0.getMessage();
          if (serverString.toLowerCase().contains("level to use")) {
                log("No pick?");
                logout();

          }
          if (serverString.toLowerCase().contains("ruby")) {
                rubyCount++;
          }
    if (serverString.toLowerCase().contains("emerald")) {
                emeraldCount++;
          }
    if (serverString.toLowerCase().contains("diamond")) {
                diamondCount++;
          }
    if (serverString.toLowerCase().contains("sapphire")) {
                sapphireCount++;
          }
    if (serverString.toLowerCase().contains("runite")) {
                runiteCount++;
          }
      }

// Time To Paint...

     public int startLevel = 99;
     public int startXP = 0;
     public long startTime = System.currentTimeMillis();
     public long time = System.currentTimeMillis();
     int checkTime;
     long lastCheck;
     boolean powerMode = false;
     int randomRun = random(40, 75);
     int rockCount;
     int oldRockCount; // /////////CREDS TO AELIN
     int xpPerRock;
     long avoidedCombat;
     long avoidedSmokingRocks;
    int startExp = 0;
    int oldExp;
    int countToNext;
    int oldLevels;
    long lastAvgCheck;
    int avgPerHour;
    int Points = 1;
    int StartPoints = 1;
    String PointsString = "LuLWuT?";
    String Status = "Starting.";

      public void onRepaint(Graphics g) {
          if (!isLoggedIn() || isLoginScreen()) {
                return;
          }
          RSInterface Planks = RSInterface.getInterface(766);

          // Ty to AELIN for these
          // local objects:
          int index = STAT_WOODCUTTING;
          int exp = 1;
          int levels;
          long hours = 0, minutes = 0, seconds = 1;
          long time;

          // Has start time been previously set?
          if (startTime == 0) {
                startTime = System.currentTimeMillis();
          }

          // Calculate hours, minutes and seconds.
          time = System.currentTimeMillis() - startTime;
          seconds = time / 1000;
          if (seconds >= 60) {
                minutes = seconds / 60;
                seconds -= minutes * 60;
          }
          if (minutes >= 60) {
                hours = minutes / 60;
                minutes -= hours * 60;
          }

          // Has variables been previously defined?
          if (startLevel == 0 || startExp == 0) {
                // No, so define them now.
                startLevel = skills.getCurrentSkillLevel(STAT_MINING);
                startExp = skills.getCurrentSkillExp(STAT_MINING);
                oldExp = 0;
          }

          // Calculate catches based on experience changes.
          exp = skills.getCurrentSkillExp(STAT_MINING) - startExp;
          if (exp > oldExp) {
                xpPerRock = exp - oldExp;
                oldExp = exp;
                rockCount++;
                countToNext = xpPerRock + 1;
          }  

          // Calculate levels gained.
          levels = skills.getCurrentSkillLevel(index) - startLevel;
          if (levels > oldLevels) {
                oldLevels = levels;
          }  

          //
          if (System.currentTimeMillis() - lastAvgCheck >= 60000) {
                lastAvgCheck = System.currentTimeMillis();
                avgPerHour = (rockCount - oldRockCount) * 60;
                oldRockCount = rockCount;
          }  

          Color BG = new Color(0, 0, 0, 125); // Creds to killa for the color -.-
          Color RED = new Color(255, 0, 0, 255);
          Color GREEN = new Color(0, 255, 0, 255);
          Color BLACK = new Color(0, 0, 0, 255);

          int GotPoints = Points - StartPoints;
          int type = STAT_MINING;
          long millis = System.currentTimeMillis() - startTime;
          millis -= hours * 1000 * 60 * 60;
          millis -= minutes * 1000 * 60;
          int XPChange = skills.getCurrentSkillExp(type) - startXP;
          int LevelChange = skills.getCurrentSkillLevel(type) - startLevel;
          int perNextLvl = 1;
          int nextLvl = skills.getCurrentSkillLevel(type) + 1;
//heres where the paint starts          
    g.setColor(BG);
          g.fill3DRect(5, 25, 215, 243, true);
          g.setColor(Color.white);
          g.drawString("RuniteDestroyer by Christian133", 10, 40);
          g.drawString("Running for: " + hours + "h " + minutes + "m " + seconds + "s", 10, 60);
          g.drawString("XP Gained: " + exp, 10, 80);
          g.drawString("XP To next lvl: " + 1, 10, 100);
          g.drawString("Progress to next lvl:", 10, 120);
//progress bar          
    g.setColor(RED);
          g.fill3DRect(10, 130, 100, 10, true);
          g.setColor(GREEN);
          g.fill3DRect(10, 130, perNextLvl, 10, true); // This is how progress bars are made
          g.setColor(BLACK);
//end progress bar
          g.drawString(perNextLvl + "%  to " + nextLvl, 40, 139);
          g.setColor(Color.white);
          g.drawString("Levels Gained: " + LevelChange, 10, 160);
          g.drawString("Emeralds: " + emeraldCount, 10, 180);
    g.drawString("Rubys: " + rubyCount, 10, 200);
    g.drawString("Diamonds: " + diamondCount, 10, 220);
    g.drawString("Sapphires: " + sapphireCount, 10, 240);
    g.drawString("Runite Ores: " + runiteCount, 10, 260);
  }

}