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

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 15.21 KB  |  hits: 9  |  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.util.Map;
  2. import java.awt.Font;
  3. import java.awt.Color;
  4. import java.awt.RenderingHints;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.io.*;
  8. import java.net.*;
  9.  
  10. import javax.swing.JOptionPane;
  11. import javax.swing.JFileChooser;  
  12.  
  13. import org.rsbot.script.Constants;
  14. import org.rsbot.script.Script;
  15. import org.rsbot.script.ScriptManifest;
  16. import org.rsbot.script.wrappers.RSObject;
  17. import org.rsbot.script.wrappers.RSTile;
  18. import org.rsbot.event.events.ServerMessageEvent;
  19. import org.rsbot.event.listeners.ServerMessageListener;
  20. import org.rsbot.event.listeners.PaintListener;
  21.  
  22.  
  23.  
  24.  
  25. @ScriptManifest(authors = {"pk purewcer,Reported"}, category = "Mining", name = "RimmingtonMiner", version = 1.11, description = ("<html><body style='font-family: Calibri; background-color: black; color:white; padding: 0px; text-align:'>"
  26.     + "<center><h2>RimmingtonMiner V1.11</h2></center>"
  27.     + "<p>"
  28.     + "Thanks for chosing RimmingtonMiner"
  29.     + "<p>The script comes whit...</p>"
  30.     + "<li>Antiban</li>"
  31.     + "<li>Nice and good paint</li>"
  32.     + "<li>Fast droping</li>"
  33.     + "<li>And more!</li>"
  34.     + "<p></p>"
  35.     + "<select name='whatToMine'><option>Gold</option><option>Copper</option></select>"
  36.     + "<p></p>"
  37.     + "Start at Rimmington mine near iron rocks!"
  38.     + "<b> Dont forget your pickaxe!</b>"))
  39.  
  40.  public class RimmingtonMiner extends Script implements PaintListener,ServerMessageListener {
  41.        
  42.         RSTile mineTile = new RSTile (2968, 3240);
  43.         RSTile walkToMine[] = { new RSTile (2968, 3240) };
  44.         public int[] dontDrop = { 995, 1269, 1273, 1275, 1265, 1271, 1267, 1617 };
  45.         public int[] ironID = {9719, 9717, 9718 };
  46.         public int[] goldID = {9722, 9720};
  47.         public int[] copperID = {9710, 9709, 9708};
  48.         public int AnimationID = (625);
  49.         public int startexp;
  50.     int oresMined = 0;
  51.         public long startTime = System.currentTimeMillis();
  52.     private String status = "";
  53.  
  54.    
  55.         public boolean onStart (Map<String, String>args) {
  56.         URLConnection url = null;
  57.         BufferedReader in = null;
  58.         BufferedWriter out = null;
  59.         //Ask the user if they'd like to check for an update...
  60.         if(JOptionPane.showConfirmDialog(null, "Would you like to check for updates? Please Note this requires an internet connection and the script will write files to your harddrive!") == 0){ //If they would, continue
  61.             try{
  62.                 //Open the version text file
  63.                 url = new URL("http://www.rimmingtonminer.webs.com/scripts/RimmingtonMinerVERSION.txt").openConnection();
  64.                 //Create an input stream for it
  65.                 in = new BufferedReader(new InputStreamReader(url.getInputStream()));
  66.                 //Check if the current version is outdated
  67.                 if(Double.parseDouble(in.readLine()) > getVersion()) {
  68.                     //If it is, check if the user would like to update.
  69.                     if(JOptionPane.showConfirmDialog(null, "Update found. Do you want to update?") == 0){
  70.                         //If so, allow the user to choose the file to be updated.
  71.                            JOptionPane.showMessageDialog(null, "Please choose 'RimmingtonMiner.java' in your scripts folder and hit 'Open'");
  72.                            JFileChooser fc = new JFileChooser();
  73.                            //Make sure "Open" was clicked.
  74.                            if(fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){
  75.                                //If so, set up the URL for the .java file and set up the IO.
  76.                                url = new URL("http://www.rimmingtonminer.webs.com/scripts/RimmingtonMiner.java").openConnection();
  77.                             in = new BufferedReader(new InputStreamReader(url.getInputStream()));
  78.                             out = new BufferedWriter(new FileWriter(fc.getSelectedFile().getPath()));
  79.                             String inp;
  80.                             /* Until we reach the end of the file, write the next line in the file
  81.                              * and add a new line. Then flush the buffer to ensure we lose
  82.                              * no data in the process.
  83.                              */
  84.                             while((inp = in.readLine()) != null){
  85.                                 out.write(inp);
  86.                                 out.newLine();
  87.                                 out.flush();
  88.                             }
  89.                             //Notify the user that the script has been updated, and a recompile and reload is needed.
  90.                                log("Script successfully downloaded. Please recompile and reload your scripts!");
  91.                             return false;
  92.                            } else log("Update canceled");
  93.                     } else log("Update canceled");
  94.                 } else
  95.                     JOptionPane.showMessageDialog(null, "You have the latest version. :)"); //User has the latest version. Tell them!
  96.                 if(in != null)
  97.                     in.close();
  98.                 if(out != null)
  99.                     out.close();
  100.             } catch (IOException e){
  101.                 log("Problem getting version :/");
  102.                 return false; //Return false if there was a problem
  103.             }
  104.         }  
  105.                 log ("Thanks for chosing rimmingtonminer." +
  106.                                 "Please start at Rimmington mine");
  107.                 startTime = System.currentTimeMillis();
  108.                 getMouseSpeed();
  109.                  if (args.get("whatToMine").equals("Gold"))
  110.                 {
  111.                     goldID = (9722, 9720);
  112.                 }
  113.                 if (args.get("whatToMine").equals("Copper"))
  114.                 {
  115.                     copperID = (9710, 9709, 9708);
  116.                 }
  117.                 if (args.get("whatToMine").equals("Iron"))
  118.                 {
  119.                     ironID = (9719, 9717, 9718);
  120.                 }
  121.                 return true;
  122.         }
  123.        
  124.         public void onFinish() {
  125.                 log ("thanks for using me scipt" +
  126.                                 "hope you like it =)");
  127.         }
  128.        
  129.        
  130.         public boolean dropAllExeptPickaxesAndMoney(){
  131.                 status = "Dropping ores.";
  132.                 dropAllExcept (dontDrop);
  133.                 return true;
  134.         }
  135.        
  136.         public boolean atMine(){       
  137.                 return distanceTo(mineTile) < 10;
  138.         }
  139.        
  140.     public boolean mineIron() {
  141.         try {
  142.           final RSObject Rock = getNearestObjectByID(ironID);
  143.           if (Rock == null) {
  144.                   status = "Waiting.";
  145.             return false;
  146.           }
  147.  
  148.           if (isAni()) {
  149.             return false;
  150.  
  151.           } else {
  152.             if (!isAni() && Rock != null) {
  153.               atObject(Rock, "Mine");
  154.               status = "Mining Iron.";
  155.               wait(random(950, 1100));
  156.               return true;
  157.             }
  158.           }
  159.         } catch (Exception ignored) {
  160.  
  161.         }
  162.         return false;
  163.       }
  164.        
  165.     public boolean mineGold() {
  166.         try {
  167.           final RSObject Rock = getNearestObjectByID(goldID);
  168.           if (Rock == null) {
  169.                   status = "Waiting";
  170.             return false;
  171.           }
  172.  
  173.           if (isAni()) {
  174.             return false;
  175.  
  176.           } else {
  177.             if (!isAni() && Rock != null) {
  178.               atObject(Rock, "Mine");
  179.               status = "Mining Gold.";
  180.               wait(random(950, 1100));
  181.               return true;
  182.             }
  183.           }
  184.         } catch (Exception ignored) {
  185.  
  186.         }
  187.         return false;
  188.       }
  189.        
  190.    
  191.     public boolean isAni() {
  192.         if (getMyPlayer().getAnimation() == AnimationID
  193.             || getMyPlayer().getAnimation() == 626
  194.             || getMyPlayer().getAnimation() == 624
  195.             || getMyPlayer().getAnimation() == 627) {
  196.           return true;
  197.         }
  198.         return false;
  199.       }
  200.    
  201.     public double getVersion() { return 1.11; } //is the current version of the script
  202.    
  203.     public boolean AntiBan(){
  204.         status = "Antiban";
  205.           int randomNumber = random(1, 25);
  206.           if (randomNumber <= 25) {
  207.               if (randomNumber == 1) {
  208.                 setCameraRotation(random(1,360));
  209.              }      
  210.               if (randomNumber == 2) {
  211.                   moveMouse(random(50, 700), random(50, 450), 2, 2);
  212.                   wait(random(300, 500));
  213.                   moveMouse(random(50, 700), random(50, 450), 2, 2);
  214.               }
  215.               if (randomNumber == 3) {
  216.                   wait(random(100, 500));
  217.                   moveMouse(522, 188, 220, 360);
  218.                   wait(random(100, 500));
  219.               }
  220.                   if (randomNumber == 4) {
  221.                       moveMouse(random(50, 700), random(50, 450), 2, 2);
  222.                       setCameraRotation(random(1,360));
  223.                       moveMouse(random(50, 700), random(50, 450), 2, 2);
  224.                       }            
  225.                               if (randomNumber == 6) {
  226.                                 wait(random(500, 1500));
  227.                               }
  228.                               if (randomNumber == 7) {
  229.                                   moveMouse(random(50, 700), random(50, 450), 2, 2);
  230.                               }
  231.                                   if (randomNumber == 8) {
  232.                                       wait(random(100, 200));
  233.                                           moveMouse(random(50, 700), random(50, 450), 2, 2);
  234.                                           wait(random(200, 500));
  235.                                           if (randomNumber == 9) {
  236.                                               wait(random(100, 200));
  237.                                                   moveMouse(random(50, 700), random(50, 450), 2, 2);
  238.                                                   if (randomNumber == 10) {
  239.                                                       moveMouse(random(50, 700), random(50, 450), 2, 2);
  240.                                                   }
  241.                                                   if (randomNumber == 11) {
  242.                                                       setCameraRotation(random(1,360));
  243.                                                       moveMouse(random(50, 700), random(50, 450), 2, 2);
  244.                                                   }
  245.                                                   if (randomNumber == 12) {
  246.                                                     openTab(TAB_STATS);
  247.                                                     wait(random(50, 100));
  248.                                                     moveMouse(522, 188, 220, 360);
  249.                                                     wait(random(500, 1400));
  250.                                                   }
  251.                                                   if (randomNumber == 13) {
  252.                                                       moveMouse(random(50, 700), random(50, 450), 2, 2);
  253.                                                       setCameraRotation(random(1,360));
  254.                                                   }
  255.                                                   if (randomNumber == 14) {
  256.                                                     openTab(TAB_STATS);
  257.                                                     wait(random(50, 100));
  258.                                                     moveMouse(522, 188, 220, 360);
  259.                                                     wait(random(500, 1400));
  260.                                                   }
  261.                                                   if (randomNumber == 15) {
  262.                                                     moveMouse(random(50, 700), random(50, 450), 2, 2);
  263.                                                     wait(random(500, 1000));
  264.                                                     moveMouse(random(50, 700), random(50, 450), 2, 2);
  265.                                                  }      
  266.                                                   }
  267.  
  268.                           }
  269.           }
  270.           return true;}
  271.       //Credits to Garrett
  272.  
  273.         @Override
  274.         public int loop() {
  275.                 if (isInventoryFull()) { // checks if invertory if full
  276.                         dropAllExeptPickaxesAndMoney();
  277.                 } else {
  278.                         if (!isInventoryFull()) { //checks if needs to mine
  279.                                 atMine();
  280.                                 mineIron();
  281.                                 AntiBan();
  282.                         }
  283.                 }
  284.                 return 0;
  285.         }
  286.        
  287.           protected int getMouseSpeed() {
  288.               return random(4, 7);
  289.             }
  290.        
  291.     @Override
  292.     public void serverMessageRecieved(ServerMessageEvent e) {  
  293.       String msg = e.getMessage();
  294.       if (msg.contains("You manage to mine")) {
  295.         oresMined++;
  296.       }
  297.  
  298.  
  299.     }
  300.  
  301. //This variable is used for Antialiasing. DO NOT DELETE!
  302. private final RenderingHints rh = new RenderingHints(
  303.         RenderingHints.KEY_TEXT_ANTIALIASING,
  304.         RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  305.  
  306.  
  307.  
  308. public void onRepaint(Graphics g) {
  309.     ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  310.       if (isLoggedIn()) {
  311.         int xpGained = 0;
  312.         if ( startexp == 0) {
  313.              startexp = skills.getCurrentSkillExp(STAT_MINING);
  314.         }
  315.         xpGained = skills.getCurrentSkillExp(STAT_MINING) - startexp;
  316.           long millis = System.currentTimeMillis() - startTime;
  317.           long hours = millis / (1000 * 60 * 60);
  318.           millis -= hours * (1000 * 60 * 60);
  319.           long minutes = millis / (1000 * 60);
  320.           millis -= minutes * (1000 * 60);
  321.           long seconds = millis / 1000;
  322.           long minutes2 = minutes + (hours * 60);
  323.                 float xpsec = 0;
  324.                 if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
  325.                         xpsec = ((float) xpGained)
  326.                                         / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
  327.                 }
  328.  
  329.                 float xpmin = xpsec * 60;
  330.                 float xpHour = xpmin * 60;
  331.       g.setColor(new Color(0, 153, 204, 193));
  332.     g.fillRect(375, 201, 139, 135);
  333.     g.setColor(new Color(0, 153, 204, 193));
  334.     g.fillRect(375, 201, 0, 0);
  335.     g.setColor(new Color(255, 255, 255));
  336.     g.drawRect(375, 200, 140, 135);
  337.     g.setColor(new Color(255, 255, 255));
  338.     g.drawRect(375, 201, 140, 134);
  339.     g.setColor(new Color(255, 255, 255));
  340.     g.drawRect(376, 201, 138, 134);
  341.     g.setFont(new Font("Narkisim", 0, 19));
  342.     g.setColor(new Color(0, 0, 204));
  343.     g.drawString("R.M.P.", 427, 219);
  344.     g.setFont(new Font("Narkisim", 0, 14));
  345.     g.setColor(new Color(255, 255, 255));
  346.     g.drawLine(513, 225, 377, 225);
  347.         g.setColor(Color.white);
  348.         g.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds + "." , 381, 240);
  349.         g.drawString("Ores Mined: " + oresMined, 381, 255);
  350.     g.drawString("Current Level: " + skills.getCurrentSkillLevel(STAT_MINING), 381, 270);
  351.     g.drawString("XP Gained: " + xpGained, 381, 285);
  352.     g.drawString("XP Hour: " + xpHour, 381, 300);
  353.     final int percent = skills.getPercentToNextLevel(Constants.STAT_MINING); //change the MINING to the stat u want
  354.     g.setColor(Color.red);
  355.     g.fillRoundRect(3, 315, 100, 10, 15, 15); //these must be on same cordinates
  356.     g.setColor(Color.green);
  357.     g.fillRoundRect(3, 315, percent, 10, 15, 15); //these must be on same cordinates
  358.     g.setFont(new Font("Narkisim", 0, 10));
  359.     g.setColor(Color.black);
  360.     g.drawString("%" + percent, 38, 325); //this must be on the center of the bar
  361.     g.drawRoundRect(3, 315, 100, 10, 15, 15); //these must be on same cordinates
  362.     g.drawRoundRect(3, 315, percent, 10, 15, 15); //these must be on same cordinates
  363.     g.setFont(new Font("Narkisim", 0, 15));
  364.         g.drawString("Status : " + status , 381, 330);
  365.       }
  366.   } // paint credits go 100% to 'Reported' he maded the paint!
  367. }