mf22

Baal

Jun 30th, 2018
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *  @filename   Baal.js
  3.  *  @author     kolton, modified by YGM
  4.  *  @desc       clear Throne of Destruction and kill Baal + hdin add-on for wave 2
  5.  */
  6.  
  7. function Baal() {
  8.     var portal, tick;
  9.  
  10.     this.preattack = function () {
  11.         var check;
  12.  
  13.         switch (me.classid) {
  14.         case 1: // Sorceress
  15.             switch (Config.AttackSkill[3]) {
  16.             case 49:
  17.             case 53:
  18.             case 56:
  19.             case 59:
  20.             case 64:
  21.                 if (me.getState(121)) {
  22.                     while (me.getState(121)) {
  23.                         delay(100);
  24.                     }
  25.                 } else {
  26.                     return Skill.cast(Config.AttackSkill[1], 0, 15094 + rand(-1, 1), 5028);
  27.                 }
  28.  
  29.                 break;
  30.             }
  31.  
  32.             break;
  33.         case 3: // Paladin
  34.             if (Config.AttackSkill[3] === 112) {
  35.                 if (Config.AttackSkill[4] > 0) {
  36.                     Skill.setSkill(Config.AttackSkill[4], 0);
  37.                 }
  38.  
  39.                 return Skill.cast(Config.AttackSkill[3], 1);
  40.             }
  41.  
  42.             break;
  43.         case 5: // Druid
  44.             if (Config.AttackSkill[3] === 245) {
  45.                 return Skill.cast(Config.AttackSkill[3], 0, 15094 + rand(-1, 1), 5028);
  46.             }
  47.  
  48.             break;
  49.         case 6: // Assassin
  50.             if (Config.UseTraps) {
  51.                 check = ClassAttack.checkTraps({x: 15094, y: 5028});
  52.  
  53.                 if (check) {
  54.                     return ClassAttack.placeTraps({x: 15094, y: 5028}, 5);
  55.                 }
  56.             }
  57.  
  58.             if (Config.AttackSkill[3] === 256) { // shock-web
  59.                 return Skill.cast(Config.AttackSkill[3], 0, 15094, 5028);
  60.             }
  61.  
  62.             break;
  63.         }
  64.  
  65.         return false;
  66.     };
  67.  
  68.     this.checkThrone = function () {
  69.         var monster = getUnit(1);
  70.  
  71.         if (monster) {
  72.             do {
  73.                 if (Attack.checkMonster(monster) && monster.y < 5080) {
  74.                     switch (monster.classid) {
  75.                     case 23:
  76.                     case 62:
  77.                         return 1;
  78.                     case 105:
  79.                     case 381:
  80.                         return 2;
  81.                     case 557:
  82.                         return 3;
  83.                     case 558:
  84.                         return 4;
  85.                     case 571:
  86.                         return 5;
  87.                     default:
  88.                         Attack.getIntoPosition(monster, 10, 0x4);
  89.                         Attack.clear(15);
  90.  
  91.                         return false;
  92.                     }
  93.                 }
  94.             } while (monster.getNext());
  95.         }
  96.  
  97.         return false;
  98.     };
  99.  
  100.     this.clearThrone = function () {
  101.         var i, monster,
  102.             monList = [],
  103.             pos = [15094, 5022, 15094, 5041, 15094, 5060, 15094, 5041, 15094, 5022];
  104.  
  105.         if (Config.AvoidDolls) {
  106.             monster = getUnit(1, 691);
  107.  
  108.             if (monster) {
  109.                 do {
  110.                     if (monster.x >= 15072 && monster.x <= 15118 && monster.y >= 5002 && monster.y <= 5079 && Attack.checkMonster(monster) && Attack.skipCheck(monster)) {
  111.                         monList.push(copyUnit(monster));
  112.                     }
  113.                 } while (monster.getNext());
  114.             }
  115.  
  116.             if (monList.length) {
  117.                 Attack.clearList(monList);
  118.             }
  119.         }
  120.  
  121.         for (i = 0; i < pos.length; i += 2) {
  122.             Pather.moveTo(pos[i], pos[i + 1]);
  123.             Attack.clear(25);
  124.         }
  125.     };
  126.  
  127.     this.hdinWaveTwo = function () { // wave 2 hdin alternative to Nature's Peace ring
  128.         if (me.classid != 3 && Config.AttackSkill[3] != 112) {
  129.             return false;
  130.         }
  131.         Skill.setSkill(113, 0);
  132.         delay(1500);
  133.         Skill.setSkill(124, 0);
  134.         delay(3000);
  135.  
  136.         return true;
  137.     };
  138.  
  139.     this.checkHydra = function () {
  140.         var hydra = getUnit(1, getLocaleString(3325));
  141.         if (hydra) {
  142.             do {
  143.                 if (hydra.mode !== 12 && hydra.getStat(172) !== 2) {
  144.                     Pather.moveTo(15072, 5002);
  145.                     while (hydra.mode !== 12) {
  146.                         delay(500);
  147.                         if (!copyUnit(hydra).x) {
  148.                             break;
  149.                         }
  150.                     }
  151.  
  152.                     break;
  153.                 }
  154.             } while (hydra.getNext());
  155.         }
  156.  
  157.         return true;
  158.     };
  159.  
  160.     this.announce = function () {
  161.         var count, string, souls, dolls,
  162.             monster = getUnit(1);
  163.  
  164.         if (monster) {
  165.             count = 0;
  166.  
  167.             do {
  168.                 if (Attack.checkMonster(monster) && monster.y < 5094) {
  169.                     if (getDistance(me, monster) <= 40) {
  170.                         count += 1;
  171.                     }
  172.  
  173.                     if (!souls && monster.classid === 641) {
  174.                         souls = true;
  175.                     }
  176.  
  177.                     if (!dolls && monster.classid === 691) {
  178.                         dolls = true;
  179.                     }
  180.                 }
  181.             } while (monster.getNext());
  182.         }
  183.  
  184.         if (count > 30) {
  185.             string = "DEADLY!!!" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  186.         } else if (count > 20) {
  187.             string = "Lethal!" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  188.         } else if (count > 10) {
  189.             string = "Dangerous!" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  190.         } else if (count > 0) {
  191.             string = "Warm" + " " + count + " monster" + (count > 1 ? "s " : " ") + "nearby.";
  192.         } else {
  193.             string = "Cool TP. No immediate monsters.";
  194.         }
  195.  
  196.         if (souls) {
  197.             string += " Souls ";
  198.  
  199.             if (dolls) {
  200.                 string += "and Dolls ";
  201.             }
  202.  
  203.             string += "in area.";
  204.         } else if (dolls) {
  205.             string += " Dolls in area.";
  206.         }
  207.  
  208.         say(string);
  209.     };
  210.  
  211.     Town.doChores();
  212.     Pather.useWaypoint(Config.RandomPrecast ? "random" : 129);
  213.     Precast.doPrecast(true);
  214.  
  215.     if (me.area !== 129) {
  216.         Pather.useWaypoint(129);
  217.     }
  218.  
  219.     if (!Pather.moveToExit([130, 131], true)) {
  220.         throw new Error("Failed to move to Throne of Destruction.");
  221.     }
  222.  
  223.     Pather.moveTo(15095, 5029);
  224.  
  225.     if (Config.Baal.DollQuit && getUnit(1, 691)) {
  226.         say("Dolls found! NG.");
  227.  
  228.         return true;
  229.     }
  230.  
  231.     if (Config.Baal.SoulQuit && getUnit(1, 641)) {
  232.         say("Souls found! NG.");
  233.  
  234.         return true;
  235.     }
  236.  
  237.     if (Config.PublicMode) {
  238.         this.announce();
  239.         Pather.moveTo(15118, 5002);
  240.         Pather.makePortal();
  241.         say(Config.Baal.HotTPMessage);
  242.         Attack.clear(15);
  243.     }
  244.  
  245.     this.clearThrone();
  246.  
  247.     if (Config.PublicMode) {
  248.         Pather.moveTo(15118, 5045);
  249.         Pather.makePortal();
  250.         say(Config.Baal.SafeTPMessage);
  251.         Precast.doPrecast(true);
  252.     }
  253.  
  254.     tick = getTickCount();
  255.  
  256.     Pather.moveTo(15094, me.classid === 3 ? 5029 : 5038);
  257.  
  258. MainLoop:
  259.     while (true) {
  260.         if (getDistance(me, 15094, me.classid === 3 ? 5029 : 5038) > 3) {
  261.             Pather.moveTo(15094, me.classid === 3 ? 5029 : 5038);
  262.         }
  263.  
  264.         if (!getUnit(1, 543)) {
  265.             break MainLoop;
  266.         }
  267.  
  268.         switch (this.checkThrone()) {
  269.         case 1:
  270.             Attack.clear(40);
  271.  
  272.             tick = getTickCount();
  273.  
  274.             Precast.doPrecast(true);
  275.  
  276.             break;
  277.         case 2:
  278.             this.hdinWaveTwo(); // comment this line if your char has a Nature's Peace ring
  279.  
  280.             Attack.clear(40);
  281.  
  282.             tick = getTickCount();
  283.  
  284.             break;
  285.         case 4:
  286.             Attack.clear(40);
  287.  
  288.             tick = getTickCount();
  289.  
  290.             break;
  291.         case 3:
  292.             Attack.clear(40);
  293.             this.checkHydra();
  294.  
  295.             tick = getTickCount();
  296.  
  297.             break;
  298.         case 5:
  299.             Attack.clear(40);
  300.  
  301.             break MainLoop;
  302.         default:
  303.             if (getTickCount() - tick < 7e3) {
  304.                 if (me.getState(2)) {
  305.                     Skill.setSkill(109, 0);
  306.                 }
  307.  
  308.                 break;
  309.             }
  310.  
  311.             if (!this.preattack()) {
  312.                 delay(100);
  313.             }
  314.  
  315.             break;
  316.         }
  317.  
  318.         delay(10);
  319.     }
  320.  
  321.     Town.doChores();
  322.     Town.move("portalspot");
  323.     Pather.usePortal(131, null);
  324.  
  325.     if (Config.Baal.KillBaal) {
  326.         if (Config.PublicMode) {
  327.             say(Config.Baal.BaalMessage);
  328.         }
  329.  
  330.         Pather.moveTo(15090, 5008);
  331.         delay(5000);
  332.         Precast.doPrecast(true);
  333.  
  334.         while (getUnit(1, 543)) {
  335.             delay(500);
  336.         }
  337.  
  338.         portal = getUnit(2, 563);
  339.  
  340.         if (portal) {
  341.             Pather.usePortal(null, null, portal);
  342.         } else {
  343.             throw new Error("Couldn't find portal.");
  344.         }
  345.  
  346.         Pather.moveTo(15134, 5923);
  347.         Attack.kill(544); // Baal
  348.         Pickit.pickItems();
  349.     }
  350.  
  351.     Town.doChores();
  352.  
  353.     return true;
  354. }
Advertisement
Add Comment
Please, Sign In to add comment