Guest User

Untitled

a guest
Jun 19th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. package com.scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Point;
  6. import java.awt.*;
  7.  
  8. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  9. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  10. import com.kbot2.scriptable.Script;
  11. import com.kbot2.scriptable.methods.data.Walking;
  12. import com.kbot2.scriptable.methods.wrappers.Obj;
  13. import com.kbot2.scriptable.methods.wrappers.Tile;
  14. import com.kbot2.scriptable.methods.wrappers.Interface;
  15.  
  16. public class StrifesFlaxPicker extends Script implements PaintListener,
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. ServerMessageListener {
  24. // FLAX VARIABLES \\
  25. int FLAX_ID[] = { 2646 ,};
  26. int FLAX_PICKED = 0;
  27. // PAINT VARIABLES \\
  28. long startTime;
  29. String Status;
  30. // OBJECTS \\
  31. Obj flax;
  32. public static int BANK_BUTTON_DEPOSIT_CARRIED_ITEMS = 20;
  33.  
  34. private final static int[] BANK_ID = new int[]{25808};
  35.  
  36. private final static Tile[] FLAX_TO_BANK_PATH = new Tile[]{new Tile(2739,3447), new Tile(2736,3443), new Tile(2735,3448),new Tile(2731,3451), new Tile(2729,3456), new Tile(2726,3461),new Tile(2728,3466), new Tile(2728,3471), new Tile(2726,3476),new Tile(2727,3481), new Tile(2727,3486), new Tile(2726,3491), };
  37.  
  38. private final static Tile[] BANK_TO_FLAX_PATH = Walking.reversePath(FLAX_TO_BANK_PATH);
  39.  
  40. private final static Rectangle FLAX_FIELD = new Rectangle(2737, 3439, 13, 11);
  41. private final static Rectangle SEER_BANK_AREA = new Rectangle(2721, 3490, 9, 3);
  42.  
  43. public boolean active() {
  44. return true;
  45. }
  46.  
  47. @Override
  48. public boolean onStart() {
  49. Status = "Starting Up";
  50. log("Welcome to Strife's Flax Picker");
  51. startTime = System.currentTimeMillis();
  52. return true;
  53. }
  54.  
  55. public void onServerMessage(String e) {
  56. if (e.contains("pick")) {
  57. FLAX_PICKED++;
  58. }
  59. }
  60.  
  61. public int loop() {
  62. try {
  63. if(walking.getEnergy() > 50)
  64. walking.setRunning(true);
  65. Tile myLoc = getMyPlayer().getLocation();
  66. Point p = new Point(myLoc.getX(), myLoc.getY());
  67. if(inventory.getCount() == 28) {
  68. if(SEER_BANK_AREA.contains(p)) {
  69. log("we are in bank");
  70. Interface iface = interfaces.getInterface(109, 13);
  71. if(iface != null && iface.isValid())
  72. iface.doClick();
  73. if(bank.isOpen()) {
  74. bank.depositInventory();
  75. } else {
  76. Obj b = objects.getClosestObject(40, BANK_ID);
  77. if(b != null)
  78. if(b.getScreenPos().getX() != -1)
  79. b.doAction("quickly");
  80. else
  81. walking.walkToMM(b.getLocation());
  82. }
  83. } else {
  84. if(!getMyPlayer().isMoving())
  85. walking.walkPath(FLAX_TO_BANK_PATH);
  86. }
  87. } else {
  88. if(FLAX_FIELD.contains(p)) {
  89. if(getMyPlayer().getAnimation() == -1 && !getMyPlayer().isMoving()) {
  90. Obj t = objects.getClosestObject(15, FLAX_ID);
  91. if(t != null)
  92. if(t.getScreenPos().getX() != -1)
  93. t.doAction("Pick");
  94. else {
  95. if(FLAX_FIELD.contains(new Point(t.getLocation().getX(), t.getLocation().getY())))
  96. walking.walkToMM(t.getLocation());
  97. else if(t.getLocation().getY() < FLAX_FIELD.getY())
  98. walking.walkToMM(new Tile(t.getLocation().getX(), (int) FLAX_FIELD.getY()));
  99. else
  100. walking.walkToMM(new Tile(t.getLocation().getX(), (int) (
  101. FLAX_FIELD.getY() + FLAX_FIELD.getHeight())));
  102. }
  103. }
  104. } else {
  105. if(!getMyPlayer().isMoving())
  106. walking.walkPath(BANK_TO_FLAX_PATH);
  107. }
  108. }
  109. } catch (Exception failSafe) {
  110. log("Some exception thrown, probably Nullpointer from Calculations");
  111. failSafe.printStackTrace();
  112. }
  113. return random(1000, 2000);
  114. }
  115.  
  116. /**
  117. * Move And Click Mouse With Randomness
  118. *
  119. * @param x
  120. * where on the x axis to move the mouse
  121. * @param y
  122. * where on the y axis to move the mouse
  123. * @param randX
  124. * maximum randomness X axes
  125. * @param randY
  126. * maximum randomness Y axes
  127. * @param randx
  128. * @param randy
  129. * @param button
  130. * boolean: true = left click, false = right click
  131. */
  132.  
  133. void clickMouse(int x, int y, int randx, int randy, boolean button) {
  134. mouse.moveMouse(x, y, randx, randy);
  135. sleep(100);
  136. mouse.clickMouse(button);
  137. }
  138.  
  139. public String getName() {
  140. return "Strife's FlaxPicker";
  141. }
  142.  
  143. public String getAuthor() {
  144. return "Strife";
  145. }
  146.  
  147. public String getDescription() {
  148. return "Picks Flax in Seers Village";
  149. }
  150.  
  151. public void onRepaint(Graphics w) {
  152.  
  153.  
  154. long runTime = System.currentTimeMillis() - startTime;
  155.  
  156. int secs = ((int) ((runTime / 1000) % 60));
  157. int mins = ((int) (((runTime / 1000) / 60) % 60));
  158. int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
  159.  
  160. String hourss, minss, secss;
  161. if (secs < 10)
  162. secss = "0" + secs;
  163. else
  164. secss = "" + secs;
  165. if (mins < 10)
  166. minss = "0" + mins;
  167. else
  168. minss = "" + mins;
  169. if (hours < 10)
  170. hourss = "0" + hours;
  171. else
  172. hourss = "" + hours;
  173.  
  174. w.setColor(new Color(61, 61, 61, 100));
  175. w.fill3DRect(25, 25, 160, 83, true);
  176. w.setColor(new Color(61, 61, 61, 200));
  177. w.fill3DRect(30, 30, 150, 73, true);
  178. w.setColor(Color.white);
  179. w.drawString("Status: " + Status, 34, 43);
  180. w.drawString("Runtime: " + hourss + ":" + minss + ":" + secss, 34, 61);
  181. w.drawString("Flax Picked: " + FLAX_PICKED, 34, 97);
  182.  
  183. }
  184.  
  185. }
Add Comment
Please, Sign In to add comment