Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
140
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
  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.checkHydra = function () {
  128.         var hydra = getUnit(1, getLocaleString(3325));
  129.         if (hydra) {
  130.             do {
  131.                 if (hydra.mode !== 12 && hydra.getStat(172) !== 2) {
  132.                     Pather.moveTo(15072, 5002);
  133.                     while (hydra.mode !== 12) {
  134.                         delay(500);
  135.                         if (!copyUnit(hydra).x) {
  136.                             break;
  137.                         }
  138.                     }
  139.  
  140.                     break;
  141.                 }
  142.             } while (hydra.getNext());
  143.         }
  144.  
  145.         return true;
  146.     };
  147.  
  148.     this.announce = function () {
  149.         var count, string, souls, dolls,
  150.             monster = getUnit(1);
  151.  
  152.         if (monster) {
  153.             count = 0;
  154.  
  155.             do {
  156.                 if (Attack.checkMonster(monster) && monster.y < 5094) {
  157.                     if (getDistance(me, monster) <= 40) {
  158.                         count += 1;
  159.                     }
  160.  
  161.                     if (!souls && monster.classid === 641) {
  162.                         souls = false;
  163.                     }
  164.  
  165.                     if (!dolls && monster.classid === 691) {
  166.                         dolls = false;
  167.                     }
  168.                 }
  169.             } while (monster.getNext());
  170.         }
  171.  
  172.         if (count > 30) {
  173.             string = "";
  174.         } else if (count > 20) {
  175.             string = "";
  176.         } else if (count > 10) {
  177.             string = "";
  178.         } else if (count > 0) {
  179.             string = "";
  180.         } else {
  181.             string = "";;
  182.         }
  183.  
  184.         if (souls) {
  185.             string += "";
  186.  
  187.             if (dolls) {
  188.                 string += "";
  189.             }
  190.  
  191.             string += "";
  192.         } else if (dolls) {
  193.             string += "";
  194.         }
  195.  
  196.         say(string) ;
  197.     };
  198.  
  199.     Town.doChores();
  200.     Pather.useWaypoint(Config.RandomPrecast ? "" : 129);
  201.     Precast.doPrecast(true);
  202.  
  203.     if (me.area !== 129) {
  204.         Pather.useWaypoint(129);
  205.     }
  206.  
  207.     if (!Pather.moveToExit([130, 131], true)) {
  208.         throw new Error("");
  209.     }
  210.  
  211.     Pather.moveTo(15095, 5029);
  212.  
  213.     if (Config.Baal.DollQuit && getUnit(1, 691)) {
  214.         say("");
  215.  
  216.         return true;
  217.     }
  218.  
  219.     if (Config.Baal.SoulQuit && getUnit(1, 641)) {
  220.         say("");
  221.  
  222.         return true;
  223.     }
  224.  
  225.     if (Config.PublicMode) {
  226.         this.announce();
  227.         Pather.moveTo(15118, 5002);
  228.         Pather.makePortal();
  229.         say(Config.Baal.HotTPMessage);
  230.         Attack.clear(15);
  231.     }
  232.  
  233.     this.clearThrone();
  234.  
  235.     if (Config.PublicMode) {
  236.         Pather.moveTo(15118, 5045);
  237.         Pather.makePortal();
  238.         say(Config.Baal.SafeTPMessage);
  239.         Precast.doPrecast(true);
  240.     }
  241.  
  242.     tick = getTickCount();
  243.  
  244.     Pather.moveTo(15094, me.classid === 3 ? 5029 : 5038);
  245.  
  246. MainLoop:
  247.     while (true) {
  248.         if (getDistance(me, 15094, me.classid === 3 ? 5029 : 5038) > 3) {
  249.             Pather.moveTo(15094, me.classid === 3 ? 5029 : 5038);
  250.         }
  251.  
  252.         if (!getUnit(1, 543)) {
  253.             break MainLoop;
  254.         }
  255.  
  256.         switch (this.checkThrone()) {
  257.         case 1:
  258.             Attack.clear(40);
  259.  
  260.             tick = getTickCount();
  261.  
  262.             Precast.doPrecast(true);
  263.  
  264.             break;
  265.         case 2:
  266.             Attack.clear(40);
  267.  
  268.             tick = getTickCount();
  269.  
  270.             break;
  271.         case 4:
  272.             Attack.clear(40);
  273.  
  274.             tick = getTickCount();
  275.  
  276.             break;
  277.         case 3:
  278.             Attack.clear(40);
  279.             this.checkHydra();
  280.  
  281.             tick = getTickCount();
  282.  
  283.             break;
  284.         case 5:
  285.             Attack.clear(40);
  286.  
  287.             break MainLoop;
  288.         default:
  289.             if (getTickCount() - tick < 7e3) {
  290.                 if (me.getState(2)) {
  291.                     Skill.setSkill(109, 0);
  292.                 }
  293.  
  294.                 break;
  295.             }
  296.  
  297.             if (!this.preattack()) {
  298.                 delay(100);
  299.             }
  300.  
  301.             break;
  302.         }
  303.  
  304.         delay(10);
  305.     }
  306.  
  307.     if (Config.Baal.KillBaal) {
  308.         if (Config.PublicMode) {
  309.             say(Config.Baal.BaalMessage);
  310.         }
  311.  
  312.         Pather.moveTo(15090, 5008);
  313.         delay(5000);
  314.         Precast.doPrecast(true);
  315.  
  316.         while (getUnit(1, 543)) {
  317.             delay(500);
  318.         }
  319.  
  320.         portal = getUnit(2, 563);
  321.  
  322.         if (portal) {
  323.             Pather.usePortal(null, null, portal);
  324.         } else {
  325.             throw new Error("");
  326.         }
  327.  
  328.         Pather.moveTo(15134, 5923);
  329.         Attack.kill(544); // Baal
  330.         Pickit.pickItems();
  331.     }
  332.  
  333.     return true;
  334. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement