Advertisement
Guest User

RushThread

a guest
Oct 24th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.58 KB | None | 0 0
  1. /**
  2. * @filename RushThread.js
  3. * @author kolton
  4. * @desc Second half of the Rusher script
  5. */
  6.  
  7. js_strict(true);
  8.  
  9. include("json2.js");
  10. include("NTItemParser.dbl");
  11. include("OOG.js");
  12. include("Gambling.js");
  13. include("AutoMule.js");
  14. include("CraftingSystem.js");
  15. include("TorchSystem.js");
  16. include("common/Attack.js");
  17. include("common/Cubing.js");
  18. include("common/Config.js");
  19. include("common/CollMap.js");
  20. include("common/Loader.js");
  21. include("common/Misc.js");
  22. include("common/Pickit.js");
  23. include("common/Pather.js");
  24. include("common/Precast.js");
  25. include("common/Prototypes.js");
  26. include("common/Runewords.js");
  27. include("common/Storage.js");
  28. include("common/Town.js");
  29.  
  30. var gidList = [];
  31.  
  32. function main() {
  33. this.playerIn = function (area) {
  34. if (!area) {
  35. area = me.area;
  36. }
  37.  
  38. var party = getParty();
  39.  
  40. if (party) {
  41. do {
  42. if (party.name !== me.name && party.area === area) {
  43. return true;
  44. }
  45. } while (party.getNext());
  46. }
  47.  
  48. return false;
  49. };
  50.  
  51. this.bumperCheck = function () {
  52. var party = getParty();
  53.  
  54. if (party) {
  55. do {
  56. if (party.name !== me.name) {
  57. switch (me.diff) {
  58. case 0:
  59. if (party.level >= 20) {
  60. return true;
  61. }
  62.  
  63. break;
  64. case 1:
  65. if (party.level >= 40) {
  66. return true;
  67. }
  68.  
  69. break;
  70. }
  71. }
  72. } while (party.getNext());
  73. }
  74.  
  75. return false;
  76. };
  77.  
  78. this.playersInAct = function (act) {
  79. var area, party,
  80. areas = [0, 1, 40, 75, 103, 109];
  81.  
  82. if (!act) {
  83. act = me.act;
  84. }
  85.  
  86. area = areas[act];
  87. party = getParty();
  88.  
  89. if (party) {
  90. do {
  91. if (party.name !== me.name && party.area !== area) {
  92. return false;
  93. }
  94. } while (party.getNext());
  95. }
  96.  
  97. return true;
  98. };
  99.  
  100. this.andariel = function () {
  101. say("starting andariel");
  102. Town.doChores();
  103. Pather.useWaypoint(35, true);
  104. Precast.doPrecast(true);
  105.  
  106. if (!Pather.moveToExit([36, 37], true) || !Pather.moveTo(22582, 9612)) {
  107. throw new Error("andy failed");
  108. }
  109.  
  110. Pather.makePortal();
  111. Attack.securePosition(me.x, me.y, 40, 3000, true);
  112. say("TP up for Andy.");
  113.  
  114. while (!this.playerIn()) {
  115. Pather.moveTo(22582, 9612);
  116. delay(250);
  117. }
  118.  
  119. Attack.kill(156);
  120. say("Andy is going down.");
  121. Pather.moveTo(22582, 9612);
  122.  
  123. while (this.playerIn()) {
  124. delay(250);
  125. }
  126.  
  127. Pather.usePortal(null, me.name);
  128. say("Let's go, Act 2 here we come.");
  129. Pather.useWaypoint(40, true);
  130.  
  131. while (!this.playersInAct(2)) {
  132. delay(250);
  133. }
  134.  
  135. return true;
  136. };
  137.  
  138. this.cube = function () {
  139. if (me.diff === 0) {
  140. say("starting cube");
  141. Pather.useWaypoint(57, true);
  142. Precast.doPrecast(true);
  143.  
  144. if (!Pather.moveToExit(60, true) || !Pather.moveToPreset(me.area, 2, 354)) {
  145. throw new Error("cube failed");
  146. }
  147.  
  148. Pather.makePortal();
  149. Attack.securePosition(me.x, me.y, 30, 3000, true);
  150. say("TP for cube.");
  151.  
  152. while (!this.playerIn()) {
  153. delay(100);
  154. }
  155.  
  156. while (this.playerIn()) {
  157. delay(100);
  158. }
  159.  
  160. Pather.usePortal(null, me.name);
  161. }
  162.  
  163. return true;
  164. };
  165.  
  166. this.amulet = function () {
  167. say("starting amulet");
  168. Town.doChores();
  169. Pather.useWaypoint(44, true);
  170. Precast.doPrecast(true);
  171.  
  172. if (!Pather.moveToExit([45, 58, 61], true) || !Pather.moveTo(15044, 14045)) {
  173. throw new Error("amulet failed");
  174. }
  175.  
  176. Pather.makePortal();
  177.  
  178. if (me.diff < 2) {
  179. Attack.securePosition(me.x, me.y, 25, 3000);
  180. } else {
  181. Attack.securePosition(me.x, me.y, 25, 3000, true, true);
  182. }
  183.  
  184. say("TP for Ammy.");
  185.  
  186. while (!this.playerIn()) {
  187. delay(100);
  188. }
  189.  
  190. while (this.playerIn()) {
  191. delay(100);
  192. }
  193.  
  194. Pather.usePortal(null, me.name);
  195. say("Please talk to drognan after getting ammy.");
  196.  
  197. return true;
  198. };
  199.  
  200. this.staff = function () {
  201. say("starting staff");
  202. Town.doChores();
  203. Pather.useWaypoint(43, true);
  204. Precast.doPrecast(true);
  205.  
  206. if (!Pather.moveToExit([62, 63, 64], true) || !Pather.moveToPreset(me.area, 2, 356)) {
  207. throw new Error("staff failed");
  208. }
  209.  
  210. Pather.makePortal();
  211. Attack.securePosition(me.x, me.y, 30, 3000, true);
  212. say("TP for Staff.");
  213.  
  214. while (!this.playerIn()) {
  215. //Pather.moveToPreset(me.area, 2, 356);
  216. delay(100);
  217. }
  218.  
  219. while (this.playerIn()) {
  220. delay(100);
  221. }
  222.  
  223. Pather.usePortal(null, me.name);
  224.  
  225. return true;
  226. };
  227.  
  228. this.summoner = function () {
  229. // right up 25449 5081 (25431, 5011)
  230. // left up 25081 5446 (25011, 5446)
  231. // right down 25830 5447 (25866, 5431)
  232. // left down 25447 5822 (25431, 5861)
  233.  
  234. say("starting summoner");
  235. Town.doChores();
  236. Pather.useWaypoint(74, true);
  237. Precast.doPrecast(true);
  238.  
  239. var i, journal,
  240. preset = getPresetUnit(me.area, 2, 357),
  241. spot = {};
  242.  
  243. switch (preset.roomx * 5 + preset.x) {
  244. case 25011:
  245. spot = {x: 25081, y: 5446};
  246. break;
  247. case 25866:
  248. spot = {x: 25830, y: 5447};
  249. break;
  250. case 25431:
  251. switch (preset.roomy * 5 + preset.y) {
  252. case 5011:
  253. spot = {x: 25449, y: 5081};
  254. break;
  255. case 5861:
  256. spot = {x: 25447, y: 5822};
  257. break;
  258. }
  259.  
  260. break;
  261. }
  262.  
  263. if (!Pather.moveToUnit(spot)) {
  264. throw new Error("summoner failed");
  265. }
  266.  
  267. Pather.makePortal();
  268. Attack.securePosition(me.x, me.y, 25, 3000);
  269. say("Come in for Summoner.");
  270.  
  271. while (!this.playerIn()) {
  272. Pather.moveToUnit(spot);
  273. Attack.securePosition(me.x, me.y, 25, 500);
  274. delay(250);
  275. }
  276.  
  277. Pather.moveToPreset(me.area, 2, 357);
  278. Attack.kill(250);
  279. say("Summoner going down.");
  280.  
  281. while (this.playerIn()) {
  282. delay(100);
  283. }
  284.  
  285. Pickit.pickItems();
  286. Pather.moveToPreset(me.area, 2, 357);
  287.  
  288. journal = getUnit(2, 357);
  289.  
  290. for (i = 0; i < 5; i += 1) {
  291. journal.interact();
  292. delay(1000);
  293. me.cancel();
  294.  
  295. if (Pather.getPortal(46)) {
  296. break;
  297. }
  298. }
  299.  
  300. if (i === 5) {
  301. throw new Error("summoner failed");
  302. }
  303.  
  304. Pather.usePortal(46);
  305.  
  306. return true;
  307. };
  308.  
  309. this.duriel = function () {
  310. say("starting duriel");
  311.  
  312. if (me.inTown) {
  313. Town.doChores();
  314. Pather.useWaypoint(46, true);
  315. }
  316.  
  317. Precast.doPrecast(true);
  318.  
  319. if (!Pather.moveToExit(getRoom().correcttomb, true) || !Pather.moveToPreset(me.area, 2, 152)) {
  320. throw new Error("duriel failed");
  321. }
  322.  
  323. Pather.makePortal();
  324. Attack.securePosition(me.x, me.y, 30, 3000, true, me.diff === 2);
  325. say("Come in with Staff, if you cant enter TP talk to cain.");
  326.  
  327. while (!this.playerIn()) {
  328. //Pather.moveToPreset(me.area, 2, 152, 0, -5);
  329. delay(100);
  330. }
  331.  
  332. while (this.playerIn()) {
  333. delay(100);
  334. }
  335.  
  336. while (!getUnit(2, 100)) {
  337. delay(500);
  338. }
  339.  
  340. Pather.useUnit(2, 100, 73);
  341. Attack.kill(211);
  342. Pickit.pickItems();
  343.  
  344. Pather.teleport = false;
  345.  
  346. Pather.moveTo(22579, 15706);
  347.  
  348. Pather.teleport = true;
  349.  
  350. Pather.moveTo(22577, 15649, 10);
  351. Pather.moveTo(22577, 15609, 10);
  352. Pather.makePortal();
  353. say("1");
  354.  
  355. while (!this.playerIn()) {
  356. delay(100);
  357. }
  358.  
  359. if (!Pather.usePortal(null, me.name)) {
  360. Town.goToTown();
  361. }
  362.  
  363. Pather.useWaypoint(52);
  364. Pather.moveToExit([51, 50], true);
  365. Pather.moveTo(10022, 5047);
  366. say("Moving on to Act 3.");
  367. Town.goToTown(3);
  368. Town.doChores();
  369.  
  370. while (!this.playersInAct(3)) {
  371. delay(250);
  372. }
  373.  
  374. return true;
  375. };
  376.  
  377. this.travincal = function () {
  378. say("starting travincal");
  379. Town.doChores();
  380. Pather.useWaypoint(83, true);
  381. Precast.doPrecast(true);
  382.  
  383. var coords = [me.x, me.y];
  384.  
  385. Pather.moveTo(coords[0] + 23, coords[1] - 102);
  386. Pather.makePortal();
  387. Attack.securePosition(me.x, me.y, 40, 3000);
  388. say("TP for Travincal up.");
  389.  
  390. while (!this.playerIn()) {
  391. delay(250);
  392. }
  393.  
  394. Pather.moveTo(coords[0] + 30, coords[1] - 134);
  395. Pather.moveTo(coords[0] + 86, coords[1] - 130);
  396. Pather.moveTo(coords[0] + 71, coords[1] - 94);
  397. Attack.securePosition(me.x, me.y, 40, 3000);
  398.  
  399. /*Attack.kill(getLocaleString(2863));
  400. Attack.kill(getLocaleString(2862));
  401. Attack.kill(getLocaleString(2860));*/
  402.  
  403. say("Counsil is dead. If you didn't get quest, leave and start rush over.");
  404. Pather.moveTo(coords[0] + 23, coords[1] - 102);
  405. Pather.usePortal(null, me.name);
  406.  
  407. return true;
  408. };
  409.  
  410. this.mephisto = function () {
  411. say("starting mephisto");
  412.  
  413. var hydra;
  414.  
  415. Town.doChores();
  416. Pather.useWaypoint(101, true);
  417. Precast.doPrecast(true);
  418. Pather.moveToExit(102, true);
  419. Pather.moveTo(17692, 8023);
  420. Pather.makePortal();
  421. delay(2000);
  422. say("TP up for Mephy.");
  423.  
  424. while (!this.playerIn()) {
  425. delay(250);
  426. }
  427.  
  428. Pather.moveTo(17591, 8070);
  429. Attack.kill(242);
  430. Pickit.pickItems();
  431. Pather.moveTo(17692, 8023);
  432. Pather.makePortal();
  433. say("Back to town please.");
  434.  
  435. while (this.playerIn()) {
  436. delay(250);
  437. }
  438.  
  439. Pather.moveTo(17591, 8070);
  440. Attack.securePosition(me.x, me.y, 40, 3000);
  441.  
  442. hydra = getUnit(1, "hydra");
  443.  
  444. if (hydra) {
  445. do {
  446. while (hydra.mode !== 0 && hydra.mode !== 12 && hydra.hp > 0) {
  447. delay(500);
  448. }
  449. } while (hydra.getNext());
  450. }
  451.  
  452. Pather.makePortal();
  453. Pather.moveTo(17581, 8070);
  454. say("Come back in, lets go to Act 4.");
  455.  
  456. while (!this.playerIn()) {
  457. delay(250);
  458. }
  459.  
  460. say("a4");
  461. //Pather.moveTo(17591, 8070);
  462.  
  463. while (!this.playersInAct(4)) {
  464. delay(250);
  465. }
  466.  
  467. delay(2000);
  468. Pather.usePortal(null);
  469.  
  470. return true;
  471. };
  472.  
  473. this.diablo = function () {
  474. say("starting diablo");
  475.  
  476. this.getLayout = function (seal, value) {
  477. var sealPreset = getPresetUnit(108, 2, seal);
  478.  
  479. if (!seal) {
  480. throw new Error("Seal preset not found. Can't continue.");
  481. }
  482.  
  483. if (sealPreset.roomy * 5 + sealPreset.y === value || sealPreset.roomx * 5 + sealPreset.x === value) {
  484. return 1;
  485. }
  486.  
  487. return 2;
  488. };
  489.  
  490. this.initLayout = function () {
  491. this.vizLayout = this.getLayout(396, 5275);
  492. this.seisLayout = this.getLayout(394, 7773);
  493. this.infLayout = this.getLayout(392, 7893);
  494. };
  495.  
  496. this.getBoss = function (name) {
  497. var i, boss,
  498. glow = getUnit(2, 131);
  499.  
  500. for (i = 0; i < (name === getLocaleString(2853) ? 14 : 12); i += 1) {
  501. boss = getUnit(1, name);
  502.  
  503. if (boss) {
  504. if (name === getLocaleString(2852)) {
  505. this.chaosPreattack(getLocaleString(2852), 8);
  506. }
  507.  
  508. Attack.kill(name);
  509. Pickit.pickItems();
  510.  
  511. return true;
  512. }
  513.  
  514. delay(250);
  515. }
  516.  
  517. return !!glow;
  518. };
  519.  
  520. this.chaosPreattack = function (name, amount) {
  521. var i, n, target, positions;
  522.  
  523. switch (me.classid) {
  524. case 0:
  525. break;
  526. case 1:
  527. break;
  528. case 2:
  529. break;
  530. case 3:
  531. target = getUnit(1, name);
  532.  
  533. if (!target) {
  534. return;
  535. }
  536.  
  537. positions = [[6, 11], [0, 8], [8, -1], [-9, 2], [0, -11], [8, -8]];
  538.  
  539. for (i = 0; i < positions.length; i += 1) {
  540. if (Attack.validSpot(target.x + positions[i][0], target.y + positions[i][1])) { // check if we can move there
  541. Pather.moveTo(target.x + positions[i][0], target.y + positions[i][1]);
  542. Skill.setSkill(Config.AttackSkill[2], 0);
  543.  
  544. for (n = 0; n < amount; n += 1) {
  545. Skill.cast(Config.AttackSkill[1], 1);
  546. }
  547.  
  548. break;
  549. }
  550. }
  551.  
  552. break;
  553. case 4:
  554. break;
  555. case 5:
  556. break;
  557. case 6:
  558. break;
  559. }
  560. };
  561.  
  562. this.openSeal = function (id) {
  563. Pather.moveToPreset(108, 2, id, 4);
  564.  
  565. var i, tick,
  566. seal = getUnit(2, id);
  567.  
  568. if (seal) {
  569. for (i = 0; i < 3; i += 1) {
  570. seal.interact();
  571.  
  572. tick = getTickCount();
  573.  
  574. while (getTickCount() - tick < 500) {
  575. if (seal.mode) {
  576. return true;
  577. }
  578.  
  579. delay(10);
  580. }
  581. }
  582. }
  583.  
  584. return false;
  585. };
  586.  
  587. Town.doChores();
  588. Pather.useWaypoint(107, true);
  589. Precast.doPrecast(true);
  590. Pather.moveTo(7790, 5544);
  591. this.initLayout();
  592.  
  593. if (!this.openSeal(395) || !this.openSeal(396)) {
  594. throw new Error("Failed to open seals");
  595. }
  596.  
  597. if (this.vizLayout === 1) {
  598. Pather.moveTo(7691, 5292);
  599. } else {
  600. Pather.moveTo(7695, 5316);
  601. }
  602.  
  603. if (!this.getBoss(getLocaleString(2851))) {
  604. throw new Error("Failed to kill Vizier");
  605. }
  606.  
  607. if (!this.openSeal(394)) {
  608. throw new Error("Failed to open seals");
  609. }
  610.  
  611. if (this.seisLayout === 1) {
  612. Pather.moveTo(7771, 5196);
  613. } else {
  614. Pather.moveTo(7798, 5186);
  615. }
  616.  
  617. if (!this.getBoss(getLocaleString(2852))) {
  618. throw new Error("Failed to kill de Seis");
  619. }
  620.  
  621. if (!this.openSeal(392) || !this.openSeal(393)) {
  622. throw new Error("Failed to open seals");
  623. }
  624.  
  625. if (this.infLayout === 1) {
  626. delay(1);
  627. } else {
  628. Pather.moveTo(7928, 5295); // temp
  629. }
  630.  
  631. if (!this.getBoss(getLocaleString(2853))) {
  632. throw new Error("Failed to kill Infector");
  633. }
  634.  
  635. Pather.moveTo(7763, 5267);
  636. Pather.makePortal();
  637. Pather.moveTo(7727, 5267);
  638. say("TP up for Diablo.");
  639.  
  640. while (!this.playerIn()) {
  641. delay(250);
  642. }
  643.  
  644. Pather.moveTo(7763, 5267);
  645.  
  646. while (!getUnit(1, 243)) {
  647. delay(500);
  648. }
  649.  
  650. Attack.kill(243);
  651. say("Diablo is dead.");
  652.  
  653. if (me.gametype > 0) {
  654. say("Let's go to Act 5 now.");
  655.  
  656. while (!this.playersInAct(5)) {
  657. delay(250);
  658. }
  659. }
  660.  
  661. Pickit.pickItems();
  662.  
  663. if (!Pather.usePortal(null, me.name)) {
  664. Town.goToTown();
  665. }
  666.  
  667. return true;
  668. };
  669.  
  670. this.ancients = function () {
  671. if (me.diff === 2) {
  672. say("Hell rush complete~");
  673. delay(500);
  674. quit();
  675.  
  676. return false;
  677. }
  678.  
  679. if (!this.bumperCheck()) {
  680. say("No eligible bumpers detected. Rush complete~");
  681. delay(500);
  682. quit();
  683.  
  684. return false;
  685. }
  686.  
  687. say("starting ancients");
  688.  
  689. var altar;
  690.  
  691. Town.doChores();
  692. Pather.useWaypoint(118, true);
  693. Precast.doPrecast(true);
  694.  
  695. if (!Pather.moveToExit(120, true)) {
  696. throw new Error("Failed to go to Ancients way.");
  697. }
  698.  
  699. Pather.moveTo(10089, 12622);
  700. Pather.makePortal();
  701. say("TP up for ancients.");
  702.  
  703. while (!this.playerIn()) {
  704. delay(250);
  705. }
  706.  
  707. Pather.moveTo(10048, 12628);
  708.  
  709. altar = getUnit(2, 546);
  710.  
  711. if (altar) {
  712. while (altar.mode !== 2) {
  713. Pather.moveToUnit(altar);
  714. altar.interact();
  715. delay(2000 + me.ping);
  716. me.cancel();
  717. }
  718. }
  719.  
  720. while (!getUnit(1, 542)) {
  721. delay(250);
  722. }
  723.  
  724. Attack.clear(50);
  725. Pather.moveTo(10089, 12622);
  726. me.cancel();
  727. Pather.makePortal();
  728.  
  729. while (this.playerIn()) {
  730. delay(100);
  731. }
  732.  
  733. if (!Pather.usePortal(null, me.name)) {
  734. Town.goToTown();
  735. }
  736.  
  737. return true;
  738. };
  739.  
  740. this.baal = function () {
  741. say("starting baal");
  742.  
  743. var tick, portal;
  744.  
  745. this.preattack = function () {
  746. var check;
  747.  
  748. switch (me.classid) {
  749. case 1:
  750. if ([56, 59, 64].indexOf(Config.AttackSkill[1]) > -1) {
  751. if (me.getState(121)) {
  752. delay(500);
  753. } else {
  754. Skill.cast(Config.AttackSkill[1], 0, 15093, 5024);
  755. }
  756. }
  757.  
  758. return true;
  759. case 3: // Paladin
  760. if (Config.AttackSkill[3] !== 112) {
  761. return false;
  762. }
  763.  
  764. if (getDistance(me, 15093, 5029) > 3) {
  765. Pather.moveTo(15093, 5029);
  766. }
  767.  
  768. if (Config.AttackSkill[4] > 0) {
  769. Skill.setSkill(Config.AttackSkill[4], 0);
  770. }
  771.  
  772. Skill.cast(Config.AttackSkill[3], 1);
  773.  
  774. return true;
  775. case 5: // Druid
  776. if (Config.AttackSkill[3] === 245) {
  777. Skill.cast(Config.AttackSkill[3], 0, 15093, 5029);
  778.  
  779. return true;
  780. }
  781.  
  782. break;
  783. case 6:
  784. if (Config.UseTraps) {
  785. check = ClassAttack.checkTraps({x: 15093, y: 5029});
  786.  
  787. if (check) {
  788. ClassAttack.placeTraps({x: 15093, y: 5029}, 5);
  789.  
  790. return true;
  791. }
  792. }
  793.  
  794. break;
  795. }
  796.  
  797. return false;
  798. };
  799.  
  800. this.checkThrone = function () {
  801. var monster = getUnit(1);
  802.  
  803. if (monster) {
  804. do {
  805. if (Attack.checkMonster(monster) && monster.y < 5080) {
  806. switch (monster.classid) {
  807. case 23:
  808. case 62:
  809. return 1;
  810. case 105:
  811. case 381:
  812. return 2;
  813. case 557:
  814. return 3;
  815. case 558:
  816. return 4;
  817. case 571:
  818. return 5;
  819. default:
  820. Attack.getIntoPosition(monster, 10, 0x4);
  821. Attack.clear(15);
  822.  
  823. return false;
  824. }
  825. }
  826. } while (monster.getNext());
  827. }
  828.  
  829. return false;
  830. };
  831.  
  832. this.clearThrone = function () {
  833. var i, monster,
  834. monList = [],
  835. pos = [15097, 5054, 15085, 5053, 15085, 5040, 15098, 5040, 15099, 5022, 15086, 5024];
  836.  
  837. if (Config.AvoidDolls) {
  838. monster = getUnit(1, 691);
  839.  
  840. if (monster) {
  841. do {
  842. if (monster.x >= 15072 && monster.x <= 15118 && monster.y >= 5002 && monster.y <= 5079 && Attack.checkMonster(monster) && Attack.skipCheck(monster)) {
  843. monList.push(copyUnit(monster));
  844. }
  845. } while (monster.getNext());
  846. }
  847.  
  848. if (monList.length) {
  849. Attack.clearList(monList);
  850. }
  851. }
  852.  
  853. for (i = 0; i < pos.length; i += 2) {
  854. Pather.moveTo(pos[i], pos[i + 1]);
  855. Attack.clear(30);
  856. }
  857. };
  858.  
  859. this.checkHydra = function () {
  860. var monster = getUnit(1, "hydra");
  861.  
  862. if (monster) {
  863. do {
  864. if (monster.mode !== 12 && monster.getStat(172) !== 2) {
  865. Pather.moveTo(15118, 5002);
  866.  
  867. while (monster.mode !== 12) {
  868. delay(500);
  869.  
  870. if (!copyUnit(monster).x) {
  871. break;
  872. }
  873. }
  874.  
  875. break;
  876. }
  877. } while (monster.getNext());
  878. }
  879.  
  880. return true;
  881. };
  882.  
  883. if (me.inTown) {
  884. Town.doChores();
  885. Pather.useWaypoint(129, true);
  886. Precast.doPrecast(true);
  887.  
  888. if (!Pather.moveToExit([130, 131], true)) {
  889. throw new Error("Failed to move to Throne of Destruction.");
  890. }
  891. }
  892.  
  893. Pather.moveTo(15113, 5040);
  894. Attack.clear(15);
  895. this.clearThrone();
  896.  
  897. tick = getTickCount();
  898. Pather.moveTo(15093, me.classid === 3 ? 5029 : 5039);
  899.  
  900. MainLoop:
  901. while (true) {
  902. if (getDistance(me, 15093, me.classid === 3 ? 5029 : 5039) > 3) {
  903. Pather.moveTo(15093, me.classid === 3 ? 5029 : 5039);
  904. }
  905.  
  906. if (!getUnit(1, 543)) {
  907. break MainLoop;
  908. }
  909.  
  910. switch (this.checkThrone()) {
  911. case 1:
  912. Attack.clear(40);
  913.  
  914. tick = getTickCount();
  915.  
  916. Precast.doPrecast(true);
  917.  
  918. break;
  919. case 2:
  920. Attack.clear(40);
  921.  
  922. tick = getTickCount();
  923.  
  924. break;
  925. case 4:
  926. Attack.clear(40);
  927.  
  928. tick = getTickCount();
  929.  
  930. break;
  931. case 3:
  932. Attack.clear(40);
  933. this.checkHydra();
  934.  
  935. tick = getTickCount();
  936.  
  937. break;
  938. case 5:
  939. Attack.clear(40);
  940.  
  941. break MainLoop;
  942. default:
  943. if (getTickCount() - tick < 7e3) {
  944. if (me.getState(2)) {
  945. Skill.setSkill(109, 0);
  946. }
  947.  
  948. break;
  949. }
  950.  
  951. if (!this.preattack()) {
  952. delay(100);
  953. }
  954.  
  955. break;
  956. }
  957.  
  958. Precast.doPrecast(false);
  959. delay(10);
  960. }
  961.  
  962. this.clearThrone();
  963. Pather.moveTo(15092, 5011);
  964. Precast.doPrecast(true);
  965.  
  966. while (getUnit(1, 543)) {
  967. delay(500);
  968. }
  969.  
  970. delay(1000);
  971.  
  972. portal = getUnit(2, 563);
  973.  
  974. if (portal) {
  975. Pather.usePortal(null, null, portal);
  976. } else {
  977. throw new Error("Couldn't find portal.");
  978. }
  979.  
  980. Pather.moveTo(15213, 5908);
  981. Pather.makePortal();
  982. Pather.moveTo(15170, 5950);
  983. delay(1000);
  984. say("3");
  985.  
  986. while (!this.playerIn()) {
  987. delay(250);
  988. }
  989.  
  990. Pather.moveTo(15134, 5923);
  991. Attack.kill(544); // Baal
  992. Pickit.pickItems();
  993.  
  994. return true;
  995. };
  996.  
  997. this.clearArea = function (area) {
  998. Pather.journeyTo(area);
  999. Attack.clearLevel(0);
  1000. say("Done clearing area: " + area);
  1001. };
  1002.  
  1003. // Quests
  1004. this.radament = function () {
  1005. if (!Config.Rusher.Radament) {
  1006. return false;
  1007. }
  1008.  
  1009. say("starting radament");
  1010.  
  1011. var i, radaCoords, rada, radaPreset, returnSpot,
  1012. moveIntoPos = function (unit, range) {
  1013. var i, coordx, coordy,
  1014. coords = [],
  1015. angle = Math.round(Math.atan2(me.y - unit.y, me.x - unit.x) * 180 / Math.PI),
  1016. angles = [0, 15, -15, 30, -30, 45, -45, 60, -60, 75, -75, 90, -90, 105, -105, 120, -120, 135, -135, 150, -150, 180];
  1017.  
  1018. for (i = 0; i < angles.length; i += 1) {
  1019. coordx = Math.round((Math.cos((angle + angles[i]) * Math.PI / 180)) * range + unit.x);
  1020. coordy = Math.round((Math.sin((angle + angles[i]) * Math.PI / 180)) * range + unit.y);
  1021.  
  1022. try {
  1023. if (!(getCollision(unit.area, coordx, coordy) & 0x1)) {
  1024. coords.push({
  1025. x: coordx,
  1026. y: coordy
  1027. });
  1028. }
  1029. } catch (e) {
  1030.  
  1031. }
  1032. }
  1033.  
  1034. if (coords.length > 0) {
  1035. coords.sort(Sort.units);
  1036.  
  1037. return Pather.moveToUnit(coords[0]);
  1038. }
  1039.  
  1040. return false;
  1041. };
  1042.  
  1043. Pather.useWaypoint(48, true);
  1044. Precast.doPrecast(false);
  1045. Pather.moveToExit(49, true);
  1046.  
  1047. radaPreset = getPresetUnit(49, 2, 355);
  1048. radaCoords = {
  1049. area: 49,
  1050. x: radaPreset.roomx * 5 + radaPreset.x,
  1051. y: radaPreset.roomy * 5 + radaPreset.y
  1052. };
  1053.  
  1054. moveIntoPos(radaCoords, 50);
  1055.  
  1056. for (i = 0; i < 3; i += 1) {
  1057. rada = getUnit(1, 229);
  1058.  
  1059. if (rada) {
  1060. break;
  1061. }
  1062.  
  1063. delay(500);
  1064. }
  1065.  
  1066. if (rada) {
  1067. moveIntoPos(rada, 60);
  1068. } else {
  1069. print("radament unit not found");
  1070. }
  1071.  
  1072. Attack.securePosition(me.x, me.y, 35, 3000);
  1073. Pather.makePortal();
  1074. say("1");
  1075.  
  1076. while (!this.playerIn()) {
  1077. delay(200);
  1078. }
  1079.  
  1080. Attack.kill(229); // Radament
  1081.  
  1082. returnSpot = {
  1083. x: me.x,
  1084. y: me.y
  1085. };
  1086.  
  1087. say("2");
  1088. Pickit.pickItems();
  1089. Attack.securePosition(me.x, me.y, 30, 3000);
  1090.  
  1091. while (this.playerIn()) {
  1092. delay(200);
  1093. }
  1094.  
  1095. Pather.moveToUnit(returnSpot);
  1096. Pather.makePortal();
  1097. say("all in");
  1098.  
  1099. while (!this.playerIn()) {
  1100. delay(200);
  1101. }
  1102.  
  1103. while (getUnit(4, 552)) {
  1104. delay(1000);
  1105. }
  1106.  
  1107. while (this.playerIn()) {
  1108. delay(200);
  1109. }
  1110.  
  1111. Pather.usePortal(null, null);
  1112.  
  1113. return true;
  1114. };
  1115.  
  1116. this.lamesen = function () {
  1117. if (!Config.Rusher.LamEsen) {
  1118. return false;
  1119. }
  1120.  
  1121. say("starting lamesen");
  1122.  
  1123. if (!Town.goToTown() || !Pather.useWaypoint(80, true)) {
  1124. throw new Error("Lam Essen quest failed");
  1125. }
  1126.  
  1127. Precast.doPrecast(false);
  1128.  
  1129. if (!Pather.moveToExit(94, true) || !Pather.moveToPreset(me.area, 2, 193)) {
  1130. throw new Error("Lam Essen quest failed");
  1131. }
  1132.  
  1133. Attack.securePosition(me.x, me.y, 30, 2000);
  1134. Pather.makePortal();
  1135. say("1");
  1136.  
  1137. while (!this.playerIn()) {
  1138. delay(200);
  1139. }
  1140.  
  1141. while (this.playerIn()) {
  1142. delay(200);
  1143. }
  1144.  
  1145. Pather.usePortal(null, null);
  1146.  
  1147. return true;
  1148. };
  1149.  
  1150. this.izual = function () {
  1151. if (!Config.Rusher.Izual) {
  1152. return false;
  1153. }
  1154.  
  1155. say("starting izual");
  1156.  
  1157. var i, izualCoords, izual, izualPreset, returnSpot,
  1158. moveIntoPos = function (unit, range) {
  1159. var i, coordx, coordy,
  1160. coords = [],
  1161. angle = Math.round(Math.atan2(me.y - unit.y, me.x - unit.x) * 180 / Math.PI),
  1162. angles = [0, 15, -15, 30, -30, 45, -45, 60, -60, 75, -75, 90, -90, 105, -105, 120, -120, 135, -135, 150, -150, 180];
  1163.  
  1164. for (i = 0; i < angles.length; i += 1) {
  1165. coordx = Math.round((Math.cos((angle + angles[i]) * Math.PI / 180)) * range + unit.x);
  1166. coordy = Math.round((Math.sin((angle + angles[i]) * Math.PI / 180)) * range + unit.y);
  1167.  
  1168. try {
  1169. if (!(getCollision(unit.area, coordx, coordy) & 0x1)) {
  1170. coords.push({
  1171. x: coordx,
  1172. y: coordy
  1173. });
  1174. }
  1175. } catch (e) {
  1176.  
  1177. }
  1178. }
  1179.  
  1180. if (coords.length > 0) {
  1181. coords.sort(Sort.units);
  1182.  
  1183. return Pather.moveToUnit(coords[0]);
  1184. }
  1185.  
  1186. return false;
  1187. };
  1188.  
  1189. Pather.useWaypoint(106, true);
  1190. Precast.doPrecast(false);
  1191. Pather.moveToExit(105, true);
  1192.  
  1193. izualPreset = getPresetUnit(105, 1, 256);
  1194. izualCoords = {
  1195. area: 105,
  1196. x: izualPreset.roomx * 5 + izualPreset.x,
  1197. y: izualPreset.roomy * 5 + izualPreset.y
  1198. };
  1199.  
  1200. moveIntoPos(izualCoords, 50);
  1201.  
  1202. for (i = 0; i < 3; i += 1) {
  1203. izual = getUnit(1, 256);
  1204.  
  1205. if (izual) {
  1206. break;
  1207. }
  1208.  
  1209. delay(500);
  1210. }
  1211.  
  1212. if (izual) {
  1213. moveIntoPos(izual, 60);
  1214. } else {
  1215. print("izual unit not found");
  1216. }
  1217.  
  1218. returnSpot = {
  1219. x: me.x,
  1220. y: me.y
  1221. };
  1222.  
  1223. Attack.securePosition(me.x, me.y, 30, 3000);
  1224. Pather.makePortal();
  1225. say("TP for Izzy.");
  1226.  
  1227. while (!this.playerIn()) {
  1228. delay(200);
  1229. }
  1230.  
  1231. Attack.kill(256); // Izual
  1232. Pickit.pickItems();
  1233. say("Izzy dead, back to town.");
  1234. Pather.moveToUnit(returnSpot);
  1235.  
  1236. while (this.playerIn()) {
  1237. delay(200);
  1238. }
  1239.  
  1240. Pather.usePortal(null, null);
  1241.  
  1242. return true;
  1243. };
  1244.  
  1245. this.shenk = function () {
  1246. if (!Config.Rusher.Shenk) {
  1247. return false;
  1248. }
  1249.  
  1250. say("starting shenk");
  1251.  
  1252. Pather.useWaypoint(111, true);
  1253. Precast.doPrecast(false);
  1254. Pather.moveTo(3846, 5120);
  1255. Attack.securePosition(me.x, me.y, 30, 3000);
  1256. Pather.makePortal();
  1257. say("1");
  1258.  
  1259. while (!this.playerIn()) {
  1260. delay(200);
  1261. }
  1262.  
  1263. Attack.kill(getLocaleString(22435)); // Shenk
  1264. Pickit.pickItems();
  1265. Pather.moveTo(3846, 5120);
  1266. say("2");
  1267.  
  1268. while (this.playerIn()) {
  1269. delay(200);
  1270. }
  1271.  
  1272. Pather.usePortal(null, null);
  1273.  
  1274. return true;
  1275. };
  1276.  
  1277. this.anya = function () {
  1278. if (!Config.Rusher.Anya) {
  1279. return false;
  1280. }
  1281.  
  1282. say("starting anya");
  1283.  
  1284. var anya;
  1285.  
  1286. if (!Town.goToTown() || !Pather.useWaypoint(113, true)) {
  1287. throw new Error("Anya quest failed");
  1288. }
  1289.  
  1290. Precast.doPrecast(false);
  1291.  
  1292. if (!Pather.moveToExit(114, true) || !Pather.moveToPreset(me.area, 2, 460)) {
  1293. throw new Error("Anya quest failed");
  1294. }
  1295.  
  1296. Attack.securePosition(me.x, me.y, 30, 2000);
  1297.  
  1298. anya = getUnit(2, 558);
  1299.  
  1300. if (anya) {
  1301. Pather.moveToUnit(anya);
  1302. sendPacket(1, 0x13, 4, 0x2, 4, anya.gid); // Rusher should be able to interact so quester can get the potion without entering
  1303. delay(1000 + me.ping);
  1304. me.cancel();
  1305. }
  1306.  
  1307. Pather.makePortal();
  1308. say("Anta TP is up.");
  1309.  
  1310. while (!this.playerIn()) {
  1311. delay(200);
  1312. }
  1313.  
  1314. while (getUnit(2, 558)) {
  1315. delay(1000);
  1316. }
  1317.  
  1318. say("2"); // Mainly for non-questers to know when to get the scroll of resistance
  1319.  
  1320. while (this.playerIn()) {
  1321. delay(200);
  1322. }
  1323.  
  1324. Pather.usePortal(null, null);
  1325.  
  1326. return true;
  1327. };
  1328.  
  1329. print("Loading RushThread");
  1330.  
  1331. var i, command,
  1332. current = 0,
  1333. sequence = [
  1334. "andariel", "radament", "cube", "amulet", "staff", "summoner", "duriel", "lamesen",
  1335. "travincal", "mephisto", "izual", "diablo", "shenk", "anya", "ancients", "baal"
  1336. ];
  1337.  
  1338. this.scriptEvent = function (msg) {
  1339. command = msg;
  1340. };
  1341.  
  1342. addEventListener("scriptmsg", this.scriptEvent);
  1343.  
  1344. // Start
  1345. Config.init(false);
  1346. Pickit.init(false);
  1347. Attack.init();
  1348. Storage.Init();
  1349. CraftingSystem.buildLists();
  1350. Runewords.init();
  1351. Cubing.init();
  1352.  
  1353. while (true) {
  1354. if (command) {
  1355. switch (command) {
  1356. case "go":
  1357. // End run if entire sequence is done or if Config.Rusher.LastRun is done
  1358. if (current >= sequence.length || (Config.Rusher.LastRun && current > sequence.indexOf(Config.Rusher.LastRun))) {
  1359. delay(3000);
  1360. say("bye ~");
  1361.  
  1362. while (Misc.getPlayerCount() > 1) {
  1363. delay(1000);
  1364. }
  1365.  
  1366. scriptBroadcast("quit");
  1367.  
  1368. return true;
  1369. }
  1370.  
  1371. try {
  1372. this[sequence[current]]();
  1373. } catch (sequenceError) {
  1374. say(sequenceError.message);
  1375. say("2");
  1376. Town.goToTown();
  1377. }
  1378.  
  1379. current += 1;
  1380.  
  1381. command = "go";
  1382.  
  1383. break;
  1384. default:
  1385. if (command.split(" ")[0] !== undefined && command.split(" ")[0] === "skiptoact") {
  1386. if (!isNaN(parseInt(command.split(" ")[1], 10))) {
  1387. switch (parseInt(command.split(" ")[1], 10)) {
  1388. case 2:
  1389. current = sequence.indexOf("andariel") + 1;
  1390.  
  1391. break;
  1392. case 3:
  1393. current = sequence.indexOf("duriel") + 1;
  1394.  
  1395. break;
  1396. case 4:
  1397. current = sequence.indexOf("mephisto") + 1;
  1398.  
  1399. break;
  1400. case 5:
  1401. current = sequence.indexOf("diablo") + 1;
  1402.  
  1403. break;
  1404. }
  1405. }
  1406. } else if (command.split(" ")[0] !== undefined && command.split(" ")[0] === "clear") {
  1407. this.clearArea(Number(command.split(" ")[1]));
  1408. Town.goToTown();
  1409.  
  1410. command = "go";
  1411. } else {
  1412. for (i = 0; i < sequence.length; i += 1) {
  1413. if (command && sequence[i].match(command, "gi")) {
  1414. current = i;
  1415.  
  1416. break;
  1417. }
  1418. }
  1419.  
  1420. Town.goToTown();
  1421.  
  1422. command = "go";
  1423.  
  1424. break;
  1425. }
  1426.  
  1427. break;
  1428. }
  1429.  
  1430. //command = false;
  1431. }
  1432.  
  1433. delay(100);
  1434. }
  1435.  
  1436. return true;
  1437. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement