Guest User

Untitled

a guest
Jul 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.88 KB | None | 0 0
  1. import java.text.*;
  2. import java.awt.Color;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.util.Map;
  6.  
  7. import org.rsbot.bot.Bot;
  8. import org.rsbot.bot.input.CanvasWrapper;
  9. import org.rsbot.bot.input.Mouse;
  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.Constants;
  14. import org.rsbot.script.Script;
  15. import org.rsbot.script.ScriptManifest;
  16. import org.rsbot.script.wrappers.RSItemTile;
  17. import org.rsbot.script.wrappers.RSTile;
  18. import org.rsbot.script.wrappers.RSInterfaceComponent;
  19. import org.rsbot.script.wrappers.RSNPC;
  20. import org.rsbot.script.wrappers.RSArea;
  21. import org.rsbot.script.Calculations;
  22. import org.rsbot.script.Skills;
  23. import org.rsbot.script.wrappers.RSCharacter;
  24.  
  25.  
  26. @ScriptManifest(authors = { "Coco" }, category = "Combat", name = "Crawlah killah", version = 1.0, description = "<html><body><h2>" +
  27. "Crawlah killah</h2><hr>by Coco<br>"
  28. + "<select name=\"arrowtype\">"
  29. + "<option> Nothing"
  30. + "<option> Bronze"
  31. + "<option> Iron"
  32. + "<option> Steel"
  33. +" </select>(NOT SUPPORTED YET) What arrows are you going to use? (if any)<p>Just start in the monastery <br> " +
  34. "<select name='food'>" +
  35. "<option>Lobster</option" +
  36. "<option>Tuna</option>" +
  37. "</select> Food to eat?</body></html>")
  38. public class Crawlah extends Script implements PaintListener, ServerMessageListener {
  39.  
  40. public long startTime = System.currentTimeMillis();
  41. public long lastExpTime;
  42. public int levelup = 0;
  43. public int i = 0;
  44. public int counter = 0;
  45.  
  46. public RSTile bankToDungeon[] = new RSTile[] {new RSTile(3093, 3490), new RSTile(3085, 3484), new RSTile(3081,3475),
  47. new RSTile(3087, 3462), new RSTile(3087, 3451), new RSTile( 3087, 3442),new RSTile(3085, 3432), new RSTile(3080,3422) };
  48. public RSArea outside = new RSArea(new RSTile(3072, 3415), new RSTile(3102, 3507));
  49.  
  50.  
  51. public final int atOutside = 0, atFirstRoom= 1, goSecondLevel = 2, nearStairs = 3, atFDoors = 4, atLaberint= 5, atAfterLaberint = 6, atSDoors = 7,
  52. atBeforeCrawlers = 8, atTDoors = 9, atSpot = 10;
  53.  
  54. //1 floor
  55. public int entranceID = 16154;
  56. public RSTile entranceTile = new RSTile(3079, 3422);
  57. public int exitID = 16148;
  58. public int portalFirstLevelID = 16150;
  59. public int stairToSecondLevel = 16149;
  60. public RSArea firstRoom = new RSArea(new RSTile(1858, 5239), new RSTile(1865, 5244));
  61. public RSArea almostSecondLevel= new RSArea(new RSTile(1901, 5212), new RSTile(1915, 5227));
  62. //
  63.  
  64. //2 floor
  65. public int doorID =16065; //16066 the other one
  66. public int ropeID =16078; //drives you to start of the level so you can go up again, climb the ladder , climb another ladder and be outside
  67. public int stairIDF2 =16080; //drives you to start of the level so you can go up again, climb the ladder , climb another ladder and be outside
  68. public RSNPC crawler = getNearestFreeNPCToAttackByID(4390); //level 35
  69.  
  70. public RSArea nearStair = new RSArea(new RSTile(2040,5240), new RSTile(2046,5246));
  71. public RSArea firstDoors = new RSArea(new RSTile(2044,5237), new RSTile(2045,5239));
  72. public RSArea laberint = new RSArea(new RSTile(2037,5211), new RSTile(2046,5236));
  73. public RSArea afterLaberint = new RSArea(new RSTile(2036,5204), new RSTile(2039,5210));
  74. public RSArea secondDoors = new RSArea(new RSTile(2036,5201), new RSTile(2037,5203));
  75. public RSArea beforeCrawlers = new RSArea(new RSTile(2036,5198), new RSTile(2046,5208));
  76. public RSArea thirdDoors = new RSArea(new RSTile(2045,5195), new RSTile(2046,5197));
  77. public RSArea spot = new RSArea(new RSTile(2035, 5185), new RSTile(2046, 5194));
  78.  
  79. public RSTile laberintP[] = { new RSTile (2044,5236), new RSTile(2045,5221), new RSTile(2037,5208) } ;
  80.  
  81. public RSTile Door1EnA = new RSTile (2044,5240);
  82. public RSTile Door1EnB = new RSTile (2044,5239);
  83. public RSTile Door1ExA = new RSTile (2044,5237);
  84. public RSTile Door1ExB = new RSTile (2044,5236);
  85.  
  86. public RSTile Door2EnA = new RSTile (2037,5204);
  87. public RSTile Door2EnB = new RSTile (2037,5203);
  88. public RSTile Door2ExA = new RSTile (2037,5201);
  89. public RSTile Door2ExB = new RSTile (2037,5200);
  90.  
  91. public RSTile Door3EnA = new RSTile (2046,5198);
  92. public RSTile Door3EnB = new RSTile (2046,5197);
  93. public RSTile Door3ExA = new RSTile (2045,5195);
  94. public RSTile Door3ExB = new RSTile (2045,5194);
  95. //
  96. //AREA 7,5 -> ROPE
  97. public int ministate = 0;
  98. public int failcount = 0;
  99. public double startExp[] = null;
  100. public double expGained[] = null;
  101. public double expPerHour[] = null;
  102. public int expG, auxExp, noexpcounter;
  103. public float totalSec = 0;
  104.  
  105.  
  106. private final int tuna=361, lobster=379, sf=373;
  107. private int[] food = { tuna, lobster, sf};
  108. private int chosenfood;
  109. ////////////////////////////HERE-STATES///////////////////////////
  110. int area, state = 1; //HERE CHECK THIS TODO
  111. final int banking = 0, walkingtospot = 1, fighting = 2, runningaway = 3;
  112. public boolean tripcounted = false;
  113. public int trips = 0;
  114. //////////////////////////////////////////////////////////////////////
  115. @Override
  116. public int loop() {
  117. if (getInterface(579).isValid()) {
  118. atInterface(getInterface(579).getChild(17), "Yes");
  119. return 500;
  120. }
  121. if (!isRunning() && getEnergy() > random(50, 75)) {
  122. setRun(true);
  123. wait(random(400, 800));
  124. }
  125.  
  126. switch (state) {
  127. case banking:
  128. manageBank();
  129. return 500;
  130. case walkingtospot:
  131. manageArea();
  132. return 500;
  133. case fighting:
  134. manageFight();
  135. return 500;
  136. case runningaway:
  137. manageRunAway();
  138. return 500;
  139. }
  140.  
  141. return (random(100, 200));
  142. }
  143.  
  144. public int whereTheHeckAmI() {
  145. if (outside.contains(getMyPlayer().getLocation())) return atOutside;
  146. if (firstRoom.contains(getMyPlayer().getLocation())) return atFirstRoom; //first level, climb down to the flesh level
  147. if (almostSecondLevel.contains(getMyPlayer().getLocation())) return goSecondLevel;
  148. if (nearStair.contains(getMyPlayer().getLocation())) return nearStairs;
  149. if (firstDoors.contains(getMyPlayer().getLocation())) return atFDoors;
  150. if (laberint.contains(getMyPlayer().getLocation())) return atLaberint;
  151. if (secondDoors.contains(getMyPlayer().getLocation())) return atSDoors;
  152. if (afterLaberint.contains(getMyPlayer().getLocation())) return atAfterLaberint; //swapped
  153. if (thirdDoors.contains(getMyPlayer().getLocation())) return atTDoors;//these two are swapped because of the overlap
  154. if (beforeCrawlers.contains(getMyPlayer().getLocation())) return atBeforeCrawlers; //these two are swapped because of the overlap
  155. if (spot.contains(getMyPlayer().getLocation())) return atSpot;
  156.  
  157. return -1;
  158. }
  159. public RSArea whereTheHeckAmIArea() {
  160. if (outside.contains(getMyPlayer().getLocation())) return outside;
  161. if (firstRoom.contains(getMyPlayer().getLocation())) return firstRoom; //first level, climb down to the flesh level
  162. if (almostSecondLevel.contains(getMyPlayer().getLocation())) return almostSecondLevel;
  163. if (nearStair.contains(getMyPlayer().getLocation())) return nearStair;
  164. if (firstDoors.contains(getMyPlayer().getLocation())) return firstDoors;
  165. if (laberint.contains(getMyPlayer().getLocation())) return laberint;
  166. if (secondDoors.contains(getMyPlayer().getLocation())) return secondDoors;
  167. if (afterLaberint.contains(getMyPlayer().getLocation())) return afterLaberint; //swapped
  168. if (thirdDoors.contains(getMyPlayer().getLocation())) return thirdDoors; //swapped
  169. if (beforeCrawlers.contains(getMyPlayer().getLocation())) return beforeCrawlers; //swapped
  170. if (spot.contains(getMyPlayer().getLocation())) return spot;
  171. return outside;
  172. }
  173. private void highlightArea(final Graphics g, final RSArea a, final Color border, final Color fill) {
  174. RSTile t;
  175. g.setColor(fill);
  176. RSTile[][] tiles = a.getTiles();
  177. for (int x = 0; x < tiles.length; x++) {
  178. for (int y = 0; y < tiles[x].length; y++) {
  179. Point screen = tileToMinimap(tiles[x][y]);
  180. g.drawRect((int) screen.getX(), (int) screen.getY(), 2, 2);
  181. }
  182. }
  183. //pick max X maxY minX minY and g.fillRect() them
  184. /*PROBABLY SHOULD ONLY DRAW BORDERS...*/
  185. }
  186. public void manageBank() {
  187. if (!bank.isOpen()) {
  188. state = runningaway;
  189. return;
  190. }
  191. if (getInventoryCount() > 0 && getInventoryCount(chosenfood) < 2) bank.depositAll();
  192. wait(300);
  193. if (getInventoryCount(chosenfood) > 20) {
  194. state = walkingtospot;
  195. return;
  196. }
  197. if (bank.getCount(chosenfood) < 28) {
  198. log("not enough food");
  199. stopScript();
  200. return;
  201. }
  202. bank.withdraw(chosenfood,0);
  203.  
  204. }
  205. public void manageArea() {
  206. area = whereTheHeckAmI();
  207. state = walkingtospot;
  208. switch (area) {
  209. case atOutside:
  210. if (distanceTo(bankToDungeon[bankToDungeon.length -1]) > 5) {
  211. if (!tileOnScreen(bankToDungeon[bankToDungeon.length -1])) {
  212. walkPathMM(bankToDungeon);
  213. wait(500);
  214. return;
  215. } else {
  216. walkTileOnScreen(bankToDungeon[bankToDungeon.length -1]);
  217. wait(500);
  218. return;
  219. }
  220. }
  221. if (getNearestObjectByID(entranceID)!=null) {
  222. if (!tileOnScreen(entranceTile)) {
  223. walkTileMM(entranceTile,0,0);
  224. wait(500);
  225. return;
  226. } else {
  227. atObject(getNearestObjectByID(entranceID), "Climb-down");
  228. wait(500);
  229. return;
  230. }
  231. }
  232. case atFirstRoom:
  233. if (getNearestObjectByID(portalFirstLevelID)!=null) {
  234. if (!tileOnScreen(getNearestObjectByID(portalFirstLevelID).getLocation())) {
  235. walkTileMM(getNearestObjectByID(portalFirstLevelID).getLocation(),0,0);
  236. wait(500);
  237. return;
  238. } else {
  239. atObject(getNearestObjectByID(portalFirstLevelID), "Enter");
  240. wait(500);
  241. return;
  242. }
  243. }
  244. case goSecondLevel:
  245. if (getNearestObjectByID(stairToSecondLevel)!=null) {
  246. if (!tileOnScreen(getNearestObjectByID(stairToSecondLevel).getLocation())) {
  247. walkTileMM(getNearestObjectByID(stairToSecondLevel).getLocation(),0,0);
  248. wait(500);
  249. return;
  250. } else {
  251. atObject(getNearestObjectByID(stairToSecondLevel), "Climb-down");
  252. wait(500);
  253. return;
  254. }
  255. }
  256. case nearStairs:
  257. if(distanceTo(new RSTile(2044,5240)) > 1) {
  258. walkTileOnScreen(new RSTile(2044,5240)); //don't do it on MM
  259. wait(500);
  260. return;
  261. }
  262. if (distanceTo(Door1EnA) < 2) {
  263. atDoorTiles(Door1EnA, Door1EnB);
  264. wait(500);
  265. return;
  266. }
  267. case atFDoors:
  268. if(distanceTo(new RSTile(2044,5238)) >1) {
  269. walkTileOnScreen(new RSTile(2044,5238));
  270. wait(500);
  271. return;
  272. }
  273. if (distanceTo(Door1ExA) < 2) {
  274. atDoorTiles(Door1ExA, Door1ExB);
  275. wait(500);
  276. return;
  277. }
  278.  
  279. case atLaberint:
  280. walkPathMM(laberintP);
  281. while (getMyPlayer().isMoving()) {
  282. wait(300);
  283. return;
  284. }
  285. if (distanceTo(laberintP[laberintP.length -1]) < 5 && distanceTo(new RSTile(2037,5204)) > 1) {
  286. if (tileOnScreen(new RSTile(2037,5204))){
  287. walkTileOnScreen(new RSTile(2037,5204));
  288. wait(500);
  289. return;
  290. } else {
  291. walkTileMM(new RSTile(2037,5204),0,0);
  292. wait(500);
  293. return;
  294. }
  295. }
  296.  
  297. case atAfterLaberint:
  298. if (tileOnScreen(Door2EnA) && distanceTo(Door2EnA) > 1) {
  299. walkTileOnScreen(Door2EnA);
  300. } else if (!tileOnScreen(Door2EnA)) {
  301. walkTileMM(Door2EnA);
  302. }
  303. if (distanceTo(new RSTile(2037,5204)) < 2) {
  304. atDoorTiles(Door2EnA, Door2EnB);
  305. wait(500);
  306. return;
  307. }
  308.  
  309. case atSDoors:
  310. if(distanceTo(new RSTile(2037,5201)) > 1) {
  311. walkTileOnScreen(new RSTile(2037,5201));
  312. wait(500);
  313. return;
  314. }
  315. if (distanceTo(Door2ExA) < 2) {
  316. atDoorTiles(Door2ExA, Door2ExB);
  317. wait(500);
  318. return;
  319. }
  320. case atBeforeCrawlers:
  321. if (distanceTo(new RSTile(2046,5198)) > 1 && !tileOnScreen(new RSTile(2046,5198))) {
  322. walkTileMM(new RSTile(2046,5198),0,0);
  323. wait(500);
  324. return;
  325. }
  326. if (distanceTo(new RSTile(2046,5198)) > 1) {
  327. walkTileOnScreen(new RSTile(2046,5198));
  328. wait(500);
  329. return;
  330. }
  331. atDoorTiles(Door3EnA, Door3EnB);
  332. wait(500);
  333. return;
  334. case atTDoors:
  335. if(distanceTo(new RSTile(2045,5195)) > 1) {
  336. walkTileOnScreen(new RSTile(2045,5195));
  337. wait(500);
  338. return;
  339. }
  340. if (distanceTo(Door3ExA) < 2) {
  341. atDoorTiles(Door3ExA,Door3ExB);
  342. wait(500);
  343. return;
  344. }
  345. case atSpot:
  346. state = fighting;
  347.  
  348. }
  349. wait(600);
  350. return;
  351. }
  352. public void manageFight() {
  353. if (getInventoryCount(food) < 1) {
  354. state = runningaway;
  355. //RUN AWAY
  356. }
  357. if (skills.getCurrentSkillLevel(STAT_HITPOINTS) <= 10) { // eat, we are dying
  358. //RUN AWAY
  359. state = runningaway;
  360. }
  361. manageEating();
  362.  
  363. /*
  364.  
  365. if (getInventoryCount(arrow) > 50) {
  366. atInventoryItem(arrow, "Wield");
  367. return 600;
  368. }*/
  369.  
  370. if (getMyPlayer().getInteracting() == null) { // doing nothing .. go attack
  371. crawler = getNearestFreeNPCToAttackByID(4390);
  372. if (crawler == null) {
  373. wait (500);
  374. return ;
  375. }// no crawler what the hell
  376.  
  377. if (!tileOnScreen(crawler.getLocation()) && !getMyPlayer().isMoving()){// crawler is away, go there
  378. walkTileMM(crawler.getLocation(),0,0);
  379. wait(500);
  380. return ;
  381. }
  382. if(crawler != null ) clickRSNPC(crawler, "Attack"); // we are near the crawler, DIE!
  383. wait(800);
  384. return;
  385. }
  386. }
  387. public void manageEating() {
  388. if (getInventoryCount(chosenfood) == 0) {
  389. state = runningaway;
  390. wait(500);
  391. return;
  392. }
  393. if (hplost() > 15) {
  394. atInventoryItem(chosenfood, "Eat");
  395. if (getMyPlayer().getInteracting() != null) wait(1400);
  396. wait(600);
  397. return;
  398. }
  399. }
  400. private int hplost() {
  401. return (skills.getRealSkillLevel(STAT_HITPOINTS) - skills.getCurrentSkillLevel(STAT_HITPOINTS));
  402. }
  403. public void manageRunAway() {
  404. state = runningaway;
  405. switch (whereTheHeckAmI()) {
  406. case atSpot:
  407. if (distanceTo(new RSTile(2045,5194)) > 1) {
  408. if (!tileOnScreen(new RSTile(2045,5194))) {
  409. walkTileMM(new RSTile(2045,5194));
  410. return;
  411. } else {
  412. walkTileOnScreen(new RSTile(2045,5194));
  413. return;
  414. }
  415. }
  416. //if (getNearestObjectByID(doorID) != null) {
  417. if (distanceTo(getNearestObjectByID(doorID).getLocation()) < 2) {
  418. atDoorTiles(Door3ExA, Door3ExB);
  419. //atObject(getNearestObjectByID(doorID), "Open");
  420. return;
  421. }
  422. //}
  423. case atTDoors:
  424. if(distanceTo(new RSTile(2046,5197)) > 1) {
  425. walkTileOnScreen(new RSTile(2046,5197));
  426. return;
  427. }
  428. //if (getNearestObjectByID(doorID) != null) {
  429. if (distanceTo(Door3EnA) < 2) {
  430. atDoorTiles(Door3EnA, Door3EnB);
  431. return;
  432. }
  433. case atBeforeCrawlers:
  434. if (distanceTo(new RSTile(2041,5208)) > 2) {
  435. if (tileOnScreen(new RSTile(2041,5208))) {
  436. walkTileOnScreen(new RSTile(2041,5208));
  437. } else {
  438. walkTileMM(new RSTile(2041,5208));
  439. }
  440. return;
  441. }
  442. if (getNearestObjectByID(ropeID) != null) {
  443. atObject(getNearestObjectByID(ropeID), "Climb-up");
  444. return;
  445. }
  446. case nearStairs:
  447. if (getNearestObjectByID(stairIDF2) != null) {
  448. atObject(getNearestObjectByID(stairIDF2), "Climb-up");
  449. return;
  450. }
  451. //case goSecondLevel: stairs up go directly to 1 floor
  452. case atFirstRoom:
  453. if (getNearestObjectByID(exitID) != null) {
  454. atObject(getNearestObjectByID(exitID), "Climb-up");
  455. return;
  456. }
  457. case atOutside:
  458. if (!tileOnScreen(bankToDungeon[0])) {
  459. walkPathMM(reversePath(bankToDungeon),0,0);
  460. wait(600);
  461. return;
  462. }
  463. if (distanceTo(bankToDungeon[0]) > 5) {
  464. walkTileOnScreen(bankToDungeon[0]);
  465. wait(600);
  466. return ;
  467. }
  468. if (!bank.isOpen()) {
  469. bank.open();
  470. wait(500);
  471. return;
  472. } else {
  473. state = banking;
  474. return;
  475. }
  476.  
  477. }
  478. }
  479.  
  480. public void onRepaint(final Graphics g) {
  481. if (!isLoggedIn()) return;
  482. long millis = System.currentTimeMillis() - startTime;
  483. long noexpmillis =System.currentTimeMillis();
  484. final long hours = millis / (1000 * 60 * 60);
  485. millis -= hours * 1000 * 60 * 60;
  486. final long minutes = millis / (1000 * 60);
  487. millis -= minutes * 1000 * 60;
  488. final long seconds = millis / 1000;
  489. totalSec = hours * 3600 + minutes * 60 + seconds;
  490.  
  491. if (auxExp < expG) { //gained exp, reset counter
  492. auxExp = expG;
  493. lastExpTime = System.currentTimeMillis();
  494. }
  495.  
  496. if ((noexpmillis - lastExpTime)/ 1000 >= 600 && lastExpTime> 0) { //seconds 600 = 10 mins
  497.  
  498. log("10 minutes without getting exp, logging off");
  499. stopScript();
  500. // mb add world swithcing?
  501. }
  502.  
  503. if (whereTheHeckAmIArea() != outside) highlightArea(g, whereTheHeckAmIArea(), new Color(255,0,0), new Color(250,201,14,100));
  504. //not yet
  505.  
  506. g.setColor(new Color(0,0,0,100));
  507. g.fillRoundRect(528,281,229,181,10,10);
  508.  
  509. g.setColor(Color.white);
  510. g.drawString("Coco's crawler killer", 593,295);
  511.  
  512. int counter = 0;
  513. expG = 0;
  514. for ( int i = 0; i < 7; i++ ) {
  515. if ((startExp != null) && ((skills.getCurrentSkillExp(i) - startExp[i]) > 0)) {
  516. expGained[i] =skills.getCurrentSkillExp(i) - startExp[i]; // exp gained
  517. expPerHour[i] = skills.getXPToNextLevel(i) /* xp left */ / (expGained[i] / totalSec );
  518. expPerHour[i] = expPerHour[i] / 60;
  519. expG = expG + (int)expGained[i];
  520. counter++;
  521.  
  522. g.drawString(skills.statsArray[i],540, 320 + (15*counter));
  523. g.drawLine(535, 323 + (15*counter), 750,323 + (15*counter)); //separates skills
  524.  
  525. if (totalSec >=60) {
  526. if ((double)expPerHour[i] >= 1) {
  527. g.drawString(""+(int)expGained[i],598, 320 + (15*counter));
  528. g.drawString(getFormattedNumber((double)expPerHour[i]) + "min", 643, 320 + (15*counter));
  529. g.drawString(""+ (int) ((expGained[i] *3600/ totalSec)), 700, 320 + (15*counter));
  530. }
  531. } else {
  532. g.drawString(""+(int)expGained[i],598, 320 + (15*counter));
  533. g.drawString("Wait", 648, 320 + (15*counter));
  534. g.drawString("till min >= 1", 700, 320 + (15*counter));
  535. }
  536. }
  537. }
  538. g.drawString("State: " + statetostring(state) + " area: " +whereTheHeckAmI(), 540, 440);
  539. g.drawString("Runtime: " + hours + " hs " + minutes + " min " + seconds + " secs.", 540, 455);
  540.  
  541. //53 cada parte, ~32 de "SKILL" -> 10 al startx
  542. g.drawLine(535, 300, 750,300); //underlines script name
  543. g.drawString("SKILL", 545, 315);
  544. g.drawLine(535, 320, 750,320); //underline "SKILL",, etc
  545. g.drawLine(588, 300,588, 410); //second column divider SKILL || EXPG
  546. g.drawString("EXP G", 598, 315);
  547. g.drawLine(641, 300,641, 410); //third column divider EXPG || TIME LEFT
  548. g.drawString("Time L", 648, 315);
  549. g.drawLine(694, 300,694, 410); //foruth column divider TIME LEFT || %
  550. g.drawString("Exp/Hour", 700, 315);
  551. }
  552. public String statetostring(int s) {
  553. if (s == 0) return "Banking";
  554. if (s == 1) return "Walking to the spot";
  555. if (s == 2) return "Fighting";
  556. if (s == 3) return "Running away";
  557. return "HUH?";
  558. }
  559. @Override
  560. protected int getMouseSpeed() {
  561. return 6;
  562. }
  563. @Override
  564. public boolean onStart(final Map<String, String> args) {
  565.  
  566. startExp = new double[7];
  567. expGained = new double[7];
  568. expPerHour = new double[7];
  569.  
  570. for ( int i = 0; i < 7; i++ ) {
  571. startExp[i] = skills.getCurrentSkillExp(i);
  572. }
  573.  
  574. if (args.get("food").equals("Tuna")) chosenfood = tuna;
  575. if (args.get("food").equals("Lobster")) chosenfood = lobster;
  576. startTime = System.currentTimeMillis();
  577. log("eating : " + args.get("food"));
  578. setCameraAltitude(true);
  579. state = manageInitialState();
  580. return true;
  581. }
  582. public int manageInitialState() {
  583. if (getInventoryCount(chosenfood) > 0 && whereTheHeckAmI() == atSpot) return fighting;
  584. if ( (whereTheHeckAmI() == atOutside && getInventoryCount(chosenfood) < 10) || getInventoryCount(chosenfood) == 0) return banking;
  585. if (getInventoryCount(chosenfood) >= 2) return walkingtospot;
  586. if (getInventoryCount(chosenfood) <= 1) return runningaway;
  587. return -1;
  588. }
  589. public void serverMessageRecieved( ServerMessageEvent arg0 ) {
  590. String serverString = arg0.getMessage();
  591. if (serverString.contains("You've just") || serverString.contains("Congratulations")) {
  592. log("You just advanced a level, attempting to click continue!");
  593. levelup++;
  594. wait(random(1500, 2500));
  595. if (canContinue()) {
  596. clickContinue();
  597. }
  598. }
  599. if (serverString.contains("already under attack")) {
  600. if (getMyPlayer().getInteracting() != null) {
  601. RSCharacter npc = getMyPlayer().getInteracting();
  602. if (npc != null) {
  603. clickCharacter(npc, "Attack");
  604. wait(1000);
  605. return ;
  606. }
  607. }
  608. }
  609. if (serverString.contains("no ammo left in") || serverString.contains("quiver")) {
  610. log("no ammo cya");
  611.  
  612. openTab(TAB_EQUIPMENT);
  613. atInterface(getInterface(387).getChild(17), "Remove");
  614.  
  615. stopScript();
  616. }
  617. }
  618. public void onFinish() {
  619. int i = 0;
  620. log ("After " + getFormattedNumber((double)(totalSec / 60)) + " minutes: ");
  621. for ( i = 0; i < 7; i++ ) {
  622. if ((startExp != null) && ((skills.getCurrentSkillExp(i) - startExp[i]) > 0)) {
  623. log("Gained: " + expGained[i] + " exp on " + skills.statsArray[i]);
  624. }
  625. }
  626.  
  627.  
  628. }
  629. public boolean customRest() {
  630. //int energy = getEnergy();
  631. for (int d = 0; d < 5; d++) {
  632. atInterface(Constants.INTERFACE_RUN, 1, "Rest");
  633. moveMouseSlightly();
  634. wait(random(400, 600));
  635. if (getMyPlayer().getAnimation() == 12108
  636. || getMyPlayer().getAnimation() == 2033
  637. || getMyPlayer().getAnimation() == 2716
  638. || getMyPlayer().getAnimation() == 11786
  639. || getMyPlayer().getAnimation() == 5713) {
  640. break;
  641. }
  642. if (d == 4) {
  643. log("Rest failed!");
  644. return false;
  645. }
  646. }
  647. while (crawler == null) {
  648. crawler = getNearestFreeNPCToAttackByID(4390);
  649. wait(random(250, 500));
  650. }
  651. return true;
  652. }
  653. public String getFormattedNumber(Double p_number) {
  654. NumberFormat l_nf = NumberFormat.getInstance();
  655. String l_rVal; // Valor de retorno de la función.
  656.  
  657. l_nf.setMaximumFractionDigits(1); // 2 decimales como mucho y como poco
  658. l_nf.setMinimumFractionDigits(1);
  659.  
  660. l_rVal = new String ( l_nf.format(p_number.doubleValue()));
  661.  
  662. return l_rVal;
  663. }
  664. }
Add Comment
Please, Sign In to add comment