Guest User

Untitled

a guest
Jan 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.80 KB | None | 0 0
  1.  
  2. import org.rsbot.script.*;
  3. import org.rsbot.event.listeners.PaintListener;
  4.  
  5. import java.awt.*;
  6. import java.text.DecimalFormat;
  7. import java.text.NumberFormat;
  8.  
  9. @ScriptManifest(authors = "Danielmedvec", keywords = "HunterKit", name = "DmKitOpener", version = 1.2, description = "Flawless!")
  10. public class DMKITOPENER extends Script implements PaintListener {
  11.  
  12. public int kit = 11159;
  13. public int[] content = {10150, 10010, 10006, 10031, 10029, 10008};
  14. public int contentPrice;
  15. public int kitPrice;
  16. public int profitPerKit;
  17. public int kitsopened = 0;
  18. public int kitsperhour;
  19. public int kitcount;
  20. public NumberFormat groupingFormat = new DecimalFormat("###,###,###");
  21. public long startTime = System.currentTimeMillis();
  22. private final RenderingHints antialiasing = new RenderingHints(
  23. RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  24.  
  25. private final Color color1 = new Color(255, 255, 255, 100);
  26. private final Color color2 = new Color(0, 0, 0);
  27. private final Color color3 = new Color(0, 0, 255);
  28. private final Color color4 = new Color(255, 0, 0);
  29. private final BasicStroke stroke1 = new BasicStroke(1);
  30. private final BasicStroke stroke2 = new BasicStroke(2);
  31. private final Font font1 = new Font("Calibri", 1, 17);
  32. private final Font font2 = new Font("Calibri", 0, 17);
  33. private final Font font3 = new Font("Calibri", 0, 10);
  34. private final Font font4 = new Font("Calibri", 1, 12);
  35.  
  36. @Override
  37. public boolean onStart() {
  38. mouse.setSpeed(random(7,10));
  39. calculateProfits();
  40. kitcount = inventory.getCount(kit);
  41. return true;
  42. }
  43.  
  44. private void calculateProfits()
  45. {
  46. kitPrice = grandExchange.lookup(kit).getGuidePrice();
  47. contentPrice = 0;
  48. for(int itemID : content)
  49. {
  50. contentPrice += grandExchange.lookup(itemID).getGuidePrice();
  51. }
  52. profitPerKit = contentPrice - kitPrice;
  53. }
  54.  
  55. public boolean openKit() {
  56. inventory.getItem(kit).doAction("Open");
  57. if(inventory.getCount(kit) < kitcount)
  58. {
  59. kitcount--;
  60. kitsopened++;
  61. return true;
  62. }
  63. return false;
  64. }
  65.  
  66. public boolean deposit() {
  67. bank.open();
  68. bank.depositAll();
  69. return true;
  70. }
  71.  
  72. public boolean withdraw() {
  73. if (!bank.isOpen()) {
  74. bank.open();
  75. bank.withdraw(kit, 4);
  76. bank.close();
  77. } else {
  78. if (bank.isOpen()) {
  79. bank.withdraw(kit, 4);
  80. }
  81. bank.close();
  82. sleep(50, 400);
  83. }
  84. kitcount = inventory.getCount(kit);
  85. return true;
  86. }
  87.  
  88. private String formatTime(long millis) {
  89. long hours = millis / (1000 * 60 * 60);
  90. millis -= hours * (1000 * 60 * 60);
  91. long minutes = millis / (1000 * 60);
  92. millis -= minutes * (1000 * 60);
  93. long seconds = millis / 1000;
  94. return String.format("%02d", hours) + ":" + String.format("%02d", minutes) + ":" + String.format("%02d", seconds);
  95. }
  96.  
  97. public void onRepaint(Graphics g1) {
  98. Graphics2D g = (Graphics2D) g1;
  99. g.setRenderingHints(antialiasing);
  100.  
  101. int x = (int) mouse.getLocation().getX();
  102. int y = (int) mouse.getLocation().getY();
  103. g.setColor(color4);
  104. g.setStroke(stroke2);
  105. g.drawLine(x-6, y, x+6, y);
  106. g.drawLine(x, y-6, x, y+6);
  107.  
  108.  
  109. long millis = System.currentTimeMillis() - startTime;
  110. float hours = (float) millis / 3600000f;
  111. int profit = kitsopened * profitPerKit;
  112. int profitPerHour = (int) (profit / hours);
  113.  
  114. String runtimeStr = formatTime(millis);
  115. String kitsopenedStr = Integer.toString(kitsopened);
  116. String profitStr = groupingFormat.format(profit);
  117. String profitPerHourStr = groupingFormat.format(profitPerHour);
  118.  
  119. g.setColor(color1);
  120. g.fillRoundRect(275, 266, 218, 69, 16, 16);
  121. g.setColor(color2);
  122. g.setStroke(stroke1);
  123. g.drawRoundRect(275, 266, 218, 69, 16, 16);
  124. g.setFont(font1);
  125. g.drawString("DM Kit Opener", 286, 282);
  126. g.setFont(font2);
  127. g.drawString("v" + Double.toString(DMKITOPENER.class.getAnnotation(ScriptManifest.class).version()), 457, 283);
  128. g.setFont(font3);
  129. g.drawString("Profit/hour", 387, 324);
  130. g.drawString("Profit", 387, 308);
  131. g.drawString("Runtime", 283, 308);
  132. g.drawString("Kits opened", 283, 324);
  133. g.setFont(font4);
  134. g.setColor(color3);
  135. g.drawString(profitPerHourStr, 436, 324);
  136. g.drawString(profitStr, 436, 308);
  137. g.drawString(kitsopenedStr, 336, 324);
  138. g.drawString(runtimeStr, 336, 308);
  139. }
  140.  
  141. @Override
  142. public int loop() {
  143. if (inventory.contains(kit)) {
  144. openKit();
  145. } else if (inventory.containsAll(content) && !inventory.contains(kit)) {
  146. deposit();
  147. } else if (!inventory.containsAll(content) && !inventory.contains(kit)) {
  148. withdraw();
  149. }
  150. return random(600, 1600);
  151. }
  152. }
Add Comment
Please, Sign In to add comment