Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.02 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Point;
  7. import java.awt.event.MouseEvent;
  8. import java.awt.event.MouseMotionListener;
  9.  
  10. import org.rsbot.event.events.ServerMessageEvent;
  11. import org.rsbot.event.listeners.PaintListener;
  12. import org.rsbot.event.listeners.ServerMessageListener;
  13. import org.rsbot.script.Script;
  14. import org.rsbot.script.ScriptManifest;
  15. import org.rsbot.script.methods.Skills;
  16. import org.rsbot.script.util.Filter;
  17. import org.rsbot.script.wrappers.RSArea;
  18. import org.rsbot.script.wrappers.RSItem;
  19. import org.rsbot.script.wrappers.RSNPC;
  20. import org.rsbot.script.wrappers.RSObject;
  21. import org.rsbot.script.wrappers.RSTile;
  22.  
  23. @ScriptManifest(authors = { "Ahmedbasil1" }, keywords = "Combat,Flesh,Crawlers,Strength,Pure", name = "Flesh Crawler Devourer", version = 0.34, description = ("Prepare typical inventory, and press start! Enjoy!"))
  24. public class FleshCrawler extends Script implements PaintListener,
  25. ServerMessageListener, MouseMotionListener {
  26.  
  27. public RSNPC allNPC[];
  28. private int NumOfPots = 0;
  29. private int PotionID = 0;
  30. private int FoodID;
  31. private boolean dist = false;
  32. long startTime, ABTime, currentTime;
  33. private RSArea FleshCrawlers = new RSArea(2036, 5185, 2046, 5193);
  34. private RSArea FleshCrawlers2 = new RSArea(2036, 5185, 2046, 5194);
  35. private RSArea Bank = new RSArea(3091, 3488, 3098, 3499);
  36. private RSArea Door1 = new RSArea(2044, 5237, 2045, 5239);
  37. private RSArea Door2 = new RSArea(2036, 5201, 2037, 5203);
  38. private RSArea Door3 = new RSArea(2045, 5195, 2046, 5197);
  39. private RSTile[] PathToBank = { new RSTile(3081, 3421),
  40. new RSTile(3087, 3428), new RSTile(3092, 3436),
  41. new RSTile(3091, 3445), new RSTile(3090, 3457),
  42. new RSTile(3100, 3465), new RSTile(3100, 3472),
  43. new RSTile(3100, 3481), new RSTile(3095, 3484),
  44. new RSTile(3093, 3491) };
  45.  
  46. // ------------------------------------------------------------------------------------------------------------\\
  47. private RSItem GetEdibleFoods() {
  48. RSItem[] EdibleFood = inventory.getItems();
  49. for (RSItem i : EdibleFood) {
  50. if (i.getComponent().getActions() == null
  51. || i.getComponent().getActions()[0] == null) {
  52. continue;
  53. }
  54. if (i.getComponent().getActions()[0].contains("Eat")) {
  55. return i;
  56. }
  57. }
  58. return null;
  59. }
  60.  
  61. private RSItem GetPotion() {
  62. RSItem[] EdibleFood = inventory.getItems();
  63. for (RSItem i : EdibleFood) {
  64. if (i.getComponent().getActions() == null
  65. || i.getComponent().getActions()[0] == null) {
  66. continue;
  67. }
  68. if (i.getComponent().getActions()[0].contains("Drink")) {
  69. return i;
  70. }
  71. }
  72. return null;
  73. }
  74.  
  75. private void DrinkPotion() {
  76. RSItem Potion = GetPotion();
  77. if (Potion != null) {
  78. Potion.doAction("Drink");
  79. if (getState() == State.NeedToDrinkPotion) {
  80. sleep(500, 700);
  81. }
  82. if (getState() == State.NeedToDrinkPotion) {
  83. sleep(500, 700);
  84. }
  85. if (getState() == State.NeedToDrinkPotion) {
  86. sleep(500, 700);
  87. }
  88. if (getState() == State.NeedToDrinkPotion) {
  89. sleep(500, 700);
  90. }
  91. if (getState() == State.NeedToDrinkPotion) {
  92. sleep(500, 700);
  93. }
  94. if (getState() == State.NeedToDrinkPotion) {
  95. sleep(500, 700);
  96. }
  97. if (getState() == State.NeedToDrinkPotion) {
  98. sleep(500, 700);
  99. }
  100. if (getState() == State.NeedToDrinkPotion) {
  101. sleep(500, 700);
  102. }
  103. if (getState() == State.NeedToDrinkPotion) {
  104. sleep(500, 700);
  105. }
  106. if (getState() == State.NeedToDrinkPotion) {
  107. sleep(500, 700);
  108. }
  109. }
  110. }
  111.  
  112. private void EatFood() {
  113. RSItem Food = GetEdibleFoods();
  114. if (Food != null) {
  115. Food.doAction("Eat");
  116. if (getState() == State.NeedToEat) {
  117. sleep(500, 700);
  118. }
  119. if (getState() == State.NeedToEat) {
  120. sleep(500, 700);
  121. }
  122. if (getState() == State.NeedToEat) {
  123. sleep(500, 700);
  124. }
  125. if (getState() == State.NeedToEat) {
  126. sleep(500, 700);
  127. }
  128. if (getState() == State.NeedToEat) {
  129. sleep(500, 700);
  130. }
  131. if (getState() == State.NeedToEat) {
  132. sleep(500, 700);
  133. }
  134. if (getState() == State.NeedToEat) {
  135. sleep(500, 700);
  136. }
  137. if (getState() == State.NeedToEat) {
  138. sleep(500, 700);
  139. }
  140. if (getState() == State.NeedToEat) {
  141. sleep(500, 700);
  142. }
  143. if (getState() == State.NeedToEat) {
  144. sleep(500, 700);
  145. }
  146. }
  147. }
  148.  
  149. private void openDoor(int x, int y, boolean tf) {
  150. RSTile doorTile = new RSTile(x, y);
  151. RSObject tempObject = objects.getTopAt(doorTile);
  152. if (tf == true) {
  153. if (isIn(x, y + 1, 2, 6)) {
  154. if (tempObject != null) {
  155. if (tempObject.isOnScreen()) {
  156. if (tempObject.doAction("Open")) {
  157. WaitToMove();
  158. }
  159. }
  160. }
  161. }
  162. }
  163. if (tf == false) {
  164. if (tempObject != null) {
  165. if (tempObject.isOnScreen()) {
  166. if (tempObject.doAction("Open")) {
  167. WaitToMove();
  168. }
  169. }
  170. }
  171. }
  172. }
  173.  
  174. public void WaitToMove() { // these type of wait's I feel are noobish, but
  175. // it works, I tried using While, and Do loops,
  176. // but they also failed.
  177. RSTile me = getMyPlayer().getLocation();
  178. boolean shouldWait;
  179. int i;
  180. i = 0;
  181. shouldWait = true;
  182. do {
  183. sleep(500, 600);
  184. i++;
  185. if (getMyPlayer().getLocation() != me || i > 10) {
  186. shouldWait = false;
  187. }
  188. } while (shouldWait);
  189. sleep(1000, 1500);
  190. }
  191.  
  192. public void climbUp() {
  193. RSTile me = getMyPlayer().getLocation();
  194. RSObject object;
  195. RSArea F1 = new RSArea(1905, 5217, 1915, 5227);
  196. object = objects.getNearest(new Filter<RSObject>() {
  197. public boolean accept(RSObject n) {
  198. if ((n.getID() == 16078 || n.getID() == 16080 || n.getID() == 16148)
  199. && calc.distanceTo(n) <= 4) {
  200. return true;
  201. }
  202. return false;
  203. }
  204. });
  205. if (object != null && !F1.contains(me)) {
  206. if (object.doAction("Climb-up")) {
  207. WaitToMove();
  208. }
  209. }
  210. }
  211.  
  212. public void climbDown() {
  213. RSObject object;
  214. object = objects.getNearest(new Filter<RSObject>() {
  215. public boolean accept(RSObject n) {
  216. if ((n.getID() == 16154 || n.getID() == 16150 || n.getID() == 16149)
  217. && calc.distanceTo(n) <= 6) {
  218. return true;
  219. }
  220. return false;
  221. }
  222. });
  223. if (object != null) {
  224. if (object.getID() == 16150) {
  225. if (object.doAction("Enter")) {
  226. WaitToMove();
  227. }
  228. }
  229. if (object.getID() == 16149 || object.getID() == 16154) {
  230. if (object.doAction("Climb-down")) {
  231. WaitToMove();
  232. }
  233. }
  234. }
  235. }
  236.  
  237. public boolean isIn(int x1, int y1, int xc, int yc) {
  238. xc--;
  239. yc--;
  240. RSArea zone = new RSArea(x1, y1, x1 + xc, y1 + yc);
  241. RSTile me = getMyPlayer().getLocation();
  242. if (zone.contains(me)) {
  243. return true;
  244. } else {
  245. return false;
  246. }
  247. }
  248.  
  249. public void checkDoors() {
  250. RSTile me = getMyPlayer().getLocation();
  251. openDoor(2044, 5239, true);
  252. openDoor(2036, 5203, true);
  253. openDoor(2045, 5197, true);
  254. if (Door1.contains(me)) {
  255. openDoor(2045, 5237, false);
  256. }
  257. if (Door2.contains(me)) {
  258. openDoor(2036, 5201, false);
  259. }
  260. if (Door3.contains(me)) {
  261. openDoor(2045, 5195, false);
  262. }
  263. }
  264.  
  265. public boolean walkToFleshCrawlers() {
  266. RSTile me = getMyPlayer().getLocation();
  267. RSTile[] PathToCave = walking.reversePath(PathToBank);
  268. RSTile MainF2Path[] = { new RSTile(2042, 5228), new RSTile(2044, 5219),
  269. new RSTile(2037, 5211), new RSTile(2037, 5204) };
  270. RSArea MainZone = new RSArea(2030, 5205, 2047, 5236);
  271. climbDown();
  272. checkDoors();
  273. if (isIn(2036, 5199, 3, 2)) {
  274. walking.walkTileMM(new RSTile(2046, 5196));
  275. WaitToMove();
  276. return true;
  277. }
  278. if (isIn(2045, 5194, 2, 1)) {
  279. walking.walkTileMM(new RSTile(2041, 5188));
  280. WaitToMove();
  281. return true;
  282. }
  283. if (isIn(2041, 5244, 3, 3)) {
  284. if (walking.walkTileMM(new RSTile(2045, 5238))) {
  285. WaitToMove();
  286. return true;
  287. }
  288. }
  289. if (isIn(1858, 5242, 3, 3)) {
  290. if (walking.walkTileMM(new RSTile(1863, 5236))) {
  291. WaitToMove();
  292. return true;
  293. }
  294. }
  295. if (me.getX() >= 1910 && me.getX() <= 1920 && me.getY() >= 5218
  296. && me.getX() <= 5230) {
  297. if (walking.walkTileMM(new RSTile(1903, 5219))) {
  298. WaitToMove();
  299. return true;
  300. }
  301. }
  302. if (MainZone.contains(me)
  303. && calc.distanceTo(MainF2Path[MainF2Path.length - 1]) >= 5) {
  304. walking.walkPathMM(MainF2Path, 1, 1);
  305. WaitToMove();
  306. return true;
  307. }
  308. if (me.getX() > 3000
  309. && calc.distanceTo(PathToCave[PathToCave.length - 1]) >= 6) {
  310. walking.walkPathMM(PathToCave, 1, 1);
  311. WaitToMove();
  312. return true;
  313. }
  314. return true;
  315. }
  316.  
  317. public boolean WalkToBank() {
  318. RSTile me = getMyPlayer().getLocation();
  319. climbUp();
  320. if (FleshCrawlers2.contains(me) && me.getY() >= 5194) {
  321. openDoor(2045, 5195, false);
  322. return true;
  323. }
  324. if (FleshCrawlers2.contains(me) && me.getY() < 5194) {
  325. walking.walkTileMM(new RSTile(2050, 5196));
  326. WaitToMove();
  327. return true;
  328. }
  329. if (Door3.contains(me)) {
  330. openDoor(2046, 5197, false);
  331. return true;
  332. }
  333. if (isIn(2045, 5198, 2, 3)) {
  334. walking.walkTileMM(new RSTile(2041, 5208));
  335. WaitToMove();
  336. return true;
  337. }
  338. if (me.getX() > 3000
  339. && calc.distanceTo(PathToBank[PathToBank.length - 1]) >= 3) {
  340. walking.walkPathMM(PathToBank, 1, 1);
  341. WaitToMove();
  342. return true;
  343. }
  344. return true;
  345. }
  346.  
  347. enum State {
  348. Banking, WalkingToFleshCrawlers, Waiting, NeedToEat, NeedToDrinkPotion, Attack, IDLE
  349. }
  350.  
  351. State getState() {
  352. if (combat.getLifePoints() <= (6 * (skills
  353. .getRealLevel(Skills.CONSTITUTION)))) {
  354. return State.NeedToEat;
  355. }
  356.  
  357. if (GetPotion() != null
  358. && FleshCrawlers.contains(getMyPlayer().getLocation())
  359. && skills.getCurrentLevel(Skills.STRENGTH) <= (skills
  360. .getRealLevel(Skills.STRENGTH) + 3)) {
  361. return State.NeedToDrinkPotion;
  362. }
  363.  
  364. if (getMyPlayer().getAnimation() != -1 || getMyPlayer().isMoving()
  365. || getMyPlayer().getInteracting() != null) {
  366. return State.Waiting;
  367. }
  368.  
  369. if (GetEdibleFoods() == null) {
  370. return State.Banking;
  371. }
  372.  
  373. if (!FleshCrawlers.contains(getMyPlayer().getLocation())
  374. && GetEdibleFoods() != null) {
  375. return State.WalkingToFleshCrawlers;
  376. }
  377.  
  378. if (FleshCrawlers.contains(getMyPlayer().getLocation())
  379. && GetEdibleFoods() != null
  380. && getMyPlayer().getInteracting() == null) {
  381. return State.Attack;
  382. }
  383. return State.IDLE;
  384. }
  385.  
  386. public boolean onStart() {
  387. sleep(1000, 2000);
  388. env.disableRandom("Improved Rewards Box");
  389. ABTime = System.currentTimeMillis();
  390. startTime = System.currentTimeMillis();
  391. E_startTime = skills.getCurrentExp(Skills.STRENGTH)
  392. + skills.getCurrentExp(Skills.ATTACK)
  393. + skills.getCurrentExp(Skills.DEFENSE)
  394. + skills.getCurrentExp(Skills.RANGE)
  395. + skills.getCurrentExp(Skills.CONSTITUTION);
  396.  
  397. if (GetEdibleFoods() != null) {
  398. FoodID = GetEdibleFoods().getID();
  399. } else {
  400. log("Start with food you want to use!");
  401. }
  402.  
  403. if (GetPotion() != null) {
  404. PotionID = GetPotion().getID();
  405. NumOfPots = inventory.getCount(PotionID);
  406. } else {
  407. log("Start with ammount of potions per inventory you want to use!");
  408. }
  409. loop();
  410. return true;
  411. }
  412.  
  413. public RSNPC getNextNPC() {
  414. RSNPC o = npcs.getNearest(new Filter<RSNPC>() {
  415. public boolean accept(RSNPC n) {
  416. if (n.getName().equals("Flesh Crawler") && !n.isInCombat()) {
  417. return true;
  418. }
  419. return false;
  420. }
  421. });
  422. if (o != null) {
  423. return o;
  424. } else {
  425. return null;
  426. }
  427. }
  428.  
  429. public boolean GA() {
  430. RSNPC closest = null;
  431. int d = 100000;
  432. for (RSNPC i : npcs.getAll()) {
  433. if (i.getName() == "Flesh Crawler" && i.getInteracting() != null
  434. && i.getInteracting().equals(getMyPlayer())) {
  435. int di = calc.distanceTo(i);
  436. if (di < d) {
  437. closest = i;
  438. d = di;
  439. }
  440. }
  441. }
  442. if (closest != null && getMyPlayer().isInCombat()) {
  443. return false;
  444. } else {
  445. return true;
  446. }
  447. }
  448.  
  449. public void doAttack() {
  450. RSNPC npc;
  451. npc = getNextNPC();
  452. double x = 0;
  453. double y = 0;
  454. double xf = 0;
  455. double yf = 0;
  456. int i;
  457. int z;
  458. i = 0;
  459. z = 0;
  460. do {
  461. x += npc.getScreenLocation().getX();
  462. i++;
  463. } while (i <= 50);
  464. do {
  465. y += npc.getScreenLocation().getY();
  466. z++;
  467. } while (z <= 50);
  468. xf = x / i;
  469. yf = y / z;
  470. Point AveragePoint = new Point((int) xf, (int) yf);
  471. mouse.move(AveragePoint);
  472. xf = 0;
  473. yf = 0;
  474. if (menu.contains("Attack")) {
  475. menu.doAction("Attack");
  476. if (random(1, 10) == 1) {
  477. mouse.moveSlightly();
  478. } else {
  479. mouse.moveRandomly(20);
  480. }
  481. sleep(1200, 1400);
  482. dist = false;
  483. } else {
  484. sleep(200, 300);
  485. }
  486. }
  487.  
  488. public void processAttack() {
  489. RSNPC npc = getNextNPC();
  490. if (npc != null && !npc.isInCombat() && GA()) {
  491. if (npc.isOnScreen()) {
  492. doAttack();
  493. } else {
  494. walking.walkTileMM(npc.getLocation());
  495. sleep(700, 800);
  496. }
  497. }
  498. }
  499.  
  500. public void Bank() {
  501. if (Bank.contains(getMyPlayer().getLocation())) {
  502. bank.open();
  503. int z = 0;
  504. do {
  505. z++;
  506. if (z >= 10) {
  507. bank.open();
  508. z = 0;
  509. }
  510. sleep(150, 200);
  511. } while (!bank.isOpen());
  512. if (bank.isOpen()) {
  513. sleep(1000, 2000);
  514. if (inventory.getCount() != 0) {
  515. bank.depositAll();
  516. int q = 0;
  517. do {
  518. sleep(350, 400);
  519. q++;
  520. } while (q <= 10 && inventory.getCount() != 0);
  521. }
  522.  
  523. if (NumOfPots != 0) {
  524. int e = 0;
  525. while (e <= NumOfPots) {
  526. bank.withdraw(PotionID, 1);
  527. e++;
  528. sleep(500, 1000);
  529. }
  530. }
  531. if (bank.getCount(FoodID) < 25) {
  532. bank.close();
  533. sleep(2000, 2500);
  534. game.logout(false);
  535. sleep(1000, 1500);
  536. stopScript();
  537. }
  538. if (!inventory.contains(FoodID) && bank.getCount(FoodID) >= 20) {
  539. bank.withdraw(FoodID, 0);
  540. int t = 0;
  541. do {
  542. sleep(150, 200);
  543. t++;
  544. } while (t <= 10 && !inventory.contains(FoodID));
  545. }
  546.  
  547. bank.close();
  548. }
  549. } else {
  550. WalkToBank();
  551. }
  552. }
  553.  
  554. public void RoundlyChecks() {
  555. mouse.setSpeed(random(4, 7));
  556. if (camera.getPitch() < 70) {
  557. camera.setPitch(random(80, 95));
  558. }
  559. if (walking.getEnergy() >= random(45, 65) && !walking.isRunEnabled()) {
  560. walking.setRun(true);
  561. if (!walking.isRunEnabled()) {
  562. sleep(1000, 1200);
  563. }
  564. if (!walking.isRunEnabled()) {
  565. sleep(1000, 1200);
  566. }
  567. if (!walking.isRunEnabled()) {
  568. sleep(1000, 1200);
  569. }
  570. if (!walking.isRunEnabled()) {
  571. sleep(1000, 1200);
  572. }
  573. if (!walking.isRunEnabled()) {
  574. sleep(1000, 1200);
  575. }
  576. if (!walking.isRunEnabled()) {
  577. sleep(1000, 1200);
  578. }
  579. if (!walking.isRunEnabled()) {
  580. sleep(1000, 1200);
  581. }
  582. if (!walking.isRunEnabled()) {
  583. sleep(1000, 1200);
  584. }
  585. }
  586. if (inventory.contains(14664)) {
  587. inventory.getItem(14664).doAction("Drop");
  588. }
  589. if (isIn(2034, 5185, 3, 2)) {
  590. openDoor(2036, 5185, false);
  591. }
  592. }
  593.  
  594. public int loop() {
  595. RoundlyChecks();
  596. switch (getState()) {
  597. case Banking:
  598. Bank();
  599. break;
  600.  
  601. case WalkingToFleshCrawlers:
  602. walkToFleshCrawlers();
  603. break;
  604.  
  605. case NeedToEat:
  606. if (GetEdibleFoods() != null) {
  607. EatFood();
  608. } else {
  609. Bank();
  610. }
  611.  
  612. break;
  613.  
  614. case NeedToDrinkPotion:
  615. DrinkPotion();
  616. break;
  617.  
  618. case Attack:
  619. if (FleshCrawlers.contains(getMyPlayer().getLocation())) {
  620. processAttack();
  621. } else {
  622. Bank();
  623. }
  624.  
  625. break;
  626.  
  627. case Waiting:
  628. if (!FleshCrawlers.contains(getMyPlayer().getLocation()) & getMyPlayer().isInCombat()) {
  629. Bank();
  630. }
  631. long i = System.currentTimeMillis();
  632. if (i - ABTime > random(60000, 240000)
  633. && FleshCrawlers.contains(getMyPlayer().getLocation())) {
  634. Antiban();
  635. ABTime = System.currentTimeMillis();
  636. } else {
  637. sleep(300, 400);
  638. }
  639. break;
  640. }
  641. return 10;
  642. }
  643.  
  644. @SuppressWarnings("static-access")
  645. public void Antiban() {
  646. int[] skillsIDIndex = { 6, 14, 5, 4, 20, 18, 13, 2, 23, 17, 8, 16, 0,
  647. 3, 22, 7, 12, 1, 24, 19, 11, 10, 9, 15, 21, 2, 2, 2 };
  648. int NOS = skillsIDIndex.length;
  649. switch (random(1, 10)) {
  650. case 1:
  651. camera.moveRandomly(1800);
  652. sleep(1000, 1200);
  653. break;
  654.  
  655. case 2:
  656. mouse.moveRandomly(500, 800);
  657. sleep(1000, 2000);
  658. break;
  659.  
  660. case 3:
  661. mouse.moveOffScreen();
  662. sleep(2000, 3000);
  663. break;
  664.  
  665. case 4:
  666. camera.setPitch(random(20, 70));
  667. break;
  668.  
  669. case 5:
  670. game.openTab(game.TAB_STATS);
  671. sleep(random(0, 3000));
  672. switch (random(1, 5)) {
  673. case 1:
  674. skills.doHover(Skills.STRENGTH);
  675. break;
  676. case 2:
  677. skills.doHover(Skills.ATTACK);
  678. break;
  679. case 3:
  680. skills.doHover(Skills.DEFENSE);
  681. break;
  682. case 4:
  683. skills.doHover(Skills.CONSTITUTION);
  684. break;
  685. case 5:
  686. skills.doHover(skillsIDIndex[random(1, NOS)]);
  687. break;
  688. }
  689. sleep(1000, 2000);
  690. break;
  691. case 6:
  692. camera.setAngle(camera.getAngle() + random(-100, 100));
  693. sleep(400, 500);
  694. break;
  695. case 7:
  696. camera.setAngle(camera.getAngle() + random(-100, 100));
  697. sleep(400, 500);
  698. break;
  699.  
  700. case 8:
  701. game.openTab(game.TAB_STATS);
  702. sleep(random(0, 3000));
  703. switch (random(1, 5)) {
  704. case 1:
  705. skills.doHover(Skills.STRENGTH);
  706. break;
  707. case 2:
  708. skills.doHover(Skills.ATTACK);
  709. break;
  710. case 3:
  711. skills.doHover(Skills.DEFENSE);
  712. break;
  713. case 4:
  714. skills.doHover(Skills.CONSTITUTION);
  715. break;
  716. case 5:
  717. skills.doHover(skillsIDIndex[random(1, NOS)]);
  718. break;
  719. }
  720. sleep(1000, 2000);
  721. break;
  722. case 9:
  723. camera.moveRandomly(1800);
  724. sleep(1000, 1200);
  725. break;
  726.  
  727. case 10:
  728. mouse.moveRandomly(1500, 1800);
  729. sleep(1000, 2000);
  730. break;
  731. }
  732. }
  733.  
  734. public void onFinish() {
  735. }
  736.  
  737. public void serverMessageRecieved(ServerMessageEvent e) {
  738. if (e.toString().contains("under attack")) {
  739. sleep(1000, 1200);
  740. }
  741. if (e.toString().contains("else is fighting")) {
  742. dist = true;
  743. sleep(200, 300);
  744. processAttack();
  745. }
  746. }
  747.  
  748. public boolean isHover(int x1, int y1, int x2, int y2) {
  749. if (p != null) {
  750. if (p.getX() >= x1 && p.getY() >= y1 && p.getX() <= x2
  751. && p.getY() <= y2) {
  752. return true;
  753. } else {
  754. return false;
  755. }
  756. } else {
  757. return false;
  758. }
  759. }
  760.  
  761. public void mouseMoved(MouseEvent e) {
  762. p = e.getPoint();
  763. }
  764.  
  765. private String formatTime() {
  766. long time = System.currentTimeMillis() - startTime;
  767. final StringBuilder stringAppend = new StringBuilder();
  768. final long TSec = time / 1000;
  769. final long TMin = TSec / 60;
  770. final long THour = TMin / 60;
  771. final int s = (int) TSec % 60;
  772. final int m = (int) TMin % 60;
  773. final int h = (int) THour;
  774. if (time <= 0) {
  775. return "00:00:00";
  776. }
  777. if (h < 10) {
  778. stringAppend.append("0");
  779. }
  780. stringAppend.append(h);
  781. stringAppend.append(":");
  782. if (m < 10) {
  783. stringAppend.append("0");
  784. }
  785. stringAppend.append(m);
  786. stringAppend.append(":");
  787. if (s < 10) {
  788. stringAppend.append("0");
  789. }
  790. stringAppend.append(s);
  791. return stringAppend.toString();
  792. }
  793.  
  794. private final BasicStroke stroke2 = new BasicStroke(2);
  795. private final Color color1 = new Color(204, 255, 255);
  796. private final Color color2 = new Color(0, 0, 204);
  797. private final Color color3 = new Color(153, 0, 0);
  798. private final BasicStroke stroke1 = new BasicStroke(5);
  799. private final Font font1 = new Font("Lucida Sans", 1, 12);
  800. public Point p;
  801. private double RoE = 0;
  802. private double E = 0;
  803. private long E_currentTime = 0;
  804. private long E_startTime = 0;
  805. private long timeRunning = 0;
  806.  
  807. public void updateVariables() {
  808. currentTime = System.currentTimeMillis();
  809. timeRunning = currentTime - startTime;
  810. E_currentTime = skills.getCurrentExp(Skills.STRENGTH)
  811. + skills.getCurrentExp(Skills.ATTACK)
  812. + skills.getCurrentExp(Skills.DEFENSE)
  813. + skills.getCurrentExp(Skills.RANGE)
  814. + skills.getCurrentExp(Skills.CONSTITUTION);
  815. E = (E_currentTime - E_startTime);
  816. RoE = E / (1000 * timeRunning / (1000 * 60 * 60));
  817. }
  818.  
  819. public void onRepaint(Graphics g1) {
  820. Graphics2D g = (Graphics2D) g1;
  821. Point l = mouse.getLocation();
  822. g.setColor(color1);
  823. g.setStroke(stroke2);
  824. g.drawLine(l.x, 0, l.x, 600);
  825. g.drawLine(800, l.y, 0, l.y);
  826. if (isHover(550, 435, 730, 465)) {
  827. updateVariables();
  828. g.setColor(color1);
  829. g.fillRoundRect(548, 434, 187, 27, 16, 16);
  830. g.setColor(color2);
  831. g.setStroke(stroke1);
  832. g.drawRoundRect(548, 434, 187, 27, 16, 16);
  833. g.setFont(font1);
  834. g.setColor(color3);
  835. g.drawString("Unhover to hide progress", 563, 453);
  836. g.setColor(color1);
  837. g.fillRoundRect(548, 340, 184, 88, 16, 16);
  838. g.setColor(color2);
  839. g.drawRoundRect(548, 340, 184, 88, 16, 16);
  840. g.setColor(color3);
  841. g.drawString("Experience/Hour: " + Math.round(RoE) + " K/PH", 557,
  842. 420);
  843. if (E < 1000) {
  844. g.drawString("Experience: " + Math.round(E), 557, 390);
  845. } else {
  846. g.drawString("Experience: " + (Math.round(E) / 1000) + " K",
  847. 557, 390);
  848. }
  849. g.drawString("Time: " + formatTime(), 557, 360);
  850. } else {
  851. g.setColor(color1);
  852. g.setColor(color1);
  853. g.fillRoundRect(548, 434, 187, 27, 16, 16);
  854. g.setColor(color2);
  855. g.setStroke(stroke1);
  856. g.drawRoundRect(548, 434, 187, 27, 16, 16);
  857. g.setFont(font1);
  858. g.setColor(color3);
  859. g.drawString("Hover to show progress", 565, 453);
  860.  
  861. }
  862. }
  863.  
  864. public void mouseDragged(MouseEvent arg0) {
  865. }
  866. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement