Advertisement
Easelm

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

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