Advertisement
kolton

Untitled

Oct 31st, 2011
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*  
  2.     Universal Baal leecher by Kolton with Autoleader by Ethic
  3.     Pure leech script for throne and Baal
  4.     Reenters throne/chamber upon death and picks the corpse back up
  5.     Make sure you setup safeMsg and baalMsg accordingly
  6. */
  7.  
  8. function NT_AutoBaal() {
  9.     // editable variables
  10.     var safeMsg = ["safe", "throne clear", "leechers can come", "tp is up", "1 clear"], // safe message - casing doesn't matter
  11.         baalMsg = ["baal"], // baal message - casing doesn't matter
  12.     // internal variables
  13.         i, baalCheck, throneCheck, leader, suspect, solofail, portal;
  14.        
  15.     addEventListener('chatmsg', // chat event, listen to what leader says
  16.         function (nick, msg) { // handler function
  17.             if (nick === leader) { // filter leader messages
  18.                 for (i = 0; i < safeMsg.length; i = i + 1) { // loop through all predefined messages to find a match
  19.                     if (msg.toLowerCase().indexOf(safeMsg[i]) > -1) { // leader says a safe message
  20.                         throneCheck = true; // safe to enter throne
  21.                         break;
  22.                     }
  23.                 }
  24.                
  25.                 for (i = 0; i < baalMsg.length; i = i + 1) { // loop through all predefined messages to find a match
  26.                     if (msg.toLowerCase().indexOf(baalMsg[i]) > -1) { // leader says a baal message
  27.                         baalCheck = true; // safe to enter baal chamber
  28.                         break;
  29.                     }
  30.                 }
  31.             }
  32.         }
  33.     );
  34.    
  35.     function AutoLeaderDetect(destination) { // autoleader by Ethic
  36.         do {
  37.             solofail = 0;
  38.             suspect = getParty(); // get party object (players in game)
  39.            
  40.             do {
  41.                 if (suspect.name !== me.name) { // player isn't alone
  42.                     solofail = solofail + 1;
  43.                 }
  44.                
  45.                 if (suspect.area === destination) { // first player in our party found in destination area...
  46.                     leader = suspect.name; // ... is our leader
  47.                     print("ÿc4AutoBaal: ÿc0Autodetected " + leader);
  48.                     return true;
  49.                 }
  50.             } while (suspect.getNext());
  51.  
  52.             if (solofail === 0) { // empty game, nothing left to do
  53.                 return false;
  54.             }
  55.            
  56.             NTC_Delay(500);
  57.         } while (!leader); // repeat until leader is found (or until game is empty)
  58.        
  59.         return false;
  60.     }
  61.    
  62.     // shrine hunter add-on
  63.     FindXPShrine();
  64.    
  65.     if (!NTTM_CheckAct(5)) {
  66.         throw new Error("NTTM_CheckAct failed."); // critical error - can't reach harrogath
  67.     }
  68.    
  69.     NTTMGR_TownManager();
  70.     NTTM_TownMove("portalspot");
  71.    
  72.     if (AutoLeaderDetect(131)) { // find the first player in area 131 - throne of destruction
  73.         while (NTC_InMyParty(leader)) { // do our stuff while partied
  74.             if (throneCheck && me.area === 109) { // wait for throne signal - leader's safe message
  75.                 print("ÿc4AutoBaal: ÿc0Trying to take TP to throne.");
  76.                 NTM_UsePortal("BluePortal", 131, leader); // take TP to throne
  77.                 NTC_Delay(500);
  78.                 NTM_MoveTo(15113, 5050); // move to a safe spot
  79.                 NTP_DoPrecast(true);
  80.                 NTT_GetCorpses(); // check for corpse - happens if you die and reenter
  81.             }
  82.            
  83.             if (baalCheck && me.area === 131) { // wait for baal signal - leader's baal message
  84.                 NTM_MoveTo(15092, 5010); // move closer to chamber portal
  85.                 NTP_DoPrecast(true);
  86.                
  87.                 while (NTC_GetUnit(NTC_UNIT_MONSTER, 543)) { // wait for baal to go through the portal
  88.                     NTC_Delay(500);
  89.                 }
  90.                
  91.                 portal = NTC_GetUnit(NTC_UNIT_OBJECT, 563);
  92.                
  93.                 NTC_Delay(5000); // wait for others to enter first - helps  with curses and tentacles from spawning around you
  94.                 print("ÿc4AutoBaal: ÿc0Entering chamber.");
  95.                
  96.                 if (NTM_UsePortal("Portal", 132, null, portal)) { // enter chamber
  97.                     NTM_MoveTo(15166, 5903); // go to a safe position
  98.                 }
  99.                
  100.                 NTT_GetCorpses(); // check for corpse - happens if you die and reenter
  101.             }
  102.            
  103.             if (me.mode === 0 || me.mode === 17) { // death check
  104.                 NTC_Delay(1500);
  105.                 me.revive(); // revive if dead
  106.             }
  107.            
  108.             NTC_Delay(500);
  109.         }
  110.     } else {
  111.         throw new Error("Empty game.");
  112.     }
  113.    
  114.     return true;
  115. }
  116.  
  117. // shrine hunter functions
  118.  
  119. function FindXPShrine() {
  120.     if (!NTTM_TownMove("waypoint")) {
  121.         return false;
  122.     }
  123.    
  124.     if (!NTM_UsePortal("Waypoint", 4)) {
  125.         return false;
  126.     }
  127.    
  128.     if (!FindShrines(4)) {
  129.         if (!FindShrines(3)) {
  130.             if (!FindShrines(2)) {
  131.                 NTTM_CheckAct();
  132.                 me.overhead("No XP shrines :(");
  133.                
  134.                 return true;
  135.             }
  136.         }
  137.     }
  138.    
  139.     me.overhead("Shrine found!");
  140.    
  141.     return true;
  142. }
  143.  
  144. function FindShrines(area) {
  145.     var i, n, room, shrine,
  146.         ShrineIds = [2, 81, 83],
  147.         ShrineLocs = [],
  148.         unit = getPresetUnits(area);
  149.        
  150.     if (unit) {
  151.         for (i = 0; i < unit.length; i += 1) {
  152.             for (n = 0; n < ShrineIds.length; n = n + 1) {
  153.                 if (ShrineIds[n] === unit[i].id) {
  154.                     ShrineLocs.push([unit[i].roomx * 5 + unit[i].x, unit[i].roomy * 5 + unit[i].y]);
  155.                 }
  156.             }
  157.         }
  158.     }
  159.    
  160.     while (ShrineLocs.length > 0) {
  161.         ShrineLocs.sort(Sort);
  162.        
  163.         room = ShrineLocs.shift();
  164.        
  165.         NTM_MoveTo(room[0] + 3, room[1]);
  166.        
  167.         shrine = NTC_GetUnit(NTC_UNIT_OBJECT);
  168.        
  169.         if (shrine) {
  170.             do {
  171.                 if (shrine.objtype === 15 && getDistance(me, shrine) <= 10) {
  172.                     for (i = 0; i < 30; i += 1) {
  173.                         if (i % 10 === 0 && NTM_GetCloserInt(shrine)) {
  174.                             shrine.interact()
  175.                         }
  176.                        
  177.                         NTC_Delay(200);
  178.                        
  179.                         if (shrine.mode) {
  180.                             NTTM_CheckAct();
  181.                            
  182.                             return true;
  183.                         }
  184.                     }
  185.                 }
  186.             } while (shrine.getNext());
  187.         }
  188.     }
  189.    
  190.     return false;
  191. }
  192.    
  193. function Sort (a, b) {
  194.     return (getDistance(me.x, me.y, a[0], a[1]) - getDistance(me.x, me.y, b[0], b[1]));
  195. }
  196.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement