Advertisement
Guest User

Untitled

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