Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
103
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 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 hydra = getUnit(1, getLocaleString(3325));
  127.  
  128. if (hydra) {
  129. do {
  130. if (hydra.mode !== 12 && hydra.getStat(172) !== 2) {
  131. Pather.moveTo(15118, 5002);
  132.  
  133. while (hydra.mode !== 12) {
  134. delay(500);
  135.  
  136. if (!copyUnit(hydra).x) {
  137. break;
  138. }
  139. }
  140.  
  141. break;
  142. }
  143. } while (hydra.getNext());
  144. }
  145.  
  146. return true;
  147. };
  148.  
  149. if (Config.BaalHelper.KillNihlathak) {
  150. include("bots/Nihlathak.js");
  151.  
  152. try {
  153. Nihlathak.call();
  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.call();
  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. Pather.useWaypoint(Config.RandomPrecast ? "random" : 129);
  175. Precast.doPrecast(true);
  176.  
  177. if (Config.BaalHelper.SkipTP) {
  178. Pather.useWaypoint(129);
  179. Precast.doPrecast(true);
  180. Attack.clearLevel(Config.ClearType);
  181.  
  182. if (Pather.moveToExit(128, true)) {
  183. Attack.clearLevel(Config.ClearType);
  184. }
  185.  
  186. if (Pather.moveToExit([129, 130], true)) {
  187. Attack.clearLevel(Config.ClearType);
  188. }
  189.  
  190. if (!Pather.moveToExit([130, 131], true)) {
  191. Attack.clearLevel(Config.ClearType);
  192. }
  193.  
  194. Pather.moveTo(15095, 5029);
  195.  
  196.  
  197.  
  198. WSKLoop:
  199. for (i = 0; i < Config.BaalHelper.Wait; i += 1) {
  200. party = getParty();
  201.  
  202. if (party) {
  203. do {
  204. if ((!Config.Leader || party.name === Config.Leader) && party.area === 131) {
  205. break WSKLoop;
  206. }
  207. } while (party.getNext());
  208. }
  209.  
  210. delay(1000);
  211. }
  212.  
  213. if (i === Config.BaalHelper.Wait) {
  214. throw new Error("Player wait timed out (" + (Config.Leader ? "Leader not" : "No players") + " found in Throne)");
  215. }
  216.  
  217. for (i = 0; i < 3; i += 1) {
  218. entrance = getUnit(5, 82);
  219.  
  220. if (entrance) {
  221. break;
  222. }
  223.  
  224. delay(200);
  225. }
  226.  
  227. if (entrance) {
  228. Pather.moveTo(entrance.x > me.x ? entrance.x - 5 : entrance.x + 5, entrance.y > me.y ? entrance.y - 5 : entrance.y + 5);
  229. }
  230.  
  231. if (!Pather.moveToExit([130, 131], false)) {
  232. throw new Error("Failed to move to WSK3.");
  233. }
  234.  
  235. if (!Pather.moveToExit(131, true)) {
  236. throw new Error("Failed to move to Throne of Destruction.");
  237. }
  238.  
  239. if (!Pather.moveTo(15113, 5040)) {
  240. D2Bot.printToConsole("path fail");
  241. }
  242. } else {
  243. Pather.useWaypoint(109);
  244. Town.move("portalspot");
  245.  
  246. for (i = 0; i < Config.BaalHelper.Wait; i += 1) {
  247. if (Pather.getPortal(131, Config.Leader || null) && Pather.usePortal(131, Config.Leader || null)) {
  248. break;
  249. }
  250.  
  251. delay(1000);
  252. }
  253.  
  254. if (i === Config.BaalHelper.Wait) {
  255. throw new Error("Player wait timed out (" + (Config.Leader ? "No leader" : "No player") + " portals found)");
  256. }
  257. }
  258.  
  259. if (Config.BaalHelper.DollQuit && getUnit(1, 691)) {
  260. print("Undead Soul Killers found.");
  261.  
  262. return true;
  263. }
  264.  
  265. Precast.doPrecast(false);
  266. Attack.clear(15);
  267. this.clearThrone();
  268.  
  269. tick = getTickCount();
  270.  
  271. Pather.moveTo(15093, me.classid === 3 ? 5029 : 5039);
  272.  
  273. MainLoop:
  274. while (true) {
  275. if (getDistance(me, 15093, me.classid === 3 ? 5029 : 5039) > 3) {
  276. Pather.moveTo(15093, me.classid === 3 ? 5029 : 5039);
  277. }
  278.  
  279. if (!getUnit(1, 543)) {
  280. break MainLoop;
  281. }
  282.  
  283. switch (this.checkThrone()) {
  284. case 1:
  285. Attack.clear(40);
  286.  
  287. tick = getTickCount();
  288.  
  289. Precast.doPrecast(true);
  290.  
  291. break;
  292. case 2:
  293. Attack.clear(40);
  294.  
  295. tick = getTickCount();
  296.  
  297. break;
  298. case 4:
  299. Attack.clear(40);
  300.  
  301. tick = getTickCount();
  302.  
  303. break;
  304. case 3:
  305. Attack.clear(40);
  306. this.checkHydra();
  307.  
  308. tick = getTickCount();
  309.  
  310. break;
  311. case 5:
  312. Attack.clear(40);
  313.  
  314. break MainLoop;
  315. default:
  316. if (getTickCount() - tick < 7e3) {
  317. if (me.getState(2)) {
  318. Skill.setSkill(109, 0);
  319. }
  320.  
  321. break;
  322. }
  323.  
  324. if (!this.preattack()) {
  325. delay(100);
  326. }
  327.  
  328. break;
  329. }
  330.  
  331. Precast.doPrecast(false);
  332. delay(10);
  333. }
  334.  
  335. if (Config.BaalHelper.KillBaal) {
  336. Pather.moveTo(15092, 5011);
  337. Precast.doPrecast(false);
  338.  
  339. while (getUnit(1, 543)) {
  340. delay(500);
  341. }
  342.  
  343. delay(1000);
  344. Pather.moveTo(15092, 5011);
  345.  
  346. portal = getUnit(2, 563);
  347.  
  348. if (portal) {
  349. Pather.usePortal(null, null, portal);
  350. } else {
  351. throw new Error("Couldn't find portal.");
  352. }
  353.  
  354. Pather.moveTo(15134, 5923);
  355. Attack.kill(544); // Baal
  356. Pickit.pickItems();
  357. } else {
  358. while (true) {
  359. delay(500);
  360. }
  361. }
  362.  
  363. return true;
  364. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement