Ministry

MinistryOfHunterKits v1.0

Jul 20th, 2011
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.99 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.image.BufferedImage;
  3. import java.net.URL;
  4. import javax.imageio.ImageIO;
  5. import org.rsbot.event.events.MessageEvent;
  6. import org.rsbot.event.listeners.MessageListener;
  7. import org.rsbot.event.listeners.PaintListener;
  8.  
  9. import org.rsbot.script.*;
  10. import org.rsbot.script.methods.*;
  11. import org.rsbot.script.methods.Game.Tab;
  12. import org.rsbot.script.methods.Magic.Spell;
  13. import org.rsbot.script.wrappers.*;
  14.  
  15. @ScriptManifest ( authors = { "Ministry" },
  16. keywords = { "Magic, Hunter Kit" },
  17. name = "MinistryOfHunterKits",
  18. description = "Uses Lunar to generate hunter kits.",
  19. version = 1.0 )
  20.  
  21. public class MinistryOfHunterKits extends Script implements PaintListener, MessageListener {
  22.  
  23. private final int astral = 9075, kit = 11159, chest_ID = 12308;
  24.  
  25. private int expGained, expHour, casts, castsHour, startExp, startLvl, currentLvl,
  26. lvlsGained, percentTNL, timeTill;
  27.  
  28. private long startTime, millis, hours, minutes, seconds, STL, MTL, HTL;
  29. private float sXP, mXP, hXP;
  30.  
  31. private BufferedImage normal = null, clicked = null;
  32.  
  33. private boolean bank_kit = false;
  34.  
  35. private String status = "";
  36.  
  37. private enum State { CAST, BANK, WAIT, ANTIBAN };
  38.  
  39. @Override
  40. public boolean onStart() {
  41. startExp = skills.getCurrentExp(Skills.MAGIC);
  42. startLvl = skills.getCurrentLevel(Skills.MAGIC);
  43. startTime = System.currentTimeMillis();
  44. log(Color.MAGENTA, "MinistryOfHunterKits starting...");
  45. try {
  46. final URL cursorURL = new URL("http://i53.tinypic.com/28b7bf9.png");
  47. final URL clickedURL = new URL("http://i55.tinypic.com/30vkjz9.png");
  48. normal = ImageIO.read(cursorURL);
  49. clicked = ImageIO.read(clickedURL);
  50. } catch (Exception e) {
  51. log.severe("Error obtaining custom cursor.");
  52. }
  53. return true;
  54. }
  55.  
  56. public void cast() {
  57. status = "Casting...";
  58. if (game.getCurrentTab() != Game.TAB_MAGIC) {
  59. game.openTab(Game.TAB_MAGIC, true);
  60. } else {
  61. magic.castSpell(Spell.HUNTER_KIT);
  62. mouse.moveRandomly(2, 4);
  63. sleep(random(120, 200));
  64. }
  65. }
  66.  
  67. public void bank() {
  68. status = "Banking...";
  69. RSObject chest = objects.getNearest(chest_ID);
  70. if (!bank.isOpen() && inventory.contains(kit)) {
  71. chest.interact("Bank");
  72. sleep(400);
  73. }
  74. if (bank.isOpen() && inventory.contains(kit)) {
  75. bank.depositAllExcept(astral);
  76. sleep(450);
  77. }
  78. if (bank.isOpen() && !inventory.contains(kit)) {
  79. bank_kit = false;
  80. bank.close();
  81. sleep(400);
  82. }
  83. }
  84.  
  85. public void antiBan() {
  86. status = "Antiban...";
  87. int b = random(0, 24);
  88. switch (b) {
  89. case 1:
  90. if (random(0, 24) == 5) {
  91. mouse.moveSlightly();
  92. sleep(200, 600);
  93. mouse.moveRandomly(150, 350);
  94. }
  95. break;
  96. case 2:
  97. if (random(0, 15) == 2) {
  98. camera.setAngle(random(30, 70));
  99. sleep(400, 1200);
  100. }
  101. break;
  102. case 3:
  103. if (random(0, 24) == 6) {
  104. mouse.moveOffScreen();
  105. sleep(1200, 2000);
  106. }
  107. break;
  108. case 5:
  109. if (random(0, 15) == 4) {
  110. mouse.moveRandomly(900);
  111. sleep(1400, 2400);
  112. }
  113. break;
  114. case 6:
  115. if (random(0, 19) == 5) {
  116. game.openTab(Game.TAB_STATS);
  117. sleep(200);
  118. mouse.move(589, 368, 2, 2);
  119. sleep(400, 500);
  120. mouse.sleep(1500);
  121. game.openTab(Game.TAB_MAGIC);
  122. }
  123. break;
  124. default:
  125. break;
  126. }
  127. }
  128.  
  129. public void messageReceived(MessageEvent e) {
  130. String x = e.getMessage();
  131. if (x.contains("enough astral runes")) {
  132. stopScript(true); }
  133. if (x.contains("need at least one free")) {
  134. bank_kit = true;
  135. }
  136. }
  137.  
  138. private State checkState() {
  139. if (game.isLoggedIn()) {
  140. if (!bank.isOpen() && bank_kit == false) {
  141. return State.CAST; }
  142. if (bank_kit == true) {
  143. bank(); }
  144. while(getMyPlayer().getAnimation() == 6303) {
  145. return State.ANTIBAN;
  146. }
  147. }
  148. return State.WAIT;
  149. }
  150.  
  151. public int loop() {
  152. mouse.setSpeed(random(4, 6));
  153. switch (checkState()) {
  154. case CAST:
  155. cast();
  156. return random (150, 750);
  157. case BANK:
  158. bank();
  159. return random (150, 750);
  160. case WAIT:
  161. sleep(random(400, 500));
  162. return random (150, 750);
  163. case ANTIBAN:
  164. antiBan();
  165. return random (150, 750);
  166. }
  167. return (random(150, 400));
  168. }
  169.  
  170. private final Color color1 = new Color(0, 0, 0);
  171. private final Color color2 = new Color(255, 102, 0);
  172. private final Color color3 = new Color(204, 102, 0);
  173. private final Color color4 = new Color(0, 0, 0, 135);
  174.  
  175. private final Font font1 = new Font("Tahoma", 1, 11);
  176. private final Font font2 = new Font("Tahoma", 0, 9);
  177.  
  178. public void onRepaint(Graphics g) {
  179.  
  180. millis = System.currentTimeMillis() - startTime;
  181. hours = millis / (1000 * 60 * 60);
  182. millis -= hours * (1000 * 60 * 60);
  183. minutes = millis / (1000 * 60);
  184. millis -= minutes * (1000 * 60);
  185. seconds = millis / 1000;
  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) (skills.getExpToNextLevel(Skills.MAGIC) / 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. casts = (skills.getCurrentExp(Skills.MAGIC) - startExp)/70;
  211. castsHour = (int) ((casts) * 3600000D/ (System.currentTimeMillis() - startTime));
  212.  
  213. expGained = casts*70;
  214. expHour = (int) ((expGained) * 3600000D / (System.currentTimeMillis() - startTime));
  215.  
  216. currentLvl = skills.getCurrentLevel(Skills.MAGIC);
  217. lvlsGained = currentLvl - startLvl;
  218. timeTill = (int) skills.getExpToNextLevel(Skills.MAGIC)/expHour;
  219.  
  220. percentTNL = skills.getPercentToNextLevel(Skills.MAGIC);
  221.  
  222. final int percentBar = (int) (skills.getPercentToNextLevel(Skills.MAGIC)*1.97);
  223.  
  224. ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  225. g.setColor(color4);
  226. g.fillRect(311, 230, 197, 101);
  227. g.drawRect(311, 230, 197, 101);
  228. g.setColor(color2);
  229. g.fillRect(308, 227, 197, 101);
  230. g.setColor(color1);
  231. g.drawRect(308, 227, 197, 101);
  232. g.setColor(color2);
  233. g.fillRect(308, 314, 197, 13);
  234. g.setColor(color1);
  235. g.drawRect(308, 314, 197, 13);
  236. g.setColor(color3);
  237. g.fillRect(308, 314, percentBar, 13);
  238. g.setColor(color1);
  239. g.drawRect(308, 314, percentBar, 13);
  240. g.setFont(font1);
  241. g.drawString("MinistryOfHunterKits v1.0", 335, 245);
  242. g.setFont(font2);
  243. g.drawString("Casts: " +casts, 320, 265);
  244. g.drawString("Casts/h: " +castsHour, 392, 265);
  245. g.drawString("Exp: " +expGained, 320, 278);
  246. g.drawString("Exp/h: " +expHour, 392, 278);
  247. g.drawString("Level: " + currentLvl + " (+"+ lvlsGained +")", 320, 292);
  248. g.drawString("TimeTill: " + HTL + ":" + MTL + ":" + STL, 392, 293);
  249. g.drawString("Status: " + status ,392, 307);
  250. g.drawString(percentTNL + "%", 399, 325);
  251. g.drawString("Runtime: " +hours + ":" + minutes + ":" + seconds, 319, 307);
  252.  
  253. if (clicked != null) {
  254. final int mx = (int)mouse.getLocation().getX();
  255. final int my = (int)mouse.getLocation().getY();
  256. final long mpt = System.currentTimeMillis() - mouse.getPressTime();
  257. if (mouse.getPressTime() == -1 || mpt >= 300)
  258. g.drawImage(normal, mx - 10, my - 6, null);
  259. if (mpt < 300)
  260. g.drawImage(clicked, mx - 10, my - 6, null);
  261. }
  262. }
  263. }
Advertisement
Add Comment
Please, Sign In to add comment