Advertisement
Easelm

Dire Maul Arena Event ~ By QQrofl/Faded (TrinityCore)

May 28th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 70.23 KB | None | 0 0
  1. /*******************************************************************************************
  2. *                        __                           __ _                                 *
  3. *                     /\ \ \___  _ __ ___  ___  ___  / _| |_                               *
  4. *                    /  \/ / _ \| '_ ` _ \/ __|/ _ \| |_| __|                              *
  5. *                   / /\  / (_) | | | | | \__ \ (_) |  _| |_                               *
  6. *                   \_\ \/ \___/|_| |_| |_|___/\___/|_|  \__|   - www.Nomsoftware.com -    *
  7. *                               The policy of Nomsoftware states: Releasing our software   *
  8. *                               or any other files are protected. You cannot re-release    *
  9. *                               anywhere unless you were given permission.                 *
  10. *                           (C) Nomsoftware 'Nomsoft' 2011-2012. All rights reserved.      *
  11. ********************************************************************************************/
  12. /**********************************************************
  13. **********************************************************
  14.  *                      Title:                          *
  15.   *            NPC Arena Battle(Dire Maul)             *
  16.    *                                                  *
  17.     *             Idea by: QQrofl                    *
  18.      *            Sub-Ideas by: Foereaper           *
  19.       *            Scripted by: QQrofl             *
  20.        *            Fondled by: Faded             *
  21.         *    Mental Support by: Foereaper        *
  22.          *                                      *
  23.           *   (C)Nomsoftware 'Nomsoft' 2012    */
  24. #include "npcs_dm_battle.h"
  25. /* Red Blood Guard GUID */
  26. class npc_dire_arena_commander : public CreatureScript
  27. {
  28.    public:
  29.        npc_dire_arena_commander() : CreatureScript("npc_dire_arena_commander") { }
  30.  
  31.        bool OnGossipHello(Player * player, Creature * creature)
  32.        {
  33.            if(player->isInCombat())
  34.                return false;
  35.  
  36.            if(isBattleActive)
  37.                player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "I'm sorry, but a battle is already active.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
  38.            else
  39.                player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, MSG_FIGHT_COMPUTER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  40.            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Nevermind", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  41.            player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
  42.            return true;
  43.        }
  44.  
  45.        bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 actions)
  46.        {
  47.            if(sender != GOSSIP_SENDER_MAIN)
  48.                return false;
  49.            player->PlayerTalkClass->ClearMenus();
  50.            switch(actions)
  51.            {
  52.               case GOSSIP_ACTION_INFO_DEF+1:
  53.                       m_PlayerGUID = player->GetGUID();
  54.                       playerName = player->GetName();
  55.                       isBattleActive = true;
  56.                       player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  57.                       player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  58.                       player->PlayerTalkClass->SendCloseGossip();
  59.                   break;
  60.  
  61.               case GOSSIP_ACTION_INFO_DEF+2:
  62.                       player->PlayerTalkClass->SendCloseGossip();
  63.                   break;
  64.  
  65.               case GOSSIP_ACTION_INFO_DEF+3:
  66.                       player->PlayerTalkClass->SendCloseGossip();
  67.                   break;
  68.            }
  69.            return true;
  70.        }
  71.  
  72.        struct npc_dire_arena_commanderAI : public ScriptedAI
  73.        {
  74.            npc_dire_arena_commanderAI(Creature * c) : ScriptedAI(c), summons(me) { }
  75.  
  76.            uint32 checkBattle;
  77.            bool checkIsDead;
  78.            bool resetOnce;
  79.  
  80.            void Reset()
  81.            {
  82.                events.Reset();
  83.                player = NULL;
  84.                summons.DespawnAll();
  85.                checkIsDead = true;
  86.                resetOnce = false;
  87.                checkBattle = 2000;
  88.            }
  89.  
  90.            void UpdateAI(const uint32 diff)
  91.            {
  92.                events.Update(diff);
  93.  
  94.                if(checkBattle <= diff)
  95.                {
  96.                    if(!isBattleActive && m_PlayerGUID == 0 && !resetOnce)
  97.                    {
  98.                        events.Reset();
  99.                        resetOnce = true;
  100.                    }
  101.  
  102.                    if(isBattleActive && m_PlayerGUID != 0 && resetOnce)
  103.                    {  
  104.                        player = Unit::GetPlayer(*me, m_PlayerGUID);
  105.                        events.ScheduleEvent(EVENT_CHECK_ACTIVITY, 1000);
  106.                        resetOnce = false;
  107.                    }
  108.                    if(resetOnce)
  109.                        checkBattle = 2000;
  110.                }
  111.                else
  112.                    checkBattle -= diff;
  113.  
  114.                if (isWaveBossDead == 1 && checkIsDead)
  115.                {
  116.                    events.ScheduleEvent(EVENT_CHECK_WAVES, 1000);
  117.                    checkIsDead = false;
  118.                }
  119.                else if (isWaveBossDead == 2 && !checkIsDead)
  120.                {
  121.                    events.ScheduleEvent(EVENT_CHECK_WAVES, 1000);
  122.                    player->RemoveAura(SPELL_ROOT_AURA);
  123.                    checkIsDead = true;
  124.                }
  125.                else if (isWaveBossDead == 3 && checkIsDead)
  126.                {
  127.                    events.ScheduleEvent(EVENT_CHECK_WAVES, 1000);
  128.                    checkIsDead = false;
  129.                }
  130.                else if (isWaveBossDead == 4 && !checkIsDead)
  131.                {
  132.                    events.ScheduleEvent(EVENT_CHECK_WAVES, 1000);
  133.                    checkIsDead = true;
  134.                }
  135.                else if (isWaveBossDead == 5 && checkIsDead)
  136.                {
  137.                    events.ScheduleEvent(EVENT_CHECK_WAVES, 1000);
  138.                    checkIsDead = false;
  139.                }
  140.                else if (isWaveBossDead == 6 && !checkIsDead)
  141.                {
  142.                    events.ScheduleEvent(EVENT_CHECK_WAVES, 1000);
  143.                    checkIsDead = true;
  144.                }
  145.                else if (isWaveBossDead == 7 && checkIsDead)
  146.                {
  147.                    events.ScheduleEvent(EVENT_CHECK_WAVES, 1000);
  148.                    checkIsDead = false;
  149.                }
  150.  
  151.                while(uint32 eventIds = events.ExecuteEvent())
  152.                {
  153.                    switch(eventIds)
  154.                    {
  155.                       case EVENT_CHECK_ACTIVITY:
  156.                           {
  157.                               if(isBattleActive)
  158.                               {
  159.                                    MessageOnWave(me, EVENT_CHECK_ACTIVITY);
  160.                                    events.ScheduleEvent(EVENT_FIRST_WAVE, 10000);
  161.                               }
  162.                                else
  163.                                    events.ScheduleEvent(EVENT_CHECK_ACTIVITY, 1000);
  164.                           }break;
  165.  
  166.                       case EVENT_CHECK_WAVES:
  167.                           {
  168.                               if(!player)
  169.                                   return;
  170.                               int itemCount = player->GetItemCount(ITEM_INTRAVENOUS_HEALING_POTION);
  171.                               if(itemCount == 0)
  172.                                   player->AddItem(ITEM_INTRAVENOUS_HEALING_POTION, 1);
  173.                               if(isWaveBossDead == 1) // Red Blood Guard
  174.                               {
  175.                                   MessageOnWave(me, EVENT_CHECK_WAVES);
  176.                                   player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  177.                                   player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  178.                                   AddEndRewards(player, 500, PVP_END_TOKEN, 1);
  179.                                   events.ScheduleEvent(EVENT_FIRST_WAVE_TREAT, 25000);
  180.                                   isWaveBossDead = 0;
  181.                               }
  182.                              
  183.                               if (isWaveBossDead == 2) // Spawn Event
  184.                               {
  185.                                   MessageOnWave(me, EVENT_CHECK_WAVES);
  186.                                   player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  187.                                   player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  188.                                   AddEndRewards(player, 1000, PVP_END_TOKEN, 2);
  189.                                   events.ScheduleEvent(EVENT_FIRST_WAVE_ELITE, 35000);
  190.                                   isWaveBossDead = 0;
  191.                               }
  192.  
  193.                               if(isWaveBossDead == 3) // Hank the Tank
  194.                               {
  195.                                   MessageOnWave(me, EVENT_CHECK_WAVES);
  196.                                   AddEndRewards(player, 2000, PVP_END_TOKEN, 5);
  197.                                   player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  198.                                   player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  199.                                   events.ScheduleEvent(EVENT_SECOND_WAVE, 35000);
  200.                                   isWaveBossDead = 0;
  201.                               }
  202.  
  203.                               if(isWaveBossDead == 4) // Rogue Initiates
  204.                               {
  205.                                   MessageOnWave(me, EVENT_CHECK_WAVES);
  206.                                   AddEndRewards(player, 3000, PVP_END_TOKEN, 10);
  207.                                   player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  208.                                   player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  209.                                   events.ScheduleEvent(EVENT_SECOND_WAVE_TREAT, 35000);
  210.                                   isWaveBossDead = 0;
  211.                               }
  212.  
  213.                               if(isWaveBossDead == 5) // The Unholys
  214.                               {
  215.                                   MessageOnWave(me, EVENT_CHECK_WAVES);
  216.                                   player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  217.                                   AddEndRewards(player, 4000, PVP_END_TOKEN, 20);
  218.                                   player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  219.                                   events.ScheduleEvent(EVENT_SECOND_WAVE_ELITE, 40000);
  220.                                   isWaveBossDead = 0;
  221.                               }
  222.  
  223.                               if(isWaveBossDead == 6) // The Riders of the Ice
  224.                               {
  225.                                   MessageOnWave(me, EVENT_CHECK_WAVES);
  226.                                   player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  227.                                   AddEndRewards(player, 5000, PVP_END_TOKEN, 30);
  228.                                   player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  229.                                   events.ScheduleEvent(EVENT_FINAL_WAVE_BOSS, 35000);
  230.                                   isWaveBossDead = 0;
  231.                               }
  232.  
  233.                               if(isWaveBossDead == 7) // Dragon Final Event
  234.                               {
  235.                                   MessageOnWave(me, EVENT_CHECK_WAVES);
  236.                                   player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  237.                                   AddEndRewards(player, 10000, PVP_END_TOKEN, 50);
  238.                                   events.ScheduleEvent(EVENT_COMPLETED_WAVES, 5000);
  239.                                   isWaveBossDead = 0;
  240.                               }
  241.                           }break;
  242.  
  243.                       case EVENT_FIRST_WAVE:
  244.                           sLog->outString("[Dire Maul Arena]: Starting First Wave...");
  245.                           MessageOnWave(me, EVENT_FIRST_WAVE);
  246.                           player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  247.                           player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f); // Making sure you're in the right place
  248.                           player->PlayDirectSound(SOUND_HORN_WAVE_START);
  249.                           me->SummonCreature(waveList[0], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation,
  250.                               TEMPSUMMON_MANUAL_DESPAWN, 0);
  251.                           break;
  252.  
  253.                       case EVENT_FIRST_WAVE_TREAT:
  254.                           MessageOnWave(me, EVENT_FIRST_WAVE_TREAT);
  255.                           me->SummonCreature(waveList[1], -3739.533447f, 1095.419434f, 131.969559f, 3.029968f, TEMPSUMMON_MANUAL_DESPAWN, 0);
  256.                           player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  257.                           player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f); // Making sure you're in the right place
  258.                           player->PlayDirectSound(SOUND_HORN_WAVE_START);
  259.                           player->AddAura(SPELL_ROOT_AURA, player);
  260.                           break;
  261.  
  262.                       case EVENT_FIRST_WAVE_ELITE:
  263.                           MessageOnWave(me, EVENT_FIRST_WAVE_ELITE);
  264.                           player->PlayDirectSound(SOUND_HORN_WAVE_START);
  265.                           player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  266.                           player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f); // Making sure you're in the right place
  267.                           me->SummonCreature(waveList[8], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation,
  268.                                 TEMPSUMMON_MANUAL_DESPAWN, 0);
  269.                           break;
  270.  
  271.                       case EVENT_SECOND_WAVE:
  272.                           MessageOnWave(me, EVENT_SECOND_WAVE);
  273.                           player->PlayDirectSound(SOUND_HORN_WAVE_START);
  274.                           player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  275.                           player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f); // Making sure you're in the right place
  276.                           me->SummonCreature(waveList[10], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation,
  277.                                 TEMPSUMMON_MANUAL_DESPAWN, 0);
  278.                           break;
  279.  
  280.                       case EVENT_SECOND_WAVE_TREAT:
  281.                           MessageOnWave(me, EVENT_SECOND_WAVE_TREAT);
  282.                           player->PlayDirectSound(SOUND_HORN_WAVE_START);
  283.                           player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  284.                           player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f); // Making sure you're in the right place
  285.                           me->SummonCreature(waveList[13], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation,
  286.                                 TEMPSUMMON_MANUAL_DESPAWN, 0);
  287.                           break;
  288.  
  289.                       case EVENT_SECOND_WAVE_ELITE:
  290.                           MessageOnWave(me, EVENT_SECOND_WAVE_ELITE);
  291.                           player->PlayDirectSound(SOUND_HORN_WAVE_START);
  292.                           player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  293.                           player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f); // Making sure you're in the right place
  294.                           me->SummonCreature(waveList[16], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation,
  295.                                 TEMPSUMMON_MANUAL_DESPAWN, 0);
  296.                           break;
  297.  
  298.                       case EVENT_FINAL_WAVE_BOSS:
  299.                           sLog->outString("[Dire Maul Arena]: Starting Final Wave...");
  300.                           MessageOnWave(me, EVENT_FINAL_WAVE_BOSS);
  301.                           player->PlayDirectSound(SOUND_HORN_WAVE_START);
  302.                           player->CastSpell(player, SPELL_TELEPORT_VISUAL);
  303.                           player->TeleportTo(1, -3739.533447f, 1095.419434f, 131.969559f, 3.029968f); // Making sure you're in the right place
  304.                           me->SummonCreature(waveList[19], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation,
  305.                                 TEMPSUMMON_MANUAL_DESPAWN, 0);
  306.                           break;
  307.  
  308.                       case EVENT_COMPLETED_WAVES:
  309.                           me->MonsterYell("Congratulations to our finest Gladiator that went through a lot to earn our rewards! Who will be our next challenger?",
  310.                               LANG_UNIVERSAL, me->GetGUID());
  311.                           isBattleActive = false;
  312.                           m_PlayerGUID = NULL;
  313.                           playerName = "";
  314.                           summons.DespawnAll();
  315.                           events.Reset();
  316.                           events.CancelEvent(EVENT_COMPLETED_WAVES);
  317.                           isWaveBossDead = 0;
  318.                           checkIsDead = true;
  319.                           break;
  320.                     }
  321.                 }
  322.            }
  323.  
  324.            void JustSummoned(Creature * summoned)
  325.            {
  326.                summons.Summon(summoned);
  327.            }
  328.        private:
  329.            EventMap events;
  330.            Player * player;
  331.            SummonList summons;
  332.        };
  333.  
  334.        CreatureAI * GetAI(Creature * pCreature) const
  335.        {
  336.            return new npc_dire_arena_commanderAI(pCreature);
  337.        }
  338. };
  339.  
  340. class npc_dire_maul_rb_guard : public CreatureScript
  341. {
  342.    public:
  343.        npc_dire_maul_rb_guard() : CreatureScript("npc_dire_maul_rb_guard") { }
  344.  
  345.        struct npc_dire_maul_rb_guardAI : public ScriptedAI
  346.        {
  347.            npc_dire_maul_rb_guardAI(Creature * c) : ScriptedAI(c), summons(me) { }
  348.  
  349.            uint32 uiCharge;
  350.            uint32 uiMortalStrike;
  351.            uint32 uiCheckOutOfRange;
  352.            bool spawnMinis;
  353.  
  354.            void Reset()
  355.            {
  356.                spawnMinis = true;
  357.                uiCharge = 2000;
  358.                uiMortalStrike = urand(5000, 8000);
  359.                me->MonsterYell("You can't defeat me!", LANG_UNIVERSAL, me->GetGUID());
  360.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 45233);
  361.            }
  362.  
  363.            void KilledUnit(Unit * who)
  364.            {
  365.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  366.                    return;
  367.  
  368.                isBattleActive = false;
  369.                m_PlayerGUID = NULL;
  370.                playerName = "";
  371.                me->DespawnOrUnsummon(1);
  372.            }
  373.  
  374.            void JustDied(Unit * killer)
  375.            {
  376.                if(killer && killer->GetTypeId() != TYPEID_PLAYER)
  377.                    return;
  378.                me->PlayDirectSound(SOUND_WAVE_COMPLETE, killer->ToPlayer());
  379.                isWaveBossDead = 1;
  380.                summons.DespawnAll();
  381.            }
  382.  
  383.            void JustSummoned(Creature * summoned)
  384.            {
  385.                summons.Summon(summoned);
  386.            }
  387.  
  388.            void UpdateAI(const uint32 diff)
  389.            {
  390.                if(!UpdateVictim())
  391.                {
  392.                    summons.DespawnAll();
  393.                    return;
  394.                }
  395.  
  396.                ScriptedAI::UpdateAI(diff);
  397.                if(!isBattleActive)
  398.                {
  399.                    me->DespawnOrUnsummon(1);
  400.                    return;
  401.                }
  402.  
  403.                if(uiCharge <= diff)
  404.                {
  405.                    me->CastSpell(me->getVictim(), SPELL_BERSERKER_CHARGE);
  406.                    uiCharge = 12000;
  407.                }
  408.                else
  409.                    uiCharge -= diff;
  410.  
  411.                if(uiMortalStrike <= diff)
  412.                {
  413.                    me->CastSpell(me->getVictim(), SPELL_MORTAL_STRIKE);
  414.                    me->CastSpell(me->getVictim(), SPELL_DEEP_WOUNDS); // Cast deep wounds after Mortal strike
  415.                    uiMortalStrike = urand(5000, 120000);
  416.                }
  417.                else
  418.                    uiMortalStrike -= diff;
  419.  
  420.                if(me->GetHealthPct() <= 45 && spawnMinis)
  421.                {
  422.                    me->MonsterYell("Minions, come to my aid!", LANG_UNIVERSAL, me->GetGUID());
  423.                    mini = me->SummonCreature(NPC_RED_BLOOD_GUARD_MINI, me->GetPositionX(), me->GetPositionY()+1, me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0);
  424.                    mini->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 45233);
  425.                    mini2 = me->SummonCreature(NPC_RED_BLOOD_GUARD_MINI2, me->GetPositionX()+2, me->GetPositionY()+1, me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0);
  426.                    mini2->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 45233);
  427.                    mini3 = me->SummonCreature(NPC_RED_BLOOD_GUARD_MINI3, me->GetPositionX()+2, me->GetPositionY()+1, me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0);
  428.                    mini3->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 45233);
  429.                    mini->AddThreat(me->getVictim(), 100.0f);
  430.                    mini2->AddThreat(me->getVictim(), 100.0f);
  431.                    mini3->AddThreat(me->getVictim(), 100.0f);
  432.                    spawnMinis = false;
  433.                }
  434.                DoMeleeAttackIfReady();
  435.            }
  436.        private:
  437.            Creature * mini;
  438.            Creature * mini2;
  439.            Creature * mini3;
  440.            SummonList summons;
  441.        };
  442.  
  443.        CreatureAI * GetAI(Creature * pCreature) const
  444.        {
  445.            return new npc_dire_maul_rb_guardAI(pCreature);
  446.        }
  447. };
  448.  
  449. class npc_red_blood_mini : public CreatureScript
  450. {
  451.    public:
  452.        npc_red_blood_mini() : CreatureScript("npc_red_blood_mini") { }
  453.  
  454.        struct npc_red_blood_miniAI : public ScriptedAI
  455.        {
  456.            npc_red_blood_miniAI(Creature * c) : ScriptedAI(c) { }
  457.  
  458.            void KilledUnit(Unit * who)
  459.            {
  460.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  461.                    return;
  462.                isBattleActive = false;
  463.                m_PlayerGUID = NULL;
  464.                playerName = "";
  465.                me->DespawnOrUnsummon(1);
  466.            }
  467.        };
  468.  
  469.        CreatureAI * GetAI(Creature * pCreature) const
  470.        {
  471.            return new npc_red_blood_miniAI(pCreature);
  472.        }
  473. };
  474.  
  475. class npc_dm_wave_trigger : public CreatureScript
  476. {
  477.    public:
  478.        npc_dm_wave_trigger() : CreatureScript("npc_dm_wave_trigger") { }
  479.  
  480.        struct npc_dm_wave_triggerAI : public ScriptedAI
  481.        {
  482.            npc_dm_wave_triggerAI(Creature * c) : ScriptedAI(c), summons(me) { }
  483.  
  484.            uint32 startSpawnWave;
  485.            int spawnPhase;
  486.  
  487.            void Reset()
  488.            {
  489.                me->MonsterTextEmote("A portal has opened..", LANG_UNIVERSAL, me->GetGUID());
  490.                me->SummonCreature(NPC_PORTAL, m_WaveSpawns[1].m_positionX, m_WaveSpawns[1].m_positionY, m_WaveSpawns[1].m_positionZ, m_WaveSpawns[1].m_orientation,
  491.                    TEMPSUMMON_MANUAL_DESPAWN, 0);
  492.                me->SummonCreature(NPC_PORTAL, m_WaveSpawns[2].m_positionX, m_WaveSpawns[2].m_positionY, m_WaveSpawns[2].m_positionZ, m_WaveSpawns[2].m_orientation,
  493.                    TEMPSUMMON_MANUAL_DESPAWN, 0);
  494.                startSpawnWave = 1000;
  495.                spawnPhase = 0;
  496.            }
  497.  
  498.            void UpdateAI(const uint32 diff)
  499.            {
  500.                if(!isBattleActive)
  501.                {
  502.                    summons.DespawnAll();
  503.                    me->DespawnOrUnsummon(1);
  504.                    return;
  505.                }
  506.  
  507.                if(startSpawnWave <= diff)
  508.                {
  509.                    switch(spawnPhase)
  510.                    {
  511.                       case 0:
  512.                           {
  513.                               spawnPhase = 1;
  514.                               DoPortalSpawns();
  515.                               startSpawnWave = 13000;
  516.                           }break;
  517.  
  518.                       case 1:
  519.                           {
  520.                               spawnPhase = 2;
  521.                               DoPortalSpawns();
  522.                               startSpawnWave = 13000;
  523.                           }break;
  524.  
  525.                       case 2:
  526.                           {
  527.                               spawnPhase = 3;
  528.                               DoPortalSpawns();
  529.                               startSpawnWave = 13000;
  530.                           }break;
  531.  
  532.                       case 3:
  533.                           {
  534.                               spawnPhase = 4;
  535.                               for(int i = 0; i < 2; i++)
  536.                                 DoPortalSpawns();
  537.                               startSpawnWave = 25000;
  538.                           }break;
  539.  
  540.                       case 4:
  541.                           {
  542.                               spawnPhase = 5;
  543.                               for(int i = 0; i < 2; i++)
  544.                                 DoPortalSpawns();
  545.                               startSpawnWave = 25000;
  546.                           }break;
  547.  
  548.                       case 5:
  549.                           {
  550.                               spawnPhase = 6;
  551.                               for(int i = 0; i < 4; i++)
  552.                                 DoPortalSpawns();
  553.                               startSpawnWave = 36000;
  554.                           }break;
  555.  
  556.                       case 6:
  557.                           {
  558.                               spawnPhase = 7;
  559.                               for(int i = 0; i < 4; i++)
  560.                                 DoPortalSpawns();
  561.                               startSpawnWave = 36000;
  562.                           }break;
  563.  
  564.                       case 7:
  565.                           {
  566.                               spawnPhase = 8;
  567.                               DoPortalSpawns();
  568.                               startSpawnWave = 10000;
  569.                           }break;
  570.  
  571.                       case 8:
  572.                           {
  573.                               spawnPhase = 9;
  574.                               DoPortalSpawns();
  575.                               startSpawnWave = 10000;
  576.                           }break;
  577.  
  578.                       case 9:
  579.                           {
  580.                               spawnPhase = 10;
  581.                               DoPortalSpawns();
  582.                               startSpawnWave = 15000;
  583.                           }break;
  584.  
  585.                       case 10:
  586.                           {
  587.                               spawnPhase = 11;
  588.                               for(int i = 0; i < 4; i++)
  589.                                 DoPortalSpawns();
  590.                               startSpawnWave = 60000;
  591.                           }break;
  592.  
  593.                       case 11:
  594.                           {
  595.                               if(Player * player = Unit::GetPlayer(*me, m_PlayerGUID))
  596.                               {
  597.                                   if(!player)
  598.                                       return;
  599.                                   me->PlayDirectSound(SOUND_WAVE_COMPLETE, player);
  600.                               }
  601.                               isWaveBossDead = 2;
  602.                               summons.DespawnAll();
  603.                               spawnPhase = 0;
  604.                               me->DespawnOrUnsummon(1);
  605.                           }break;
  606.                    }
  607.                }
  608.                else
  609.                    startSpawnWave -= diff;
  610.            }
  611.  
  612.            void JustSummoned(Creature * summoned)
  613.            {
  614.                summons.Summon(summoned);
  615.            }
  616.  
  617.            void DoPortalSpawns() // Spawns Random Npcs
  618.            {
  619.                int random = urand(0, 4);
  620.                switch(random)
  621.                {
  622.                    case 0:
  623.                        me->SummonCreature(waveList[2], m_WaveSpawns[1].m_positionX, m_WaveSpawns[1].m_positionY, m_WaveSpawns[1].m_positionZ, m_WaveSpawns[1].m_orientation,
  624.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  625.                        break;
  626.  
  627.                    case 1:
  628.                        me->SummonCreature(waveList[3], m_WaveSpawns[1].m_positionX, m_WaveSpawns[1].m_positionY, m_WaveSpawns[1].m_positionZ, m_WaveSpawns[1].m_orientation,
  629.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  630.                        break;
  631.  
  632.                    case 2:
  633.                        me->SummonCreature(waveList[4], m_WaveSpawns[1].m_positionX, m_WaveSpawns[1].m_positionY, m_WaveSpawns[1].m_positionZ, m_WaveSpawns[1].m_orientation,
  634.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  635.                        break;
  636.  
  637.                    case 3:
  638.                        me->SummonCreature(waveList[5], m_WaveSpawns[1].m_positionX, m_WaveSpawns[1].m_positionY, m_WaveSpawns[1].m_positionZ, m_WaveSpawns[1].m_orientation,
  639.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  640.                        break;
  641.  
  642.                    case 4:
  643.                        me->SummonCreature(waveList[6], m_WaveSpawns[1].m_positionX, m_WaveSpawns[1].m_positionY, m_WaveSpawns[1].m_positionZ, m_WaveSpawns[1].m_orientation,
  644.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  645.                        break;
  646.                }
  647.                int random2 = urand(0, 4);
  648.                switch(random2)
  649.                {
  650.                    case 0:
  651.                        me->SummonCreature(waveList[2], m_WaveSpawns[2].m_positionX, m_WaveSpawns[2].m_positionY, m_WaveSpawns[2].m_positionZ, m_WaveSpawns[2].m_orientation,
  652.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  653.                        break;
  654.  
  655.                    case 1:
  656.                        me->SummonCreature(waveList[3], m_WaveSpawns[2].m_positionX, m_WaveSpawns[2].m_positionY, m_WaveSpawns[2].m_positionZ, m_WaveSpawns[2].m_orientation,
  657.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  658.                        break;
  659.  
  660.                    case 2:
  661.                        me->SummonCreature(waveList[4], m_WaveSpawns[2].m_positionX, m_WaveSpawns[2].m_positionY, m_WaveSpawns[2].m_positionZ, m_WaveSpawns[2].m_orientation,
  662.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  663.                        break;
  664.  
  665.                    case 3:
  666.                        me->SummonCreature(waveList[5], m_WaveSpawns[2].m_positionX, m_WaveSpawns[2].m_positionY, m_WaveSpawns[2].m_positionZ, m_WaveSpawns[2].m_orientation,
  667.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  668.                        break;
  669.  
  670.                    case 4:
  671.                        me->SummonCreature(waveList[6], m_WaveSpawns[2].m_positionX, m_WaveSpawns[2].m_positionY, m_WaveSpawns[2].m_positionZ, m_WaveSpawns[2].m_orientation,
  672.                            TEMPSUMMON_MANUAL_DESPAWN, 0);
  673.                        break;
  674.                }
  675.            }
  676.        private:
  677.            SummonList summons;
  678.        };
  679.  
  680.        CreatureAI * GetAI(Creature * pCreature) const
  681.        {
  682.            return new npc_dm_wave_triggerAI(pCreature);
  683.        }
  684. };
  685.  
  686. class npc_dm_wave_spawns : public CreatureScript
  687. {
  688.    public:
  689.        npc_dm_wave_spawns() : CreatureScript("npc_dm_wave_spawns") { }
  690.  
  691.        struct npc_dm_wave_spawnsAI : public ScriptedAI
  692.        {
  693.            npc_dm_wave_spawnsAI(Creature * c) : ScriptedAI(c) { }
  694.  
  695.  
  696.            void Reset()
  697.            {
  698.                me->GetMotionMaster()->MovePoint(-3739.533447f, 1095.419434f, 131.969559f, 3.029968f);
  699.            }
  700.  
  701.            void KilledUnit(Unit * who)
  702.            {
  703.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  704.                    return;
  705.                isBattleActive = false;
  706.                m_PlayerGUID = NULL;
  707.                playerName = "";
  708.                me->DespawnOrUnsummon(1);
  709.            }
  710.  
  711.            void UpdateAI(const uint32 diff)
  712.            {
  713.                if(!UpdateVictim())
  714.                    return;
  715.  
  716.                if(!isBattleActive)
  717.                    me->DespawnOrUnsummon(1);
  718.  
  719.                DoMeleeAttackIfReady();
  720.            }
  721.        };
  722.  
  723.        CreatureAI * GetAI(Creature * pCreature) const
  724.        {
  725.            return new npc_dm_wave_spawnsAI(pCreature);
  726.        }
  727. };
  728.  
  729. uint32 hankAuras[] = { SPELL_BATTLE_STANCE, SPELL_INCREASE_BLOCK_VALUE, SPELL_INCREASE_DEFENSE_RATING, SPELL_INCREASE_DODGE_RATING };
  730. class npc_dm_hank_the_tank : public CreatureScript
  731. {
  732.    public:
  733.        npc_dm_hank_the_tank() : CreatureScript("npc_dm_hank_the_tank") { }
  734.  
  735.        struct npc_dm_hank_the_tankAI : public ScriptedAI
  736.        {
  737.            npc_dm_hank_the_tankAI(Creature * c) : ScriptedAI(c), summons(me) { }
  738.  
  739.            uint32 shoutBuff;
  740.            uint32 groundStomp;
  741.            uint32 uiExecute;
  742.            uint32 tankStrike;
  743.            uint32 uiRend;
  744.            uint32 shieldBlock;
  745.            uint32 shieldBash;
  746.  
  747.            void Reset()
  748.            {
  749.                me->MonsterYell("You will succumb to death, young scums!", LANG_UNIVERSAL, me->GetGUID());
  750.                summons.DespawnAll();
  751.                me->SummonCreature(waveList[9], me->GetPositionX(), me->GetPositionY()+3, me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0);
  752.                shoutBuff = 1000;
  753.                groundStomp = 6000;
  754.                shieldBash = urand(9000, 13000);
  755.                uiExecute = urand(21000, 26000);
  756.                shieldBlock = 18000;
  757.                tankStrike = urand(4000, 8000);
  758.                uiRend = 11000;
  759.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51516);
  760.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 51533);
  761.                for(int i = 0; i < 4; i++)
  762.                    me->AddAura(hankAuras[i], me);
  763.            }
  764.  
  765.            void EnterCombat(Unit * who)
  766.            {
  767.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  768.                    return;
  769.                DoCast(who, SPELL_TANK_CHARGE);
  770.            }
  771.  
  772.            void JustDied(Unit * killer)
  773.            {
  774.                if(killer && killer->GetTypeId() != TYPEID_PLAYER)
  775.                    return;
  776.                me->PlayDirectSound(SOUND_WAVE_COMPLETE, killer->ToPlayer());
  777.                summons.DespawnAll();
  778.                isWaveBossDead = 3;
  779.            }
  780.  
  781.            void KilledUnit(Unit * who)
  782.            {
  783.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  784.                    return;
  785.                isBattleActive = false;
  786.                m_PlayerGUID = NULL;
  787.                playerName = "";
  788.                summons.DespawnAll();
  789.                me->DespawnOrUnsummon(1);
  790.            }
  791.  
  792.            void JustSummoned(Creature * summoned)
  793.            {
  794.                summons.Summon(summoned);
  795.            }
  796.  
  797.            void UpdateAI(const uint32 diff)
  798.            {
  799.                if(!UpdateVictim())
  800.                    return;
  801.  
  802.                if(!isBattleActive)
  803.                {
  804.                    summons.DespawnAll();
  805.                    me->DespawnOrUnsummon(1);
  806.                    return;
  807.                }
  808.  
  809.                if(shoutBuff <= diff)
  810.                {
  811.                    me->AddAura(SPELL_SHOUT_BUFF, me);
  812.                    shoutBuff = 120000; // 2 minutes
  813.                }
  814.                else
  815.                    shoutBuff -= diff;
  816.  
  817.                if(groundStomp <= diff)
  818.                {
  819.                    DoCast(me->getVictim(), SPELL_GROUND_STOMP, true);
  820.                    groundStomp = 6000;
  821.                }
  822.                else
  823.                    groundStomp -= diff;
  824.  
  825.                if(uiExecute <= diff)
  826.                {
  827.                    if(me->getVictim()->GetHealthPct() <= 20)
  828.                        DoCast(me->getVictim(), SPELL_EXECUTE);
  829.                    uiExecute = urand(21000, 26000);
  830.                }
  831.                else
  832.                    uiExecute -= diff;
  833.  
  834.                if(shieldBlock <= diff)
  835.                {
  836.                    DoCast(me, SPELL_SHIELD_BLOCK); // Cast on self
  837.                    shieldBlock = 18000;
  838.                }
  839.                else
  840.                    shieldBlock -= diff;
  841.  
  842.                if(tankStrike <= diff)
  843.                {
  844.                    DoCast(me->getVictim(), SPELL_TANK_STRIKE);
  845.                    tankStrike = urand(4000, 8000);
  846.                }
  847.                else
  848.                    tankStrike -= diff;
  849.  
  850.                if(uiRend <= diff)
  851.                {
  852.                    DoCast(me->getVictim(), SPELL_REND, true);
  853.                    uiRend = 15000;
  854.                }
  855.                else
  856.                    uiRend -= diff;
  857.                DoMeleeAttackIfReady();
  858.            }
  859.        private:
  860.            SummonList summons;
  861.        };
  862.  
  863.        CreatureAI * GetAI(Creature * pCreature) const
  864.        {
  865.            return new npc_dm_hank_the_tankAI(pCreature);
  866.        }
  867. };
  868.  
  869. class npc_dm_field_medic : public CreatureScript
  870. {
  871.    public:
  872.        npc_dm_field_medic() : CreatureScript("npc_dm_field_medic") { }
  873.  
  874.        struct npc_dm_field_medicAI : public ScriptedAI
  875.        {
  876.            npc_dm_field_medicAI(Creature * c) : ScriptedAI(c) { }
  877.  
  878.            uint32 uiRegrowthTimer;
  879.            uint32 uiHealingTouchTimer;
  880.            uint32 uiHealRejuvTimer;
  881.            uint32 uiFlashHealTimer;
  882.            uint32 uiPowerShieldTimer;
  883.            uint32 uiLifebloomTimer;
  884.            int casted;
  885.            bool showOnce;
  886.            bool canHealMaster;
  887.  
  888.            void Reset()
  889.            {
  890.                uiRegrowthTimer = urand(11000, 13000);
  891.                uiHealingTouchTimer = urand(6000, 8000);
  892.                uiHealRejuvTimer = 15000;
  893.                uiFlashHealTimer = urand(14000, 17000);
  894.                uiPowerShieldTimer = 1000;
  895.                uiLifebloomTimer = 2000;
  896.                canHealMaster = true;
  897.                showOnce = false;
  898.                int casted = 0;
  899.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51404);
  900.                me->AddAura(SPELL_HEAL_AURA_HOTS, me);
  901.                hank = me->FindNearestCreature(NPC_HANK_THE_TANK, 50.0f, true);
  902.            }
  903.  
  904.            void UpdateAI(const uint32 diff)
  905.            {
  906.                if(!hank)
  907.                    return;
  908.  
  909.                if(hank->isDead() && !showOnce)
  910.                {
  911.                    me->MonsterYell("Master Dead?!!! I give up!...", LANG_UNIVERSAL, me->GetGUID());
  912.                    me->setFaction(35);
  913.                    me->DespawnOrUnsummon(1);
  914.                    showOnce = true;
  915.                    return;
  916.                }
  917.  
  918.                if(!hank->isInCombat())
  919.                    return;
  920.  
  921.                if(hank && hank->GetHealthPct() >= 100)
  922.                    canHealMaster = false;
  923.                else
  924.                    canHealMaster = true;
  925.  
  926.                if(uiRegrowthTimer <= diff)
  927.                {
  928.                    if(canHealMaster)
  929.                        DoCast(hank, SPELL_HEAL_REGROWTH, true);
  930.                    if(me->GetHealthPct() <= 70)
  931.                        DoCast(me, SPELL_HEAL_REGROWTH, true);
  932.                    uiRegrowthTimer = urand(10000, 16000);
  933.                }
  934.                else
  935.                    uiRegrowthTimer -= diff;
  936.  
  937.                if(uiHealingTouchTimer <= diff)
  938.                {
  939.                    if(hank->GetHealthPct() <= 45 && canHealMaster)
  940.                        DoCast(hank, SPELL_HEAL_NORMAL, true);
  941.                    if(me->GetHealthPct() <= 30)
  942.                        DoCast(me, SPELL_HEAL_NORMAL, true);
  943.                    uiHealingTouchTimer = urand(6000, 8000);
  944.                }
  945.                else
  946.                    uiHealingTouchTimer -= diff;
  947.  
  948.                if(uiHealRejuvTimer <= diff)
  949.                {
  950.                    if(canHealMaster)
  951.                        DoCast(hank, SPELL_HEAL_REJUV, true);
  952.                    if(me->GetHealthPct() <= 90)
  953.                        DoCast(me, SPELL_HEAL_REJUV, true);
  954.                    uiHealRejuvTimer = 15000;
  955.                }
  956.                else
  957.                    uiHealRejuvTimer -= diff;
  958.  
  959.                if(uiFlashHealTimer <= diff)
  960.                {
  961.                    if(canHealMaster)
  962.                        DoCast(hank, SPELL_FLASH_HEAL, true);
  963.                    if(me->GetHealthPct() <= 55)
  964.                        DoCast(me, SPELL_FLASH_HEAL, true);
  965.                    uiFlashHealTimer = urand(14000, 17000);
  966.                }
  967.                else
  968.                    uiFlashHealTimer -= diff;
  969.  
  970.                if(uiPowerShieldTimer <= diff)
  971.                {
  972.                    DoCast(me, SPELL_POWER_WORD_SHIELD);
  973.                    uiPowerShieldTimer = 30000;
  974.                }
  975.                else
  976.                    uiPowerShieldTimer -= diff;
  977.  
  978.                if(uiLifebloomTimer <= diff)
  979.                {
  980.                    if(canHealMaster)
  981.                    {
  982.                        DoCast(hank, SPELL_HEAL_LIFEBLOOM, true); // Stacking
  983.                        casted++; // Increment the value
  984.                        if(casted != 3)
  985.                            uiLifebloomTimer = 2000;
  986.                        else // Prevents further stacking of this spell
  987.                        {
  988.                            uiLifebloomTimer = 26000;
  989.                            casted = 0;
  990.                        }
  991.                    }
  992.                }
  993.                else
  994.                    uiLifebloomTimer -= diff;
  995.                DoMeleeAttackIfReady();
  996.            }
  997.        private:
  998.            Creature * hank;
  999.        };
  1000.  
  1001.        CreatureAI * GetAI(Creature * pCreature) const
  1002.        {
  1003.            return new npc_dm_field_medicAI(pCreature);
  1004.        }
  1005. };
  1006.  
  1007. class npc_dm_main_rogue : public CreatureScript
  1008. {
  1009.    public:
  1010.        npc_dm_main_rogue() : CreatureScript("npc_dm_main_rogue") { }
  1011.  
  1012.        struct npc_dm_main_rogueAI : public ScriptedAI
  1013.        {
  1014.            npc_dm_main_rogueAI(Creature * c) : ScriptedAI(c), summons(me) { }
  1015.  
  1016.            uint32 uiVanishTimer;
  1017.            uint32 uiCheapShotTimer;
  1018.            uint32 uiStrikeTimer;
  1019.            uint32 uiFinisherTimer;
  1020.            uint32 uiKickTimer;
  1021.            uint32 uiWaitTimer;
  1022.            uint32 uiRuptureTimer;
  1023.            int comboPoints;
  1024.            bool InStealth;
  1025.            bool InVanish;
  1026.  
  1027.            void Reset()
  1028.            {
  1029.                me->MonsterYell("We'll teach you a valued lesson.", LANG_UNIVERSAL, me->GetGUID());
  1030.                InStealth = true;
  1031.                InVanish = false;
  1032.                comboPoints = 0;
  1033.                uiFinisherTimer = 4000;
  1034.                uiStrikeTimer = 6000;  
  1035.                uiRuptureTimer = 9000;
  1036.                uiKickTimer = 10000;
  1037.                uiVanishTimer = 17000;
  1038.                DoCast(me, SPELL_ROGUE_STEALTH);
  1039.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51517);
  1040.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 51441);
  1041.                summons.DespawnAll();
  1042.                me->SummonCreature(waveList[11], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY+3, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation, TEMPSUMMON_MANUAL_DESPAWN, 0);
  1043.                me->SummonCreature(waveList[12], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY-3, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation, TEMPSUMMON_MANUAL_DESPAWN, 0);
  1044.            }
  1045.  
  1046.            void JustDied(Unit * killer)
  1047.            {
  1048.                if(killer && killer->GetTypeId() != TYPEID_PLAYER)
  1049.                    return;
  1050.                me->PlayDirectSound(SOUND_WAVE_COMPLETE, killer->ToPlayer());
  1051.                summons.DespawnAll();
  1052.                isWaveBossDead = 4;
  1053.            }
  1054.  
  1055.            void KilledUnit(Unit * who)
  1056.            {
  1057.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1058.                    return;
  1059.                isBattleActive = false;
  1060.                m_PlayerGUID = NULL;
  1061.                playerName = "";
  1062.                summons.DespawnAll();
  1063.                me->DespawnOrUnsummon(1);               
  1064.            }
  1065.  
  1066.            void JustSummoned(Creature * summoned)
  1067.            {
  1068.                summons.Summon(summoned);
  1069.            }
  1070.  
  1071.            void UpdateAI(const uint32 diff)
  1072.            {
  1073.                if(!UpdateVictim())
  1074.                    return;
  1075.  
  1076.                if(!isBattleActive)
  1077.                {
  1078.                    summons.DespawnAll();
  1079.                    me->DespawnOrUnsummon(1);
  1080.                    return;
  1081.                }
  1082.  
  1083.                if(InStealth)
  1084.                {
  1085.                    me->CastSpell(me->getVictim(), SPELL_ROGUE_CHEAP_SHOT, true);
  1086.                    InStealth = false;
  1087.                }
  1088.  
  1089.                if(uiStrikeTimer <= diff)
  1090.                {
  1091.                    if(!InVanish)
  1092.                    {
  1093.                        DoCast(me->getVictim(), SPELL_ROGUE_STRIKE);
  1094.                        comboPoints++;
  1095.                    }  
  1096.                    uiStrikeTimer = 6000;
  1097.                }
  1098.                else
  1099.                    uiStrikeTimer -= diff;
  1100.  
  1101.                if(uiFinisherTimer <= diff)
  1102.                {
  1103.                    if(!InVanish && comboPoints >= 2)
  1104.                    {
  1105.                        me->CastSpell(me->getVictim(), SPELL_ROGUE_FINISHER);
  1106.                        comboPoints = 0;
  1107.                    }
  1108.                    uiFinisherTimer = 4000;
  1109.                }
  1110.                else
  1111.                    uiFinisherTimer -= diff;
  1112.  
  1113.                if(uiKickTimer <= diff)
  1114.                {
  1115.                    if(!InVanish)
  1116.                        DoCast(me->getVictim(), SPELL_ROGUE_KICK);
  1117.                    uiKickTimer = 10000;
  1118.                }
  1119.                else
  1120.                    uiKickTimer -= diff;
  1121.  
  1122.                if(uiVanishTimer <= diff)
  1123.                {
  1124.                    DoCast(me, SPELL_ROGUE_VANISH);
  1125.                    InVanish = true;
  1126.                    uiVanishTimer = 20000;
  1127.                    uiWaitTimer = 6000;
  1128.                }
  1129.                else
  1130.                    uiVanishTimer -= diff;
  1131.  
  1132.                if(uiRuptureTimer <= diff)
  1133.                {
  1134.                    if(!InVanish)
  1135.                        DoCast(me->getVictim(), SPELL_ROGUE_RUPTURE, true);
  1136.                    uiRuptureTimer = 9000;
  1137.                }
  1138.                else
  1139.                    uiRuptureTimer -= diff;
  1140.  
  1141.                if(InVanish)
  1142.                {
  1143.                    if(uiWaitTimer <= diff)
  1144.                    {
  1145.                        me->CastSpell(me->getVictim(), SPELL_ROGUE_CHEAP_SHOT, true);
  1146.                        me->MonsterYell("Attack!", LANG_UNIVERSAL, me->GetGUID());
  1147.                        InVanish = false;
  1148.                    }
  1149.                    else
  1150.                        uiWaitTimer -= diff;
  1151.                }
  1152.                if(!InVanish)
  1153.                    DoMeleeAttackIfReady();
  1154.            }
  1155.        private:
  1156.            SummonList summons;
  1157.        };
  1158.  
  1159.        CreatureAI * GetAI(Creature * pCreature) const
  1160.        {
  1161.            return new npc_dm_main_rogueAI(pCreature);
  1162.        }
  1163. };
  1164.  
  1165. class npc_dm_rogue_initiate : public CreatureScript
  1166. {
  1167.    public:
  1168.        npc_dm_rogue_initiate() : CreatureScript("npc_dm_rogue_initiate") { }
  1169.  
  1170.        struct npc_dm_rogue_initiateAI : public ScriptedAI
  1171.        {
  1172.            npc_dm_rogue_initiateAI(Creature * c) : ScriptedAI(c) { }
  1173.  
  1174.            uint32 uiVanishTimer;
  1175.            uint32 uiCheapShotTimer;
  1176.            uint32 uiStrikeTimer;
  1177.            uint32 uiFinisherTimer;
  1178.            uint32 uiKickTimer;
  1179.            uint32 uiWaitTimer;
  1180.            uint32 uiKidneyShotTimer;
  1181.            int comboPoints;
  1182.            bool InVanish;
  1183.            bool InStealth;
  1184.  
  1185.            void Reset()
  1186.            {
  1187.                InVanish = false;
  1188.                InStealth = true;
  1189.                comboPoints = 0;
  1190.                uiFinisherTimer = 4000;
  1191.                uiStrikeTimer = 6000;  
  1192.                uiKickTimer = 10000;
  1193.                uiKidneyShotTimer = 14000;
  1194.                uiVanishTimer = 17000;      
  1195.                DoCast(me, SPELL_ROGUE_STEALTH);
  1196.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51517);
  1197.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 51441);
  1198.            }
  1199.  
  1200.            void KilledUnit(Unit * who)
  1201.            {
  1202.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1203.                    return;
  1204.                isBattleActive = false;
  1205.                m_PlayerGUID = NULL;
  1206.                playerName = "";
  1207.                me->DespawnOrUnsummon(1);
  1208.            }
  1209.  
  1210.            void UpdateAI(const uint32 diff)
  1211.            {
  1212.                if(!UpdateVictim())
  1213.                    return;
  1214.  
  1215.                if(InStealth)
  1216.                {
  1217.                    DoCast(me->getVictim(), SPELL_ROGUE_BACKSTAB);
  1218.                    InStealth = false;
  1219.                }
  1220.  
  1221.                if(uiStrikeTimer <= diff)
  1222.                {
  1223.                    if(!InVanish)
  1224.                    {
  1225.                        DoCast(me->getVictim(), SPELL_ROGUE_STRIKE);
  1226.                        comboPoints++;
  1227.                    }  
  1228.                    uiStrikeTimer = 6000;
  1229.                }
  1230.                else
  1231.                    uiStrikeTimer -= diff;
  1232.  
  1233.                if(uiFinisherTimer <= diff)
  1234.                {
  1235.                    if(!InVanish && comboPoints >= 2)
  1236.                    {
  1237.                        me->CastSpell(me->getVictim(), SPELL_ROGUE_FINISHER);
  1238.                        comboPoints = 0;
  1239.                    }
  1240.                    uiFinisherTimer = 4000;
  1241.                }
  1242.                else
  1243.                    uiFinisherTimer -= diff;
  1244.  
  1245.                if(uiKickTimer <= diff)
  1246.                {
  1247.                    if(!InVanish)
  1248.                        DoCast(me->getVictim(), SPELL_ROGUE_KICK);
  1249.                    uiKickTimer = 10000;
  1250.                }
  1251.                else
  1252.                    uiKickTimer -= diff;
  1253.  
  1254.                if(uiKidneyShotTimer <= diff)
  1255.                {
  1256.                    if(!InVanish)
  1257.                        DoCast(me->getVictim(), SPELL_ROGUE_KIDNEY_SHOT);
  1258.                    uiKidneyShotTimer = 12000;
  1259.                }
  1260.                else
  1261.                    uiKidneyShotTimer -= diff;
  1262.  
  1263.                if(uiVanishTimer <= diff)
  1264.                {
  1265.                    DoCast(me, SPELL_ROGUE_VANISH);
  1266.                    InVanish = true;
  1267.                    uiVanishTimer = 20000;
  1268.                    uiWaitTimer = 6000;
  1269.                }
  1270.                else
  1271.                    uiVanishTimer -= diff;
  1272.  
  1273.                if(InVanish)
  1274.                {
  1275.                    if(uiWaitTimer <= diff)
  1276.                    {
  1277.                        DoCast(me->getVictim(), SPELL_ROGUE_BACKSTAB);
  1278.                        InVanish = false;
  1279.                    }
  1280.                    else
  1281.                        uiWaitTimer -= diff;
  1282.                }
  1283.                if(!InVanish)
  1284.                    DoMeleeAttackIfReady();
  1285.            }
  1286.        };
  1287.  
  1288.        CreatureAI * GetAI(Creature * pCreature) const
  1289.        {
  1290.            return new npc_dm_rogue_initiateAI(pCreature);
  1291.        }
  1292. };
  1293.  
  1294. class npc_dm_main_unholy : public CreatureScript
  1295. {
  1296.    public:
  1297.        npc_dm_main_unholy() : CreatureScript("npc_dm_main_unholy") { }
  1298.  
  1299.        struct npc_dm_main_unholyAI : public ScriptedAI
  1300.        {
  1301.            npc_dm_main_unholyAI(Creature * c) : ScriptedAI(c), summons(me) { }
  1302.  
  1303.            uint32 uiCinematic;
  1304.            uint32 uiAoeTimer;
  1305.            uint32 uiPlagueStrikeTimer;
  1306.            uint32 uiStangulateTimer;
  1307.            uint32 uiDeathStrikeTimer;
  1308.            uint32 uiArmyOfTheDeadTimer;
  1309.            int cinematicPassed;
  1310.            bool checkGuin;
  1311.            bool boneArmor;
  1312.  
  1313.            void Reset()
  1314.            {
  1315.                me->MonsterSay("What is this? A trap?", LANG_UNIVERSAL, me->GetGUID());
  1316.                uiCinematic = 9000;
  1317.                cinematicPassed = 0;
  1318.                checkGuin = true;
  1319.                boneArmor = true;
  1320.                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
  1321.                me->SetReactState(REACT_PASSIVE);
  1322.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51393);
  1323.                summons.DespawnAll();
  1324.                twin = me->SummonCreature(waveList[14], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY+3, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation, TEMPSUMMON_MANUAL_DESPAWN, 0);
  1325.                guin = me->SummonCreature(waveList[15], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY-3, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation, TEMPSUMMON_MANUAL_DESPAWN, 0);
  1326.            }
  1327.  
  1328.            void KilledUnit(Unit * who)
  1329.            {
  1330.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1331.                    return;
  1332.                isBattleActive = false;
  1333.                m_PlayerGUID = NULL;
  1334.                playerName = "";
  1335.                summons.DespawnAll();
  1336.                twin = NULL;
  1337.                guin = NULL;
  1338.                me->DespawnOrUnsummon(1);
  1339.            }
  1340.  
  1341.            void JustDied(Unit * killer)
  1342.            {
  1343.                if(killer && killer->GetTypeId() != TYPEID_PLAYER)
  1344.                    return;
  1345.                me->PlayDirectSound(SOUND_WAVE_COMPLETE, killer->ToPlayer());
  1346.                summons.DespawnAll();
  1347.                twin = NULL;
  1348.                guin = NULL;
  1349.                isWaveBossDead = 5;
  1350.            }
  1351.  
  1352.            void UpdateAI(const uint32 diff)
  1353.            {
  1354.                if(!isBattleActive)
  1355.                {
  1356.                    summons.DespawnAll();
  1357.                    twin = NULL;
  1358.                    guin = NULL;
  1359.                    me->DespawnOrUnsummon(1);
  1360.                    return;
  1361.                }
  1362.  
  1363.                if(uiCinematic <= diff)
  1364.                {
  1365.                    if(cinematicPassed == 0)
  1366.                    {
  1367.                        me->MonsterSay("Ahh, so this thing wants to fight, huh?", LANG_UNIVERSAL, me->GetGUID());
  1368.                        cinematicPassed = 1;
  1369.                        uiCinematic = 10000;
  1370.                    }
  1371.                    else if(cinematicPassed == 1)
  1372.                    {
  1373.                        me->MonsterSay("Don't be a fool!", LANG_UNIVERSAL, me->GetGUID());
  1374.                        cinematicPassed = 2;
  1375.                        uiCinematic = 9000;
  1376.                    }
  1377.                    else if(cinematicPassed == 2)
  1378.                    {
  1379.                        me->MonsterSay("Twin, no! Let him go. We can just watch, for now....", LANG_UNIVERSAL, me->GetGUID());
  1380.                        cinematicPassed = 3;
  1381.                    }
  1382.                }
  1383.                else
  1384.                    uiCinematic -= diff;
  1385.  
  1386.                if(checkGuin)
  1387.                {
  1388.                    if(guin && guin->isDead())
  1389.                    {
  1390.                        me->MonsterYell("SO BE IT!", LANG_UNIVERSAL, me->GetGUID());
  1391.                        me->AddAura(SPELL_UNHOLY_BONE_SHIELD, me);
  1392.                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
  1393.                        uiAoeTimer = 25000;
  1394.                        uiPlagueStrikeTimer = urand(5000, 8000);
  1395.                        uiDeathStrikeTimer = urand(9000, 12000);
  1396.                        uiStangulateTimer = 15000;
  1397.                        uiArmyOfTheDeadTimer = 30000;
  1398.                        me->SetReactState(REACT_AGGRESSIVE);
  1399.                        if(twin)
  1400.                        {
  1401.                            twin->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
  1402.                            twin->SetReactState(REACT_AGGRESSIVE);
  1403.                        }
  1404.                        checkGuin = false;
  1405.                    }
  1406.                }
  1407.  
  1408.                if(!UpdateVictim())
  1409.                    return;
  1410.  
  1411.                if(HealthBelowPct(25) && boneArmor)
  1412.                {
  1413.                    me->AddAura(SPELL_UNHOLY_BONE_SHIELD, me);
  1414.                    boneArmor = false;
  1415.                }
  1416.  
  1417.                if(uiAoeTimer <= diff)
  1418.                {
  1419.                    me->CastSpell(me->getVictim()->GetPositionX(), me->getVictim()->GetPositionY(), me->getVictim()->GetPositionZ(), SPELL_UNHOLY_AOE, true);
  1420.                    uiAoeTimer = 25000;
  1421.                }
  1422.                else
  1423.                    uiAoeTimer -= diff;
  1424.  
  1425.                if(uiPlagueStrikeTimer <= diff)
  1426.                {
  1427.                    DoCast(me->getVictim(), SPELL_UNHOLY_PLAGUE_STRIKE);
  1428.                    uiPlagueStrikeTimer = urand(5000, 8000);
  1429.                }
  1430.                else
  1431.                    uiPlagueStrikeTimer -= diff;
  1432.  
  1433.                if(uiStangulateTimer <= diff)
  1434.                {
  1435.                    DoCast(me->getVictim(), SPELL_UNHOLY_STANGULATE, true);
  1436.                    uiStangulateTimer = 15000;
  1437.                }
  1438.                else
  1439.                    uiStangulateTimer -= diff;
  1440.  
  1441.                if(uiDeathStrikeTimer <= diff)
  1442.                {
  1443.                    DoCast(me->getVictim(), SPELL_UNHOLY_DEATH_STRIKE);
  1444.                    uiDeathStrikeTimer = urand(9000, 12000);
  1445.                }
  1446.                else
  1447.                    uiDeathStrikeTimer -= diff;
  1448.  
  1449.                if(uiArmyOfTheDeadTimer <= diff)
  1450.                {
  1451.                    DoCast(me, SPELL_UNHOLY_ARMY, true);
  1452.                    uiArmyOfTheDeadTimer = 30000;
  1453.                }
  1454.                else
  1455.                    uiArmyOfTheDeadTimer -= diff;
  1456.                DoMeleeAttackIfReady();
  1457.            }
  1458.  
  1459.            void JustSummoned(Creature * summoned)
  1460.            {
  1461.                summons.Summon(summoned);
  1462.            }
  1463.  
  1464.           private:
  1465.               Creature * guin;
  1466.               Creature * twin;
  1467.               SummonList summons;
  1468.        };
  1469.  
  1470.        CreatureAI * GetAI(Creature * pCreature) const
  1471.        {
  1472.            return new npc_dm_main_unholyAI(pCreature);
  1473.        }
  1474. };
  1475.  
  1476. class npc_dm_unholy_twin : public CreatureScript
  1477. {
  1478.    public:
  1479.        npc_dm_unholy_twin() : CreatureScript("npc_dm_unholy_twin") { }
  1480.  
  1481.        struct npc_dm_unholy_twinAI : public ScriptedAI
  1482.        {
  1483.            npc_dm_unholy_twinAI(Creature * c) : ScriptedAI(c) { }
  1484.  
  1485.            uint32 uiCinematic;
  1486.            uint32 uiAoeTimer;
  1487.            uint32 uiPlagueStrikeTimer;
  1488.            uint32 uiStangulateTimer;
  1489.            uint32 uiDeathStrikeTimer;
  1490.            uint32 uiArmyOfTheDeadTimer;
  1491.            int cinematicPassed;
  1492.            bool boneArmor;
  1493.  
  1494.            void Reset()
  1495.            {
  1496.                uiCinematic = 6000;
  1497.                boneArmor = true;
  1498.                cinematicPassed = 0;
  1499.                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
  1500.                me->SetReactState(REACT_PASSIVE);
  1501.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51393);
  1502.            }
  1503.  
  1504.            void OnCombatStart(Unit * /* who */)
  1505.            {
  1506.                me->AddAura(SPELL_UNHOLY_BONE_SHIELD, me);
  1507.                uiAoeTimer = 25000;
  1508.                uiPlagueStrikeTimer = urand(5000, 8000);
  1509.                uiDeathStrikeTimer = urand(9000, 12000);
  1510.                uiStangulateTimer = 15000;
  1511.                uiArmyOfTheDeadTimer = 30000;
  1512.            }
  1513.  
  1514.            void KilledUnit(Unit * who)
  1515.            {
  1516.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1517.                    return;
  1518.                isBattleActive = false;
  1519.                m_PlayerGUID = NULL;
  1520.                playerName = "";
  1521.                me->DespawnOrUnsummon(1);
  1522.            }
  1523.  
  1524.            void UpdateAI(const uint32 diff)
  1525.            {
  1526.                if(uiCinematic <= diff)
  1527.                {
  1528.                    if (cinematicPassed == 0)
  1529.                    {
  1530.                        me->MonsterSay("I believe it wants to fight us.", LANG_UNIVERSAL, me->GetGUID());
  1531.                        cinematicPassed = 1;
  1532.                        uiCinematic = 7000;
  1533.                    }
  1534.                    else if (cinematicPassed == 1)
  1535.                    {
  1536.                        me->MonsterSay("Yes. So it seems.", LANG_UNIVERSAL, me->GetGUID());
  1537.                        cinematicPassed = 2;
  1538.                        uiCinematic = 6000;
  1539.                    }
  1540.                    else if (cinematicPassed == 2)
  1541.                    {
  1542.                        me->MonsterSay("What? FIGHT?", LANG_UNIVERSAL, me->GetGUID());
  1543.                        cinematicPassed = 3;
  1544.                        uiCinematic = 3000;
  1545.                    }
  1546.                    else if (cinematicPassed == 3)
  1547.                    {
  1548.                        me->MonsterYell("GUIN! NO!", LANG_UNIVERSAL, me->GetGUID());
  1549.                        cinematicPassed = 4;
  1550.                    }
  1551.                }
  1552.                else
  1553.                    uiCinematic -= diff;
  1554.  
  1555.                if(!UpdateVictim())
  1556.                    return;
  1557.  
  1558.                if(HealthBelowPct(25) && boneArmor)
  1559.                {
  1560.                    me->AddAura(SPELL_UNHOLY_BONE_SHIELD, me);
  1561.                    boneArmor = false;
  1562.                }
  1563.  
  1564.                if(uiAoeTimer <= diff)
  1565.                {
  1566.                    me->CastSpell(me->getVictim()->GetPositionX(), me->getVictim()->GetPositionY(), me->getVictim()->GetPositionZ(), SPELL_UNHOLY_AOE, true);
  1567.                    uiAoeTimer = 25000;
  1568.                }
  1569.                else
  1570.                    uiAoeTimer -= diff;
  1571.  
  1572.                if(uiPlagueStrikeTimer <= diff)
  1573.                {
  1574.                    DoCast(me->getVictim(), SPELL_UNHOLY_PLAGUE_STRIKE);
  1575.                    uiPlagueStrikeTimer = urand(5000, 8000);
  1576.                }
  1577.                else
  1578.                    uiPlagueStrikeTimer -= diff;
  1579.  
  1580.                if(uiStangulateTimer <= diff)
  1581.                {
  1582.                    DoCast(me->getVictim(), SPELL_UNHOLY_STANGULATE, true);
  1583.                    uiStangulateTimer = 15000;
  1584.                }
  1585.                else
  1586.                    uiStangulateTimer -= diff;
  1587.  
  1588.                if(uiDeathStrikeTimer <= diff)
  1589.                {
  1590.                    DoCast(me->getVictim(), SPELL_UNHOLY_DEATH_STRIKE);
  1591.                    uiDeathStrikeTimer = urand(9000, 12000);
  1592.                }
  1593.                else
  1594.                    uiDeathStrikeTimer -= diff;
  1595.  
  1596.                if(uiArmyOfTheDeadTimer <= diff)
  1597.                {
  1598.                    DoCast(me, SPELL_UNHOLY_ARMY, true);
  1599.                    uiArmyOfTheDeadTimer = 30000;
  1600.                }
  1601.                else
  1602.                    uiArmyOfTheDeadTimer -= diff;
  1603.                DoMeleeAttackIfReady();
  1604.            }
  1605.            
  1606.        };
  1607.  
  1608.        CreatureAI * GetAI(Creature * pCreature) const
  1609.        {
  1610.            return new npc_dm_unholy_twinAI(pCreature);
  1611.        }
  1612. };
  1613.  
  1614. class npc_dm_unholy_pet : public CreatureScript
  1615. {
  1616.    public:
  1617.        npc_dm_unholy_pet() : CreatureScript("npc_dm_unholy_pet") { }
  1618.  
  1619.        struct npc_dm_unholy_petAI : public ScriptedAI
  1620.        {
  1621.            npc_dm_unholy_petAI(Creature * c) : ScriptedAI(c) { }
  1622.  
  1623.            uint32 uiCinematicTimer;
  1624.            uint32 uiPhaseChangeTimer;
  1625.            uint32 uiEnrageTimer;
  1626.            int phase;
  1627.            int cinematicPassed;
  1628.  
  1629.            void Reset()
  1630.            {
  1631.                uiCinematicTimer = 16000;
  1632.                uiPhaseChangeTimer = 1000;
  1633.                uiEnrageTimer = 5000;
  1634.                phase = 1;
  1635.                cinematicPassed = 0;
  1636.                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
  1637.                me->SetReactState(REACT_PASSIVE);
  1638.            }
  1639.  
  1640.            void KilledUnit(Unit * who)
  1641.            {
  1642.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1643.                    return;
  1644.                isBattleActive = false;
  1645.                m_PlayerGUID = NULL;
  1646.                playerName = "";
  1647.                me->DespawnOrUnsummon(1);
  1648.            }
  1649.  
  1650.            void UpdateAI(const uint32 diff)
  1651.            {
  1652.                if(uiCinematicTimer <= diff)
  1653.                {
  1654.                    if (cinematicPassed == 0)
  1655.                    {
  1656.                        me->MonsterSay("Why can't we fight masters?", LANG_UNIVERSAL, me->GetGUID());
  1657.                        cinematicPassed = 1;
  1658.                        uiCinematicTimer = 5000;
  1659.                    }
  1660.                    else if (cinematicPassed == 1)
  1661.                    {
  1662.                        me->MonsterYell("Well, I'm hungry!", LANG_UNIVERSAL, me->GetGUID());
  1663.                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
  1664.                        me->SetReactState(REACT_AGGRESSIVE);
  1665.                        if(Player * player = me->SelectNearestPlayer(500.0f))
  1666.                            if(player && player->GetGUID() == m_PlayerGUID)
  1667.                                me->AI()->AttackStart(player);
  1668.                        cinematicPassed = 2;
  1669.                    }
  1670.                }
  1671.                else
  1672.                    uiCinematicTimer -= diff;
  1673.  
  1674.                if(!UpdateVictim())
  1675.                    return;
  1676.  
  1677.                if(uiPhaseChangeTimer <= diff)
  1678.                {
  1679.                    if(me->GetHealthPct() <= 85 && phase == 1)
  1680.                    {
  1681.                        me->SetMaxHealth(me->GetMaxHealth()+40000);
  1682.                        me->SetHealth(me->GetMaxHealth()+40000);
  1683.                        me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2);
  1684.                        phase = 2;
  1685.                    }
  1686.                    else if(me->GetHealthPct() <= 65 && phase == 2)
  1687.                    {
  1688.                        me->SetMaxHealth(me->GetMaxHealth()+40000);
  1689.                        me->SetHealth(me->GetMaxHealth()+40000);
  1690.                        me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.5);
  1691.                        phase = 3;
  1692.                    }
  1693.                    else if(me->GetHealthPct() <= 35 && phase == 3)
  1694.                    {
  1695.                        me->SetMaxHealth(me->GetMaxHealth()+40000);
  1696.                        me->SetHealth(me->GetMaxHealth()+40000);
  1697.                        me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.5);
  1698.                        phase = 4;
  1699.                    }
  1700.                    else if(me->GetHealthPct() <= 15 && phase == 4)
  1701.                    {
  1702.                        me->MonsterYell("HUNGER!", LANG_UNIVERSAL, me->GetGUID());
  1703.                        me->SetMaxHealth(me->GetMaxHealth()+40000);
  1704.                        me->SetHealth(me->GetMaxHealth()+40000);
  1705.                        me->SetFloatValue(OBJECT_FIELD_SCALE_X, 3.5);
  1706.                        phase = 5;
  1707.                    }
  1708.                }
  1709.                else
  1710.                    uiPhaseChangeTimer -= diff;
  1711.  
  1712.                if(uiEnrageTimer <= diff)
  1713.                {
  1714.                    DoCast(SPELL_ENRAGE);
  1715.                    uiEnrageTimer = 5000;
  1716.                }
  1717.                else
  1718.                    uiEnrageTimer -= diff;
  1719.                DoMeleeAttackIfReady();
  1720.            }
  1721.        };
  1722.  
  1723.        CreatureAI * GetAI(Creature * pCreature) const
  1724.        {
  1725.            return new npc_dm_unholy_petAI(pCreature);
  1726.        }
  1727. };
  1728.  
  1729. class npc_army_ghoul : public CreatureScript
  1730. {
  1731.    public:
  1732.        npc_army_ghoul() : CreatureScript("npc_army_ghoul") { }
  1733.  
  1734.        struct npc_army_ghoulAI : public ScriptedAI
  1735.        {
  1736.            npc_army_ghoulAI(Creature * c) : ScriptedAI(c) { }
  1737.  
  1738.            void KilledUnit(Unit * who)
  1739.            {
  1740.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1741.                    return;
  1742.                isBattleActive = false;
  1743.                m_PlayerGUID = NULL;
  1744.                playerName = "";
  1745.                me->DespawnOrUnsummon(1);
  1746.            }
  1747.        };
  1748.        CreatureAI * GetAI(Creature * pCreature) const
  1749.        {
  1750.            return new npc_army_ghoulAI(pCreature);
  1751.        }
  1752. };
  1753.  
  1754. class npc_dm_rider_guardian : public CreatureScript
  1755. {
  1756.    public:
  1757.        npc_dm_rider_guardian() : CreatureScript("npc_dm_rider_guardian") { }
  1758.  
  1759.        struct npc_dm_rider_guardianAI : public ScriptedAI
  1760.        {
  1761.            npc_dm_rider_guardianAI(Creature * c) : ScriptedAI(c), summons(me) { }
  1762.  
  1763.            uint32 uiShieldTimer;
  1764.            uint32 uiHealingBoltTimer;
  1765.            uint32 uiRenewTimer;
  1766.            uint32 uiGreaterHealTimer;
  1767.            uint32 uiHealingBoltWaitTimer;
  1768.            bool checkBrutes;
  1769.            bool giveUp;
  1770.            bool InHealingBolt;
  1771.  
  1772.            void Reset()
  1773.            {
  1774.                uiShieldTimer = 25000;
  1775.                uiHealingBoltTimer = urand(10000, 14000);
  1776.                uiRenewTimer = 5000;
  1777.                uiGreaterHealTimer = 8000;
  1778.                me->SetReactState(REACT_PASSIVE);
  1779.                me->CastSpell(me, SPELL_RIDERS_SHIELD);
  1780.                me->CastSpell(me, SPELL_RIDERS_STAM_BUFF);
  1781.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51453);
  1782.                checkBrutes = false;
  1783.                giveUp = false;
  1784.                InHealingBolt = false;
  1785.                summons.DespawnAll();
  1786.                brute = me->SummonCreature(waveList[17], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY+3, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation, TEMPSUMMON_MANUAL_DESPAWN, 0);
  1787.                brute2 = me->SummonCreature(waveList[18], m_WaveSpawns[0].m_positionX, m_WaveSpawns[0].m_positionY-3, m_WaveSpawns[0].m_positionZ, m_WaveSpawns[0].m_orientation, TEMPSUMMON_MANUAL_DESPAWN, 0);
  1788.            }
  1789.  
  1790.            void KilledUnit(Unit * who)
  1791.            {
  1792.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1793.                    return;
  1794.                isBattleActive = false;
  1795.                m_PlayerGUID = NULL;
  1796.                playerName = "";
  1797.                summons.DespawnAll();
  1798.                me->DespawnOrUnsummon(1);
  1799.            }
  1800.  
  1801.            void JustSummoned(Creature * summoned)
  1802.            {
  1803.                summons.Summon(summoned);
  1804.            }
  1805.  
  1806.            void UpdateAI(const uint32 diff)
  1807.            {
  1808.                if(!isBattleActive)
  1809.                {
  1810.                    summons.DespawnAll();
  1811.                    brute = NULL;
  1812.                    brute2 = NULL;
  1813.                    me->DespawnOrUnsummon(1);
  1814.                    return;
  1815.                }
  1816.  
  1817.                if(HealthBelowPct(10) && !giveUp)
  1818.                {
  1819.                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
  1820.                    me->MonsterYell("I.. I GIVE UP!", LANG_UNIVERSAL, me->GetGUID());
  1821.                    me->SetHealth(me->GetMaxHealth());
  1822.                    checkBrutes = true;
  1823.                    giveUp = true;
  1824.                }
  1825.  
  1826.                if(checkBrutes && giveUp)
  1827.                {
  1828.                    if(brute && brute->isDead() && brute2 && brute2->isDead())
  1829.                    {
  1830.                        if(Player * player = me->SelectNearestPlayer(200.0f))
  1831.                            if(player && player->GetGUID() == m_PlayerGUID)
  1832.                                me->PlayDirectSound(SOUND_WAVE_COMPLETE, player);
  1833.                        summons.DespawnAll();
  1834.                        me->DespawnOrUnsummon(1);
  1835.                        isWaveBossDead = 6;
  1836.                    }
  1837.                    return;
  1838.                }
  1839.  
  1840.                if(uiShieldTimer <= diff && !InHealingBolt)
  1841.                {
  1842.                    int target = urand(0, 2);
  1843.                    switch(target)
  1844.                    {
  1845.                       case 0:
  1846.                           if(brute)
  1847.                               DoCast(brute, SPELL_RIDERS_SHIELD);
  1848.                           break;
  1849.  
  1850.                       case 1:
  1851.                           if(brute2)
  1852.                               DoCast(brute2, SPELL_RIDERS_SHIELD);
  1853.                           break;
  1854.  
  1855.                       case 2:
  1856.                           DoCast(me, SPELL_RIDERS_SHIELD);
  1857.                           break;
  1858.                    }
  1859.                    uiShieldTimer = 16000;
  1860.                }
  1861.                else
  1862.                    uiShieldTimer -= diff;
  1863.  
  1864.                if(uiHealingBoltTimer <= diff)
  1865.                {
  1866.                    int target = urand(0, 1);
  1867.                    switch(target)
  1868.                    {
  1869.                       case 0:
  1870.                           if(brute && brute->GetHealthPct() <= 85)
  1871.                               me->CastSpell(brute, SPELL_RIDERS_HEALING_BOLT, true);
  1872.                           break;
  1873.  
  1874.                       case 1:
  1875.                           if(brute2 && brute2->GetHealthPct() <= 65)
  1876.                               me->CastSpell(brute2, SPELL_RIDERS_HEALING_BOLT, true);
  1877.                           break;
  1878.                    }
  1879.                    InHealingBolt = true;
  1880.                    uiHealingBoltWaitTimer = 3000;
  1881.                    uiHealingBoltTimer = urand(10000, 14000);
  1882.                }
  1883.                else
  1884.                    uiHealingBoltTimer -= diff;
  1885.  
  1886.                if(InHealingBolt)
  1887.                {
  1888.                    if(uiHealingBoltWaitTimer <= diff)
  1889.                    {
  1890.                        InHealingBolt = false;
  1891.                    }
  1892.                    else
  1893.                        uiHealingBoltWaitTimer -= diff;
  1894.                }
  1895.  
  1896.                if(uiRenewTimer <= diff && !InHealingBolt)
  1897.                {
  1898.                    int target = urand(0, 2);
  1899.                    switch(target)
  1900.                    {
  1901.                       case 0:
  1902.                           if(brute)
  1903.                               DoCast(brute, SPELL_RIDERS_RENEW);
  1904.                           break;
  1905.  
  1906.                       case 1:
  1907.                           if(brute2)
  1908.                               DoCast(brute2, SPELL_RIDERS_RENEW);
  1909.                           break;
  1910.  
  1911.                       case 2:
  1912.                           if(HealthBelowPct(80))
  1913.                               DoCast(me, SPELL_RIDERS_RENEW);
  1914.                           break;
  1915.                    }
  1916.                    uiRenewTimer = 5000;
  1917.                }
  1918.                else
  1919.                    uiRenewTimer -= diff;
  1920.  
  1921.                if(uiGreaterHealTimer <= diff && !InHealingBolt)
  1922.                {
  1923.                    int target = urand(0, 2);
  1924.                    switch(target)
  1925.                    {
  1926.                       case 0:
  1927.                           if(brute && brute->GetHealthPct() <= 30)
  1928.                               me->CastSpell(brute, SPELL_RIDERS_GREATER_HEAL, true);
  1929.                           break;
  1930.  
  1931.                       case 1:
  1932.                           if(brute2 && brute2->GetHealthPct() <= 20)
  1933.                               me->CastSpell(brute2, SPELL_RIDERS_GREATER_HEAL, true);
  1934.                           break;
  1935.  
  1936.                       case 2:
  1937.                           if(HealthBelowPct(40))
  1938.                               me->CastSpell(me, SPELL_RIDERS_GREATER_HEAL, true);
  1939.                           break;
  1940.                    }
  1941.                    uiGreaterHealTimer = 6000;
  1942.                }
  1943.                else
  1944.                    uiGreaterHealTimer -= diff;
  1945.            }
  1946.           private:
  1947.               Creature * brute;
  1948.               Creature * brute2;
  1949.               SummonList summons;
  1950.        };
  1951.  
  1952.        CreatureAI * GetAI(Creature * pCreature) const
  1953.        {
  1954.            return new npc_dm_rider_guardianAI(pCreature);
  1955.        }
  1956. };
  1957.  
  1958. class npc_dm_rider_brute : public CreatureScript
  1959. {
  1960.    public:
  1961.        npc_dm_rider_brute() : CreatureScript("npc_dm_rider_brute") { }
  1962.  
  1963.        struct npc_dm_rider_bruteAI : public ScriptedAI
  1964.        {
  1965.            npc_dm_rider_bruteAI(Creature * c) : ScriptedAI(c) { }
  1966.  
  1967.            uint32 uiLightningTimer;
  1968.            uint32 uiChainLightningTimer;
  1969.            uint32 uiMoonfireTimer;
  1970.            uint32 uiLightningStormTimer;
  1971.            uint32 uiLightningWaitTimer;
  1972.            bool InLightningChannel;
  1973.  
  1974.            void Reset()
  1975.            {
  1976.                uiLightningTimer = 13000;
  1977.                uiChainLightningTimer = urand(6000, 9000);
  1978.                uiMoonfireTimer = 5000;
  1979.                uiLightningStormTimer = urand(20000, 26000);
  1980.                InLightningChannel = false;
  1981.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 51517);
  1982.                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 51447);
  1983.            }
  1984.  
  1985.            void KilledUnit(Unit * who)
  1986.            {
  1987.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  1988.                    return;
  1989.                isBattleActive = false;
  1990.                m_PlayerGUID = NULL;
  1991.                playerName = "";
  1992.                me->DespawnOrUnsummon(1);
  1993.            }
  1994.  
  1995.            void UpdateAI(const uint32 diff)
  1996.            {
  1997.                if(!UpdateVictim())
  1998.                    return;
  1999.  
  2000.                if(!isBattleActive)
  2001.                {
  2002.                    me->DespawnOrUnsummon(1);
  2003.                    return;
  2004.                }
  2005.  
  2006.                if(uiLightningTimer <= diff)
  2007.                {
  2008.                    if(!InLightningChannel)
  2009.                        DoCast(me->getVictim(), SPELL_RIDERS_LIGHTNING);
  2010.                    uiLightningTimer = 13000;
  2011.                }
  2012.                else
  2013.                    uiLightningTimer -= diff;
  2014.  
  2015.                if(uiChainLightningTimer <= diff)
  2016.                {
  2017.                    if(!InLightningChannel)
  2018.                        DoCast(me->getVictim(), SPELL_RIDERS_CHAIN_LIGHTNING, true);
  2019.                    uiChainLightningTimer = urand(6000, 9000);
  2020.                }
  2021.                else
  2022.                    uiChainLightningTimer -= diff;
  2023.  
  2024.                if(uiMoonfireTimer <= diff)
  2025.                {
  2026.                    if(!InLightningChannel)
  2027.                        DoCast(me->getVictim(), SPELL_RIDERS_MOONFIRE);
  2028.                    uiMoonfireTimer = 5000;
  2029.                }
  2030.                else
  2031.                    uiMoonfireTimer -= diff;
  2032.  
  2033.                if(uiLightningStormTimer <= diff)
  2034.                {
  2035.                    if(!InLightningChannel)
  2036.                    {
  2037.                        me->CastSpell(me->getVictim(), SPELL_RIDERS_STORM, true);
  2038.                        InLightningChannel = true;
  2039.                        uiLightningWaitTimer = 10000;
  2040.                    }
  2041.                    uiLightningStormTimer = urand(20000, 26000);
  2042.                }
  2043.                else
  2044.                    uiLightningStormTimer -= diff;
  2045.  
  2046.                if(InLightningChannel)
  2047.                {
  2048.                    if(uiLightningWaitTimer <= diff)
  2049.                    {
  2050.                        InLightningChannel = false;
  2051.                    }
  2052.                    else
  2053.                        uiLightningWaitTimer -= diff;
  2054.                }
  2055.  
  2056.                if(!InLightningChannel)
  2057.                    DoMeleeAttackIfReady();
  2058.            }
  2059.        };
  2060.  
  2061.        CreatureAI * GetAI(Creature * pCreature) const
  2062.        {
  2063.            return new npc_dm_rider_bruteAI(pCreature);
  2064.        }
  2065. };
  2066.  
  2067. class npc_dm_dragon_final : public CreatureScript
  2068. {
  2069.    public:
  2070.        npc_dm_dragon_final() : CreatureScript("npc_dm_dragon_final") { }
  2071.  
  2072.        struct npc_dm_dragon_finalAI : public ScriptedAI
  2073.        {
  2074.            npc_dm_dragon_finalAI(Creature * c) : ScriptedAI(c), summons(me) { }
  2075.  
  2076.            uint32 uiBerserkTimer;
  2077.            uint32 uiBreathTimer;
  2078.            uint32 uiTailWhipTimer;
  2079.            uint32 uiClawTimer;
  2080.            //uint32 uiFireballBarrageTimer;
  2081.            uint32 uiFlameStrikeTimer;
  2082.            uint32 uiFlightTimer;
  2083.            uint32 uiFlightWaitTimer;
  2084.            uint32 uiLandTimer;
  2085.  
  2086.            uint32 m_Phase;
  2087.            int  FlameStrikeData;
  2088.            bool IsInFlight;
  2089.            bool FireShield;
  2090.            bool canLand;
  2091.  
  2092.            void Reset()
  2093.            {
  2094.                if(!IsCombatMovementAllowed())
  2095.                    SetCombatMovement(true);
  2096.  
  2097.                uiFlightTimer = 10000; // 10s
  2098.                uiClawTimer = urand(3000, 5000);
  2099.                uiTailWhipTimer = urand(12000, 16000);
  2100.                uiBreathTimer = urand(18000, 22000);
  2101.  
  2102.                FlameStrikeData = 0;
  2103.  
  2104.                summons.DespawnAll();
  2105.                IsInFlight = false;
  2106.                FireShield = true;
  2107.                canLand = false;
  2108.            }
  2109.  
  2110.            void EnterCombat(Unit * /* who */)
  2111.            {
  2112.                m_Phase = PHASE_START_COMBAT;
  2113.                uiBerserkTimer = 420000; // 7 Mins
  2114.            }
  2115.  
  2116.            void KilledUnit(Unit * who)
  2117.            {
  2118.                if(who && who->GetTypeId() != TYPEID_PLAYER)
  2119.                    return;
  2120.                isBattleActive = false;
  2121.                m_PlayerGUID = NULL;
  2122.                playerName = "";
  2123.                m_Phase = PHASE_END;
  2124.                summons.DespawnAll();
  2125.                me->DespawnOrUnsummon(1);
  2126.            }
  2127.  
  2128.            void JustDied(Unit * killer)
  2129.            {
  2130.                if(killer && killer->GetTypeId() != TYPEID_PLAYER &&
  2131.                    killer->GetGUID() != m_PlayerGUID)
  2132.                    return;
  2133.                me->PlayDirectSound(SOUND_WAVE_COMPLETE, killer->ToPlayer());
  2134.                m_Phase = PHASE_END;
  2135.                isWaveBossDead = 7;
  2136.            }
  2137.  
  2138.            void MovementInform(uint32 type, uint32 id)
  2139.            {
  2140.                if(type == POINT_MOTION_TYPE)
  2141.                {
  2142.                    switch(id)
  2143.                    {
  2144.                        case 1:
  2145.                            me->SetFacingTo(sMoveData[0].o);
  2146.                            break;
  2147.                    }
  2148.                }
  2149.            }
  2150.  
  2151.            void JustSummoned(Creature * summoned)
  2152.            {
  2153.                summons.Summon(summoned);
  2154.            }
  2155.  
  2156.            void UpdateAI(const uint32 diff)
  2157.            {
  2158.                if(!UpdateVictim() || m_Phase == PHASE_END)
  2159.                    return;
  2160.  
  2161.                if(!isBattleActive)
  2162.                {
  2163.                    summons.DespawnAll();
  2164.                    m_Phase = PHASE_END;
  2165.                    me->DespawnOrUnsummon(1);       
  2166.                    return;
  2167.                }
  2168.  
  2169.                if(m_Phase == PHASE_START_COMBAT)
  2170.                {
  2171.                    if(HealthBelowPct(15) && FireShield) // Doesn't matter if you're flying
  2172.                    {
  2173.                        DoCast(me, SPELL_DRAGON_FIRE_SHIELD, true);
  2174.                        FireShield = false;
  2175.                    }
  2176.  
  2177.                    if(uiClawTimer <= diff)
  2178.                    {
  2179.                        if(!IsInFlight)
  2180.                            DoCast(me->getVictim(), SPELL_DRAGON_CLAW);
  2181.                        uiClawTimer = urand(3000, 5000);
  2182.                    }
  2183.                    else
  2184.                        uiClawTimer -= diff;
  2185.  
  2186.                    if(uiBreathTimer <= diff)
  2187.                    {
  2188.                        if(!IsInFlight)
  2189.                            me->CastSpell(me->getVictim(), SPELL_DRAGON_BREATH, true);
  2190.                        uiBreathTimer = urand(18000, 24000);
  2191.                    }
  2192.                    else
  2193.                        uiBreathTimer -= diff;
  2194.  
  2195.                    if(uiTailWhipTimer <= diff)
  2196.                    {
  2197.                        if(!IsInFlight)
  2198.                            DoCastAOE(SPELL_DRAGON_TAIL_WHIP, false);
  2199.                        uiTailWhipTimer = urand(12000, 16000);
  2200.                    }
  2201.                    else
  2202.                        uiTailWhipTimer -= diff;
  2203.  
  2204.                    if(uiBerserkTimer <= diff)
  2205.                    {
  2206.                        DoCast(me, SPELL_DRAGON_BERSERK);
  2207.                        uiBerserkTimer = 420000;
  2208.                    }
  2209.                    else
  2210.                        uiBerserkTimer -= diff;
  2211.  
  2212.                    if(uiFlightTimer <= diff && !IsInFlight)
  2213.                    {
  2214.                        me->SetCanFly(true);
  2215.                        me->SetSpeed(MOVE_FLIGHT, 1.3f);                    
  2216.                        me->GetMotionMaster()->MovePoint(1, -3786.241943f, 1096.538452f, 153.903366f);                      
  2217.                        FlameStrikeData = 0;
  2218.                        uiFlameStrikeTimer = 6000;
  2219.                        uiFlightWaitTimer = 30000;
  2220.                        IsInFlight = true;
  2221.                        uiFlightTimer = 50000;
  2222.                    }
  2223.                    else
  2224.                        uiFlightTimer -= diff;
  2225.  
  2226.                    if(IsInFlight)
  2227.                    {
  2228.                        if(uiFlameStrikeTimer <= diff)
  2229.                        {
  2230.                            if(FlameStrikeData == 0)
  2231.                            {
  2232.                                me->MonsterTextEmote("The Arena Dragon has a lot of fire inside!", me->getVictim()->GetGUID(), true);
  2233.                                groundTarget = me->SummonGameObject(sMoveData[0].gobject, me->getVictim()->GetPositionX()-3, me->getVictim()->GetPositionY()+6, me->getVictim()->GetPositionZ(),
  2234.                                    me->GetOrientation(), 0, 0, 0, 0, 0);
  2235.                                uiFlameStrikeTimer = 2000;
  2236.                                FlameStrikeData = 1;
  2237.                            }
  2238.                            else if (FlameStrikeData == 1)
  2239.                            {
  2240.                                trigger = me->SummonCreature(NPC_DRAGON_BOSS_TRIGGER, groundTarget->GetPositionX(), groundTarget->GetPositionY(), groundTarget->GetPositionZ(), 0.0f,
  2241.                                    TEMPSUMMON_TIMED_DESPAWN, 3000);
  2242.                                me->CastSpell(trigger->GetPositionX(), trigger->GetPositionY(), trigger->GetPositionZ(), sMoveData[0].spellId, true);
  2243.                                uiFlameStrikeTimer = 2000;
  2244.                                FlameStrikeData = 2;
  2245.                            }
  2246.                            else if (FlameStrikeData == 2)
  2247.                            {
  2248.                                if(groundTarget)
  2249.                                    groundTarget->Delete();
  2250.                                me->MonsterTextEmote("The Arena Dragon has a lot of fire inside!", me->getVictim()->GetGUID(), true);
  2251.                                groundTarget = me->SummonGameObject(sMoveData[0].gobject, me->getVictim()->GetPositionX()-3, me->getVictim()->GetPositionY()-6, me->getVictim()->GetPositionZ(),
  2252.                                    me->GetOrientation(), 0, 0, 0, 0, 0);
  2253.                                uiFlameStrikeTimer = 2000;
  2254.                                FlameStrikeData = 3;
  2255.                            }
  2256.                            else if (FlameStrikeData == 3)
  2257.                            {
  2258.                                trigger = me->SummonCreature(NPC_DRAGON_BOSS_TRIGGER, groundTarget->GetPositionX(), groundTarget->GetPositionY(), groundTarget->GetPositionZ(), 0.0f,
  2259.                                    TEMPSUMMON_TIMED_DESPAWN, 3000);
  2260.                                me->CastSpell(trigger->GetPositionX(), trigger->GetPositionY(), trigger->GetPositionZ(), sMoveData[0].spellId, true);
  2261.                                uiFlameStrikeTimer = 2000;
  2262.                                FlameStrikeData = 4;
  2263.                            }
  2264.                            else if (FlameStrikeData == 4)
  2265.                            {
  2266.                                if(groundTarget)
  2267.                                    groundTarget->Delete();
  2268.                                me->MonsterTextEmote("The Arena Dragon has a lot of fire inside!", me->getVictim()->GetGUID(), true);
  2269.                                groundTarget = me->SummonGameObject(sMoveData[0].gobject, me->getVictim()->GetPositionX()-3, me->getVictim()->GetPositionY()-6, me->getVictim()->GetPositionZ(),
  2270.                                    me->GetOrientation(), 0, 0, 0, 0, 0);
  2271.                                uiFlameStrikeTimer = 2000;
  2272.                                FlameStrikeData = 5;
  2273.                            }
  2274.                            else if (FlameStrikeData == 5)
  2275.                            {
  2276.                                trigger = me->SummonCreature(NPC_DRAGON_BOSS_TRIGGER, groundTarget->GetPositionX(), groundTarget->GetPositionY(), groundTarget->GetPositionZ(), 0.0f,
  2277.                                    TEMPSUMMON_TIMED_DESPAWN, 3000);
  2278.                                me->CastSpell(trigger->GetPositionX(), trigger->GetPositionY(), trigger->GetPositionZ(), sMoveData[0].spellId, true);
  2279.                                uiFlameStrikeTimer = 2000;
  2280.                                FlameStrikeData = 6;
  2281.                            }
  2282.                            else if (FlameStrikeData == 6)
  2283.                            {
  2284.                                if(groundTarget)
  2285.                                    groundTarget->Delete();
  2286.                                me->MonsterTextEmote("The Arena Dragon has a lot of fire inside!", me->getVictim()->GetGUID(), true);
  2287.                                groundTarget = me->SummonGameObject(sMoveData[0].gobject, me->getVictim()->GetPositionX()-3, me->getVictim()->GetPositionY()+6, me->getVictim()->GetPositionZ(),
  2288.                                    me->GetOrientation(), 0, 0, 0, 0, 0);
  2289.                                uiFlameStrikeTimer = 2000;
  2290.                                FlameStrikeData = 7;
  2291.                            }
  2292.                            else if (FlameStrikeData == 7)
  2293.                            {
  2294.                                trigger = me->SummonCreature(NPC_DRAGON_BOSS_TRIGGER, groundTarget->GetPositionX(), groundTarget->GetPositionY(), groundTarget->GetPositionZ(), 0.0f,
  2295.                                    TEMPSUMMON_TIMED_DESPAWN, 3000);
  2296.                                me->CastSpell(trigger->GetPositionX(), trigger->GetPositionY(), trigger->GetPositionZ(), sMoveData[0].spellId, true);
  2297.                                uiFlameStrikeTimer = 2000;
  2298.                                FlameStrikeData = 8;
  2299.                            }
  2300.                            else if (FlameStrikeData == 8)
  2301.                            {
  2302.                                if(groundTarget)
  2303.                                    groundTarget->Delete();
  2304.                                me->MonsterTextEmote("The Arena Dragon has a lot of fire inside!", me->getVictim()->GetGUID(), true);
  2305.                                groundTarget = me->SummonGameObject(sMoveData[0].gobject, me->getVictim()->GetPositionX()-3, me->getVictim()->GetPositionY()+6, me->getVictim()->GetPositionZ(),
  2306.                                    me->GetOrientation(), 0, 0, 0, 0, 0);
  2307.                                uiFlameStrikeTimer = 2000;
  2308.                                FlameStrikeData = 9;
  2309.                            }
  2310.                            else if (FlameStrikeData == 9)
  2311.                            {
  2312.                                trigger = me->SummonCreature(NPC_DRAGON_BOSS_TRIGGER, groundTarget->GetPositionX(), groundTarget->GetPositionY(), groundTarget->GetPositionZ(), 0.0f,
  2313.                                    TEMPSUMMON_TIMED_DESPAWN, 3000);
  2314.                                me->CastSpell(trigger->GetPositionX(), trigger->GetPositionY(), trigger->GetPositionZ(), sMoveData[0].spellId, true);
  2315.                                uiFlameStrikeTimer = 1000;
  2316.                                FlameStrikeData = 10;
  2317.                            }
  2318.                            else if (FlameStrikeData == 10)
  2319.                            {
  2320.                                if(groundTarget)
  2321.                                    groundTarget->Delete();
  2322.                                FlameStrikeData = 11;
  2323.                            }
  2324.                        }
  2325.                        else
  2326.                            uiFlameStrikeTimer -= diff;
  2327.  
  2328.                        if(uiFlightWaitTimer <= diff && !canLand)
  2329.                        {
  2330.                            me->GetMotionMaster()->MovePoint(2, me->GetHomePosition()); // Back Home
  2331.                            canLand = true;
  2332.                            uiLandTimer = 5000;
  2333.                        }
  2334.                        else
  2335.                            uiFlightWaitTimer -= diff;
  2336.  
  2337.                        if(uiLandTimer <= diff && canLand)
  2338.                        {
  2339.                            me->SetCanFly(false);
  2340.                            SetCombatMovement(true);
  2341.                            me->GetMotionMaster()->Clear(false);
  2342.                            IsInFlight = false;
  2343.                            canLand = false;
  2344.                        }
  2345.                        else
  2346.                            uiLandTimer -= diff;
  2347.                    }
  2348.                }
  2349.               if(!IsInFlight)
  2350.                   DoMeleeAttackIfReady();
  2351.            }
  2352.            private:
  2353.                GameObject * groundTarget;
  2354.                Creature * trigger;
  2355.                SummonList summons;
  2356.        };
  2357.  
  2358.        CreatureAI * GetAI(Creature * pCreature) const
  2359.        {
  2360.            return new npc_dm_dragon_finalAI(pCreature);
  2361.        }
  2362. };
  2363.  
  2364. class remove_non_battle_player : public PlayerScript
  2365. {
  2366.    public:
  2367.        remove_non_battle_player() : PlayerScript("remove_non_battle_player") { }
  2368.  
  2369.        void OnUpdateZone(Player * player, uint32 zone, uint32 area)
  2370.        {
  2371.            if(player->GetZoneId() != DIRE_MAUL_ZONE && player->GetAreaId() != DIRE_MAUL_AREA || player->GetSession()->GetSecurity() > 1)
  2372.                return;
  2373.  
  2374.            if(isBattleActive && player->GetGUID() != m_PlayerGUID)
  2375.            {
  2376.                player->TeleportTo(player->GetStartPosition().GetMapId(), player->GetStartPosition().GetPositionX(), player->GetStartPosition().GetPositionY(),
  2377.                   player->GetStartPosition().GetPositionZ(), player->GetStartPosition().GetOrientation());
  2378.                ChatHandler(player).SendSysMessage("You cannot be in the Dire Maul Arena while the event is going on!");
  2379.            }
  2380.        }
  2381. };
  2382.  
  2383. void AddSC_arena_link_battle()
  2384. {
  2385.     /* Npc Classes */
  2386.     new npc_dire_arena_commander;
  2387.     new npc_dire_maul_rb_guard;
  2388.     new npc_red_blood_mini;
  2389.     new npc_dm_wave_trigger;
  2390.     new npc_dm_wave_spawns;
  2391.     new npc_dm_hank_the_tank;
  2392.     new npc_dm_field_medic;
  2393.     new npc_dm_main_rogue;
  2394.     new npc_dm_rogue_initiate;
  2395.     new npc_dm_main_unholy;
  2396.     new npc_dm_unholy_twin;
  2397.     new npc_dm_unholy_pet;
  2398.     new npc_army_ghoul;
  2399.     new npc_dm_rider_guardian;
  2400.     new npc_dm_rider_brute;
  2401.     new npc_dm_dragon_final;
  2402.     /* Player Classes */
  2403.     new remove_non_battle_player;
  2404. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement