Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. /**
  2. * @filename AutoBaal.js
  3. * @author kolton
  4. * @desc Universal Baal leecher by Kolton with Autoleader by Ethic
  5. * Pure leech script for throne and Baal
  6. * Reenters throne/chamber upon death and picks the corpse back up
  7. * Make sure you setup safeMsg and baalMsg accordingly
  8. */
  9.  
  10. function AutoBaal() {
  11. // editable variables
  12. var i, baalCheck, throneCheck, hotCheck, leader, suspect, solofail, portal, baal,
  13. // internal variables
  14. safeMsg = ["safe", "throne clear", "leechers can come", "tp is up", "1 clear"], // safe message - casing doesn't matter
  15. baalMsg = ["baal"], // baal message - casing doesn't matter
  16. hotMsg = ["hot", "warm", "dangerous", "lethal"]; // used for shrine hunt
  17.  
  18. // CHAT LISTENER REPLACEMENT
  19. var newChatEvent = function(mode, msg) {
  20. if (mode == 1337) {
  21. var obj = JSON.parse(msg);
  22. if (obj.realm == me.realm && obj.gamename == me.gamename.toLowerCase() && obj.name != me.name) {
  23. //obj.msg
  24. }
  25. }
  26. };
  27. function (nick, msg) { // handler function
  28. var i;
  29.  
  30. if (nick === leader) { // filter leader messages
  31. for (i = 0; i < hotMsg.length; i += 1) { // loop through all predefined messages to find a match
  32. if (msg.toLowerCase().indexOf(hotMsg[i].toLowerCase()) > -1 && Config.AutoBaal.FindShrine === 1) { // leader says a hot tp message
  33. hotCheck = true; // safe to enter baal chamber
  34.  
  35. break;
  36. }
  37. }
  38.  
  39. for (i = 0; i < safeMsg.length; i += 1) { // loop through all predefined messages to find a match
  40. if (msg.toLowerCase().indexOf(safeMsg[i].toLowerCase()) > -1) { // leader says a safe tp message
  41. throneCheck = true; // safe to enter throne
  42.  
  43. break;
  44. }
  45. }
  46.  
  47. for (i = 0; i < baalMsg.length; i += 1) { // loop through all predefined messages to find a match
  48. if (msg.toLowerCase().indexOf(baalMsg[i].toLowerCase()) > -1) { // leader says a baal message
  49. baalCheck = true; // safe to enter baal chamber
  50.  
  51. break;
  52. }
  53. }
  54. }
  55. });
  56.  
  57. // test
  58. this.longRangeSupport = function () {
  59. var monster, monList, index;
  60.  
  61. switch (me.classid) {
  62. case 0:
  63. break;
  64. case 1:
  65. break;
  66. case 2:
  67. ClassAttack.raiseArmy(50);
  68.  
  69. if (Config.Curse[1] > 0) {
  70. monster = getUnit(1);
  71.  
  72. if (monster) {
  73. do {
  74. if (Attack.checkMonster(monster) && getDistance(me, monster) < 50 && !checkCollision(me, monster, 0x4) &&
  75. ClassAttack.isCursable(monster) && !(monster.spectype & 0x7) && !monster.getState(ClassAttack.curseState[1])) {
  76. Skill.cast(Config.Curse[1], 0, monster);
  77. }
  78. } while (monster.getNext());
  79. }
  80. }
  81.  
  82. break;
  83. case 3:
  84. break;
  85. case 4:
  86. break;
  87. case 5:
  88. break;
  89. case 6:
  90. break;
  91. }
  92.  
  93. if ([24, 49, 51, 56, 59, 84, 93, 140, 244].indexOf(Config.AttackSkill[1]) === -1 &&
  94. [24, 49, 51, 56, 59, 84, 93, 140, 244].indexOf(Config.AttackSkill[3]) === -1) {
  95. return false;
  96. }
  97.  
  98. monster = getUnit(1);
  99. monList = [];
  100.  
  101. if (monster) {
  102. do {
  103. if (Attack.checkMonster(monster) && getDistance(me, monster) < 50 && !checkCollision(me, monster, 0x4)) {
  104. monList.push(copyUnit(monster));
  105. }
  106. } while (monster.getNext());
  107. }
  108.  
  109. while (monList.length) {
  110. monList.sort(Sort.units);
  111.  
  112. monster = copyUnit(monList[0]);
  113.  
  114. if (monster && Attack.checkMonster(monster)) {
  115. index = monster.spectype & 0x7 ? 1 : 3;
  116.  
  117. if (Attack.checkResist(monster, Attack.getSkillElement(Config.AttackSkill[index]))) {
  118. if (Config.AttackSkill[index] > -1) {
  119. ClassAttack.doCast(monster, Config.AttackSkill[index], Config.AttackSkill[index + 1]);
  120. }
  121. } else {
  122. monList.shift();
  123. }
  124. } else {
  125. monList.shift();
  126. }
  127.  
  128. delay(5);
  129. }
  130.  
  131. return true;
  132. };
  133.  
  134. function autoLeaderDetect(destination) { // autoleader by Ethic
  135. do {
  136. solofail = 0;
  137. suspect = getParty(); // get party object (players in game)
  138.  
  139. do {
  140. if (suspect.name !== me.name) { // player isn't alone
  141. solofail += 1;
  142. }
  143.  
  144. if (suspect.area === destination) { // first player in our party found in destination area...
  145. leader = suspect.name; // ... is our leader
  146. print("ÿc4AutoBaal: ÿc0Autodetected " + leader);
  147. return true;
  148. }
  149. } while (suspect.getNext());
  150.  
  151. if (solofail === 0) { // empty game, nothing left to do
  152. return false;
  153. }
  154.  
  155. delay(500);
  156. } while (!leader); // repeat until leader is found (or until game is empty)
  157.  
  158. return false;
  159. }
  160.  
  161. if (!Town.goToTown(5)) {
  162. throw new Error("Town.goToTown failed."); // critical error - can't reach harrogath
  163. }
  164.  
  165. if (Config.Leader) {
  166. leader = Config.Leader;
  167.  
  168. for (i = 0; i < 30; i += 1) {
  169. if (Misc.inMyParty(leader)) {
  170. break;
  171. }
  172.  
  173. delay(1000);
  174. }
  175.  
  176. if (i === 30) {
  177. throw new Error("Autobaal: Leader not partied");
  178. }
  179. }
  180.  
  181. if (Config.AutoBaal.FindShrine === 2) {
  182. hotCheck = true;
  183. }
  184.  
  185. Town.doChores();
  186. Town.move("portalspot");
  187.  
  188. if (leader || autoLeaderDetect(131)) { // find the first player in area 131 - throne of destruction
  189. while (Misc.inMyParty(leader)) { // do our stuff while partied
  190. if (hotCheck) {
  191. Pather.useWaypoint(4);
  192. Precast.doPrecast(true);
  193.  
  194. for (i = 4; i > 1; i -= 1) {
  195. if (Misc.getShrinesInArea(i, 15, true)) {
  196. break;
  197. }
  198. }
  199.  
  200. if (i === 1) {
  201. Town.goToTown();
  202. Pather.useWaypoint(5);
  203.  
  204. for (i = 5; i < 8; i += 1) {
  205. if (Misc.getShrinesInArea(i, 15, true)) {
  206. break;
  207. }
  208. }
  209. }
  210.  
  211. Town.goToTown(5);
  212. Town.move("portalspot");
  213.  
  214. hotCheck = false;
  215. }
  216.  
  217. if (throneCheck && me.area === 109) { // wait for throne signal - leader's safe message
  218. print("ÿc4AutoBaal: ÿc0Trying to take TP to throne.");
  219. Pather.usePortal(131, null); // take TP to throne
  220. Pather.moveTo(Config.AutoBaal.LeechSpot[0], Config.AutoBaal.LeechSpot[1]); // move to a safe spot
  221. Precast.doPrecast(true);
  222. Town.getCorpse(); // check for corpse - happens if you die and reenter
  223. }
  224.  
  225. if (!baalCheck && me.area === 131 && Config.AutoBaal.LongRangeSupport) {
  226. this.longRangeSupport();
  227. }
  228.  
  229. if (baalCheck && me.area === 131) { // wait for baal signal - leader's baal message
  230. Pather.moveTo(15092, 5010); // move closer to chamber portal
  231. Precast.doPrecast(false);
  232.  
  233. while (getUnit(1, 543)) { // wait for baal to go through the portal
  234. delay(500);
  235. }
  236.  
  237. portal = getUnit(2, 563);
  238.  
  239. if (Config.AutoBaal.KillBaal) {
  240. delay(500);
  241. }
  242. else {
  243. try { getScript("tools/party.js").stop() } catch (error) {}; // stop party thread to avoid getting in party again
  244. clickParty(getParty(), 3); // leave party
  245. Town.goToTown();
  246. delay(40000);
  247.  
  248. }
  249.  
  250. delay(2000); // wait for others to enter first - helps with curses and tentacles from spawning around you
  251. print("ÿc4AutoBaal: ÿc0Entering chamber.");
  252.  
  253. if (Pather.usePortal(null, null, portal)) { // enter chamber
  254. Pather.moveTo(15166, 5903);
  255. delay(40000);// go to a safe position
  256. }
  257.  
  258. Town.getCorpse(); // check for corpse - happens if you die and reenter
  259. }
  260.  
  261. baal = getUnit(1, 544);
  262.  
  263. if (baal) {
  264. if (baal.mode === 0 || baal.mode === 12) {
  265. break;
  266. }
  267.  
  268. this.longRangeSupport();
  269. }
  270.  
  271. if (me.mode === 17) { // death check
  272. me.revive(); // revive if dead
  273. }
  274.  
  275. delay(500);
  276. }
  277. } else {
  278. throw new Error("Empty game.");
  279. }
  280.  
  281. return true;
  282. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement