mf22

BoBarbHelper

Jul 2nd, 2018
4,987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. *   @filename   BoBarbHelper.js
  3. *   @author     nag0k
  4. *   @desc       give Battle Orders buff modded for hardcore, with barbarian waiting whole game on Catacombs 2 wp by default
  5. */
  6.  
  7. const BoBarbHelper = () => {
  8.     if (Config.BoBarbHelper.Mode !== 0) {
  9.         return true;
  10.     }
  11.  
  12.     const townNearbyMonster = true; // go to town if monsters nearby
  13.     const townLowMana = 20; // go refill mana if mana drops below this percent
  14.  
  15.     const shouldHealMana = amount => me.mp < Math.floor(me.mpmax * amount / 100)
  16.  
  17.     const healMana = () => {
  18.         Pather.useWaypoint(1);
  19.         Town.initNPC("Heal", "heal");
  20.         Pather.useWaypoint(Config.BoBarbHelper.Wp);
  21.     };
  22.  
  23.     const shouldBuff = unit => (
  24.         Misc.inMyParty(unit) &&
  25.         getDistance(me, unit) < 10 &&
  26.         unit.name !== me.name &&
  27.         !unit.dead &&
  28.         !unit.inTown
  29.     )  
  30.  
  31.     const giveBuff = () => {
  32.         const unit = getUnit(0);
  33.  
  34.         do {
  35.             if (shouldBuff(unit)) {
  36.                 Precast.doPrecast(true);
  37.                 delay(50);
  38.             }
  39.         } while(unit.getNext());
  40.     };
  41.  
  42.     const monsterNear = () => {
  43.         const unit = getUnit(1);
  44.  
  45.         if (unit) {
  46.             do {
  47.                 if (Attack.checkMonster(unit) && getDistance(me, unit) < 20) {
  48.                     return true;
  49.                 }
  50.             } while(unit.getNext());
  51.         }
  52.  
  53.         return false;
  54.     };
  55.  
  56.     if (!Config.QuitList) {
  57.         showConsole();
  58.         print('set Config.QuitList in character settings');
  59.         print('if you don\'t I will idle indefinitely');
  60.     }
  61.  
  62.     if (me.playertype == 1 && Config.LifeChicken <= 0) {
  63.         showConsole();
  64.         print('on HARDCORE');
  65.         print('you should set Config.LifeChicken');
  66.         print('monsters can find their way to wps ...');
  67.         delay(2000);
  68.         hideConsole();
  69.         me.overhead('set LifeChiken to 40');
  70.         Config.LifeChicken = 40;
  71.     }
  72.  
  73.     if (shouldHealMana(townLowMana)) {
  74.         Town.initNPC("Heal", "heal");
  75.     }
  76.  
  77.     Town.heal(); // in case our life is low as well
  78.    
  79.     try {
  80.         Pather.useWaypoint(Config.BoBarbHelper.Wp);
  81.     } catch (e) {
  82.         showConsole();
  83.         print('Failed to move to BO WP');
  84.         print('make sure I have ' + Pather.getAreaName(Config.BoBarbHelper.Wp) + ' waypoint');
  85.         delay(20000);
  86.  
  87.         return true;
  88.     }
  89.  
  90.     Pather.moveTo(me.x + 4, me.y + 4);
  91.  
  92.     while (true) {
  93.         giveBuff();
  94.  
  95.         if (townNearbyMonster && monsterNear()) {
  96.             if (!Pather.useWaypoint(1)) {
  97.                 break;
  98.             }
  99.         }
  100.  
  101.         if (shouldHealMana(townLowMana)) {
  102.             healMana();
  103.         }
  104.  
  105.         delay(25);
  106.     }
  107.  
  108.     Town.goToTown();
  109.  
  110.     return true;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment