Advertisement
Guest User

Untitled

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