Advertisement
kolton

Untitled

Dec 2nd, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.97 KB | None | 0 0
  1. /**
  2. * @filename Baal.js
  3. * @author kolton, modified by YGM
  4. * @desc clear Throne of Destruction and kill Baal
  5. */
  6.  
  7. function Baal() {
  8. var portal, tick,
  9. RandomPrecast = Config.Baal.RandomPrecast,
  10. DollQuit = Config.Baal.DollQuit,
  11. SoulQuit = Config.Baal.SoulQuit,
  12. KillBaal = Config.Baal.KillBaal,
  13. hotTPMessage = Config.Baal.HotTPMessage,
  14. safeTPMessage = Config.Baal.SafeTPMessage,
  15. baalMessage = Config.Baal.BaalMessage;
  16.  
  17. this.preattack = function () {
  18. var check;
  19. switch (me.classid) {
  20. case 1:
  21. // Sorceress
  22. switch (Config.AttackSkill[1]) {
  23. case 49:
  24. case 53:
  25. case 64:
  26. if (me.getState(121)) {
  27. delay(500);
  28. } else {
  29. Skill.cast(Config.AttackSkill[1], 0, 15094, 5028);
  30. }
  31.  
  32. break;
  33. case 56:
  34. if (me.getState(121)) {
  35. delay(500);
  36. } else {
  37. Skill.cast(Config.AttackSkill[1], 0, 15093, 5028);
  38. }
  39.  
  40. break;
  41. case 59:
  42. if (me.getState(121)) {
  43. delay(500);
  44. } else {
  45. Skill.cast(Config.AttackSkill[1], 0, 15095, 5028);
  46. }
  47.  
  48. break;
  49. }
  50.  
  51. return true;
  52. case 3:
  53. // Paladin
  54. if (Config.AttackSkill[3] !== 112) {
  55. return false;
  56. }
  57.  
  58. if (getDistance(me, 15094, 5029) > 3) {
  59. Pather.moveTo(15094, 5029);
  60. }
  61.  
  62. if (Config.AttackSkill[4] > 0) {
  63. Skill.setSkill(Config.AttackSkill[4], 0);
  64. }
  65.  
  66. Skill.cast(Config.AttackSkill[3], 1);
  67.  
  68. return true;
  69. case 5:
  70. // Druid
  71. if (Config.AttackSkill[3] === 245) {
  72. Skill.cast(Config.AttackSkill[3], 0, 15094, 5028);
  73. return true;
  74. }
  75. break;
  76. case 6:
  77. // Assassin
  78. if (Config.UseTraps) {
  79. check = ClassAttack.checkTraps({
  80. x: 15094,
  81. y: 5028
  82. });
  83.  
  84. if (check) {
  85. ClassAttack.placeTraps({
  86. x: 15094,
  87. y: 5028
  88. }, 5);
  89.  
  90. return true;
  91. }
  92. }
  93.  
  94. break;
  95. }
  96.  
  97. return false;
  98. };
  99.  
  100. this.checkThrone = function () {
  101. var monster = getUnit(1);
  102.  
  103. if (monster) {
  104. do {
  105. if (Attack.checkMonster(monster) && monster.y < 5080) {
  106. switch (monster.classid) {
  107. case 23:
  108. case 62:
  109. return 1;
  110. case 105:
  111. case 381:
  112. return 2;
  113. case 557:
  114. return 3;
  115. case 558:
  116. return 4;
  117. case 571:
  118. return 5;
  119. default:
  120. Attack.getIntoPosition(monster, 10, 0x4);
  121. Attack.clear(15);
  122.  
  123. return false;
  124. }
  125. }
  126. } while (monster.getNext());
  127. }
  128.  
  129. return false;
  130. };
  131.  
  132. this.clearThrone = function () {
  133. var i, monster,
  134. monList = [],
  135. pos = [15094, 5022, 15094, 5041, 15094, 5060, 15094, 5041, 15094, 5022];
  136.  
  137. if (Config.AvoidDolls) {
  138. monster = getUnit(1, 691);
  139.  
  140. if (monster) {
  141. do {
  142. if (monster.x >= 15072 && monster.x <= 15118 && monster.y >= 5002 && monster.y <= 5079 && Attack.checkMonster(monster) && Attack.skipCheck(monster)) {
  143. monList.push(copyUnit(monster));
  144. }
  145. } while (monster.getNext());
  146. }
  147.  
  148. if (monList.length) {
  149. Attack.clearList(monList);
  150. }
  151. }
  152.  
  153. for (i = 0; i < pos.length; i += 2) {
  154. Pather.moveTo(pos[i], pos[i + 1]);
  155. Attack.clear(25);
  156. }
  157. };
  158.  
  159. this.checkHydra = function () {
  160. var monster = getUnit(1, "hydra");
  161. if (monster) {
  162. do {
  163. if (monster.mode !== 12 && monster.getStat(172) !== 2) {
  164. Pather.moveTo(15072, 5002);
  165. while (monster.mode !== 12) {
  166. delay(500);
  167. if (!copyUnit(monster).x) {
  168. break;
  169. }
  170. }
  171.  
  172. break;
  173. }
  174. } while (monster.getNext());
  175. }
  176.  
  177. return true;
  178. };
  179.  
  180. this.announce = function () {
  181. var count, string, souls, dolls,
  182. monster = getUnit(1);
  183.  
  184. if (monster) {
  185. count = 0;
  186.  
  187. do {
  188. if (Attack.checkMonster(monster) && monster.y < 5094) {
  189. if (getDistance(me, monster) <= 40) {
  190. count += 1;
  191. }
  192.  
  193. if (!souls && monster.classid === 641) {
  194. souls = true;
  195. }
  196.  
  197. if (!dolls && monster.classid === 691) {
  198. dolls = true;
  199. }
  200. }
  201. } while (monster.getNext());
  202. }
  203.  
  204. if (count > 30) {
  205. string = "DEADLY!!!" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  206. } else if (count > 20) {
  207. string = "Lethal!" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  208. } else if (count > 10) {
  209. string = "Dangerous!" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  210. } else if (count > 0) {
  211. string = "Warm" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  212. } else {
  213. string = "Cool TP. No immediate monsters.";
  214. }
  215.  
  216. if (souls) {
  217. string += " Souls ";
  218.  
  219. if (dolls) {
  220. string += "and Dolls ";
  221. }
  222.  
  223. string += "in area.";
  224. } else if (dolls) {
  225. string += " Dolls in area.";
  226. }
  227.  
  228. say(string);
  229. };
  230.  
  231. Town.doChores();
  232.  
  233. if (RandomPrecast) {
  234. Pather.useWaypoint("random");
  235. Precast.doPrecast(true);
  236. } else {
  237. Pather.useWaypoint(129);
  238. Precast.doPrecast(true);
  239. }
  240.  
  241. if (me.area !== 129) {
  242. Pather.useWaypoint(129);
  243. }
  244.  
  245. if (!Pather.moveToExit([130, 131], true)) {
  246. throw new Error("Failed to move to Throne of Destruction.");
  247. }
  248.  
  249. Pather.moveTo(15095, 5029);
  250.  
  251. if ((SoulQuit && getUnit(1, 691)) || (DollQuit && getUnit(1, 690))) {
  252. say("Too many undead soul killers and undead stygian dolls, next game!");
  253. print("Undead soul killers or Undead stygian dolls found, ending script.");
  254.  
  255. return true;
  256. }
  257.  
  258. if (Config.PublicMode) {
  259. this.announce();
  260. Pather.moveTo(15118, 5002);
  261. Pather.makePortal();
  262. say(hotTPMessage);
  263. Attack.clear(15);
  264. }
  265.  
  266. this.clearThrone();
  267.  
  268. if (Config.PublicMode) {
  269. Pather.moveTo(15118, 5045);
  270. Pather.makePortal();
  271. say(safeTPMessage);
  272. Precast.doPrecast(true);
  273. }
  274.  
  275. tick = getTickCount();
  276.  
  277. Pather.moveTo(15094, me.classid === 3 ? 5029 : 5038);
  278.  
  279. MainLoop:
  280. while (true) {
  281. if (getDistance(me, 15094, me.classid === 3 ? 5029 : 5038) > 3) {
  282. Pather.moveTo(15094, me.classid === 3 ? 5029 : 5038);
  283. }
  284.  
  285. if (!getUnit(1, 543)) {
  286. break MainLoop;
  287. }
  288.  
  289. switch (this.checkThrone()) {
  290. case 1:
  291. Attack.clear(40);
  292.  
  293. tick = getTickCount();
  294.  
  295. Precast.doPrecast(true);
  296.  
  297. break;
  298. case 2:
  299. Attack.clear(40);
  300.  
  301. tick = getTickCount();
  302.  
  303. break;
  304. case 4:
  305. Attack.clear(40);
  306.  
  307. tick = getTickCount();
  308.  
  309. break;
  310. case 3:
  311. Attack.clear(40);
  312. this.checkHydra();
  313.  
  314. tick = getTickCount();
  315.  
  316. break;
  317. case 5:
  318. Attack.clear(40);
  319.  
  320. break MainLoop;
  321. default:
  322. if (getTickCount() - tick < 7e3) {
  323. if (me.getState(2)) {
  324. Skill.setSkill(109, 0);
  325. }
  326.  
  327. break;
  328. }
  329.  
  330. if (!this.preattack()) {
  331. delay(100);
  332. }
  333.  
  334. break;
  335. }
  336.  
  337. delay(10);
  338. }
  339.  
  340. if (KillBaal) {
  341. if (Config.PublicMode) {
  342. say(baalMessage);
  343. }
  344.  
  345. Pather.moveTo(15090, 5008);
  346. delay(7000);
  347. Precast.doPrecast(true);
  348.  
  349. while (getUnit(1, 543)) {
  350. delay(500);
  351. }
  352.  
  353. portal = getUnit(2, 563);
  354.  
  355. if (portal) {
  356. Pather.usePortal(null, null, portal);
  357. } else {
  358. throw new Error("Couldn't find portal.");
  359. }
  360.  
  361. Pather.moveTo(15134, 5923);
  362. Attack.kill(544); // Baal
  363. Pickit.pickItems();
  364. }
  365.  
  366. return true;
  367. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement