Advertisement
Guest User

Amlolas

a guest
Jul 26th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.29 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2017 InevitableGaming
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17.  
  18. #include "ScriptPCH.h"
  19. #include "zone_azshara_crater.h"
  20.  
  21. enum Texts
  22. {
  23.     SAY_AGGRO = 0,
  24.     SAY_KILL_TARGET = 1,
  25.     SAY_DEATH = 2
  26. };
  27.  
  28. enum Spells
  29. {
  30.     SPELL_WRATH = 67953,
  31.     SPELL_MOONFIRE = 67946,
  32.     SPELL_STARFIRE = 67949,
  33.     SPELL_INSECT_SWARM = 67943,
  34.     SPELL_TYPHOON = 61384,
  35.     SPELL_THORNS = 34663,
  36.     SPELL_INNERVATE = 29166
  37. };
  38.  
  39. enum Events
  40. {
  41.     EVENT_WRATH = 1,
  42.     EVENT_MOONFIRE = 2,
  43.     EVENT_STARFIRE = 3,
  44.     EVENT_INSECT_SWARM = 4,
  45.     EVENT_TYPHOON = 5,
  46.     EVENT_THORNS = 6,
  47.     EVENT_MANA_CHECK = 7,
  48.     EVENT_INNERVATE = 8
  49. };
  50.  
  51. enum Phases
  52. {
  53.     PHASE_ONE = 1,
  54.     PHASE_TWO = 2,
  55.     PHASE_THREE = 3
  56. };
  57.  
  58. class boss_amlolas : public CreatureScript
  59. {
  60.     public:
  61.         boss_amlolas() : CreatureScript("boss_amlolas") { }
  62.  
  63.         struct boss_amlolasAI : public BossAI
  64.         {
  65.  
  66.             boss_amlolasAI(Creature* creature) : BossAI(creature, DATA_AMLOLAS)
  67.             {
  68.                 Initialize();
  69.             }
  70.  
  71.             void Initialize()
  72.             {
  73.  
  74.             }
  75.  
  76.             void EnterCombat(Unit* /*who*/) override
  77.             {
  78.                 if (GameObject* gate = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_GATE_AMLOLAS)))
  79.                     gate->SetGoState(GO_STATE_READY);
  80.  
  81.                 events.SetPhase(PHASE_ONE);
  82.                 Talk(SAY_AGGRO);
  83.                 events.ScheduleEvent(EVENT_THORNS, 2000, 0, PHASE_ONE);
  84.                 events.ScheduleEvent(EVENT_WRATH, 8000, 0, PHASE_ONE);
  85.                 events.ScheduleEvent(EVENT_MOONFIRE, 11000, 0, PHASE_ONE);
  86.                 events.ScheduleEvent(EVENT_MANA_CHECK, 1000);
  87.                
  88.  
  89.                 DoZoneInCombat();
  90.                 _EnterCombat();
  91.             }
  92.  
  93.             void KilledUnit(Unit* /*killer*/) override
  94.             {
  95.                 Talk(SAY_KILL_TARGET);
  96.             }
  97.  
  98.             void Reset() override
  99.             {
  100.                 _Reset();
  101.  
  102.                 if (GameObject* gate = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_GATE_AMLOLAS)))
  103.                 {
  104.                     gate->ResetDoorOrButton();
  105.                     gate->SetGoState(GO_STATE_ACTIVE);
  106.                 }
  107.             }
  108.  
  109.             void JustDied(Unit* /*killer*/) override
  110.             {
  111.                 if (GameObject* gate = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(GO_GATE_AMLOLAS)))
  112.                 {
  113.                     gate->ResetDoorOrButton();
  114.                     gate->SetGoState(GO_STATE_ACTIVE);
  115.  
  116.                     Talk(SAY_DEATH);
  117.                 }
  118.  
  119.                 _JustDied();
  120.             }
  121.  
  122.             bool ManaBelowPct(int32 pct) const
  123.             {
  124.                 return (me->GetPower(POWER_MANA) < CountPctFromMaxMana(pct));
  125.             }
  126.  
  127.             uint32 CountPctFromMaxMana(int32 pct) const
  128.             {
  129.                 return CalculatePct(me->GetMaxPower(POWER_MANA), pct);
  130.             }
  131.  
  132.             void UpdateAI(uint32 diff) override
  133.             {
  134.                 if (!UpdateVictim())
  135.                     return;
  136.  
  137.                 events.Update(diff);
  138.  
  139.                 if (me->HasUnitState(UNIT_STATE_CASTING))
  140.                     return;
  141.  
  142.                 if (events.IsInPhase(PHASE_ONE) && HealthBelowPct(50))
  143.                 {
  144.                     events.SetPhase(PHASE_TWO);
  145.  
  146.                     events.ScheduleEvent(EVENT_STARFIRE, 1000, 0, PHASE_TWO);
  147.                     events.ScheduleEvent(EVENT_TYPHOON, 5000, 0, PHASE_TWO);
  148.                     events.ScheduleEvent(EVENT_WRATH, 7000, 0, PHASE_TWO);
  149.                     events.ScheduleEvent(EVENT_INSECT_SWARM, 3500, 0, PHASE_TWO);
  150.                     events.ScheduleEvent(EVENT_MOONFIRE, 500, 0, PHASE_TWO);
  151.                 }
  152.  
  153.                 while (uint32 eventId = events.ExecuteEvent())
  154.                 {
  155.                     switch (eventId)
  156.                     {
  157.                     case EVENT_WRATH:
  158.                         DoCastVictim(SPELL_WRATH);
  159.                         events.ScheduleEvent(EVENT_WRATH, 11000, 0, PHASE_ONE);
  160.                         break;
  161.                     case EVENT_MOONFIRE:
  162.                     {
  163.                         if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  164.                             DoCast(target, SPELL_MOONFIRE);
  165.                             events.ScheduleEvent(EVENT_MOONFIRE, 9000, 0, PHASE_ONE);
  166.                         break;
  167.                     }
  168.                     case EVENT_INSECT_SWARM:
  169.                         if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  170.                             DoCast(target, SPELL_INSECT_SWARM);
  171.                         events.ScheduleEvent(EVENT_INSECT_SWARM, 7500, 0, PHASE_ONE);
  172.                         break;
  173.                     case EVENT_STARFIRE:
  174.                         if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  175.                             DoCast(target, SPELL_STARFIRE);
  176.                         events.ScheduleEvent(EVENT_STARFIRE, 10000, 0, PHASE_TWO);
  177.                         break;
  178.                     case EVENT_THORNS:
  179.                         DoCast(me, SPELL_THORNS, true);
  180.                         events.ScheduleEvent(EVENT_THORNS, 15000, PHASE_ONE);
  181.                         break;
  182.                     case EVENT_TYPHOON:
  183.                         DoCast(me, SPELL_TYPHOON);
  184.                         events.ScheduleEvent(EVENT_TYPHOON, 13000, 0, PHASE_TWO);
  185.                         break;
  186.                     case EVENT_MANA_CHECK:
  187.                         if (ManaBelowPct(30))
  188.                             events.ScheduleEvent(EVENT_INNERVATE, 1000);
  189.                         else
  190.                             events.ScheduleEvent(EVENT_MANA_CHECK, 1000);
  191.                         break;
  192.                     case EVENT_INNERVATE:
  193.                         DoCast(me, SPELL_INNERVATE);
  194.                         break;
  195.                     default:
  196.                         break;
  197.                     }
  198.  
  199.                     if (me->HasUnitState(UNIT_STATE_CASTING))
  200.                         return;
  201.                 }
  202.                 DoMeleeAttackIfReady();
  203.             }
  204.         };
  205.  
  206.         CreatureAI* GetAI(Creature* creature) const override
  207.         {
  208.             return GetAzsharaCraterAI<boss_amlolasAI>(creature);
  209.         }
  210. };
  211.  
  212. void AddSC_boss_amlolas()
  213. {
  214.     new boss_amlolas();
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement