Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.98 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.Point;
  6. import java.awt.RenderingHints;
  7. import java.text.DecimalFormat;
  8.  
  9. import org.rsbot.event.events.ServerMessageEvent;
  10. import org.rsbot.event.listeners.PaintListener;
  11. import org.rsbot.event.listeners.ServerMessageListener;
  12. import org.rsbot.script.Script;
  13. import org.rsbot.script.ScriptManifest;
  14. import org.rsbot.script.methods.Skills;
  15. import org.rsbot.script.util.Filter;
  16. import org.rsbot.script.wrappers.RSGroundItem;
  17. import org.rsbot.script.wrappers.RSItem;
  18. import org.rsbot.script.wrappers.RSNPC;
  19. import org.rsbot.script.wrappers.RSTile;
  20.  
  21. @ScriptManifest (authors = {"Patrick"}, name = "Ghouls Virus whiper", description = "Whipes out the ghouls viruz!", version = 1.5)
  22. public class GhoulViruzWhiper extends Script implements PaintListener, ServerMessageListener {
  23.  
  24. private long start, ttl;
  25. private int exp;
  26. private double eph;
  27. private DecimalFormat k = new DecimalFormat("#.#");
  28. private int[] lootID = {12158, 12163, 12160, 12159, 10266, 10264, 10265, 10263};
  29. private int[] skill = { 0, 1, 2, 3, 4, 6 }, startXP;
  30. private int[] potionID = {2436, 145, 149, 147, 2440, 159, 157, 161, 2442, 165, 163, 167};
  31. private static final int[] bones = {526, 532, 530, 528, 3183, 2859};
  32. private static final String[] skillNames = { "Attack", "Defence", "Strength", "Constitution", "Range", "Magic" };
  33. private static final Color[] skillColors = { new Color(145, 25, 25).brighter(), new Color(95, 115, 185), Color.GREEN.darker(), Color.WHITE.darker(), new Color(70, 95, 20).brighter(), new Color(95, 115, 230) };
  34. RSTile[] ghoulToBank = { new RSTile(3421, 3505), new RSTile(3431, 3497),
  35. new RSTile(3446, 3493), new RSTile(3458, 3483),
  36. new RSTile(3472, 3275), new RSTile(3002, 3289),
  37. new RSTile(3001, 3301), new RSTile(3005, 3312),
  38. new RSTile(3006, 3322), new RSTile(3007, 3336),
  39. new RSTile(3006, 3352), new RSTile(3012, 3355) };
  40.  
  41. @Override
  42. public boolean onStart() {
  43. startXP = new int[6];
  44. for (int i = 0; i < skill.length; i++) {
  45. startXP[i] = skills.getCurrentExp(skill[i]);
  46. }
  47. start = System.currentTimeMillis();
  48. return true;
  49. }
  50. private void drinkPotion() {
  51. RSItem Potion = inventory.getItem(potionID);
  52. if (inventory.containsOneOf(potionID)) {
  53. Potion.doAction("Drink");
  54. }
  55. }
  56.  
  57. @Override
  58. public int loop() {
  59. mouse.setSpeed(random(4, 7));
  60. if (!game.isLoggedIn()) {
  61. return 3000;
  62. }
  63. drinkPotion();
  64. if (!walking.isRunEnabled() && walking.getEnergy() > 60) {
  65. walking.setRun(true);
  66. return random(750, 1000);
  67. }
  68. if (players.getMyPlayer().getInteracting() != null) {
  69. if (combat.getLifePoints() < (skills.getRealLevel(3) * 10) / 2) {
  70. RSItem food = edible();
  71. if (food != null) {
  72. food.doAction("Eat ");
  73. } else {
  74. game.logout(true);
  75. log("Out of food...");
  76. return -1;
  77. }
  78. return random(900, 1100);
  79. }
  80. if (interfaces.canContinue()) {
  81. interfaces.clickContinue();
  82. }
  83. return random(400, 600);
  84. }
  85.  
  86. RSGroundItem loot = pickup();
  87. if (loot != null) {
  88. if (players.getMyPlayer().isMoving()) {
  89. return random(400, 600);
  90. }
  91. if (inventory.isFull()) {
  92. if (inventory.getItem(bones) != null) {
  93. inventory.getItem(bones).doAction("Drop");
  94. return random(800, 1000);
  95. } else if (edible() != null) {
  96. edible().doAction("Eat");
  97. antiban();
  98. return random(800, 1000);
  99. }
  100. } else {
  101. if (!loot.isOnScreen()) {
  102. camera.turnToTile(loot.getLocation(), 15);
  103. if (!loot.isOnScreen()) {
  104. walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
  105. return random(900, 1200);
  106. }
  107. }
  108. loot.doAction("Take " + loot.getItem().getName());
  109. antiban();
  110. return random(900, 1100);
  111. }
  112. }
  113.  
  114. RSNPC ghoul = newNPC();
  115. if (ghoul == null || players.getMyPlayer().isMoving() && !ghoul.isOnScreen()) {
  116. return random(400, 600);
  117. }
  118. if (!ghoul.isOnScreen()) {
  119. turnTo(camera.getCharacterAngle(ghoul), ghoul);
  120. if (!ghoul.isOnScreen()) {
  121. walking.walkTileMM(walking.getClosestTileOnMap(ghoul.getLocation()));
  122. return random(900, 1200);
  123. }
  124. }
  125. ghoul.doAction("Attack "+ghoul.getName());
  126. antiban();
  127. return random(900, 1100);
  128. }
  129.  
  130. @Override
  131. public void onRepaint(Graphics render) {
  132. int y = 365, z = 356, w = 196, x = 201;
  133. final Graphics2D g = (Graphics2D)render;
  134. long runTime = System.currentTimeMillis() - start;
  135. g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  136. g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  137. Point m = mouse.getLocation();
  138. g.drawLine((int) m.getX() - 3, (int) m.getY(), (int) m.getX() + 3, (int) m.getY());
  139. g.drawLine((int) m.getX(), (int) m.getY() - 3, (int) m.getX(), (int) m.getY()+ 3);
  140. g.setFont(new Font("Comic Sans MS", Font.PLAIN, 10));
  141. g.setColor(Color.BLACK);
  142. g.drawRect(w, 345, 300, 11);
  143. g.setColor(new Color(0, 0, 0, 220));
  144. g.fillRect(w, 345, 300, 11);
  145. g.setColor(Color.WHITE);
  146. g.drawString("Ghouls Viruz Whiper- Run Time: "+format(runTime)+" - Version 1.5", x, 354);
  147. for (int i = 0; i < 6; i++, exp = 0, eph = 0, ttl = 0) {
  148. exp = (skills.getCurrentExp(skill[i]) - startXP[i]);
  149. if (exp > 0) {
  150. eph = (exp * 3600000D / (System.currentTimeMillis() - start));
  151. ttl = (long) ((skills.getExpToNextLevel(skill[i]) * 3600000D) / eph);
  152. g.setColor(Color.BLACK);
  153. g.drawRect(w, z, 300, 11);
  154. g.setColor(new Color(0, 0, 0, 220));
  155. g.fillRect(w, z, 300, 11);
  156. g.setColor(skillColors[i]);
  157. g.drawString(skillNames[i]+": "+k.format(exp / 1000D)+" K Earned - "+k.format(eph / 1000)
  158. +" K P/H - "+format(ttl)+" TTL", x, y);
  159. y += 11;
  160. z += 11;
  161. }
  162. }
  163. }
  164.  
  165. private String format(long time) {
  166. if (time <= 0) {
  167. return "--:--:--";
  168. }
  169. final StringBuilder t = new StringBuilder();
  170. final long TotalSec = time / 1000;
  171. final long TotalMin = TotalSec / 60;
  172. final long TotalHour = TotalMin / 60;
  173. final int second = (int) TotalSec % 60;
  174. final int minute = (int) TotalMin % 60;
  175. final int hour = (int) TotalHour;
  176. if (hour < 10) {
  177. t.append("0");
  178. }
  179. t.append(hour);
  180. t.append(":");
  181. if (minute < 10) {
  182. t.append("0");
  183. }
  184. t.append(minute);
  185. t.append(":");
  186. if (second < 10) {
  187. t.append("0");
  188. }
  189. t.append(second);
  190. return t.toString();
  191. }
  192.  
  193. private RSGroundItem pickup() {
  194. return groundItems.getNearest(new Filter<RSGroundItem>() {
  195. public boolean accept(RSGroundItem g) {
  196. if (lootID == null) {
  197. return false;
  198. }
  199. if (inventory.getCount() >= 27) {
  200. for (int b : bones) {
  201. if (g.getItem().getID() != b) {
  202. continue;
  203. }
  204. return false;
  205. }
  206. }
  207. for (int i : lootID) {
  208. if (g.getItem().getID() != i) {
  209. continue;
  210. }
  211. return true;
  212. }
  213. return false;
  214. }
  215. });
  216. }
  217.  
  218. private RSNPC newNPC() {
  219. RSNPC interacting = interactingNPC();
  220. return interacting != null ? interacting : npcs.getNearest(new Filter<RSNPC>() {
  221. public boolean accept(RSNPC npc) {
  222. return npc.getName().contains("Ghoul") && npc.getHPPercent() > 0 && !npc.isInCombat();
  223. }
  224. });
  225. }
  226.  
  227. private RSNPC interactingNPC() {
  228. return npcs.getNearest(new Filter<RSNPC>() {
  229. public boolean accept(RSNPC n) {
  230. return n.getInteracting() != null && n.getInteracting().equals(players.getMyPlayer());
  231. }
  232. });
  233. }
  234.  
  235. private RSItem edible() {
  236. RSItem[] is = inventory.getItems();
  237. for (RSItem i : is) {
  238. if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null) {
  239. continue;
  240. }
  241. if (i.getComponent().getActions()[0].contains("Eat")) {
  242. return i;
  243. }
  244. }
  245. return null;
  246. }
  247. public void antiban() {
  248.  
  249. int b = random(0, 10);
  250. switch (b) {
  251. case 1:
  252. if (random(0, 10) == 5) {
  253. log("[Antiban] move mouse");
  254.  
  255. mouse.moveSlightly();
  256. sleep(200, 600);
  257. mouse.moveRandomly(150, 600);
  258. }
  259. break;
  260. case 2:
  261. if (random(0, 13) == 2) {
  262.  
  263. log("[Antiban] Turn screen");
  264.  
  265. camera.setAngle(random(10, 100));
  266. sleep(400, 1200);
  267.  
  268. }
  269. break;
  270. case 3:
  271. if (random(0, 24) == 6) {
  272.  
  273. log("[Antiban] mouse off screen");
  274. mouse.moveOffScreen();
  275. sleep(random(600, random(1200, 2000)));
  276. }
  277. break;
  278. case 4:
  279. if (random(0, 18) == 3) {
  280.  
  281. log("[antiban] Checking Xp.");
  282. game.openTab(1);
  283. skills.doHover(Skills.INTERFACE_ATTACK);
  284. sleep(random(100, 340));
  285. }
  286. case 5:
  287. if (random(0, 15) == 7) {
  288.  
  289. log("[antiban] Checking Xp.");
  290. game.openTab(1);
  291. skills.doHover(skills.INTERFACE_DEFENSE);
  292. sleep(random(210, 340));
  293. }
  294. case 6:
  295. if (random(0, 15) == 7) {
  296.  
  297. log("[antiban] Opening other tab");
  298. game.openTab(3);
  299. sleep(random(210, 340));
  300. }
  301. case 7:
  302. if (random(0, 15) == 7) {
  303.  
  304. log("[antiban] Opening other tab");
  305. game.openTab(5);
  306. sleep(random(210, 340));
  307. }
  308. case 8:
  309. if (random(0, 15) == 7) {
  310.  
  311. log("[antiban] Opening other tab");
  312. game.openTab(1);
  313. sleep(random(210, 340));
  314. }
  315. break;
  316. default:
  317. break;
  318. }
  319. }
  320.  
  321. public void turnTo(int degrees, RSNPC n) {
  322. char left = 37;
  323. char right = 39;
  324. char whichDir = left;
  325. int start = camera.getAngle();
  326. if (start < 180) {
  327. start += 360;
  328. }
  329. if (degrees < 180) {
  330. degrees += 360;
  331. }
  332. if (degrees > start) {
  333. if (degrees - 180 < start) {
  334. whichDir = right;
  335. }
  336. } else if (start > degrees) {
  337. if (start - 180 >= degrees) {
  338. whichDir = right;
  339. }
  340. }
  341. degrees %= 360;
  342. keyboard.pressKey(whichDir);
  343. int timeWaited = 0;
  344. while (!n.isOnScreen() && camera.getAngle() > degrees + 10 || !n.isOnScreen() && camera.getAngle() < degrees - 10) {
  345. sleep(10);
  346. timeWaited += 10;
  347. if (timeWaited > 500) {
  348. int time = timeWaited - 500;
  349. if (time == 0) {
  350. keyboard.pressKey(whichDir);
  351. } else if (time % 40 == 0) {
  352. keyboard.pressKey(whichDir);
  353. }
  354. }
  355. }
  356. keyboard.releaseKey(whichDir);
  357. }
  358.  
  359. @Override
  360. public void serverMessageRecieved(ServerMessageEvent e) {
  361. String serverString = e.getMessage();
  362. if (serverString.contains("just advanced a")) {
  363. env.saveScreenshot(true);
  364. }
  365. }
  366. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement