Guest User

Untitled

a guest
Jun 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. package com.scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5.  
  6. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  7. import com.kbot2.scriptable.Script;
  8. import com.kbot2.scriptable.methods.wrappers.NPC;
  9. import com.kbot2.scriptable.methods.wrappers.Obj;
  10. import com.kbot2.scriptable.methods.wrappers.Tile;
  11.  
  12. public class WarbosEyeBuyer extends Script implements PaintListener {
  13.  
  14. // PATHS \\
  15. Tile[] TO_SHOP = new Tile[] { new Tile(3093, 3093), new Tile(3089, 3089),
  16. new Tile(3085, 3085), new Tile(3082, 3082), new Tile(3078, 3078),
  17. new Tile(3074, 3074), new Tile(3074, 3074), new Tile(3071, 3071),
  18. new Tile(3066, 3066), new Tile(3061, 3061), new Tile(3056, 3056),
  19. new Tile(3051, 3051), new Tile(3046, 3046), new Tile(3041, 3041),
  20. new Tile(3036, 3036), new Tile(3031, 3031), new Tile(3027, 3027),
  21. new Tile(3022, 3022), new Tile(3020, 3020) };
  22. Tile[] TO_BANK;
  23.  
  24. // Tile[] TO_SHOP_RAND = walking.randomizePath(TO_SHOP, 3, 3);
  25. // Tile[] TO_BANK_RAND = walking.randomizePath(TO_BANK, 3, 3);
  26.  
  27. // TRADING VARIABLES \\
  28. int TRADER_ID = 583;
  29. int ITEM_ID = 221;
  30. int DOOR_ID = 40108;
  31. // OTHER VARIABLES \\
  32. int BANKER_ID[] = { 495 };
  33. int INTERFACE_ID_TRADE = 620;
  34. String Status;
  35. long startTime;
  36. boolean WALKING = false;
  37.  
  38. public boolean active() {
  39. return true;
  40. }
  41.  
  42. @SuppressWarnings("static-access")
  43. @Override
  44. public boolean onStart() {
  45. Status = "Starting Up";
  46. startTime = System.currentTimeMillis();
  47. TO_BANK = walking.reversePath(TO_SHOP);
  48. return true;
  49. }
  50.  
  51. public String getName() {
  52. return "Warbos Eye Buyer";
  53. }
  54.  
  55. public String getAuthor() {
  56. return "xWaRbOx";
  57. }
  58.  
  59. public String getDescription() {
  60. return "Buys Newt Eyes";
  61. }
  62.  
  63. public int loop() {
  64. if (inventory.getCount() == 28) {
  65. walkToBank();
  66. bankItems();
  67. }
  68. if (inventory.getCount() != 28) {
  69. walkToShop();
  70. openDoor();
  71. sleep(500, 600);
  72. tradeSeller();
  73. }
  74. return random(100, 300);
  75. }
  76.  
  77. void walkToShop() {
  78. WALKING = true;
  79. walking.walkPath(walking.randomizePath(TO_SHOP, 3, 3));
  80. sleep(2000, 3000);
  81. if (!getMyPlayer().isMoving()) {
  82. WALKING = false;
  83. }
  84. }
  85.  
  86. void walkToBank() {
  87. WALKING = true;
  88. walking.walkPath(walking.randomizePath(TO_BANK, 3, 3));
  89. sleep(2000, 3000);
  90. if (!getMyPlayer().isMoving()) {
  91. WALKING = false;
  92. }
  93. }
  94.  
  95. int bankItems() {
  96. Status = "Banking";
  97. if (WALKING == false) {
  98. if (!bank.isOpen()) {
  99. NPC npc = npcs.getClosest(8, BANKER_ID);
  100. npc.doAction("Bank Banker");
  101. sleep(300, 1200);
  102. }
  103. if (bank.isOpen()) {
  104. if (inventory.getCount() == 28) {
  105. bank.depositAll(221);
  106. bank.close();
  107. return random(100, 500);
  108. }
  109. return random(100, 500);
  110. }
  111. }
  112. return random(1000, 2000);
  113. }
  114.  
  115. void getItems() {
  116. Status = "Getting Items";
  117. if (WALKING == false) {
  118. if (interfaces.getInterfaceGroup(620).isValid()) {
  119. int X_POS = 391;
  120. int Y_POS = 106;
  121. clickMouse(X_POS, Y_POS, 5, 5, false);
  122. atMenu("Buy-X");
  123. sleep(100, 200);
  124. sendText(Integer.toString(random(27, 99)), true);
  125. } else {
  126. tradeSeller();
  127. }
  128. }
  129. }
  130.  
  131. int openDoor() {
  132. Status = "Opening Door";
  133. if (WALKING == false) {
  134. Obj j = getClosestObject(10, DOOR_ID);
  135. if (j == null)
  136. return random(100, 500);
  137. if (j != null) {
  138. j.doActionAtDoor('w', "Open");
  139.  
  140. }
  141. }
  142. return random(300, 200);
  143. }
  144.  
  145. int tradeSeller() {
  146. if (WALKING == false) {
  147. Status = "Trading Seller";
  148. NPC n = npcs.getClosest(8, TRADER_ID);
  149. if (n == null)
  150. return random(100, 500);
  151. if (n != null) {
  152. n.doAction("Trade");
  153. sleep(1000, 2000);
  154. getItems();
  155. }
  156. }
  157. return random(1000, 2000);
  158. }
  159.  
  160. /*
  161. * Methods
  162. */
  163.  
  164. /**
  165. * Move And Click Mouse With Randomness
  166. *
  167. * @param x
  168. * where on the x axis to move the mouse
  169. * @param y
  170. * where on the y axis to move the mouse
  171. * @param randX
  172. * maximum randomness X axes
  173. * @param randY
  174. * maximum randomness Y axes
  175. * @param button
  176. * boolean: true = left click, false = right click
  177. */
  178.  
  179. void clickMouse(int x, int y, int randx, int randy, boolean button) {
  180. mouse.moveMouse(x, y, randx, randy);
  181. sleep(100);
  182. mouse.clickMouse(button);
  183. }
  184.  
  185. public void onRepaint(Graphics g) {
  186. long runTime = System.currentTimeMillis() - startTime;
  187.  
  188. int secs = ((int) ((runTime / 1000) % 60));
  189. int mins = ((int) (((runTime / 1000) / 60) % 60));
  190. int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
  191.  
  192. String hourss, minss, secss;
  193. if (secs < 10)
  194. secss = "0" + secs;
  195. else
  196. secss = "" + secs;
  197. if (mins < 10)
  198. minss = "0" + mins;
  199. else
  200. minss = "" + mins;
  201. if (hours < 10)
  202. hourss = "0" + hours;
  203. else
  204. hourss = "" + hours;
  205.  
  206. g.setColor(new Color(60, 155, 200, 50));
  207. g.fill3DRect(5, 20, 150, 50, true);
  208. g.setColor(Color.white);
  209. g.drawString("Status: " + Status, 10, 38);
  210. g.drawString("Runtime: " + hourss + ":" + minss + ":" + secss, 10, 56);
  211. }
  212. }
Add Comment
Please, Sign In to add comment