Advertisement
kolton

Untitled

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