Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.45 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Point;
  7. import java.awt.event.MouseEvent;
  8. import java.awt.event.MouseListener;
  9. import java.util.Random;
  10.  
  11. import org.rsbot.event.listeners.PaintListener;
  12. import org.rsbot.script.Script;
  13. import org.rsbot.script.ScriptManifest;
  14. import org.rsbot.script.methods.Skills;
  15. import org.rsbot.script.wrappers.RSComponent;
  16. import org.rsbot.script.wrappers.RSTile;
  17.  
  18.  
  19. @ScriptManifest(authors = { "evanson and mrfluffy" }, name = "Livid Farmer", description = "Farms the Livid Plants at the Livid Farm", version = 1.00)
  20. public class LividFarmer extends Script implements PaintListener, MouseListener {
  21.  
  22. private int ASTRAL_ID = 9075;
  23. private int NATURE_ID = 561;
  24. private int farmingxp;
  25. private int magexp;
  26. private int startfarmingxp = 0;
  27. private int startfarminglv;
  28. private int startmagexp = 0;
  29. private int startmagelv;
  30. private long start1 = 0;
  31. private long starttime = 0;
  32. private final Color color1 = new Color(180, 255, 153);
  33. private final Color color2 = new Color(0, 102, 51);
  34. private final BasicStroke stroke1 = new BasicStroke(2);
  35. private final Font font1 = new Font("Lucida Handwriting", 0, 18);
  36. private final Font font2 = new Font("Lucida Handwriting", 1, 18);
  37. private final Font font3 = new Font("Arial", 0, 14);
  38. private final Color color3 = new Color(204, 0, 0);
  39. private final Color color4 = new Color(0, 0, 0);
  40. private final Color color5 = new Color(255, 255, 255);
  41. private final BasicStroke stroke2 = new BasicStroke(1);
  42. private final BasicStroke stroke3 = new BasicStroke(2);
  43. private boolean showPaint = true;
  44.  
  45.  
  46. public final static RSTile[] LIVID_PLANTS = { new RSTile(2098, 3943),
  47. new RSTile(2100, 3943), new RSTile(2102, 3943),
  48.  
  49. new RSTile(2104, 3943), new RSTile(2106, 3943),
  50. new RSTile(2106, 3946), new RSTile(2104, 3946),
  51. new RSTile(2102, 3946), new RSTile(2100, 3946),
  52. new RSTile(2098, 3946), new RSTile(2098, 3949),
  53. new RSTile(2100, 3949), new RSTile(2102, 3949),
  54. new RSTile(2104, 3949), new RSTile(2106, 3949) };
  55.  
  56. public boolean onStart() {
  57. startfarmingxp = skills.getCurrentExp(Skills.FARMING);
  58. startfarminglv = skills.getCurrentLevel(Skills.FARMING);
  59. startmagexp = skills.getCurrentExp(Skills.MAGIC);
  60. startmagelv = skills.getCurrentLevel(Skills.MAGIC);
  61. starttime = System.currentTimeMillis();
  62. return inventory.containsAll(ASTRAL_ID, NATURE_ID);
  63. }
  64.  
  65. //@SuppressWarnings({ })
  66. //@Override
  67. public int loop() {
  68. if (!getMyPlayer().getLocation().equals(new RSTile(2101, 3946))) {
  69. if (calc.tileOnScreen(new RSTile(2101, 3946)))
  70. walking.walkTileOnScreen(new RSTile(2101, 3946));
  71. else
  72.  
  73. walking.walkTo(new RSTile(2101, 3946));
  74. try {
  75. Thread.sleep(696);
  76. } catch (InterruptedException e) {
  77. // TODO Auto-generated catch block
  78.  
  79. e.printStackTrace();
  80. }
  81. }
  82. camera.setAngle(0);
  83. camera.setPitch(true);
  84. long start = System.currentTimeMillis();
  85. try {
  86. start1 = start;
  87. // RSTile[] random = LIVID_PLANTS;
  88. // Random rgen = new Random(System.currentTimeMillis());
  89. // for(int i = 0; i > random.length; i++){
  90. // int randomPosition = rgen.nextInt(random.length);
  91. // RSTile temp = random[i];
  92. // random[i] = random[randomPosition];
  93. // random[randomPosition] = temp;
  94.  
  95. //
  96. // }
  97. for (RSTile t : LIVID_PLANTS) {
  98. if (!tiles.interact(t, "fertilise e")) {
  99. if (menu.doAction("cure")) {
  100. waitForInterface(1081, 2000);
  101. getButton(t).doClick();
  102. try {
  103. Thread.sleep(3000);
  104. } catch (InterruptedException e) {
  105. }
  106. }
  107. } else {
  108. try {
  109. Thread.sleep(3000);
  110. } catch (InterruptedException e) {
  111. }
  112. }
  113. // while(getMyPlayer().getAnimation() != -1){
  114. // try {
  115. // Thread.sleep(100);
  116. // } catch (InterruptedException e) {}
  117. // }
  118. }
  119.  
  120. for(int i = LIVID_PLANTS.length - 1; i >= 0; i--){
  121. RSTile t = LIVID_PLANTS[i] ;
  122. if (!tiles.interact(t, "fertilise e")) {
  123. if (menu.doAction("cure")) {
  124. waitForInterface(1081, 2000);
  125. getButton(t).doClick();
  126. try {
  127. Thread.sleep(3000);
  128. } catch (InterruptedException e) {
  129. }
  130. }
  131. } else {
  132. try {
  133.  
  134. Thread.sleep(3000);
  135. } catch (InterruptedException e) {
  136. }
  137. }
  138. // while(getMyPlayer().getAnimation() != -1){
  139. // try {
  140. // Thread.sleep(100);
  141. // } catch (InterruptedException e) {}
  142. // }
  143. }
  144. } catch (Exception e) {
  145. }
  146. try {
  147. Thread.sleep((start + 59750) - System.currentTimeMillis());
  148. } catch (Exception e) {
  149. }
  150.  
  151. return 200;
  152. }
  153.  
  154. RSComponent getButton(RSTile t) {
  155. if (t.equals(new RSTile(2098, 3949))
  156. || t.equals(new RSTile(2100, 3949))
  157. || t.equals(new RSTile(2102, 3949))
  158. || t.equals(new RSTile(2106, 3949))) {
  159. return interfaces.get(1081).getComponent(3);
  160. }
  161. if (t.equals(new RSTile(2104, 3949))
  162. || t.equals(new RSTile(2102, 3946))
  163. || t.equals(new RSTile(2104, 3946))
  164. || t.equals(new RSTile(2106, 3946)))
  165. return interfaces.get(1081).getComponent(4);
  166. if (t.equals(new RSTile(2098, 3943))
  167. || t.equals(new RSTile(2106, 3943))
  168. || t.equals(new RSTile(2100, 3946)))
  169. return interfaces.get(1081).getComponent(5);
  170.  
  171. return interfaces.get(1081).getComponent(6);
  172.  
  173. }
  174.  
  175. private boolean waitForInterface(int id, int timeout) {
  176. long start = System.currentTimeMillis();
  177. while (start + timeout > System.currentTimeMillis()) {
  178. if (interfaces.get(id).isValid())
  179. return true;
  180. try {
  181. Thread.sleep(125);
  182. } catch (InterruptedException e) {
  183. }
  184. }
  185. return false;
  186. }
  187.  
  188. public void onRepaint(Graphics g1) {
  189. Graphics2D g = (Graphics2D)g1;
  190. final long runtime = System.currentTimeMillis() - starttime;
  191. long runtime2 = runtime;
  192. final long hours = (long) runtime2 / 3600000;
  193. runtime2 -= hours * 3600000;
  194. final long mins = (long) runtime2 / 60000;
  195. runtime2 -= mins * 60000;
  196. final long secs = (long) runtime2 / 1000;
  197. farmingxp = skills.getCurrentExp(Skills.FARMING) - startfarmingxp;
  198. magexp = skills.getCurrentExp(Skills.MAGIC) - startmagexp;
  199. if(showPaint) {
  200. g.setColor(color1);
  201. g.fillRoundRect(546, 205, 188, 259, 16, 16);
  202. g.setColor(color2);
  203. g.setStroke(stroke1);
  204. g.drawRoundRect(546, 205, 188, 259, 16, 16);
  205. g.setFont(font1);
  206. g.drawString("mrfluffy's", 588, 229);
  207. g.setFont(font2);
  208. g.drawString("Livid Farmer", 562, 255);
  209. g.setFont(font3);
  210. g.drawString("Farm Level: " + skills.getCurrentLevel(Skills.FARMING) + " (+" + ((skills.getCurrentLevel(Skills.FARMING) - startfarminglv)) + ")", 561, 290);
  211. g.drawString("Farm XP: " + farmingxp, 561, 315);
  212. g.drawString("Farming XP/Hr: " + ((long) (farmingxp) * 3600000 / runtime), 561, 340);
  213. g.drawString("Magic Level: " + skills.getCurrentLevel(Skills.MAGIC) + " (+" + ((skills.getCurrentLevel(Skills.MAGIC) - startmagelv)) + ")", 561, 365);
  214. g.drawString("Mage XP: " + magexp, 561, 390);
  215. g.drawString("Running For: " + hours + ":" + mins + ":" + secs, 561, 415);
  216. g.setColor(color2);
  217. g.fillRect(708, 208, 17, 17);
  218. g.setColor(color4);
  219. g.setStroke(stroke2);
  220. g.drawRect(708, 208, 17, 17);
  221. g.setColor(color5);
  222. g.setStroke(stroke3);
  223. g.drawLine(722, 210, 710, 223);
  224. g.drawLine(710, 210, 722, 222);
  225. }
  226. if(!showPaint) {
  227. g.setColor(color2);
  228. g.fillRect(708, 208, 17, 17);
  229. g.setColor(color4);
  230. g.setStroke(stroke2);
  231. g.drawRect(708, 208, 17, 17);
  232. g.setColor(color5);
  233. g.setStroke(stroke3);
  234. g.drawOval(711, 211, 11, 11);
  235. }
  236. }
  237.  
  238. @Override
  239. public void mouseClicked(MouseEvent e) {
  240. Point p = e.getPoint();
  241. if(p.x > 708 && p.x < 725 && p.y > 208 && p.y < 225) {
  242. showPaint = !showPaint;
  243. }
  244. }
  245.  
  246. @Override
  247. public void mousePressed(MouseEvent e) {
  248. // TODO Auto-generated method stub
  249.  
  250. }
  251.  
  252. @Override
  253. public void mouseReleased(MouseEvent e) {
  254. // TODO Auto-generated method stub
  255.  
  256. }
  257.  
  258. @Override
  259. public void mouseEntered(MouseEvent e) {
  260. // TODO Auto-generated method stub
  261.  
  262. }
  263.  
  264. @Override
  265. public void mouseExited(MouseEvent e) {
  266. // TODO Auto-generated method stub
  267.  
  268. }
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement