Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.27 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. // Entrance to Star / De Seis
  11. if (me.y > 5325 || me.y < 5260) {
  12. if (a.y > b.y) {
  13. return -1;
  14. }
  15.  
  16. return 1;
  17. }
  18.  
  19. // Vizier
  20. if (me.x < 7765) {
  21. if (a.x > b.x) {
  22. return -1;
  23. }
  24.  
  25. return 1;
  26. }
  27.  
  28. // Infector
  29. if (me.x > 7825) {
  30. if (!checkCollision(me, a, 0x1) && a.x < b.x) {
  31. return -1;
  32. }
  33.  
  34. return 1;
  35. }
  36.  
  37. return getDistance(me, a) - getDistance(me, b);
  38. };
  39.  
  40. // general functions
  41. this.getLayout = function (seal, value) {
  42. var sealPreset = getPresetUnit(108, 2, seal);
  43.  
  44. if (!seal) {
  45. throw new Error("Seal preset not found. Can't continue.");
  46. }
  47.  
  48. if (sealPreset.roomy * 5 + sealPreset.y === value || sealPreset.roomx * 5 + sealPreset.x === value) {
  49. return 1;
  50. }
  51.  
  52. return 2;
  53. };
  54.  
  55. this.initLayout = function () {
  56. this.vizLayout = this.getLayout(396, 5275); // 1 = "Y", 2 = "L"
  57. this.seisLayout = this.getLayout(394, 7773); // 1 = "2", 2 = "5"
  58. this.infLayout = this.getLayout(392, 7893); // 1 = "I", 2 = "J"
  59. };
  60.  
  61. this.getBoss = function (name) {
  62. var i, boss, glow;
  63.  
  64. while (true) {
  65. if (!this.preattack(name)) {
  66. delay(500);
  67. }
  68.  
  69. glow = getUnit(2, 131);
  70.  
  71. if (glow) {
  72. break;
  73. }
  74. }
  75.  
  76. for (i = 0; i < 16; i += 1) {
  77. boss = getUnit(1, name);
  78.  
  79. if (boss) {
  80. return Attack.clear(40, 0, name, this.sort);
  81. }
  82.  
  83. delay(250);
  84. }
  85.  
  86. return !!glow;
  87. };
  88.  
  89. this.vizierSeal = function () {
  90. this.followPath(this.vizLayout === 1 ? this.starToVizA : this.starToVizB, this.sort);
  91.  
  92. if (this.vizLayout === 1) {
  93. Pather.moveTo(7691, 5292);
  94. } else {
  95. Pather.moveTo(7695, 5316);
  96. }
  97.  
  98. if (!this.getBoss(getLocaleString(2851))) {
  99. throw new Error("Failed to kill Vizier");
  100. }
  101.  
  102. if (Config.FieldID) {
  103. Town.fieldID();
  104. }
  105.  
  106. return true;
  107. };
  108.  
  109. this.seisSeal = function () {
  110. this.followPath(this.seisLayout === 1 ? this.starToSeisA : this.starToSeisB, this.sort);
  111.  
  112. if (this.seisLayout === 1) {
  113. Pather.moveTo(7771, 5196);
  114. } else {
  115. Pather.moveTo(7798, 5186);
  116. }
  117.  
  118. if (!this.getBoss(getLocaleString(2852))) {
  119. throw new Error("Failed to kill de Seis");
  120. }
  121.  
  122. if (Config.FieldID) {
  123. Town.fieldID();
  124. }
  125.  
  126. return true;
  127. };
  128.  
  129. this.infectorSeal = function () {
  130. this.followPath(this.infLayout === 1 ? this.starToInfA : this.starToInfB, this.sort);
  131.  
  132. if (this.infLayout === 1) {
  133. delay(1);
  134. } else {
  135. Pather.moveTo(7928, 5295); // temp
  136. }
  137.  
  138. if (!this.getBoss(getLocaleString(2853))) {
  139. throw new Error("Failed to kill Infector");
  140. }
  141.  
  142. if (Config.FieldID) {
  143. Town.fieldID();
  144. }
  145.  
  146. return true;
  147. };
  148.  
  149. this.diabloPrep = function () {
  150. var trapCheck,
  151. tick = getTickCount();
  152.  
  153. while (getTickCount() - tick < 40000) {
  154. if (getTickCount() - tick >= 8000) {
  155. switch (me.classid) {
  156. case 1: // Sorceress
  157. if ([56, 59, 64].indexOf(Config.AttackSkill[1]) > -1) {
  158. if (me.getState(121)) {
  159. delay(500);
  160. } else {
  161. Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
  162. }
  163.  
  164. break;
  165. }
  166.  
  167. delay(500);
  168.  
  169. break;
  170. case 3: // Paladin
  171. Skill.setSkill(Config.AttackSkill[2]);
  172. Skill.cast(Config.AttackSkill[1], 1);
  173.  
  174. break;
  175. case 5: // Druid
  176. if (Config.AttackSkill[1] === 245) {
  177. Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
  178.  
  179. break;
  180. }
  181.  
  182. delay(500);
  183.  
  184. break;
  185. case 6: // Assassin
  186. if (Config.UseTraps) {
  187. trapCheck = ClassAttack.checkTraps({x: 7793, y: 5293});
  188.  
  189. if (trapCheck) {
  190. ClassAttack.placeTraps({x: 7793, y: 5293, classid: 243}, trapCheck);
  191.  
  192. break;
  193. }
  194. }
  195.  
  196. delay(500);
  197.  
  198. break;
  199. default:
  200. delay(500);
  201.  
  202. break;
  203. }
  204. } else {
  205. delay(500);
  206. }
  207.  
  208. if (getUnit(1, 243)) {
  209. return true;
  210. }
  211. }
  212.  
  213. throw new Error("Diablo not found");
  214. };
  215.  
  216. this.preattack = function (id) {
  217. var trapCheck,
  218. coords = [];
  219.  
  220. switch (id) {
  221. case getLocaleString(2851):
  222. if (this.vizLayout === 1) {
  223. coords = [7676, 5295];
  224. }
  225.  
  226. coords = [7684, 5318];
  227.  
  228. break;
  229. case getLocaleString(2852):
  230. if (this.seisLayout === 1) {
  231. coords = [7778, 5216];
  232. }
  233.  
  234. coords = [7775, 5208];
  235.  
  236. break;
  237. case getLocaleString(2853):
  238. if (this.infLayout === 1) {
  239. coords = [7913, 5292];
  240. }
  241.  
  242. coords = [7915, 5280];
  243.  
  244. break;
  245. }
  246.  
  247. switch (me.classid) {
  248. case 1:
  249. if ([56, 59, 64].indexOf(Config.AttackSkill[1]) > -1) {
  250. if (me.getState(121)) {
  251. delay(500);
  252. } else {
  253. Skill.cast(Config.AttackSkill[1], 0, coords[0], coords[1]);
  254. }
  255. }
  256.  
  257. return true;
  258. case 3:
  259. break;
  260. case 6:
  261. if (Config.UseTraps) {
  262. trapCheck = ClassAttack.checkTraps({x: coords[0], y: coords[1]});
  263.  
  264. if (trapCheck) {
  265. ClassAttack.placeTraps({x: coords[0], y: coords[1]}, 5);
  266. }
  267. }
  268.  
  269. return true;
  270. }
  271.  
  272. return false;
  273. };
  274.  
  275. this.followPath = function (path) {
  276. var i;
  277.  
  278. for (i = 0; i < path.length; i += 2) {
  279. Pather.moveTo(path[i], path[i + 1]);
  280. Attack.clear(30, 0, false, this.sort);
  281. }
  282. };
  283.  
  284. // path coordinates
  285. 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];
  286. this.starToVizA = [7759, 5295, 7734, 5295, 7716, 5295, 7718, 5276, 7697, 5292, 7678, 5293, 7665, 5276, 7662, 5314];
  287. this.starToVizB = [7759, 5295, 7734, 5295, 7716, 5295, 7701, 5315, 7666, 5313, 7653, 5284];
  288. this.starToSeisA = [7781, 5259, 7805, 5258, 7802, 5237, 7776, 5228, 7775, 5205, 7804, 5193, 7814, 5169, 7788, 5153];
  289. this.starToSeisB = [7781, 5259, 7805, 5258, 7802, 5237, 7776, 5228, 7811, 5218, 7807, 5194, 7779, 5193, 7774, 5160, 7803, 5154];
  290. this.starToInfA = [7809, 5268, 7834, 5306, 7852, 5280, 7852, 5310, 7869, 5294, 7895, 5295, 7919, 5290];
  291. this.starToInfB = [7809, 5268, 7834, 5306, 7852, 5280, 7852, 5310, 7869, 5294, 7895, 5274, 7927, 5275, 7932, 5297, 7923, 5313];
  292.  
  293. var i, partybaal, areaCheck;
  294.  
  295. // start
  296. Town.doChores();
  297. Pather.useWaypoint(107);
  298. Precast.doPrecast(true);
  299. Pather.useWaypoint(103);
  300. Town.move("portalspot");
  301.  
  302. for (i = 0; i < Config.DiabloHelper.Wait; i += 1) {
  303. partybaal = getParty();
  304.  
  305. if (partybaal) {
  306. do {
  307. if (!areaCheck && partybaal.name !== me.name && partybaal.area) {
  308. areaCheck = true;
  309. }
  310.  
  311. if (partybaal.area === 131) {
  312. return false;
  313. }
  314. } while (partybaal.getNext());
  315. }
  316.  
  317. if (areaCheck && Pather.usePortal(108, null)) {
  318. break;
  319. }
  320.  
  321. delay(1000);
  322. }
  323.  
  324. if (i === Config.DiabloHelper.Wait) {
  325. throw new Error("No portals to Chaos");
  326. }
  327.  
  328. this.initLayout();
  329.  
  330. if (Config.DiabloHelper.Entrance) {
  331. Attack.clear(35, 0, false, this.sort);
  332. this.followPath(this.entranceToStar);
  333. } else {
  334. Pather.moveTo(7774, 5305);
  335. Attack.clear(35, 0, false, this.sort);
  336. }
  337.  
  338. Pather.moveTo(7774, 5305);
  339. Attack.clear(35, 0, false, this.sort);
  340. this.vizierSeal();
  341. this.seisSeal();
  342. Precast.doPrecast(true);
  343. this.infectorSeal();
  344. Pather.moveTo(7788, 5292);
  345. this.diabloPrep();
  346. Attack.kill(243); // Diablo
  347. Pickit.pickItems();
  348.  
  349. return true;
  350. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement