gamemaste789

Untitled

Apr 25th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.06 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import java.awt.image.BufferedImage;
  5. import java.io.*;
  6. import java.net.MalformedURLException;
  7. import java.net.URI;
  8. import java.net.URL;
  9.  
  10. import javax.imageio.ImageIO;
  11. import javax.swing.*;
  12.  
  13. import org.powerbot.concurrent.Task;
  14. import org.powerbot.concurrent.strategy.Condition;
  15. import org.powerbot.concurrent.strategy.Strategy;
  16. import org.powerbot.game.api.ActiveScript;
  17. import org.powerbot.game.api.Manifest;
  18. import org.powerbot.game.api.methods.Calculations;
  19. import org.powerbot.game.api.methods.Game;
  20. import org.powerbot.game.api.methods.Tabs;
  21. import org.powerbot.game.api.methods.Walking;
  22. import org.powerbot.game.api.methods.Widgets;
  23. import org.powerbot.game.api.methods.input.Mouse;
  24. import org.powerbot.game.api.methods.interactive.NPCs;
  25. import org.powerbot.game.api.methods.interactive.Players;
  26. import org.powerbot.game.api.methods.tab.Inventory;
  27. import org.powerbot.game.api.methods.tab.Skills;
  28. import org.powerbot.game.api.methods.widget.Camera;
  29. import org.powerbot.game.api.util.Filter;
  30. import org.powerbot.game.api.util.Random;
  31. import org.powerbot.game.api.util.Time;
  32. import org.powerbot.game.api.wrappers.Area;
  33. import org.powerbot.game.api.wrappers.Tile;
  34. import org.powerbot.game.api.wrappers.interactive.NPC;
  35. import org.powerbot.game.api.wrappers.node.Item;
  36. import org.powerbot.game.bot.event.MessageEvent;
  37. import org.powerbot.game.bot.event.listener.MessageListener;
  38. import org.powerbot.game.bot.event.listener.PaintListener;
  39.  
  40. @Manifest(name = "JamRSKaramjaFisher", description = "The most stable and perfect karamja fisher !", version = 3.4, authors = { "Jamesst123" })
  41. public class JamRSKaramjaFisher extends ActiveScript implements PaintListener,
  42. MessageListener {
  43. final static double version = 3.4;
  44. static int tunaPrice = 0;
  45. static int lobsterPrice = 0;
  46. static int swordfishPrice = 0;
  47. final static int shrimpID = 317;
  48. final static int anchoviesID = 321;
  49. final static int tunaID = 359;
  50. final static int lobsterID = 377;
  51. final static int swordfishID = 371;
  52. static int shrimpCaught = 0;
  53. static int anchoviesCaught = 0;
  54. static int tunaCaught = 0;
  55. static int lobstersCaught = 0;
  56. static int swordfishCaught = 0;
  57. static String fishType;
  58. static String fishingMode;
  59. static int spotID = 0;
  60. static boolean guiDone = false;
  61. static int[] fishIds = { 359, 377, 371, 317, 321 };
  62. static int[] wrongFishIds = { 317, 321 };
  63. static boolean wrongFish = false;
  64. static int[] onlysword = { 317, 321, 359 , 377 };
  65. static boolean onlysword = false;
  66. static long startTime = 0;
  67. static int startLevel = 0;
  68. static int startExp = 0;
  69. static String antiBanStatus = "Idle";
  70. static String botStatus = "Starting";
  71. static boolean statsLoaded = false;
  72. static BufferedImage mouse;
  73. static boolean wasDropping = false;
  74. static boolean dropped = false;
  75. static boolean droptuna = false
  76. static GUI gui;
  77.  
  78. @Override
  79. protected void setup() {
  80. System.out.println("Loading JamRSKaramjaFisher v" + version);
  81. LoadingThread loading = new LoadingThread();
  82. loading.start();
  83. Fishing fishing = new Fishing();
  84. FullInventory fullInventory = new FullInventory();
  85. AntiBan antiBan = new AntiBan();
  86. Strategy fishingAction = new Strategy(fishing, fishing);
  87. Strategy fullInventoryAction = new Strategy(fullInventory,
  88. fullInventory);
  89. Strategy antiBanAction = new Strategy(antiBan, antiBan);
  90. provide(fishingAction);
  91. provide(fullInventoryAction);
  92. provide(antiBanAction);
  93. startLevel = Skills.getLevels()[10];
  94. startExp = Skills.getExperiences()[10];
  95. if (startLevel != 0 && startExp != 0) {
  96. statsLoaded = true;
  97. }
  98. }
  99.  
  100. private class Fishing implements Task, Condition {
  101. @Override
  102. public void run() {
  103. if (FishingArea.contains(Players.getLocal().getLocation().getX(),
  104. Players.getLocal().getLocation().getY())) {
  105. if (!Players.getLocal().isMoving()) {
  106. botStatus = "Fishing";
  107. NPCs.getNearest(new Filter<NPC>() {
  108. @Override
  109. public boolean accept(NPC t) {
  110. return t.getId() == spotID;
  111. }
  112. }).interact(fishType);
  113. Time.sleep(4000);
  114. }
  115. } else {
  116. botStatus = "Walking to fish";
  117. walk(FishPath);
  118. Time.sleep(1000);
  119. }
  120. }
  121.  
  122. @Override
  123. public boolean validate() {
  124. if (guiDone && Game.isLoggedIn() && Inventory.getCount() < 28
  125. && Players.getLocal().getAnimation() == -1 && !wasDropping) {
  126. return true;
  127. }
  128. return false;
  129. }
  130. }
  131.  
  132. private class FullInventory implements Task, Condition {
  133. @Override
  134. public void run() {
  135. if (fishingMode.equals("Stiles") && fishingMode.equals("droptuna")) {
  136. onlysword = false;
  137. for (Item item : Inventory.getItems()) {
  138. for (int ID : onlysword) {
  139. if (item.getId() == ID) {
  140. botStatus = "Dropping wrong fishes";
  141. item.getWidgetChild().interact("Drop");
  142. wrongFish = true;
  143. Time.sleep(800);
  144. }
  145. }
  146. }
  147. if (!wrongFish) {
  148. if (StilesArea.contains(Players.getLocal().getLocation())) {
  149. botStatus = "Exchanging Fishes";
  150. NPCs.getNearest(StilesFilter).interact("Exchange");
  151. Time.sleep(3000);
  152. } else {
  153. botStatus = "Walking to Stiles";
  154. walk(StilesPath);
  155. Time.sleep(1000);
  156. }
  157. }
  158. }
  159.  
  160. if (fishingMode.equals("Stiles")) {
  161. wrongFish = false;
  162. for (Item item : Inventory.getItems()) {
  163. for (int ID : wrongFishIds) {
  164. if (item.getId() == ID) {
  165. botStatus = "Dropping wrong fishes";
  166. item.getWidgetChild().interact("Drop");
  167. wrongFish = true;
  168. Time.sleep(800);
  169. }
  170. }
  171. }
  172. if (!wrongFish) {
  173. if (StilesArea.contains(Players.getLocal().getLocation())) {
  174. botStatus = "Exchanging Fishes";
  175. NPCs.getNearest(StilesFilter).interact("Exchange");
  176. Time.sleep(3000);
  177. } else {
  178. botStatus = "Walking to Stiles";
  179. walk(StilesPath);
  180. Time.sleep(1000);
  181. }
  182. }
  183. } else if (fishingMode.equals("Powerfishing")) {
  184. botStatus = "Dropping Fishes";
  185. wasDropping = false;
  186. for (Item item : Inventory.getItems()) {
  187. for (int id : fishIds) {
  188. if (item.getId() == id) {
  189. item.getWidgetChild().interact("Drop");
  190. wasDropping = true;
  191. Time.sleep(random(600, 900));
  192. break;
  193. }
  194. }
  195. if (wasDropping) {
  196. break;
  197. }
  198. }
  199. }
  200. }
  201. }
  202.  
  203.  
  204. @Override
  205. public boolean validate() {
  206. if (!statsLoaded) {
  207. startLevel = Skills.getLevels()[10];
  208. startExp = Skills.getExperiences()[10];
  209. if (startLevel != 0 && startExp != 0) {
  210. statsLoaded = true;
  211. }
  212. }
  213. if (wasDropping) {
  214. return true;
  215. }
  216. if (guiDone && Game.isLoggedIn() && Inventory.getCount() >= 28) {
  217. return true;
  218. }
  219. return false;
  220. }
  221. }
  222.  
  223. private class AntiBan implements Task, Condition {
  224. @Override
  225. public void run() {
  226. int r = random(1, 150);
  227. if (r == 4) {
  228. antiBanStatus = ("Friend's List");
  229. Tabs.FRIENDS.open();
  230. Mouse.move(random(500, 650), random(300, 420));
  231. Time.sleep(random(25, 674));
  232. Mouse.move(random(500, 650), random(300, 420));
  233. Time.sleep(random(2100, 3400));
  234. Tabs.INVENTORY.open();
  235. } else if (r == 8) {
  236. antiBanStatus = ("Mouse Moving");
  237. for (int i = 0; i < 10; i++) {
  238. Mouse.move(random(0, 600), random(0, 600));
  239. }
  240. Time.sleep(random(1000, 2000));
  241. } else if (r == 12 || r == 1 || r == 2 || r == 3 || r == 4
  242. || r == 5 || r == 6 || r == 7 || r == 8 || r == 9
  243. || r == 10) {
  244. antiBanStatus = ("Angle Adjustment");
  245. Camera.setAngle(random(1, 359));
  246. Time.sleep(random(1000, 2000));
  247. } else if (r == 16) {
  248. antiBanStatus = ("Check Quest");
  249. Tabs.QUESTS.open();
  250. Time.sleep(random(1000, 2000));
  251. Tabs.INVENTORY.open();
  252. } else if (r == 20) {
  253. antiBanStatus = ("Checking Exp");
  254. Tabs.STATS.open();
  255. Widgets.get(320).getChild(29).hover();
  256. Time.sleep(random(2100, 3400));
  257. Tabs.INVENTORY.open();
  258. } else if (r == 24) {
  259. antiBanStatus = ("Playing with tabs");
  260. Tabs.ATTACK.open();
  261. Time.sleep(random(50, 600));
  262. Tabs.TASK_LIST.open();
  263. Time.sleep(random(50, 600));
  264. Tabs.STATS.open();
  265. Time.sleep(random(50, 600));
  266. Tabs.QUESTS.open();
  267. Time.sleep(random(50, 600));
  268. Tabs.INVENTORY.open();
  269. Time.sleep(random(50, 600));
  270. Tabs.EQUIPMENT.open();
  271. Time.sleep(random(50, 600));
  272. Tabs.PRAYER.open();
  273. Time.sleep(random(50, 600));
  274. Tabs.MAGIC.open();
  275. Time.sleep(random(50, 600));
  276. Tabs.INVENTORY.open();
  277. } else {
  278. antiBanStatus = ("Idle");
  279. Time.sleep(random(250, 300));
  280. }
  281. }
  282.  
  283. @Override
  284. public boolean validate() {
  285. if (guiDone && Game.isLoggedIn() && !Players.getLocal().isMoving()
  286. && Players.getLocal().getAnimation() != -1) {
  287. return true;
  288. }
  289. return false;
  290. }
  291. }
  292.  
  293. @Override
  294. public void onStop() {
  295. System.out
  296. .println("Turning off JamRSKaramjaFisher. Thanks for using it !");
  297. System.exit(0);
  298. }
  299.  
  300. // START: Code generated using Enfilade's Easel
  301. private final Color color1 = new Color(0, 0, 0, 100);
  302. private final Color color2 = new Color(255, 255, 255, 80);
  303. private final Color color3 = new Color(255, 255, 255);
  304. private final Color color4 = new Color(51, 102, 0);
  305.  
  306. private final BasicStroke stroke1 = new BasicStroke(3);
  307. private final BasicStroke stroke2 = new BasicStroke(1);
  308. private final BasicStroke stroke3 = new BasicStroke(2);
  309.  
  310. private final Font font1 = new Font("Arial", 1, 16);
  311. private final Font font2 = new Font("Arial", 1, 11);
  312. private final Font font3 = new Font("Arial", 1, 13);
  313. private final Font font4 = new Font("Arial", 1, 12);
  314. static int currentLevel = 0;
  315. static int levelGained = 0;
  316. static int experienceGained = 0;
  317. static int experienceHour = 0;
  318. static int experienceTNL = 0;
  319. static int tunaCaughtHour = 0;
  320. static int lobstersCaughtHour = 0;
  321. static int swordfishCaughtHour = 0;
  322. static int shrimpsCaughtHour = 0;
  323. static int anchoviesCaughtHour = 0;
  324. static int profit = 0;
  325. static int profitHour = 0;
  326. static int percentLevel = 0;
  327. static int experience = 0;
  328. static long timeToNextLevel = 0;
  329.  
  330. @Override
  331. public void onRepaint(Graphics g1) {
  332. if (Game.isLoggedIn() && guiDone && !(Skills.getLevels()[10] == 0)) {
  333. currentLevel = Skills.getLevels()[10];
  334. experience = Skills.getExperiences()[10];
  335. levelGained = currentLevel - startLevel;
  336. experienceGained = Skills.getExperience(10) - startExp;
  337. experienceHour = (int) ((experienceGained * 3600000D) / (System
  338. .currentTimeMillis() - startTime));
  339. experienceTNL = XP_TABLE[currentLevel + 1] - experience;
  340. tunaCaughtHour = (int) ((tunaCaught) * 3600000D / (System
  341. .currentTimeMillis() - startTime));
  342. lobstersCaughtHour = (int) ((lobstersCaught) * 3600000D / (System
  343. .currentTimeMillis() - startTime));
  344. swordfishCaughtHour = (int) ((swordfishCaught) * 3600000D / (System
  345. .currentTimeMillis() - startTime));
  346. shrimpsCaughtHour = (int) ((shrimpCaught) * 3600000D / (System
  347. .currentTimeMillis() - startTime));
  348. anchoviesCaughtHour = (int) ((anchoviesCaught) * 3600000D / (System
  349. .currentTimeMillis() - startTime));
  350. profit = ((tunaCaught * tunaPrice)
  351. + (lobstersCaught * lobsterPrice) + (swordfishCaught * swordfishPrice));
  352. profitHour = (int) ((profit) * 3600000D / (System
  353. .currentTimeMillis() - startTime));
  354. percentLevel = (int) (100 * (experience - XP_TABLE[currentLevel]) / (XP_TABLE[currentLevel + 1] - XP_TABLE[currentLevel]));
  355. if (experienceTNL == 0 || experienceHour == 0) {
  356. timeToNextLevel = 0;
  357. } else {
  358. timeToNextLevel = (long) ((double) experienceTNL
  359. / (double) experienceHour * 3600000D);
  360. }
  361.  
  362. Graphics2D g = (Graphics2D) g1;
  363. g.setColor(color1);
  364. g.fillRoundRect(6, 205, 508, 131, 16, 16);
  365. g.setColor(color2);
  366. g.setStroke(stroke1);
  367. g.setColor(color3);
  368. g.setStroke(stroke2);
  369. g.drawLine(241, 253, 328, 253);
  370. g.drawLine(59, 253, 126, 253);
  371. g.setColor(color2);
  372. g.setStroke(stroke1);
  373. g.drawLine(7, 235, 512, 235);
  374. g.drawLine(385, 206, 385, 334);
  375. g.drawLine(184, 206, 184, 334);
  376. g.setFont(font1);
  377. g.setColor(color3);
  378. g.drawString("JamRSKaramjaFisher", 16, 229);
  379. g.drawString("Running Time : "
  380. + format(System.currentTimeMillis() - startTime), 193, 229);
  381. g.setFont(font2);
  382. g.drawString("Experience", 63, 252);
  383. g.drawString("Fishies Caught", 244, 252);
  384. g.drawString("Current Level : " + currentLevel + " ( "
  385. + levelGained + " )", 12, 270);
  386. g.drawString("Experience Gained : " + experienceGained, 12, 285);
  387. g.drawString("Experience Hour : " + experienceHour, 12, 300);
  388. g.drawString("Experience TNL : " + experienceTNL, 12, 315);
  389. g.drawString("Time TNL : " + format(timeToNextLevel), 12, 329);
  390. g.drawString("Tuna : " + tunaCaught + " (Hour : " + tunaCaughtHour
  391. + ")", 191, 269);
  392. g.setColor(color4);
  393. g.fillRoundRect(190, 308, (int) (percentLevel * 1.9), 18, 16, 16);
  394. g.setColor(color3);
  395. g.setStroke(stroke3);
  396. g.drawRoundRect(190, 308, 190, 18, 16, 16);
  397. g.setStroke(stroke2);
  398. g.drawLine(409, 252, 491, 252);
  399. g.drawString("Lobsters : " + lobstersCaught + " (Hour : "
  400. + lobstersCaughtHour + ")", 191, 283);
  401. g.drawString("Swordfish : " + swordfishCaught + " (Hour : "
  402. + swordfishCaughtHour + ")", 191, 297);
  403. g.setFont(font3);
  404. g.drawString(percentLevel + "%", 269, 322);
  405. g.setColor(color2);
  406. g.setStroke(stroke1);
  407. g.drawLine(385, 290, 512, 290);
  408. g.setFont(font2);
  409. g.setColor(color3);
  410. g.drawString("Money Gained", 412, 251);
  411. g.drawString("Profit : " + profit, 392, 270);
  412. g.drawString("Profit Hour : " + profitHour, 392, 283);
  413. g.setFont(font4);
  414. g.drawString(botStatus, 393, 226);
  415. g.setStroke(stroke2);
  416. g.drawLine(405, 306, 492, 306);
  417. g.setFont(font2);
  418. g.drawString("Antiban Status", 410, 305);
  419. g.drawString(antiBanStatus, 390, 322);
  420.  
  421. // Mouse Region
  422. g.drawImage(mouse, Mouse.getLocation().x, Mouse.getLocation().y,
  423. null);
  424. // End Mouse Region
  425. }
  426. }
  427.  
  428. // END: Code generated using Enfilade's Easel
  429.  
  430. public class GUI extends JFrame {
  431. private static final long serialVersionUID = 4269443661291347215L;
  432.  
  433. public GUI() {
  434. setTitle("JamRSKaramjaFisher");
  435. getContentPane().setLayout(null);
  436. setBounds(40, 40, 292, 274);
  437. setVisible(false);
  438.  
  439. title = new JLabel();
  440. fishingModeLBL = new JLabel();
  441. fish = new JLabel();
  442. fishList = new JComboBox<String>();
  443. fishingModeList = new JComboBox<String>();
  444. instructions = new JLabel();
  445. instruction2 = new JLabel();
  446. startButton = new JButton();
  447.  
  448. title.setText("JamRSKaramjaFisher");
  449. title.setBounds(0, 12, getWidth() - 7, 20);
  450. title.setFont(new Font("Tahoma", Font.PLAIN, 16));
  451. title.setHorizontalAlignment(SwingConstants.CENTER);
  452. fish.setText("Fish : ");
  453. fish.setBounds(20, 57, 40, 10);
  454. fishingModeLBL.setText("Fishing Mode :");
  455. fishingModeLBL.setBounds(20, 82, 80, 14);
  456. fishList.setBounds(100, 50, 132, 20);
  457. fishList.setModel(new DefaultComboBoxModel<String>(new String[] {
  458. "Shrimps/Anchovies", "Lobsters", "Tuna/Swordfish" }));
  459. fishingModeList.setBounds(100, 79, 132, 20);
  460. fishingModeList.setModel(new DefaultComboBoxModel<String>(
  461. new String[] { "Powerfishing" }));
  462. instructions.setBounds(-7, 110, getWidth(), 50);
  463. instructions
  464. .setText("<html>Note that you must have your cage, harpoon or net <br> <center>in your inventory or toolbelt!</center></html>");
  465. instructions.setHorizontalAlignment(SwingConstants.CENTER);
  466. instruction2.setText("Please start at the fishing area.");
  467. instruction2.setBounds(-7, 180, getWidth(), 12);
  468. instruction2.setHorizontalAlignment(SwingConstants.CENTER);
  469. startButton.setText("Start");
  470. startButton.setBounds(108, 200, 70, 23);
  471.  
  472. startButton.addActionListener(new ActionListener() {
  473. @Override
  474. public void actionPerformed(ActionEvent e) {
  475. fishingMode = fishingModeList.getSelectedItem().toString();
  476. String f = fishList.getSelectedItem().toString();
  477. if (f.equals("Lobsters")) {
  478. fishType = "Cage";
  479. spotID = 324;
  480. } else if (f.equals("Tuna/Swordfish")) {
  481. fishType = "Harpoon";
  482. spotID = 324;
  483. } else if (f.equals("Shrimps/Anchovies")) {
  484. fishType = "Net";
  485. spotID = 323;
  486. }
  487. setVisible(false);
  488. startTime = System.currentTimeMillis();
  489. guiDone = true;
  490. }
  491. });
  492.  
  493. fishList.addActionListener(new ActionListener() {
  494. @Override
  495. public void actionPerformed(ActionEvent e) {
  496. String f = fishList.getSelectedItem().toString();
  497. if (f.equals("Lobsters")) {
  498. fishingModeList.removeAllItems();
  499. fishingModeList.addItem("Stiles");
  500. fishingModeList.addItem("Powerfishing");
  501. } else if (f.equals("Shrimps/Anchovies")) {
  502. fishingModeList.removeAllItems();
  503. fishingModeList.addItem("Powerfishing");
  504. }
  505. else if (f.equals("Tuna/Swordfish")) {
  506. fishingModeList.removeAllItems();
  507. fishingModeList.addItem("Stiles");
  508. fishingModeList.addItem("Powerfishing");
  509. fishingModeList.addItem("droptuna");
  510.  
  511. }
  512. });
  513.  
  514. getContentPane().add(title);
  515. getContentPane().add(fishingModeLBL);
  516. getContentPane().add(fish);
  517. getContentPane().add(fishList);
  518. getContentPane().add(fishingModeList);
  519. getContentPane().add(instructions);
  520. getContentPane().add(instruction2);
  521. getContentPane().add(startButton);
  522. }
  523.  
  524. JLabel title;
  525. JLabel fishingModeLBL;
  526. JLabel fish;
  527. JLabel instructions;
  528. JLabel instruction2;
  529. JComboBox<String> fishList;
  530. JComboBox<String> fishingModeList;
  531. JButton startButton;
  532.  
  533. }
  534.  
  535. @Override
  536. public void messageReceived(MessageEvent arg0) {
  537. if (arg0.getMessage().contains("You catch a lobster")) {
  538. lobstersCaught++;
  539. }
  540. if (arg0.getMessage().contains("catch a tuna")) {
  541. tunaCaught++;
  542. }
  543. if (arg0.getMessage().contains("catch a swordfish")) {
  544. swordfishCaught++;
  545. }
  546. if (arg0.getMessage().contains("catch some shrimp")) {
  547. shrimpCaught++;
  548. }
  549. if (arg0.getMessage().contains("catch some anchovies")) {
  550. anchoviesCaught++;
  551. }
  552. }
  553.  
  554. class LoadingThread extends Thread {
  555. @Override
  556. public void run() {
  557. System.out.println("Checking for Update...");
  558. boolean turningOff = false;
  559. try {
  560. turningOff = checkForUpdate();
  561. } catch (IOException e) {
  562. System.out.println("Failed to check for update.");
  563. }
  564. if (!turningOff) {
  565. System.out.println("Loading Price... ");
  566. tunaPrice = getPrice(tunaID);
  567. lobsterPrice = getPrice(lobsterID);
  568. swordfishPrice = getPrice(swordfishID);
  569. System.out.println("Prices are : Tuna " + tunaPrice
  570. + " gp, Lobster " + lobsterPrice + " gp, Swordfish "
  571. + swordfishPrice + " gp.");
  572. System.out.println("Done Loading price.");
  573. System.out.println("Loading Mouse cursor.");
  574. loadMouseCursor();
  575. System.out.println("Done Loading Mouse cursor.");
  576. gui = new GUI();
  577. gui.setVisible(true);
  578. }
  579. }
  580.  
  581. private int getPrice(int itemID) {
  582. URL url;
  583. InputStream in_stream;
  584. String line = "0";
  585. BufferedReader reader;
  586. try {
  587. url = new URL("http://scripts.audefy.com/l/" + itemID);
  588. in_stream = url.openConnection().getInputStream();
  589. reader = new BufferedReader(new InputStreamReader(in_stream));
  590. line = reader.readLine();
  591. } catch (IOException ex) {
  592. System.out
  593. .println("An error occured while trying to load price");
  594. }
  595. return Integer.parseInt(line);
  596. }
  597. }
  598.  
  599. private String format(long time) {
  600. StringBuilder t = new StringBuilder();
  601. long total_secs = time / 1000;
  602. long total_mins = total_secs / 60;
  603. long total_hrs = total_mins / 60;
  604. int secs = (int) total_secs % 60;
  605. int mins = (int) total_mins % 60;
  606. int hrs = (int) total_hrs % 60;
  607. if (hrs < 10) {
  608. t.append("0");
  609. }
  610. t.append(hrs);
  611. t.append(":");
  612. if (mins < 10) {
  613. t.append("0");
  614. }
  615. t.append(mins);
  616. t.append(":");
  617. if (secs < 10) {
  618. t.append("0");
  619. }
  620. t.append(secs);
  621. return t.toString();
  622. }
  623.  
  624. private void walk(Tile[] fullTile) {
  625. if (Walking.getEnergy() > random(30, 50)) {
  626. Walking.setRun(true);
  627. }
  628. for (int i = fullTile.length - 1; i >= 0; i--) {
  629. if (Calculations.distanceTo(fullTile[i]) <= 15
  630. && Walking.walk(fullTile[i])) {
  631. break;
  632. }
  633. }
  634. }
  635.  
  636. private int random(int Min, int Max) {
  637. return Random.nextInt(Min, Max);
  638. }
  639.  
  640. private void loadMouseCursor() {
  641. // Mouse Region
  642. final URL cursorURL;
  643. try {
  644. cursorURL = new URL("http://i.imgur.com/lgkS7.png");
  645. mouse = ImageIO.read(cursorURL);
  646. } catch (MalformedURLException ex) {
  647. System.out.println("Unable to download the cursor");
  648. } catch (IOException ex) {
  649. System.out.println("Unable to load the cursor");
  650. }
  651. // End Mouse Region
  652. }
  653.  
  654. private boolean checkForUpdate() throws IOException {
  655. BufferedReader buffReader = new BufferedReader(new InputStreamReader(
  656. new URL("http://pastebin.com/raw.php?i=Jc1nf3MZ").openStream()));
  657. String text;
  658. while ((text = buffReader.readLine()) != null) {
  659. if (text.contains("final static double version = ")) {
  660. String versionString = text.replace(
  661. "final static double version = ", "");
  662. versionString = versionString.replace(";", "");
  663. double versionD;
  664. try {
  665. versionD = Double.parseDouble(versionString);
  666. buffReader.close();
  667. if (versionD > version) {
  668. System.out.println("An update is available. Version "
  669. + versionD);
  670. int answer = JOptionPane.showConfirmDialog(null,
  671. "An update is available. Version " + versionD
  672. + ". Do you want to update ?",
  673. "Update available", JOptionPane.YES_NO_OPTION);
  674. if (answer == JOptionPane.YES_OPTION) {
  675. Desktop.getDesktop()
  676. .browse(new URI(
  677. "http://www.powerbot.org/community/topic/675111-new-jamrskaramjafisher-best-known-karamja-fisher/"));
  678. stop();
  679. return true;
  680. }
  681. } else {
  682. System.out.println("No updates available");
  683. }
  684. } catch (Exception e) {
  685. System.out.println("Failed to check for update");
  686. }
  687. break;
  688. }
  689. }
  690. buffReader.close();
  691. return false;
  692. }
  693.  
  694. Filter<NPC> StilesFilter = new Filter<NPC>() {
  695. @Override
  696. public boolean accept(NPC t) {
  697. if (t.getId() == 11267) {
  698. return true;
  699. }
  700. return false;
  701. }
  702. };
  703.  
  704. Tile[] StilesPath = new Tile[] { new Tile(2924, 3175, 0),
  705. new Tile(2924, 3172, 0), new Tile(2915, 3172, 0),
  706. new Tile(2906, 3172, 0), new Tile(2900, 3166, 0),
  707. new Tile(2898, 3157, 0), new Tile(2889, 3154, 0),
  708. new Tile(2881, 3154, 0), new Tile(2873, 3150, 0),
  709. new Tile(2865, 3149, 0), new Tile(2857, 3144, 0),
  710. new Tile(2852, 3142, 0) };
  711.  
  712. Tile[] StilesPath2 = new Tile[] { new Tile(2922, 3173, 0),
  713. new Tile(2913, 3173, 0), new Tile(2904, 3170, 0),
  714. new Tile(2895, 3167, 0), new Tile(2894, 3158, 0),
  715. new Tile(2892, 3149, 0), new Tile(2890, 3143, 0),
  716. new Tile(2881, 3143, 0), new Tile(2872, 3145, 0),
  717. new Tile(2863, 3149, 0), new Tile(2855, 3144, 0),
  718. new Tile(2852, 3142, 0) };
  719.  
  720. Tile[] FishPath2 = new Tile[] { new Tile(2852, 3142, 0),
  721. new Tile(2860, 3147, 0), new Tile(2869, 3147, 0),
  722. new Tile(2878, 3144, 0), new Tile(2887, 3146, 0),
  723. new Tile(2896, 3148, 0), new Tile(2897, 3157, 0),
  724. new Tile(2898, 3166, 0), new Tile(2901, 3172, 0),
  725. new Tile(2910, 3172, 0), new Tile(2919, 3172, 0),
  726. new Tile(2924, 3175, 0) };
  727.  
  728. Tile[] FishPath = new Tile[] { new Tile(2854, 3142, 0),
  729. new Tile(2859, 3146, 0), new Tile(2865, 3148, 0),
  730. new Tile(2872, 3146, 0), new Tile(2881, 3146, 0),
  731. new Tile(2890, 3146, 0), new Tile(2894, 3150, 0),
  732. new Tile(2898, 3154, 0), new Tile(2898, 3163, 0),
  733. new Tile(2898, 3168, 0), new Tile(2903, 3170, 0),
  734. new Tile(2908, 3172, 0), new Tile(2917, 3172, 0),
  735. new Tile(2924, 3172, 0), new Tile(2924, 3175, 0) };
  736.  
  737. Area FishingArea = new Area(new Tile[] { new Tile(2927, 3172, 0),
  738. new Tile(2919, 3172, 0), new Tile(2919, 3183, 0),
  739. new Tile(2927, 3183, 0) });
  740.  
  741. Area StilesArea = new Area(new Tile[] { new Tile(2847, 3140, 0),
  742. new Tile(2855, 3140, 0), new Tile(2855, 3146, 0),
  743. new Tile(2848, 3146, 0) });
  744.  
  745. static final int[] XP_TABLE = { 0, 0, 83, 174, 276, 388, 512, 650, 801,
  746. 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973,
  747. 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031,
  748. 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408,
  749. 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127,
  750. 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636,
  751. 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599,
  752. 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445,
  753. 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200,
  754. 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594,
  755. 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253,
  756. 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431,
  757. 14391160, 15889109, 17542976, 19368992, 21385073, 23611006,
  758. 26068632, 28782069, 31777943, 35085654, 38737661, 42769801,
  759. 47221641, 52136869, 57563718, 63555443, 70170840, 77474828,
  760. 85539082, 94442737, 104273167 };
  761. }
Advertisement
Add Comment
Please, Sign In to add comment