Advertisement
Guest User

Untitled

a guest
May 29th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.01 KB | None | 0 0
  1. package monkfishfrenzy;
  2.  
  3. import com.kbotpro.scriptsystem.events.PaintEventListener;
  4. import com.kbotpro.scriptsystem.events.ServerMessageListener;
  5. import com.kbotpro.scriptsystem.interfaces.Looped;
  6. import com.kbotpro.scriptsystem.runnable.Script;
  7. import com.kbotpro.scriptsystem.various.GrandExchangeLookup;
  8. import com.kbotpro.scriptsystem.various.KTimer;
  9. import com.kbotpro.scriptsystem.wrappers.GroundItem;
  10. import com.kbotpro.scriptsystem.wrappers.IComponent;
  11. import com.kbotpro.scriptsystem.wrappers.NPC;
  12. import com.kbotpro.scriptsystem.wrappers.Tile;
  13. import org.apache.commons.lang.ArrayUtils;
  14.  
  15. import javax.imageio.ImageIO;
  16. import javax.swing.*;
  17. import javax.swing.border.TitledBorder;
  18. import java.awt.*;
  19. import java.awt.event.ActionEvent;
  20. import java.awt.event.ActionListener;
  21. import java.awt.image.BufferedImage;
  22. import java.io.IOException;
  23. import java.net.MalformedURLException;
  24. import java.net.URL;
  25. import java.text.NumberFormat;
  26. import java.util.ArrayList;
  27.  
  28.  
  29. public class MonkfishFrenzy extends Script implements PaintEventListener, ServerMessageListener, ActionListener {
  30.  
  31. private int[] invAntipot = new int[ ] {175, 177, 179};
  32. private int coins = 995;
  33. private int[] whirlpools = new int[ ] { 403, 404, 406, 406};
  34. private int npcSpots = 3848;
  35. private int npcArnold = 3824;
  36. private int net = 303;
  37. private int randomRunValue = 45;
  38. private Tile[] toDock = new Tile[] {
  39. new Tile(2333, 3692), new Tile(2337, 3693), new Tile(2339, 3697),
  40. new Tile(2340, 3798), new Tile(2346, 3799)};
  41. private Tile[] toBank = walking.reversePath( toDock );
  42. private Tile bankTile = new Tile(2330, 3689 );
  43. private Tile lumby = new Tile(3223, 3218);
  44. private volatile int catches = 0;
  45. private int antiBanActive = 0;
  46. private State state;
  47. private boolean poisoned = false;
  48. private int cured = 0;
  49. private int checkTime;
  50. private KTimer time;
  51. private long lastCheck;
  52. private int startLevel;
  53. private int startExp;
  54. private int whirlpoolsAvoided;
  55. private int oldLevels;
  56. private int countToNext = 0;
  57. private int avoidedCombat;
  58. private int index = skills.SKILL_FISHING;
  59. private int stats = game.TAB_STATS;
  60. private String status = "Starting Up!";
  61. KTimer breakTimer = new KTimer(random(3600000, 12000000));
  62. boolean breaking = false;
  63. private int monkPrice;
  64. private long fishHour, profitHour, expHour = 0;
  65. private int xpPerCatch = 120;
  66. NumberFormat nf = NumberFormat.getInstance();
  67. public boolean useBreaks = true;
  68. public boolean useAntiBan = true;
  69. public boolean hidePaint = true;
  70. public int antiBanLevel = 1;
  71. public String[] aBOptions = {"1", "2", "3"};
  72. public JFrame frame;
  73.  
  74.  
  75.  
  76.  
  77. private boolean debug = false;
  78.  
  79. public void createAndShowGUI() {
  80. //Create and set up the window.
  81. frame = new JFrame("Monkfish Frenzy By The Bru Crew");
  82. final JLabel antiBanInfo = new JLabel("Select Your AntiBan Activity", null, JLabel.CENTER);
  83. final JLabel antiBanInfo2 = new JLabel("1, Lowest, 3 Highest", null, JLabel.CENTER);
  84. final JComboBox antiBanOptions = new JComboBox(aBOptions);
  85. JCheckBox antiBan = new JCheckBox("Use AntiBan");
  86. JPanel breakPanel = new JPanel(new BorderLayout());
  87. JCheckBox breaks = new JCheckBox("Use Breaks");
  88. JPanel antiBanPanel = new JPanel(new BorderLayout());
  89. JPanel innerAntiBan = new JPanel(new BorderLayout());
  90. JPanel paintPanel = new JPanel(new BorderLayout());
  91. JCheckBox paint = new JCheckBox("Hide Paint");
  92. JButton startScript = new JButton("Update & Start Fishin!");
  93. JLabel mainLabel = new JLabel("Monkfish Frenzy Settings", null, JLabel.CENTER);
  94.  
  95. frame.setLocationRelativeTo(null);
  96.  
  97. ActionListener paintListener = new ActionListener() {
  98. public void actionPerformed(ActionEvent actionEvent) {
  99. AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
  100. hidePaint = abstractButton.getModel().isSelected();
  101. }
  102. };
  103.  
  104. ActionListener breakListener = new ActionListener() {
  105. public void actionPerformed(ActionEvent actionEvent) {
  106. AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
  107. useBreaks = abstractButton.getModel().isSelected();
  108. }
  109. };
  110. ActionListener startListener = new ActionListener() {
  111. public void actionPerformed(ActionEvent actionEvent) {
  112. if ("enable".equals(actionEvent.getActionCommand()))
  113. sleep(random(500,750));
  114. frame.setVisible(false);
  115. }
  116. };
  117.  
  118. TitledBorder breakTitle;
  119. breakTitle = BorderFactory.createTitledBorder("Use Breaks");
  120. breakPanel.setBorder(breakTitle);
  121. breaks.setToolTipText("Periodically Use Breaks?");
  122. breaks.addActionListener(breakListener);
  123. breaks.setSelected(true);
  124. breakPanel.add(breaks);
  125. frame.add(breakPanel, BorderLayout.LINE_START);
  126.  
  127. TitledBorder antiBanTitle = BorderFactory.createTitledBorder("Use AntiBan");
  128. antiBanPanel.setBorder(antiBanTitle);
  129.  
  130. ActionListener antiBanListener = new ActionListener() {
  131. public void actionPerformed(ActionEvent actionEvent) {
  132. AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
  133. useAntiBan = abstractButton.getModel().isSelected();
  134. if (!abstractButton.getModel().isSelected()) {
  135. antiBanOptions.setEnabled(false);
  136. antiBanInfo.setVisible(false);
  137. antiBanInfo2.setVisible(false);
  138.  
  139. } else {
  140. antiBanOptions.setEnabled(true);
  141. antiBanInfo.setVisible(true);
  142. antiBanInfo2.setVisible(true);
  143. }
  144. }
  145. };
  146.  
  147.  
  148.  
  149. antiBan.addActionListener(antiBanListener);
  150.  
  151. antiBan.setSelected(true);
  152. antiBan.setToolTipText("Use AntiBan?");
  153. innerAntiBan.add(antiBan, BorderLayout.LINE_END);
  154. antiBanOptions.setPreferredSize(new Dimension(50, 10));
  155. antiBanOptions.setSelectedIndex(0);
  156. antiBanOptions.addActionListener(this);
  157. antiBanOptions.setToolTipText("Select your Anti-Ban Activity Level!");
  158.  
  159. antiBanPanel.add(antiBanInfo, BorderLayout.CENTER);
  160. antiBanPanel.add(antiBanInfo2, BorderLayout.PAGE_END);
  161. innerAntiBan.add(antiBanOptions, BorderLayout.LINE_START);
  162. antiBanPanel.add(innerAntiBan, BorderLayout.PAGE_START);
  163. frame.add(antiBanPanel, BorderLayout.CENTER);
  164.  
  165.  
  166. TitledBorder paintTitle = BorderFactory.createTitledBorder("Hide Paint");
  167. paintPanel.setBorder(paintTitle);
  168. paint.setToolTipText("Hide Paint on Mouse Over");
  169. paint.addActionListener(paintListener);
  170. paint.setSelected(true);
  171. paintPanel.add(paint);
  172. frame.add(paintPanel, BorderLayout.LINE_END);
  173.  
  174. startScript.setToolTipText("Jump on them Monkies!");
  175. startScript.setHorizontalTextPosition(AbstractButton.CENTER);
  176. startScript.addActionListener(startListener);
  177. startScript.setActionCommand("enable");
  178. frame.add(startScript, BorderLayout.PAGE_END);
  179.  
  180. mainLabel.setHorizontalTextPosition(JLabel.CENTER);
  181. frame.add(mainLabel, BorderLayout.PAGE_START);
  182.  
  183. //Display the window.
  184. frame.pack();
  185. frame.setVisible(true);
  186. }
  187. public void actionPerformed(ActionEvent e) {
  188. JComboBox cb = (JComboBox)e.getSource();
  189. String antiBanLevelString = (String) cb.getSelectedItem();
  190. antiBanLevel = Integer.parseInt(antiBanLevelString);
  191. }
  192.  
  193.  
  194.  
  195. public void takeBreak() {
  196. //long breakedtime = 0;
  197. if(useBreaks){
  198. if (breakTimer.isDone() && !breaking) {
  199.  
  200. breaking = true;
  201. enableRandom(false, "AutoLogin");
  202. game.exitToLogin();
  203. //breakedtime = time.getTimeElapsed();
  204. breakTimer.addTime(random(2000000, 450000));
  205.  
  206.  
  207. } else if (breakTimer.isDone() && breaking) {
  208. //time.reset();
  209. //time.addTime(breakedtime);
  210. breaking = false;
  211. enableRandom(true, "AutoLogin");
  212. breakTimer.addTime(random(7200000, 10800000));
  213.  
  214. }
  215. }
  216.  
  217. }
  218.  
  219. @Override
  220. public void stop() {
  221. frame.setVisible(false);
  222. }
  223.  
  224. @Override
  225. public String getName( ) {
  226. return( "Monkfish Frenzy" );
  227. }
  228.  
  229. public void debug(String s) {
  230. if(debug)
  231. log.log(s);
  232. }
  233.  
  234. @Override
  235. public void onStart() {
  236. setUserInputEnabled(false);
  237. monkPrice = new GrandExchangeLookup(7944).getMarketPrice();
  238. time = new KTimer();
  239. status = "Starting Up";
  240. mouse.setDefaultSpeed(1.4);
  241. status = "Creating GUI";
  242. createAndShowGUI();
  243.  
  244.  
  245. }
  246.  
  247.  
  248. NPC spot = null;
  249. @Override
  250. public void registerWorkers() {
  251. createWorker(new Looped() {
  252. public int loop() {
  253. takeBreak();
  254. if (!breaking && game.isLoggedIn()) {
  255. state = getState();
  256. switch(state){
  257. case Setup:
  258. if ( game.getRunningEnergy() >= randomRunValue && !isRunning()) {
  259. status = "Setting run.";
  260. walking.setRunning( true );
  261. randomRunValue = random(45, 65);
  262. break;
  263. }
  264. if (inventory.contains(coins)) {
  265. if(inventory.getCount(true, coins) <= 500) {
  266. inventory.atItem(coins, "drop");
  267. status = "Dropped Coins less than 500";
  268. break;
  269. }
  270. }
  271. break;
  272. case InCombat:
  273. status = "Getting Out Of Combat";
  274. runAway();
  275. break;
  276. case Fishing:
  277. status = "Fishing";
  278. GroundItem itemTile = groundItems.getClosestItem( net );
  279. if(itemTile != null){
  280. if ( itemTile.onScreen()) {
  281. log("Recovered gear.");
  282. itemTile.doAction("Take");
  283. sleep(random(750, 900));
  284. } else if(!getMyPlayer().isMoving()) {
  285. log("Walking to gear location.");
  286. walking.walkToMM(itemTile.getLocation());
  287. sleep(random(1700, 1900));
  288. }
  289. break;
  290. }
  291. spot = getClosestNPC(25, spot, npcSpots);
  292. if(spot != null) {
  293. if(spot.onScreen() && !inventory.isFull()){
  294. spot.doAction("Net");
  295. sleep(random(500, 750));
  296. while(getMyPlayer().isMoving())
  297. sleep(random(2000, 2500));
  298. break;
  299. } else if(!getMyPlayer().isMoving()) {
  300. walking.walkToMM(spot.getLocation().randomizeTile(3, 3));
  301. sleep(random(700, 900));
  302. break;
  303. }
  304. break;
  305. } else {
  306. try{
  307. walkLocalPath(toDock, 2, 2, random(5,10));
  308. sleep(random(700,900));
  309. }catch(Exception e){
  310. log("Exception Thrown");
  311. }
  312. }
  313. break;
  314. case Banking:
  315. status = "Banking";
  316. if(bank.isOpen()){
  317. bank.depositAllExcept(net);
  318. if(!inventory.contains(net)){
  319. log("Withdrawing Small Fishing Net");
  320. bank.withdrawX(net, 1);
  321. break;
  322. }
  323. bank.close();
  324. break;
  325. }
  326. NPC arnold = npcs.getClosest(40, npcArnold);
  327. if (arnold != null) {
  328. if(arnold.onScreen()) {
  329. arnold.doAction("Bank");
  330. sleep(random(750, 900));
  331. } else if(distanceTo(bankTile) <= 10) {
  332. if(!getMyPlayer().isMoving()) {
  333. walking.walkToMM(bankTile.randomizeTile(2, 2));
  334. sleep(random(700, 900));
  335. }
  336. } else if(distanceTo(bankTile) > 10) {
  337. try {
  338. walkLocalPath(toBank, 2, 2, random(5,10));
  339. sleep(random(700, 900));
  340. }catch(Exception e){
  341. log("Exception Thrown");
  342. }
  343. }
  344. } else {
  345. try {
  346. walkLocalPath(toBank, 2, 2, random(5,10));
  347. sleep(random(1700,1900));
  348. }catch(Exception e){
  349. log("Exception Thrown");
  350. }
  351. }
  352. break;
  353. case Poisoned:
  354. status = "Poisoned";
  355. if(!inventory.contains(invAntipot)) {
  356. if(bank.isOpen()){
  357. bank.depositAllExcept(net);
  358. sleep(random(500,750));
  359. if(bank.contains(175)) {
  360. bank.withdrawX(175, 1); }
  361. else if(bank.contains(177)) {
  362. bank.withdrawX(177, 1);
  363. } else if(bank.contains(179)) {
  364. bank.withdrawX(179, 1);
  365. }
  366. bank.close();
  367. break;
  368. }
  369. NPC arnoldPoison = npcs.getClosest(40, npcArnold);
  370. if (arnoldPoison != null) {
  371. if(arnoldPoison.onScreen()) {
  372. arnoldPoison.doAction("Bank");
  373. sleep(random(750, 900));
  374. } else if(distanceTo(bankTile) <= 10) {
  375. walking.walkToMM(bankTile.randomizeTile(2, 2));
  376. sleep(random(1700, 1900));
  377. } else if(distanceTo(bankTile) > 10) {
  378. try {
  379. walkLocalPath(toBank, 2, 2, random(5,10));
  380. sleep(random(1700,1900));
  381. }catch(Exception e){
  382. log("Exception Thrown");
  383. }
  384. }
  385. } else {
  386. try {
  387. walkLocalPath(toBank, 2, 2, random(5,10));
  388. sleep(random(1700,1900));
  389. }catch(Exception e){
  390. log("Exception Thrown");
  391. }
  392. }
  393. } else {
  394. for(int i=0; i<3; i++) {
  395. if ( poisoned && inventory.atItem(invAntipot[i], "Drink") ) {
  396. log("Drunk part of anti-pot.");
  397. cured++;
  398. poisoned = false;
  399. break;
  400. }
  401. }
  402. }
  403. break;
  404. case Busy:
  405. NPC whirl = npcs.getClosest(25, whirlpools );
  406. if ( whirl != null && distanceTo(whirl.getLocation( )) <= 2 && getMyPlayer().getInteracting() == whirl ) {
  407. status = "Avoiding whirlpool.";
  408. log("Avoiding whirlpool");
  409. walking.walkToMM(new Tile (getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY() - 2));
  410. sleep(random(1000,1500));
  411. whirlpoolsAvoided++;
  412. break;
  413. }
  414. return antiBan();
  415. case Dead:
  416. log.logImportant("In Lumby, Stopping All Scripts.");
  417. stopAllScripts();
  418. default:
  419. return random(1300, 1800);
  420. }
  421. }
  422. return random(1000, 1750);
  423. }
  424. });
  425. }
  426.  
  427. public String getAuthor( ) {
  428. return( "The Bru Crew" );
  429. }
  430.  
  431. public double getVersion( ) {
  432. return( 3.0 );
  433. }
  434.  
  435. private int antiBan() {
  436. int gamble = 1;
  437. KTimer countDownTimer = new KTimer(random(60000, 180000));
  438. if(useAntiBan == true) {
  439. if(antiBanLevel == 1)
  440. gamble = random(1, 300);
  441. else if(antiBanLevel == 2)
  442. gamble = random(1, 200);
  443. else if(antiBanLevel == 3)
  444. gamble = random(1, 100);
  445. switch (gamble) {
  446. case 1:
  447. return random(500, 750);
  448.  
  449. case 2:
  450. int x = random(0, 750);
  451. int y = random(0, 500);
  452. mouse.moveMouse(x, y);
  453. antiBanActive++;
  454. return random(500, 750);
  455. case 3:
  456. if (game.getCurrentTab() != game.TAB_INVENTORY) {
  457. game.openTab(game.TAB_INVENTORY);
  458. }
  459. return random(500, 700);
  460. case 4:
  461. if (getMyPlayer().isMoving()) {
  462. return random(750, 1000);
  463. }
  464.  
  465. if (countDownTimer.isDone()) {
  466. countDownTimer = new KTimer(random(60000, 180000));
  467.  
  468. if (game.getCurrentTab() != stats) {
  469. game.openTab(stats);
  470. }
  471. mouse.moveMouse(random(674, 733), random(266, 292));
  472. antiBanActive++;
  473. sleep(random(5000, 8000));
  474. if (game.getCurrentTab() != game.TAB_INVENTORY) {
  475. game.openTab(game.TAB_INVENTORY);
  476. }
  477. return random(250, 500);
  478. }
  479.  
  480.  
  481. case 5:
  482. if (random(1, 8) == 2) {
  483. double angle = camera.getAngle() + random(-90, 90);
  484. if (angle < 0) {
  485. angle = 0;
  486. }
  487. if (angle > 359) {
  488. angle = 0;
  489. }
  490. int rotateAngle = (int) angle;
  491. antiBanActive++;
  492. camera.setAngle(rotateAngle);
  493. }
  494.  
  495. return random(500, 750);
  496. }
  497. }
  498. debug("Anti-Ban Used: " + antiBanActive + " Times.");
  499. return random(500, 750);
  500. }
  501.  
  502. public void onRepaint( Graphics g ) {
  503. int exp = 0;
  504. int levels;
  505. int mouse_x = (int) mouse.getMousePos().getX();
  506. int mouse_y = (int) mouse.getMousePos().getY();
  507. int fishingLevel = skills.getCurrentLevel(index);
  508. Color White = new Color(255, 255, 255, 200);
  509. int percentToLevel = (int) skills.getPercToNextLevel(index);
  510. levels = fishingLevel - startLevel;
  511. if(!breaking) {
  512. exp = skills.getExperience(index) - startExp;
  513. }
  514. if ( startLevel == 0 || startExp == 0 ) {
  515. startLevel = skills.getCurrentLevel(index);
  516. startExp = skills.getExperience(index);
  517. }
  518. countToNext = (skills.getExperienceToNextLevel(index) / xpPerCatch) + 1;
  519. if (levels > oldLevels) {
  520. oldLevels = levels;
  521. }
  522. g.setColor(White);
  523. if(!(mouse_x > 0 && mouse_x < 240 && mouse_y < 337 && mouse_y > 180) || !hidePaint || breaking) {
  524. g.drawString(getName( ) + " v" + getVersion( ) + " By: " + getAuthor(), 9, 205);
  525. g.drawString("Currently: " + status, 9, 221);
  526. g.drawString("Current Fishing Level: " + fishingLevel + " | Percent To Next: " + percentToLevel, 9, 237);
  527. g.drawString("XP Gained: " + nf.format(exp) + " | Per hour: " + nf.format(expHour), 9, 253);
  528. g.drawString("Catches: " + nf.format(catches) + " | Per hour: " + nf.format(fishHour), 9, 269);
  529. g.drawString("Profit: " + nf.format(catches * monkPrice) + " | Per hour: " + nf.format(profitHour), 9, 285);
  530. g.drawString("Catches to next level: " + nf.format(countToNext), 9, 301);
  531. g.drawString("Time running: " + time.getFormattedTime(time.getTimeElapsed()), 9, 317);
  532. g.drawString(breakText() , 9, 333);
  533. }
  534. }
  535. public String breakText() {
  536. String textTime, text;
  537. if(breaking) {
  538. text = "Resuming in: ";
  539. } else {
  540. text = "Next Break In: ";
  541. }
  542. if(useBreaks) {
  543. textTime = breakTimer.getFormattedTime(breakTimer.getTimeRemaining());
  544. }
  545. else {
  546. textTime = "Not Breaking";
  547. return textTime;
  548. }
  549. return text + textTime;
  550. }
  551.  
  552. public void onServerMessage(String e) {
  553. if ( e.contains("poisoned") && !poisoned) {
  554. log("Poisoned!");
  555. poisoned = true;
  556. }
  557. if ( e.contains("catch a monkfish")){
  558. catches++;
  559. fishHour = (((long)catches * 1000L * 60L * 60L)) / (time.getTimeElapsed());
  560. profitHour = fishHour*monkPrice;
  561. expHour = fishHour*xpPerCatch;
  562. }
  563. }
  564.  
  565. public void runAway() {
  566. Tile foo, foo2;
  567. foo = getMyPlayer().getLocation();
  568. walking.setRunning(true);
  569. foo2 = new Tile(foo.getX() + random(8, 10), foo.getY()
  570. + random(8, 10));
  571.  
  572. walking.walkToMM(foo2);
  573. sleep(random(2000, 4000));
  574. walking.walkToMM(foo);
  575. avoidedCombat++;
  576. }
  577.  
  578. private State getState() {
  579. IComponent fullfish = interfaces.getComponent(210,1);
  580. if(distanceTo(lumby) < 40 )
  581. return State.Dead;
  582. if(getMyPlayer().isInCombat()){
  583. return State.InCombat;
  584. }
  585. if(poisoned) {
  586. return State.Poisoned;
  587. }
  588. if(fullfish != null) {
  589. if (fullfish.textContainsIgnoreCase("carry any")) {
  590. game.openTab(game.TAB_INVENTORY);
  591. return State.Banking;
  592. }
  593. }
  594. if ( inventory.getCount(false, net) < 1 ) {
  595. return State.Banking;
  596. }
  597. if( inventory.isFull())
  598. return State.Banking;
  599. if((inventory.getCount(true, coins) > 0 && inventory.getCount(true, coins) <= 500) || (game.getRunningEnergy() >= randomRunValue && !isRunning())) {
  600. return State.Setup;
  601. }
  602. if(getMyPlayer().getAnimation() != -1) {
  603. return State.Busy;
  604. }
  605. return State.Fishing;
  606. }
  607.  
  608. private enum State {
  609. InCombat, Fishing, Banking, Poisoned, Busy, Dead, Setup
  610. }
  611.  
  612. private boolean isRunning() {
  613. return (interfaces.getComponent(750, 3) != null && interfaces.getComponent(750, 3).getTextureID() == 783);
  614. }
  615.  
  616. private NPC getClosestNPC(int range, NPC exclude, int... IDs) {
  617. if (!isLoggedIn()) {
  618. return null;
  619. }
  620. if (exclude == null) {
  621. return npcs.getClosest(range, IDs);
  622. }
  623.  
  624. final int excludeId = exclude.getID();
  625. final Tile excludeLoc = exclude.getLocation();
  626.  
  627. final Tile myPos = botEnv.players.getMyPlayer().getLocation();
  628. int minX = myPos.getX() - range;
  629. int minY = myPos.getY() - range;
  630. int maxX = myPos.getX() + range;
  631. int maxY = myPos.getY() + range;
  632. java.util.List<NPC> objList = new ArrayList<NPC>();
  633. for (NPC n : npcs.getNPCs()) {
  634. if (n.getLocation().equals(excludeLoc))
  635. continue;
  636. if (n.getLocation().getX() < 2323)
  637. continue;
  638. if (!ArrayUtils.contains(IDs, n.getID()))
  639. continue;
  640.  
  641. objList.add(n);
  642. }
  643. if (objList.isEmpty())
  644. return null;
  645. double closest = 9999;
  646. NPC closestNPC = null;
  647. for (NPC n : objList) {
  648. double distance = myPos.distanceToPrecise(n.getLocation());
  649. if (distance < closest) {
  650. closest = distance;
  651. closestNPC = n;
  652. }
  653. }
  654. return closestNPC;
  655. }
  656. public boolean walkLocalPath(Tile[] tiles, final int randX, final int randY, final int flag) {
  657.  
  658. Tile destination = (tiles[tiles.length - 1]);
  659. debug("WalkLocalPath: "+destination.toString()+" | on MM: " + calculations.tileToMinimap(destination));
  660. boolean finished = false;
  661. while (!finished) {
  662. finished = walking.walkToMM(destination);
  663. sleep(random(800, 1200));
  664. if (players.getMyPlayer().isMoving()) {
  665. final Tile dest = walking.getDestination();
  666. if (dest != null)
  667. if (((int) players.getMyPlayer().distanceTo(dest)) > flag) {
  668. continue;
  669. }
  670. }
  671.  
  672. Tile[] mutable = tiles;
  673. ArrayUtils.reverse(mutable);
  674.  
  675. for (Tile t: mutable){
  676. debug(""+finished);
  677. if(finished)
  678. break;
  679. finished = walking.walkToMM(t);
  680. }
  681.  
  682. }
  683.  
  684. return finished;
  685. }
  686.  
  687. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement