Advertisement
Guest User

Untitled

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