Ministry

Untitled

Apr 29th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.40 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. import org.rsbot.event.events.MessageEvent;
  4. import org.rsbot.event.listeners.MessageListener;
  5. import org.rsbot.event.listeners.PaintListener;
  6. import org.rsbot.script.Script;
  7. import org.rsbot.script.ScriptManifest;
  8. import org.rsbot.script.methods.Skills;
  9. import org.rsbot.script.wrappers.RSObject;
  10. import org.rsbot.script.wrappers.RSTile;
  11. import org.rsbot.script.wrappers.RSTilePath;
  12.  
  13. @ScriptManifest(
  14.                 authors = {"Jakebobjo"},
  15.                 name = "LegendMiner",
  16.                 version = 1.0,
  17.                 description = "LegendMiner, by Jakebobjo.",
  18.                 keywords = {"Miner", "PwrLvl"})
  19.  
  20. public class LegendMiner extends Script implements PaintListener, MessageListener {
  21.  
  22.         int boothID = 11402;
  23.         int[] pickaxeID = {1265, 1267, 1269, 1273, 1271, 1275, 15259};
  24.         int[] oreID = {11959, 11957, 11058};
  25.  
  26.         RSTile[] tilesToBank = {new RSTile(3182, 3376), new RSTile(3176, 3187),
  27.                         new RSTile(3169, 3399), new RSTile(3168, 3411), new RSTile(3169, 3423), new RSTile(3178, 3429),
  28.                         new RSTile(3183, 3438)};
  29.         RSTilePath pathToBank;
  30.  
  31.         //Paint Variables
  32.           public long startTime = 0;
  33.           public long millis = 0;
  34.           public long hours = 0;
  35.           public long minutes = 0;
  36.           public long seconds = 0;
  37.           public long last = 0;
  38.           public int oresMined = 0;
  39.           public int oresHour = 0;
  40.           public int startExp = 0;
  41.           public int expGained = 0;
  42.           public int expHour = 0;
  43.           public int expTNL = 0;
  44.           public int currLevel;
  45.           public int startLevel;
  46.           public int lvlsGained;
  47.           private int percentTNL;
  48.           private int tinPrice;
  49.           private int profitHour;
  50.           private int profitGained;
  51.          
  52.           public float sXP = 0;
  53.           public float mXP = 0;
  54.           public float hXP = 0;
  55.           long STL;
  56.           long MTL;
  57.           long HTL;
  58.  
  59.         public boolean onStart() {
  60.                 pathToBank = walking.newTilePath(tilesToBank);
  61.                 startTime = System.currentTimeMillis();
  62.                 startExp = skills.getCurrentExp(Skills.MINING);
  63.                 startLevel = skills.getCurrentLevel(Skills.MINING);
  64.                 tinPrice = grandExchange.lookup(438).getGuidePrice();
  65.                 return true;
  66.         }
  67.  
  68.         public int loop() {
  69.                 if(inventory.isFull()){
  70.                         if(atBank()){
  71.                                 doBank();
  72.                         } else {
  73.                                 walk();
  74.                         }
  75.                 } else {
  76.                         if(atMine()){
  77.                                 mineOres();
  78.                         } else {
  79.                                 walkR();
  80.                         }
  81.                 }
  82.                 return random(600, 800);
  83.         }
  84.  
  85.         private void mineOres() {
  86.                 RSObject rock = objects.getNearest(oreID);
  87.                 if(getMyPlayer().getAnimation() != 625){
  88.                         rock.doAction("Mine");
  89.                 }
  90.                 sleep(1200, 1500);
  91.         }
  92.  
  93.         public void messageReceived(MessageEvent e) {
  94.         String x = e.getMessage().toLowerCase();
  95.         if (x.contains("manage to mine")) {
  96.             oresMined++;
  97.         }
  98.     }
  99.  
  100.         private void walkR() {
  101.                 pathToBank.reverse();
  102.                 pathToBank.traverse();
  103.                 pathToBank.reverse();
  104.         }
  105.  
  106.         private void walk(){
  107.                 pathToBank.traverse();
  108.         }
  109.  
  110.         public void onFinish() {
  111.         }
  112.  
  113.         public void doBank(){
  114.                 if(bank.isOpen()){
  115.                         bank.depositAllExcept(pickaxeID);
  116.                         sleep(800, 1200);
  117.                 } else {
  118.                         bank.open();
  119.                         sleep(1800, 2200);
  120.                 }
  121.         }
  122.  
  123.         private boolean atBank(){
  124.                 RSObject bank = objects.getNearest(boothID);
  125.                         if(bank != null){
  126.                                 if(bank.isOnScreen()){
  127.                                         return true;
  128.                                 }
  129.                         }
  130.                         return false;
  131.         }
  132.  
  133.         private boolean atMine(){
  134.                 RSObject ore = objects.getNearest(oreID);
  135.                         if(ore != null){
  136.                                 if(ore.isOnScreen()){
  137.                                         return true;
  138.                                 }
  139.                         }
  140.                         return false;
  141.         }
  142.  
  143.  
  144.     //START: Code generated using Enfilade's Easel
  145.     private final RenderingHints antialiasing = new RenderingHints(
  146.             RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  147.  
  148.     private final Color color1 = new Color(204, 204, 204, 184);
  149.     private final Color color2 = new Color(0, 0, 0);
  150.     private final Color color3 = new Color(0, 153, 153);
  151.     private final Color color4 = new Color(255, 0, 0);
  152.     private final Color color5 = new Color(102, 255, 0);
  153.  
  154.     private final BasicStroke stroke1 = new BasicStroke(1);
  155.  
  156.     private final Font font1 = new Font("Arial Black", 0, 15);
  157.     private final Font font2 = new Font("Arial", 1, 15);
  158.     //END: Code generated using Enfilade's Easel
  159.  
  160.         /*
  161.          * ----- PAINT -----
  162.          */
  163.  
  164.         @Override
  165.         public void onRepaint(Graphics g) {
  166.  
  167.             expGained = skills.getCurrentExp(skills.MINING) - startExp;
  168.             expHour = (int) ((expGained) * 3600000D / (System.currentTimeMillis() - startTime));
  169.             profitHour = (int) ((profitGained) * 3600000D / (System.currentTimeMillis() - startTime));
  170.  
  171.             millis = System.currentTimeMillis() - startTime;
  172.             hours = millis / (1000 * 60 * 60);
  173.             millis -= hours * (1000 * 60 * 60);
  174.             minutes = millis / (1000 * 60);
  175.             millis -= minutes * (1000 * 60);
  176.             seconds = millis / 1000;
  177.  
  178.             currLevel = skills.getCurrentLevel(skills.MINING);
  179.             lvlsGained = currLevel - startLevel;
  180.             profitGained = oresMined*tinPrice;
  181.  
  182.             final int percentBar = (int) (skills.getPercentToNextLevel(skills.MINING)*3.02);
  183.  
  184.             percentTNL = skills.getPercentToNextLevel(skills.MINING);
  185.             expTNL = skills.getExpToNextLevel(skills.MINING);
  186.  
  187.             if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  188.             sXP = (float) expGained
  189.                                 / (float) (seconds + minutes * 60 + hours * 60 * 60);
  190.                 }
  191.                 mXP = sXP * 60;
  192.                 hXP = mXP * 60;
  193.  
  194.                   if (sXP > 0) {
  195.                 STL = (int) (expTNL / sXP);
  196.                 }
  197.                 if (STL >= 60) {
  198.                     MTL = STL / 60;
  199.                     STL -= MTL * 60;
  200.                 } else {
  201.                     MTL = 0;
  202.                 }
  203.                 if (MTL >= 60) {
  204.                     HTL = MTL / 60;
  205.                     MTL -= HTL * 60;
  206.                 } else {
  207.                     HTL = 0;
  208.                 }
  209.  
  210.             if(oresMined == 0){
  211.                 oresHour = 0;
  212.             }else{
  213.                 oresHour = (int) ((oresMined) * 3600000D / (System.currentTimeMillis() - startTime));
  214.             }
  215.  
  216.             //Paint
  217.                 Graphics2D g1 = (Graphics2D)g;
  218.                 g1.setRenderingHints(antialiasing);
  219.  
  220.                 //Percent Bar
  221.                 g.setColor(color4);
  222.                 g.fillRoundRect(13, 25, 493, 17, 16, 16);
  223.                 g.setColor(color2);
  224.                 g.drawRoundRect(13, 25, 493, 17, 16, 16);
  225.                 g.setColor(color5);
  226.                 g.fillRoundRect(13, 25, percentBar, 17, 16, 16);
  227.                 g.setColor(color2);
  228.                 g.drawRoundRect(13, 25, percentBar, 17, 16, 16);
  229.  
  230.                 //Main Paint
  231.                 g1.setColor(color1);
  232.                 g1.fillRect(8, 346, 501, 125);
  233.                 g1.setColor(color2);
  234.                 g1.setStroke(stroke1);
  235.                 g1.drawRect(8, 346, 501, 125);
  236.                 g1.setFont(font1);
  237.                 g1.setColor(color3);
  238.                 g1.drawString("LEGENDMINER V1.0", 17, 365);
  239.                 g1.setColor(color2);
  240.                 g1.drawString("LEGENDMINER V1.0", 15, 363);
  241.                 g1.setFont(font2);
  242.                 g1.drawString("Runetime: " + hours +":"+ minutes + ":" + seconds, 200, 364);
  243.                 g1.drawString("Exp TNL: " + skills.getExpToNextLevel(Skills.MINING), 360, 364);
  244.                 g1.drawString("Exp Gained: " + expGained + "  Exp/h: " + expHour, 17, 388);
  245.                 g1.drawString("Ore Mined: " + oresMined + "  Ore/h: " + oresHour, 17, 408);
  246.                 g1.drawString("Current Lvl: " + currLevel + " (" + lvlsGained + ")", 17, 428);
  247.                 g1.drawString("Time TNL: " + HTL + ":" + MTL + ":" + STL, 17, 448);
  248.                 g1.drawString("Profit Gained: " + profitGained + "  Profit/h: " + profitHour, 17, 468);
  249.                 g1.drawString(percentTNL + "%", 475, 40);
  250.  
  251.                 //Mouse
  252.                 g.setColor(Color.WHITE);
  253.         g.drawLine(0, (int) (mouse.getLocation().getY()), 800, (int) (mouse.getLocation().getY()));
  254.         g.drawLine((int) (mouse.getLocation().getX()), 0, (int) (mouse.getLocation().getX()), 800);
  255.         g.setColor(Color.WHITE);
  256.         g.drawLine(0, (int) (mouse.getLocation().getY()), 800, (int) (mouse.getLocation().getY()));
  257.         g.drawLine((int) (mouse.getLocation().getX()), 0, (int) (mouse.getLocation().getX()), 800);
  258.         }
  259. }
Advertisement
Add Comment
Please, Sign In to add comment