Advertisement
Zalgo2462

RFighter

Aug 19th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 96.63 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import java.awt.event.MouseEvent;
  5. import java.awt.event.MouseListener;
  6. import java.awt.image.BufferedImage;
  7. import java.io.*;
  8. import java.text.DecimalFormat;
  9. import java.text.NumberFormat;
  10. import java.util.*;
  11. import java.net.*;
  12. import java.util.List;
  13.  
  14. import javax.imageio.ImageIO;
  15. import javax.swing.*;
  16.  
  17. import org.rsbot.bot.event.events.MessageEvent;
  18. import org.rsbot.script.Script;
  19. import org.rsbot.script.internal.event.MessageListener;
  20. import org.rsbot.script.internal.event.PaintListener;
  21. import org.rsbot.script.ScriptManifest;
  22. import org.rsbot.script.methods.*;
  23. import org.rsbot.script.methods.Menu;
  24. import org.rsbot.script.methods.tabs.*;
  25. import org.rsbot.script.methods.ui.Camera;
  26. import org.rsbot.script.methods.ui.Interfaces;
  27. import org.rsbot.script.methods.ui.Magic;
  28. import org.rsbot.script.util.Filter;
  29. import org.rsbot.script.wrappers.*;
  30. import org.rsbot.Configuration;
  31. import org.rsbot.script.wrappers.Character;
  32. import org.rsbot.util.io.HttpClient;
  33.  
  34. /**
  35. * Change log:
  36. * v1.01: API updates
  37. * v1.00: FIRST RENATUS SCRIPT BOO YA!
  38. *
  39. * RENATUS CONVERSION!!!!!!!!!!!!!!
  40. *
  41. * v2.30: Arrow Equipping, Explorers Ring, Expanded anti ban, bunyip summoning, pbot DDoS protection
  42. * v2.20: New GUI, added amount of food to withdraw, fixed prayer pot double clicking, fixed? stats panel freezing for some
  43. * v2.10: Fixed InCombatloop NPE, added staffs to alching
  44. * v2.02: Finally fixed prayer pots.... hopefully, rewrote bonesLoop, bug fixes
  45. * v2.01: Fixed LootLoop Error.
  46. * v2.00: Milestone release:
  47. * Added:
  48. * -new autoupdater
  49. * -changed new paint
  50. * -multithreading
  51. * -disable specs
  52. * -fixed? prayer pots
  53. * -automatic banking (Experimental)
  54. * -Secondary Loot Method
  55. * -Bad Tile Checking
  56. * -Code optimization
  57. * v1.80: Stable: Fixed click to continue issue, Added autoupdater, Added new paint
  58. * v1.75: Unstable: Added autoupdater, new paint, may freeze a bit, looking to improve with multithreading next version.
  59. * v1.70: Stable: Fixed GUI, Added: B2B, alching, prayer pot support, and special attacks codings. (Please tell me if you have any issues with this.)
  60. * v1.66: Unstable: Removed "can reach" checking, improved Prayer pot support, added Special Attacks Codings
  61. * v1.65: Unstable: Added: B2B, alching, and item/npc "can reach" checking.
  62. * v1.61: Made SDN compatible.
  63. * v1.60: Stable: Potions and ssh scattering added.
  64. * v1.55: Unstable: Potions and ash scattering added.
  65. * v1.50: Project branched by Zalgo2462. Bone burial added.
  66. * v1.02: Includes click here to continue hotfix.
  67. * v1.01: Prioritize looting over combat. Safespotting + looting is now possible. Implemented new LoopAction structure internally.
  68. * v1.00: Milestone release.
  69. * Added:
  70. * -Safespot ability
  71. * -Central clicking
  72. * -Clicking continue
  73. * -Antiban - performs camera + mouse at same time! (sometimes)
  74. * -Declared stable
  75. * v0.96: Hopefully finally fixed food
  76. * v0.95: Small error, caused null pointer
  77. * v0.94: Fixed eating.
  78. * v0.93: Hide paint by clicking it.
  79. * v0.92: Loot support, mainly. Many small changes.
  80. * v0.91: Oops, forgot to add mouse speed settings!
  81. * v0.9: Initial release
  82. */
  83. @ScriptManifest(name = "RFighter", authors = "!@!@! And Zalgo2462", keywords = {"universal", "fighter", "!@!@!", "Zalgo2462"}, version = 1.02,
  84. description = "RFighter by Zalgo2462: Original by !@!@!", website = "http://www.powerbot.org/community/topic/444458-tfighteree-the-original-tfighter-but-with-enhancements-approved-by/")
  85. public class RFighter extends Script implements PaintListener, MouseListener, MessageListener {
  86. private final String branch = "Renatus";
  87. private final static ScriptManifest mani = RFighter.class.getAnnotation(ScriptManifest.class);
  88.  
  89. private final Util u = new Util();
  90.  
  91. private Tile startTile;
  92.  
  93. private long nextAntiban = 0;
  94.  
  95. private int badFoodCount = 0;
  96. private int startTime = 0;
  97. private int mouseSpeedMin = 4, mouseSpeedMax = 7;
  98.  
  99. private boolean startScript;
  100. private boolean autoDownloaded = false;
  101. private boolean onlyInRadius = false;
  102. private boolean utilizeMultiwayCombat = false;
  103. private boolean useSafespot = false;
  104. private boolean useCentralClicking = true;
  105. private boolean prioritizeLoot = false;
  106. private boolean buryBones = false;
  107.  
  108. private ZUI zui = new ZUI();
  109.  
  110. private List<LoopAction> loopActions = new LinkedList<LoopAction>();
  111.  
  112. // private RSWeb webToBank;
  113. //
  114. // private RSWeb webToStart;
  115.  
  116.  
  117. public boolean onRun() {
  118. if (!Game.isLoggedIn()) {
  119. log("Start logged in.");
  120. return false;
  121. }
  122. u.vChecker.start();
  123.  
  124. u.paint.showPaint = true;
  125. u.paint.showMain = true;
  126.  
  127. if (SwingUtilities.isEventDispatchThread()) {
  128. zui.setResizable(false);
  129. zui.setVisible(true);
  130. } else {
  131. try {
  132. SwingUtilities.invokeAndWait(new Runnable() {
  133. public void run() {
  134. zui.setResizable(false);
  135. zui.setVisible(true);
  136. }
  137. });
  138. } catch (Exception ignored) { }
  139. }
  140.  
  141. startScript = false;
  142.  
  143. while (!startScript) {
  144. if (!zui.isVisible())
  145. return false;
  146. sleep(100);
  147. }
  148. u.sw.poll();
  149. startTime = (int) System.currentTimeMillis();
  150. startTile = Players.getLocal().getLocation();
  151.  
  152. // if(u.bank.bankingEnabled) {
  153. // if(startTile.getZ() == 0){
  154. // Tile bankTile = web.getNearestBank();
  155. // if(bankTile.getX() == 3382 && bankTile.getY() == 3270) {
  156. // bankTile = new Tile(3269, 3167);
  157. // }
  158. // webToBank = web.getWeb(startTile, bankTile);
  159. // webToStart = web.getWeb(bankTile, startTile);
  160. // } else {
  161. // log("Banking only works on ground level.");
  162. // u.bank.bankingEnabled = false;
  163. // }
  164. // }
  165.  
  166. Game.openTab(Game.Tabs.INVENTORY);
  167.  
  168. // u.eat.foodOfChoice = u.eat.getFood();
  169. //
  170. // if(u.eat.foodOfChoice == null && u.bank.withdrawFood) {
  171. // log("You do not have any food in your inventory! Food withdrawal banking will not be used!");
  172. // log("If you want to use food withdrawal banking, start the script with the food you use in your inventory.");
  173. // }
  174.  
  175. Game.openTab(Game.Tabs.EQUIPMENT);
  176. //Credit: The Powerbot Scripters Team
  177. if(Equipment.getItem(Equipment.Slot.WEAPON) != null && !u.npcs.disableSpecials){
  178. u.npcs.weapon = Equipment.getItem(Equipment.Slot.WEAPON).getName();
  179. if(u.npcs.weapon.contains(">")) {
  180. u.npcs.weapon = u.npcs.weapon.substring(u.npcs.weapon.indexOf(">") + 1);
  181. }
  182.  
  183. String[] specialWeaponsArray = new String[] {"Rune thrownaxe", "Rod of ivandis", "Dragon Dagger",
  184. "Dragon dagger (p)", "Dragon dagger (p+)", "Dragon dagger (p++)", "Dragon Mace", "Dragon Spear",
  185. "Dragon longsword", "Rune claws", "Dragon Halberd", "Magic Longbow", "Magic Composite Bow",
  186. "Dragon Claws", "Abyssal Whip", "Granite Maul", "Darklight", "Barrelchest Anchor",
  187. "Armadyl Godsword", "Magic Shortbow", "Dragon Scimitar", "Dragon 2H Sword", "Zamorak Godsword",
  188. "Korasi's sword", "Dorgeshuun Crossbow", "Bone Dagger", "Bone Dagger (p+)", "Bone Dagger (p++)",
  189. "Brine Sabre", "Bandos Godsword", "Dragon Battleaxe", "Dragon Hatchet", "Seercull Bow",
  190. "Excalibur", "Enhanced excalibur", "Ancient Mace", "Saradomin sword"};
  191.  
  192. for(String weapon : specialWeaponsArray ) {
  193. if (weapon.equalsIgnoreCase(u.npcs.weapon)) {
  194. u.npcs.hasSpecialWeapon = true;
  195. }
  196. }
  197. }
  198.  
  199. if(Equipment.getItem(Equipment.Slot.AMMO) != null) {
  200. u.npcs.ammo = Equipment.getItem(Equipment.Slot.AMMO).getName();
  201. }
  202.  
  203. if(Equipment.getItem(Equipment.Slot.RING) != null) {
  204. u.npcs.ring = Equipment.getItem(Equipment.Slot.RING).getName();
  205. }
  206.  
  207. LoopAction[] actions;
  208. if(prioritizeLoot) {
  209. actions = new LoopAction[] {new SummoningLoop(), new AlchLoop(), (buryBones ? new BonesLoop() : null), new LootLoop(),
  210. (useSafespot ? new SafespotLoop() : null), new InCombatLoop(), new AttackLoop() };
  211. }
  212. else {
  213. actions = new LoopAction[] { (useSafespot ? new SafespotLoop() : null), new InCombatLoop(), new SummoningLoop(), new AlchLoop(),
  214. (buryBones ? new BonesLoop() : null), new LootLoop(), new AttackLoop() };
  215. }
  216. loopActions.addAll(Arrays.asList(actions));
  217.  
  218. return true;
  219. }
  220.  
  221. // public void onStop() {
  222. // if(u.paint.priceGetter != null) {
  223. // if(u.paint.priceGetter.isAlive()) {
  224. // u.paint.priceGetter.safeStop();
  225. // }
  226. // }
  227. // }
  228.  
  229. @Override
  230. public int loop() {
  231. if (random(0, 3) == 0 || Mouse.getSpeed() < mouseSpeedMin || Mouse.getSpeed() > mouseSpeedMax) {
  232. Mouse.setSpeed(random(mouseSpeedMin, mouseSpeedMax));
  233. }
  234. if (Camera.getPitch() < 90) {
  235. Camera.setPitch(true);
  236. return random(50, 100);
  237. }
  238. if (!Walking.isRunEnabled() && Walking.getEnergy() > random(60, 90)) {
  239. Walking.setRun(true);
  240. return random(1200, 1600);
  241. } else if(u.npcs.ring.contains("Explorer's Ring") && u.npcs.rechargeAvailable) {
  242. Game.openTab(Game.Tabs.EQUIPMENT);
  243. Equipment.getItem(Equipment.Slot.RING).interact("Run-replenish");
  244. long millis = System.currentTimeMillis();
  245. int run = Walking.getEnergy();
  246. while(System.currentTimeMillis() - millis < 5000 && run == Walking.getEnergy()) {
  247. sleep(random (50, 70));
  248. }
  249. if(Interfaces.getComponent(211, 1) != null &&
  250. Interfaces.getComponent(211, 1).getText().contains("Your ring appears")) {
  251. u.npcs.rechargeAvailable = false;
  252. }
  253. }
  254.  
  255. if (Interfaces.canContinue()) {
  256. Interfaces.clickContinue();
  257. return random(1200, 1600);
  258. }
  259.  
  260. if (Game.getCurrentTab() != Game.Tabs.INVENTORY) {
  261. Game.openTab(Game.Tabs.INVENTORY);
  262. return random(700, 1500);
  263. }
  264.  
  265. //banking
  266. // if (u.bank.bankingEnabled) {
  267. // if (u.bank.shouldWalkHome) {
  268. // if(Calculations.distanceTo(startTile) > 5) {
  269. // if(webToStart != null) {
  270. // webToStart.step();
  271. // sleep(random(1500, 2000));
  272. // if(!Players.getLocal().isMoving()) {
  273. // Walking.walkTileOnScreen(webToStart.getEnd());
  274. // sleep(random(500, 1000));
  275. // webToStart.update();
  276. // }
  277. // } else {
  278. // log("Web is null");
  279. // }
  280. // } else {
  281. // u.bank.shouldWalkHome = false;
  282. // }
  283. // return (random(500, 750));
  284. // }
  285. //
  286. // if (u.bank.isInBank && u.bank.needsBank()) {
  287. // while(!Bank.isOpen()) {
  288. // Bank.open();
  289. // sleep(random(2000, 3000));
  290. // }
  291. // if(u.bank.depositLoot) {
  292. // u.bank.deposit();
  293. // }
  294. // if(u.bank.withdrawFood && u.eat.foodOfChoice != null) {
  295. // u.bank.withdraw();
  296. // }
  297. // u.bank.shouldWalkHome = true;
  298. // u.bank.isInBank = false;
  299. // return (random(500, 750));
  300. // }
  301. //
  302. // if (u.bank.needsBank()) {
  303. // if(Calculations.distanceTo(web.getNearestBank()) > 5 ) {
  304. // if(webToBank != null) {
  305. // webToBank.step();
  306. // sleep(random(1500, 2000));
  307. // if(!Players.getLocal().isMoving()) {
  308. // Walking.walkTileOnScreen(webToBank.getEnd());
  309. // sleep(random(500, 1000));
  310. // webToBank.update();
  311. // }
  312. // } else {
  313. // log("Web is null");
  314. // }
  315. // } else {
  316. // u.bank.isInBank = true;
  317. // }
  318. // return (random(500, 750));
  319. // }
  320. // }
  321.  
  322. //eating
  323. if (u.eat.needEat()) {
  324. if (u.eat.haveFood()) {
  325. badFoodCount = 0;
  326. u.eat.eatFood();
  327. } else if (u.eat.haveB2pTab() && u.eat.haveBones()) {
  328. u.eat.breakB2pTab();
  329. return random(2600, 3000);
  330. } else if (u.eat.haveB2bRunes() && u.eat.haveBones() && Skills.getLevel(Skills.MAGIC) >= 15) {
  331. u.eat.castB2b();
  332. return random(2600, 3000);
  333. // } else if (u.bank.bankingEnabled && u.bank.withdrawFood){
  334. // u.bank.needBankforFood = true;
  335. } else {
  336. badFoodCount++;
  337. if (badFoodCount > 5) {
  338. log("You ran out of food! Stopping.");
  339. container.stop();
  340. }
  341. }
  342. return random(1200, 1600);
  343. }
  344.  
  345. //potions and prayer
  346. u.pot.usePotions();
  347.  
  348. if(u.pot.getPotions().get("PRAYER").length != 0 && !Prayer.isQuickPrayersActive() && u.pot.setQuickPrayer) {
  349. Prayer.toggleQuickPrayers(true);
  350. }
  351.  
  352. //arrow equipping
  353. if(u.npcs.weapon != null && u.npcs.ammo != null) {
  354. if(u.npcs.weapon.toLowerCase().contains("bow")) {
  355. for(Item item : Inventory.getItems()) {
  356. if(item != null) {
  357. if(item.getID() != -1 && item.getName().equals(u.npcs.ammo)) {
  358. int n = Inventory.getCount(true);
  359. if(item.interact("Wield")) {
  360. waitForInvChange(n, 3000);
  361. }
  362. }
  363. }
  364. }
  365. }
  366. }
  367.  
  368. if(u.loot.onlyTakeLootFromKilled && u.npcs.lastClickedNPC != null) {
  369. u.npcs.sleepWhileNpcIsDying(u.npcs.lastClickedNPC);
  370. }
  371.  
  372. for(LoopAction a : loopActions)
  373. if(a != null && a.activate())
  374. return a.loop();
  375. return random(50, 200);
  376. }
  377.  
  378.  
  379. private interface LoopAction {
  380. public int loop();
  381. public boolean activate();
  382. }
  383.  
  384. private class InCombatLoop implements LoopAction {
  385.  
  386. public int loop() {
  387. if(u.npcs.getInteracting() != null) {
  388. if( u.npcs.useSpecial() && !Combat.isSpecialEnabled() && !u.npcs.getInteracting().isDead()) {
  389. sleep(random(500, 1000));
  390. Combat.setSpecial(true);
  391. }
  392.  
  393. if(u.loot.onlyTakeLootFromKilled) {
  394. if(u.npcs.getInteracting() != null){
  395. if(!u.npcs.tilesFoughtOn.contains(u.npcs.getInteracting().getLocation())
  396. && !u.npcs.getInteracting().isMoving()) {
  397. u.npcs.tilesFoughtOn.add(u.npcs.getInteracting().getLocation());
  398. }
  399. }
  400. }
  401. }
  402. antiban();
  403. return random(50, 200);
  404. }
  405.  
  406. public boolean activate() {
  407. return u.npcs.isInCombat();
  408. }
  409.  
  410. }
  411.  
  412. private class AttackLoop implements LoopAction {
  413.  
  414. public int loop() {
  415. NPC inter = u.npcs.getInteracting();
  416. NPC n = inter != null ? inter : u.npcs.getNPC();
  417. if (n != null) {
  418. int result = u.npcs.clickNPC(n, "Attack " + n.getName());
  419. if (result == 0) {
  420. if(!useSafespot) {
  421. waitWhileMoving();
  422. } else {
  423. waitForAnim();
  424. }
  425. return random(300, 500);
  426. } else if (result == 1) {
  427. waitWhileMoving();
  428. return random(0, 200);
  429. }
  430. } else {
  431. if (Calculations.distanceTo(startTile) > 5) {
  432. Walking.walkTileMM(Walking.getClosestTileOnMap(startTile));
  433. waitWhileMoving();
  434. } else {
  435. antiban();
  436. }
  437. }
  438. return random(50, 200);
  439. }
  440.  
  441. public boolean activate() {
  442. return !u.npcs.isInCombat();
  443. }
  444.  
  445. }
  446.  
  447. private class SafespotLoop implements LoopAction {
  448.  
  449. public int loop() {
  450. if (!startTile.isOnScreen()) {
  451. Walking.walkTileMM(startTile);
  452. } else {
  453. startTile.interact("Walk");
  454. }
  455. waitWhileMoving();
  456. return random(200, 500);
  457. }
  458.  
  459. public boolean activate() {
  460. return useSafespot && Calculations.distanceTo(startTile) > 0;
  461. }
  462.  
  463. }
  464.  
  465. private class LootLoop implements LoopAction {
  466.  
  467. private GroundItem loot = null;
  468.  
  469. public int loop() {
  470. int origCount = Inventory.getCount(true);
  471. String name = loot.getItem().getName();
  472. int count = loot.getItem().getStackSize();
  473. int result = u.loot.takeItem(loot);
  474. if (result == 0) {
  475. waitWhileMoving();
  476. if (waitForInvChange(origCount)) {
  477. u.loot.addItem(name, count);
  478. if(u.loot.onlyTakeLootFromKilled && u.npcs.tilesFoughtOn.contains(loot.getLocation())) {
  479. u.npcs.tilesFoughtOn.remove(loot.getLocation());
  480. }
  481. }
  482. } else if (result == 1) {
  483. waitWhileMoving();
  484. }
  485. return random(50, 200);
  486. }
  487.  
  488. public boolean activate() {
  489. return (loot = u.loot.getLoot()) != null;
  490. }
  491. }
  492.  
  493. private class AlchLoop implements LoopAction {
  494.  
  495. public int loop() {
  496. for(Item i : Inventory.getItems()) {
  497. for ( String s : u.alch.alchNames) {
  498. if ( i.getID() != -1 && i.getName().toLowerCase().contains(s)) {
  499. u.alch.alch(i.getComponent());
  500. return random(2500, 3000);
  501. }
  502. }
  503. for ( int n : u.alch.alchIDs) {
  504. if( n == i.getID()) {
  505. u.alch.alch(i.getComponent());
  506. return random(2500, 3000);
  507. }
  508. }
  509. }
  510.  
  511. return random(50, 200);
  512. }
  513.  
  514. public boolean activate() {
  515. return u.alch.canAlch() && u.alch.hasAlchItems();
  516. }
  517. }
  518.  
  519. private class BonesLoop implements LoopAction {
  520. private final int[] BONE_IDS = new int[] { 526, 528, 530, 532, 534, 536, 2859, 3123, 3125, 3183, 6182 , 20268, 20266, 20264};
  521.  
  522. public int loop() {
  523. Item bone = Inventory.getItem(BONE_IDS);
  524. if(bone != null) {
  525. if(bone.getID() != -1) {
  526. int n = Inventory.getCount(true);
  527. bone.click(true);
  528. waitForInvChange(n);
  529. }
  530. }
  531. return random(50, 200);
  532. }
  533.  
  534. public boolean activate() {
  535. return Inventory.getCount(BONE_IDS) != 0;
  536. }
  537. }
  538.  
  539. //TODO: Add support for other familiars
  540. private class SummoningLoop implements LoopAction {
  541. public int loop() {
  542. Inventory.getItem(12029).interact("Summon");
  543. return random(3000, 5000);
  544. }
  545.  
  546. public boolean activate() {
  547. return !Summoning.isFamiliarSummoned() && Inventory.contains(12029) && Summoning.getPoints() > 0;
  548. }
  549. }
  550.  
  551. private void waitWhileMoving() {
  552. long start = System.currentTimeMillis();
  553. while (System.currentTimeMillis() - start < 1500 && !Players.getLocal().isMoving()) {
  554. sleep(random(50, 200));
  555. }
  556. while (Players.getLocal().isMoving()) {
  557. sleep(random(20, 50));
  558. }
  559. }
  560.  
  561. /**
  562. * Waits until the inventory count changes
  563. * @param origCount the original count of rsitems inventory.getCount(true)
  564. * @return True when inventory has changed
  565. */
  566. private boolean waitForInvChange(int origCount) {
  567. long start = System.currentTimeMillis();
  568. while (Inventory.getCount(true) == origCount && System.currentTimeMillis() - start < 2000) {
  569. sleep(random(20, 70));
  570. }
  571. return Inventory.getCount(true) != origCount;
  572. }
  573.  
  574. private boolean waitForInvChange(int origCount, int bound) {
  575. long start = System.currentTimeMillis();
  576. while (Inventory.getCount(true) == origCount && System.currentTimeMillis() - start < bound) {
  577. sleep(random(20, 70));
  578. }
  579. return Inventory.getCount(true) != origCount;
  580. }
  581.  
  582. /**
  583. * Used in safe spotting. Waits for an animation.
  584. */
  585. private void waitForAnim() {
  586. long timer = System.currentTimeMillis();
  587. while(System.currentTimeMillis() - timer < 2500 && Players.getLocal().getAnimation() == -1
  588. && (System.currentTimeMillis() - timer < 1000 || Players.getLocal().getInteracting() != null))
  589. sleep(random(50, 100));
  590. }
  591.  
  592. private void antiban() {
  593. if (System.currentTimeMillis() > nextAntiban) {
  594. nextAntiban = System.currentTimeMillis() + random(2000, 30000);
  595. } else {
  596. return;
  597. }
  598. Thread mouseThread = new Thread() {
  599. public void run() {
  600. switch(random(0, 5)) {
  601. case 0:
  602. Mouse.moveOffScreen();
  603. break;
  604. case 1:
  605. Mouse.move(random(0, Game.getWidth()), random(0, Game.getHeight()));
  606. break;
  607. case 2:
  608. Mouse.move(random(0, Game.getWidth()), random(0, Game.getHeight()));
  609. break;
  610. }
  611. }
  612. };
  613. Thread keyThread = new Thread() {
  614. public void run() {
  615. switch(random(0, 4)) {
  616. case 0:
  617. Camera.setAngle(Camera.getAngle() + random(-100, 100));
  618. break;
  619. case 1:
  620. Camera.setAngle(Camera.getAngle() + random(-100, 100));
  621. break;
  622. case 2:
  623. Camera.setAngle(Camera.getAngle() + random(-100, 100));
  624. break;
  625. }
  626. }
  627. };
  628. int decision = random(1, 6);
  629. if(decision < 3) {
  630. keyThread.start();
  631. sleep(random(0, 600));
  632. mouseThread.start();
  633. } else if (decision < 5) {
  634. mouseThread.start();
  635. sleep(random(0, 600));
  636. keyThread.start();
  637. } else if (decision == 6) {
  638. Game.Tabs tab = Game.getCurrentTab();
  639. Game.openTab(Game.Tabs.STATS);
  640. while(tab == Game.getCurrentTab()) {
  641. sleep(random(50, 90));
  642. }
  643. int decision2 = random (1, 4);
  644. if(decision2 == 1)
  645. Skills.hover(1);
  646. else if (decision2 == 2)
  647. Skills.hover(4);
  648. else if (decision2 == 3)
  649. Skills.hover(22);
  650. }
  651. while(keyThread.isAlive() || mouseThread.isAlive())
  652. sleep(random(30, 100));
  653. }
  654.  
  655. public void onRepaint(Graphics g) {
  656. if (u.paint.showPaint) {
  657. final NumberFormat nf = NumberFormat.getIntegerInstance();
  658. ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  659. //Variables
  660. InterfaceComponent inter = Interfaces.get(137).getComponent(0);
  661. int xx = inter.getLocation().x;
  662. int yy = inter.getLocation().y;
  663.  
  664. int runTime = (int) System.currentTimeMillis() - startTime;
  665.  
  666. if(u.paint.useAdvancedPaint) {
  667. g.setColor(Color.WHITE);
  668. g.setFont(u.paint.KellyAnnGothic.deriveFont(Font.BOLD, 18));
  669. g.drawImage(u.paint.ribbon, xx, yy - 325, null);
  670. g.drawString("RFighter", xx + 35, yy - 290);
  671. g.drawImage(u.paint.ribbon, xx, yy - 225, null);
  672. g.drawString("Stats", xx + 55, yy - 190);
  673. g.drawImage(u.paint.ribbon, xx, yy - 125, null);
  674. g.drawString("Loot", xx + 55, yy - 90);
  675.  
  676. ArrayList<Tile> alreadyDrawn = new ArrayList<Tile>();
  677.  
  678. //Credit: Parnassian for paint method
  679. for(Tile tile : u.tiles.badTiles) {
  680. if(!alreadyDrawn.contains(tile)) {
  681. Point p = tile.toMinimap();
  682. if (p != null && p.x > 0 && p.x < Game.getWidth() && p.y > 0
  683. && p.y < Game.getHeight()) {
  684. g.setColor(Color.CYAN);
  685. g.drawRect(p.x - 2, p.y - 2, 4, 4);
  686. g.fillRect(p.x - 2, p.y - 2, 4, 4);
  687. alreadyDrawn.add(tile);
  688. }
  689. }
  690. }
  691.  
  692. if(u.paint.showMain) {
  693. int x = inter.getLocation().x;
  694. int y = inter.getLocation().y;
  695. g.drawImage(u.paint.stableRug, x, y, inter.getWidth(), inter.getHeight(), null);
  696. g.setColor(Color.WHITE);
  697. g.setFont(new Font("Arial", Font.PLAIN, 16));
  698. g.drawString("Renatus Fighter (v" + mani.version() + ")", x + 15, y += g.getFontMetrics().getMaxAscent() + 10);
  699. g.setFont(new Font("Arial", Font.PLAIN, 14));
  700. g.drawString("By !@!@! & Zalgo2462", x + 15, y += g.getFontMetrics().getMaxAscent() + 5);
  701. g.setFont(new Font("Arial", Font.PLAIN, 12));
  702. g.drawString("Run time: " + millisToTime(runTime), x + 25, y += g.getFontMetrics().getMaxAscent() + 5);
  703.  
  704. //Exp gains
  705. g.setFont(new Font("Arial", Font.BOLD, 12));
  706. g.drawString("Experience gained:", x + 25, y += g.getFontMetrics().getMaxAscent() + 10);
  707. g.setFont(new Font("Arial", Font.PLAIN, 11));
  708.  
  709. int skillLayoutNumber = 0;
  710. final int skillYStart = y + g.getFontMetrics().getMaxAscent();
  711. for (Map.Entry<String, Integer> entry : u.sw.getExpGainedMap().entrySet()) {
  712.  
  713. skillLayoutNumber++;
  714.  
  715. double expPerSec = entry.getValue() / (double) (runTime / 1000);
  716. int expPerHour = (int) Math.round(expPerSec * 3600);
  717.  
  718.  
  719. if((skillLayoutNumber < 4) || (skillLayoutNumber > 4)) {
  720. g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
  721. " (p/hr: " + nf.format(expPerHour) + ")", x + 25, y += g.getFontMetrics().getMaxAscent());
  722. }
  723.  
  724. else if(skillLayoutNumber == 4) {
  725. g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
  726. " (p/hr: " + nf.format(expPerHour) + ")", x + 175, skillYStart);
  727. }
  728. }
  729. y = inter.getLocation().y;
  730. g.setFont(new Font("Arial", Font.BOLD, 12));
  731. g.drawString("Loot taken:", x + 280, y += g.getFontMetrics().getMaxAscent() + 15);
  732. g.setFont(new Font("Arial", Font.PLAIN, 11));
  733. Map<String, Integer> loot = u.loot.getLootTaken();
  734. for (Map.Entry<String, Integer> entry : loot.entrySet()) {
  735. g.drawString(entry.getKey() + " x" + entry.getValue(), x + 285, y += g.getFontMetrics().getMaxAscent());
  736. }
  737. }
  738. else if (u.paint.showSkills) {
  739. int x = inter.getLocation().x;
  740. int y = inter.getLocation().y;
  741. g.drawImage(u.paint.skillsRug, x, y, inter.getWidth(), inter.getHeight(), null);
  742. g.setColor(new Color(0, 203, 0));
  743.  
  744. int attackHeight = Math.round(Skills.getPercentToLevel(Skills.ATTACK) * 80 / 100);
  745. if(attackHeight != 0)
  746. g.fillRect(x + 44, y + (93 - attackHeight), 25, attackHeight);
  747.  
  748. int strengthHeight = Math.round(Skills.getPercentToLevel(Skills.STRENGTH) * 80 / 100);
  749. if(strengthHeight != 0)
  750. g.fillRect(x + 109, y + (93 - strengthHeight), 25, strengthHeight);
  751.  
  752. int defenseHeight = Math.round(Skills.getPercentToLevel(Skills.DEFENSE) * 80 / 100);
  753. if(defenseHeight != 0)
  754. g.fillRect(x + 174, y + (93 - defenseHeight), 25, defenseHeight);
  755.  
  756. int rangedHeight = Math.round(Skills.getPercentToLevel(Skills.RANGE) * 80 / 100);
  757. if(rangedHeight != 0)
  758. g.fillRect(x + 238, y + (93 - rangedHeight), 25, rangedHeight);
  759.  
  760. int prayerHeight = Math.round(Skills.getPercentToLevel(Skills.PRAYER) * 80 / 100);
  761. if(prayerHeight != 0)
  762. g.fillRect(x + 304, y + (93 - prayerHeight), 25, prayerHeight);
  763.  
  764. int magicHeight = Math.round(Skills.getPercentToLevel(Skills.MAGIC) * 80 / 100);
  765. if(magicHeight != 0)
  766. g.fillRect(x + 370, y + (93 - magicHeight), 25, magicHeight);
  767.  
  768. int constitutionHeight = Math.round(Skills.getPercentToLevel(Skills.CONSTITUTION) * 80 / 100);
  769. if(constitutionHeight != 0)
  770. g.fillRect(x + 434, y + (93 - constitutionHeight), 25, constitutionHeight);
  771.  
  772. g.setColor(Color.WHITE);
  773. g.setFont(new Font("Arial", Font.PLAIN, 18));
  774. g.drawString(Skills.getAbsoluteLevel(Skills.ATTACK) + "", x + 20, y + 40);
  775. g.drawString(Skills.getAbsoluteLevel(Skills.STRENGTH) + "", x + 85, y + 40);
  776. g.drawString(Skills.getAbsoluteLevel(Skills.DEFENSE) + "", x + 150, y + 40);
  777. g.drawString(Skills.getAbsoluteLevel(Skills.RANGE) + "", x + 215, y + 40);
  778. g.drawString(Skills.getAbsoluteLevel(Skills.PRAYER) + "", x + 280, y + 40);
  779. g.drawString(Skills.getAbsoluteLevel(Skills.MAGIC) + "", x + 345, y + 40);
  780. g.drawString(Skills.getAbsoluteLevel(Skills.CONSTITUTION) + "", x + 410, y + 40);
  781.  
  782. g.setColor(Color.GREEN);
  783. g.drawString("+" + u.sw.getLevelsGainedIn(Skills.ATTACK) + "", x + 20, y + 60);
  784. g.drawString("+" + u.sw.getLevelsGainedIn(Skills.STRENGTH) + "", x + 85, y + 60);
  785. g.drawString("+" + u.sw.getLevelsGainedIn(Skills.DEFENSE) + "", x + 150, y + 60);
  786. g.drawString("+" + u.sw.getLevelsGainedIn(Skills.RANGE) + "", x + 215, y + 60);
  787. g.drawString("+" + u.sw.getLevelsGainedIn(Skills.PRAYER) + "", x + 280, y + 60);
  788. g.drawString("+" + u.sw.getLevelsGainedIn(Skills.MAGIC) + "", x + 345, y + 60);
  789. g.drawString("+" + u.sw.getLevelsGainedIn(Skills.CONSTITUTION) + "", x + 410, y + 60);
  790.  
  791. g.setColor(Color.WHITE);
  792. g.setFont(new Font("Arial", Font.PLAIN, 11));
  793.  
  794. g.drawString("TNL: " + numberPostfixer(Skills.getExperienceToLevel(Skills.ATTACK)), x + 10, y + 93 + g.getFontMetrics().getMaxAscent());
  795. g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.STRENGTH)), x + 110, y + 93 + g.getFontMetrics().getMaxAscent());
  796. g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.DEFENSE)), x + 175, y + 93 + g.getFontMetrics().getMaxAscent());
  797. g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.RANGE)), x + 238, y + 93 + g.getFontMetrics().getMaxAscent());
  798. g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.PRAYER)), x + 305, y + 93 + g.getFontMetrics().getMaxAscent());
  799. g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.MAGIC)), x + 370, y + 93 + g.getFontMetrics().getMaxAscent());
  800. g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.CONSTITUTION)), x + 435, y + 93 + g.getFontMetrics().getMaxAscent());
  801.  
  802. int lowerStringY = y + 93 + g.getFontMetrics().getMaxAscent();
  803.  
  804. g.drawString("P/Hr: " + numberPostfixer(u.paint.getExpPerHour(Skills.ATTACK)),
  805. x + 10, lowerStringY + g.getFontMetrics().getMaxAscent());
  806. g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.STRENGTH)),
  807. x + 110, lowerStringY + g.getFontMetrics().getMaxAscent());
  808. g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.DEFENSE)) ,
  809. x + 175, lowerStringY + g.getFontMetrics().getMaxAscent());
  810. g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.RANGE)),
  811. x + 238, lowerStringY + g.getFontMetrics().getMaxAscent());
  812. g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.PRAYER)),
  813. x + 305, lowerStringY + g.getFontMetrics().getMaxAscent());
  814. g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.MAGIC)),
  815. x + 370, lowerStringY + g.getFontMetrics().getMaxAscent());
  816. g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.CONSTITUTION)),
  817. x + 435, lowerStringY + g.getFontMetrics().getMaxAscent());
  818. }
  819. else if (u.paint.showLoot) {
  820. int x = inter.getLocation().x;
  821. int y = inter.getLocation().y;
  822. g.drawImage(u.paint.stableRug, x, y, inter.getWidth(), inter.getHeight(), null);
  823. g.setColor(Color.WHITE);
  824. g.setFont(new Font("Arial", Font.BOLD, 14));
  825. g.drawString("Loot taken:", x + 50 , y += g.getFontMetrics().getMaxAscent() + 15);
  826. y += 5;
  827. g.setFont(new Font("Arial", Font.PLAIN, 12));
  828. Map<String, Integer> loot = u.loot.getLootTaken();
  829. int totalProfit = 0;
  830. for (Map.Entry<String, Integer> entry : loot.entrySet()) {
  831. g.drawString(entry.getKey() + " x" + entry.getValue() /** + " = " + (
  832. u.paint.priceGetter.prices.containsKey(entry.getKey()) ?
  833. nf.format(u.paint.priceGetter.prices.get(entry.getKey()) * entry.getValue()) + " Coins":
  834. "Fetching Price")**/, x + 50, y += g.getFontMetrics().getMaxAscent());
  835. // if(u.paint.priceGetter.prices.containsKey(entry.getKey())) {
  836. // totalProfit += (u.paint.priceGetter.prices.get(entry.getKey()) * entry.getValue());
  837. // }
  838. }
  839.  
  840. // y = inter.getLocation().y;
  841. // g.setFont(new Font("Arial", Font.PLAIN, 24));
  842. // g.drawString("PROFIT???", x + 300, y += g.getFontMetrics().getMaxAscent() + 15);
  843. // g.drawString(nf.format(totalProfit) + " COINS", x + 300, y += g.getFontMetrics().getMaxAscent() + 15);
  844. }
  845. }
  846. else{
  847. int x = inter.getLocation().x;
  848. int y = inter.getLocation().y;
  849. // Background
  850. g.setColor(new Color(198, 226, 255));
  851. g.fillRect(x, y, inter.getWidth() + 5, inter.getHeight() + 5);
  852. //Simple things
  853. g.setColor(Color.BLACK);
  854. g.setFont(new Font("Arial", Font.PLAIN, 16));
  855. g.drawString("Renatus Fighter (v" + mani.version() + ")", x + 10, y += g.getFontMetrics().getMaxAscent() + 10);
  856. g.setFont(new Font("Arial", Font.PLAIN, 14));
  857. g.drawString("By !@!@! & Zalgo2462", x + 10, y += g.getFontMetrics().getMaxAscent() + 5);
  858. g.setFont(new Font("Arial", Font.PLAIN, 12));
  859. g.drawString("Run time: " + millisToTime(runTime), x + 20, y += g.getFontMetrics().getMaxAscent() + 5);
  860.  
  861. //Exp gains
  862. g.setFont(new Font("Arial", Font.BOLD, 12));
  863. g.drawString("Experience gained:", x + 20, y += g.getFontMetrics().getMaxAscent() + 15);
  864. g.setFont(new Font("Arial", Font.PLAIN, 11));
  865.  
  866. int skillLayoutNumber = 0;
  867. final int skillYStart = y + g.getFontMetrics().getMaxAscent();
  868. for (Map.Entry<String, Integer> entry : u.sw.getExpGainedMap().entrySet()) {
  869.  
  870. skillLayoutNumber++;
  871.  
  872. double expPerSec = entry.getValue() / (double) (runTime / 1000);
  873. int expPerHour = (int) Math.round(expPerSec * 3600);
  874.  
  875.  
  876. if((skillLayoutNumber < 5) || (skillLayoutNumber > 5)) {
  877. g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
  878. " (p/hr: " + nf.format(expPerHour) + ")", x + 25, y += g.getFontMetrics().getMaxAscent());
  879. }
  880.  
  881. else if(skillLayoutNumber == 5) {
  882. g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
  883. " (p/hr: " + nf.format(expPerHour) + ")", x + 175, skillYStart);
  884. }
  885. }
  886.  
  887. //Loot
  888. y = inter.getLocation().y;
  889. g.setFont(new Font("Arial", Font.BOLD, 12));
  890. g.drawString("Loot taken:", x + 280, y += g.getFontMetrics().getMaxAscent() + 15);
  891. g.setFont(new Font("Arial", Font.PLAIN, 11));
  892. Map<String, Integer> loot = u.loot.getLootTaken();
  893. for (Map.Entry<String, Integer> entry : loot.entrySet()) {
  894. g.drawString(entry.getKey() + " x" + entry.getValue(), x + 285, y += g.getFontMetrics().getMaxAscent());
  895. }
  896. }
  897. }
  898. drawMouse(g);
  899. }
  900.  
  901. private void drawMouse(Graphics g) {
  902. int x = Mouse.getLocation().x, y = Mouse.getLocation().y;
  903.  
  904.  
  905. g.setColor(System.currentTimeMillis() - Mouse.getPressTime() < 300 ? Color.CYAN : Color.RED);
  906. g.fillOval(x - 6, y - 6, 12, 12);
  907. g.setColor(Color.ORANGE);
  908. g.fillOval(x - 3, y - 3, 6, 6);
  909. g.drawLine(x - 10, y - 10, x + 10, y + 10);
  910. g.drawLine(x - 10, y + 10, x + 10, y - 10);
  911. }
  912.  
  913. public void messageReceived(MessageEvent e) {
  914. if(e.getMessage().equals("You can't reach that.")) {
  915. if(u.loot.itemWasClickedLast && u.loot.lastClickedItem != null) {
  916. u.tiles.addBadTile(u.loot.lastClickedItem.getLocation());
  917. } else if(u.npcs.npcWasClickedLast && u.npcs.lastClickedNPC != null) {
  918. u.tiles.addBadTile(u.npcs.lastClickedNPC.getLocation());
  919. }
  920. } else if(e.getMessage().equals("You don't have any quick prayers selected.")) {
  921. u.pot.setQuickPrayer = false;
  922. log("You must set your quick prayers to use prayer potions.");
  923. } else if(e.getMessage().equals("There is no ammo in your quiver.")) {
  924. boolean weaponIsCBow = u.npcs.weapon.toLowerCase().contains("crossbow");
  925. for(Item item : Inventory.getItems()) {
  926. if(item != null && item.getID() != -1) {
  927. if(weaponIsCBow && item.getName().toLowerCase().contains("bolt") ||
  928. !weaponIsCBow && item.getName().toLowerCase().contains("arrow")) {
  929. if(item.interact("Wield")) {
  930. u.npcs.ammo = item.getName();
  931. }
  932. }
  933. }
  934. }
  935. }
  936. }
  937.  
  938. private String millisToTime(int millis) {
  939. int hours = millis / (60 * 1000 * 60);
  940. int minutes = (millis - (hours * 60 * 1000 * 60)) / (60 * 1000);
  941. int seconds = (millis - (hours * 60 * 1000 * 60) - (minutes * 60 * 1000)) / 1000;
  942. return (hours >= 10 ? hours + ":" : "0" + hours + ":")
  943. + (minutes >= 10 ? minutes + ":" : "0" + minutes + ":")
  944. + (seconds >= 10 ? seconds : "0" + seconds);
  945. }
  946.  
  947. private String numberPostfixer(int number) {
  948. if(number >= 1000) {
  949. DecimalFormat twoDForm = new DecimalFormat("#.##");
  950. double temp = number / 1000.0;
  951. return Double.valueOf(twoDForm.format(temp)) + "K";
  952. }
  953. return "" + number;
  954. }
  955.  
  956. private class Util {
  957. private final Npcs npcs = new Npcs();
  958. private final Eating eat = new Eating();
  959. private final Loot loot = new Loot();
  960. private final Potion pot = new Potion();
  961. private final Alchemy alch = new Alchemy();
  962. private final Paint paint = new Paint();
  963. private final SkillWatcher sw = new SkillWatcher();
  964. private final VersionChecker vChecker = new VersionChecker();
  965. // private final Banking bank = new Banking();
  966. private final Tiles tiles = new Tiles();
  967. }
  968.  
  969. private class Npcs {
  970.  
  971. private int[] npcIDs = new int[0];
  972. private String[] npcNames = new String[0];
  973.  
  974. private String weapon = "";
  975. private boolean hasSpecialWeapon = false;
  976. private boolean disableSpecials = false;
  977.  
  978. public String ammo = "";
  979.  
  980. public String ring = "";
  981.  
  982. private int maxRadius = 10;
  983.  
  984. NPC lastClickedNPC = null;
  985. boolean npcWasClickedLast = false;
  986.  
  987.  
  988. private ArrayList<Tile> tilesFoughtOn = new ArrayList<Tile>();
  989. public boolean rechargeAvailable = true;
  990.  
  991.  
  992.  
  993. public boolean useSpecial() {
  994. if(hasSpecialWeapon) {
  995. int[] amountUsage = {10, 25, 33, 35, 45, 50, 55, 60, 80, 85, 100};
  996. String[][] weapons = {
  997. {"Rune thrownaxe", "Rod of ivandis"},
  998. {"Dragon Dagger", "Dragon dagger (p)", "Dragon dagger (p+)",
  999. "Dragon dagger (p++)", "Dragon Mace", "Dragon Spear",
  1000. "Dragon longsword", "Rune claws"},
  1001. {"Dragon Halberd"},
  1002. {"Magic Longbow"},
  1003. {"Magic Composite Bow"},
  1004. {"Dragon Claws", "Abyssal Whip", "Granite Maul", "Darklight",
  1005. "Barrelchest Anchor", "Armadyl Godsword"},
  1006. {"Magic Shortbow"},
  1007. {"Dragon Scimitar", "Dragon 2H Sword", "Zamorak Godsword",
  1008. "Korasi's sword"},
  1009. {"Dorgeshuun Crossbow", "Bone Dagger", "Bone Dagger (p+)",
  1010. "Bone Dagger (p++)"},
  1011. {"Brine Sabre"},
  1012. {"Bandos Godsword", "Dragon Battleaxe", "Dragon Hatchet",
  1013. "Seercull Bow", "Excalibur", "Enhanced excalibur",
  1014. "Ancient Mace", "Saradomin sword"}};
  1015.  
  1016. for (int i = 0; i < weapons.length; i++) {
  1017. for (int j = 0; j < weapons[i].length; j++) {
  1018. if (weapons[i][j].equalsIgnoreCase(weapon)) {
  1019. return Combat.getSpecialEnergy() >= amountUsage[i];
  1020. }
  1021. }
  1022. }
  1023. }
  1024. return false;
  1025. }
  1026.  
  1027. /**
  1028. * Checks if we are in combat.
  1029. *
  1030. * @return True if we are in combat.
  1031. */
  1032. private boolean isInCombat() {
  1033. return Players.getLocal().getInteracting() instanceof NPC;
  1034. }
  1035.  
  1036. /**
  1037. * Clicks an NPC based on its model.
  1038. *
  1039. * @param npc The NPC to click.
  1040. * @param action The action to perform.
  1041. * @return 0 if the NPC was clicked, 1 if we walked to it, or -1 if nothing happened.
  1042. */
  1043. private int clickNPC(NPC npc, String action) {
  1044. for (int i = 0; i < 10; i++) {
  1045. if (isPartiallyOnScreen(npc.getModel())) {
  1046. Point p = useCentralClicking ? getCentralPoint(npc.getModel()) : getPointOnScreen(npc.getModel(), false);
  1047. if (p == null || !Calculations.pointOnScreen(p)) {
  1048. continue;
  1049. }
  1050. Mouse.move(p, useCentralClicking ? 3 : 0, useCentralClicking ? 3 : 0);
  1051. String[] items = Menu.getItems();
  1052. if (items.length > 0 && items[0].contains(action)) {
  1053. Mouse.click(true);
  1054. u.loot.itemWasClickedLast = false;
  1055. npcWasClickedLast = true;
  1056. lastClickedNPC = npc;
  1057. return 0;
  1058. } else if (Menu.contains(action)) {
  1059. Mouse.click(false);
  1060. sleep(random(100, 200));
  1061. for (int x = 0; x < 4; x++) {
  1062. if (!Menu.contains(action)) {
  1063. break;
  1064. }
  1065. if (Menu.click(action)) {
  1066. u.loot.itemWasClickedLast = false;
  1067. npcWasClickedLast = true;
  1068. lastClickedNPC = npc;
  1069. return 0;
  1070. }
  1071. }
  1072. }
  1073. } else {
  1074. if(!useSafespot) {
  1075. Walking.walkTileMM(closerTile(npc.getLocation(), 1), 2, 2);
  1076. sleep(random(1500, 2000));
  1077. if(!Players.getLocal().isMoving()){
  1078. u.tiles.addBadTile(npc.getLocation());
  1079. return -1;
  1080. }
  1081. return 1;
  1082. } else {
  1083. int angle = Camera.getCharacterAngle(npc);
  1084. if (Calculations.distanceTo(npc) < 10 && Math.abs(angle - Camera.getAngle()) > 20) {
  1085. Camera.setAngle(angle + random(-20, 20));
  1086. }
  1087. }
  1088. }
  1089. }
  1090. return -1;
  1091. }
  1092.  
  1093. /**
  1094. * Checks if a model is partially on screen.
  1095. *
  1096. * @param m The GameModel to check.
  1097. * @return True if any point on the model is on screen.
  1098. */
  1099. private boolean isPartiallyOnScreen(GameModel m) {
  1100. return getPointOnScreen(m, true) != null;
  1101. }
  1102.  
  1103. /**
  1104. * Gets a point on a model that is on screen.
  1105. *
  1106. * @param m The GameModel to test.
  1107. * @param first If true, it will return the first point that it finds on screen.
  1108. * @return A random point on screen of an object.
  1109. */
  1110. private Point getPointOnScreen(GameModel m, boolean first) {
  1111. if (m == null)
  1112. return null;
  1113. ArrayList<Point> list = new ArrayList<Point>();
  1114. try {
  1115. Polygon[] tris = m.getTriangles();
  1116. for (int i = 0; i < tris.length; i++) {
  1117. Polygon p = tris[i];
  1118. for (int j = 0; j < p.xpoints.length; j++) {
  1119. Point pt = new Point(p.xpoints[j], p.ypoints[j]);
  1120. if (Calculations.pointOnScreen(pt)) {
  1121. if (first)
  1122. return pt;
  1123. list.add(pt);
  1124. }
  1125. }
  1126. }
  1127. } catch (Exception ignored) {
  1128. }
  1129. return list.size() > 0 ? list.get(random(0, list.size())) : null;
  1130. }
  1131.  
  1132. /**
  1133. * Generates a rough central point. Performs the calculation
  1134. * by first generating a rough point, and then finding the point
  1135. * closest to the rough point that is actually on the GameModel.
  1136. *
  1137. * @param m The GameModel to test.
  1138. * @return The rough central point.
  1139. */
  1140. private Point getCentralPoint(GameModel m) {
  1141. if(m == null)
  1142. return null;
  1143. try {
  1144. /* Add X and Y of all points, to get a rough central point */
  1145. int x = 0, y = 0, total = 0;
  1146. for(Polygon poly : m.getTriangles()) {
  1147. for(int i = 0; i < poly.npoints; i++) {
  1148. x += poly.xpoints[i];
  1149. y += poly.ypoints[i];
  1150. total++;
  1151. }
  1152. }
  1153. Point central = new Point(x / total, y / total);
  1154. /* Find a real point on the NPC that is closest to the central point */
  1155. Point curCentral = null;
  1156. double dist = 20000;
  1157. for(Polygon poly : m.getTriangles()) {
  1158. for(int i = 0; i < poly.npoints; i++) {
  1159. Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
  1160. if(!Calculations.pointOnScreen(p))
  1161. continue;
  1162. double dist2 = distanceBetween(central, p);
  1163. if(curCentral == null || dist2 < dist) {
  1164. curCentral = p;
  1165. dist = dist2;
  1166. }
  1167. }
  1168. }
  1169. return curCentral;
  1170. } catch (Exception ignored) {}
  1171. return null;
  1172. }
  1173.  
  1174. /**
  1175. * Calculates the distance between two points.
  1176. *
  1177. * @param p1 The first point.
  1178. * @param p2 The second point.
  1179. * @return The distance between the two points, using the distance formula.
  1180. */
  1181. private double distanceBetween(Point p1, Point p2) {
  1182. return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)));
  1183. }
  1184.  
  1185. /**
  1186. * Gets a closer tile to us within dist.
  1187. *
  1188. * @param t The tile to start with.
  1189. * @param dist The max dist.
  1190. * @return A closer tile.
  1191. */
  1192. private Tile closerTile(Tile t, int dist) {
  1193. Tile loc = Players.getLocal().getLocation();
  1194. int newX = t.getX(), newY = t.getY();
  1195. for (int i = 1; i < dist; i++) {
  1196. newX = t.getX() != loc.getX() ? (t.getX() < loc.getX() ? newX-- : newX++) : newX;
  1197. newY = t.getY() != loc.getY() ? (t.getY() < loc.getY() ? newY-- : newY++) : newY;
  1198. }
  1199. return new Tile(newX, newY);
  1200. }
  1201.  
  1202. /**
  1203. * Returns the nearest NPC.
  1204. *
  1205. * @return The nearest NPC that matches the filter.
  1206. */
  1207. private NPC getNPC() {
  1208. NPC onScreen = NPCs.getNearest(npcOnScreenFilter);
  1209. if(onScreen != null)
  1210. return onScreen;
  1211. return NPCs.getNearest(npcFilter);
  1212. }
  1213.  
  1214. /**
  1215. * Returns the interacting NPC that matches our description, if any.
  1216. *
  1217. * @return The closest interacting NPC that matches the filter.
  1218. */
  1219. private NPC getInteracting() {
  1220. NPC npc = null;
  1221. int dist = 20;
  1222. for (NPC n : NPCs.getLoaded()) {
  1223. if (!isOurNPC(n))
  1224. continue;
  1225. Character inter = n.getInteracting();
  1226. if (inter != null && inter instanceof Player && inter.equals(Players.getLocal()) && Calculations.distanceTo(n) < dist) {
  1227. dist = Calculations.distanceTo(n);
  1228. npc = n;
  1229. }
  1230. }
  1231. return npc;
  1232. }
  1233.  
  1234. private boolean isOurNPC(NPC t) {
  1235. int id = t.getID();
  1236. String name = t.getName();
  1237. boolean good = false;
  1238. for (int i : npcIDs) {
  1239. if (id == i)
  1240. good = true;
  1241. }
  1242. for (String s : npcNames) {
  1243. if (name.toLowerCase().contains(s.toLowerCase()))
  1244. good = true;
  1245. }
  1246. return good;
  1247. }
  1248.  
  1249. private void sleepWhileNpcIsDying(NPC t) {
  1250. if(u.npcs.lastClickedNPC.isDead()) {
  1251. GroundItem[] GIs = GroundItems.getLoadedAt(t.getLocation());
  1252. long start = System.currentTimeMillis();
  1253. while(u.npcs.lastClickedNPC.isDead() && GIs.length == GroundItems.getLoadedAt(t.getLocation()).length
  1254. && System.currentTimeMillis() - start < 5000) {
  1255. sleep(random(20, 70));
  1256. }
  1257. }
  1258. }
  1259.  
  1260.  
  1261. /**
  1262. * The filter we use!
  1263. */
  1264. private final Filter<NPC> npcFilter = new Filter<NPC>() {
  1265. public boolean accept(NPC t) {
  1266. return (isOurNPC(t) && t.verify() && (!onlyInRadius || Calculations.distanceBetween(t.getLocation(), startTile) < maxRadius)
  1267. && (utilizeMultiwayCombat || !t.isInCombat() && t.getInteracting() == null) && t.getHPPercent() != 0
  1268. && !u.tiles.NPCisOnBadTile(t));
  1269. }
  1270. };
  1271.  
  1272. /**
  1273. * Will only return an on screen NPC. Based on npcFilter.
  1274. */
  1275. private final Filter<NPC> npcOnScreenFilter = new Filter<NPC>() {
  1276. public boolean accept(NPC n) {
  1277. return npcFilter.accept(n) && getPointOnScreen(n.getModel(), true) != null;
  1278. }
  1279. };
  1280. }
  1281.  
  1282. private class Eating {
  1283.  
  1284. private final int[] B2P_TAB_ID = new int[]{8015};
  1285. // --Commented out by Inspection (7/20/11 2:14 PM):private final int[] B2B_TAB_ID = new int[]{8014};
  1286. private final int[] NATURE_RUNE = new int[]{561};
  1287. private final int[] EARTH_RUNE = new int[]{557};
  1288. private final int[] WATER_RUNE = new int[]{555};
  1289. private final int[] MUD_RUNE = new int[]{4698};
  1290. private final int[] BONES_ID = new int[]{526, 532, 530, 528, 3183, 2859};
  1291.  
  1292. private int toEatAtPercent = getRandomEatPercent();
  1293.  
  1294. //private Item foodOfChoice;
  1295. /**
  1296. * Returns a random integer of when to eat.
  1297. * @return A random integer of the percent to eat at.
  1298. */
  1299. private int getRandomEatPercent() {
  1300. return random(45, 60);
  1301. }
  1302.  
  1303. /**
  1304. * Checks if we have at least one B2P tab.
  1305. *
  1306. * @return True if we have a tab.
  1307. */
  1308. private boolean haveB2pTab() {
  1309. return Inventory.getCount(B2P_TAB_ID) > 0;
  1310. }
  1311. /**
  1312. * Checks if we have enough runes for B2B.
  1313. * @return True if we have enough runes.
  1314. */
  1315. private boolean haveB2bRunes() {
  1316. if(Inventory.getCount(true, NATURE_RUNE) > 2) {
  1317. if(Inventory.getCount(true, MUD_RUNE) >= 1 || (Inventory.getCount(true, EARTH_RUNE) >= 1 && Inventory.getCount(true, WATER_RUNE) >= 1)) {
  1318. return true;
  1319. }
  1320. }
  1321. return false;
  1322. }
  1323.  
  1324. /**
  1325. * Breaks a B2P tab.
  1326. */
  1327. private void breakB2pTab() {
  1328. Item i = Inventory.getItem(B2P_TAB_ID);
  1329. if (i != null)
  1330. i.click(true);
  1331. }
  1332.  
  1333.  
  1334. /**
  1335. * Casts B2B.
  1336. */
  1337. private void castB2b() {
  1338. Game.openTab(Game.Tabs.MAGIC);
  1339. Magic.castSpell(Magic.Modern.BONES_TO_BANANAS);
  1340. }
  1341.  
  1342.  
  1343. /**
  1344. * Checks if the Inventory contains bones, for B2P.
  1345. *
  1346. * @return True if we have bones.
  1347. */
  1348. private boolean haveBones() {
  1349. return Inventory.getCount(BONES_ID) > 0;
  1350. }
  1351.  
  1352. /**
  1353. * Checks if we have food.
  1354. *
  1355. * @return True if we have food.
  1356. */
  1357. private boolean haveFood() {
  1358. return getFood() != null;
  1359. }
  1360.  
  1361. /**
  1362. * Finds food based on Inventory actions.
  1363. *
  1364. * @return The Item of food, or null if none was found.
  1365. */
  1366. private Item getFood() {
  1367. for (Item i : Inventory.getItems()) {
  1368. if (i == null || i.getID() == -1)
  1369. continue;
  1370. if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null)
  1371. continue;
  1372. if (i.getComponent().getActions()[0].contains("Eat"))
  1373. return i;
  1374. }
  1375. return null;
  1376. }
  1377.  
  1378. /**
  1379. * Attempts to eat food.
  1380. *
  1381. * @return True if we ate.
  1382. */
  1383. private boolean eatFood() {
  1384. Item i = getFood();
  1385. for (int j = 0; j < 3; j++) {
  1386. if (i == null)
  1387. break;
  1388. if (i.interact("Eat")) {
  1389. return true;
  1390. }
  1391. }
  1392. return false;
  1393. }
  1394.  
  1395. /**
  1396. * Checks whether you need to eat or not.
  1397. *
  1398. * @return True if we need to eat.
  1399. */
  1400. private boolean needEat() {
  1401. if(getHPPercent() <= toEatAtPercent) {
  1402. toEatAtPercent = getRandomEatPercent();
  1403. return true;
  1404. }
  1405. return false;
  1406. }
  1407.  
  1408. /**
  1409. * Returns an integer representing the current health percentage.
  1410. * @return The current health percentage.
  1411. */
  1412. public int getHPPercent() {
  1413. try {
  1414. return ((int) ((Integer.parseInt(Interfaces.get(748).getComponent(8).getText().trim()) / (double)(Skills.getAbsoluteLevel(Skills.CONSTITUTION) * 10)) * 100));
  1415. } catch (Exception e) {
  1416. return 100;
  1417. }
  1418. }
  1419. }
  1420.  
  1421. private class Loot {
  1422.  
  1423. private int[] lootIDs = new int[0];
  1424. private String[] lootNames = new String[0];
  1425.  
  1426. GroundItem lastClickedItem = null;
  1427. boolean itemWasClickedLast = false;
  1428.  
  1429. private Map<String, Integer> lootTaken = new HashMap<String, Integer>();
  1430.  
  1431. boolean onlyTakeLootFromKilled = false;
  1432. /**
  1433. * Gets the nearest loot, based on the filter
  1434. *
  1435. * @return The nearest item to loot, or null if none.
  1436. */
  1437. private GroundItem getLoot() {
  1438. return GroundItems.getNearest(lootFilter);
  1439. }
  1440.  
  1441. /**
  1442. * Attempts to take an item.
  1443. *
  1444. * @param item The item to take.
  1445. * @return -1 if error, 0 if taken, 1 if walked
  1446. */
  1447. private int takeItem(GroundItem item) {
  1448. if (item == null)
  1449. return -1;
  1450. String action = "Take " + item.getItem().getName();
  1451. if (item.isOnScreen()) {
  1452. for (int i = 0; i < 5; i++) {
  1453. if (Menu.isOpen())
  1454. Mouse.moveRandomly(300, 500);
  1455. Point p = item.getLocation().toScreen(random(0.48, 0.52), random(0.48, 0.52), 0);
  1456. if (!Calculations.pointOnScreen(p))
  1457. continue;
  1458. Mouse.move(p, 3, 3);
  1459. if (Menu.contains(action)) {
  1460. if (Menu.getItems()[0].contains(action)) {
  1461. Mouse.click(true);
  1462. itemWasClickedLast = true;
  1463. u.npcs.npcWasClickedLast = false;
  1464. lastClickedItem = item;
  1465. return 0;
  1466. } else {
  1467. Mouse.click(false);
  1468. sleep(random(100, 200));
  1469. if (Menu.click(action)) {
  1470. itemWasClickedLast = true;
  1471. u.npcs.npcWasClickedLast = false;
  1472. lastClickedItem = item;
  1473. return 0;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. } else {
  1479. Walking.walkTileMM(Walking.getClosestTileOnMap(item.getLocation()));
  1480. sleep(random(1500, 2000));
  1481. if(!Players.getLocal().isMoving()) {
  1482. u.tiles.addBadTile(item.getLocation());
  1483. return -1;
  1484. }
  1485. return 1;
  1486. }
  1487. return -1;
  1488. }
  1489.  
  1490. private void addItem(String name, int count) {
  1491. if (lootTaken.get(name) != null) {
  1492. int newCount = count + lootTaken.get(name);
  1493. lootTaken.remove(name);
  1494. lootTaken.put(name, newCount);
  1495. } else {
  1496. lootTaken.put(name, count);
  1497. }
  1498. }
  1499.  
  1500. private Map<String, Integer> getLootTaken() {
  1501. HashMap<String, Integer> m = new HashMap<String, Integer>();
  1502. m.putAll(lootTaken);
  1503. return m;
  1504. }
  1505.  
  1506. private final Filter<GroundItem> lootFilter = new Filter<GroundItem>() {
  1507. public boolean accept(GroundItem t) {
  1508. //Skip if we can't hold it
  1509. Item i;
  1510. if (Inventory.isFull() && ((i = Inventory.getItem(t.getItem().getID())) == null || i.getStackSize() <= 1)) {
  1511. return false;
  1512. }
  1513. //Skip if its out of radius or far away
  1514. if (onlyInRadius && Calculations.distanceBetween(t.getLocation(), startTile) > u.npcs.maxRadius
  1515. || Calculations.distanceTo(t.getLocation()) > 25) {
  1516. return false;
  1517. }
  1518. //Check ID/name
  1519. boolean good = false;
  1520. int id = t.getItem().getID();
  1521. for (int iD : lootIDs) {
  1522. if (iD == id)
  1523. good = true;
  1524. }
  1525. String name = t.getItem().getName();
  1526. for (String s : lootNames) {
  1527. if (name != null && name.toLowerCase().contains(s.toLowerCase()))
  1528. good = true;
  1529. }
  1530. if(good){
  1531. for(Tile badTile : u.tiles.badTiles) {
  1532. if(t.getLocation().getX() == badTile.getX() && t.getLocation().getY() == badTile.getY() ) {
  1533. good = false;
  1534. break;
  1535. }
  1536. }
  1537. }
  1538. if(good && onlyTakeLootFromKilled) {
  1539. if(!u.npcs.tilesFoughtOn.isEmpty()) {
  1540. for(Tile tileFoughtOn : u.npcs.tilesFoughtOn) {
  1541. if(t.getLocation().getX() == tileFoughtOn.getX() && t.getLocation().getY() == tileFoughtOn.getY()) {
  1542. return true;
  1543. } else {
  1544. good = false;
  1545. }
  1546. }
  1547. } else {
  1548. good = false;
  1549. }
  1550. }
  1551. return good;
  1552. }
  1553. };
  1554. }
  1555.  
  1556. private class Potion {
  1557.  
  1558. private final int[] MAGIC_POTIONS = new int[] {3040, 3042, 3044, 3046, 11513, 11515, 13520, 13521, 13522, 13523};
  1559.  
  1560. private final int[] PRAYER_POTIONS = new int[] {2434, 139, 141, 143, 11465, 11467};
  1561.  
  1562. private final int[] RANGE_POTIONS = new int[] {2444, 169, 171, 173, 11509, 11511, 13524, 13525, 15326, 15327};
  1563.  
  1564. private final int[] ENERGY_POTIONS = new int[] {3008, 3010, 3012, 3014, 3016, 3018, 3020, 3022, 11453, 11455,
  1565. 11481, 11483};
  1566.  
  1567. private final int[] COMBAT_POTIONS = new int[] {9739, 9741, 9743, 9745, 11445, 11447};
  1568.  
  1569. private final int[] ATTACK_POTIONS = new int[] {2428, 121, 123, 125, 2436, 145, 147, 149, 11429, 11431,
  1570. 11429, 11431, 11429, 11431, 11469, 11471, 15308 , 15309, 15310, 15311};
  1571.  
  1572. private final int[] STRENGTH_POTIONS = new int[] {113, 115, 117, 119, 2440, 157, 159, 161, 11443, 11441,
  1573. 11485, 11487, 15312, 15313, 15314, 15315};
  1574.  
  1575. private final int[] DEFENSE_POTIONS = new int[] {2432, 133, 135, 137, 2442, 163, 165, 167, 11457, 11459,
  1576. 11497, 11499, 15316, 15317, 15318, 15319};
  1577.  
  1578. private final int[] ANTIPOISON = new int[] {2446, 175, 177, 179, 2448, 181, 183, 185, 5952, 5954,
  1579. 5956, 5958, 5943, 5945, 5947, 5949, 11433, 11435, 11501, 11503};
  1580.  
  1581. private final int[] ZAMORAK_POTIONS = new int[] {2450, 189, 191, 193, 11521, 11523};
  1582.  
  1583. private final int[] SARADOMIN_POTIONS = new int[] {6685, 6687, 6689, 6691};
  1584.  
  1585. private final int[] OVERLOAD_POTIONS = new int[] {15332, 15333, 15334, 15335};
  1586.  
  1587. private final int[] VIAL = new int[] {229};
  1588.  
  1589. private boolean setQuickPrayer = true;
  1590.  
  1591. private HashMap<String, Item[]> getPotions() {
  1592. HashMap<String, Item[]> potions = new HashMap<String, Item[]>();
  1593.  
  1594. potions.put("MAGIC", getRealItems(MAGIC_POTIONS));
  1595.  
  1596. potions.put("PRAYER", getRealItems(PRAYER_POTIONS));
  1597.  
  1598. potions.put("RANGE", getRealItems(RANGE_POTIONS));
  1599.  
  1600. potions.put("ENERGY", getRealItems(ENERGY_POTIONS));
  1601.  
  1602. potions.put("COMBAT", getRealItems(COMBAT_POTIONS));
  1603.  
  1604. potions.put("ATTACK", getRealItems(ATTACK_POTIONS));
  1605.  
  1606. potions.put("STRENGTH", getRealItems(STRENGTH_POTIONS));
  1607.  
  1608. potions.put("DEFENSE", getRealItems(DEFENSE_POTIONS));
  1609.  
  1610. potions.put("ANTIPOISON", getRealItems(ANTIPOISON));
  1611.  
  1612. potions.put("ZAMORAK", getRealItems(ZAMORAK_POTIONS));
  1613.  
  1614. potions.put("SARADOMIN", getRealItems(SARADOMIN_POTIONS));
  1615.  
  1616. potions.put("OVERLOAD", getRealItems(OVERLOAD_POTIONS));
  1617.  
  1618. return potions;
  1619. }
  1620.  
  1621. public void usePotions() {
  1622. HashMap<String, Item[]> potions = u.pot.getPotions();
  1623.  
  1624. if(Inventory.getItems(VIAL).length != 0) {
  1625. for( Item i : Inventory.getItems(VIAL)) {
  1626. int n = Inventory.getCount(true);
  1627. i.interact("Drop Vial");
  1628. waitForInvChange(n);
  1629. }
  1630. }
  1631.  
  1632. if(!(u.pot.statIsBoosted(Skills.MAGIC)) && (potions.get("MAGIC").length != 0 || potions.get("OVERLOAD").length != 0)) {
  1633. if(potions.get("MAGIC").length != 0) {
  1634. potions.get("MAGIC")[0].click(true);
  1635. }
  1636. else if(potions.get("OVERLOAD").length != 0) {
  1637. potions.get("OVERLOAD")[0].click(true);
  1638. }
  1639. }
  1640.  
  1641. if(shouldUsePrayerPot() && potions.get("PRAYER").length != 0 && setQuickPrayer) {
  1642. int current = Prayer.getRemainingPoints();
  1643. if(potions.get("PRAYER")[0].click(true)) {
  1644. long time = System.currentTimeMillis();
  1645. while(Prayer.getRemainingPoints() == current && System.currentTimeMillis() - time < 10000) {
  1646. sleep(random(200, 500));
  1647. }
  1648. }
  1649. }
  1650.  
  1651. if(!(u.pot.statIsBoosted(Skills.RANGE)) && (potions.get("RANGE").length != 0 || potions.get("OVERLOAD").length != 0)) {
  1652. if(potions.get("RANGE").length != 0) {
  1653. potions.get("RANGE")[0].click(true);
  1654. }
  1655. else if(potions.get("OVERLOAD").length != 0) {
  1656. potions.get("OVERLOAD")[0].click(true);
  1657. }
  1658. }
  1659.  
  1660. if(Walking.getEnergy() < random(40, 70) && potions.get("ENERGY").length != 0) {
  1661. potions.get("ENERGY")[0].click(true);
  1662. }
  1663.  
  1664. if(!(u.pot.statIsBoosted(Skills.STRENGTH)) && (potions.get("STRENGTH").length != 0 || potions.get("COMBAT").length != 0 || potions.get("ZAMORAK").length != 0 || potions.get("OVERLOAD").length != 0)) {
  1665. if(potions.get("COMBAT").length != 0) {
  1666. potions.get("COMBAT")[0].click(true);
  1667. }
  1668. else if(potions.get("STRENGTH").length != 0) {
  1669. potions.get("STRENGTH")[0].click(true);
  1670. }
  1671. else if(potions.get("ZAMORAK").length != 0) {
  1672. potions.get("ZAMORAK")[0].click(true);
  1673. }
  1674. else if(potions.get("OVERLOAD").length != 0) {
  1675. potions.get("OVERLOAD")[0].click(true);
  1676. }
  1677. }
  1678.  
  1679. if(!(u.pot.statIsBoosted(Skills.DEFENSE)) && (potions.get("DEFENSE").length != 0 || potions.get("SARADOMIN").length != 0 || potions.get("OVERLOAD").length != 0)) {
  1680. if(potions.get("DEFENSE").length != 0) {
  1681. potions.get("DEFENSE")[0].click(true);
  1682. }
  1683. else if(potions.get("SARADOMIN").length != 0) {
  1684. potions.get("SARADOMIN")[0].click(true);
  1685. }
  1686. else if(potions.get("OVERLOAD").length != 0) {
  1687. potions.get("OVERLOAD")[0].click(true);
  1688. }
  1689. }
  1690.  
  1691. if(!(u.pot.statIsBoosted(Skills.ATTACK)) && (potions.get("ATTACK").length != 0 || potions.get("COMBAT").length != 0 || potions.get("ZAMORAK").length != 0 || potions.get("OVERLOAD").length != 0)) {
  1692. if(potions.get("COMBAT").length != 0) {
  1693. potions.get("COMBAT")[0].click(true);
  1694. }
  1695. else if(potions.get("ATTACK").length != 0) {
  1696. potions.get("ATTACK")[0].click(true);
  1697. }
  1698. else if(potions.get("ZAMORAK").length != 0) {
  1699. potions.get("ZAMORAK")[0].click(true);
  1700. }
  1701. else if(potions.get("OVERLOAD").length != 0) {
  1702. potions.get("OVERLOAD")[0].click(true);
  1703. }
  1704. }
  1705.  
  1706. if(isPoisoned() && potions.get("ANTIPOISON").length != 0) {
  1707. potions.get("ANTIPOISON")[0].click(true);
  1708. }
  1709. }
  1710.  
  1711. private boolean isPoisoned() {
  1712. return Settings.get(102) > 0 || Interfaces.getComponent(748, 4).getTextureID() == 1801;
  1713. }
  1714.  
  1715.  
  1716. private boolean statIsBoosted(int Skill) {
  1717. return Skills.getLevel(Skill) != Skills.getAbsoluteLevel(Skill);
  1718. }
  1719.  
  1720. private boolean shouldUsePrayerPot() {
  1721. return (Skills.getAbsoluteLevel(Skills.PRAYER) - Prayer.getRemainingPoints()) > (7+Math.floor(Skills.getAbsoluteLevel(Skills.PRAYER)/4));
  1722. }
  1723.  
  1724. public Item[] getRealItems(int[] ids) {
  1725. Item[] raw = Inventory.getItems(ids);
  1726. ArrayList<Item> refined = new ArrayList<Item>();
  1727. for(Item item : raw) {
  1728. if(item != null) {
  1729. if(item.getID() != -1) {
  1730. refined.add(item);
  1731. }
  1732. }
  1733. }
  1734. return refined.toArray(new Item[refined.size()]);
  1735. }
  1736. }
  1737.  
  1738. private class Alchemy {
  1739. private int[] alchIDs = new int[0];
  1740. private String[] alchNames = new String[0];
  1741. private final int[] NATURE_RUNE = new int[]{561};
  1742. private final int[] FIRE_RUNE = new int[]{554};
  1743. private final int[] COINS= new int[]{995};
  1744.  
  1745. private boolean canAlch() {
  1746. if(Inventory.getCount(true, NATURE_RUNE) >= 1 && (Inventory.getCount(true, FIRE_RUNE) >= 5 ||
  1747. u.npcs.weapon.toLowerCase().contains("fire") || u.npcs.weapon.toLowerCase().contains("steam")
  1748. || u.npcs.weapon.toLowerCase().contains("lava")) && (Inventory.getCount(COINS) > 0 ||
  1749. Inventory.getCount() <= 27) && Skills.getLevel(Skills.MAGIC) >= 55) {
  1750. return true;
  1751. }
  1752. else if(Inventory.getCount(true, NATURE_RUNE) >= 1 && Inventory.getCount(true, FIRE_RUNE) >= 3 && (Inventory.getCount(COINS) > 0 || Inventory.getCount() <= 27) && Skills.getLevel(Skills.MAGIC) >= 21) {
  1753. return true;
  1754. }
  1755. return false;
  1756. }
  1757.  
  1758. private boolean hasAlchItems() {
  1759. if(alchNames.length > 0 || alchIDs.length > 0)
  1760. {
  1761. for( Item i : Inventory.getItems()) {
  1762. for ( String s : u.alch.alchNames) {
  1763. if (i.getComponent() != null && i.getID() != -1 && i.getName().toLowerCase().contains(s)) {
  1764. return true;
  1765. }
  1766. }
  1767. for ( int n : u.alch.alchIDs) {
  1768. if( n == i.getID()) {
  1769. return true;
  1770. }
  1771. }
  1772. }
  1773. }
  1774. return false;
  1775. }
  1776.  
  1777.  
  1778. private void alch(InterfaceComponent i) {
  1779. if (i != null) {
  1780. if(Inventory.getCount(true, NATURE_RUNE) >= 1 && (Inventory.getCount(true, FIRE_RUNE) >= 5 ||
  1781. u.npcs.weapon.toLowerCase().contains("fire") || u.npcs.weapon.toLowerCase().contains("steam") ||
  1782. u.npcs.weapon.toLowerCase().contains("lava")) && Skills.getLevel(Skills.MAGIC) >= 55) {
  1783.  
  1784. if(Game.getCurrentTab() != Game.Tabs.MAGIC) {
  1785. Game.openTab(Game.Tabs.MAGIC);
  1786. }
  1787. Magic.castSpell(Magic.Modern.HIGH_LEVEL_ALCHEMY);
  1788. }
  1789. else if(Inventory.getCount(true, NATURE_RUNE) >= 1 && (Inventory.getCount(true, FIRE_RUNE) >= 5 ||
  1790. u.npcs.weapon.toLowerCase().contains("fire") || u.npcs.weapon.toLowerCase().contains("steam") ||
  1791. u.npcs.weapon.toLowerCase().contains("lava")) && Skills.getLevel(Skills.MAGIC) >= 21) {
  1792.  
  1793. if(Game.getCurrentTab() != Game.Tabs.MAGIC) {
  1794. Game.openTab(Game.Tabs.MAGIC);
  1795. }
  1796. Magic.castSpell(Magic.Modern.LOW_LEVEL_ALCHEMY);
  1797. }
  1798. sleep(random(150, 500));
  1799. i.interact("Cast");
  1800. }
  1801. }
  1802. }
  1803.  
  1804. private class Paint {
  1805. BufferedImage ribbon = null;
  1806. BufferedImage stableRug = null;
  1807. BufferedImage skillsRug = null;
  1808. Font KellyAnnGothic = null;
  1809. boolean showPaint = false;
  1810. boolean showMain = false;
  1811. boolean showSkills = false;
  1812. boolean showLoot = false;
  1813. // public ExchangePriceGetter priceGetter;
  1814.  
  1815. boolean useAdvancedPaint = true;
  1816. private Paint() {
  1817. try {
  1818. ribbon = ImageIO.read(new URL("http://scripters.powerbot.org/585097/Paint/pentagon_tag.png"));
  1819. stableRug = ImageIO.read(new URL("http://scripters.powerbot.org/585097/Paint/rug.png"));
  1820. skillsRug = ImageIO.read(new URL("http://scripters.powerbot.org/585097/Paint/rug1.png"));
  1821. URL fontURL = new URL("http://scripters.powerbot.org/585097/Paint/kellyag.ttf");
  1822. URLConnection fontDownload = fontURL.openConnection();
  1823. KellyAnnGothic = Font.createFont(Font.TRUETYPE_FONT, fontDownload.getInputStream());
  1824. // priceGetter = new ExchangePriceGetter();
  1825. // priceGetter.start();
  1826. } catch (Exception e){
  1827. useAdvancedPaint = false;
  1828. }
  1829. }
  1830.  
  1831. public int getExpPerHour(int Skill) {
  1832. double entry = u.sw.getExpGainedIn(Skill);
  1833. int runTime = (int) System.currentTimeMillis() - startTime;
  1834. double expPerSec = entry / (runTime / 1000);
  1835. return((int) Math.round(expPerSec * 3600));
  1836. }
  1837.  
  1838. // private class ExchangePriceGetter extends Thread {
  1839. // HashMap<String, Integer> prices = new HashMap<String, Integer>();
  1840. // boolean stopThread = false;
  1841. //
  1842. // public ExchangePriceGetter() {
  1843. // setDaemon(true);
  1844. // setPriority(2);
  1845. // }
  1846. //
  1847. // public void safeStop() {
  1848. // stopThread = true;
  1849. // }
  1850. //
  1851. // public void run() {
  1852. // Map<String, Integer> lootTaken;
  1853. // while(!stopThread){
  1854. // if(u != null) {
  1855. // lootTaken = u.loot.getLootTaken();
  1856. // for(Map.Entry<String, Integer> lootEntry: lootTaken.entrySet()) {
  1857. // if(!prices.containsKey(lootEntry.getKey())) {
  1858. // if(lootEntry.getKey().equals("Coins")) {
  1859. // prices.put("Coins", 1);
  1860. // }
  1861. // GrandExchange.GEItem item = grandExchange.lookup(lootEntry.getKey());
  1862. // if(item != null) {
  1863. // prices.put(item.getName(), item.getGuidePrice());
  1864. // }
  1865. // }
  1866. // }
  1867. // }
  1868. // try{ sleep(5000); } catch (Exception ignored) {}
  1869. // }
  1870. // }
  1871. // }
  1872. }
  1873.  
  1874. private class SkillWatcher {
  1875.  
  1876. private HashMap<Integer, Integer> startExpMap = new HashMap<Integer, Integer>();
  1877. private final int[] SKILLS_TO_WATCH = new int[]{Skills.SLAYER, Skills.CONSTITUTION, Skills.ATTACK, Skills.STRENGTH, Skills.DEFENSE, Skills.RANGE, Skills.MAGIC, Skills.PRAYER};
  1878. private HashMap<Integer, Integer> startLevelsMap = new HashMap<Integer, Integer>();
  1879. /**
  1880. * Basically sets start exp for all Skills we are watching.
  1881. */
  1882. private void poll() {
  1883. for (int skill : SKILLS_TO_WATCH) {
  1884. if (startExpMap.containsKey(skill)) {
  1885. startExpMap.remove(skill);
  1886. }
  1887. if (startLevelsMap.containsKey(skill)) {
  1888. startLevelsMap.remove(skill);
  1889. }
  1890. startExpMap.put(skill, Skills.getExperience(skill));
  1891. startLevelsMap.put(skill, Skills.getAbsoluteLevel(skill));
  1892. }
  1893. }
  1894.  
  1895. /**
  1896. * Returns the amount of exp gained in the specified skill.
  1897. *
  1898. * @param skill The skill see Skills.*
  1899. * @return the EXP Gained
  1900. */
  1901. private int getExpGainedIn(int skill) {
  1902. if (startExpMap.get(skill) == null)
  1903. return -1;
  1904. return Skills.getExperience(skill) - startExpMap.get(skill);
  1905. }
  1906.  
  1907. // --Commented out by Inspection START (7/24/11 10:18 PM):
  1908. // private int getExpStart(int skill) {
  1909. // if (startExpMap.get(skill) == null)
  1910. // return -1;
  1911. // return startExpMap.get(skill);
  1912. // }
  1913. // --Commented out by Inspection STOP (7/24/11 10:18 PM)
  1914.  
  1915. private int getLevelsGainedIn(int skill) {
  1916. return Skills.getAbsoluteLevel(skill) - startLevelsMap.get(skill);
  1917. }
  1918.  
  1919.  
  1920. /**
  1921. * Returns a map of skill names and exp gained.
  1922. *
  1923. * @return A map of exp gains and skill names.
  1924. */
  1925. private Map<String, Integer> getExpGainedMap() {
  1926. Map<String, Integer> map = new HashMap<String, Integer>();
  1927. for (int i : SKILLS_TO_WATCH) {
  1928. int gained = getExpGainedIn(i);
  1929. if (gained != 0)
  1930. map.put(Skills.SKILL_NAMES[i], gained);
  1931. }
  1932. return map;
  1933. }
  1934.  
  1935. }
  1936.  
  1937. @SuppressWarnings({"ResultOfMethodCallIgnored"})
  1938. private class VersionChecker extends Thread {
  1939. public void run() {
  1940. try {
  1941. Properties versionInfo = new Properties();
  1942. URL url = new URL("http://scripters.powerbot.org/files/349221/" + branch + "/Version.txt");
  1943. URLConnection conn = url.openConnection();
  1944. conn.setConnectTimeout(10 * 1000);
  1945. conn.setReadTimeout(10 * 1000);
  1946. versionInfo.load( new BufferedReader(new InputStreamReader(conn.getInputStream())));
  1947. if(Double.parseDouble(versionInfo.getProperty(branch + "Version")) > mani.version()) {
  1948. if (SwingUtilities.isEventDispatchThread()) {
  1949. Object[] options = {"Yes.", "No."};
  1950. int answer = JOptionPane.showOptionDialog(null, "A new version of RFighter (" + branch + ") is available. \r\n" +
  1951. "Would you like to download it?", "New Version Available!", JOptionPane.YES_NO_OPTION,
  1952. JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
  1953. if(answer == 0) {
  1954. String sourceURL = "http://scripters.powerbot.org/files/349221/" + branch + "/RFighter.java";
  1955. log("Downloading: " + sourceURL);
  1956. final File classFile = new File(Configuration.Paths.getScriptsSourcesDirectory() + File.separator
  1957. + "RFighter.java");
  1958. try {
  1959. HttpClient.download(new URL(sourceURL), classFile);
  1960. } catch (Exception e) {
  1961. classFile.delete();
  1962. JOptionPane.showMessageDialog(null, "Could not download script");
  1963. }
  1964. if(classFile.exists()) {
  1965. JOptionPane.showMessageDialog(null, "Please Recompile Scripts!");
  1966. }
  1967. zui.dispose();
  1968. container.stop();
  1969. }
  1970. } else {
  1971. SwingUtilities.invokeAndWait(new Runnable() {
  1972. public void run() {
  1973. Object[] options = {"Yes.", "No."};
  1974. int answer = JOptionPane.showOptionDialog(null, "A new version of RFighter (" + branch + ") is available. \r\n" +
  1975. "Would you like to download it?", "New Version Available!", JOptionPane.YES_NO_OPTION,
  1976. JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
  1977. if(answer == 0) {
  1978. String sourceURL = "http://scripters.powerbot.org/files/349221/" + branch + "/RFighter.java";
  1979. log("Downloading: " + sourceURL);
  1980. final File classFile = new File(Configuration.Paths.getScriptsSourcesDirectory() + File.separator
  1981. + "RFighter.java");
  1982. if(classFile.exists()) {
  1983. classFile.delete();
  1984. }
  1985. try {
  1986. HttpClient.download(new URL(sourceURL), classFile);
  1987. } catch (Exception e) {
  1988. if(classFile.exists()) {
  1989. classFile.delete();
  1990. }
  1991. JOptionPane.showMessageDialog(null, "Could not download script");
  1992. }
  1993. if(classFile.exists()) {
  1994. JOptionPane.showMessageDialog(null, "Please Recompile Scripts!");
  1995. autoDownloaded = true;
  1996. }
  1997. }
  1998. }
  1999. });
  2000. if(autoDownloaded) {
  2001. zui.dispose();
  2002. container.stop();
  2003. }
  2004. }
  2005. }
  2006. } catch (SocketTimeoutException stw) {
  2007. log("Powerbot is currently being DDoS'd!");
  2008. u.paint.useAdvancedPaint = false;
  2009. } catch (Exception e) {
  2010. log(e.getMessage());
  2011. u.paint.useAdvancedPaint = false;
  2012. }
  2013. }
  2014. }
  2015.  
  2016. // private class Banking {
  2017. //
  2018. // boolean bankingEnabled = false;
  2019. // boolean depositLoot = false;
  2020. // boolean depositBones = false;
  2021. // boolean withdrawFood = false;
  2022. //
  2023. // boolean needBankforFood = false;
  2024. // int minimumFood = 5;
  2025. // int maximumFood = 7;
  2026. //
  2027. // boolean shouldWalkHome = false;
  2028. // boolean isInBank = false;
  2029. //
  2030. //
  2031. // private boolean needsBank() {
  2032. // if(bankingEnabled) {
  2033. // if(depositLoot && Inventory.getCount(false) == 28 && !u.loot.getLootTaken().isEmpty() || needBankforFood) {
  2034. // if (needBankforFood && !u.eat.haveFood()) {
  2035. // return true;
  2036. // }
  2037. // int iii = 0;
  2038. // boolean containsBones = false;
  2039. // for(Map.Entry<String, Integer> entry : u.loot.getLootTaken().entrySet()) {
  2040. // if(entry.getKey().contains("Bones")) {
  2041. // containsBones = true;
  2042. // }
  2043. // iii++;
  2044. // }
  2045. //
  2046. // if(iii == 1 && containsBones && !u.bank.depositBones) {
  2047. // return false;
  2048. // }
  2049. // return true;
  2050. // }
  2051. // }
  2052. // return false;
  2053. // }
  2054. //
  2055. // private void withdraw() {
  2056. // if(Inventory.getCount(false) < 28 && !u.eat.haveFood() && u.eat.foodOfChoice != null) {
  2057. // Item bankItem = Bank.getItem(u.eat.foodOfChoice.getID());
  2058. // if (bankItem == null || bankItem.getID() == -1) {
  2059. // log(Color.RED, "Banking Error!");
  2060. // container.stop();
  2061. // }
  2062. // assert bankItem != null;
  2063. // InterfaceComponent bankItemComponent = bankItem.getComponent();
  2064. // if (bankItemComponent == null) {
  2065. // log(Color.RED, "Banking Error!");
  2066. // container.stop();
  2067. // }
  2068. // int t = 0;
  2069. // assert bankItemComponent != null;
  2070. // while (bankItemComponent.getRelativeX() == 0 && Bank.getCurrentTab() != 0 && t < 5) {
  2071. // if (Interfaces.getComponent(Bank.INTERFACE_BANK, Bank.INTERFACE_BANK_TAB[0]).click()) {
  2072. // sleep(random(800, 1300));
  2073. // }
  2074. // t++;
  2075. // }
  2076. // if (!Interfaces.scrollTo(bankItemComponent, (Bank.INTERFACE_BANK << 16) + Bank.INTERFACE_BANK_SCROLLBAR)) {
  2077. // log(Color.RED, "Banking Error!");
  2078. // container.stop();
  2079. // }
  2080. // boolean withdrew = false;
  2081. // for(int iii = 0; iii < 10; iii++) {
  2082. // bankItemComponent.click(false);
  2083. // if(Menu.isOpen()) {
  2084. // int origCount = Inventory.getCount(true);
  2085. // bankItemComponent.interact("Withdraw-X");
  2086. // sleep(1000);
  2087. // Keyboard.sendText(String.valueOf(random(minimumFood, maximumFood)), true);
  2088. // if(waitForInvChange(origCount, 5000)) {
  2089. // withdrew = true;
  2090. // break;
  2091. // } else {
  2092. // Keyboard.sendText("", true);
  2093. // }
  2094. // }
  2095. // }
  2096. // if(!withdrew) {
  2097. // log(Color.RED, "Banking Error!");
  2098. // container.stop();
  2099. // }
  2100. // needBankforFood = false;
  2101. // }
  2102. // }
  2103. //
  2104. // private void deposit() {
  2105. // Set<Map.Entry<String, Integer>> entries = u.loot.getLootTaken().entrySet();
  2106. // Item[] items = Inventory.getItems();
  2107. // ArrayList<Integer> alreadyDeposited = new ArrayList<Integer>();
  2108. // for(Map.Entry<String, Integer> entry : entries) {
  2109. // for(Item item : items) {
  2110. // if(item != null && item.getID() != -1 && !alreadyDeposited.contains(item.getID())) {
  2111. // if (item.getName().equals(entry.getKey())) {
  2112. // if(!item.getName().contains("Bones") || (item.getName().contains("Bones") && u.bank.depositBones)) {
  2113. // int origCount = Inventory.getCount(true);
  2114. // int itemCount = Inventory.getCount(true, item.getID());
  2115. // boolean deposited = false;
  2116. //
  2117. // InterfaceComponent freeSpace, freeItems, memSpace, memItems;
  2118. //
  2119. // freeSpace = Interfaces.getComponent(762, 29);
  2120. // freeItems = Interfaces.getComponent(762, 30);
  2121. //
  2122. // memSpace = Interfaces.getComponent(762, 31);
  2123. // memItems = Interfaces.getComponent(762, 32);
  2124. //
  2125. // if(freeSpace.getText().equals(freeItems.getText())
  2126. // || memSpace.getText().equals(memItems.getText())) {
  2127. // log(Color.RED, "You Ran Out Of Bank Space! Stopping Script!");
  2128. // container.stop();
  2129. // }
  2130. //
  2131. // for(int iii = 0; iii < 10; iii++) {
  2132. // item.interact(itemCount > 1 ? "Deposit-All" : "Deposit");
  2133. // if(waitForInvChange(origCount, 5000)) {
  2134. // deposited = true;
  2135. // break;
  2136. // }
  2137. // }
  2138. //
  2139. // if(deposited) {
  2140. // alreadyDeposited.add(item.getID());
  2141. // } else {
  2142. // log(Color.RED, "Banking Error!");
  2143. // container.stop();
  2144. // }
  2145. // }
  2146. // }
  2147. // }
  2148. // }
  2149. // }
  2150. // }
  2151. //
  2152. // }
  2153.  
  2154. private class Tiles {
  2155. ArrayList<Tile> badTiles = new ArrayList<Tile>();
  2156. int threshold = 5;
  2157.  
  2158. public void addBadTile(Tile tile) {
  2159. addBadTile(tile, threshold);
  2160. }
  2161.  
  2162. public void addBadTile(Tile tile, int thres) {
  2163. if(thres > -1) {
  2164. if (badTiles.size() > 0) {
  2165.  
  2166. ArrayList<Tile> tilesWithinRadius = new ArrayList<Tile>();
  2167.  
  2168. for(Tile badTile : badTiles) {
  2169. if(Calculations.distanceBetween(badTile, tile) < thres) {
  2170. tilesWithinRadius.add(badTile);
  2171. }
  2172. }
  2173.  
  2174. if (tilesWithinRadius.size() > 1){
  2175. tilesWithinRadius.add(tile);
  2176. Area temp = new Area(tilesWithinRadius.toArray(new Tile[tilesWithinRadius.size()]));
  2177. Tile[] areaTiles = temp.getTileArray();
  2178. for(Tile tileToAdd : areaTiles) {
  2179. if(!badTiles.contains(tileToAdd)) {
  2180. badTiles.add(tileToAdd);
  2181. }
  2182. }
  2183. if(!badTiles.contains(tile)) {
  2184. badTiles.add(tile);
  2185. }
  2186.  
  2187. } else {
  2188. if(!badTiles.contains(tile)) {
  2189. badTiles.add(tile);
  2190. }
  2191. }
  2192. } else {
  2193. badTiles.add(tile);
  2194. }
  2195. }
  2196. }
  2197.  
  2198. @SuppressWarnings({"BooleanMethodIsAlwaysInverted"})
  2199. private boolean NPCisOnBadTile(NPC t) {
  2200. for(Tile badTile: badTiles) {
  2201. if(t.getLocation().getX() == badTile.getX() &&
  2202. t.getLocation().getY() == badTile.getY() ) {
  2203. return true;
  2204. }
  2205. }
  2206. return false;
  2207. }
  2208.  
  2209. }
  2210.  
  2211. @SuppressWarnings({"serial", "ResultOfMethodCallIgnored"})
  2212. private class ZUI extends JFrame {
  2213.  
  2214. private final File file = new File(Configuration.Paths.getStorageDirectory() + File.separator + "RFighter.txt");
  2215.  
  2216. private JCheckBox useMulti, useRadius, useSafe, useCentral, disableSpecials, prioritizeLoot, onlyLoot, useBones,
  2217. useOldPaint/**, depositLoot, depositBones, withdrawFood, enableBanking**/;
  2218.  
  2219. private JTextField npcBox, lootBox, alchBox, mouseSpeedBox, thresholdBox/**, foodBox**/;
  2220.  
  2221. private JButton start;
  2222.  
  2223. private ZUI() {
  2224. init();
  2225. pack();
  2226. }
  2227.  
  2228. private void init() {
  2229. Properties props = loadProperties();
  2230.  
  2231. JPanel north = new JPanel(new FlowLayout());
  2232. north.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  2233. {
  2234. JLabel title = new JLabel("Renatus Fighter");
  2235. title.setFont(new Font("Arial", Font.PLAIN, 24));
  2236. north.add(title);
  2237. }
  2238. add(north, BorderLayout.NORTH);
  2239.  
  2240. JPanel center = new JPanel();
  2241. center.setLayout(new BoxLayout(center, BoxLayout.PAGE_AXIS));
  2242. center.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  2243. {
  2244. JPanel combat = new JPanel();
  2245. combat.setLayout(new BoxLayout(combat, BoxLayout.PAGE_AXIS));
  2246. combat.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  2247. {
  2248. JLabel title = new JLabel("Combat");
  2249. JLabel npcLabel = new JLabel("Enter the names/ ids of the monsters to fight");
  2250. npcBox = new JTextField("barbarian,278,dragon");
  2251. useMulti = new JCheckBox("Attack monsters that are fighting others");
  2252. useRadius = new JCheckBox("Stay within a radius (Applies to loot too.)");
  2253. useSafe = new JCheckBox("Use a safespot");
  2254. useCentral = new JCheckBox("Use central point on NPC");
  2255. disableSpecials = new JCheckBox("Disable special attacks");
  2256.  
  2257. title.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2258. npcLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2259. npcBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
  2260. useMulti.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2261. useRadius.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2262. useSafe.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2263. useCentral.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2264. disableSpecials.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2265.  
  2266. npcBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, npcBox.getPreferredSize().height));
  2267. npcBox.setColumns(25);
  2268.  
  2269. if (props.getProperty("npcBox") != null) {
  2270. npcBox.setText(props.getProperty("npcBox"));
  2271. }
  2272. if (props.getProperty("useMulti") != null) {
  2273. if (props.getProperty("useMulti").equals("true"))
  2274. useMulti.setSelected(true);
  2275. }
  2276. if (props.getProperty("useRadius") != null) {
  2277. if (props.getProperty("useRadius").equals("true"))
  2278. useRadius.setSelected(true);
  2279. }
  2280. if(props.getProperty("useSafe") != null) {
  2281. if(props.getProperty("useSafe").equals("true"))
  2282. useSafe.setSelected(true);
  2283. }
  2284. if(props.getProperty("useCentral") != null) {
  2285. if(props.getProperty("useCentral").equals("true"))
  2286. useCentral.setSelected(true);
  2287. }
  2288. if(props.getProperty("disableSpecials") != null) {
  2289. if(props.get("disableSpecials").equals("true"))
  2290. disableSpecials.setSelected(true);
  2291. }
  2292.  
  2293. combat.add(title);
  2294. combat.add(new JLabel(" "));
  2295. combat.add(npcLabel);
  2296. combat.add(npcBox);
  2297. combat.add(new JLabel(" "));
  2298. combat.add(useMulti);
  2299. combat.add(useRadius);
  2300. combat.add(useSafe);
  2301. combat.add(useCentral);
  2302. combat.add(disableSpecials);
  2303. combat.add(Box.createVerticalGlue());
  2304. combat.add(Box.createRigidArea(new Dimension(1,1)));
  2305. }
  2306.  
  2307. JPanel loot = new JPanel();
  2308. loot.setLayout(new BoxLayout(loot, BoxLayout.PAGE_AXIS));
  2309. loot.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  2310. {
  2311. JLabel title = new JLabel("Loot");
  2312. JLabel lootLabel = new JLabel("Enter the names/ ids of the loot to pick up");
  2313. lootBox = new JTextField("arrow,rune");
  2314. prioritizeLoot = new JCheckBox("Loot while fighting");
  2315. onlyLoot = new JCheckBox("Only loot from monsters you kill");
  2316.  
  2317. title.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2318. lootLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2319. lootBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
  2320. prioritizeLoot.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2321. onlyLoot.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2322.  
  2323. lootBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, lootBox.getPreferredSize().height));
  2324. lootBox.setColumns(25);
  2325.  
  2326. if (props.getProperty("lootBox") != null) {
  2327. lootBox.setText(props.getProperty("lootBox"));
  2328. }
  2329. if(props.getProperty("onlyLoot") != null) {
  2330. if(props.get("onlyLoot").equals("true"))
  2331. onlyLoot.setSelected(true);
  2332. }
  2333. if(props.getProperty("prioritizeLoot") != null) {
  2334. if(props.get("prioritizeLoot").equals("true"))
  2335. prioritizeLoot.setSelected(true);
  2336. }
  2337.  
  2338. loot.add(title);
  2339. loot.add(new JLabel(" "));
  2340. loot.add(lootLabel);
  2341. loot.add(lootBox);
  2342. loot.add(new JLabel(" "));
  2343. loot.add(prioritizeLoot);
  2344. loot.add(onlyLoot);
  2345. loot.add(Box.createVerticalGlue());
  2346. loot.add(Box.createRigidArea(new Dimension(1,1)));
  2347. }
  2348.  
  2349. // JPanel bank = new JPanel();
  2350. // bank.setLayout(new BoxLayout(bank, BoxLayout.PAGE_AXIS));
  2351. // bank.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  2352. // {
  2353. // JLabel title = new JLabel("Bank");
  2354. // JLabel bankLabel1 = new JLabel("WARNING: EXPERIMENTAL");
  2355. // JLabel bankLabel2 = new JLabel("ONLY WORKS ON GROUND LEVEL");
  2356. //
  2357. // enableBanking = new JCheckBox("Enable banking");
  2358. // depositLoot = new JCheckBox("Deposit Loot");
  2359. // depositBones = new JCheckBox("Deposit Bones");
  2360. // withdrawFood = new JCheckBox("Withdraw Food");
  2361. // foodBox = new JTextField("5,7");
  2362. //
  2363. // title.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2364. // bankLabel1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2365. // bankLabel2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2366. // enableBanking.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2367. // depositLoot.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2368. // depositBones.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2369. // withdrawFood.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2370. // foodBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
  2371. //
  2372. // foodBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, foodBox.getPreferredSize().height));
  2373. // foodBox.setColumns(25);
  2374. //
  2375. // enableBanking.addActionListener(disableAllBankingOptions);
  2376. // depositLoot.addActionListener(disableDepositBones);
  2377. // withdrawFood.addActionListener(disableFoodBox);
  2378. //
  2379. // if (props.getProperty("depositLoot") != null) {
  2380. // if (props.getProperty("depositLoot").equals("true"))
  2381. // depositLoot.setSelected(true);
  2382. // }
  2383. //
  2384. // if (props.getProperty("depositBones") != null) {
  2385. // if (props.getProperty("depositBones").equals("true"))
  2386. // depositBones.setSelected(true);
  2387. // }
  2388. //
  2389. // if (props.getProperty("withdrawFood") != null) {
  2390. // if (props.getProperty("withdrawFood").equals("true")) {
  2391. // withdrawFood.setSelected(true);
  2392. // foodBox.setEnabled(true);
  2393. // } else {
  2394. // foodBox.setEnabled(false);
  2395. // }
  2396. // }
  2397. //
  2398. // if (props.getProperty("enableBanking") != null) {
  2399. // if (props.getProperty("enableBanking").equals("true")) {
  2400. // enableBanking.setSelected(true);
  2401. // } else {
  2402. // depositLoot.setSelected(false);
  2403. // depositBones.setSelected(false);
  2404. // withdrawFood.setSelected(false);
  2405. // depositLoot.setEnabled(false);
  2406. // depositBones.setEnabled(false);
  2407. // withdrawFood.setEnabled(false);
  2408. // foodBox.setEnabled(false);
  2409. // }
  2410. // } else {
  2411. // depositLoot.setSelected(false);
  2412. // depositBones.setSelected(false);
  2413. // withdrawFood.setSelected(false);
  2414. // depositLoot.setEnabled(false);
  2415. // depositBones.setEnabled(false);
  2416. // withdrawFood.setEnabled(false);
  2417. // foodBox.setEnabled(false);
  2418. // }
  2419. //
  2420. // bank.add(title);
  2421. // bank.add(new JLabel(" "));
  2422. // bank.add(bankLabel1);
  2423. // bank.add(bankLabel2);
  2424. // bank.add(new JLabel(" "));
  2425. // bank.add(enableBanking);
  2426. // bank.add(new JLabel(" "));
  2427. // bank.add(depositLoot);
  2428. // bank.add(depositBones);
  2429. // bank.add(new JLabel(" "));
  2430. // bank.add(withdrawFood);
  2431. // bank.add(foodBox);
  2432. // bank.add(Box.createVerticalGlue());
  2433. // bank.add(Box.createRigidArea(new Dimension(1,1)));
  2434. // }
  2435.  
  2436. JPanel misc = new JPanel();
  2437. misc.setLayout(new BoxLayout(misc, BoxLayout.PAGE_AXIS));
  2438. misc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  2439. {
  2440. JLabel miscLabel = new JLabel("Miscellaneous Settings");
  2441. JLabel mouseLabel = new JLabel("Mouse Speed: Lower = Faster");
  2442. mouseSpeedBox = new JTextField("4,7");
  2443. JLabel thresholdLabel = new JLabel("Threshold for bad tile checking: -1 to turn off");
  2444. thresholdBox = new JTextField("5");
  2445. JLabel alchLabel = new JLabel("Enter the ids/ names of items to alch");
  2446. alchBox = new JTextField("");
  2447. useBones = new JCheckBox("Bury the bones you loot");
  2448. useOldPaint = new JCheckBox("Use simple paint");
  2449.  
  2450. miscLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2451. mouseLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2452. mouseSpeedBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
  2453. thresholdLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2454. thresholdBox.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2455. alchLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2456. alchBox.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2457. useBones.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2458. useOldPaint.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
  2459.  
  2460. mouseSpeedBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, mouseSpeedBox.getPreferredSize().height));
  2461. thresholdBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, thresholdBox.getPreferredSize().height));
  2462. alchBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, alchBox.getPreferredSize().height));
  2463.  
  2464. mouseSpeedBox.setColumns(25);
  2465. thresholdBox.setColumns(25);
  2466. alchBox.setColumns(25);
  2467.  
  2468. if (props.getProperty("mouseSpeed") != null) {
  2469. mouseSpeedBox.setText(props.getProperty("mouseSpeed"));
  2470. }
  2471. if(props.getProperty("useSimplePaint") != null ) {
  2472. if(props.get("useSimplePaint").equals("true"))
  2473. useOldPaint.setSelected(true);
  2474. }
  2475. if (props.getProperty("thresholdBox") != null) {
  2476. thresholdBox.setText(props.getProperty("thresholdBox"));
  2477. }
  2478. if (props.getProperty("alchBox") != null) {
  2479. alchBox.setText(props.getProperty("alchBox"));
  2480. }
  2481. if(props.getProperty("useBones") != null) {
  2482. if(props.get("useBones").equals("true"))
  2483. useBones.setSelected(true);
  2484. }
  2485.  
  2486. if(!u.paint.useAdvancedPaint) {
  2487. useOldPaint.setSelected(true);
  2488. useOldPaint.setEnabled(false);
  2489. }
  2490.  
  2491. misc.add(miscLabel);
  2492. misc.add(new JLabel(" "));
  2493. misc.add(mouseLabel);
  2494. misc.add(mouseSpeedBox);
  2495. misc.add(new JLabel(" "));
  2496. misc.add(thresholdLabel);
  2497. misc.add(thresholdBox);
  2498. misc.add(new JLabel(" "));
  2499. misc.add(alchLabel);
  2500. misc.add(alchBox);
  2501. misc.add(new JLabel(" "));
  2502. misc.add(useBones);
  2503. if(!u.paint.useAdvancedPaint) {
  2504. JLabel ddosLabel1 = new JLabel("Powerbot is currently being DDoS'd");
  2505. JLabel ddosLabel2 = new JLabel("Due to this fact, only simple paint");
  2506. JLabel ddosLabel3 = new JLabel("is available.");
  2507. ddosLabel1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2508. ddosLabel2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2509. ddosLabel3.setAlignmentX(JLabel.CENTER_ALIGNMENT);
  2510. misc.add(new JLabel(" "));
  2511. misc.add(ddosLabel1);
  2512. misc.add(ddosLabel2);
  2513. misc.add(ddosLabel3);
  2514. }
  2515. misc.add(useOldPaint);
  2516. }
  2517.  
  2518. JTabbedPane tabbedPane = new JTabbedPane();
  2519. tabbedPane.addTab("Combat", combat);
  2520. tabbedPane.addTab("Loot", loot);
  2521. // tabbedPane.addTab("Bank", bank);
  2522. tabbedPane.addTab("Misc.", misc);
  2523. center.add(tabbedPane);
  2524. }
  2525. add(center, BorderLayout.CENTER);
  2526.  
  2527. JPanel south = new JPanel(new FlowLayout());
  2528. south.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  2529. {
  2530. start = new JButton("Start script!");
  2531. start.setAlignmentX(JButton.CENTER_ALIGNMENT);
  2532. start.addActionListener(onStart);
  2533. south.add(start);
  2534. }
  2535. add(south, BorderLayout.SOUTH);
  2536.  
  2537. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  2538. setTitle("RFighter GUI");
  2539. }
  2540.  
  2541. private Properties loadProperties() {
  2542. try {
  2543. if (!file.exists())
  2544. file.createNewFile();
  2545. Properties p = new Properties();
  2546. p.load(new FileInputStream(file));
  2547. return p;
  2548. } catch (Exception e) {
  2549. e.printStackTrace();
  2550. }
  2551. return null;
  2552. }
  2553.  
  2554. private void saveProperties() {
  2555. Properties p = new Properties();
  2556. p.put("mouseSpeed", mouseSpeedBox.getText());
  2557. p.put("npcBox", npcBox.getText());
  2558. p.put("lootBox", lootBox.getText());
  2559. p.put("alchBox", alchBox.getText());
  2560. p.put("useMulti", Boolean.toString(useMulti.isSelected()));
  2561. p.put("useRadius", Boolean.toString(useRadius.isSelected()));
  2562. p.put("useSafe", Boolean.toString(useSafe.isSelected()));
  2563. p.put("useCentral", Boolean.toString(useCentral.isSelected()));
  2564. p.put("useBones", Boolean.toString(useBones.isSelected()));
  2565. p.put("disableSpecials", Boolean.toString(disableSpecials.isSelected()));
  2566. p.put("onlyLoot", Boolean.toString(onlyLoot.isSelected()));
  2567. p.put("prioritizeLoot", Boolean.toString(prioritizeLoot.isSelected()));
  2568. p.put("useSimplePaint", Boolean.toString(useOldPaint.isSelected()));
  2569.  
  2570. // p.put("enableBanking", Boolean.toString(enableBanking.isSelected()));
  2571. // p.put("depositLoot", Boolean.toString(depositLoot.isSelected()));
  2572. // p.put("depositBones", Boolean.toString(depositBones.isSelected()));
  2573. // p.put("withdrawFood", Boolean.toString(withdrawFood.isSelected()));
  2574. // p.put("foodBox", foodBox.getText());
  2575. p.put("thresholdBox", thresholdBox.getText());
  2576.  
  2577. try {
  2578. p.store(new FileOutputStream(file), "");
  2579. } catch (Exception e) {
  2580. e.printStackTrace();
  2581. }
  2582. }
  2583.  
  2584. private ActionListener onStart = new ActionListener() {
  2585. public void actionPerformed(ActionEvent e) {
  2586. saveProperties();
  2587. startScript = true;
  2588. mouseSpeedMin = Integer.parseInt(mouseSpeedBox.getText().split(",")[0]);
  2589. mouseSpeedMax = Integer.parseInt(mouseSpeedBox.getText().split(",")[1]);
  2590. utilizeMultiwayCombat = useMulti.isSelected();
  2591. onlyInRadius = useRadius.isSelected();
  2592. useSafespot = useSafe.isSelected();
  2593. useCentralClicking = useCentral.isSelected();
  2594. buryBones = useBones.isSelected();
  2595. u.loot.onlyTakeLootFromKilled = onlyLoot.isSelected();
  2596. u.tiles.threshold = Integer.parseInt(thresholdBox.getText());
  2597. u.paint.useAdvancedPaint = !useOldPaint.isSelected();
  2598. u.npcs.disableSpecials = disableSpecials.isSelected();
  2599. // u.bank.bankingEnabled = enableBanking.isSelected();
  2600. // u.bank.depositLoot = depositLoot.isSelected();
  2601. // u.bank.depositBones = depositBones.isSelected();
  2602. // u.bank.withdrawFood = withdrawFood.isSelected();
  2603. // u.bank.minimumFood = Integer.parseInt(foodBox.getText().split(",")[0]);
  2604. // u.bank.maximumFood = Integer.parseInt(foodBox.getText().split(",")[1]);
  2605. RFighter.this.prioritizeLoot = prioritizeLoot.isSelected();
  2606.  
  2607. if (onlyInRadius) {
  2608. u.npcs.maxRadius = Integer.parseInt(JOptionPane.showInputDialog("Enter the max radius. Example: 10"));
  2609. }
  2610.  
  2611. String[] ids = npcBox.getText().split(",");
  2612. ArrayList<Integer> idList = new ArrayList<Integer>();
  2613. ArrayList<String> nameList = new ArrayList<String>();
  2614. for (String id3 : ids) {
  2615. if (id3 != null && !id3.equals("")) {
  2616. try {
  2617. int id = Integer.parseInt(id3);
  2618. idList.add(id);
  2619. } catch (Exception e1) {
  2620. nameList.add(id3);
  2621. }
  2622. }
  2623. }
  2624. u.npcs.npcIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[idList.size()])) : new int[0];
  2625. u.npcs.npcNames = nameList.size() > 0 ? nameList.toArray(new String[nameList.size()]) : new String[0];
  2626.  
  2627. ids = lootBox.getText().split(",");
  2628. idList = new ArrayList<Integer>();
  2629. nameList = new ArrayList<String>();
  2630. for (String id2 : ids) {
  2631. if (id2 != null && !id2.equals("")) {
  2632. try {
  2633. int id = Integer.parseInt(id2);
  2634. idList.add(id);
  2635. } catch (Exception e1) {
  2636. nameList.add(id2);
  2637. }
  2638. }
  2639. }
  2640. u.loot.lootIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[idList.size()])) : new int[0];
  2641. u.loot.lootNames = nameList.size() > 0 ? nameList.toArray(new String[nameList.size()]) : new String[0];
  2642.  
  2643. ids = alchBox.getText().split(",");
  2644. idList = new ArrayList<Integer>();
  2645. nameList = new ArrayList<String>();
  2646. for (String id1 : ids) {
  2647. if (id1 != null && !id1.equals("")) {
  2648. try {
  2649. int id = Integer.parseInt(id1);
  2650. idList.add(id);
  2651. } catch (Exception e1) {
  2652. nameList.add(id1.toLowerCase());
  2653. }
  2654. }
  2655. }
  2656.  
  2657. u.alch.alchIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[idList.size()])) : new int[0];
  2658. u.alch.alchNames = nameList.size() > 0 ? nameList.toArray(new String[nameList.size()]) : new String[0];
  2659.  
  2660. dispose();
  2661. }
  2662. };
  2663.  
  2664. // private ActionListener disableAllBankingOptions = new ActionListener() {
  2665. // public void actionPerformed(ActionEvent e) {
  2666. // AbstractButton abstractButton = (AbstractButton) e.getSource();
  2667. // boolean selected = abstractButton.getModel().isSelected();
  2668. //
  2669. // if(selected) {
  2670. //
  2671. // withdrawFood.setEnabled(selected);
  2672. // depositLoot.setEnabled(selected);
  2673. // } else {
  2674. // withdrawFood.setSelected(selected);
  2675. // depositLoot.setSelected(selected);
  2676. // depositBones.setSelected(selected);
  2677. // withdrawFood.setEnabled(selected);
  2678. // depositLoot.setEnabled(selected);
  2679. // depositBones.setEnabled(selected);
  2680. // foodBox.setEnabled(selected);
  2681. // }
  2682. // }
  2683. // };
  2684.  
  2685. // private ActionListener disableDepositBones = new ActionListener() {
  2686. // public void actionPerformed(ActionEvent e) {
  2687. // AbstractButton abstractButton = (AbstractButton) e.getSource();
  2688. // boolean selected = abstractButton.getModel().isSelected();
  2689. // depositBones.setEnabled(selected);
  2690. // }
  2691. // };
  2692. //
  2693. // private ActionListener disableFoodBox = new ActionListener() {
  2694. // public void actionPerformed(ActionEvent e) {
  2695. // AbstractButton abstractButton = (AbstractButton) e.getSource();
  2696. // boolean selected = abstractButton.getModel().isSelected();
  2697. // foodBox.setEnabled(selected);
  2698. // }
  2699. // };
  2700.  
  2701. private int[] toIntArray(Integer[] ints) {
  2702. int[] done = new int[ints.length];
  2703. for (int i = 0; i < done.length; i++) {
  2704. done[i] = ints[i];
  2705. }
  2706. return done;
  2707. }
  2708. }
  2709.  
  2710. public void mouseClicked(MouseEvent e) {
  2711. InterfaceComponent inter = Interfaces.get(137).getComponent(0);
  2712. int x = inter.getLocation().x;
  2713. int y = inter.getLocation().y;
  2714. if (inter.contains(e.getPoint())) {
  2715. u.paint.showPaint = !u.paint.showPaint;
  2716. }
  2717.  
  2718. Polygon mainRibbonPoly =
  2719. new Polygon(
  2720. new int[] {x, x, x + 80, x + 160, x + 160},
  2721. new int[] {y - 325, y - 325 + 52, y - 325 + 97, y - 325 + 52, y - 325},
  2722. 5);
  2723. Polygon skillsRibbonPoly =
  2724. new Polygon(
  2725. new int[] {x, x, x + 80, x + 160, x + 160},
  2726. new int[] {y - 225, y - 225 + 52, y - 225 + 97, y - 225 + 52, y - 225},
  2727. 5);
  2728. Polygon lootRibbonPoly =
  2729. new Polygon(
  2730. new int[] {x, x, x + 80, x + 160, x + 160},
  2731. new int[] {y - 125, y - 125 + 52, y - 125 + 97, y - 125 + 52, y - 125},
  2732. 5);
  2733.  
  2734. if(mainRibbonPoly.contains(e.getPoint())) {
  2735. u.paint.showMain = true;
  2736. u.paint.showSkills = false;
  2737. u.paint.showLoot = false;
  2738. }
  2739. if(skillsRibbonPoly.contains(e.getPoint())) {
  2740. u.paint.showMain = false;
  2741. u.paint.showSkills = true;
  2742. u.paint.showLoot = false;
  2743. }
  2744. if(lootRibbonPoly.contains(e.getPoint())) {
  2745. u.paint.showMain = false;
  2746. u.paint.showSkills = false;
  2747. u.paint.showLoot = true;
  2748. }
  2749. }
  2750.  
  2751. public void mousePressed(MouseEvent e) {}
  2752.  
  2753. public void mouseReleased(MouseEvent e) {}
  2754.  
  2755. public void mouseEntered(MouseEvent e) {}
  2756.  
  2757. public void mouseExited(MouseEvent e) {}
  2758. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement