Advertisement
kolton

Untitled

Oct 31st, 2011
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     ShrineHunter by kolton for d2bs with NTBot libs
  3.     Based on bobode's 'open chests in area' function
  4.     Searches for exp shrine in Stony Field, Cold Plains and Blood Moor
  5.     Requires Stony Field waypoint.
  6. */
  7.  
  8. function NT_ShrineHunter() {
  9.     print("ΓΏc3Running Shrine Hunter");
  10.    
  11.     NTTMGR_TownManager();
  12.    
  13.     if (!NTTM_TownMove("waypoint")) {
  14.         throw new Error("Town move failed.");
  15.     }
  16.    
  17.     if (!NTM_UsePortal("Waypoint", 4)) {
  18.         throw new Error("Failed to take WP.");
  19.     }
  20.    
  21.     if (!FindShrines(4)) {
  22.         if (!FindShrines(3)) {
  23.             if (!FindShrines(2)) {
  24.                 NTTM_CheckAct();
  25.                 me.overhead("No XP shrines :(");
  26.                
  27.                 return true;
  28.             }
  29.         }
  30.     }
  31.    
  32.     me.overhead("Shrine found!");
  33.    
  34.     return true;
  35. }
  36.  
  37. function FindShrines(area) {
  38.     var i, n, room, shrine,
  39.         ShrineIds = [2, 81, 83],
  40.         ShrineLocs = [],
  41.         unit = getPresetUnits(area);
  42.        
  43.     if (unit) {
  44.         for (i = 0; i < unit.length; i += 1) {
  45.             for (n = 0; n < ShrineIds.length; n = n + 1) {
  46.                 if (ShrineIds[n] === unit[i].id) {
  47.                     ShrineLocs.push([unit[i].roomx * 5 + unit[i].x, unit[i].roomy * 5 + unit[i].y]);
  48.                 }
  49.             }
  50.         }
  51.     }
  52.    
  53.     while (ShrineLocs.length > 0) {
  54.         ShrineLocs.sort(Sort);
  55.        
  56.         room = ShrineLocs.shift();
  57.        
  58.         NTM_MoveTo(room[0] + 3, room[1]);
  59.        
  60.         shrine = NTC_GetUnit(NTC_UNIT_OBJECT);
  61.        
  62.         if (shrine) {
  63.             do {
  64.                 if (shrine.objtype === 15 && getDistance(me, shrine) <= 10) {
  65.                     for (i = 0; i < 30; i += 1) {
  66.                         if (i % 10 === 0 && NTM_GetCloserInt(shrine)) {
  67.                             shrine.interact()
  68.                         }
  69.                        
  70.                         NTC_Delay(200);
  71.                        
  72.                         if (shrine.mode) {
  73.                             NTTM_CheckAct();
  74.                            
  75.                             return true;
  76.                         }
  77.                     }
  78.                 }
  79.             } while (shrine.getNext());
  80.         }
  81.     }
  82.    
  83.     return false;
  84. }
  85.    
  86. function Sort (a, b) {
  87.     return (getDistance(me.x, me.y, a[0], a[1]) - getDistance(me.x, me.y, b[0], b[1]));
  88. }
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement