gamemaste789

Untitled

Apr 25th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.99 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 fisher 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") && f.equals("Swordfish")) {
  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 == 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 == 12) {
  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. }
  278. else if (r == 1){
  279. antiBanStatus = ("Playing with tabs");
  280. Tabs.ATTACK.open();
  281. Time.sleep(random(50, 600));
  282. Tabs.TASK_LIST.open();
  283. Time.sleep(random(50, 600));
  284. Tabs.STATS.open();
  285. Time.sleep(random(50, 600));
  286. Tabs.QUESTS.open();
  287. Time.sleep(random(50, 600));
  288. Tabs.INVENTORY.open();
  289. }
  290. else if (r ==26){
  291. antiBanStatus = ("Playing with tabs");
  292. Tabs.MAGIC.open();
  293. Time.sleep(random(50, 600));
  294. Tabs.INVENTORY.open();
  295. Time.sleep(random(50, 600));
  296. Tabs.EQUIPMENT.open();
  297. Time.sleep(random(50, 600));
  298. Tabs.PRAYER.open();
  299. Time.sleep(random(50, 600));
  300. Tabs.MAGIC.open();
  301. Time.sleep(random(50, 600));
  302. Tabs.INVENTORY.open();
  303. }
  304. }
  305. else {
  306. antiBanStatus = ("Idle");
  307. Time.sleep(random(250, 300));
  308. }
  309. }
  310.  
  311. @Override
  312. public boolean validate() {
  313. if (guiDone && Game.isLoggedIn() && !Players.getLocal().isMoving()
  314. && Players.getLocal().getAnimation() != -1) {
  315. return true;
  316. }
  317. return false;
  318. }
  319. }
  320.  
  321. @Override
  322. public void onStop() {
  323. System.out
  324. .println("Turning off JamRSKaramjaFisher. Thanks for using it !");
  325. System.exit(0);
  326. }
  327.  
  328. // START: Code generated using Enfilade's Easel
  329. private final Color color1 = new Color(0, 0, 0, 100);
  330. private final Color color2 = new Color(255, 255, 255, 80);
  331. private final Color color3 = new Color(255, 255, 255);
  332. private final Color color4 = new Color(51, 102, 0);
  333.  
  334. private final BasicStroke stroke1 = new BasicStroke(3);
  335. private final BasicStroke stroke2 = new BasicStroke(1);
  336. private final BasicStroke stroke3 = new BasicStroke(2);
  337.  
  338. private final Font font1 = new Font("Arial", 1, 16);
  339. private final Font font2 = new Font("Arial", 1, 11);
  340. private final Font font3 = new Font("Arial", 1, 13);
  341. private final Font font4 = new Font("Arial", 1, 12);
  342. static int currentLevel = 0;
  343. static int levelGained = 0;
  344. static int experienceGained = 0;
  345. static int experienceHour = 0;
  346. static int experienceTNL = 0;
  347. static int tunaCaughtHour = 0;
  348. static int lobstersCaughtHour = 0;
  349. static int swordfishCaughtHour = 0;
  350. static int shrimpsCaughtHour = 0;
  351. static int anchoviesCaughtHour = 0;
  352. static int profit = 0;
  353. static int profitHour = 0;
  354. static int percentLevel = 0;
  355. static int experience = 0;
  356. static long timeToNextLevel = 0;
  357.  
  358. @Override
  359. public void onRepaint(Graphics g1) {
  360. if (Game.isLoggedIn() && guiDone && !(Skills.getLevels()[10] == 0)) {
  361. currentLevel = Skills.getLevels()[10];
  362. experience = Skills.getExperiences()[10];
  363. levelGained = currentLevel - startLevel;
  364. experienceGained = Skills.getExperience(10) - startExp;
  365. experienceHour = (int) ((experienceGained * 3600000D) / (System
  366. .currentTimeMillis() - startTime));
  367. experienceTNL = XP_TABLE[currentLevel + 1] - experience;
  368. tunaCaughtHour = (int) ((tunaCaught) * 3600000D / (System
  369. .currentTimeMillis() - startTime));
  370. lobstersCaughtHour = (int) ((lobstersCaught) * 3600000D / (System
  371. .currentTimeMillis() - startTime));
  372. swordfishCaughtHour = (int) ((swordfishCaught) * 3600000D / (System
  373. .currentTimeMillis() - startTime));
  374. shrimpsCaughtHour = (int) ((shrimpCaught) * 3600000D / (System
  375. .currentTimeMillis() - startTime));
  376. anchoviesCaughtHour = (int) ((anchoviesCaught) * 3600000D / (System
  377. .currentTimeMillis() - startTime));
  378. profit = ((tunaCaught * tunaPrice)
  379. + (lobstersCaught * lobsterPrice) + (swordfishCaught * swordfishPrice));
  380. profitHour = (int) ((profit) * 3600000D / (System
  381. .currentTimeMillis() - startTime));
  382. percentLevel = (int) (100 * (experience - XP_TABLE[currentLevel]) / (XP_TABLE[currentLevel + 1] - XP_TABLE[currentLevel]));
  383. if (experienceTNL == 0 || experienceHour == 0) {
  384. timeToNextLevel = 0;
  385. } else {
  386. timeToNextLevel = (long) ((double) experienceTNL
  387. / (double) experienceHour * 3600000D);
  388. }
  389.  
  390. Graphics2D g = (Graphics2D) g1;
  391. g.setColor(color1);
  392. g.fillRoundRect(6, 205, 508, 131, 16, 16);
  393. g.setColor(color2);
  394. g.setStroke(stroke1);
  395. g.setColor(color3);
  396. g.setStroke(stroke2);
  397. g.drawLine(241, 253, 328, 253);
  398. g.drawLine(59, 253, 126, 253);
  399. g.setColor(color2);
  400. g.setStroke(stroke1);
  401. g.drawLine(7, 235, 512, 235);
  402. g.drawLine(385, 206, 385, 334);
  403. g.drawLine(184, 206, 184, 334);
  404. g.setFont(font1);
  405. g.setColor(color3);
  406. g.drawString("JamRSKaramjaFisher", 16, 229);
  407. g.drawString("Running Time : "
  408. + format(System.currentTimeMillis() - startTime), 193, 229);
  409. g.setFont(font2);
  410. g.drawString("Experience", 63, 252);
  411. g.drawString("Fishies Caught", 244, 252);
  412. g.drawString("Current Level : " + currentLevel + " ( "
  413. + levelGained + " )", 12, 270);
  414. g.drawString("Experience Gained : " + experienceGained, 12, 285);
  415. g.drawString("Experience Hour : " + experienceHour, 12, 300);
  416. g.drawString("Experience TNL : " + experienceTNL, 12, 315);
  417. g.drawString("Time TNL : " + format(timeToNextLevel), 12, 329);
  418. g.drawString("Tuna : " + tunaCaught + " (Hour : " + tunaCaughtHour
  419. + ")", 191, 269);
  420. g.setColor(color4);
  421. g.fillRoundRect(190, 308, (int) (percentLevel * 1.9), 18, 16, 16);
  422. g.setColor(color3);
  423. g.setStroke(stroke3);
  424. g.drawRoundRect(190, 308, 190, 18, 16, 16);
  425. g.setStroke(stroke2);
  426. g.drawLine(409, 252, 491, 252);
  427. g.drawString("Lobsters : " + lobstersCaught + " (Hour : "
  428. + lobstersCaughtHour + ")", 191, 283);
  429. g.drawString("Swordfish : " + swordfishCaught + " (Hour : "
  430. + swordfishCaughtHour + ")", 191, 297);
  431. g.setFont(font3);
  432. g.drawString(percentLevel + "%", 269, 322);
  433. g.setColor(color2);
  434. g.setStroke(stroke1);
  435. g.drawLine(385, 290, 512, 290);
  436. g.setFont(font2);
  437. g.setColor(color3);
  438. g.drawString("Money Gained", 412, 251);
  439. g.drawString("Profit : " + profit, 392, 270);
  440. g.drawString("Profit Hour : " + profitHour, 392, 283);
  441. g.setFont(font4);
  442. g.drawString(botStatus, 393, 226);
  443. g.setStroke(stroke2);
  444. g.drawLine(405, 306, 492, 306);
  445. g.setFont(font2);
  446. g.drawString("Antiban Status", 410, 305);
  447. g.drawString(antiBanStatus, 390, 322);
  448.  
  449. // Mouse Region
  450. g.drawImage(mouse, Mouse.getLocation().x, Mouse.getLocation().y,
  451. null);
  452. // End Mouse Region
  453. }
  454. }
  455.  
  456. // END: Code generated using Enfilade's Easel
  457.  
  458. public class GUI extends JFrame {
  459. private static final long serialVersionUID = 4269443661291347215L;
  460.  
  461. public GUI() {
  462. setTitle("JamRSKaramjaFisher");
  463. getContentPane().setLayout(null);
  464. setBounds(40, 40, 292, 274);
  465. setVisible(false);
  466.  
  467. title = new JLabel();
  468. fishingModeLBL = new JLabel();
  469. fish = new JLabel();
  470. fishList = new JComboBox<String>();
  471. fishingModeList = new JComboBox<String>();
  472. instructions = new JLabel();
  473. instruction2 = new JLabel();
  474. startButton = new JButton();
  475.  
  476. title.setText("JamRSKaramjaFisher");
  477. title.setBounds(0, 12, getWidth() - 7, 20);
  478. title.setFont(new Font("Tahoma", Font.PLAIN, 16));
  479. title.setHorizontalAlignment(SwingConstants.CENTER);
  480. fish.setText("Fish : ");
  481. fish.setBounds(20, 57, 40, 10);
  482. fishingModeLBL.setText("Fishing Mode :");
  483. fishingModeLBL.setBounds(20, 82, 80, 14);
  484. fishList.setBounds(100, 50, 132, 20);
  485. fishList.setModel(new DefaultComboBoxModel<String>(new String[] {
  486. "Shrimps/Anchovies", "Lobsters", "Swordfish", "Tuna/Swordfish" }));
  487. fishingModeList.setBounds(100, 79, 132, 20);
  488. fishingModeList.setModel(new DefaultComboBoxModel<String>(
  489. new String[] { "Powerfishing" }));
  490. instructions.setBounds(-7, 110, getWidth(), 50);
  491. instructions
  492. .setText("<html>Note that you must have your cage, harpoon or net <br> <center>in your inventory or toolbelt!</center></html>");
  493. instructions.setHorizontalAlignment(SwingConstants.CENTER);
  494. instruction2.setText("Please start at the fishing area.");
  495. instruction2.setBounds(-7, 180, getWidth(), 12);
  496. instruction2.setHorizontalAlignment(SwingConstants.CENTER);
  497. startButton.setText("Start");
  498. startButton.setBounds(108, 200, 70, 23);
  499.  
  500. startButton.addActionListener(new ActionListener() {
  501. @Override
  502. public void actionPerformed(ActionEvent e) {
  503. fishingMode = fishingModeList.getSelectedItem().toString();
  504. String f = fishList.getSelectedItem().toString();
  505. if (f.equals("Lobsters")) {
  506. fishType = "Cage";
  507. spotID = 324;
  508. } else if (f.equals("Tuna/Swordfish")) {
  509. fishType = "Harpoon";
  510. spotID = 324;
  511. } else if (f.equals("Shrimps/Anchovies")) {
  512. fishType = "Net";
  513. spotID = 323;
  514. }
  515. else if (f.equals("Swordfish")) {
  516. fishType = "Harpoon";
  517. spotID = 324;
  518. }
  519. setVisible(false);
  520. startTime = System.currentTimeMillis();
  521. guiDone = true;
  522. }
  523. });
  524.  
  525. fishList.addActionListener(new ActionListener() {
  526. @Override
  527. public void actionPerformed(ActionEvent e) {
  528. String f = fishList.getSelectedItem().toString();
  529. if (f.equals("Lobsters")) {
  530. fishingModeList.removeAllItems();
  531. fishingModeList.addItem("Stiles");
  532. fishingModeList.addItem("Powerfishing");
  533. } else if (f.equals("Shrimps/Anchovies")) {
  534. fishingModeList.removeAllItems();
  535. fishingModeList.addItem("Powerfishing");
  536. }
  537. else if (f.equals("Swordfish")) {
  538. fishingModeList.removeAllItems();
  539. fishingodeList.addMItem("Stiles");
  540. fishingModeList.addItem("Powerfishing");
  541. }
  542. else if (f.equals("Tuna/Swordfish")) {
  543. fishingModeList.removeAllItems();
  544. fishingodeList.addMItem("Stiles");
  545. fishingModeList.addItem("Powerfishing");
  546. }
  547. );
  548.  
  549. getContentPane().add(title);
  550. getContentPane().add(fishingModeLBL);
  551. getContentPane().add(fish);
  552. getContentPane().add(fishList);
  553. getContentPane().add(fishingModeList);
  554. getContentPane().add(instructions);
  555. getContentPane().add(instruction2);
  556. getContentPane().add(startButton);
  557. }
  558.  
  559. JLabel title;
  560. JLabel fishingModeLBL;
  561. JLabel fish;
  562. JLabel instructions;
  563. JLabel instruction2;
  564. JComboBox<String> fishList;
  565. JComboBox<String> fishingModeList;
  566. JButton startButton;
  567.  
  568. }
  569.  
  570. @Override
  571. public void messageReceived(MessageEvent arg0) {
  572. if (arg0.getMessage().contains("You catch a lobster")) {
  573. lobstersCaught++;
  574. }
  575. if (arg0.getMessage().contains("catch a tuna")) {
  576. tunaCaught++;
  577. }
  578. if (arg0.getMessage().contains("catch a swordfish")) {
  579. swordfishCaught++;
  580. }
  581. if (arg0.getMessage().contains("catch some shrimp")) {
  582. shrimpCaught++;
  583. }
  584. if (arg0.getMessage().contains("catch some anchovies")) {
  585. anchoviesCaught++;
  586. }
  587. }
  588.  
  589. class LoadingThread extends Thread {
  590. @Override
  591. public void run() {
  592. System.out.println("Checking for Update...");
  593. boolean turningOff = false;
  594. try {
  595. turningOff = checkForUpdate();
  596. } catch (IOException e) {
  597. System.out.println("Failed to check for update.");
  598. }
  599. if (!turningOff) {
  600. System.out.println("Loading Price... ");
  601. tunaPrice = getPrice(tunaID);
  602. lobsterPrice = getPrice(lobsterID);
  603. swordfishPrice = getPrice(swordfishID);
  604. System.out.println("Prices are : Tuna " + tunaPrice
  605. + " gp, Lobster " + lobsterPrice + " gp, Swordfish "
  606. + swordfishPrice + " gp.");
  607. System.out.println("Done Loading price.");
  608. System.out.println("Loading Mouse cursor.");
  609. loadMouseCursor();
  610. System.out.println("Done Loading Mouse cursor.");
  611. gui = new GUI();
  612. gui.setVisible(true);
  613. }
  614. }
  615.  
  616. private int getPrice(int itemID) {
  617. URL url;
  618. InputStream in_stream;
  619. String line = "0";
  620. BufferedReader reader;
  621. try {
  622. url = new URL("http://scripts.audefy.com/l/" + itemID);
  623. in_stream = url.openConnection().getInputStream();
  624. reader = new BufferedReader(new InputStreamReader(in_stream));
  625. line = reader.readLine();
  626. } catch (IOException ex) {
  627. System.out
  628. .println("An error occured while trying to load price");
  629. }
  630. return Integer.parseInt(line);
  631. }
  632. }
  633.  
  634. private String format(long time) {
  635. StringBuilder t = new StringBuilder();
  636. long total_secs = time / 1000;
  637. long total_mins = total_secs / 60;
  638. long total_hrs = total_mins / 60;
  639. int secs = (int) total_secs % 60;
  640. int mins = (int) total_mins % 60;
  641. int hrs = (int) total_hrs % 60;
  642. if (hrs < 10) {
  643. t.append("0");
  644. }
  645. t.append(hrs);
  646. t.append(":");
  647. if (mins < 10) {
  648. t.append("0");
  649. }
  650. t.append(mins);
  651. t.append(":");
  652. if (secs < 10) {
  653. t.append("0");
  654. }
  655. t.append(secs);
  656. return t.toString();
  657. }
  658.  
  659. private void walk(Tile[] fullTile) {
  660. if (Walking.getEnergy() > random(30, 50)) {
  661. Walking.setRun(true);
  662. }
  663. for (int i = fullTile.length - 1; i >= 0; i--) {
  664. if (Calculations.distanceTo(fullTile[i]) <= 15
  665. && Walking.walk(fullTile[i])) {
  666. break;
  667. }
  668. }
  669. }
  670.  
  671. private int random(int Min, int Max) {
  672. return Random.nextInt(Min, Max);
  673. }
  674.  
  675. private void loadMouseCursor() {
  676. // Mouse Region
  677. final URL cursorURL;
  678. try {
  679. cursorURL = new URL("http://i.imgur.com/lgkS7.png");
  680. mouse = ImageIO.read(cursorURL);
  681. } catch (MalformedURLException ex) {
  682. System.out.println("Unable to download the cursor");
  683. } catch (IOException ex) {
  684. System.out.println("Unable to load the cursor");
  685. }
  686. // End Mouse Region
  687. }
  688.  
  689. private boolean checkForUpdate() throws IOException {
  690. BufferedReader buffReader = new BufferedReader(new InputStreamReader(
  691. new URL("http://pastebin.com/raw.php?i=Jc1nf3MZ").openStream()));
  692. String text;
  693. while ((text = buffReader.readLine()) != null) {
  694. if (text.contains("final static double version = ")) {
  695. String versionString = text.replace(
  696. "final static double version = ", "");
  697. versionString = versionString.replace(";", "");
  698. double versionD;
  699. try {
  700. versionD = Double.parseDouble(versionString);
  701. buffReader.close();
  702. if (versionD > version) {
  703. System.out.println("An update is available. Version "
  704. + versionD);
  705. int answer = JOptionPane.showConfirmDialog(null,
  706. "An update is available. Version " + versionD
  707. + ". Do you want to update ?",
  708. "Update available", JOptionPane.YES_NO_OPTION);
  709. if (answer == JOptionPane.YES_OPTION) {
  710. Desktop.getDesktop()
  711. .browse(new URI(
  712. "http://www.powerbot.org/community/topic/675111-new-jamrskaramjafisher-best-known-karamja-fisher/"));
  713. stop();
  714. return true;
  715. }
  716. } else {
  717. System.out.println("No updates available");
  718. }
  719. } catch (Exception e) {
  720. System.out.println("Failed to check for update");
  721. }
  722. break;
  723. }
  724. }
  725. buffReader.close();
  726. return false;
  727. }
  728.  
  729. Filter<NPC> StilesFilter = new Filter<NPC>() {
  730. @Override
  731. public boolean accept(NPC t) {
  732. if (t.getId() == 11267) {
  733. return true;
  734. }
  735. return false;
  736. }
  737. };
  738.  
  739. Tile[] StilesPath = new Tile[] { new Tile(2924, 3175, 0),
  740. new Tile(2924, 3172, 0), new Tile(2915, 3172, 0),
  741. new Tile(2906, 3172, 0), new Tile(2900, 3166, 0),
  742. new Tile(2898, 3157, 0), new Tile(2889, 3154, 0),
  743. new Tile(2881, 3154, 0), new Tile(2873, 3150, 0),
  744. new Tile(2865, 3149, 0), new Tile(2857, 3144, 0),
  745. new Tile(2852, 3142, 0) };
  746.  
  747. Tile[] StilesPath2 = new Tile[] { new Tile(2922, 3173, 0),
  748. new Tile(2913, 3173, 0), new Tile(2904, 3170, 0),
  749. new Tile(2895, 3167, 0), new Tile(2894, 3158, 0),
  750. new Tile(2892, 3149, 0), new Tile(2890, 3143, 0),
  751. new Tile(2881, 3143, 0), new Tile(2872, 3145, 0),
  752. new Tile(2863, 3149, 0), new Tile(2855, 3144, 0),
  753. new Tile(2852, 3142, 0) };
  754.  
  755. Tile[] FishPath2 = new Tile[] { new Tile(2852, 3142, 0),
  756. new Tile(2860, 3147, 0), new Tile(2869, 3147, 0),
  757. new Tile(2878, 3144, 0), new Tile(2887, 3146, 0),
  758. new Tile(2896, 3148, 0), new Tile(2897, 3157, 0),
  759. new Tile(2898, 3166, 0), new Tile(2901, 3172, 0),
  760. new Tile(2910, 3172, 0), new Tile(2919, 3172, 0),
  761. new Tile(2924, 3175, 0) };
  762.  
  763. Tile[] FishPath = new Tile[] { new Tile(2854, 3142, 0),
  764. new Tile(2859, 3146, 0), new Tile(2865, 3148, 0),
  765. new Tile(2872, 3146, 0), new Tile(2881, 3146, 0),
  766. new Tile(2890, 3146, 0), new Tile(2894, 3150, 0),
  767. new Tile(2898, 3154, 0), new Tile(2898, 3163, 0),
  768. new Tile(2898, 3168, 0), new Tile(2903, 3170, 0),
  769. new Tile(2908, 3172, 0), new Tile(2917, 3172, 0),
  770. new Tile(2924, 3172, 0), new Tile(2924, 3175, 0) };
  771.  
  772. Area FishingArea = new Area(new Tile[] { new Tile(2927, 3172, 0),
  773. new Tile(2919, 3172, 0), new Tile(2919, 3183, 0),
  774. new Tile(2927, 3183, 0) });
  775.  
  776. Area StilesArea = new Area(new Tile[] { new Tile(2847, 3140, 0),
  777. new Tile(2855, 3140, 0), new Tile(2855, 3146, 0),
  778. new Tile(2848, 3146, 0) });
  779.  
  780. static final int[] XP_TABLE = { 0, 0, 83, 174, 276, 388, 512, 650, 801,
  781. 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973,
  782. 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031,
  783. 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408,
  784. 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127,
  785. 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636,
  786. 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599,
  787. 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445,
  788. 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200,
  789. 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594,
  790. 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253,
  791. 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431,
  792. 14391160, 15889109, 17542976, 19368992, 21385073, 23611006,
  793. 26068632, 28782069, 31777943, 35085654, 38737661, 42769801,
  794. 47221641, 52136869, 57563718, 63555443, 70170840, 77474828,
  795. 85539082, 94442737, 104273167 };
  796. }
Advertisement
Add Comment
Please, Sign In to add comment