Advertisement
gtoilet

clear cs no seals/diablo

Apr 21st, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 KB | None | 0 0
  1. /**
  2. * @filename DiabloHelper.js
  3. * @author kolton
  4. * @desc help leading player in clearing Chaos Sanctuary and killing Diablo
  5. */
  6.  
  7. function DiabloHelper() {
  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); // 1 = "Y", 2 = "L"
  71. this.seisLayout = this.getLayout(394, 7773); // 1 = "2", 2 = "5"
  72. this.infLayout = this.getLayout(392, 7893); // 1 = "I", 2 = "J"
  73. };
  74.  
  75. this.getBoss = function (name) {
  76. var i, boss, glow;
  77.  
  78. while (true) {
  79. if (!this.preattack(name)) {
  80. delay(500);
  81. }
  82.  
  83. glow = getUnit(2, 131);
  84.  
  85. if (glow) {
  86. break;
  87. }
  88. }
  89.  
  90. for (i = 0; i < 16; i += 1) {
  91. boss = getUnit(1, name);
  92.  
  93. if (boss) {
  94. return Attack.clear(40, 0, name, this.sort);
  95. }
  96.  
  97. delay(250);
  98. }
  99.  
  100. return !!glow;
  101. };
  102.  
  103. this.vizierSeal = function () {
  104. this.followPath(this.vizLayout === 1 ? this.starToVizA : this.starToVizB, this.sort);
  105.  
  106.  
  107.  
  108. return true;
  109. };
  110.  
  111. this.seisSeal = function () {
  112. this.followPath(this.seisLayout === 1 ? this.starToSeisA : this.starToSeisB, this.sort);
  113.  
  114.  
  115.  
  116. return true;
  117. };
  118.  
  119. this.infectorSeal = function () {
  120. this.followPath(this.infLayout === 1 ? this.starToInfA : this.starToInfB, this.sort);
  121.  
  122.  
  123. return true;
  124. };
  125.  
  126. this.diabloPrep = function () {
  127. var trapCheck,
  128. tick = getTickCount();
  129.  
  130. while (getTickCount() - tick < 30000) {
  131. if (getTickCount() - tick >= 8000) {
  132. switch (me.classid) {
  133. case 1: // Sorceress
  134. if ([56, 59, 64].indexOf(Config.AttackSkill[1]) > -1) {
  135. if (me.getState(121)) {
  136. delay(500);
  137. } else {
  138. Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
  139. }
  140.  
  141. break;
  142. }
  143.  
  144. delay(500);
  145.  
  146. break;
  147. case 3: // Paladin
  148. Skill.setSkill(Config.AttackSkill[2]);
  149. Skill.cast(Config.AttackSkill[1], 1);
  150.  
  151. break;
  152. case 5: // Druid
  153. if (Config.AttackSkill[1] === 245) {
  154. Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
  155.  
  156. break;
  157. }
  158.  
  159. delay(500);
  160.  
  161. break;
  162. case 6: // Assassin
  163. if (Config.UseTraps) {
  164. trapCheck = ClassAttack.checkTraps({x: 7793, y: 5293});
  165.  
  166. if (trapCheck) {
  167. ClassAttack.placeTraps({x: 7793, y: 5293, classid: 243}, trapCheck);
  168.  
  169. break;
  170. }
  171. }
  172.  
  173. delay(500);
  174.  
  175. break;
  176. default:
  177. delay(500);
  178.  
  179. break;
  180. }
  181. } else {
  182. delay(500);
  183. }
  184.  
  185. if (getUnit(1, 243)) {
  186. return true;
  187. }
  188. }
  189.  
  190. throw new Error("Diablo not found");
  191. };
  192.  
  193. this.preattack = function (id) {
  194. var trapCheck,
  195. coords = [];
  196.  
  197. switch (id) {
  198. case getLocaleString(2851):
  199. if (this.vizLayout === 1) {
  200. coords = [7676, 5295];
  201. }
  202.  
  203. coords = [7684, 5318];
  204.  
  205. break;
  206. case getLocaleString(2852):
  207. if (this.seisLayout === 1) {
  208. coords = [7778, 5216];
  209. }
  210.  
  211. coords = [7775, 5208];
  212.  
  213. break;
  214. case getLocaleString(2853):
  215. if (this.infLayout === 1) {
  216. coords = [7913, 5292];
  217. }
  218.  
  219. coords = [7915, 5280];
  220.  
  221. break;
  222. }
  223.  
  224. switch (me.classid) {
  225. case 1:
  226. if ([56, 59, 64].indexOf(Config.AttackSkill[1]) > -1) {
  227. if (me.getState(121)) {
  228. delay(500);
  229. } else {
  230. Skill.cast(Config.AttackSkill[1], 0, coords[0], coords[1]);
  231. }
  232.  
  233. return true;
  234. }
  235.  
  236. break;
  237. case 3:
  238. break;
  239. case 6:
  240. if (Config.UseTraps) {
  241. trapCheck = ClassAttack.checkTraps({x: coords[0], y: coords[1]});
  242.  
  243. if (trapCheck) {
  244. ClassAttack.placeTraps({x: coords[0], y: coords[1]}, 5);
  245.  
  246. return true;
  247. }
  248. }
  249.  
  250. break;
  251. }
  252.  
  253. return false;
  254. };
  255.  
  256. this.followPath = function (path) {
  257. var i;
  258.  
  259. for (i = 0; i < path.length; i += 2) {
  260. if (this.cleared.length) {
  261. this.clearStrays();
  262. }
  263.  
  264. Pather.moveTo(path[i], path[i + 1], 3, getDistance(me, path[i], path[i + 1]) > 50);
  265. Attack.clear(30, 0, false, this.sort);
  266.  
  267. // Push cleared positions so they can be checked for strays
  268. this.cleared.push([path[i], path[i + 1]]);
  269.  
  270. // After 5 nodes go back 2 nodes to check for monsters
  271. if (i === 10 && path.length > 16) {
  272. path = path.slice(6);
  273. i = 0;
  274. }
  275. }
  276. };
  277.  
  278. this.clearStrays = function () {
  279. /*if (!Config.PublicMode) {
  280. return false;
  281. }*/
  282.  
  283. var i,
  284. oldPos = {x: me.x, y: me.y},
  285. monster = getUnit(1);
  286.  
  287. if (monster) {
  288. do {
  289. if (Attack.checkMonster(monster)) {
  290. for (i = 0; i < this.cleared.length; i += 1) {
  291. if (getDistance(monster, this.cleared[i][0], this.cleared[i][1]) < 30 && Attack.validSpot(monster.x, monster.y)) {
  292. me.overhead("we got a stray");
  293. Pather.moveToUnit(monster);
  294. Attack.clear(15, 0, false, this.sort);
  295.  
  296. break;
  297. }
  298. }
  299. }
  300. } while (monster.getNext());
  301. }
  302.  
  303. if (getDistance(me, oldPos.x, oldPos.y) > 5) {
  304. Pather.moveTo(oldPos.x, oldPos.y);
  305. }
  306.  
  307. return true;
  308. };
  309.  
  310. this.cleared = [];
  311.  
  312. // path coordinates
  313. this.entranceToStar = [7794, 5517, 7791, 5491, 7768, 5459, 7775, 5424, 7817, 5458, 7777, 5408, 7769, 5379, 7777, 5357, 7809, 5359, 7805, 5330, 7780, 5317, 7774, 5305];
  314. this.starToVizA = [7759, 5295, 7734, 5295, 7716, 5295, 7718, 5276, 7697, 5292, 7678, 5293, 7665, 5276, 7662, 5314];
  315. this.starToVizB = [7759, 5295, 7734, 5295, 7716, 5295, 7701, 5315, 7666, 5313, 7653, 5284];
  316. this.starToSeisA = [7781, 5259, 7805, 5258, 7802, 5237, 7776, 5228, 7775, 5205, 7804, 5193, 7814, 5169, 7788, 5153];
  317. this.starToSeisB = [7781, 5259, 7805, 5258, 7802, 5237, 7776, 5228, 7811, 5218, 7807, 5194, 7779, 5193, 7774, 5160, 7803, 5154];
  318. this.starToInfA = [7809, 5268, 7834, 5306, 7852, 5280, 7852, 5310, 7869, 5294, 7895, 5295, 7919, 5290];
  319. this.starToInfB = [7809, 5268, 7834, 5306, 7852, 5280, 7852, 5310, 7869, 5294, 7895, 5274, 7927, 5275, 7932, 5297, 7923, 5313];
  320.  
  321. var i, party;
  322.  
  323. // start
  324. Town.doChores();
  325.  
  326. if (Config.DiabloHelper.SkipIfBaal) {
  327. AreaInfoLoop:
  328. while (true) {
  329. me.overhead("Getting party area info");
  330.  
  331. if (Misc.getPlayerCount() <= 1) {
  332. throw new Error("Empty game"); // Alone in game
  333. }
  334.  
  335. party = getParty();
  336.  
  337. if (party) {
  338. do {
  339. if (party.name !== me.name && party.area) {
  340. break AreaInfoLoop; // Can read player area
  341. }
  342. } while (party.getNext());
  343. }
  344.  
  345. delay(1000);
  346. }
  347.  
  348. party = getParty();
  349.  
  350. if (party) {
  351. do {
  352. if (party.area === 131 || party.area === 132) { // Player is in Throne of Destruction or Worldstone Chamber
  353. return false; // End script
  354. }
  355. } while (party.getNext());
  356. }
  357. }
  358.  
  359. Pather.useWaypoint(Config.RandomPrecast ? "random" : 107);
  360. Precast.doPrecast(true);
  361.  
  362. if (Config.DiabloHelper.SkipTP) {
  363. if (me.area !== 107) {
  364. Pather.useWaypoint(107);
  365. }
  366.  
  367. if (!Pather.moveTo(7790, 5544)) {
  368. throw new Error("Failed to move to Chaos Sanctuary");
  369. }
  370.  
  371. if (!Config.DiabloHelper.Entrance) {
  372. Pather.moveTo(7774, 5305);
  373. }
  374.  
  375. CSLoop:
  376. for (i = 0; i < Config.DiabloHelper.Wait; i += 1) {
  377. party = getParty();
  378.  
  379. if (party) {
  380. do {
  381. if (party.name !== me.name && party.area === 108 && (!Config.Leader || party.name === Config.Leader)) {
  382. break CSLoop;
  383. }
  384. } while (party.getNext());
  385. }
  386.  
  387. Attack.clear(30, 0, false, this.sort);
  388. delay(1000);
  389. }
  390.  
  391. if (i === Config.DiabloHelper.Wait) {
  392. throw new Error("Player wait timed out (" + (Config.Leader ? "Leader not" : "No players") + " found in Chaos)");
  393. }
  394. } else {
  395. Pather.useWaypoint(103);
  396. Town.move("portalspot");
  397.  
  398. for (i = 0; i < Config.DiabloHelper.Wait; i += 1) {
  399. if (Pather.getPortal(108, Config.Leader || null) && Pather.usePortal(108, Config.Leader || null)) {
  400. break;
  401. }
  402.  
  403. delay(1000);
  404. }
  405.  
  406. if (i === Config.DiabloHelper.Wait) {
  407. throw new Error("Player wait timed out (" + (Config.Leader ? "No leader" : "No player") + " portals found)");
  408. }
  409. }
  410.  
  411. this.initLayout();
  412.  
  413. if (Config.DiabloHelper.Entrance) {
  414. Attack.clear(35, 0, false, this.sort);
  415. this.followPath(this.entranceToStar);
  416. } else {
  417. Pather.moveTo(7774, 5305);
  418. Attack.clear(35, 0, false, this.sort);
  419. }
  420.  
  421. Pather.moveTo(7774, 5305);
  422. Attack.clear(35, 0, false, this.sort);
  423. this.vizierSeal();
  424. this.seisSeal();
  425. Precast.doPrecast(true);
  426. this.infectorSeal();
  427.  
  428. switch (me.classid) {
  429. case 1:
  430. Pather.moveTo(7793, 5291);
  431.  
  432. break;
  433. default:
  434. Pather.moveTo(7788, 5292);
  435.  
  436. break;
  437. }
  438.  
  439. Pickit.pickItems();
  440.  
  441. return true;
  442. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement