Advertisement
Easelm

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

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