Guest User

Untitled

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