OFFR500

AutoBaalStop.js

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