Guest User

XFADE48X_SEEERSBOT

a guest
Sep 24th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. package seersbot;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.image.BufferedImage;
  8. import java.io.IOException;
  9. import java.net.MalformedURLException;
  10. import java.net.URL;
  11. import java.text.DecimalFormat;
  12.  
  13. import javax.imageio.ImageIO;
  14.  
  15. import org.osbot.script.Script;
  16. import org.osbot.script.ScriptManifest;
  17. import org.osbot.script.rs2.model.Entity;
  18. import org.osbot.script.rs2.model.Player;
  19. import org.osbot.script.rs2.ui.Bank;
  20. import org.osbot.script.rs2.ui.Inventory;
  21. import org.osbot.script.rs2.utility.Area;
  22.  
  23. @ScriptManifest(author = "xFADE48x", info = "Picks flax at seer's village and banks it (START AT SEER'S VILLAGE BANK)", name = "xFADE48x SeersBot", version = 1.7)
  24. public class SEERSBOT extends Script {
  25.  
  26. private static long startTime = 0;
  27.  
  28. static Timer runTime;
  29.  
  30. final String FLAX_NAME = "Flax";
  31.  
  32. final Area BANK_AREA = new Area(2721, 3490, 2726, 3493);
  33. final Area FLAX_AREA = new Area(2737, 3438, 2741, 3442);
  34. final Area MIDWAY_AREA = new Area(2718, 3463, 2730, 3476);
  35. final Area BANKOTHER_AREA = new Area(2727, 3490, 2730, 3493);
  36. final Area BANKOTHER2_AREA = new Area(2725, 3487, 2726, 3490);
  37. final Area FRONTBANK_AREA = new Area(2722, 3480, 2729, 3486);
  38. final Area FLAXFIELD_AREA = new Area(2719, 3441, 2736, 3459);
  39.  
  40. final int BANK_BOOTH_ID = 25808;
  41.  
  42. int flaxpicked = 0;
  43.  
  44. BufferedImage img;
  45.  
  46. // code used at start
  47. public void onStart() {
  48.  
  49. try {
  50. img = ImageIO.read(new URL("http://i.imgur.com/3aUvHFl.png"));
  51. } catch (MalformedURLException e) {
  52. // TODO Auto-generated catch block
  53. e.printStackTrace();
  54. } catch (IOException e) {
  55. // TODO Auto-generated catch block
  56. e.printStackTrace();
  57. }
  58.  
  59. runTime = new Timer(0);
  60.  
  61. startTime = System.currentTimeMillis();
  62.  
  63. }
  64.  
  65. // code to be executed at the end
  66. public void onExit() {
  67.  
  68. }
  69.  
  70. // code in loop
  71. @Override
  72. public int onLoop() throws InterruptedException {
  73.  
  74. if (client.getRunEnergy() > 50) {
  75. setRunning(true);
  76.  
  77. }
  78.  
  79. Inventory inven = client.getInventory();
  80. Player player = client.getMyPlayer();
  81. Bank bank = client.getBank();
  82.  
  83. if (!inven.isFull()) {
  84. // pick
  85.  
  86. if (FLAX_AREA.contains(player)) {
  87. Entity flax = closestObjectForName(FLAX_NAME);
  88.  
  89. if (flax != null) {
  90. if (flax.isVisible()) {
  91. flax.interact("Pick");
  92. sleep(random(300, 400));
  93.  
  94. }
  95. } else {
  96. client.moveCameraToEntity(flax);
  97.  
  98. }
  99. } else {
  100. walk(FLAX_AREA);
  101.  
  102. }
  103. } else {
  104. // bank
  105.  
  106. if (FRONTBANK_AREA.contains(player)) {
  107. walk(BANK_AREA);
  108. }
  109.  
  110. if (BANKOTHER_AREA.contains(player)) {
  111. walk(BANK_AREA);
  112. sleep(random(800, 1000));
  113. }
  114.  
  115. if (BANKOTHER2_AREA.contains(player)) {
  116. walk(BANK_AREA);
  117. sleep(random(800, 1000));
  118. }
  119.  
  120. if (MIDWAY_AREA.contains(player)) {
  121. walk(FRONTBANK_AREA);
  122. }
  123.  
  124. if (FLAXFIELD_AREA.contains(player)) {
  125. walk(MIDWAY_AREA);
  126. }
  127.  
  128. if (BANK_AREA.contains(player)) {
  129. Entity bankbooth = closestObject(BANK_BOOTH_ID);
  130.  
  131. if (bank.isOpen()) {
  132. bank.depositAll();
  133. bank.close();
  134.  
  135.  
  136. } else {
  137. if (bankbooth != null) {
  138. if (bankbooth.isVisible()) {
  139. bankbooth.interact("Bank");
  140. sleep(random(1200, 1300));
  141.  
  142. } else {
  143. client.moveCameraToEntity(bankbooth);
  144. }
  145.  
  146. }
  147.  
  148. }
  149.  
  150. } else {
  151. if (FLAX_AREA.contains(player)) {
  152. walk(MIDWAY_AREA);
  153. sleep(random(800, 1000));
  154.  
  155. }
  156. }
  157. }
  158. return 50;
  159. }
  160.  
  161. public void onMessage(String message) {
  162.  
  163. if (message.contains("You pick some flax.")) {
  164. flaxpicked++;
  165. }
  166.  
  167. }
  168.  
  169. // paint
  170. public void onPaint(Graphics g) {
  171.  
  172. Graphics2D gr = (Graphics2D) g;
  173.  
  174. g.drawImage(img, 0, 287, null);
  175.  
  176. gr.setColor(Color.WHITE);
  177. gr.setFont(new Font("Arial", Font.PLAIN, 13));
  178.  
  179. gr.drawString(": " + flaxpicked, 467, 300);
  180. gr.drawString(": " + getPerHour(flaxpicked), 330, 329);
  181. gr.drawString(": " + runTime(startTime), 295, 300);
  182.  
  183. }
  184.  
  185. public String runTime(long i) {
  186. DecimalFormat nf = new DecimalFormat("00");
  187. long millis = System.currentTimeMillis() - i;
  188. long hours = millis / (1000 * 60 * 60);
  189. millis -= hours * (1000 * 60 * 60);
  190. long minutes = millis / (1000 * 60);
  191. millis -= minutes * (1000 * 60);
  192. long seconds = millis / 1000;
  193. return nf.format(hours) + ":" + nf.format(minutes) + ":"
  194. + nf.format(seconds);
  195. }
  196.  
  197. public static int getPerHour(int value) {
  198. if (runTime != null && runTime.getElapsed() > 0) {
  199. return (int) (value * 3600000d / runTime.getElapsed());
  200. } else {
  201. return 0;
  202. }
  203. }
  204.  
  205. public static long getPerHour(long value) {
  206. if (runTime != null && runTime.getElapsed() > 0) {
  207. return (long) (value * 3600000d / runTime.getElapsed());
  208. } else {
  209. return 0;
  210. }
  211. }
  212.  
  213. }
Advertisement
Add Comment
Please, Sign In to add comment