Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 8.63 KB | None | 0 0
  1. // Leech Baal Bot v1.5 written by ImprisonedPride for D2BS with 1.4 core.
  2.  
  3. function NT_LeechBaal() {
  4.  
  5.     if(Unit_findItemByFname("Ondal's Wisdom")) {            // REVISION 1.5: Switch to Primary Weapon on-switch (in tab 1)
  6.         NTC_DoWeaponSwitch(0);
  7.     }
  8.  
  9.     print("ÿc1Starting Baal-Leech Script");
  10.     // Hopefully this top section is self-explanatory. It's the way most leech-bots start. TownManager(), then find leader.
  11.  
  12.     var _leader=NT_Leader[0];                               // REVISION 1.2: Was setting leader = NT_Leader which is an array
  13.                                                                 // and caused the bot to leave the game immediately 99%
  14.                                                                 // of the time.
  15.     var _helpPreClear = NTConfig_HelpPreClear;              // REVISION 1.4: This settings makes bot skip 10 second delay after portal and clear the area
  16.                                                                 // before the first wave (if leader is having trouble with souls, set true).   
  17.     var _helpWithWaves = NTConfig_HelpWithWaves;            // REVISION 1.1: Set true to help kill the waves. False to leech behind pillars.
  18.                                                                 // Should be defined in NTConfig.dbl and assigned in char config.
  19.     var _helpWithBaal = NTConfig_HelpWithBaal;              // REVISION 1.1: Set true to help kill Baal. False to leech outside of moat.
  20.                                                                 // Same as above.
  21.     var _getBaalItems = NTConfig_GetBaalItems;              // REVISION 1.1: Set true to jump to Baal's location for items.
  22.                                                                 // You know the drill.
  23.                                                                 // NOTE: There's usually nothing left by the time you get there, though.
  24.     var _clearLeechPosition = NTConfig_ClearLeechPosition;  // REVISION 1.2: Added so that low levels don't attack monsters.
  25.                                                                 // Updates at Line 60 and Line 102.
  26.    
  27.     var _wave = 0;                                          // REVISION 1.3: Added because instead of checking for leader, we check the wave number.
  28.    
  29.  
  30.  
  31.     if(!NTTM_CheckAct()) return false;
  32.  
  33.     print("ÿc2Shopping...");
  34.  
  35.     NTTMGR_TownManager();
  36.  
  37.     print("ÿc2...shopping is complete.");
  38.    
  39.     if(me.area!=109) {
  40.         print("ÿc2Heading to Harrogath...");
  41.         NTTM_TownMove("waypoint");
  42.         while(me.area != 109) {
  43.             NTM_UsePortal("Waypoint", 109);
  44.             delay(1000);
  45.         }
  46.     }
  47.  
  48.     if(!NTTM_TownMove("portalspot")) {
  49.         print("ÿc8Error: PortalSpot is not found.");
  50.         return false;
  51.     }
  52.    
  53.     for(var i = 0; i < 100; i++) {
  54.         if(findLead(_leader)) break;
  55.         for( var j = 0; j < NT_Leader.length; j++) {
  56.             if(findLead(NT_Leader[j])) _leader = NT_Leader[j];
  57.         }
  58.         delay(100);
  59.     }
  60.  
  61.     QuitWithLeader = _leader;
  62.     while(me.area==109) {
  63.         NTM_UsePortal("BluePortal", 131, _leader);
  64.         delay(1000);
  65.         if(!findLead(_leader)) return false;
  66.     }
  67.    
  68.     print("ÿc2Waiting for Throne of Destruction to be cleared...");
  69.     NTP_DoPrecast();                                    // REVISION 1.3: Precast (for example, Holy Shield for paladins for extra def while leeching)
  70.                                                             // Also done after entering Worldstone Chamber
  71.     if(_clearLeechPosition) NTA_ClearPosition(10);
  72.     if(!_helpPreClear) {                                // REVISION 1.4: If leader has trouble with souls, don't wait and help kill them.
  73.         delay(10000);                                   // REVISION 1.1: Dispite this large delay, this prevents players from getting killed by
  74.                                                         // souls by staying in the corner while the leader kills them.
  75.         NTM_MoveTo(me.x-2, me.y-2, 5, false);           // REVISION 1.1: Fixes the candle glitch where players get stuck.
  76.     } else {
  77.         NTA_ClearPosition(50);
  78.     }
  79.     delay(500);
  80.     NTM_MoveTo(15113, 5037, 5, false);                  // Move to third Pillar. Second pillar is X:15113 Y:5037   
  81.                                                                               // Third pillar is X:15112 Y:5052
  82.                                                                              
  83.     if(Unit_findItemByFname("Ondal's Wisdom")) {        // REVISION 1.5: Switch to Ondal's Weapon on-switch (in tab 2)
  84.         NTC_DoWeaponSwitch(1);
  85.     }
  86.    
  87.     while (1) {                                         // REVISION 1.3: Remain at leech position until baal has passed through the red portal.
  88.         if(_clearLeechPosition) NTA_ClearPosition(10);      // REVISION 1.3: If not low-level, clear any stray monsters
  89.         if(_helpWithWaves) {                                // REVISOIN 1.3: If we want to help with waves... will clear entire throne room.
  90.             NTA_ClearPosition(40);
  91.             NTSI_PickItems();
  92.             NTM_MoveTo(15113, 5037, 5, false);
  93.         }
  94.         NTT_CleanPotions();                                 // REVISION 1.3: check your potions
  95.        
  96.         _wave = NT_ThroneCheckInt();                        // REVISION 1.3: get the current wave index
  97.        
  98.         if (_wave == 5) break;                              // REVISION 1.3: If Minion wave is going, stop waiting
  99.        
  100.         delay(1000);                                        // REVISION 1.3: Check position/wave delay
  101.     }
  102.     while(NT_ThroneCheckInt() == 5) delay(100);             // REVISION 1.3: If Minion wave is still going, wait
  103.     print("ÿc2Throne of Destruction clear. Moving to Worldstone Chamber...");
  104.     NTM_MoveTo(15092, 5010);
  105.     NTP_DoPrecast();                                        // REVISION 1.3: Precast while waiting for baal to move his fat ass
  106.     while (NTC_FindMonster(getLocaleString(3061)))          // REVISION 1.3: Wait for baal-clone to take the red portal
  107.         NTC_Delay(250);
  108.    
  109.     var _portal = NTC_GetUnit(NTC_UNIT_OBJECT, 563);    // REVISION 1.3: After baal leaves, find the red portal
  110.  
  111.     if (!_portal) return false;                         // Couldn't find the portal.
  112.  
  113.     if (!NTM_UsePortal("Portal", 132, null, _portal)) return false; // Found the portal but couldn't use it.
  114.  
  115.     print("ÿc2Entering Worldstone Chamber. Waiting for Baal to die...");
  116.     //delay(1000);
  117.     //NTP_DoPrecast();
  118.     if (!_helpWithBaal) {
  119.         print("ÿc2...I'll just stay right here.");
  120.         NTM_MoveTo(15166, 5923, 5, false); 
  121.         while(withLeader(_leader)) {                            // Wait until the leader isn't there (usually they left game).
  122.             if(_clearLeechPosition) NTA_ClearPosition(10);      // Clear our position in the case of tentacles.
  123.             if(getDistance(me.x, me.y, 15166, 5923)>5) NTM_MoveTo(15166, 5923, 5, false);   // See explanation at line 63.
  124.             delay(1000);
  125.         }
  126.     } else {
  127.         print("ÿc2...I'd rather kill him myself.");
  128.         NTM_MoveTo(15138, 5916);                                // Move to the moat.
  129.         if (!NTA_KillBoss(getLocaleString(3061))) return false; // Kill Baal.
  130.         print("ÿc2\\o/ BAAL IS DEAD! \\o/");
  131.         NTSI_PickItems();
  132.     }
  133.     return true;
  134. }
  135.  
  136. function NT_ThroneCheckInt() {
  137.     var _monster;
  138.  
  139.     if (!NTC_FindMonster(getLocaleString(3061))) return 5;
  140.  
  141.     _monster = NTC_GetUnit(NTC_UNIT_MONSTER);
  142.  
  143.     if (_monster) {
  144.         do {
  145.             if (NTA_IsValidTarget(_monster)) {
  146.                 if (_monster.classid == 23 || _monster.classid == 62) return 1;
  147.  
  148.                 if (_monster.classid == 105 || _monster.classid == 381) return 2;
  149.  
  150.                 if (_monster.classid == 557) return 3;
  151.  
  152.                 if (_monster.classid == 558) return 4;
  153.  
  154.                 if (_monster.classid == 571) return 5;
  155.             }
  156.         } while (_monster.getNext());
  157.     }
  158.  
  159.     return 0;
  160. }
  161.  
  162. function withLeader(leader) {   // Check if the leader is with us or in town.
  163.     var party = getParty();
  164.     if (!party) return false;
  165.     do {
  166.         if (party.name==leader) {
  167.             return (me.area == party.area || party.area == 108);
  168.         }
  169.     } while (party.getNext());
  170.     return false;
  171. }
  172.  
  173. function findLead(leader) {     // Check if the leader in bot config is present in the game.
  174.     var _lead = getUnit(0, leader);
  175.         if(_lead) return _lead.area;
  176.     // leader not found look in party
  177.     var area =0;
  178.     var a = getParty();
  179.     if(!a) return false;
  180.     do {
  181.         if (a.name==leader){
  182.             return (a.area >0 )? a.area :true;
  183.         }
  184.     } while(a.getNext());
  185.     if (area==0) {
  186.         //sendCopyData(null, "OOG", 0,"Quit:Quit()" );
  187.         return false;
  188.     }
  189. return area;
  190. }
  191.  
  192. function LeaveWithLeader(mode, param,name1,name2){  //event is called from default
  193.     if (QuitWithLeader == name2 && (mode == 0 || mode == 1 || mode == 3)){
  194.         if(_getBaalItems) {
  195.             NTM_MoveTo(15138, 5916); // Move to the moat.
  196.             NTSI_PickItems();
  197.         }
  198.         quit();
  199.     }
  200. }
  201.  
  202. function Unit_findItemByFname(_fname)
  203. {
  204.     //This item search function will only find the FIRST matching result of _fname string argument in any UNIT.fname and return the UNIT Object that caused the RegEx match;
  205.  
  206.     var _unitItem;
  207.  
  208.     //check for correct input; to make sure it exists and make sure it is a string;
  209.     if((arguments.length < 1) || (typeof(_fname) != "string")) return false;
  210.    
  211.     var myItems = me.getItems();    //get all items owned by char (Unit objects in inventory, cube, stash, on body, and merc's body) and put in array myItems;
  212.            
  213.     for(var item_num = 0; item_num < myItems.length; item_num++)    //loop through all items in array;
  214.     {
  215.         //print("Testing item index "+ item_num); //TESTING PURPOSE: used to watch progress in console;
  216.  
  217.         if((RegExp(_fname,"ig").test(myItems[item_num].fname))) //test if current item unit object in myItems array matches function input in item's fname attribute;
  218.         {
  219.             //found match;
  220.             //storing Unit to var _unitItem;
  221.             _unitItem = myItems[item_num];
  222.             //print("Found match for \""+_fname+"\", at location: "+_unitItem.location);    //TESTING PURPOSE: used to watch progress in console;
  223.             return _unitItem;   //returning _unitItem Unit object to caller function;
  224.         }
  225.     }
  226.    
  227.     //print("No match found for \""+_fname+"\"");
  228.     return false;
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement