Advertisement
Guest User

Untitled

a guest
Jan 30th, 2013
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.07 KB | None | 0 0
  1.  
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Image;
  7. import java.awt.Point;
  8. import java.io.IOException;
  9. import java.net.URL;
  10. import java.util.ArrayList;
  11.  
  12. import javax.imageio.ImageIO;
  13.  
  14. import com.rarebot.event.listeners.PaintListener;
  15. import com.rarebot.script.Script;
  16. import com.rarebot.script.ScriptManifest;
  17. import com.rarebot.script.methods.Skills;
  18. import com.rarebot.script.util.Timer;
  19. import com.rarebot.script.wrappers.RSArea;
  20. import com.rarebot.script.wrappers.RSGroundItem;
  21. import com.rarebot.script.wrappers.RSNPC;
  22. import com.rarebot.script.wrappers.RSTile;
  23.  
  24. @ScriptManifest(authors = { "Swipe" }, name = "ExtremeHunter")
  25. public class ExtremeHunter extends Script implements PaintListener {
  26. // START: Code generated using Enfilade's Easel
  27. private Image getImage(String url) {
  28. try {
  29. return ImageIO.read(new URL(url));
  30. } catch (IOException e) {
  31. return null;
  32. }
  33. }
  34.  
  35. private final int GREY_CHIN = 5079;
  36. private final int trapItem = 10008;
  37. private final int trapFailed = 19192;
  38. private final int trapCaught = 19190;
  39. private final int trapSetup = 19187;
  40. public final RSArea maBANK = new RSArea(new RSTile[] {
  41. new RSTile(2399, 2845), new RSTile(2399, 2838),
  42. new RSTile(2405, 2838), new RSTile(2405, 2844) });
  43. public final RSArea C_SWIFT = new RSArea(new RSTile[] {
  44. new RSTile(2606, 2933), new RSTile(2602, 2914),
  45. new RSTile(2606, 2910), new RSTile(2616, 2918),
  46. new RSTile(2622, 2927), new RSTile(2615, 2935) });
  47. public final RSArea T_WAGTAIL = new RSArea(new RSTile[] {
  48. new RSTile(2518, 2901), new RSTile(2520, 2917),
  49. new RSTile(2507, 2917), new RSTile(2507, 2904) });
  50. public final RSArea G_CHIN = new RSArea(new RSTile[] {
  51. new RSTile(2345, 3540), new RSTile(2345, 3540),
  52. new RSTile(2345, 3526), new RSTile(2357, 3526),
  53. new RSTile(2353, 3533), new RSTile(2358, 3540) });
  54. public final RSArea R_CHIN = new RSArea(new RSTile[] {
  55. new RSTile(2517, 2905), new RSTile(2516, 2886),
  56. new RSTile(2542, 2886), new RSTile(2539, 2902) });
  57. private final Image img1 = getImage("http://i.imgur.com/JlOte.png");
  58. // private final Image troll =
  59. // getImage("http://revolushii.ro/forum/Smileys/smileys/trollface.png");
  60. private String status = "Hunting";
  61. private int expGain = 0;
  62. private final int raw_meat = 9978;
  63. private final int BIRD_SNARE = 10006;
  64. private final int SET_SNARE = 19175;
  65. private final int[] DONE_SNARE = { 19180, 19178 };
  66. private final int C_SWIFT_ID = 5073;
  67. private final int T_WAG_ID = 5072;
  68. private final int trapID = 10008;
  69.  
  70. int startLevel;
  71. private int fail = 300;
  72.  
  73. private boolean banking;
  74. private ArrayList<RSTile> mySnares = new ArrayList<RSTile>();
  75. private long startTime;
  76. RSTile mainTrap;
  77. int startExp;
  78. public Job[] jobs = getJobs();
  79. final int butterflyJar = 10012;
  80. final int[] dropIDs = { 9978, 10115, 10125, 10127 }, buryIDs = { 526 },
  81. releaseIDs = { 10149, 10146, 10147, 10148, 10092 }, trapIDs = {
  82. 10006, 10008, 303, 954, 19965 }, layedTraps = { 19187,
  83. 19175, 19678, 19650, 19662 }, failedTraps = { 19192, 19174,
  84. 56813 }, layTrapHere = { 19679, 19652, 19663 },
  85. collapsedTraps = { 19190, 19180, 19178, 19182, 19189, 19675, 19186,
  86. 19654, 19659, 19184, 56819, 19191, 56821 },
  87. catchedButterflies = { 10014, 10016, 10018, 10020 },
  88. falconTargets = { 5098, 5099, 5100 }, falconSuccessful = { 5094,
  89. 5095, 5096 };
  90. RSTile startLoc, clickedFalcon;
  91. Image Background, Background2, Show, turnOffImage, startImg;
  92. boolean[] huntTrap = { false, false, false, false, true, false, false,
  93. false, false };
  94. RSTile[] traps = { null, null, null, null, null }, notMyFalcons = { null,
  95. null, null, null, null };
  96. int[] objAt = { 0, 0, 0, 0, 0 }, trapsX = { 0, 0, 0, 0, 0 }, trapsY = { 0,
  97. 0, 0, 0, 0 }, butterflyIDs = { 5082, 5084, 5085 },
  98. butterflyIDs2 = { 5082, 5083, 5084, 5085 };
  99. int[] jujuPot = { 20026, 20025, 20024, 20023 };
  100. /* Defining areas */
  101. final int[] bankArea = { 3507, 3475, 3513, 3483 }, swampLizardArea = {
  102. 3533, 3432, 3581, 3454 }, orangeSalamanderArea = { 3398, 3072,
  103. 3422, 3151 }, redSalamanderArea = { 2440, 3210, 2482, 3261 },
  104. falconryArea = { 2364, 3573, 2392, 3619 };
  105. final int[][] swampLizard = { { 3546, 3437, 3555, 3443 },
  106. { 3547, 3448, 3558, 3454 }, { 3535, 3450, 3539, 3452 } },
  107. orangeSalamander = { { 3410, 3072, 3417, 3079 },
  108. { 3408, 3080, 3413, 3083 }, { 3402, 3086, 3412, 3094 },
  109. { 3400, 3099, 3406, 3102 }, { 3401, 3131, 3410, 3136 } },
  110. redSalamander = { { 2466, 3234, 2480, 3246 },
  111. { 2445, 3220, 2452, 3228 }, { 2450, 3216, 2456, 3222 } },
  112. butterflyAreas = { { 2537, 2898, 2570, 2917 },
  113. { 2306, 3506, 2361, 3621 }, { 2690, 3758, 2747, 3802 },
  114. { 2702, 3803, 2740, 3838 } },
  115. butterflyStartingLocations = { { 2558, 2910 }, { 2322, 3600 },
  116. { 2714, 3792 }, { 2711, 3822 } };
  117.  
  118. private void drawTile(Graphics render, RSTile tile, Color color) {
  119. Point southwest = calc.tileToScreen(tile, 0, 0, 0);
  120. Point southeast = calc.tileToScreen(
  121. new RSTile(tile.getX() + 1, tile.getY()), 0, 0, 0);
  122. Point northwest = calc.tileToScreen(new RSTile(tile.getX(),
  123. tile.getY() + 1), 0, 0, 0);
  124. Point northeast = calc.tileToScreen(
  125. new RSTile(tile.getX() + 1, tile.getY() + 1), 0, 0, 0);
  126.  
  127. if (calc.pointOnScreen(southwest) && calc.pointOnScreen(southeast)
  128. && calc.pointOnScreen(northwest)
  129. && calc.pointOnScreen(northeast)) {
  130. render.setColor(Color.BLACK);
  131. render.drawPolygon(new int[] { (int) northwest.getX(),
  132. (int) northeast.getX(), (int) southeast.getX(),
  133. (int) southwest.getX() },
  134. new int[] { (int) northwest.getY(), (int) northeast.getY(),
  135. (int) southeast.getY(), (int) southwest.getY() }, 4);
  136. render.setColor(color);
  137. render.fillPolygon(new int[] { (int) northwest.getX(),
  138. (int) northeast.getX(), (int) southeast.getX(),
  139. (int) southwest.getX() },
  140. new int[] { (int) northwest.getY(), (int) northeast.getY(),
  141. (int) southeast.getY(), (int) southwest.getY() }, 4);
  142. }
  143. }
  144.  
  145. public void onRepaint(Graphics g1) {
  146. Graphics2D g = (Graphics2D) g1;
  147. g.drawImage(img1, 0, 336, null);
  148. g.setColor(Color.black);
  149. g.setFont(new Font("Arial", 0, 12));
  150. g.drawString(status, 108, 395);
  151. expGain = skills.getCurrentExp(Skills.HUNTER) - startExp;
  152. g.drawString(expGain + " (+"
  153. + (skills.getRealLevel(Skills.HUNTER) - startLevel) + ") ",
  154. 148, 418);
  155. if (ChinTraps != null) {
  156. if (getCurrentJob().reqLevel() == 53) {
  157. g.drawString(
  158. (skills.getCurrentExp(Skills.HUNTER) - startExp)
  159. / 198
  160. + " Chins = "
  161. + ((skills.getCurrentExp(Skills.HUNTER) - startExp) / 198)
  162. * 655 + " gp", 250, 410);
  163. } else {
  164. g.drawString(
  165. (skills.getCurrentExp(Skills.HUNTER) - startExp)
  166. / 255
  167. + " Chins = "
  168. + ((skills.getCurrentExp(Skills.HUNTER) - startExp) / 255)
  169. * 905 + " gp", 250, 410);
  170. }
  171. }
  172. g.drawString(
  173. ""
  174. + (int) (((expGain)) * 3600000D / (System
  175. .currentTimeMillis() - startTime)) + " (+"
  176. + (skills.getRealLevel(Skills.HUNTER) - startLevel)
  177. * 3600000D / (System.currentTimeMillis() - startTime)
  178. + ") ", 112, 435);
  179. g.drawString(
  180. Timer.format(skills.getTimeTillNextLevel(Skills.HUNTER,
  181. (int) ((skills.getRealLevel(Skills.HUNTER) - startLevel) * 3600000D / (System
  182. .currentTimeMillis() - startTime)), System.currentTimeMillis() - startTime))
  183. + " || Total Time: "
  184. + Timer.format(System.currentTimeMillis() - startTime),
  185. 180, 454);
  186. g.setColor(new Color(250, 20, 20, 180));
  187. g.fillRoundRect(245, 385, 196, 12, 16, 16);
  188. g.setColor(new Color(20, 220, 20, 180));
  189. g.fillRoundRect(
  190. 245,
  191. 385,
  192. (int) ((int) skills.getPercentToNextLevel(Skills.HUNTER) * 1.96),
  193. 12, 16, 16);
  194. g.setColor(Color.BLACK);
  195. g.drawString(
  196. skills.getPercentToNextLevel(Skills.HUNTER) + "% to Level "
  197. + (skills.getCurrentLevel(Skills.HUNTER) + 1)
  198. + " Hunter - ("
  199. + skills.getExpToNextLevel(Skills.HUNTER) + ")", 250,
  200. 395);
  201. Point mLoc = mouse.getLocation();
  202. g.setColor(new Color(20, 230, 40, 180));
  203. g.drawLine(mLoc.x, 0, mLoc.x, 502);
  204. g.drawLine(0, mLoc.y, 764, mLoc.y);
  205. for (RSTile t : mySnares) {
  206. drawTile(g, t, new Color(200, 200, 200, 100));
  207. g.fillRect(calc.tileToMinimap(t).x, calc.tileToMinimap(t).y, 4, 4);
  208. g.setColor(new Color(30, 220, 80, 120));
  209. // objects.getTopAt(t).getModel().drawWireFrame(g);
  210. }
  211. RSNPC[] bird = npcs.getAll(C_SWIFT_ID, T_WAG_ID);
  212. for (int i = 0; i < mySnares.size(); i++) {
  213. for (RSNPC npc : bird) {
  214. g.drawLine(calc.tileToMinimap(npc.getLocation()).x,
  215. calc.tileToMinimap(npc.getLocation()).y,
  216. calc.tileToMinimap(mySnares.get(i)).x,
  217. calc.tileToMinimap(mySnares.get(i)).y);
  218. g.setColor(Color.WHITE);
  219. if (npc.isOnScreen()) {
  220. // g.drawImage(troll, npc.getModel().getPointOnScreen().x,
  221. // npc
  222. // .getModel().getPointOnScreen().y, null);
  223. g.drawString(
  224. "Distance (Trap "
  225. + (i + 1)
  226. + ")"
  227. + ": "
  228. + calc.distanceBetween(npc.getLocation(),
  229. mySnares.get(i)), npc.getModel()
  230. .getPointOnScreen().x, npc.getModel()
  231. .getPointOnScreen().y + (i * 8));
  232. }
  233. }
  234. }
  235. if (fail < 300) {
  236. g.drawString("FUCK! WE FAILED", 10, 10);
  237. fail++;
  238. }
  239. if (ChinTraps != null) {
  240. for (RSTile t : ChinTraps) {
  241. switch (objects.getTopAt(t).getID()) {
  242. case trapSetup:
  243. drawTile(g, t, Transparent(Color.YELLOW, 80));
  244. break;
  245. case trapFailed:
  246. drawTile(g, t, Transparent(Color.RED, 80));
  247. break;
  248. case 19189:
  249. drawTile(g, t, Transparent(Color.GREEN, 80));
  250. break;
  251. case 19190:
  252. drawTile(g, t, Transparent(Color.GREEN, 80));
  253. break;
  254. }
  255. }
  256. }
  257. }
  258.  
  259. private Color Transparent(Color c, int trans) {
  260. return new Color(c.getRed(), c.getGreen(), c.getBlue(), trans);
  261. }
  262.  
  263. private int getMaxTrapAmount() {
  264. int lvl = skills.getRealLevel(skills.HUNTER);
  265. if (lvl >= 80) {
  266. return 5;
  267. } else if (lvl >= 60) {
  268. return 4;
  269. } else if (lvl >= 40) {
  270. return 3;
  271. } else if (lvl >= 20) {
  272. return 2;
  273. }
  274. return 1;
  275. }
  276.  
  277. private RSTile MainTrap;
  278.  
  279. private RSTile[] getWagTraps() {
  280. switch (getMaxTrapAmount()) {
  281. case 2:
  282. return new RSTile[] {
  283. getMyPlayer().getLocation(),
  284. new RSTile(getMyPlayer().getLocation().getX() - 1,
  285. getMyPlayer().getLocation().getY() - 1) };
  286. case 3:
  287. return new RSTile[] {
  288. getMyPlayer().getLocation(),
  289. new RSTile(getMyPlayer().getLocation().getX() - 1,
  290. getMyPlayer().getLocation().getY() + 1),
  291. new RSTile(getMyPlayer().getLocation().getX() - 1,
  292. getMyPlayer().getLocation().getY() - 1) };
  293. }
  294. return null;
  295. }
  296.  
  297. private RSTile[] getChinTraps() {
  298. switch (getMaxTrapAmount()) {
  299. case 3:
  300. return new RSTile[] {
  301. getMyPlayer().getLocation(),
  302. new RSTile(getMyPlayer().getLocation().getX() - 1,
  303. getMyPlayer().getLocation().getY() + 1),
  304. new RSTile(getMyPlayer().getLocation().getX() - 1,
  305. getMyPlayer().getLocation().getY() - 1) };
  306. case 4:
  307. return new RSTile[] {
  308. getMyPlayer().getLocation(),
  309. new RSTile(getMyPlayer().getLocation().getX() - 1,
  310. getMyPlayer().getLocation().getY() + 1),
  311. new RSTile(getMyPlayer().getLocation().getX() - 1,
  312. getMyPlayer().getLocation().getY() - 1),
  313. new RSTile(getMyPlayer().getLocation().getX() - 2,
  314. getMyPlayer().getLocation().getY()) };
  315. case 5:
  316. return new RSTile[] {
  317. getMyPlayer().getLocation(),
  318. new RSTile(getMyPlayer().getLocation().getX() - 1,
  319. getMyPlayer().getLocation().getY() - 1),
  320. new RSTile(getMyPlayer().getLocation().getX() - 1,
  321. getMyPlayer().getLocation().getY() + 1),
  322. new RSTile(getMyPlayer().getLocation().getX() + 1,
  323. getMyPlayer().getLocation().getY() + 1),
  324. new RSTile(getMyPlayer().getLocation().getX() + 1,
  325. getMyPlayer().getLocation().getY() - 1) };
  326. }
  327. return null;
  328. }
  329.  
  330. private RSTile[] WagTraps;
  331. private RSTile[] ChinTraps;
  332.  
  333. private Job[] getJobs() {
  334. Action snareWalkBank = new Action() {
  335. private int DUEL_RING;
  336.  
  337. boolean activate() {
  338. return inventory.getCount(BIRD_SNARE) == 0;
  339. }
  340.  
  341. void run() {
  342. banking = true;
  343. equipment.getItem(DUEL_RING).interact("rub");
  344. mouse.click(
  345. interfaces.getAllContaining("Mobil")[0].getLocation(),
  346. true);
  347. web.getWeb(maBANK.getCentralTile()).step();
  348. }
  349. };
  350. Action snareBank = new Action() {
  351. boolean activate() {
  352. return banking == true
  353. && maBANK.contains(getMyPlayer().getLocation());
  354. }
  355.  
  356. void run() {
  357. if (!bank.isOpen()) {
  358. bank.open();
  359. } else if (bank.isOpen()) {
  360. // If the bone is not null, withdraw it
  361. if (bank.getItem(BIRD_SNARE) != null) {
  362. bank.withdraw(BIRD_SNARE, 24);
  363. bank.close();
  364. }
  365. // If the bird snare is null, stop the script
  366. else {
  367. log("You have no snares in the bank, stopping script!");
  368. env.saveScreenshot(true);
  369. stopScript();
  370. }
  371. }
  372. }
  373. };
  374. Action placeSnare = new Action() {
  375. boolean activate() {
  376. return mySnares.size() < getMaxTrapAmount();
  377. }
  378.  
  379. void run() {
  380. if (MainTrap == null
  381. || !getCurrentJob().mainArea().contains(MainTrap)) {
  382. MainTrap = getMyPlayer().getLocation();
  383. }
  384. while (calc.distanceTo(MainTrap) > 0) {
  385. walking.walkTileOnScreen(MainTrap);
  386. }
  387. mySnares.add(MainTrap);
  388. inventory.getItem(BIRD_SNARE).doClick(true);
  389. sleep(5000);
  390.  
  391. }
  392. };
  393. Action collectSnare = new Action() {
  394.  
  395. boolean activate() {
  396. for (RSTile t : mySnares) {
  397. if (objects.getTopAt(t) != null
  398. && objects.getTopAt(t).getID() == DONE_SNARE[0]) {
  399. MainTrap = t;
  400. return true;
  401. }
  402. }
  403. return false;// TODO
  404. }
  405.  
  406. void run() {
  407. objects.getTopAt(MainTrap).doClick();
  408. sleep(500);
  409. expGain += 34;
  410. mySnares.remove(MainTrap);
  411. }
  412. };
  413.  
  414. Action fallenSnare = new Action() {
  415. boolean activate() {
  416. RSGroundItem g = groundItems.getNearest(BIRD_SNARE);
  417. if (g != null) {
  418. for (RSTile t : mySnares) {
  419. if (g.getLocation().equals(t))
  420. return true;
  421. }
  422. }
  423. return false;
  424. }
  425.  
  426. void run() {
  427. RSGroundItem k = groundItems.getNearest(BIRD_SNARE);
  428. if (k != null)
  429. k.interact("Lay");
  430. sleep(2000);
  431. }
  432. };
  433.  
  434. Job CRIMSON_SWIFTS = new Job() {
  435. int reqLevel() {
  436. return 1;
  437. }
  438.  
  439. int endLevel() {
  440. return 20;
  441. }
  442.  
  443. public RSArea mainArea() {
  444. return C_SWIFT;
  445.  
  446. }
  447. };
  448. CRIMSON_SWIFTS.Steps.add(placeSnare);
  449. CRIMSON_SWIFTS.Steps.add(collectSnare);
  450. CRIMSON_SWIFTS.Steps.add(fallenSnare);
  451. // //////////////////////////////////////////////////////////////////
  452. Action fallenWagSnare = new Action() {
  453. RSTile Next;
  454.  
  455. boolean activate() {
  456. RSGroundItem g = groundItems.getNearest(BIRD_SNARE);
  457. if (g != null) {
  458. for (RSTile t : mySnares) {
  459. if (g.getLocation().equals(t)) {
  460. if (objects.getTopAt(t) == null) {
  461. if (mySnares.size() == getMaxTrapAmount()) {
  462. Next = t;
  463. return true;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. return false;
  470. }
  471.  
  472. void run() {
  473. RSGroundItem k = groundItems.getNearest(BIRD_SNARE);
  474. if (k != null)
  475. k.interact("Lay");
  476. sleep(2000);
  477. }
  478. };
  479. Action placeWagSnare = new Action() {
  480. boolean activate() {
  481. return mySnares.size() < getMaxTrapAmount();
  482. }
  483.  
  484. void run() {
  485. RSTile Next = null;
  486. if (WagTraps == null || WagTraps.length < getMaxTrapAmount()) {
  487. WagTraps = getWagTraps();
  488. }
  489. for (RSTile t : WagTraps) {
  490. if (objects.getTopAt(t) == null) {
  491. Next = t;
  492. break;
  493. }
  494. }
  495. if (Next != null) {
  496. while (calc.distanceTo(Next) > 0) {
  497. walking.walkTileOnScreen(Next);
  498. sleep(1000);
  499. }
  500. mySnares.add(Next);
  501. inventory.getItem(BIRD_SNARE).doClick(true);
  502. sleep(6000);
  503. }
  504. }
  505. };
  506. Action collectWagSnare = new Action() {
  507. RSTile Next;
  508.  
  509. boolean activate() {
  510. for (RSTile t : WagTraps) {
  511. if (objects.getTopAt(t) != null
  512. && objects.getTopAt(t).getID() == DONE_SNARE[1]) {
  513. Next = t;
  514. return true;
  515. }
  516. }
  517. return false;// TODO
  518. }
  519.  
  520. void run() {
  521. objects.getTopAt(Next).doClick();
  522. sleep(500);
  523. expGain += 96;
  524. sleep(500);
  525. mySnares.remove(Next);
  526. }
  527. };
  528. Action dropJunk = new Action() {
  529.  
  530. boolean activate() {
  531. return inventory.containsOneOf(526, raw_meat);
  532. }
  533.  
  534. void run() {
  535. inventory.dropItem(526);
  536. inventory.dropItem(raw_meat);
  537. sleep(500);
  538. }
  539. };
  540. Action failSafe = new Action() {
  541.  
  542. boolean activate() {
  543. for (RSTile t : WagTraps) {
  544. for (RSGroundItem rg : groundItems.getAllAt(t)) {
  545. if (rg.getItem().getID() == BIRD_SNARE) {
  546. if (objects.getTopAt(t) != null) {
  547. rg.interact("take");
  548. }
  549. }
  550. }
  551. }
  552. return false;
  553. }
  554.  
  555. void run() {
  556. log("We fucking failed. Probabaly going crazy with the traps...");
  557. fail = 0;
  558. }
  559. };
  560. Job TROPICAL_WAGTAIL = new Job() {
  561. int reqLevel() {
  562. return 20;
  563. }
  564.  
  565. int endLevel() {
  566. return 53;
  567. }
  568.  
  569. public RSArea mainArea() {
  570. return T_WAGTAIL;
  571.  
  572. }
  573. };
  574. TROPICAL_WAGTAIL.Steps.add(placeWagSnare);
  575. TROPICAL_WAGTAIL.Steps.add(collectWagSnare);
  576. TROPICAL_WAGTAIL.Steps.add(fallenWagSnare);
  577. TROPICAL_WAGTAIL.Steps.add(dropJunk);
  578. TROPICAL_WAGTAIL.Steps.add(failSafe);
  579. CRIMSON_SWIFTS.Steps.add(dropJunk);
  580. Action setTrap = new Action() {
  581. RSTile Next = null;
  582.  
  583. boolean activate() {
  584. if (ChinTraps == null) {
  585. ChinTraps = getChinTraps();
  586. }
  587. for (RSTile t : ChinTraps) {
  588. if (objects.getTopAt(t) == null) {
  589. Next = t;
  590. return true;
  591. }
  592. }
  593. return false;
  594. }
  595.  
  596. void run() {
  597. if (Next != null) {
  598. while (calc.distanceTo(Next) > 0) {
  599. walking.walkTileOnScreen(Next);
  600. sleep(1000);
  601. }
  602. if (groundItems.getAllAt(Next).length == 0) {
  603. inventory.getItem(trapItem).doClick(true);
  604. } else {
  605. groundItems.getAllAt(Next)[0].interact("Lay");
  606. }
  607. sleep(6000);
  608. }
  609. }
  610. };
  611. Action takeTrap = new Action() {
  612. RSTile Next = null;
  613.  
  614. boolean activate() {
  615. for (RSTile t : ChinTraps) {
  616. if (objects.getTopAt(t) != null) {
  617. if (objects.getTopAt(t).getID() == 19189) {
  618. Next = t;
  619. return true;
  620. }
  621. }
  622. }
  623. return false;
  624. }
  625.  
  626. void run() {
  627. if (Next != null) {
  628. if (objects.getTopAt(Next).getID() == 19189) {
  629. objects.getTopAt(Next).doClick();
  630. sleep(2000);
  631. }
  632. }
  633. }
  634. };
  635. Action takefailTrap = new Action() {
  636. RSTile Next = null;
  637.  
  638. boolean activate() {
  639. for (RSTile t : ChinTraps) {
  640. if (objects.getTopAt(t) != null) {
  641. if (objects.getTopAt(t).getID() == trapFailed) {
  642. Next = t;
  643. return true;
  644. }
  645. }
  646. }
  647. return false;
  648. }
  649.  
  650. void run() {
  651. if (Next != null) {
  652. if (objects.getTopAt(Next).getID() == trapFailed) {
  653. objects.getTopAt(Next).doClick();
  654. sleep(2000);
  655. }
  656. }
  657. }
  658. };
  659. //
  660. Action takefail = new Action() {
  661. RSTile Next = null;
  662.  
  663. boolean activate() {
  664. for (RSTile t : ChinTraps) {
  665. if (groundItems.getAllAt(t) != null) {
  666. if (groundItems.getAllAt(t).length > 0) {
  667. if (groundItems.getAllAt(t)[0].getItem().getID() == trapSetup) {
  668. Next = t;
  669. return true;
  670. }
  671. }
  672. }
  673. }
  674. return false;
  675. }
  676.  
  677. void run() {
  678. if (Next != null) {
  679. if (groundItems.getAllAt(Next) != null
  680. && groundItems.getAllAt(Next)[0] != null) {
  681. groundItems.getAllAt(Next)[0].interact("take");
  682. }
  683. }
  684.  
  685. }
  686. };
  687. Job GREY_CHIN = new Job() {
  688. int reqLevel() {
  689. return 53;
  690. }
  691.  
  692. int endLevel() {
  693. return 63;// change once red is coded
  694. }
  695.  
  696. public RSArea mainArea() {
  697. return G_CHIN;
  698.  
  699. }
  700. };
  701. GREY_CHIN.Steps.add(setTrap);
  702. GREY_CHIN.Steps.add(takeTrap);
  703. GREY_CHIN.Steps.add(takefail);
  704. GREY_CHIN.Steps.add(takefailTrap);
  705. // ////////////////////////////////////////
  706. Action setRTrap = new Action() {
  707. RSTile Next = null;
  708.  
  709. boolean activate() {
  710. if (ChinTraps == null) {
  711. ChinTraps = getChinTraps();
  712. }
  713. for (RSTile t : ChinTraps) {
  714. if (objects.getTopAt(t) == null) {
  715. Next = t;
  716. return true;
  717. }
  718. }
  719. return false;
  720. }
  721.  
  722. void run() {
  723. if (Next != null) {
  724. while (calc.distanceTo(Next) > 0) {
  725. walking.walkTileOnScreen(Next);
  726. sleep(1000);
  727. }
  728. if (groundItems.getAllAt(Next).length == 0) {
  729. inventory.getItem(trapItem).doClick(true);
  730. } else {
  731. groundItems.getAllAt(Next)[0].interact("Lay");
  732. }
  733. sleep(6000);
  734. }
  735. }
  736. };
  737. Action takeRTrap = new Action() {
  738. RSTile Next = null;
  739.  
  740. boolean activate() {
  741. for (RSTile t : ChinTraps) {
  742. if (objects.getTopAt(t) != null) {
  743. if (objects.getTopAt(t).getID() == 19190) {
  744. Next = t;
  745. return true;
  746. }
  747. }
  748. }
  749. return false;
  750. }
  751.  
  752. void run() {
  753. if (Next != null) {
  754. if (objects.getTopAt(Next).getID() == 19190) {
  755. objects.getTopAt(Next).doClick();
  756. sleep(2000);
  757. }
  758. }
  759. }
  760. };
  761. Action takeRfailTrap = new Action() {
  762. RSTile Next = null;
  763.  
  764. boolean activate() {
  765. for (RSTile t : ChinTraps) {
  766. if (objects.getTopAt(t) != null) {
  767. if (objects.getTopAt(t).getID() == trapFailed) {
  768. Next = t;
  769. return true;
  770. }
  771. }
  772. }
  773. return false;
  774. }
  775.  
  776. void run() {
  777. if (Next != null) {
  778. if (objects.getTopAt(Next).getID() == trapFailed) {
  779. objects.getTopAt(Next).doClick();
  780. sleep(2000);
  781. }
  782. }
  783. }
  784. };
  785. //
  786. Action takeRfail = new Action() {
  787. RSTile Next = null;
  788.  
  789. boolean activate() {
  790. for (RSTile t : ChinTraps) {
  791. if (groundItems.getAllAt(t) != null) {
  792. if (groundItems.getAllAt(t).length > 0) {
  793. if (groundItems.getAllAt(t)[0].getItem().getID() == trapSetup) {
  794. Next = t;
  795. return true;
  796. }
  797. }
  798. }
  799. }
  800. return false;
  801. }
  802.  
  803. void run() {
  804. if (Next != null) {
  805. if (groundItems.getAllAt(Next) != null
  806. && groundItems.getAllAt(Next)[0] != null) {
  807. groundItems.getAllAt(Next)[0].interact("take");
  808. }
  809. }
  810.  
  811. }
  812. };
  813. Job RED_CHIN = new Job() {
  814. int reqLevel() {
  815. return 63;
  816. }
  817.  
  818. int endLevel() {
  819. return 99;// change once red is coded
  820. }
  821.  
  822. public RSArea mainArea() {
  823. return R_CHIN;
  824.  
  825. }
  826. };
  827. RED_CHIN.Steps.add(setRTrap);
  828. RED_CHIN.Steps.add(takeRTrap);
  829. RED_CHIN.Steps.add(takeRfail);
  830. RED_CHIN.Steps.add(takeRfailTrap);
  831. Job[] temp = { CRIMSON_SWIFTS, TROPICAL_WAGTAIL, GREY_CHIN, RED_CHIN };
  832. return temp;
  833. }
  834.  
  835. // END: Code generated using Enfilade's Easel
  836. public boolean onStart() {
  837. startTime = System.currentTimeMillis();
  838. startLevel = skills.getRealLevel(Skills.HUNTER);
  839. startExp = skills.getCurrentExp(Skills.HUNTER);
  840. // new Scanner();
  841. return true;
  842. }
  843.  
  844. @Override
  845. public int loop() {
  846. try {
  847. Job cur = getCurrentJob();
  848. if (cur.mainArea() != null
  849. && cur.mainArea().contains(getMyPlayer().getLocation())) {
  850. for (Action a : cur.Steps) {
  851. if (a.activate()) {
  852. a.run();
  853. break;
  854. }
  855. }
  856. } else {
  857. if (!banking)
  858. web.getWeb(cur.mainArea().getCentralTile()).step();
  859. }
  860. } catch (Exception e) {
  861. log(e.getMessage());
  862. }
  863. return 100;
  864. }
  865.  
  866. private Job getCurrentJob() {
  867. for (Job job : getJobs()) {
  868. if (job.reqLevel() <= skills.getRealLevel(Skills.HUNTER)
  869. && job.endLevel() > skills.getRealLevel(Skills.HUNTER)) {
  870. return job;
  871. }
  872. }
  873. return null;
  874.  
  875. }
  876.  
  877. class Action {
  878. boolean activate() {
  879. return false;
  880. }
  881.  
  882. void run() {
  883.  
  884. }
  885. }
  886.  
  887. class Job {
  888. private long startTime;
  889.  
  890. public RSArea mainArea() {
  891. return null;
  892. }
  893.  
  894. int reqLevel() {
  895. return -1;
  896. }
  897.  
  898. int endLevel() {
  899. return -1;
  900. }
  901.  
  902. ArrayList<Action> Steps = new ArrayList<Action>();
  903. }
  904.  
  905. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement