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

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 13.40 KB  |  hits: 22  |  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 com.rarebot.event.events.MessageEvent;
  2. import com.rarebot.event.listeners.MessageListener;
  3. import com.rarebot.event.listeners.PaintListener;
  4. import com.rarebot.script.Script;
  5. import com.rarebot.script.ScriptManifest;
  6. import com.rarebot.script.methods.Players;
  7. import com.rarebot.script.methods.Skills;
  8. import com.rarebot.script.wrappers.RSArea;
  9. import com.rarebot.script.wrappers.RSObject;
  10. import com.rarebot.script.wrappers.RSPlayer;
  11. import com.rarebot.script.wrappers.RSTile;
  12. import com.rarebot.script.wrappers.RSTilePath;
  13. import com.rarebot.script.wrappers.RSNPC;
  14. import java.awt.*;
  15. import java.awt.event.MouseEvent;
  16. import java.awt.event.MouseListener;
  17. import java.text.DecimalFormat;
  18. import java.text.NumberFormat;
  19.  
  20.  
  21.  
  22. @ScriptManifest(authors = { "<html><body><b>DD<html><body><b>" }, keywords = { "Shilo Gem Miner" }, name = "BombTheGem", version = 1.0, description = "<html><body><b>Bank expensive gem at Shilo<html><body><b>")
  23. public class BombTheGem extends Script implements PaintListener, MouseListener, MessageListener{
  24.  
  25.         //Item
  26.         private int[] pickaxeID = {1265, 1267, 1269, 1272, 1271, 1275, 15259};
  27.         private int[] keep = {1621, 1623, 1617, 1619,1265, 1267, 1269, 1272, 1271, 1275, 15259};
  28.         private int[] drop = {1625, 1627, 1629};
  29.         int sapphireID = 1623;
  30.         int emeraldID = 1621;
  31.         int rubyID = 1619;
  32.         int diamondID = 1617;  
  33.     int sapphirePrice;
  34.     int emeraldPrice;
  35.     int rubyPrice;
  36.     int diamondPrice;
  37.     private int profit;
  38.     public final NumberFormat formatter = new DecimalFormat("###,###,###");
  39.     private int gemsMined = 0;
  40.     private int sapphire = 0;
  41.     private int emerald = 0;
  42.     private int ruby = 0;
  43.     private int diamond = 0;
  44.     public long runTime;
  45.         //Objects
  46.         private int bankerID = 499;
  47.         private int[] rockID = {11195, 11364, 11194};
  48.         //Walking
  49.         RSTile[] toMine = {new RSTile(2843,2962), new RSTile(2834,2968),
  50.                         new RSTile(2828,2980), new RSTile(2824,2990),
  51.                         new RSTile(2822,3000)};
  52.         RSTile[] toBank = {new RSTile(2822,3000),new RSTile(2824,2990), new RSTile(2828,2980),
  53.                         new RSTile(2834,2968), new RSTile(2843,2962), new RSTile(2852,2955)};
  54.         public int w;
  55.     public int k;
  56.         //Area
  57.     RSArea mineArea = new RSArea(new RSTile(2819,2997), new RSTile(2827,3005));
  58.     RSArea bankArea = new RSArea(new RSTile(2849,2951), new RSTile(2855,2957));
  59.     public int shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol = 0;//0= shouldn't be walking, 1= to bank, 2 = to mine
  60.     //Paint
  61.     public long startTime;
  62.     final int cuttingSkill = Skills.MINING;
  63.         int currentLevel;
  64.         int startingLevel;
  65.         int startingXp;
  66.         private String status = "";
  67.         long timeRan;
  68.         private int showTab = 1; //1 = main, 2 = hide//
  69.         Rectangle main = new Rectangle(422, 458, 51, 19);
  70.     Rectangle hide = new Rectangle(468, 460, 51, 19);
  71.        
  72.        
  73.        
  74.        
  75.        
  76.         //METHODS
  77.     //Walking
  78.    
  79.     public boolean onStart(){
  80.                 startingXp =  skills.getCurrentExp(Skills.MINING);
  81.                 startTime = System.currentTimeMillis();
  82.                 sapphirePrice = grandExchange.lookup(sapphireID).getGuidePrice();
  83.                 emeraldPrice = grandExchange.lookup(emeraldID).getGuidePrice();
  84.                 rubyPrice = grandExchange.lookup(rubyID).getGuidePrice();
  85.                 diamondPrice = grandExchange.lookup(diamondID).getGuidePrice();
  86.                 startingLevel = skills.getCurrentLevel(cuttingSkill);
  87.                
  88.  
  89.  return true;
  90. }          
  91.  
  92.  
  93.        
  94.  
  95. public void messageReceived(MessageEvent e) {
  96.            String msg = e.getMessage().toLowerCase();
  97.             if (msg.contains("just mined"))
  98.                 gemsMined++;
  99.             if (msg.contains("diamond"))
  100.                 diamond++;
  101.             if (msg.contains("a ruby"))
  102.                 ruby++;
  103.             if (msg.contains("a sapphire"))
  104.                 sapphire++;
  105.             if (msg.contains("an emerald"))
  106.              emerald++;
  107.          
  108. }      
  109.    
  110.  
  111.  
  112.  
  113.         private boolean walkThePath(RSTile[] path){
  114.                 w = random(4,6);
  115.                 k = random(2,4);
  116.                 int b = k;
  117.                 int t = w;
  118.                 boolean D=false;
  119.                 try{
  120.                         RSTilePath pathToWalk = walking.newTilePath(path);
  121.                         RSTile next = pathToWalk.getNext();
  122.                         RSTile start = pathToWalk.getStart();
  123.                         if ((walking.getDestination() == null||calc.distanceTo(walking.getDestination()) < t ||calc.distanceBetween(next,walking.getDestination()) > b)) {
  124.                                 if(!walking.walkTileMM(next)){
  125.                                         if(walking.walkTileMM(start)){
  126.                                                 sleep(412,565);
  127.                                                 D=true;
  128.                                         }else{
  129.                                                 walkToTile(walking.getClosestTileOnMap(next));
  130.                                                 sleep(277,562);
  131.                                         }
  132.                                 }else{
  133.                                         sleep(299,565);
  134.                                         D=true;
  135.                                 }
  136.                         }
  137.                         return D;
  138.                 }catch(Exception e ){ log("Caught a Exception in pathToWalk. Saved the script from stopping!"); sleep(554,789); }
  139.                 return D;
  140.         }
  141.         private boolean walkToTile(RSTile tile){
  142.                 int q = k;
  143.                 int i = w;
  144.                 boolean D = false;
  145.                 try{
  146.                         if ((walking.getDestination() == null||(calc.distanceTo(walking.getDestination()) < q &&calc.distanceBetween(tile,walking.getDestination()) > i))) {
  147.                                 if(calc.tileOnScreen(tile)){
  148.                                         if(walking.walkTileOnScreen(tile))
  149.                                                 D = true;
  150.                                 }else if(calc.tileOnMap(tile)){
  151.                                         if(walking.walkTileMM(tile))
  152.                                                 D = true;
  153.                                 }else{
  154.                                         if(walkToTile(walking.getClosestTileOnMap(tile)))
  155.                                                 D = true;
  156.                                 }
  157.                                 sleep(389);
  158.                         }
  159.                 return D;
  160.                 }catch(Exception e){ log("Caught an Exception in walkToTile. Saved the scrpt from stopping!"); sleep(554,789); }
  161.                 return D;
  162.         }
  163.        
  164.        
  165.         private void toMine(){
  166.                 walkThePath(toMine);
  167.                 shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol = 2;
  168.                 while (players.getMyPlayer().isMoving()) {
  169.                         status = "Walking to Mine";
  170.                         sleep(500, 1000);
  171.                 }
  172.         }
  173.         private void toBank() {
  174.                 walkThePath(toBank);
  175.                 shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol = 1;
  176.                 while (players.getMyPlayer().isMoving()) {
  177.                         status = "Walking to Bank";
  178.                         sleep(500, 1000);
  179.                 }
  180.         }
  181.                 ////////////////////////MINING\\\\\\\\\\\\\\\\\\\\\\\
  182.         private void mining(){
  183.                 RSObject rock = objects.getNearest(rockID);
  184.                 sleep(random(750, 2000));
  185.                 if(players.getMyPlayer().getAnimation() == -1){
  186.                         if (rock != null) {                    
  187.                                 sleep(100, 300);
  188.                                 rock.interact("Mine");
  189.                                 status = "Mining";
  190.                         }else{
  191.                                 dropping();
  192.                                
  193.                         }
  194.                 }else{
  195.                         sleep(1000,1500);
  196.                 }
  197.         }
  198.        
  199.        
  200.         ////////////////////Banking\\\\\\\\\\\\\\\\\\
  201.         private void bankOpen(){
  202.         RSNPC banker = npcs.getNearest(bankerID);
  203.         banker.interact("Bank Banker");
  204.         status = "Depositing Gems";
  205.         sleep(1600,2300);
  206.         }
  207.        
  208.         private void depositGem() {
  209.                 if (bank.isOpen()) {
  210.                         sleep(600);
  211.                         bank.depositAllExcept(pickaxeID);
  212.                         sleep(random(150, 200));
  213.                 }
  214.         }
  215.        
  216.         //////////////////Dropping\\\\\\\\\\\\\\
  217.         private void dropping(){
  218.                 status = "Dropping useless Gems";
  219.                 inventory.dropAllExcept(keep);
  220.                 sleep(250,500);
  221.         }
  222.        
  223.         ///////////////////AntiBan\\\\\\\\\\\\\\\\
  224.         @SuppressWarnings("deprecation")
  225.         public void antiban() {
  226.                 switch (random(0, 18)) {
  227.  
  228.                 case 1:
  229.                         // if the random equals 5 then
  230.                         if (random(0, 20) == 5) {
  231.                                 // mouse moves a bit
  232.                                 mouse.moveSlightly();
  233.                                 // sleeps for 50 to 100 milliseconds
  234.                                 sleep(50, 100);
  235.                                 // moves mouse randomly
  236.                                 mouse.moveRandomly(150, 350);
  237.                                
  238.  
  239.                         }
  240.  
  241.                         break;
  242.  
  243.                 case 2:
  244.  
  245.                         if (random(0, 15) == 2) {
  246.  
  247.                                 camera.setAngle(random(30, 70));
  248.  
  249.                                 sleep(400, 1200);
  250.                                
  251.                         }
  252.  
  253.                         break;
  254.  
  255.                 case 3:
  256.  
  257.                         if (random(0, 25) == 6) {
  258.  
  259.                                 mouse.moveOffScreen();
  260.  
  261.                                 sleep(random(600, random(1200, 2000)));
  262.                                
  263.  
  264.                         }
  265.  
  266.                         break;
  267.  
  268.                 case 4:
  269.  
  270.                         if (random(0, 30) == 3) {
  271.  
  272.                                 game.openTab(1);
  273.  
  274.                                 sleep(random(240, 500));
  275.  
  276.                                 skills.doHover(Skills.INTERFACE_MINING);
  277.  
  278.                                 sleep(random(1240, 1760));
  279.                                
  280.                         }
  281.  
  282.                         break;
  283.  
  284.                 case 5:
  285.  
  286.                         if (random(0, 25) == 1) {
  287.  
  288.                                 RSPlayer player = players.getNearest(Players.ALL_FILTER);
  289.  
  290.                                 if (player != null && calc.distanceTo(player) != 0) {
  291.  
  292.                                         mouse.move(player.getScreenLocation(), 5, 5);
  293.  
  294.                                         sleep(random(150, 250));
  295.  
  296.                                         mouse.click(false);
  297.  
  298.                                         sleep(random(550, 600));
  299.  
  300.                                         mouse.move(random(10, 450), random(10, 495));
  301.                                        
  302.                                 }
  303.  
  304.                         }
  305.  
  306.                         break;
  307.  
  308.                 case 6:
  309.  
  310.                         if (random(0, 15) == 4) {
  311.  
  312.                                 camera.setAngle(random(1, 359));
  313.                                
  314.                         }
  315.  
  316.                         break;
  317.  
  318.                 case 7:
  319.  
  320.                         if (random(0, 20) == 2) {
  321.  
  322.                                 final int x = (int) mouse.getLocation().getX();
  323.  
  324.                                 final int y = (int) mouse.getLocation().getY();
  325.  
  326.                                 mouse.move(x + random(-100, 100), y + random(-50, 50));
  327.                                
  328.                         }
  329.  
  330.                         break;
  331.  
  332.                 case 8:
  333.  
  334.                         if (random(0, 19) == 5) {
  335.  
  336.                                 mouse.moveSlightly();
  337.  
  338.                                 sleep(50, 150);
  339.  
  340.                                 mouse.moveRandomly(150, 350);
  341.                                
  342.                         }
  343.  
  344.                         break;
  345.  
  346.                 case 9:
  347.  
  348.                         if (random(0, 25) == 1) {
  349.  
  350.                                 camera.setAngle(random(30, 70));
  351.  
  352.                                 sleep(400, 1200);
  353.                                
  354.                         }
  355.  
  356.                         break;
  357.  
  358.                 case 10:
  359.  
  360.                         if (random(0, 30) == 6) {
  361.  
  362.                                 mouse.moveOffScreen();
  363.  
  364.                                 sleep(random(600, random(1200, 2000)));
  365.                                
  366.                         }
  367.  
  368.                         break;
  369.  
  370.                 default:
  371.  
  372.                         break;
  373.                 }
  374.  
  375.         }
  376.         ///////////////////Loop\\\\\\\\\\\\\\\\\\\
  377.         @Override
  378.         public int loop() {
  379.                 if(mineArea.contains(players.getMyPlayer().getLocation()) && !inventory.isFull()){
  380.                         shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol=0;
  381.                         mining();
  382.                         antiban();
  383.                 }
  384.                 if(inventory.isFull()){
  385.                         shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol=0;
  386.                         dropping();
  387.                 }
  388.                 if(!inventory.containsOneOf(drop) && inventory.isFull() || shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol==1){//wait why don't you have a endint braket?
  389.                         toBank();
  390.                 }
  391.                 if(bankArea.contains(players.getMyPlayer().getLocation()) && inventory.isFull()){
  392.                         shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol=0;
  393.                         bankOpen();
  394.                         depositGem();
  395.                 }if(!inventory.isFull() && !mineArea.contains(players.getMyPlayer().getLocation()) || shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol==2){
  396.                         toMine();
  397.                 }
  398.                 return 0;
  399.         }
  400.        
  401.         //////////////////////Paint\\\\\\\\\\\\\\\\\\\\\\\
  402.          //START: Code generated using Enfilade's Easel
  403.     private final Color color1 = new Color(51, 51, 0, 184);
  404.     private final Color color2 = new Color(255, 255, 255);
  405.     private final Color color3 = new Color(0, 0, 0);
  406.     int ExpH;
  407.  
  408.     private final BasicStroke stroke1 = new BasicStroke(1);
  409.  
  410.     private final Font font1 = new Font("Arial", 0, 9);
  411.     private final Font font2 = new Font("Arial", 0, 11);
  412.  
  413.     public void onRepaint(Graphics g1) {
  414.         long millis = System.currentTimeMillis() - startTime;
  415.                 long hours = millis / (1000 * 60 * 60);
  416.                 millis -= hours * (1000 * 60 * 60);
  417.                 long minutes = millis / (1000 * 60);
  418.                 millis -= minutes * (1000 * 60);
  419.                 long seconds = millis / 100;
  420.                 int ExpGained = skills.getCurrentExp(cuttingSkill) - startingXp;
  421.                 profit = ((sapphirePrice*sapphire)+(emeraldPrice*emerald)+(rubyPrice*ruby)+(diamondPrice*diamond));
  422.  
  423.                 float xpsec = 0;
  424.                 xpsec = ((float) ExpGained)/(float)(seconds + (minutes*60) + (hours*60*60));
  425.                 float xpmin = xpsec * 60;
  426.                 float xphour = xpmin * 60;
  427.                 float moneysec = 0;
  428.                 moneysec = ((float) profit)/(float)(seconds + (minutes*60) + (hours*60*60));
  429.                 float moneymin = moneysec * 60;
  430.                 float moneyhour = moneymin * 60;
  431.                        
  432.                  Graphics2D g = (Graphics2D)g1;
  433.         g.setColor(color1);
  434.                 g.drawRect(hide.x, hide.y, hide.width, hide.height);
  435.                 g.drawRect(main.x, main.y, main.width, main.height);
  436.                 if(showTab == 1){
  437.                 int LvlsGained = skills.getCurrentLevel(cuttingSkill) - startingLevel;
  438.                 long currentLevel = skills.getCurrentLevel(cuttingSkill);
  439.  
  440.         g.setColor(color1);
  441.         g.fillRoundRect(8, 345, 486, 111, 16, 16);
  442.         g.setColor(color2);
  443.         g.setStroke(stroke1);
  444.         g.drawRoundRect(8, 345, 486, 111, 16, 16);
  445.         g.setColor(color1);
  446.         g.fillRoundRect(494, 456, 0, 0, 16, 16);
  447.         g.setColor(color2);
  448.         g.drawRoundRect(494, 456, 0, 0, 16, 16);
  449.         g.setFont(font1);
  450.         g.drawString("Time Running :" + hours + " H " + minutes + " M "
  451.                                 + seconds + " S ", 20, 358);
  452.         g.drawString("Sapphire Mined :"+sapphire, 273, 359);
  453.         g.drawString("Emerald Mined :"+emerald, 272, 379);
  454.         g.drawString("Ruby Mined :"+ruby, 281, 399);
  455.         g.drawString("Diamond Mined :"+diamond, 269, 417);
  456.         g.drawString("Exp Gained :"+ ExpGained, 22, 391);
  457.       //  ExpH = ((int) (ExpGained * 3600000D / (System.currentTimeMillis() - startTime)));
  458.         g.drawString("Exp/H : " + formatter.format(xphour), 31, 411);
  459.         g.drawString("Money Gained : "  + formatter.format(profit), 16, 429);
  460.         g.drawString("Money/H : " + formatter.format(moneyhour), 25, 446);
  461.         g.drawString("Total mined :"+gemsMined, 282, 436);
  462.         g.setFont(font2);
  463.         g.setColor(color3);
  464.         g.drawString("BombTheGem - DD", 191, 334);
  465.         g.setColor(color2);
  466.         g.drawString("Status :" + status, 299, 453);
  467.         g.setFont(font1);
  468.         g.drawString("Current Lvl :" + currentLevel + "(" + LvlsGained + ")", 20, 375);
  469.         g.drawString("Hide |  Show", 443, 471);
  470.        
  471.         Point p = mouse.getLocation();
  472.                 g.setColor(Color.white);
  473.                 g1.fillRect(p.x - 5, p.y, 12, 2);
  474.                 g1.fillRect(p.x, p.y - 5, 2, 12);
  475.     }
  476.                 if(showTab  == 2){
  477.                         g1.drawString("Show", 475,471);
  478.                        
  479.                        
  480.                 }
  481.                
  482.         }
  483.     //END: Code generated using Enfilade's Easel       
  484.    
  485.                
  486.  
  487.  
  488.  
  489.                         public void mouseClicked(MouseEvent e) {
  490.                                 if(main.contains(e.getPoint())){
  491.                                         showTab = 2;
  492.                                 }
  493.                                 if (hide.contains(e.getPoint())) {
  494.                                         showTab = 1;
  495.                                         }
  496.                                 }
  497.  
  498.                         public void mouseEntered(MouseEvent e) {}
  499.                         public void mouseExited(MouseEvent e) {}
  500.                         public void mousePressed(MouseEvent e) {}
  501.                         public void mouseReleased(MouseEvent e) {
  502.                         }
  503.  
  504.                        
  505.                                
  506.                         }