Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.55 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Point;
  4. import java.util.HashSet;
  5. import java.util.Iterator;
  6. import java.util.Set;
  7. import java.awt.*;
  8. import org.rsbot.event.events.MessageEvent;
  9. import org.rsbot.event.listeners.MessageListener;
  10. import org.rsbot.script.*;
  11. import org.rsbot.script.methods.Game;
  12. import org.rsbot.script.methods.Skills;
  13. import org.rsbot.script.wrappers.*;
  14. import org.rsbot.script.util.Timer;
  15. import org.rsbot.event.listeners.PaintListener;
  16. import org.rsbot.script.methods.GrandExchange;
  17.  
  18.  
  19. @ScriptManifest(authors = "Havefunpeeps", keywords = "Harpoons", name = "FunHarpoonBuyer", version = 1.02, description = "Buys Harpoons")
  20. public class HarpoonBuyer extends Script implements PaintListener, MessageListener {
  21.  
  22. private enum State {
  23. BANK, WALKTOBANK, WALKTOFISHER, BUYHARPOONS, TOGGLERUN, FAILSAFE1, WAIT
  24. }
  25.  
  26. public boolean onStart(){
  27. mouse.setSpeed(random(6, 10));
  28. startTime = System.currentTimeMillis();
  29. HarpoonPrice = grandExchange.lookup(HarpoonID).getGuidePrice();
  30. log("The Current Version Script you are running is 1.00. Check the forum page for updates");
  31. log("Start Script by the Fishing shop in Port Sarim. Good Luck on making Cash");
  32. return true;
  33. }
  34.  
  35.  
  36. //items//
  37. int HarpoonID = 311;
  38. int CoinID = 995;
  39. int DepBoxID = 36788;
  40. int FishGuyID = 558;
  41. int DoorOpenID = 40109;
  42. int DoorClosedID = 40108;
  43. int CoinsID = 995;
  44. private int nextMinRunEnergy = random(20, 50);
  45.  
  46. //tiles//
  47. RSTile DoorTileOutside = new RSTile(3013, 3219);
  48. RSTile DepBoxTile = new RSTile(3047, 3236);
  49. RSTile DoorTileInside = new RSTile(3013, 3220);
  50. RSTile StoreTile = new RSTile(3014, 3224);
  51. RSTile[] PathToBank = {new RSTile(3013, 3219), new RSTile(3019, 3218), new RSTile(3026, 3218), new RSTile(3027, 3223), new RSTile(3027, 3229), new RSTile(3033, 3235), new RSTile(3037, 3235), new RSTile(3044, 3236), new RSTile(3046, 3236)};
  52. RSTile[] PathToFisher = {new RSTile(3041, 3236), new RSTile(3036, 3236), new RSTile(3031, 3236), new RSTile(3028, 3233), new RSTile(3028, 3228), new RSTile(3027, 3220), new RSTile(3023, 3218), new RSTile(3016, 3219), new RSTile(3013, 3218)};
  53.  
  54. //areas//
  55. RSArea StoreArea = new RSArea(new RSTile(3011, 3220), new RSTile(3016, 3229));
  56. RSArea BoothArea = new RSArea(new RSTile(3042, 3235), new RSTile(3051, 3237));
  57. RSArea DoorArea = new RSArea(new RSTile(3008, 3216), new RSTile(3018, 3219));
  58. RSArea FailSafe1Area = new RSArea(new RSTile(3006, 3217), new RSTile(3010, 3224));
  59. //walking
  60. public long startTime = 0;
  61. public long millis = 0;
  62. public long hours = 0;
  63. public long minutes = 0;
  64. public long seconds = 0;
  65. public long last = 0;
  66. private int Trips;
  67. private int Harpoons;
  68. private int TripsHour;
  69. private int HarpoonsHour;
  70. private int Profit;
  71. private int ProfitHour;
  72. private int HarpoonPrice;
  73.  
  74. private State getState() {
  75. if (!walking.isRunEnabled() && walking.getEnergy() >= nextMinRunEnergy) {
  76. return State.TOGGLERUN;
  77. }
  78. if(inventory.contains(HarpoonID) && BoothArea.contains(players.getMyPlayer().getLocation())) {
  79. return State.BANK;
  80. }
  81. if(inventory.contains(HarpoonID) && !BoothArea.contains(players.getMyPlayer().getLocation())) {
  82. return State.WALKTOBANK;
  83. }
  84. if(StoreArea.contains(players.getMyPlayer().getLocation()) && !inventory.contains(HarpoonID)) {
  85. return State.BUYHARPOONS;
  86. }
  87. if(!inventory.contains(HarpoonID) && !StoreArea.contains(players.getMyPlayer().getLocation())) {
  88. return State.WALKTOFISHER;
  89. }
  90. return State.WAIT;
  91. }
  92.  
  93. private boolean walkPath(RSTile[] path) {
  94. if (calc.distanceTo(path[path.length - 1]) > 4) {
  95. RSTile n = getNext(path);
  96. if(n!=null){
  97. walking.walkTileMM(n.randomize(2, 2));
  98. if(random(1,6) != 2){
  99. mouse.moveRandomly(20);
  100. }
  101. }
  102. }
  103. return false;
  104. }
  105.  
  106. private RSTile getNext(RSTile[] path) {
  107. boolean found = false;
  108. for (int a = 0; a < path.length&&!found; a++) {
  109. if(calc.tileOnMap(path[path.length-1-a])){
  110. found = true;
  111. return path[path.length-1-a];
  112. }
  113. }
  114. return null;
  115. }
  116.  
  117. public void antiBanCamera() {
  118. int randomNumber3 = random(1, 40);
  119. if (randomNumber3 == 1 || randomNumber3 == 2 || randomNumber3 == 3) {
  120. camera.setPitch(random(40, 68));
  121. }
  122. if (randomNumber3 == 4 || randomNumber3 == 5 || randomNumber3 == 6) {
  123. camera.moveRandomly(random(800, 1200));
  124. }
  125. if (randomNumber3 == 7 || randomNumber3 == 8 || randomNumber3 == 9) {
  126. camera.setAngle(random(10, 50));
  127. }
  128. if (randomNumber3 == 10 || randomNumber3 == 11) {
  129. camera.setPitch(true);
  130. }
  131. if (randomNumber3 == 12 || randomNumber3 == 13) {
  132. camera.setPitch(false);
  133. }
  134. if (randomNumber3 == 14) {
  135. camera.moveRandomly(random(400, 800));
  136. }
  137. if (randomNumber3 == 15) {
  138. camera.setAngle(random(5, 40));
  139. sleep(random(200, 300));
  140. }
  141. if (randomNumber3 > 15 && randomNumber3 < 30) {
  142. camera.setPitch(true);
  143. }
  144. if (randomNumber3 > 29) {
  145. camera.moveRandomly(random(200, 800));
  146. }
  147. }
  148.  
  149. public int loop() {
  150. mouse.setSpeed(random(6, 12));
  151. final State state = getState();
  152. switch (state) {
  153. case TOGGLERUN:
  154. walking.setRun(true);
  155. sleep(200, 400);
  156. nextMinRunEnergy = random(27, 40);
  157. break;
  158. case WALKTOBANK:
  159. if(DoorC != null && StoreArea.contains(players.getMyPlayer().getLocation())) {
  160. DoorC.doAction("Open");
  161. }
  162. walkPath(PathToBank);
  163. sleep(random(1200, 1500));
  164. antiBanCamera();
  165. sleep(1000, 2000);
  166. break;
  167. case WALKTOFISHER:
  168. walkPath(PathToFisher);
  169. sleep(random(1200, 1500));
  170. RSObject DoorC = objects.getNearest(DoorClosedID);
  171. if(DoorC != null && DoorArea.contains(players.getMyPlayer().getLocation())) {
  172. DoorC.doAction("Open");
  173. if(!players.getMyPlayer().isMoving()) {
  174. walking.walkTileMM(StoreTile, 2, 2);
  175. }
  176. }
  177. if(DoorC == null) {
  178. walking.walkTileMM(StoreTile, 2, 2);
  179. camera.moveRandomly(300);
  180. }
  181. antiBanCamera();
  182. sleep(1000, 2000);
  183. break;
  184. case BANK:
  185. RSObject DepBox = objects.getNearest(DepBoxID);
  186. RSItem Harpoon2 = inventory.getItem(HarpoonID);
  187. bank.openDepositBox();
  188. sleep(400, 599);
  189. bank.deposit(HarpoonID, 0);
  190. bank.close();
  191. break;
  192. case BUYHARPOONS:
  193. RSNPC Fisher = npcs.getNearest(FishGuyID);
  194. RSItem Harpoon = inventory.getItem(HarpoonID);
  195. if(Fisher != null) {
  196. if(!players.getMyPlayer().isMoving()) {
  197. Fisher.doAction("Trade");
  198. sleep(400, 600);
  199. }
  200. }
  201. if(store.isOpen()) {
  202. store.buy(HarpoonID, 50);
  203. sleep(300, 400);
  204. }
  205. break;
  206. case FAILSAFE1:
  207. walking.walkTileMM(DoorTileOutside, 2, 2);
  208. break;
  209. }
  210. return random(100, 600);
  211. }
  212.  
  213. public void messageReceived(MessageEvent e) {
  214. String x = e.getMessage().toLowerCase();
  215. if (x.contains("enough inventory")){
  216. Trips++;
  217. }
  218. }
  219.  
  220. //START: Code generated using Enfilade's Easel
  221. private final Color color1 = new Color(51, 255, 51, 123);
  222. private final Color color2 = new Color(0, 0, 0);
  223.  
  224. private final BasicStroke stroke1 = new BasicStroke(1);
  225.  
  226. private final Font font1 = new Font("Arial", 0, 9);
  227.  
  228. public void onRepaint(Graphics g1) {
  229. Graphics2D g = (Graphics2D)g1;
  230. millis = System.currentTimeMillis() - startTime;
  231. hours = millis / (1000 * 60 * 60);
  232. millis -= hours * (1000 * 60 * 60);
  233. minutes = millis / (1000 * 60);
  234. millis -= minutes * (1000 * 60);
  235. seconds = millis / 1000;
  236. Harpoons = Trips * 27;
  237. TripsHour = (int) ((Trips) * 3600000D / (System.currentTimeMillis() - startTime));
  238. HarpoonsHour = (int) ((Harpoons) * 3600000D / (System.currentTimeMillis() - startTime));
  239. Profit = HarpoonPrice * Harpoons;
  240. ProfitHour = HarpoonPrice * HarpoonsHour;
  241. g.setColor(color1);
  242. g.fillRoundRect(351, 160, 166, 178, 16, 16);
  243. g.setColor(color2);
  244. g.setStroke(stroke1);
  245. g.drawRoundRect(351, 160, 166, 178, 16, 16);
  246. g.setFont(font1);
  247. g.drawString("Time Ran: "+ hours +":"+ minutes + ":" + seconds, 364, 210);
  248. g.drawString("Harpoons Bought: " +Harpoons, 363, 227);
  249. g.drawString("Trips Taken: " +Trips, 363, 268);
  250. g.drawString("Harpoons Per Hour: " +HarpoonsHour, 364, 248);
  251. g.drawString("Trips Per Hour: " +TripsHour, 363, 291);
  252. g.drawString("Profit: " +Profit, 362, 310);
  253. g.drawString("Profit Per Hour: " +ProfitHour, 360, 329);
  254. }
  255. //END: Code generated using Enfilade's Easel
  256. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement