Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.10 KB | None | 0 0
  1. /**
  2. * @filename Diablo.js
  3. * @author kolton
  4. * @desc clear Chaos Sanctuary and kill Diablo
  5. */
  6.  
  7. function Diablo() {
  8. // Sort function
  9. this.sort = function (a, b) {
  10. if (Config.BossPriority) {
  11. if ((a.spectype & 0x5) && (b.spectype & 0x5)) {
  12. return getDistance(me, a) - getDistance(me, b);
  13. }
  14.  
  15. if (a.spectype & 0x5) {
  16. return -1;
  17. }
  18.  
  19. if (b.spectype & 0x5) {
  20. return 1;
  21. }
  22. }
  23.  
  24. // Entrance to Star / De Seis
  25. if (me.y > 5325 || me.y < 5260) {
  26. if (a.y > b.y) {
  27. return -1;
  28. }
  29.  
  30. return 1;
  31. }
  32.  
  33. // Vizier
  34. if (me.x < 7765) {
  35. if (a.x > b.x) {
  36. return -1;
  37. }
  38.  
  39. return 1;
  40. }
  41.  
  42. // Infector
  43. if (me.x > 7825) {
  44. if (!checkCollision(me, a, 0x1) && a.x < b.x) {
  45. return -1;
  46. }
  47.  
  48. return 1;
  49. }
  50.  
  51. return getDistance(me, a) - getDistance(me, b);
  52. };
  53.  
  54. // general functions
  55. this.getLayout = function (seal, value) {
  56. var sealPreset = getPresetUnit(108, 2, seal);
  57.  
  58. if (!seal) {
  59. throw new Error("Seal preset not found. Can't continue.");
  60. }
  61.  
  62. if (sealPreset.roomy * 5 + sealPreset.y === value || sealPreset.roomx * 5 + sealPreset.x === value) {
  63. return 1;
  64. }
  65.  
  66. return 2;
  67. };
  68.  
  69. this.initLayout = function () {
  70. this.vizLayout = this.getLayout(396, 5275);
  71. this.seisLayout = this.getLayout(394, 7773);
  72. this.infLayout = this.getLayout(392, 7893);
  73. };
  74.  
  75. this.openSeal = function (classid) {
  76. var i, seal, warn;
  77.  
  78. switch (classid) {
  79. case 396:
  80. case 394:
  81. case 392:
  82. warn = true;
  83.  
  84. break;
  85. default:
  86. warn = false;
  87.  
  88. break;
  89. }
  90.  
  91. for (i = 0; i < 5; i += 1) {
  92. Pather.moveToPreset(108, 2, classid, classid === 394 ? 5 : 2, classid === 394 ? 5 : 0);
  93.  
  94. seal = getUnit(2, classid);
  95.  
  96. if (!seal) {
  97. return false;
  98. }
  99.  
  100. if (seal.mode) { // for pubbies
  101. if (warn) {
  102. say(Config.Diablo.SealWarning);
  103. }
  104.  
  105. return true;
  106. }
  107.  
  108. warn = false;
  109.  
  110. if (classid === 394) {
  111. Misc.click(0, 0, seal);
  112. } else {
  113. seal.interact();
  114. }
  115.  
  116. delay(classid === 394 ? 1000 : 500);
  117.  
  118. if (!seal.mode) {
  119. if (classid === 394 && Attack.validSpot(seal.x + 15, seal.y)) { // de seis optimization
  120. Pather.moveTo(seal.x + 15, seal.y);
  121. } else {
  122. Pather.moveTo(seal.x - 5, seal.y - 5);
  123. }
  124.  
  125. delay(500);
  126. } else {
  127. return true;
  128. }
  129. }
  130.  
  131. return false;
  132. };
  133.  
  134. this.chaosPreattack = function (name, amount) {
  135. var i, n, target, positions;
  136.  
  137. switch (me.classid) {
  138. case 0:
  139. break;
  140. case 1:
  141. break;
  142. case 2:
  143. break;
  144. case 3:
  145. target = getUnit(1, name);
  146.  
  147. if (!target) {
  148. return;
  149. }
  150.  
  151. positions = [[6, 11], [0, 8], [8, -1], [-9, 2], [0, -11], [8, -8]];
  152.  
  153. for (i = 0; i < positions.length; i += 1) {
  154. if (Attack.validSpot(target.x + positions[i][0], target.y + positions[i][1])) { // check if we can move there
  155. Pather.moveTo(target.x + positions[i][0], target.y + positions[i][1]);
  156. Skill.setSkill(Config.AttackSkill[2], 0);
  157.  
  158. for (n = 0; n < amount; n += 1) {
  159. Skill.cast(Config.AttackSkill[1], 1);
  160. }
  161.  
  162. break;
  163. }
  164. }
  165.  
  166. break;
  167. case 4:
  168. break;
  169. case 5:
  170. break;
  171. case 6:
  172. break;
  173. }
  174. };
  175.  
  176. this.getBoss = function (name) {
  177. var i, boss,
  178. glow = getUnit(2, 131);
  179.  
  180. for (i = 0; i < 16; i += 1) {
  181. boss = getUnit(1, name);
  182.  
  183. if (boss) {
  184. this.chaosPreattack(name, 8);
  185.  
  186. return Attack.clear(40, 0, name, this.sort);
  187. }
  188.  
  189. delay(250);
  190. }
  191.  
  192. return !!glow;
  193. };
  194.  
  195. this.vizierSeal = function () {
  196. print("Viz layout " + this.vizLayout);
  197. this.followPath(this.vizLayout === 1 ? this.starToVizA : this.starToVizB);
  198.  
  199. if (!this.openSeal(395) || !this.openSeal(396)) {
  200. throw new Error("Failed to open Vizier seals.");
  201. }
  202.  
  203. if (this.vizLayout === 1) {
  204. Pather.moveTo(7691, 5292);
  205. } else {
  206. Pather.moveTo(7695, 5316);
  207. }
  208.  
  209. if (!this.getBoss(getLocaleString(2851))) {
  210. throw new Error("Failed to kill Vizier");
  211. }
  212.  
  213. return true;
  214. };
  215.  
  216. this.seisSeal = function () {
  217. print("Seis layout " + this.seisLayout);
  218. this.followPath(this.seisLayout === 1 ? this.starToSeisA : this.starToSeisB);
  219.  
  220. if (!this.openSeal(394)) {
  221. throw new Error("Failed to open de Seis seal.");
  222. }
  223.  
  224. if (this.seisLayout === 1) {
  225. Pather.moveTo(7771, 5196);
  226. } else {
  227. Pather.moveTo(7798, 5186);
  228. }
  229.  
  230. if (!this.getBoss(getLocaleString(2852))) {
  231. throw new Error("Failed to kill de Seis");
  232. }
  233.  
  234. return true;
  235. };
  236.  
  237. this.infectorSeal = function () {
  238. print("Inf layout " + this.infLayout);
  239. this.followPath(this.infLayout === 1 ? this.starToInfA : this.starToInfB);
  240.  
  241. if (!this.openSeal(392)) {
  242. throw new Error("Failed to open Infector seals.");
  243. }
  244.  
  245. if (this.infLayout === 1) {
  246. delay(1);
  247. } else {
  248. Pather.moveTo(7928, 5295); // temp
  249. }
  250.  
  251. if (!this.getBoss(getLocaleString(2853))) {
  252. throw new Error("Failed to kill Infector");
  253. }
  254.  
  255. if (!this.openSeal(393)) {
  256. throw new Error("Failed to open Infector seals.");
  257. }
  258.  
  259. return true;
  260. };
  261.  
  262. this.getShrine = function () {
  263. var i
  264. for (i = 4; i > 1; i -= 1) {
  265. if (Misc.getShrinesInArea(i, 15, true)) {
  266. break;
  267. }
  268.  
  269. }
  270. };
  271.  
  272. this.diabloPrep = function () {
  273. var trapCheck,
  274. tick = getTickCount();
  275.  
  276. while (getTickCount() - tick < 30000) {
  277. if (getTickCount() - tick >= 8000) {
  278. switch (me.classid) {
  279. case 1: // Sorceress
  280. if ([56, 59, 64].indexOf(Config.AttackSkill[1]) > -1) {
  281. if (me.getState(121)) {
  282. delay(500);
  283. } else {
  284. Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
  285. }
  286.  
  287. break;
  288. }
  289.  
  290. delay(500);
  291.  
  292. break;
  293. case 3: // Paladin
  294. Skill.setSkill(Config.AttackSkill[2]);
  295. Skill.cast(Config.AttackSkill[1], 1);
  296.  
  297. break;
  298. case 5: // Druid
  299. if (Config.AttackSkill[1] === 245) {
  300. Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
  301.  
  302. break;
  303. }
  304.  
  305. delay(500);
  306.  
  307. break;
  308. case 6: // Assassin
  309. if (Config.UseTraps) {
  310. trapCheck = ClassAttack.checkTraps({x: 7793, y: 5293});
  311.  
  312. if (trapCheck) {
  313. ClassAttack.placeTraps({x: 7793, y: 5293, classid: 243}, trapCheck);
  314.  
  315. break;
  316. }
  317. }
  318.  
  319. delay(500);
  320.  
  321. break;
  322. default:
  323. delay(500);
  324.  
  325. break;
  326. }
  327. } else {
  328. delay(500);
  329. }
  330.  
  331. if (getUnit(1, 243)) {
  332. return true;
  333. }
  334. }
  335.  
  336. throw new Error("Diablo not found");
  337. };
  338.  
  339. this.followPath = function (path) {
  340. var i;
  341.  
  342. for (i = 0; i < path.length; i += 2) {
  343. if (this.cleared.length) {
  344. this.clearStrays();
  345. }
  346.  
  347. Pather.moveTo(path[i], path[i + 1], 3, getDistance(me, path[i], path[i + 1]) > 50);
  348. Attack.clear(30, 0, false, this.sort);
  349.  
  350. // Push cleared positions so they can be checked for strays
  351. this.cleared.push([path[i], path[i + 1]]);
  352.  
  353. // After 5 nodes go back 2 nodes to check for monsters
  354. if (i === 10 && path.length > 16) {
  355. path = path.slice(6);
  356. i = 0;
  357. }
  358. }
  359. };
  360.  
  361. this.clearStrays = function () {
  362. /*if (!Config.PublicMode) {
  363. return false;
  364. }*/
  365.  
  366. var i,
  367. oldPos = {x: me.x, y: me.y},
  368. monster = getUnit(1);
  369.  
  370. if (monster) {
  371. do {
  372. if (Attack.checkMonster(monster)) {
  373. for (i = 0; i < this.cleared.length; i += 1) {
  374. if (getDistance(monster, this.cleared[i][0], this.cleared[i][1]) < 30 && Attack.validSpot(monster.x, monster.y)) {
  375. me.overhead("we got a stray");
  376. Pather.moveToUnit(monster);
  377. Attack.clear(15, 0, false, this.sort);
  378.  
  379. break;
  380. }
  381. }
  382. }
  383. } while (monster.getNext());
  384. }
  385.  
  386. if (getDistance(me, oldPos.x, oldPos.y) > 5) {
  387. Pather.moveTo(oldPos.x, oldPos.y);
  388. }
  389.  
  390. return true;
  391. };
  392.  
  393. this.defendPlayers = function () {
  394. var player,
  395. oldPos = {x: me.x, y: me.y},
  396. monster = getUnit(1);
  397.  
  398. if (monster) {
  399. do {
  400. if (Attack.checkMonster(monster)) {
  401. player = getUnit(0);
  402.  
  403. if (player) {
  404. do {
  405. if (player.name !== me.name && getDistance(monster, player) < 30) {
  406. me.overhead("defending players");
  407. Pather.moveToUnit(monster);
  408. Attack.clear(15, 0, false, this.sort);
  409. }
  410. } while (player.getNext());
  411. }
  412. }
  413. } while (monster.getNext());
  414. }
  415.  
  416. if (getDistance(me, oldPos.x, oldPos.y) > 5) {
  417. Pather.moveTo(oldPos.x, oldPos.y);
  418. }
  419.  
  420. return true;
  421. };
  422.  
  423. this.cleared = [];
  424.  
  425. // path coordinates
  426. this.entranceToStar = [7794, 5517, 7791, 5491, 7768, 5459, 7775, 5424, 7817, 5458, 7777, 5408, 7769, 5379, 7777, 5357, 7809, 5359, 7805, 5330, 7780, 5317, 7791, 5293];
  427. this.starToVizA = [7759, 5295, 7734, 5295, 7716, 5295, 7718, 5276, 7697, 5292, 7678, 5293, 7665, 5276, 7662, 5314];
  428. this.starToVizB = [7759, 5295, 7734, 5295, 7716, 5295, 7701, 5315, 7666, 5313, 7653, 5284];
  429. this.starToSeisA = [7781, 5259, 7805, 5258, 7802, 5237, 7776, 5228, 7775, 5205, 7804, 5193, 7814, 5169, 7788, 5153];
  430. this.starToSeisB = [7781, 5259, 7805, 5258, 7802, 5237, 7776, 5228, 7811, 5218, 7807, 5194, 7779, 5193, 7774, 5160, 7803, 5154];
  431. this.starToInfA = [7809, 5268, 7834, 5306, 7852, 5280, 7852, 5310, 7869, 5294, 7895, 5295, 7919, 5290];
  432. this.starToInfB = [7809, 5268, 7834, 5306, 7852, 5280, 7852, 5310, 7869, 5294, 7895, 5274, 7927, 5275, 7932, 5297, 7923, 5313];
  433. Pather._teleport = Pather.teleport;
  434.  
  435. // start
  436. Town.doChores();
  437. Pather.useWaypoint(Config.RandomPrecast ? "random" : 107);
  438. Precast.doPrecast(true);
  439.  
  440. if (me.area !== 107) {
  441. Pather.useWaypoint(107);
  442. }
  443.  
  444. if (!Pather.moveTo(7790, 5544)) {
  445. throw new Error("Failed to move to Chaos Sanctuary");
  446. }
  447.  
  448. this.initLayout();
  449.  
  450. if (Config.Diablo.Entrance) {
  451. Attack.clear(30, 0, false, this.sort);
  452. Pather.moveTo(7790, 5544);
  453.  
  454. if (Config.PublicMode) {
  455. Pather.makePortal();
  456. say(Config.Diablo.EntranceTP);
  457. Pather.teleport = !Config.Diablo.WalkClear && Pather._teleport;
  458. }
  459.  
  460. Pather.moveTo(7790, 5544);
  461. Precast.doPrecast(true);
  462. Attack.clear(30, 0, false, this.sort);
  463. this.followPath(this.entranceToStar);
  464. } else {
  465. Pather.moveTo(7774, 5305);
  466. Attack.clear(15, 0, false, this.sort);
  467. }
  468.  
  469. Pather.moveTo(7791, 5293);
  470.  
  471. if (Config.PublicMode) {
  472. Pather.makePortal();
  473. say(Config.Diablo.StarTP);
  474. Pather.teleport = !Config.Diablo.WalkClear && Pather._teleport;
  475. }
  476.  
  477. Attack.clear(30, 0, false, this.sort);
  478. this.vizierSeal();
  479. this.seisSeal();
  480. Precast.doPrecast(true);
  481. this.infectorSeal();
  482.  
  483. switch (me.classid) {
  484. case 1:
  485. Pather.moveTo(7792, 5294);
  486.  
  487. break;
  488. default:
  489. Pather.moveTo(7788, 5292);
  490.  
  491. break;
  492. }
  493.  
  494.  
  495. if (Config.PublicMode) {
  496. say(Config.Diablo.DiabloMsg);
  497. }
  498.  
  499. this.diabloPrep();
  500. Town.goToTown(4);
  501. Pather.useWaypoint(4);
  502. Precast.doPrecast(true);
  503.  
  504. for (i = 4; i > 1; i -= 1) {
  505. if (Misc.getShrinesInArea(i, 15, true)) {
  506. break;
  507. }
  508. }
  509.  
  510. if (i === 1) {
  511. Town.goToTown();
  512. Pather.useWaypoint(5);
  513.  
  514. for (i = 5; i < 8; i += 1) {
  515. if (Misc.getShrinesInArea(i, 15, true)) {
  516. break;
  517. }
  518. }
  519. }
  520.  
  521. Town.goToTown(4);
  522. Pather.useWaypoint(107);
  523. Pather.moveTo(7791, 5293);
  524. Attack.kill(243); // Diablo
  525. Pickit.pickItems();
  526.  
  527. Pather.teleport = Pather._teleport;
  528.  
  529. return true;
  530. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement