Guest User

Untitled

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