Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 9.46 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.*;
  2. import java.util.Map;
  3.  
  4. import org.rsbot.script.wrappers.*;
  5. import org.rsbot.script.methods.*;
  6. import org.rsbot.event.events.ServerMessageEvent;
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.event.listeners.ServerMessageListener;
  9. import org.rsbot.script.Script;
  10. import org.rsbot.script.ScriptManifest;
  11. @ScriptManifest(authors = {"BOOM BOOM"}, category = "Mining", name = "RDMiner", version = 1.0, description = ("Have a pickaxe in Inventory or Equipment"))
  12. public class RDMiner extends Script implements PaintListener, ServerMessageListener {
  13.         public int coal[] = { 32426, 32427, 32428 };
  14.         public int coal2[] = { 33400, 33401, 33402, };
  15.         public int bankId = 25937;
  16.         public RSTile path = new RSTile(1043, 4578);
  17.         public RSTile path2 = new RSTile(1064, 4573);
  18.         private long startTime;
  19.         private int orePrice;
  20.         private int oresMined = 0;
  21.         public int ran = random(4, 6);
  22.         public int actionID = 1;
  23.         public static final int INTERFACE_BANK = 11;
  24.         public static final int INTERFACE_DEPOSIT_BOX_INTERFACE = 19;
  25.        
  26.         public boolean onStart(Map<String, String> args) { //What the script will do when it has been started.
  27.                 log("Happy Botting :)");
  28.                 orePrice = grandExchange.loadItemInfo(440).getMarketPrice();
  29.                 startTime = System.currentTimeMillis();
  30.                 return true;
  31.         }
  32.        
  33.         private boolean isInArea(final int minX, final int minY, final int maxX, final int maxY) {
  34.         final int x = getMyPlayer().getLocation().getX();
  35.         final int y = getMyPlayer().getLocation().getY();
  36.         if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
  37.             return true;
  38.         }
  39.         return false;
  40.       }
  41.          
  42.           public void action(){//Credits to ishitpants for area tiles.
  43.                 final RSObject Ore = objects.getNearest(coal2);
  44.                 if (!inventory.isFull() && !isOpen()) {//1 = mining
  45.                         actionID = 1;
  46.                 } else if (inventory.isFull()) {//2 = banking
  47.                         actionID = 2;
  48.                 } else if (isInArea(1061, 4565, 1070, 4582) && actionID == 4){//4 = walking to mine
  49.                         actionID = 1;
  50.                 } else if (isInArea(1041, 4575, 1044, 4578) && actionID == 3) {//3 = walking to bank
  51.                         actionID = 2;
  52.                 } else if (isInArea(1041, 4575, 1044, 4578) && actionID == 2) {
  53.                         actionID = 4;
  54.                 } else if (isInArea(1062, 4560, 1075, 4585) && actionID == 1) {
  55.                         actionID = 1;
  56.                 } else if (Ore != null && isInArea(1062, 4560, 1075, 4585) && actionID == 1) {
  57.                         actionID = 5;
  58.                 }
  59.         }
  60.        
  61.         public boolean depositBox(){
  62.                 return isOpen() && interfaces.getComponent(INTERFACE_BANK, INTERFACE_DEPOSIT_BOX_INTERFACE).doClick();
  63.         }
  64.        
  65.         public boolean isOpen(){
  66.                 return interfaces.get(INTERFACE_BANK).isValid();
  67.         }
  68.        
  69.         public boolean open(){
  70.                 final RSObject Bank = objects.getNearest(bankId);
  71.                 if (Bank.isOnScreen()){
  72.                         tiles.doAction(Bank.getLocation(), "Deposit");
  73.                         while (getMyPlayer().isMoving()) {
  74.                                 return false;
  75.                         }
  76.                         sleep(750);
  77.                 } else {
  78.                         walking.walkTo(path);
  79.                         log("Walk");
  80.                 }
  81.                 return false;
  82.         }
  83.        
  84.         public boolean dwarf(){
  85.                 return npcs.getNearestToAttack("Dwarf")==null;
  86.         }
  87.        
  88.         private void AntiBan() {
  89.                 final int r = random(1, 360);
  90.                 final int b = random(750, 1500);
  91.                 int randomNum = random(1, 30);
  92.                 int ra = random(1, 45);
  93.                 if (randomNum == 6) {
  94.                         if (ra == 1) {
  95.                                 if (game.getCurrentTab() != game.TAB_STATS) {
  96.                                         game.openTab(game.TAB_STATS);
  97.                                         mouse.move(random(680, 730), random(355, 370));
  98.                                 }
  99.                         }
  100.                         if (ra == 2) {
  101.                                 game.openTab(random(1, 14));
  102.                         }
  103.                         if (ra == 3) {
  104.                                 Point mPos = mouse.getClientLocation();
  105.                                 mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
  106.                         }
  107.                         if (ra == 4) {
  108.                                 Point mPos = mouse.getClientLocation();
  109.                                 mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
  110.                         }
  111.                         if (ra == 5) {
  112.                                 Point mPos = mouse.getClientLocation();
  113.                                 mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
  114.                         }
  115.                         if (ra == 6) {
  116.                                 Point mPos = mouse.getClientLocation();
  117.                                 mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
  118.                         }
  119.                         if (ra == 7) {
  120.                                 Point mPos = mouse.getClientLocation();
  121.                                 mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
  122.                         }
  123.                         if (ra == 8) {
  124.                                 camera.setAngle(random(100, 360));
  125.                         }
  126.                         if (ra == 9) {
  127.                                 camera.setAngle(random(100, 360));
  128.                         }
  129.                         if (ra == 10) {
  130.                                 camera.setAngle(random(100, 360));
  131.                         }
  132.                         if(ra == 11){
  133.                                 camera.setAltitude(true);
  134.                         }
  135.                         if(ra == 12){
  136.                                 camera.setAltitude(false);
  137.                         }
  138.                         if(ra == 13) {
  139.                                 camera.moveRandomly(b);
  140.                         }
  141.                         if(ra == 14) {
  142.                                 camera.setAngle(r);
  143.                         }
  144.                         if(ra == 15) {
  145.                                 camera.setCompass('n');
  146.                         }
  147.                         if(ra == 16) {
  148.                                 camera.setCompass('w');
  149.                         }
  150.                         if(ra == 17) {
  151.                                 camera.setCompass('e');
  152.                         }
  153.                         if(ra == 18) {
  154.                                 camera.setCompass('s');
  155.                         }
  156.                 }
  157.         }
  158.        
  159.         public boolean bank() {
  160.                 final RSObject Bank = objects.getNearest(bankId);
  161.                 if (calc.distanceTo(Bank.getLocation()) <=5){
  162.                         log("Open");
  163.                         open();
  164.                         sleep(750);
  165.                         if (isOpen()){
  166.                                 depositBox();
  167.                                 sleep(1000);
  168.                                 walking.walkTo(path2);
  169.                                 return true;
  170.                         }else{
  171.                                 open();
  172.                                 return false;
  173.                         }
  174.                 } else if (calc.distanceTo(Bank.getLocation()) > 5 && inventory.isFull()){
  175.                         walking.walkTo(path);
  176.                         return false;
  177.                 }
  178.                 return false;
  179.         }
  180.        
  181.         public boolean doMine() {
  182.                 final int a = 32426;
  183.                 final int b[] = { 32427, 32438 };
  184.                 final int c = 32428;
  185.                 final RSObject Ore = objects.getNearest(coal);
  186.                 final RSObject Ore2 = objects.getNearest(coal2);
  187.                 final RSObject A = objects.getNearest(a);
  188.                 final RSObject B = objects.getNearest(b);
  189.                 final RSObject C = objects.getNearest(c);
  190.                 if (calc.distanceTo(Ore) <= 10) {
  191.                         if (Ore != null) {
  192.                                 if (Ore.isOnScreen()) {
  193.                                         if (getMyPlayer().isMoving()){
  194.                                                 return false;
  195.                                         }
  196.                                         if (getMyPlayer().getAnimation() == 624 && calc.distanceTo(Ore2) < 1 && calc.distanceTo(Ore) < 1) {
  197.                                                 return false;
  198.                                         }
  199.                                         tiles.doAction(Ore.getLocation(), "Mine");
  200.                                         sleep(1750, 2000);
  201.                                         return true;
  202.                                 } else {
  203.                                         walking.walkTo(Ore.getLocation());
  204.                                 }
  205.                         } else {
  206.                                 return false;
  207.                         }
  208.                 } else if (calc.distanceTo(Ore) > 10) {
  209.                         if (!calc.pointOnScreen(calc.tileToScreen(Ore.getLocation()))) {
  210.                                 final int whichOre = random(1, 3);
  211.                                 if (whichOre == 1) {
  212.                                         walking.walkTo(Ore.getLocation());
  213.                                         sleep(1200, 1800);
  214.                                         while (getMyPlayer().isMoving()) {
  215.                                                 sleep(10, 20);
  216.                                         }
  217.                                         return false;
  218.                                 } else {
  219.                                         walking.walkTo(path2);
  220.                                         sleep(1200, 1800);
  221.                                         while (getMyPlayer().isMoving()) {
  222.                                                 sleep(10, 20);
  223.                                         }
  224.                                         return false;
  225.                                 }
  226.                         }
  227.                 } else {
  228.                         return false;
  229.                 }
  230.                 return false;
  231.         }
  232.        
  233.         public boolean check() {
  234.                 final RSObject Ore = objects.getNearest(coal2);
  235.                 while (getMyPlayer().getAnimation() == 624) {
  236.                         if (Ore != null) {
  237.                                 doMine();
  238.                                 return true;
  239.                         }else{
  240.                                 return false;
  241.                         }
  242.                 }
  243.                 return false;
  244.         }
  245.        
  246.         public boolean mine() {
  247.                 if (getMyPlayer().getAnimation() == -1) {
  248.                         doMine();
  249.                 }else{
  250.                         check();
  251.                 }
  252.                 return false;
  253.         }
  254.        
  255.         public void onFinish() { //What the script will do when stopped.
  256.                 log("RDMiner");
  257.         }
  258.        
  259.         public void onRepaint(Graphics g) {
  260.                 final int percent = skills.getPercentToNextLevel(Skills.MINING); //change the MINING to the stat u want
  261.                 long millis = System.currentTimeMillis() - startTime;
  262.                 long hours = millis / (1000 * 60 * 60);
  263.                 millis -= hours * (1000 * 60 * 60);
  264.                 long minutes = millis / (1000 * 60);
  265.                 millis -= minutes * (1000 * 60);
  266.                 long seconds = millis / 1000;
  267.                 long profit = orePrice * oresMined;
  268.                 final RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  269.                 Font font = new Font("Monospaced", Font.BOLD, 17);
  270.                         ((Graphics2D) g).setRenderingHints(rh);
  271.                         g.setColor(new Color(250, 0, 0, 95));
  272.                         g.fillRect(545, 205, 195, 262);
  273.                         g.setFont(font);
  274.                         g.setColor(new Color(0, 0, 0));
  275.                         g.drawString("RDMiner", 565, 215);
  276.                         g.setFont(font);
  277.                         g.setColor(new Color(0, 0, 0));
  278.                         g.drawString("Run Time :" + hours + ":" + minutes + ":" + seconds, 565, 230);
  279.                         g.setFont(font);
  280.                         g.setColor(new Color(0, 0, 0));
  281.                         g.drawString("Ores Mined : " + oresMined, 565, 245);
  282.                         g.setFont(font);
  283.                         g.setColor(new Color(0, 0, 0));
  284.                         g.drawString("Profit : " + profit, 565, 260);
  285.         }
  286.        
  287.         @Override
  288.         public void serverMessageRecieved(ServerMessageEvent f) { //What it will do if it recieves a message in game, by the System.
  289.                 final String m = f.getMessage();
  290.                 if (m.contains("manage")) {
  291.                         oresMined++;
  292.                 }
  293.                 if (m.contains("You do not have")) {
  294.                         log("no Pickaxe... logging out and stopping script");
  295.                         game.logout(true);
  296.                         stopScript();
  297.                 }
  298.                 if (m.contains("Hi") || m.contains(" ello")) {
  299.                         keyboard.sendText("Sorry, I don't feel like talking.", true);
  300.                 }
  301.         }
  302.        
  303.         public int loop() { //Your main code should be here, it will keep repeating it.
  304.                 mouse.setSpeed(ran);
  305.                 action();
  306.                 AntiBan();
  307.                 int runEnergy = random(60, 80);
  308.                 if (walking.getEnergy() >= runEnergy) {
  309.                         walking.setRun(true);
  310.                 }
  311.                 if (getMyPlayer().getAnimation() == 397){
  312.                         final RSNPC dwarf = npcs.getNearestFreeToAttack("Dwarf");
  313.                         if(calc.tileOnScreen(dwarf.getLocation())) {
  314.                                 dwarf.doAction("attack");
  315.                                 sleep(250, 500);
  316.                         } else {
  317.                                 walking.walkTo(dwarf.getLocation());
  318.                         }
  319.                 }
  320.                 switch (actionID) {
  321.                         case 1:
  322.                                 mine();
  323.                                 break;
  324.                         case 2:
  325.                                 bank();
  326.                                 break;
  327.                         case 3:
  328.                                 walking.walkTo(path);
  329.                                 actionID = 2;
  330.                                 break;
  331.                         case 4:
  332.                                 walking.walkTo(path2);
  333.                                 actionID = 1;
  334.                                 break;
  335.                         case 5:
  336.                                 AntiBan();
  337.                                 actionID = 1;
  338.                 }
  339.                 return 0;
  340.         }
  341. }