wafflecat

Untitled

Mar 13th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. //This script is the sole property of Robert G
  2. //Anyone found re-distributing it may face legal consequences!
  3.  
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.Graphics;
  7. import java.awt.Graphics2D;
  8. import java.awt.RenderingHints;
  9. import java.text.NumberFormat;
  10.  
  11. import com.rarebot.event.events.MessageEvent;
  12. import com.rarebot.event.listeners.MessageListener;
  13. import com.rarebot.event.listeners.PaintListener;
  14. import com.rarebot.script.Script;
  15. import com.rarebot.script.ScriptManifest;
  16. import com.rarebot.script.methods.Skills;
  17. import com.rarebot.script.wrappers.RSNPC;
  18.  
  19.  
  20.  
  21. @ScriptManifest(name = "Simple Thiever", authors = {"Robert G"}, description = "Trains thieving at the Thieves' Guild on the Pickpocketing trainer.")
  22. public class SimpleThiever extends Script implements MessageListener, PaintListener {
  23.  
  24. private static final int trainerID = 11281;
  25. private static int curXP, startXP, curLVL, startLVL, picked = 0;
  26. private static final long startTime = System.currentTimeMillis();
  27. private static long runTime;
  28. private static String status = "Loading...";
  29. private static boolean stunned;
  30. private static final NumberFormat nf = NumberFormat.getInstance();
  31. private final RenderingHints antialiasing = new RenderingHints(
  32. RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  33.  
  34. @Override
  35. public boolean onStart() {
  36. startXP = skills.getCurrentExp(Skills.THIEVING);
  37. startLVL = skills.getRealLevel(Skills.THIEVING);
  38. return true;
  39. }
  40.  
  41. @Override
  42. public int loop() {
  43. mouse.setSpeed(random(3, 5));
  44. if (stunned) {
  45. status = "Stunned, waiting 3 seconds.";
  46. sleep(3000, 3500);
  47. stunned = false;
  48. } else {
  49. RSNPC x = npcs.getNearest(trainerID);
  50. if (x != null) {
  51. if (x.isOnScreen()) {
  52. status = "Picking trainers pocket.";
  53. if (x.interact("Pickpocket " + x.getName())) {
  54. return random(1000, 1200);
  55. }
  56. } else {
  57. status = "Walking to trainer.";
  58. if (walking.walkTileMM(x.getLocation())) {
  59. return random(1000, 1200);
  60. }
  61. }
  62. }
  63. }
  64. return 0;
  65. }
  66.  
  67.  
  68. @Override
  69. public void messageReceived(MessageEvent e) {
  70. String x = e.getMessage().toLowerCase();
  71. if (x.contains("you retrieve a")) {
  72. picked++;
  73. }
  74. if (x.contains("you've been stunned")) {
  75. stunned = true;
  76. }
  77. }
  78.  
  79. private static String formatTime(final long time) {
  80. final int sec = (int) (time / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60;
  81. return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":"
  82. + (s < 10 ? "0" + s : s);
  83. }
  84.  
  85. private int PH(int arg0) {
  86. int PH = (int) (3600000.0 / runTime * arg0);
  87. return PH;
  88. }
  89.  
  90. private String nf(int number) {
  91. return nf.format(number);
  92. }
  93.  
  94. @Override
  95. public void onRepaint(Graphics g1) {
  96. Graphics2D g = (Graphics2D) g1;
  97. g.setRenderingHints(antialiasing);
  98. runTime = (System.currentTimeMillis() - startTime);
  99. curXP = skills.getCurrentExp(Skills.THIEVING) - startXP;
  100. curLVL = skills.getRealLevel(Skills.THIEVING);
  101. int aTrans = 200;
  102. int x = 0, y = 0, width = 190, height = 1;
  103. for (int i = 0; i < 210; i++) {
  104. Color a = new Color(0, 0, 0, aTrans);
  105. g.setColor(a);
  106. g.fillRect(x, y, width, height);
  107. y++;
  108. if (aTrans > 0)
  109. aTrans--;
  110. }
  111. int t = 20;
  112. g.setColor(Color.white);
  113. g.setFont(new Font("Calibri", 1, 20));
  114. g.drawString("SimpleThiever", 10, t);
  115. t += 20;
  116. g.setFont(new Font("Calibri", 0, 14));
  117. g.drawString("Run Time: " + formatTime(runTime), 10, t);
  118. t += 20;
  119. g.drawString("Picked: " + nf(picked), 10, t);
  120. t += 20;
  121. g.drawString("Picked Ph: " + nf(PH(picked)), 10, t);
  122. t += 20;
  123. g.drawString("Exp Gained: " + nf(curXP), 10, t);
  124. t += 20;
  125. g.drawString("Exp Ph: " + nf(PH(curXP)), 10, t);
  126. t += 20;
  127. g.drawString("Levels Gained: " + (curLVL - startLVL), 10, t);
  128. t += 20;
  129. g.drawString("Current Level: " + curLVL, 10, t);
  130. t += 10;
  131. // stat bar
  132. int percent = skills.getPercentToNextLevel(Skills.THIEVING);
  133. int length = (percent * 170) / 100;
  134. g.setColor(Color.red);
  135. g.fillRect(10, t, 170, 20);
  136. g.setColor(Color.black);
  137. g.drawRect(10, t, 170, 20);
  138. g.setColor(Color.green);
  139. g.fillRect(10, t, length, 20);
  140. g.setColor(Color.black);
  141. g.drawRect(10, t, length, 20);
  142. g.setColor(Color.black);
  143. g.drawString(percent + "% (" + nf(skills.getExpToNextLevel(Skills.THIEVING))+ " Xp Tnl)", 40, t + 15);
  144. g.setColor(Color.black);
  145. g.drawString("Status: " + status, 5, 335);
  146. g.drawLine(0, (int) (mouse.getLocation().getY()) + 1, 800,
  147. (int) (mouse.getLocation().getY()) + 1);
  148. g.drawLine((int) (mouse.getLocation().getX()) + 1, 0,
  149. (int) (mouse.getLocation().getX()) + 1, 800);
  150. }
  151.  
  152. }
Add Comment
Please, Sign In to add comment