Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.06 KB | None | 0 0
  1. package scripts.runecrafting.abysscrafter;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6.  
  7. import org.tribot.api.General;
  8. import org.tribot.api.Timing;
  9. import org.tribot.api.input.Mouse;
  10. import org.tribot.api.util.ABCUtil;
  11. import org.tribot.api2007.Camera;
  12. import org.tribot.api2007.Combat;
  13. import org.tribot.api2007.Game;
  14. import org.tribot.api2007.GameTab;
  15. import org.tribot.api2007.Interfaces;
  16. import org.tribot.api2007.Inventory;
  17. import org.tribot.api2007.NPCChat;
  18. import org.tribot.api2007.Options;
  19. import org.tribot.api2007.Player;
  20. import org.tribot.api2007.Skills;
  21. import org.tribot.api2007.Walking;
  22. import org.tribot.api2007.WebWalking;
  23. import org.tribot.api2007.Skills.SKILLS;
  24. import org.tribot.api2007.types.RSCharacter;
  25. import org.tribot.api2007.types.RSItem;
  26. import org.tribot.api2007.types.RSNPC;
  27. import org.tribot.api2007.util.DPathNavigator;
  28. import org.tribot.script.EnumScript;
  29. import org.tribot.script.ScriptManifest;
  30. import org.tribot.script.interfaces.Painting;
  31.  
  32. import scripts.methods.Methods;
  33.  
  34. @ScriptManifest(authors = { "iant06" }, category = "Runecrafting", name = "iAbyss Runecrafter")
  35.  
  36. public class Main extends EnumScript<State> implements Painting {
  37.  
  38. private Bank bank;
  39. private Ditch ditch;
  40. private House house;
  41. private Obstacles obstacles;
  42. private Runecrafting runecrafting;
  43. private State state;
  44. private Rune rune;
  45. private AbyssGUI gui;
  46. private Orientation orientation;
  47.  
  48. private DPathNavigator pathNavigator = new DPathNavigator();
  49.  
  50. private boolean endScript = false;
  51.  
  52. private int foodId = -1;
  53.  
  54. private int healAmount = 0;
  55.  
  56. private int natPrice = 0;
  57.  
  58. private int essPrice = 0;
  59.  
  60. private int lobsterPrice = 0;
  61.  
  62. private int natsCrafted = 0;
  63.  
  64. private int moneySpent = 0;
  65.  
  66. private int tabPrice = 0;
  67.  
  68. private int emergencyTeleports = 0;
  69.  
  70. private int lobstersEaten = 0;
  71.  
  72. private int startLevel = 0;
  73.  
  74. private int startXp = 0;
  75.  
  76. public int getCurrentXP() {
  77. return Skills.getXP(SKILLS.RUNECRAFTING);
  78. }
  79.  
  80. public int getActualLevel() {
  81. return Skills.getLevelByXP(getCurrentXP());
  82. }
  83.  
  84. @Override
  85. public State getInitialState() {
  86. if(gui == null) {
  87. setGui(new AbyssGUI(this));
  88. while(getGui().isVisible()) {
  89. sleep(50, 100);
  90. }
  91. }
  92. if(bank == null) {
  93. setBank(new Bank(this));
  94. }
  95. if(ditch == null) {
  96. setDitch(new Ditch(this));
  97. }
  98. if(house == null) {
  99. setHouse(new House(this));
  100. }
  101. if(obstacles == null) {
  102. setObstacles(new Obstacles(this));
  103. }
  104. if(runecrafting == null) {
  105. setRunecrafting(new Runecrafting(this));
  106. }
  107. Walking.setWalkingTimeout(2000);
  108. Mouse.setSpeed(130 + General.random(0, 10));
  109. if(getRunecrafting().isAtRift() || Locations.isInsideInnerRing()) {
  110. if(pouchNeedsRepair()) {
  111. return State.REPAIRING_POUCH;
  112. }
  113. return State.ENTERING_RIFT;
  114. }
  115. if(getHouse().isInside() || getHouse().isOutside()) {
  116. return State.TELEPORTING_TO_EDGEVILLE;
  117. }
  118. if(Locations.isInsideAltar()) {
  119. return State.CRAFTING_RUNES;
  120. }
  121. if(Locations.isAtZamorakMage()) {
  122. return State.TELEPORTING_TO_ABYSS;
  123. }
  124. return State.BANKING;
  125. }
  126.  
  127. public boolean toggleAutoRetaliate() {
  128. if(GameTab.getOpen() != GameTab.TABS.COMBAT) {
  129. GameTab.open(GameTab.TABS.COMBAT);
  130. }
  131. return Interfaces.get(593, 27).click("Auto retaliate");
  132. }
  133.  
  134. @Override
  135. public State handleState(State state) {
  136. if(isEndScript()) {
  137. Thread.currentThread().interrupt();
  138. return null;
  139. }
  140. if(!isOnBreak() && !isPaused()) {
  141. state = getState() != null ? getState() : getInitialState();
  142. if(Combat.isAutoRetaliateOn()) {
  143. toggleAutoRetaliate();
  144. sleep(400, 800);
  145. }
  146. if(getHouse().isOutside()) {
  147. getHouse().enterHouse();
  148. sleep(500, 1000);
  149. }
  150. switch(state) {
  151.  
  152. case BANKING:
  153. getDitch().clickedDitch = false;
  154. if(!Locations.isInsideBank()) {
  155. if(!Player.isMoving() || !Locations.BANK_AREA.contains(Game.getDestination()))
  156. WebWalking.walkToBank();
  157. return State.BANKING;
  158. }
  159. if(!getBanking().performedBankTasks()) {
  160. getBanking().attemptBankTasks();
  161. setState(State.BANKING);
  162. return State.BANKING;
  163. } else {
  164. getBanking().filledPouches = false;
  165. setState(State.TELEPORTING_TO_ABYSS);
  166. return State.TELEPORTING_TO_ABYSS;
  167. }
  168.  
  169. case TELEPORTING_TO_ABYSS:
  170. getDitch().clickedDitch = false;
  171. if(Combat.getAttackingEntities() != null && Combat.getAttackingEntities().length > 0) {
  172. for(int i = 0; i < Combat.getAttackingEntities().length; i++) {
  173. if(Combat.getAttackingEntities()[i] instanceof RSCharacter) {
  174. int teles = getEmergencyTeleports();
  175. setEmergencyTeleports(teles + 1);
  176. setState(State.TELEPORTING_TO_HOUSE);
  177. return State.TELEPORTING_TO_HOUSE;
  178. }
  179. }
  180. }
  181. if(getObstacles().isHealthLow()) {
  182. int teles = getEmergencyTeleports();
  183. setEmergencyTeleports(teles + 1);
  184. setState(State.TELEPORTING_TO_HOUSE);
  185. return State.TELEPORTING_TO_HOUSE;
  186. }
  187. if(getObstacles().getMonsterDistance() <= 3) {
  188. setState(State.PASSING_OBSTACLE);
  189. return State.PASSING_OBSTACLE;
  190. }
  191. if(Player.getPosition().getY() < Locations.DITCH_TILE.getY() - 8) {
  192. WebWalking.walkTo(Locations.DITCH_TILE);
  193. if(!turnedCamera) {
  194. Methods.turnCameraNorth();
  195. turnedCamera = true;
  196. }
  197. return State.TELEPORTING_TO_ABYSS;
  198. }
  199. if(Player.getPosition().getY() <= Locations.DITCH_TILE.getY()) {
  200. if(getDitch().cross()) {
  201. if(Game.getRunEnergy() > abc.INT_TRACKER.NEXT_RUN_AT.next()) {
  202. Options.setRunOn(true);
  203. abc.INT_TRACKER.NEXT_RUN_AT.reset();
  204. }
  205. return State.TELEPORTING_TO_ABYSS;
  206. }
  207. }
  208. if(Player.getPosition().getY() > Locations.DITCH_TILE.getY()) {
  209. if(!Locations.isAtZamorakMage()) {
  210. //Methods.performAntiBan();
  211. if(Game.getRunEnergy() > abc.INT_TRACKER.NEXT_RUN_AT.next()) {
  212. Options.setRunOn(true);
  213. abc.INT_TRACKER.NEXT_RUN_AT.reset();
  214. }
  215. WebWalking.walkTo(Locations.ZAMORAK_MAGE_TILE);
  216. return State.TELEPORTING_TO_ABYSS;
  217. }
  218. if(mageTeleport()) {
  219. setState(State.PASSING_OBSTACLE);
  220. return State.PASSING_OBSTACLE;
  221. }
  222. }
  223. return State.TELEPORTING_TO_ABYSS;
  224.  
  225. case PASSING_OBSTACLE:
  226.  
  227. if(Locations.isInsideInnerRing() && getObstacles().getMonsterDistance() > 2) {
  228. if(pouchNeedsRepair()) {
  229. setState(State.REPAIRING_POUCH);
  230. return State.REPAIRING_POUCH;
  231. } else {
  232. setState(State.ENTERING_RIFT);
  233. return State.ENTERING_RIFT;
  234. }
  235. }
  236. if(getObstacles().isHealthLow()) {
  237. int teles = getEmergencyTeleports();
  238. setEmergencyTeleports(teles + 1);
  239. setState(State.TELEPORTING_TO_HOUSE);
  240. return State.TELEPORTING_TO_HOUSE;
  241. }
  242. if(getObstacles().getObstacle() == null) {
  243. getObstacles().findClosest();
  244. }
  245. if(getObstacles().getObstacle() != null) {
  246. if(Locations.isInsideInnerRing() && getObstacles().getMonsterDistance() > 2) {
  247. if(pouchNeedsRepair()) {
  248. setState(State.REPAIRING_POUCH);
  249. return State.REPAIRING_POUCH;
  250. } else {
  251. setState(State.ENTERING_RIFT);
  252. return State.ENTERING_RIFT;
  253. }
  254. }
  255. if(!setRun) {
  256. setRun = true;
  257. if(General.random(0, 1) == 1) {
  258. Options.setRunOn(true);
  259. }
  260. }
  261. if(getObstacles().passObstacle()) {
  262. if(getObstacles().getMonsterDistance() > 2) {
  263. if(pouchNeedsRepair()) {
  264. setState(State.REPAIRING_POUCH);
  265. return State.REPAIRING_POUCH;
  266. } else {
  267. setState(State.ENTERING_RIFT);
  268. return State.ENTERING_RIFT;
  269. }
  270. }
  271. }
  272. if(Locations.isInsideInnerRing() && getObstacles().getMonsterDistance() > 2) {
  273. if(pouchNeedsRepair()) {
  274. setState(State.REPAIRING_POUCH);
  275. return State.REPAIRING_POUCH;
  276. } else {
  277. setState(State.ENTERING_RIFT);
  278. return State.ENTERING_RIFT;
  279. }
  280. }
  281. }
  282. setState(State.PASSING_OBSTACLE);
  283. return State.PASSING_OBSTACLE;
  284.  
  285. case ENTERING_RIFT:
  286. if(Locations.isInsideAltar()) {
  287. setState(State.CRAFTING_RUNES);
  288. return State.CRAFTING_RUNES;
  289. }
  290. if(getRunecrafting().isAtRift()) {
  291. if(getRunecrafting().enterRift()) {
  292. setState(State.CRAFTING_RUNES);
  293. return State.CRAFTING_RUNES;
  294. }
  295. }
  296. if(!getRunecrafting().isAtRift() && !Player.isMoving()) {
  297. if(Game.getDestination() == null) {
  298. Walking.walkPath(getRunecrafting().getRiftPath());
  299. }
  300. if(Game.getDestination() != null && !Game.getDestination().isOnScreen() || !Player.isMoving())
  301. Walking.walkPath(getRunecrafting().getRiftPath());
  302. return State.ENTERING_RIFT;
  303. }
  304. return State.ENTERING_RIFT;
  305.  
  306. case CRAFTING_RUNES:
  307. if(!Locations.isInsideAltar()) {
  308. if(getRunecrafting().isAtRift() || Locations.isInsideInnerRing()) {
  309. setState(State.ENTERING_RIFT);
  310. return State.ENTERING_RIFT;
  311. }
  312. }
  313. if(getRunecrafting().craftRunes()) {
  314. setState(State.TELEPORTING_TO_HOUSE);
  315. return State.TELEPORTING_TO_HOUSE;
  316. }
  317. return State.CRAFTING_RUNES;
  318.  
  319. case TELEPORTING_TO_HOUSE:
  320. if(getHouse().isInside()) {
  321. turnedCamera = false;
  322. setRun = false;
  323. getDitch().clickedDitch = false;
  324. setState(State.TELEPORTING_TO_EDGEVILLE);
  325. return State.TELEPORTING_TO_EDGEVILLE;
  326. }
  327. teleportHome();
  328. return State.TELEPORTING_TO_HOUSE;
  329.  
  330. case TELEPORTING_TO_EDGEVILLE:
  331. if(Locations.isAtEdgeville()) {
  332. setState(State.BANKING);
  333. return State.BANKING;
  334. }
  335. if(getHouse().isOutside()) {
  336. getHouse().enterHouse();
  337. return State.TELEPORTING_TO_EDGEVILLE;
  338. }
  339. getHouse().rubGlory();
  340. return State.TELEPORTING_TO_EDGEVILLE;
  341.  
  342. case REPAIRING_POUCH:
  343. if(!pouchNeedsRepair()) {
  344. setState(State.ENTERING_RIFT);
  345. return State.ENTERING_RIFT;
  346. }
  347. if(!Locations.isAtDarkMage()) {
  348. if(Game.getDestination() == null) {
  349. WebWalking.walkTo(Locations.DARK_MAGE_TILE);
  350. }
  351. if(Game.getDestination() != null && !Game.getDestination().isOnScreen() || !Player.isMoving())
  352. WebWalking.walkTo(Locations.DARK_MAGE_TILE);
  353. return State.REPAIRING_POUCH;
  354. }
  355. if(repairPouch()) {
  356. setState(State.ENTERING_RIFT);
  357. return State.ENTERING_RIFT;
  358. }
  359. return State.REPAIRING_POUCH;
  360.  
  361. case WALKING_TO_DARK_MAGE:
  362. if(!Locations.isAtDarkMage()) {
  363. if(Game.getDestination() == null) {
  364. WebWalking.walkTo(Locations.DARK_MAGE_TILE);
  365. }
  366. if(Game.getDestination() != null && !Game.getDestination().isOnScreen() || !Player.isMoving())
  367. WebWalking.walkTo(Locations.DARK_MAGE_TILE);
  368. return State.REPAIRING_POUCH;
  369. }
  370. return State.WALKING_TO_DARK_MAGE;
  371.  
  372. case GETTING_SMALL_POUCH:
  373. if(hasSmallPouch()) {
  374. setState(State.ENTERING_RIFT);
  375. return State.ENTERING_RIFT;
  376. }
  377. talkToDarkMage();
  378. return State.GETTING_SMALL_POUCH;
  379.  
  380. }
  381. sleep(50, 150);
  382. }
  383. return null;
  384. }
  385.  
  386. public boolean setRun = false;
  387.  
  388. public boolean turnedCamera = false;
  389.  
  390. private boolean talkToDarkMage() {
  391.  
  392. setState(State.GETTING_SMALL_POUCH);
  393.  
  394. if(Inventory.isFull()) {
  395. RSItem[] ess = Inventory.find(Constants.ESSENCE);
  396. if(ess != null && ess.length > 0) {
  397. Inventory.drop(ess[0]);
  398. }
  399. }
  400.  
  401. final int DARK_MAGE = Constants.DARK_MAGE;
  402. RSNPC darkMage = Methods.findNPCByModelPoints(new int[]{DARK_MAGE});
  403.  
  404. if(darkMage != null) {
  405.  
  406. if(!darkMage.isOnScreen()) {
  407. Walking.clickTileMM(darkMage, 0);
  408. }
  409.  
  410. while(NPCChat.getClickContinueInterface() == null) {
  411. darkMage.click("Talk-to");
  412. talkedToDarkMage(3000);
  413. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  414. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  415. }
  416.  
  417. boolean firstOption = true;
  418. for(int i = 0; i < Constants.DARK_MAGE_MESSAGES.length; i++) {
  419.  
  420. if(NPCChat.getMessage() != null) {
  421. while(NPCChat.getMessage() != null && Constants.DARK_MAGE_MESSAGES[i].contains(NPCChat.getMessage())) {
  422. NPCChat.clickContinue(false);
  423. clickedContinue(2000, NPCChat.getMessage());
  424. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  425. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  426. }
  427. }
  428.  
  429. if(NPCChat.getOptions() != null) {
  430. if(firstOption) {
  431. firstOption = false;
  432. NPCChat.selectOption("I need your help with something...", true);
  433. i = 1;
  434. } else {
  435. NPCChat.selectOption("Can I have a new essence pouch?", false);
  436. i = 3;
  437. }
  438. clickedOption(2000);
  439. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  440. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  441. }
  442.  
  443. }
  444.  
  445. if(hasSmallPouch()) {
  446. setState(State.ENTERING_RIFT);
  447. return true;
  448. }
  449. }
  450. return false;
  451. }
  452.  
  453. private boolean clickedOption(int i) {
  454. long t = System.currentTimeMillis();
  455. while (Timing.timeFromMark(t) < i) {
  456. if (NPCChat.getOptions() == null) {
  457. return true;
  458. }
  459. sleep(50, 150);
  460. }
  461. return false;
  462. }
  463.  
  464. private boolean clickedContinue(int i, String message) {
  465. long t = System.currentTimeMillis();
  466. while (Timing.timeFromMark(t) < i) {
  467. if(NPCChat.getMessage() != null) {
  468. if (!NPCChat.getMessage().equals(message)) {
  469. return true;
  470. }
  471. }
  472. sleep(50, 150);
  473. }
  474. return false;
  475. }
  476.  
  477. private boolean talkedToDarkMage(int i) {
  478. long t = System.currentTimeMillis();
  479. while (Timing.timeFromMark(t) < i) {
  480. if(NPCChat.getMessage()!= null) {
  481. if (NPCChat.getMessage().equals(Constants.DARK_MAGE_MESSAGES[0])) {
  482. return true;
  483. }
  484. }
  485. sleep(50, 150);
  486. }
  487. return false;
  488. }
  489.  
  490. private boolean hasSmallPouch() {
  491. RSItem[] smallPouch = Inventory.find(Constants.POUCHES[0]);
  492. if(smallPouch != null && smallPouch.length > 0) {
  493. return true;
  494. }
  495. return false;
  496. }
  497.  
  498. private boolean repairPouch() {
  499. RSNPC darkMage = Methods.findNPCByModelPoints(new int[] { Constants.DARK_MAGE });
  500. if(darkMage != null) {
  501. if(!darkMage.isOnScreen() || Methods.distanceTo(this, darkMage.getPosition()) > 5) {
  502. if(Game.getDestination() == null) {
  503. WebWalking.walkTo(darkMage);
  504. }
  505. if(Game.getDestination() != null && !Game.getDestination().isOnScreen() || !Player.isMoving())
  506. WebWalking.walkTo(darkMage);
  507. Camera.turnToTile(darkMage);
  508. } else {
  509. if(NPCChat.getMessage() == null) {
  510. darkMage.click("Repairs");
  511. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  512. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  513. }
  514. if(talking(2000)) {
  515. boolean firstOption = true;
  516. for(int i = 0; i < Constants.DARK_MAGE_MESSAGE.length; i++) {
  517.  
  518. if(NPCChat.getMessage() != null) {
  519. while(NPCChat.getMessage() != null && Constants.DARK_MAGE_MESSAGE[i].contains(NPCChat.getMessage())) {
  520. NPCChat.clickContinue(true);
  521. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  522. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  523. sleep(50, 250);
  524. }
  525. }
  526.  
  527. if(NPCChat.getOptions() != null) {
  528. if(firstOption) {
  529. firstOption = false;
  530. NPCChat.selectOption("I need your help with something...", true);
  531. i = 1;
  532. } else {
  533. NPCChat.selectOption("Can you repair my pouches?", true);
  534. i = 3;
  535. }
  536. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  537. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  538. }
  539.  
  540. }
  541. }
  542. }
  543.  
  544. } else {
  545. if(Game.getDestination() == null) {
  546. WebWalking.walkTo(Locations.DARK_MAGE_TILE);
  547. }
  548. if(Game.getDestination() != null && !Game.getDestination().isOnScreen() || !Player.isMoving())
  549. WebWalking.walkTo(Locations.DARK_MAGE_TILE);
  550. }
  551. return false;
  552. }
  553.  
  554. private long time = 0L;
  555.  
  556. private ABCUtil abc = new ABCUtil();
  557.  
  558. public boolean tabBroke = false;
  559.  
  560. public void teleportHome() {
  561. RSItem[] tab = Inventory.find(Constants.HOUSE_TAB);
  562. if(tab != null && tab.length > 0 && !tabBroke) {
  563. int tabCount = Inventory.getCount(Constants.HOUSE_TAB);
  564. getObstacles().setObstacle(null);
  565. time = System.currentTimeMillis();
  566. while(Player.getAnimation() != 4069 && !getHouse().isInside() && Inventory.getCount(Constants.HOUSE_TAB) == tabCount) {
  567. if(Locations.isInsideInnerRing()) {
  568. setState(State.ENTERING_RIFT);
  569. break;
  570. }
  571. tab = Inventory.find(Constants.HOUSE_TAB);
  572. if(tab != null && tab.length > 0) {
  573. if(tab[0].click("Break")) {
  574. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  575. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  576. tabBroke = true;
  577. }
  578. }
  579. sleep(500, 1000);
  580. }
  581. }
  582. }
  583.  
  584. public boolean isTimedOut(int i, int j) {
  585. if(System.currentTimeMillis() - time > General.random(i, j)) {
  586. return true;
  587. }
  588. return false;
  589. }
  590.  
  591. public boolean pouchNeedsRepair() {
  592. for(int i = 0; i < Constants.DAMAGED_POUCHES.length; i++) {
  593. if(Inventory.getCount(Constants.DAMAGED_POUCHES) > 0) {
  594. return true;
  595. }
  596. }
  597. return false;
  598. }
  599.  
  600. private boolean mageTeleport() {
  601. //if(Locations.isAtZamorakMage()) {
  602. RSNPC zamorakMage = Methods.findNPCByModelPoints(new int[] { Constants.ZAMORAK_MAGE });
  603. if(zamorakMage != null) {
  604. if(zamorakMage.isOnScreen()) {
  605. if(zamorakMage.click("Teleport")) {
  606. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  607. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  608. if(teleported(5000)) {
  609. return true;
  610. }
  611. }
  612. }
  613. if(!zamorakMage.isOnScreen()) {
  614. //WebWalking.walkTo(zamorakMage);
  615. Camera.turnToTile(zamorakMage);
  616. /*if(Game.getDestination() == null) {
  617. WebWalking.walkTo(zamorakMage);
  618. }
  619. if(Game.getDestination() != null && !Game.getDestination().isOnScreen() || !Player.isMoving())
  620. WebWalking.walkTo(zamorakMage);*/
  621. }
  622. }
  623. //}
  624. return false;
  625. }
  626.  
  627. private boolean teleported(int i) {
  628. long t = System.currentTimeMillis();
  629. while (Timing.timeFromMark(t) < i) {
  630. if(getObstacles().getMonsterDistance() <= 1) {
  631. return true;
  632. }
  633. sleep(50, 150);
  634. }
  635. return false;
  636. }
  637.  
  638. private boolean talking(int i) {
  639. long t = System.currentTimeMillis();
  640. while (Timing.timeFromMark(t) < i) {
  641. if(NPCChat.getMessage() != null) {
  642. return true;
  643. }
  644. sleep(50, 150);
  645. }
  646. return false;
  647. }
  648.  
  649. @Override
  650. public void onPaint(Graphics g) {
  651. int nats = getNatsCrafted();
  652. int natsHr = (int) (nats / ((getRunningTime()) / 3600000D));
  653. double profitHr = (double) (calculateProfit() / ((getRunningTime()) / 3600000D));
  654. int xp = (getCurrentXP() - getStartXp());
  655. int xpHr = (int) (xp / ((getRunningTime()) / 3600000D));
  656. g.setColor(Color.BLACK);
  657. g.setFont(new Font("default", Font.BOLD, 12));
  658. g.drawString("Runes Crafted: " + nats + " (" + natsHr + ")", 290, 358);
  659. g.drawString("Profit: " + Methods.setInMoneyFormat(calculateProfit()) + " (" + Methods.setInMoneyFormat(profitHr) + ")", 290, 358 + 15);
  660. g.drawString("Level: " + getActualLevel() + " (" + (getActualLevel() - getStartLevel()) + ")", 290, 358 + 30);
  661. g.drawString("XP: " + xp + " (" + xpHr + ")", 290, 358 + 45);
  662. g.drawString("Emergency Teleports: " + getEmergencyTeleports(), 290, 358 + 60);
  663. g.drawString("Food Eaten: " + getLobstersEaten(), 290, 358 + 75);
  664. g.drawString("Rune: " + Methods.correctCapitalization(rune.toString()), 290, 358 + 90);
  665. g.drawString("State: " + Methods.correctCapitalization(state.toString()), 290, 358 + 105);
  666. g.drawString("Running for: " + Timing.msToString(getRunningTime()), 290, 358 + 120);
  667. }
  668.  
  669. private double calculateProfit() {
  670. double profit = 0;
  671.  
  672. int natPrice = getNatPrice();
  673. int essPrice = getEssPrice();
  674. int natProfit = natPrice - essPrice;
  675. int natsCrafted = getNatsCrafted();
  676. profit += natProfit * natsCrafted;
  677.  
  678. int lobPrice = getLobsterPrice();
  679. int lobsEaten = getLobstersEaten();
  680. profit -= lobPrice * lobsEaten;
  681.  
  682. return profit;
  683. }
  684.  
  685. public void setState(State state) {
  686. this.state = state;
  687. }
  688.  
  689. public State getState() {
  690. return state;
  691. }
  692.  
  693. public void setEndScript(boolean endScript) {
  694. this.endScript = endScript;
  695. }
  696.  
  697. public boolean isEndScript() {
  698. return endScript;
  699. }
  700.  
  701. public void setBank(Bank bank) {
  702. this.bank = bank;
  703. }
  704.  
  705. public Bank getBanking() {
  706. return bank;
  707. }
  708.  
  709. public void setHouse(House house) {
  710. this.house = house;
  711. }
  712.  
  713. public House getHouse() {
  714. return house;
  715. }
  716.  
  717. public void setObstacles(Obstacles obstacles) {
  718. this.obstacles = obstacles;
  719. }
  720.  
  721. public Obstacles getObstacles() {
  722. return obstacles;
  723. }
  724.  
  725. public void setRunecrafting(Runecrafting runecrafting) {
  726. this.runecrafting = runecrafting;
  727. }
  728.  
  729. public Runecrafting getRunecrafting() {
  730. return runecrafting;
  731. }
  732.  
  733. public Ditch getDitch() {
  734. return ditch;
  735. }
  736.  
  737. public void setDitch(Ditch ditch) {
  738. this.ditch = ditch;
  739. }
  740.  
  741. public void setNatsCrafted(int natsCrafted) {
  742. this.natsCrafted = natsCrafted;
  743. }
  744.  
  745. public int getNatsCrafted() {
  746. return natsCrafted;
  747. }
  748.  
  749. public void setPathNavigator(DPathNavigator pathNavigator) {
  750. this.pathNavigator = pathNavigator;
  751. }
  752.  
  753. public DPathNavigator getPathNavigator() {
  754. return pathNavigator;
  755. }
  756.  
  757. public void setNatPrice(int natPrice) {
  758. this.natPrice = natPrice;
  759. }
  760.  
  761. public int getNatPrice() {
  762. return natPrice;
  763. }
  764.  
  765. public void setEssPrice(int essPrice) {
  766. this.essPrice = essPrice;
  767. }
  768.  
  769. public int getEssPrice() {
  770. return essPrice;
  771. }
  772.  
  773. public void setLobsterPrice(int lobsterPrice) {
  774. this.lobsterPrice = lobsterPrice;
  775. }
  776.  
  777. public int getLobsterPrice() {
  778. return lobsterPrice;
  779. }
  780.  
  781. public void setMoneySpent(int moneySpent) {
  782. this.moneySpent = moneySpent;
  783. }
  784.  
  785. public int getMoneySpent() {
  786. return moneySpent;
  787. }
  788.  
  789. public void setEmergencyTeleports(int emergencyTeleports) {
  790. this.emergencyTeleports = emergencyTeleports;
  791. }
  792.  
  793. public int getEmergencyTeleports() {
  794. return emergencyTeleports;
  795. }
  796.  
  797. public void setLobstersEaten(int lobstersEaten) {
  798. this.lobstersEaten = lobstersEaten;
  799. }
  800.  
  801. public int getLobstersEaten() {
  802. return lobstersEaten;
  803. }
  804.  
  805. public Rune getRune() {
  806. return rune;
  807. }
  808.  
  809. public void setRune(Rune rune) {
  810. this.rune = rune;
  811. }
  812.  
  813. public AbyssGUI getGui() {
  814. return gui;
  815. }
  816.  
  817. public void setGui(AbyssGUI gui) {
  818. this.gui = gui;
  819. }
  820.  
  821. public int getTabPrice() {
  822. return tabPrice;
  823. }
  824.  
  825. public void setTabPrice(int tabPrice) {
  826. this.tabPrice = tabPrice;
  827. }
  828.  
  829. public int getFoodId() {
  830. return foodId;
  831. }
  832.  
  833. public void setFoodId(int foodId) {
  834. this.foodId = foodId;
  835. }
  836.  
  837. public Orientation getOrientation() {
  838. return orientation;
  839. }
  840.  
  841. public void setOrientation(Orientation orientation) {
  842. this.orientation = orientation;
  843. }
  844.  
  845. public int getHealAmount() {
  846. return healAmount;
  847. }
  848.  
  849. public void setHealAmount(int healAmount) {
  850. this.healAmount = healAmount;
  851. }
  852.  
  853. public int getStartLevel() {
  854. return startLevel;
  855. }
  856.  
  857. public void setStartLevel(int startLevel) {
  858. this.startLevel = startLevel;
  859. }
  860.  
  861. public int getStartXp() {
  862. return startXp;
  863. }
  864.  
  865. public void setStartXp(int startXp) {
  866. this.startXp = startXp;
  867. }
  868.  
  869. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement