Advertisement
Easelm

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

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