Guest User

Untitled

a guest
Jul 22nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.24 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.KeyEvent;
  3. import java.util.*;
  4. import java.util.List;
  5. import java.util.logging.Level;
  6. import javax.accessibility.*;
  7. import javax.swing.*;
  8. import org.rsbot.bot.Bot;
  9. import org.rsbot.bot.input.CanvasWrapper;
  10. import org.rsbot.script.*;
  11. import org.rsbot.script.wrappers.*;
  12. import org.rsbot.event.listeners.PaintListener;
  13. import org.rsbot.event.listeners.ServerMessageListener;
  14. import org.rsbot.event.events.ServerMessageEvent;
  15.  
  16. @ScriptManifest(authors = { "Grapes" }, category = "Combat", name = "gYaks", version = 1.00, description = "<html><head></head><body><center><h1>gYaks v1.00</h1></center><br>"
  17. + "<center><strong>By Grapes</strong></center><br>"
  18. + "<br>"
  19. + "<center><strong>ENJOY!</strong></center><br>")
  20. public class gYaks extends Script implements PaintListener,
  21. ServerMessageListener {
  22.  
  23. // *VARIABLES*\\
  24. private final ScriptManifest properties = getClass().getAnnotation(
  25. ScriptManifest.class);
  26.  
  27. private final int[] yakID = { 5529 };
  28. private final int[] foodID = { 6701, 365, 1891, 1897, 2011, 379, 7946, 329,
  29. 385, 333, 361 };
  30.  
  31. public long startTime = System.currentTimeMillis();
  32. long runTime = System.currentTimeMillis() - startTime;
  33.  
  34. public int strengthExp = skills.getCurrentSkillExp(STAT_STRENGTH);
  35. public int attackExp = skills.getCurrentSkillExp(STAT_ATTACK);
  36. public int defenseExp = skills.getCurrentSkillExp(STAT_DEFENSE);
  37. public int rangeExp = skills.getCurrentSkillExp(STAT_RANGE);
  38. public int hitpointsExp = skills.getCurrentSkillExp(STAT_HITPOINTS);
  39.  
  40. public int gainedStrength = skills.getCurrentSkillExp(STAT_STRENGTH)
  41. - strengthExp;
  42. public int gainedAttack = skills.getCurrentSkillExp(STAT_ATTACK)
  43. - attackExp;
  44. public int gainedDefense = skills.getCurrentSkillExp(STAT_DEFENSE)
  45. - defenseExp;
  46. public int gainedRange = skills.getCurrentSkillExp(STAT_RANGE) - rangeExp;
  47. public int gainedHitpoints = skills.getCurrentSkillExp(STAT_HITPOINTS)
  48. - hitpointsExp;
  49.  
  50. public int totalXpGained = gainedStrength + gainedAttack + gainedDefense
  51. + gainedRange;
  52.  
  53. public int Hp = skills.getCurrentSkillExp(STAT_HITPOINTS);
  54.  
  55. int xpPerHour = (int) (3600000.0 / runTime * gainedStrength);
  56.  
  57. protected int getMouseSpeed() {
  58. return (random(6, 9));
  59. }
  60.  
  61. // *START*\\
  62. public boolean onStart(Map<String, String> args) {
  63. startTime = System.currentTimeMillis();
  64. log("Script has begun.");
  65. return true;
  66. }
  67.  
  68. public boolean run() {
  69. if (!isRunning() && getEnergy() > 50) {
  70. setRun(true);
  71. }
  72. return true;
  73. }
  74.  
  75. public boolean eat() {
  76. if (skills.getCurrentSkillLevel(STAT_HITPOINTS) <= (skills
  77. .getRealSkillLevel(STAT_HITPOINTS) / 4)) {
  78. for (int i = 0; i < foodID.length; i++) {
  79. if (getInventoryCount(foodID[i]) != 0) {
  80. atInventoryItem(foodID[i], "Eat");
  81. if (getInventoryCount(foodID[i]) != 0) {
  82. wait(random(436, 669));
  83. }
  84. return true;
  85. }
  86. if (foodID == null)
  87. ;
  88. return false;
  89. }
  90. return true;
  91. }
  92. return true;
  93. }
  94.  
  95. public boolean attackYak() {
  96. RSNPC Yak = getNearestFreeNPCToAttackByID(yakID);
  97. {
  98. atNPC(Yak, "Attack");
  99. wait(random(1000, 1500));
  100. if (getMyPlayer().getInteracting() != null) {
  101. moveMouseRandomly(random(3000, 10000));
  102. }
  103. return true;
  104. }
  105. }
  106.  
  107. public int loop() {
  108. {
  109. while (getMyPlayer().isMoving()) {
  110. return (random(100, 300));
  111. }
  112. if (!isRunning() && getEnergy() > 50) {
  113. setRun(true);
  114. }
  115. if (skills.getCurrentSkillLevel(STAT_HITPOINTS) <= (skills
  116. .getRealSkillLevel(STAT_HITPOINTS) / 4)) {
  117. eat();
  118. }
  119. if (getMyPlayer().getInteracting() != null) {
  120. return random(300, 450);
  121. }
  122. if (getMyPlayer().getInteracting() == null) {
  123. attackYak();
  124. }
  125. run();
  126. wait(random(500, 700));
  127. }
  128. return 100;
  129. }
  130.  
  131. public void serverMessageRecieved(ServerMessageEvent e) {
  132. String msg = e.getMessage();
  133. if (msg.contains("Oh dear"))
  134. ;
  135. stopScript();
  136. log("You died noob.");
  137. }
  138.  
  139. // *PAINT*\\
  140. public void onRepaint(Graphics g) {
  141. if (!isLoggedIn() || isLoginScreen())
  142. return;
  143. long millis = System.currentTimeMillis() - startTime;
  144. long hours = millis / (1000 * 60 * 60);
  145. millis -= hours * (1000 * 60 * 60);
  146. long minutes = millis / (1000 * 60);
  147. millis -= minutes * (1000 * 60);
  148. long seconds = millis / 1000;
  149. long minutes2 = minutes + (hours * 60);
  150. g.setColor(new Color(128, 0, 0, 128));
  151. g.fillRoundRect(550, 206, 185, 260, 10, 10);
  152. g.setColor(Color.white);
  153. g.setFont(new Font("Arial", Font.BOLD, 13));
  154. g.drawString("gYaks V 1.00", 610, 225);
  155. g.setFont(new Font("Arial", Font.PLAIN, 12));
  156. g.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds,
  157. 560, 255);
  158. gainedStrength = skills.getCurrentSkillExp(STAT_STRENGTH) - strengthExp;
  159. gainedAttack = skills.getCurrentSkillExp(STAT_ATTACK) - attackExp;
  160. gainedDefense = skills.getCurrentSkillExp(STAT_DEFENSE) - defenseExp;
  161. gainedHitpoints = skills.getCurrentSkillExp(STAT_HITPOINTS)
  162. - hitpointsExp;
  163. g.drawString("Strength XP Gained: " + gainedStrength, 560, 295);
  164. g.drawString("Attack XP Gained: " + gainedAttack, 560, 335);
  165. g.drawString("Defense XP Gained: " + gainedDefense, 560, 375);
  166. g.drawString("Hitpoints XP Gained: " + gainedHitpoints, 560, 415);
  167. float xpPerSec = 0;
  168. if ((minutes > 0 || hours > 0 || seconds > 0) && totalXpGained > 0) {
  169. xpPerSec = (float) totalXpGained
  170. / (float) (seconds + minutes * 60 + hours * 60 * 60);
  171. }
  172. final float xpPerMin = xpPerSec * 60;
  173. final float xpPerHour = xpPerMin * 60;
  174. totalXpGained = gainedStrength + gainedAttack + gainedDefense
  175. + gainedRange;
  176. g.drawString("Exp/Hour: " + xpPerHour, 560, 455);
  177. }
  178.  
  179. // AntiBan
  180. // Credits to Foulwerp
  181. public int antiban() {
  182. int i = random(0, 20);
  183. if (i == 2) {
  184. moveMouse(random(5, CanvasWrapper.getGameWidth()), random(0,
  185. CanvasWrapper.getGameHeight()));
  186. return random(0, 400);
  187. } else if (i == 3 || i == 12) {
  188. char dir = 37;
  189. if (random(0, 3) == 2) {
  190. dir = 39;
  191. }
  192. Bot.getInputManager().pressKey(dir);
  193. wait(random(500, 2000));
  194. Bot.getInputManager().releaseKey(dir);
  195. return random(0, 500);
  196. } else if (i == 7 || i == 4) {
  197. setCameraAltitude(random(35, 150));
  198. return random(0, 500);
  199. } else if (i == 5 || i == 10 || i == 11 || i == 13 || i == 18) {
  200. moveMouseRandomly(random(-4, 4));
  201. } else if (i == 1 || i == 8 || i == 15 || i == 20) {
  202. Thread camera = new Thread() {
  203. @Override
  204. public void run() {
  205. char dir = 37;
  206. if (random(0, 3) == 2)
  207. dir = 39;
  208. Bot.getInputManager().pressKey(dir);
  209. try {
  210. Thread.sleep(random(500, 2000));
  211. } catch (InterruptedException e) {
  212. e.printStackTrace();
  213. }
  214. Bot.getInputManager().releaseKey(dir);
  215. }
  216. };
  217. Thread mouse = new Thread() {
  218. @Override
  219. public void run() {
  220. moveMouse(random(0, CanvasWrapper.getGameWidth()), random(
  221. 0, CanvasWrapper.getGameHeight()));
  222. }
  223. };
  224. if (i == 7 || i == 20) {
  225. camera.start();
  226. }
  227. if (i == 1) {
  228. mouse.start();
  229. }
  230. while (camera.isAlive() || mouse.isAlive()) {
  231. wait(random(100, 300));
  232. return random(300, 700);
  233. }
  234. }
  235. return random(1000, 1500);
  236. }
  237.  
  238. public void onFinish() {
  239. log("Script has stopped.");
  240. }
  241. }
Add Comment
Please, Sign In to add comment