Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1.  
  2. import java.awt.BasicStroke;
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7.  
  8. import org.rsbot.event.events.MessageEvent;
  9. import org.rsbot.event.listeners.MessageListener;
  10. import org.rsbot.event.listeners.PaintListener;
  11. import org.rsbot.script.Script;
  12. import org.rsbot.script.ScriptManifest;
  13. import org.rsbot.script.methods.Skills;
  14. import org.rsbot.script.wrappers.RSObject;
  15.  
  16. @ScriptManifest(authors = { "clScripts" }, keywords = "mining", name = "clPowerMiner", version = 1.0, description = "Power Mines Tin & Copper. First Script!")
  17.  
  18.  
  19.  
  20.  
  21. public class clPowerMiner extends Script implements PaintListener, MessageListener {
  22.  
  23. ScriptManifest props = getClass().getAnnotation(ScriptManifest.class);
  24.  
  25. int[] rockID ={3245, 3038, 3229, 3027 };
  26. int miningAnimation = 628;
  27. int pickaxe = 1271;
  28. int oresMined = 0;
  29. long startTime;
  30.  
  31. int expGained = 0;
  32. int startExp = 0;
  33.  
  34. private int levelsGained;
  35.  
  36.  
  37.  
  38. public boolean onStart(){
  39. log("Welcome! Have fun botting!");
  40. log("You are using version " + props.version());
  41. startTime = System.currentTimeMillis();
  42. startExp = skills.getCurrentExp(Skills.MINING);
  43. return true;
  44. }
  45.  
  46. @Override
  47. public int loop() {
  48. if(atSite()){
  49. minerock();
  50. if(inventory.isFull()){
  51. inventory.dropAllExcept(pickaxe);
  52.  
  53. }
  54. }
  55. return random(1500, 2000);
  56. }
  57.  
  58. public void onFinish() {
  59. log("Thank you for using cPowerMiner!");
  60. }
  61. private boolean atSite() {
  62. RSObject rock = objects.getNearest(rockID);
  63. if(rock != null){
  64. if(rock.isOnScreen()){
  65. if(random(1, 15) ==4)antiBan();
  66. return true;
  67. }
  68.  
  69. }
  70. return false;
  71. }
  72. private void minerock(){
  73. RSObject rock = objects.getNearest(rockID);
  74. if(getMyPlayer().getAnimation() != miningAnimation)
  75. rock.doAction("Mine");
  76. sleep(1000, 2000 );
  77. if(random(1, 16) ==8)antiBan();
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84. @Override
  85. public void onRepaint(Graphics g){
  86. g.setColor(Color.ORANGE);
  87. g.drawLine(mouse.getLocation().x - 6, mouse.getLocation().y, mouse.getLocation().x + 6,
  88. mouse.getLocation().y);
  89. g.drawLine(mouse.getLocation().x, mouse.getLocation().y - 6,mouse.getLocation().x,mouse.getLocation().y + 6);
  90. g.setColor(Color.GREEN);
  91. g.drawLine(mouse.getPressLocation().x - 6, mouse.getPressLocation().y, mouse.getPressLocation().x + 6, mouse.getPressLocation().y);
  92. g.drawLine(mouse.getPressLocation().x, mouse.getPressLocation().y - 6, mouse.getPressLocation().x, mouse.getPressLocation().y + 6);
  93.  
  94.  
  95. //START: Code generated using Enfilade's Easel
  96. final Color color1 = new Color(0, 0, 204, 207);
  97. final Color color2 = new Color(0, 0, 0);
  98. final Color color3 = new Color(102, 0, 102);
  99. final Color color4 = new Color(255, 0, 0, 225);
  100.  
  101. final BasicStroke stroke1 = new BasicStroke(1);
  102.  
  103. final Font font1 = new Font("Rockwell Condensed", 1, 22);
  104. final Font font2 = new Font("SansSerif", 1, 18);
  105.  
  106.  
  107.  
  108. //END: Code generated using Enfilade's Easel
  109.  
  110. expGained = skills.getCurrentExp(Skills.MINING) - startExp;
  111.  
  112.  
  113.  
  114. long millis = System.currentTimeMillis() - startTime;
  115. long hours = millis / (1000 * 60 *60);
  116. millis -= hours * (1000 *60 *60);
  117. long minutes = millis / (1000 * 60);
  118. millis -= minutes * (1000 * 60);
  119. long seconds = millis / 1000;
  120. g.setColor(Color.cyan);
  121.  
  122.  
  123.  
  124. g.setFont(new Font("Arial", 5, 17));
  125. float xpsec = 0;
  126. if((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  127. xpsec = ((float) expGained)/(seconds + (minutes*60) + (hours*60*60));
  128. }
  129. float xpmin = xpsec * 60;
  130. float xphour = xpmin * 60;
  131.  
  132. float oresec = 0;
  133. if((minutes > 0 || hours > 0 || seconds > 0) && oresMined > 0) {
  134. oresec = ((float) oresMined)/(seconds + (minutes*60) + (hours*60*60));
  135. }
  136. float oremin = oresec * 60;
  137.  
  138. float orehour = oremin * 60;
  139.  
  140. Graphics2D g11 = (Graphics2D)g;
  141. g11.setColor(color1);
  142. g11.fillRect(61, 346, 433, 125);
  143. g11.setColor(color2);
  144. g11.setStroke(stroke1);
  145. g11.drawRect(61, 346, 433, 125);
  146. g11.setFont(font1);
  147. g11.setColor(color3);
  148. g11.drawString("clPowerMiner Version" + props.version(), 259, 367);
  149. g11.setFont(font2);
  150. g11.setColor(color4);
  151. g11.drawString("Runtime:"+ hours + ":" + minutes + ":" + seconds, 69, 393);
  152. g11.drawString("Experience gained:" + expGained + " Exp/h: " + (int)xphour, 69, 412);
  153. g11.drawString("Ores mined:" + oresMined + " Ores/h: " + (int)orehour, 69, 433);
  154. g11.drawString("Levels gained:" + levelsGained , 69, 452 );
  155.  
  156.  
  157. }
  158.  
  159. @Override
  160. public void messageReceived(MessageEvent e) {
  161. String txt = e.getMessage();
  162. if(txt.contains("You manage to mine")){
  163. oresMined++;
  164. }
  165. if(txt.contains("You've just advanced a Mining" )){
  166. levelsGained++;
  167. log("You have advanced a level thanks to clPowerMiner!");
  168.  
  169.  
  170. }
  171.  
  172.  
  173. }
  174.  
  175. public void antiBan() {
  176. int b = random(0, 30);
  177. switch(b) {
  178. case 3:
  179. mouse.moveSlightly();
  180. sleep(500, 800);
  181. break;
  182. case 7:
  183. mouse.moveRandomly(10, 50);
  184. sleep(1500);
  185. break;
  186. case 16:
  187. mouse.moveOffScreen();
  188. sleep(2000);
  189. break;
  190. case 18:
  191. camera.moveRandomly(random(750, 1250));
  192. break;
  193. case 9: camera.setNorth();
  194. break;
  195. case 20:
  196. camera.moveRandomly(1564);
  197. break;
  198. }
  199. }
  200.  
  201.  
  202.  
  203.  
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement