Advertisement
Guest User

boss_grand_champions.cpp

a guest
Apr 14th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 41.85 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
  3.  * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify it
  6.  * under the terms of the GNU General Public License as published by the
  7.  * Free Software Foundation; either version 2 of the License, or (at your
  8.  * option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful, but WITHOUT
  11.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12.  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13.  * more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License along
  16.  * with this program. If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. /* ScriptData
  20. SDName: boss_grand_champions
  21. SD%Complete: 50 %
  22. SDComment: Is missing the ai to make the npcs look for a new mount and use it.
  23. SDCategory: Trial Of the Champion
  24. EndScriptData */
  25.  
  26. #include "ScriptMgr.h"
  27. #include "ScriptedCreature.h"
  28. #include "ScriptPCH.h"
  29. #include "ScriptedEscortAI.h"
  30. #include "Vehicle.h"
  31. #include "trial_of_the_champion.h"
  32. #include "Player.h"
  33.  
  34. enum eSpells
  35. {
  36.     //Vehicle
  37.     SPELL_SHIELD_BREAKER            = 62575,
  38.     SPELL_SHIELD                    = 62544,
  39.     SPELL_THRUST                    = 68505,
  40.     SPELL_SHIELD_1                  = 66482,
  41.     SPELL_CHARGE                    = 63010,
  42.     SPELL_DEFEND                    = 62719,
  43.  
  44.     // Marshal Jacob Alerius && Mokra the Skullcrusher || Warrior
  45.     SPELL_MORTAL_STRIKE             = 68783,
  46.     SPELL_MORTAL_STRIKE_H           = 68784,
  47.     SPELL_BLADESTORM                = 63784,
  48.     SPELL_INTERCEPT                 = 67540,
  49.     SPELL_ROLLING_THROW             = 47115, //not implemented in the AI yet...
  50.  
  51.     // Ambrose Boltspark && Eressea Dawnsinger || Mage
  52.     SPELL_FIREBALL                  = 66042,
  53.     SPELL_FIREBALL_H                = 68310,
  54.     SPELL_BLAST_WAVE                = 66044,
  55.     SPELL_BLAST_WAVE_H              = 68312,
  56.     SPELL_HASTE                     = 66045,
  57.     SPELL_POLYMORPH                 = 66043,
  58.     SPELL_POLYMORPH_H               = 68311,
  59.  
  60.     // Colosos && Runok Wildmane || Shaman
  61.     SPELL_CHAIN_LIGHTNING           = 67529,
  62.     SPELL_CHAIN_LIGHTNING_H         = 68319,
  63.     SPELL_EARTH_SHIELD              = 67530,
  64.     SPELL_HEALING_WAVE              = 67528,
  65.     SPELL_HEALING_WAVE_H            = 68318,
  66.     SPELL_HEX_OF_MENDING            = 67534,
  67.  
  68.     // Jaelyne Evensong && Zul'tore || Hunter
  69.     SPELL_DISENGAGE                 = 68340, //not implemented in the AI yet...
  70.     SPELL_LIGHTNING_ARROWS          = 66083,
  71.     SPELL_MULTI_SHOT                = 49047,
  72.     SPELL_SHOOT                     = 65868,
  73.     SPELL_SHOOT_H                   = 67988,
  74.  
  75.     // Lana Stouthammer Evensong && Deathstalker Visceri || Rouge
  76.     SPELL_EVISCERATE                = 67709,
  77.     SPELL_EVISCERATE_H              = 68317,
  78.     SPELL_FAN_OF_KNIVES             = 67706,
  79.     SPELL_POISON_BOTTLE             = 67701,
  80.  
  81.     // Achievement Credit
  82.     SPELL_GRAND_CHAMPIONS_CREDIT    = 68572,
  83. };
  84.  
  85. enum Talk
  86. {
  87.     SAY_CHAMPION_DIED               = 0,
  88.     WARNING_WEAPONS                 = 1,
  89. };
  90.  
  91. enum eSeat
  92. {
  93.     SEAT_ID_0                       = 0
  94. };
  95.  
  96. void AggroAllPlayers(Creature* pTemp)
  97. {
  98.     Map::PlayerList const &PlList = pTemp->GetMap()->GetPlayers();
  99.  
  100.     if (PlList.isEmpty())
  101.         return;
  102.  
  103.     for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
  104.     {
  105.         if (Player* player = i->GetSource())
  106.         {
  107.             if (player->IsGameMaster())
  108.                 continue;
  109.  
  110.             if (player->IsAlive())
  111.             {
  112.                 pTemp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC);
  113.                 pTemp->SetReactState(REACT_AGGRESSIVE);
  114.                 pTemp->SetInCombatWith(player);
  115.                 player->SetInCombatWith(pTemp);
  116.                 pTemp->AddThreat(player, 0.0f);
  117.             }
  118.         }
  119.     }
  120. }
  121.  
  122. bool GrandChampionsOutVehicle(Creature* me)
  123. {
  124.     InstanceScript* pInstance = me->GetInstanceScript();
  125.  
  126.     if (!pInstance)
  127.         return false;
  128.  
  129.     Creature* pGrandChampion1 = Unit::GetCreature(*me, pInstance->GetData64(DATA_GRAND_CHAMPION_1));
  130.     Creature* pGrandChampion2 = Unit::GetCreature(*me, pInstance->GetData64(DATA_GRAND_CHAMPION_2));
  131.     Creature* pGrandChampion3 = Unit::GetCreature(*me, pInstance->GetData64(DATA_GRAND_CHAMPION_3));
  132.  
  133.     if (pGrandChampion1 && pGrandChampion2 && pGrandChampion3)
  134.     {
  135.         if (!pGrandChampion1->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) &&
  136.             !pGrandChampion1->GetVehicle() &&
  137.             !pGrandChampion2->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) &&
  138.             !pGrandChampion2->GetVehicle() &&
  139.             !pGrandChampion3->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) &&
  140.             !pGrandChampion3->GetVehicle())
  141.             return true;
  142.     }
  143.  
  144.     return false;
  145. }
  146.  
  147. /*
  148. * Generic AI for vehicles used by npcs in ToC, it needs more improvements.  *
  149. * Script Complete: 25%.                                                     *
  150. */
  151. class generic_vehicleAI_toc5 : public CreatureScript
  152. {
  153.     public:
  154.         generic_vehicleAI_toc5() : CreatureScript("generic_vehicleAI_toc5") {}
  155.  
  156.     struct generic_vehicleAI_toc5AI : public npc_escortAI
  157.     {
  158.         generic_vehicleAI_toc5AI(Creature* creature) : npc_escortAI(creature)
  159.         {
  160.             hasBeenInCombat = false;
  161.             SetDespawnAtEnd(false);
  162.             uiWaypointPath = 0;
  163.  
  164.             uiCheckTimer = 5000;
  165.             pInstance = creature->GetInstanceScript();
  166.         }
  167.  
  168.         InstanceScript* pInstance;
  169.  
  170.         bool hasBeenInCombat;
  171.         bool combatEntered;
  172.  
  173.         uint32 combatCheckTimer;
  174.         uint32 uiShieldBreakerTimer;
  175.         uint32 uiTimerSpell1;
  176.         uint32 uiTimerSpell2;
  177.         uint32 uiTimerSpell3;
  178.         uint32 uiBuffTimer;
  179.         uint32 uiCheckTimer;
  180.         uint32 uiDefendTimer;
  181.         uint32 uiChargeTimer;
  182.         uint32 uiThrustTimer;
  183.         uint32 uiWaypointPath;
  184.  
  185.         void Reset() OVERRIDE
  186.         {
  187.             combatCheckTimer = 500;
  188.             uiShieldBreakerTimer = 8000;
  189.             uiBuffTimer = urand(30000, 60000);
  190.             uiTimerSpell1 = urand(4000, 10000);
  191.             uiTimerSpell2 = urand(4000, 10000);
  192.             uiTimerSpell3 = urand(1000, 2000);
  193.             uiDefendTimer = urand(30000, 60000);
  194.         }
  195.  
  196.         void SetData(uint32 uiType, uint32 /*uiData8*/) OVERRIDE
  197.         {
  198.             switch (uiType)
  199.             {
  200.                 case 1:
  201.                     AddWaypoint(0, 746.45f, 647.03f, 411.57f);
  202.                     AddWaypoint(1, 771.434f, 642.606f, 411.9f);
  203.                     AddWaypoint(2, 779.807f, 617.535f, 411.716f);
  204.                     AddWaypoint(3, 771.098f, 594.635f, 411.625f);
  205.                     AddWaypoint(4, 746.887f, 583.425f, 411.668f);
  206.                     AddWaypoint(5, 715.176f, 583.782f, 412.394f);
  207.                     AddWaypoint(6, 720.719f, 591.141f, 411.737f);
  208.                     uiWaypointPath = 1;
  209.                     break;
  210.                 case 2:
  211.                     AddWaypoint(0, 746.45f, 647.03f, 411.57f);
  212.                     AddWaypoint(1, 771.434f, 642.606f, 411.9f);
  213.                     AddWaypoint(2, 779.807f, 617.535f, 411.716f);
  214.                     AddWaypoint(3, 771.098f, 594.635f, 411.625f);
  215.                     AddWaypoint(4, 746.887f, 583.425f, 411.668f);
  216.                     AddWaypoint(5, 746.16f, 571.678f, 412.389f);
  217.                     AddWaypoint(6, 746.887f, 583.425f, 411.668f);
  218.                     uiWaypointPath = 2;
  219.                     break;
  220.                 case 3:
  221.                     AddWaypoint(0, 746.45f, 647.03f, 411.57f);
  222.                     AddWaypoint(1, 771.434f, 642.606f, 411.9f);
  223.                     AddWaypoint(2, 779.807f, 617.535f, 411.716f);
  224.                     AddWaypoint(3, 771.098f, 594.635f, 411.625f);
  225.                     AddWaypoint(4, 777.759f, 584.577f, 412.393f);
  226.                     AddWaypoint(5, 772.48f, 592.99f, 411.68f);
  227.                     uiWaypointPath = 3;
  228.                     break;
  229.                 case 4:
  230.                     combatEntered = true;
  231.                     break;
  232.             }
  233.  
  234.             if (uiType <= 3)
  235.                 Start(false, true, 0, NULL);
  236.         }
  237.  
  238.         void WaypointReached(uint32 i) OVERRIDE
  239.         {
  240.             switch (i)
  241.             {
  242.                 case 2:
  243.                     if ((pInstance && uiWaypointPath == 3) || uiWaypointPath == 2)
  244.                         pInstance->SetData(DATA_MOVEMENT_DONE, pInstance->GetData(DATA_MOVEMENT_DONE)+1);
  245.                     break;
  246.                 case 3:
  247.                     //if (pInstance)
  248.                         pInstance->SetData(DATA_MOVEMENT_DONE, pInstance->GetData(DATA_MOVEMENT_DONE)+1);
  249.                     break;
  250.             }
  251.         }
  252.  
  253.         void EnterCombat(Unit* who) OVERRIDE
  254.         {
  255.             hasBeenInCombat = true;
  256.             DoCastSpellDefend();
  257.         }
  258.  
  259.         void DoCastSpellDefend()
  260.         {
  261.             for (uint8 i = 0; i < 3; ++i)
  262.                 DoCast(me, SPELL_DEFEND, true);
  263.         }
  264.  
  265.         void SpellHit(Unit* source, const SpellInfo* spell) OVERRIDE
  266.         {
  267.             uint32 defendAuraStackAmount = 0;
  268.  
  269.             if (me->HasAura(SPELL_DEFEND))
  270.             if (Aura* defendAura = me->GetAura(SPELL_DEFEND))
  271.                 defendAuraStackAmount = defendAura->GetStackAmount();
  272.  
  273.             // Shield-Break by player vehicle
  274.             if (spell->Id == 62575)
  275.             {
  276.                 source->DealDamage(me, uint32(2000 * (1 - 0.3f * defendAuraStackAmount)));
  277.                 source->SendSpellNonMeleeDamageLog(me, 62575, uint32(2000 * (1 - 0.3f * defendAuraStackAmount)), SPELL_SCHOOL_MASK_NORMAL, 0, 0, true, 0, false);
  278.  
  279.                 if (me->HasAura(SPELL_DEFEND))
  280.                     me->RemoveAuraFromStack(SPELL_DEFEND);
  281.             }
  282.  
  283.             // Charge by player vehicle
  284.             if (spell->Id == 68282)
  285.             {
  286.                 source->DealDamage(me, uint32(20000 * (1 - 0.3f * defendAuraStackAmount)));
  287.                 source->SendSpellNonMeleeDamageLog(me, 68282, uint32(20000 * (1 - 0.3f * defendAuraStackAmount)), SPELL_SCHOOL_MASK_NORMAL, 0, 0, true, 0, false);
  288.  
  289.                 if (source->GetMotionMaster())
  290.                     source->GetMotionMaster()->MoveCharge(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
  291.  
  292.                 if (me->HasAura(SPELL_DEFEND))
  293.                     me->RemoveAuraFromStack(SPELL_DEFEND);
  294.             }
  295.         }
  296.  
  297.         bool StayInCombatAndCleanup(bool combat, bool cleanup)
  298.         {
  299.             if (me->GetMap())
  300.             {
  301.                 Map::PlayerList const& players = me->GetMap()->GetPlayers();
  302.                 bool foundtarget = false;
  303.  
  304.                 if (me->GetMap()->IsDungeon() && !players.isEmpty())
  305.                 {
  306.                     for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  307.                     {
  308.                         Player* player = itr->GetSource();
  309.                         if (player && !player->IsGameMaster() && player->IsAlive())
  310.                         {
  311.                             // Handle combat variable
  312.                             if (combat)
  313.                             {
  314.                                 if (combatEntered)
  315.                                 {
  316.                                     me->SetInCombatWith(player);
  317.                                     player->SetInCombatWith(me);
  318.                                     me->AddThreat(player, 0.0f);
  319.  
  320.                                     foundtarget = true;
  321.  
  322.                                     if (Vehicle* pVehicle = player->GetVehicle())
  323.                                     {
  324.                                         if (Unit* vehicleCreature = pVehicle->GetBase())
  325.                                         {
  326.                                             me->SetInCombatWith(vehicleCreature);
  327.                                             vehicleCreature->SetInCombatWith(me);
  328.                                             me->AddThreat(vehicleCreature, 0.0f);
  329.                                         }
  330.                                     }
  331.                                 }
  332.                             }
  333.  
  334.                             // Handle cleanup variable
  335.                             if (cleanup)
  336.                             if (player->HasAura(SPELL_DEFEND))
  337.                                 player->RemoveAurasDueToSpell(SPELL_DEFEND);
  338.                         }
  339.                     }
  340.                 }
  341.  
  342.                 if (combatEntered && combat && !foundtarget)
  343.                 {
  344.                     me->SetFullHealth();
  345.                     return false;
  346.                 }
  347.             }
  348.  
  349.             return true;
  350.         }
  351.  
  352.         void EnterEvadeMode()
  353.         {
  354.             // Try to stay in combat, otherwise reset
  355.             if (!StayInCombatAndCleanup(true, false))
  356.                 ScriptedAI::EnterEvadeMode();
  357.         }
  358.  
  359.         bool CheckPlayersAlive()
  360.         {
  361.             Map* pMap = me->GetMap();
  362.             if (pMap && pMap->IsDungeon())
  363.             {
  364.                 Map::PlayerList const &players = pMap->GetPlayers();
  365.                 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  366.                 {
  367.                     if (itr->GetSource() && itr->GetSource()->IsAlive() && !itr->GetSource()->IsGameMaster())
  368.                         return true;
  369.                 }
  370.             }
  371.  
  372.             return false;
  373.         }
  374.  
  375.         void DoCastSpellShield()
  376.         {
  377.             for (uint8 i = 0; i < 3; ++i)
  378.                 DoCast(me, SPELL_SHIELD, true);
  379.         }
  380.  
  381.         void UpdateAI(uint32 uiDiff) OVERRIDE
  382.         {
  383.             // Try to keep players clean of defend aura
  384.             if (combatEntered)
  385.             {
  386.                 if (combatCheckTimer <= uiDiff)
  387.                 {
  388.                     StayInCombatAndCleanup(false, true);
  389.                     combatCheckTimer = 1000;
  390.                 }
  391.                 else
  392.                     combatCheckTimer -= uiDiff;
  393.             }
  394.  
  395.             npc_escortAI::UpdateAI(uiDiff);
  396.  
  397.             if (!UpdateVictim())
  398.                 return;
  399.  
  400.             if (uiDefendTimer <= uiDiff)
  401.             {
  402.                 DoCastSpellDefend();
  403.                 uiDefendTimer = urand(30000, 45000);
  404.             }
  405.             else
  406.                 uiDefendTimer -= uiDiff;
  407.  
  408.             if (uiShieldBreakerTimer <= uiDiff)
  409.             {
  410.                 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  411.                 {
  412.                     if (target->GetTypeId() == TYPEID_PLAYER && me->GetDistance(target) > 10.0f && me->GetDistance(target) < 30.0f)
  413.                     {
  414.                         if (target->GetVehicle())
  415.                         {
  416.                             if (Unit* vehTarget = target->GetVehicle()->GetBase())
  417.                             {
  418.                                 DoCast(vehTarget, SPELL_SHIELD_BREAKER);
  419.                                 vehTarget->RemoveAuraFromStack(SPELL_DEFEND);
  420.                             }
  421.                         }
  422.                     }
  423.                     else
  424.                     if (target->GetTypeId() == TYPEID_UNIT && me->GetDistance(target) > 8.0f && me->GetDistance(target) < 25.0f)
  425.                     {
  426.                         DoCast(target, SPELL_SHIELD_BREAKER);
  427.                         target->RemoveAuraFromStack(SPELL_DEFEND);
  428.                     }
  429.                 }
  430.  
  431.                 uiShieldBreakerTimer = urand(15000, 20000);
  432.             }
  433.             else
  434.                 uiShieldBreakerTimer -= uiDiff;
  435.  
  436.             if (uiChargeTimer <= uiDiff)
  437.             {
  438.                 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  439.                 {
  440.                     if (target->GetTypeId() == TYPEID_PLAYER && me->GetDistance(target) > 8.0f && me->GetDistance(target) < 25.0f)
  441.                     {
  442.                         if (target->GetVehicle())
  443.                         {
  444.                             if (Unit* vehTarget = target->GetVehicle()->GetBase())
  445.                             {
  446.                                 DoCast(vehTarget, SPELL_CHARGE);
  447.  
  448.                                 if (vehTarget->HasAura(SPELL_DEFEND))
  449.                                     vehTarget->RemoveAuraFromStack(SPELL_DEFEND);
  450.                             }
  451.                         }
  452.                     }
  453.                     else
  454.                     if (target->GetTypeId() == TYPEID_UNIT && me->GetDistance(target) > 8.0f && me->GetDistance(target) < 25.0f)
  455.                     {
  456.                         DoCast(target, SPELL_CHARGE);
  457.  
  458.                         if (target->HasAura(SPELL_DEFEND))
  459.                             target->RemoveAuraFromStack(SPELL_DEFEND);
  460.                     }
  461.                 }
  462.  
  463.                 uiChargeTimer = urand(10000, 30000);
  464.             }
  465.             else
  466.                 uiChargeTimer -= uiDiff;
  467.  
  468.             if (uiThrustTimer <= uiDiff)
  469.             {
  470.                 if (me->GetVictim() && me->GetDistance(me->GetVictim()) < 5.0f)
  471.                     DoCast(me->GetVictim(), SPELL_THRUST);
  472.  
  473.                 uiThrustTimer = urand(8000, 14000);
  474.             }
  475.             else
  476.                 uiThrustTimer -= uiDiff;
  477.  
  478.             DoMeleeAttackIfReady();
  479.         }
  480.     };
  481.  
  482.     CreatureAI* GetAI(Creature* creature) const OVERRIDE
  483.     {
  484.         return GetInstanceAI<generic_vehicleAI_toc5AI>(creature);
  485.     }
  486. };
  487.  
  488. // Marshal Jacob Alerius && Mokra the Skullcrusher || Warrior
  489. class boss_warrior_toc5 : public CreatureScript
  490. {
  491.     public:
  492.         boss_warrior_toc5() : CreatureScript("boss_warrior_toc5") {}
  493.  
  494.     struct boss_warrior_toc5AI : public BossAI
  495.     {
  496.         boss_warrior_toc5AI(Creature* creature) : BossAI(creature, BOSS_GRAND_CHAMPIONS)
  497.         {
  498.             pInstance = creature->GetInstanceScript();
  499.  
  500.             bDone = false;
  501.             bHome = false;
  502.             bCredit = false;
  503.             hasBeenInCombat = false;
  504.  
  505.             uiPhase = 0;
  506.             uiPhaseTimer = 0;
  507.  
  508.             //me->SetReactState(REACT_PASSIVE);
  509.             // THIS IS A HACK, SHOULD BE REMOVED WHEN THE EVENT IS FULL SCRIPTED
  510.             //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  511.         }
  512.  
  513.         InstanceScript* pInstance;
  514.  
  515.         uint8 uiPhase;
  516.         uint32 uiPhaseTimer;
  517.  
  518.         uint32 uiBladeStormTimer;
  519.         uint32 uiInterceptTimer;
  520.         uint32 uiMortalStrikeTimer;
  521.         uint32 uiAttackTimer;
  522.  
  523.         bool bDone;
  524.         bool bHome;
  525.         bool bCredit;
  526.         bool hasBeenInCombat;
  527.  
  528.         void Reset() OVERRIDE
  529.         {
  530.             uiBladeStormTimer = urand(15000, 20000);
  531.             uiInterceptTimer  = 7000;
  532.             uiMortalStrikeTimer = urand(8000, 12000);
  533.         }
  534.  
  535.         void JustReachedHome() OVERRIDE
  536.         {
  537.             ScriptedAI::JustReachedHome();
  538.  
  539.             if (!bHome)
  540.                 return;
  541.  
  542.             uiPhaseTimer = 15000;
  543.             uiPhase = 1;
  544.  
  545.             bHome = false;
  546.         }
  547.  
  548.         void EnterCombat(Unit* who) OVERRIDE
  549.         {
  550.             _EnterCombat();
  551.             hasBeenInCombat = true;
  552.         }
  553.  
  554.         void UpdateAI(uint32 uiDiff) OVERRIDE
  555.         {
  556.             if (!bDone && GrandChampionsOutVehicle(me))
  557.             {
  558.                 bDone = true;
  559.  
  560.                 Talk(WARNING_WEAPONS);
  561.                 me->RemoveAura(64723); // [DND] ReadyJoust Pose Effect
  562.  
  563.                 if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_1))
  564.                     me->SetHomePosition(739.678f, 662.541f, 413.395f, 4.49f);
  565.                 else
  566.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_2))
  567.                         me->SetHomePosition(746.71f, 661.02f, 412.695f, 4.6f);
  568.                 else
  569.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_3))
  570.                         me->SetHomePosition(754.34f, 660.70f, 413.395f, 4.79f);
  571.  
  572.                 EnterEvadeMode();
  573.                 bHome = true;
  574.             }
  575.  
  576.             if (uiPhaseTimer <= uiDiff)
  577.             {
  578.                 if (uiPhase == 1)
  579.                 {
  580.                     AggroAllPlayers(me);
  581.                     uiPhase = 0;
  582.                 }
  583.             }
  584.             else
  585.                 uiPhaseTimer -= uiDiff;
  586.  
  587.             if (!UpdateVictim() || me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) || me->GetVehicle())
  588.                 return;
  589.  
  590.             if (uiInterceptTimer <= uiDiff)
  591.             {
  592.                 Map::PlayerList const& players = me->GetMap()->GetPlayers();
  593.                 if (me->GetMap()->IsDungeon() && !players.isEmpty())
  594.                 {
  595.                     for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  596.                     {
  597.                         Player* player = itr->GetSource();
  598.                         if (player && !player->IsGameMaster() && me->IsInRange(player, 8.0f, 25.0f, false))
  599.                         {
  600.                             DoResetThreat();
  601.                             me->AddThreat(player, 5.0f);
  602.                             DoCast(player, SPELL_INTERCEPT);
  603.                             break;
  604.                         }
  605.                     }
  606.                 }
  607.  
  608.                 uiInterceptTimer = 7000;
  609.             }
  610.             else
  611.                 uiInterceptTimer -= uiDiff;
  612.  
  613.             if (uiBladeStormTimer <= uiDiff)
  614.             {
  615.                 DoCastVictim(SPELL_BLADESTORM);
  616.                 uiBladeStormTimer = urand(15000, 25000);
  617.             }
  618.             else
  619.                 uiBladeStormTimer -= uiDiff;
  620.  
  621.             if (uiMortalStrikeTimer <= uiDiff)
  622.             {
  623.                 DoCastVictim(DUNGEON_MODE(SPELL_MORTAL_STRIKE, SPELL_MORTAL_STRIKE_H));
  624.                 uiMortalStrikeTimer = urand(8000, 12000);
  625.             }
  626.             else
  627.                 uiMortalStrikeTimer -= uiDiff;
  628.  
  629.             DoMeleeAttackIfReady();
  630.         }
  631.  
  632.         void DamageTaken(Unit* /*who*/, uint32& damage)
  633.         {
  634.             if (damage >= me->GetHealth())
  635.             {
  636.                 Talk(SAY_CHAMPION_DIED);
  637.                 // Instance encounter counting mechanics
  638.                 if (!bCredit)
  639.                 {
  640.                     bCredit = true;
  641.                     HandleSpellOnPlayersInInstanceToC5(me, SPELL_GRAND_CHAMPIONS_CREDIT);
  642.                 }
  643.  
  644.                 EnterEvadeMode();
  645.                 //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  646.                 me->setFaction(35);
  647.                 me->GetMotionMaster()->MovePoint(0, 746.843f, 695.68f, 412.339f);
  648.             }
  649.         }
  650.  
  651.         void JustDied(Unit* /*killer*/) OVERRIDE
  652.         {
  653.             instance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
  654.         }
  655.     };
  656.  
  657.     CreatureAI* GetAI(Creature* creature) const OVERRIDE
  658.     {
  659.         return GetInstanceAI<boss_warrior_toc5AI>(creature);
  660.     }
  661. };
  662.  
  663. // Ambrose Boltspark && Eressea Dawnsinger || Mage
  664. class boss_mage_toc5 : public CreatureScript
  665. {
  666.     public:
  667.         boss_mage_toc5() : CreatureScript("boss_mage_toc5") {}
  668.  
  669.     struct boss_mage_toc5AI : public BossAI
  670.     {
  671.         boss_mage_toc5AI(Creature* creature) : BossAI(creature, BOSS_GRAND_CHAMPIONS)
  672.         {
  673.             pInstance = creature->GetInstanceScript();
  674.  
  675.             bDone = false;
  676.             bHome = false;
  677.             bCredit = false;
  678.  
  679.             hasBeenInCombat = false;
  680.  
  681.             uiPhase = 0;
  682.             uiPhaseTimer = 0;
  683.  
  684.             //me->SetReactState(REACT_PASSIVE);
  685.             // THIS IS A HACK, SHOULD BE REMOVED WHEN THE EVENT IS FULL SCRIPTED
  686.             //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  687.         }
  688.  
  689.         InstanceScript* pInstance;
  690.  
  691.         uint8 uiPhase;
  692.         uint32 uiPhaseTimer;
  693.  
  694.         uint32 uiFireBallTimer;
  695.         uint32 uiBlastWaveTimer;
  696.         uint32 uiHasteTimer;
  697.         uint32 uiPolymorphTimer;
  698.  
  699.         bool bDone;
  700.         bool bHome;
  701.  
  702.         bool hasBeenInCombat;
  703.         bool bCredit;
  704.  
  705.         void Reset() OVERRIDE
  706.         {
  707.             uiFireBallTimer = 5000;
  708.             uiPolymorphTimer  = 8000;
  709.             uiBlastWaveTimer = 12000;
  710.             uiHasteTimer = 22000;
  711.         }
  712.  
  713.         void JustReachedHome() OVERRIDE
  714.         {
  715.             ScriptedAI::JustReachedHome();
  716.  
  717.             if (!bHome)
  718.                 return;
  719.  
  720.             uiPhaseTimer = 15000;
  721.             uiPhase = 1;
  722.  
  723.             bHome = false;
  724.         }
  725.  
  726.         void EnterCombat(Unit* who) OVERRIDE
  727.         {
  728.             _EnterCombat();
  729.             hasBeenInCombat = true;
  730.         }
  731.  
  732.        void UpdateAI(uint32 uiDiff) OVERRIDE
  733.         {
  734.             if (!bDone && GrandChampionsOutVehicle(me))
  735.             {
  736.                 bDone = true;
  737.                 me->RemoveAura(64723); // [DND] ReadyJoust Pose Effect
  738.  
  739.                 if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_1))
  740.                     me->SetHomePosition(739.678f, 662.541f, 413.395f, 4.49f);
  741.                 else
  742.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_2))
  743.                         me->SetHomePosition(746.71f, 661.02f, 412.695f, 4.6f);
  744.                 else
  745.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_3))
  746.                         me->SetHomePosition(754.34f, 660.70f, 413.395f, 4.79f);
  747.  
  748.                 if (pInstance)
  749.                     pInstance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
  750.  
  751.                 EnterEvadeMode();
  752.                 bHome = true;
  753.             }
  754.  
  755.             if (uiPhaseTimer <= uiDiff)
  756.             {
  757.                 if (uiPhase == 1)
  758.                 {
  759.                     AggroAllPlayers(me);
  760.                     uiPhase = 0;
  761.                 }
  762.             }
  763.             else
  764.                 uiPhaseTimer -= uiDiff;
  765.  
  766.             if (!UpdateVictim() || me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) || me->GetVehicle())
  767.                 return;
  768.  
  769.             if (uiFireBallTimer <= uiDiff)
  770.             {
  771.                 DoCastVictim(DUNGEON_MODE(SPELL_FIREBALL, SPELL_FIREBALL_H));
  772.                 uiFireBallTimer = 17000;
  773.             }
  774.             else
  775.                 uiFireBallTimer -= uiDiff;
  776.  
  777.             if (uiPolymorphTimer <= uiDiff)
  778.             {
  779.                 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  780.                     DoCast(target, DUNGEON_MODE(SPELL_POLYMORPH, SPELL_POLYMORPH_H));
  781.                 uiPolymorphTimer = 22000;
  782.             }
  783.             else
  784.                 uiPolymorphTimer -= uiDiff;
  785.  
  786.             if (uiBlastWaveTimer <= uiDiff)
  787.             {
  788.                 DoCastAOE(DUNGEON_MODE(SPELL_BLAST_WAVE, SPELL_BLAST_WAVE_H), false);
  789.                 uiBlastWaveTimer = 30000;
  790.             }
  791.             else
  792.                 uiBlastWaveTimer -= uiDiff;
  793.  
  794.             if (uiHasteTimer <= uiDiff)
  795.             {
  796.                 me->InterruptNonMeleeSpells(true);
  797.  
  798.                 DoCast(me, SPELL_HASTE);
  799.                 uiHasteTimer = 40000;
  800.             }
  801.             else
  802.                 uiHasteTimer -= uiDiff;
  803.  
  804.             DoMeleeAttackIfReady();
  805.         }
  806.  
  807.         void DamageTaken(Unit* /*who*/, uint32& damage)
  808.         {
  809.             if (damage >= me->GetHealth())
  810.             {
  811.                 // Instance encounter counting mechanics
  812.                 if (!bCredit)
  813.                 {
  814.                     bCredit = true;
  815.                     HandleSpellOnPlayersInInstanceToC5(me, SPELL_GRAND_CHAMPIONS_CREDIT);
  816.                 }
  817.  
  818.                 EnterEvadeMode();
  819.                 //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  820.                 me->setFaction(35);
  821.                 me->GetMotionMaster()->MovePoint(0, 746.843f, 695.68f, 412.339f);
  822.             }
  823.         }
  824.  
  825.         void JustDied(Unit* /*killer*/) OVERRIDE
  826.         {
  827.             hasBeenInCombat = false;
  828.             Talk(SAY_CHAMPION_DIED);
  829.             if (pInstance)
  830.                 pInstance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
  831.         }
  832.     };
  833.  
  834.     CreatureAI* GetAI(Creature* creature) const OVERRIDE
  835.     {
  836.         return GetInstanceAI<boss_mage_toc5AI>(creature);
  837.     };
  838. };
  839.  
  840. // Colosos && Runok Wildmane || Shaman
  841. class boss_shaman_toc5 : public CreatureScript
  842. {
  843.     public:
  844.         boss_shaman_toc5() : CreatureScript("boss_shaman_toc5") {}
  845.  
  846.     struct boss_shaman_toc5AI : public BossAI
  847.     {
  848.         boss_shaman_toc5AI(Creature* creature) : BossAI(creature, BOSS_GRAND_CHAMPIONS)
  849.         {
  850.             pInstance = creature->GetInstanceScript();
  851.  
  852.             bDone = false;
  853.             bHome = false;
  854.             bCredit = false;
  855.  
  856.             hasBeenInCombat = false;
  857.  
  858.             uiPhase = 0;
  859.             uiPhaseTimer = 0;
  860.  
  861.             //me->SetReactState(REACT_PASSIVE);
  862.             // THIS IS A HACK, SHOULD BE REMOVED WHEN THE EVENT IS FULL SCRIPTED
  863.             //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  864.         }
  865.  
  866.         InstanceScript* pInstance;
  867.  
  868.         uint8 uiPhase;
  869.         uint32 uiPhaseTimer;
  870.  
  871.         uint32 uiChainLightningTimer;
  872.         uint32 uiEartShieldTimer;
  873.         uint32 uiHealingWaveTimer;
  874.         uint32 uiHexMendingTimer;
  875.  
  876.         bool bDone;
  877.         bool bHome;
  878.         bool hasBeenInCombat;
  879.         bool bCredit;
  880.  
  881.         void Reset() OVERRIDE
  882.         {
  883.             uiChainLightningTimer = 16000;
  884.             uiHealingWaveTimer = 12000;
  885.             uiEartShieldTimer = urand(30000, 35000);
  886.             uiHexMendingTimer = urand(20000, 25000);
  887.         }
  888.  
  889.         void EnterCombat(Unit* who) OVERRIDE
  890.         {
  891.             _EnterCombat();
  892.             hasBeenInCombat = true;
  893.             DoCast(me, SPELL_EARTH_SHIELD);
  894.             DoCast(who, SPELL_HEX_OF_MENDING);
  895.         };
  896.  
  897.         void JustReachedHome() OVERRIDE
  898.         {
  899.             ScriptedAI::JustReachedHome();
  900.  
  901.             if (!bHome)
  902.                 return;
  903.  
  904.             uiPhaseTimer = 15000;
  905.             uiPhase = 1;
  906.  
  907.             bHome = false;
  908.         }
  909.  
  910.         void UpdateAI(uint32 uiDiff) OVERRIDE
  911.         {
  912.             if (!bDone && GrandChampionsOutVehicle(me))
  913.             {
  914.                 bDone = true;
  915.  
  916.                 me->RemoveAura(64723); // [DND] ReadyJoust Pose Effect
  917.  
  918.                 if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_1))
  919.                     me->SetHomePosition(739.678f, 662.541f, 413.395f, 4.49f);
  920.                 else
  921.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_2))
  922.                         me->SetHomePosition(746.71f, 661.02f, 412.695f, 4.6f);
  923.                 else
  924.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_3))
  925.                         me->SetHomePosition(754.34f, 660.70f, 413.395f, 4.79f);
  926.  
  927.                 if (pInstance)
  928.                     pInstance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
  929.  
  930.                 EnterEvadeMode();
  931.                 bHome = true;
  932.             }
  933.  
  934.             if (uiPhaseTimer <= uiDiff)
  935.             {
  936.                 if (uiPhase == 1)
  937.                 {
  938.                     AggroAllPlayers(me);
  939.                     uiPhase = 0;
  940.                 }
  941.             }
  942.             else
  943.                 uiPhaseTimer -= uiDiff;
  944.  
  945.             if (!UpdateVictim() || me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) || me->GetVehicle())
  946.                 return;
  947.  
  948.             if (uiChainLightningTimer <= uiDiff)
  949.             {
  950.                 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  951.                     DoCast(target, DUNGEON_MODE(SPELL_CHAIN_LIGHTNING, SPELL_CHAIN_LIGHTNING_H));
  952.  
  953.                 uiChainLightningTimer = 23000;
  954.             }
  955.             else
  956.                 uiChainLightningTimer -= uiDiff;
  957.  
  958.             if (uiHealingWaveTimer <= uiDiff)
  959.             {
  960.                 bool bChance = urand(0, 1);
  961.  
  962.                 if (!bChance)
  963.                 {
  964.                     if (Unit* pFriend = DoSelectLowestHpFriendly(40))
  965.                         DoCast(pFriend, DUNGEON_MODE(SPELL_HEALING_WAVE, SPELL_HEALING_WAVE_H));
  966.                 }
  967.                 else
  968.                     DoCast(me, DUNGEON_MODE(SPELL_HEALING_WAVE, SPELL_HEALING_WAVE_H));
  969.  
  970.                 uiHealingWaveTimer = 19000;
  971.             }
  972.             else
  973.                 uiHealingWaveTimer -= uiDiff;
  974.  
  975.             if (uiEartShieldTimer <= uiDiff)
  976.             {
  977.                 DoCast(me, SPELL_EARTH_SHIELD);
  978.  
  979.                 uiEartShieldTimer = urand(40000, 45000);
  980.             }
  981.             else
  982.                 uiEartShieldTimer -= uiDiff;
  983.  
  984.             if (uiHexMendingTimer <= uiDiff)
  985.             {
  986.                 DoCastVictim(SPELL_HEX_OF_MENDING, true);
  987.  
  988.                 uiHexMendingTimer = urand(30000, 35000);
  989.             }
  990.             else
  991.                 uiHexMendingTimer -= uiDiff;
  992.  
  993.             DoMeleeAttackIfReady();
  994.         }
  995.  
  996.         void DamageTaken(Unit* /*who*/, uint32& damage)
  997.         {
  998.             if (damage >= me->GetHealth())
  999.             {
  1000.                 // Instance encounter counting mechanics
  1001.                 if (!bCredit)
  1002.                 {
  1003.                     bCredit = true;
  1004.                     HandleSpellOnPlayersInInstanceToC5(me, SPELL_GRAND_CHAMPIONS_CREDIT);
  1005.                 }
  1006.  
  1007.                 EnterEvadeMode();
  1008.                 //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1009.                 me->setFaction(35);
  1010.                 me->GetMotionMaster()->MovePoint(0, 746.843f, 695.68f, 412.339f);
  1011.             }
  1012.         }
  1013.  
  1014.         void JustDied(Unit* /*killer*/) OVERRIDE
  1015.         {
  1016.             hasBeenInCombat = false;
  1017.             Talk(SAY_CHAMPION_DIED);
  1018.  
  1019.             if (pInstance)
  1020.                 pInstance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
  1021.  
  1022.             //what a nonsense! -.-
  1023.             if (GameObject* pGO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1)))
  1024.                 pInstance->HandleGameObject(pGO->GetGUID(), true);
  1025.         }
  1026.     };
  1027.  
  1028.     CreatureAI* GetAI(Creature* creature) const OVERRIDE
  1029.     {
  1030.         return GetInstanceAI<boss_shaman_toc5AI>(creature);
  1031.     }
  1032. };
  1033.  
  1034. // Jaelyne Evensong && Zul'tore || Hunter
  1035. class boss_hunter_toc5 : public CreatureScript
  1036. {
  1037.     public:
  1038.         boss_hunter_toc5() : CreatureScript("boss_hunter_toc5") {}
  1039.  
  1040.     struct boss_hunter_toc5AI : public BossAI
  1041.     {
  1042.         boss_hunter_toc5AI(Creature* creature) : BossAI(creature, BOSS_GRAND_CHAMPIONS)
  1043.         {
  1044.             pInstance = creature->GetInstanceScript();
  1045.  
  1046.             bDone = false;
  1047.             bHome = false;
  1048.             hasBeenInCombat = false;
  1049.             bCredit = false;
  1050.  
  1051.             uiPhase = 0;
  1052.             uiPhaseTimer = 0;
  1053.  
  1054.             //me->SetReactState(REACT_PASSIVE);
  1055.             // THIS IS A HACK, SHOULD BE REMOVED WHEN THE EVENT IS FULL SCRIPTED
  1056.             //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1057.         }
  1058.  
  1059.         InstanceScript* pInstance;
  1060.  
  1061.         uint8 uiPhase;
  1062.         uint32 uiPhaseTimer;
  1063.  
  1064.         uint32 uiShootTimer;
  1065.         uint32 uiDisengageCooldown;
  1066.         uint32 uiMultiShotTimer;
  1067.         uint32 uiLightningArrowsTimer;
  1068.  
  1069.         uint64 uiTargetGUID;
  1070.  
  1071.         bool bShoot;
  1072.         bool bDone;
  1073.         bool bHome;
  1074.         bool hasBeenInCombat;
  1075.         bool bCredit;
  1076.  
  1077.         void Reset() OVERRIDE
  1078.         {
  1079.             uiShootTimer = 12000;
  1080.             uiMultiShotTimer = 0;
  1081.             uiLightningArrowsTimer = 7000;
  1082.             uiDisengageCooldown = 10000;
  1083.  
  1084.             uiTargetGUID = 0;
  1085.  
  1086.             bShoot = false;
  1087.             Map* pMap = me->GetMap();
  1088.             if (hasBeenInCombat && pMap && pMap->IsDungeon())
  1089.             {
  1090.                 Map::PlayerList const &players = pMap->GetPlayers();
  1091.                 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  1092.                 {
  1093.                     if (itr->GetSource() && itr->GetSource()->IsAlive() && !itr->GetSource()->IsGameMaster())
  1094.                         return;
  1095.                 }
  1096.  
  1097.                 if (pInstance)
  1098.                     pInstance->SetData(BOSS_GRAND_CHAMPIONS, FAIL);
  1099.                 if (pInstance)
  1100.                 {
  1101.                     GameObject* GO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1));
  1102.                     if(GO)
  1103.                         pInstance->HandleGameObject(GO->GetGUID(), true);
  1104.                 }
  1105.  
  1106.                 me->RemoveFromWorld();
  1107.             }
  1108.         }
  1109.  
  1110.         void JustReachedHome() OVERRIDE
  1111.         {
  1112.             ScriptedAI::JustReachedHome();
  1113.  
  1114.             if (!bHome)
  1115.                 return;
  1116.  
  1117.             uiPhaseTimer = 15000;
  1118.             uiPhase = 1;
  1119.  
  1120.             bHome = false;
  1121.         }
  1122.  
  1123.         void EnterCombat(Unit* who) OVERRIDE
  1124.         {
  1125.             _EnterCombat();
  1126.             hasBeenInCombat = true;
  1127.         }
  1128.  
  1129.         void UpdateAI(uint32 uiDiff) OVERRIDE
  1130.         {
  1131.             if (!bDone && GrandChampionsOutVehicle(me))
  1132.             {
  1133.                 bDone = true;
  1134.  
  1135.                 me->RemoveAura(64723); // [DND] ReadyJoust Pose Effect
  1136.  
  1137.                 if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_1))
  1138.                     me->SetHomePosition(739.678f, 662.541f, 413.395f, 4.49f);
  1139.                 else
  1140.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_2))
  1141.                         me->SetHomePosition(746.71f, 661.02f, 412.695f, 4.6f);
  1142.                 else
  1143.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_3))
  1144.                         me->SetHomePosition(754.34f, 660.70f, 413.395f, 4.79f);
  1145.  
  1146.                 if (pInstance)
  1147.                     pInstance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
  1148.  
  1149.                 EnterEvadeMode();
  1150.                 bHome = true;
  1151.             }
  1152.  
  1153.             if (uiPhaseTimer <= uiDiff)
  1154.             {
  1155.                 if (uiPhase == 1)
  1156.                 {
  1157.                     AggroAllPlayers(me);
  1158.                     uiPhase = 0;
  1159.                 }
  1160.             }
  1161.             else
  1162.                 uiPhaseTimer -= uiDiff;
  1163.  
  1164.             if (!UpdateVictim() || me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) || me->GetVehicle())
  1165.                 return;
  1166.  
  1167.             if (uiDisengageCooldown <= uiDiff)
  1168.             {
  1169.                 if (me->IsWithinDistInMap(me->GetVictim(), 5) && uiDisengageCooldown == 0)
  1170.                 {
  1171.                     DoCast(me, SPELL_DISENGAGE);
  1172.                     uiDisengageCooldown = 35000;
  1173.                 }
  1174.                 uiDisengageCooldown = 20000;
  1175.             }
  1176.             else
  1177.                 uiDisengageCooldown -= uiDiff;
  1178.  
  1179.             if (uiLightningArrowsTimer <= uiDiff)
  1180.             {
  1181.                 DoCastAOE(SPELL_LIGHTNING_ARROWS, false);
  1182.                 uiLightningArrowsTimer = 15000;
  1183.  
  1184.             }
  1185.             else
  1186.                 uiLightningArrowsTimer -= uiDiff;
  1187.  
  1188.             if (uiShootTimer <= uiDiff)
  1189.             {
  1190.                 if (Unit* target = SelectTarget(SELECT_TARGET_FARTHEST, 0, 30.0f))
  1191.                 {
  1192.                     uiTargetGUID = target->GetGUID();
  1193.                     DoCast(target, DUNGEON_MODE(SPELL_SHOOT, SPELL_SHOOT_H));
  1194.                 }
  1195.                
  1196.                 uiShootTimer = 19000;
  1197.                 bShoot = true;
  1198.             }
  1199.             else
  1200.                 uiShootTimer -= uiDiff;
  1201.  
  1202.             if (bShoot && uiMultiShotTimer <= uiDiff)
  1203.             {
  1204.                 me->InterruptNonMeleeSpells(true);
  1205.                 Unit* target = Unit::GetUnit(*me, uiTargetGUID);
  1206.  
  1207.                 if (target && me->IsInRange(target, 5.0f, 30.0f, false))
  1208.                 {
  1209.                     DoCast(target, SPELL_MULTI_SHOT);
  1210.                 }
  1211.                 else
  1212.                 {
  1213.                     Map::PlayerList const& players = me->GetMap()->GetPlayers();
  1214.                     if (me->GetMap()->IsDungeon() && !players.isEmpty())
  1215.                     {
  1216.                         for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  1217.                         {
  1218.                             Player* player = itr->GetSource();
  1219.                             if (player && !player->IsGameMaster() && me->IsInRange(player, 5.0f, 30.0f, false))
  1220.                             {
  1221.                                 DoCast(target, SPELL_MULTI_SHOT);
  1222.                                 break;
  1223.                             }
  1224.                         }
  1225.                     }
  1226.                 }
  1227.  
  1228.                 bShoot = false;
  1229.             }
  1230.             else
  1231.                 uiMultiShotTimer -= uiDiff;
  1232.  
  1233.             DoMeleeAttackIfReady();
  1234.         }
  1235.  
  1236.         void DamageTaken(Unit* /*who*/, uint32& damage) OVERRIDE
  1237.         {
  1238.             if (damage >= me->GetHealth())
  1239.             {
  1240.                 // Instance encounter counting mechanics
  1241.                 if (!bCredit)
  1242.                 {
  1243.                     bCredit = true;
  1244.                     HandleSpellOnPlayersInInstanceToC5(me, SPELL_GRAND_CHAMPIONS_CREDIT);
  1245.                 }
  1246.  
  1247.                 EnterEvadeMode();
  1248.                 //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1249.                 me->setFaction(35);
  1250.                 me->GetMotionMaster()->MovePoint(0, 746.843f, 695.68f, 412.339f);
  1251.             }
  1252.         }
  1253.  
  1254.         void JustDied(Unit* killer)
  1255.         {
  1256.             hasBeenInCombat = false;
  1257.             Talk(SAY_CHAMPION_DIED);
  1258.             if (pInstance)
  1259.                 pInstance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
  1260.  
  1261.             //what a nonsense! -.-
  1262.             if (GameObject* pGO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1)))
  1263.                 pInstance->HandleGameObject(pGO->GetGUID(), true);
  1264.         }
  1265.     };
  1266.  
  1267.     CreatureAI* GetAI(Creature* creature) const OVERRIDE
  1268.     {
  1269.         return GetInstanceAI<boss_hunter_toc5AI>(creature);
  1270.     }
  1271. };
  1272.  
  1273. // Lana Stouthammer Evensong && Deathstalker Visceri || Rouge
  1274. class boss_rouge_toc5 : public CreatureScript
  1275. {
  1276.     public:
  1277.         boss_rouge_toc5() : CreatureScript("boss_rouge_toc5") {}
  1278.  
  1279.     struct boss_rouge_toc5AI : public BossAI
  1280.     {
  1281.         boss_rouge_toc5AI(Creature* creature) : BossAI(creature, BOSS_GRAND_CHAMPIONS)
  1282.         {
  1283.             pInstance = creature->GetInstanceScript();
  1284.  
  1285.             bDone = false;
  1286.             bHome = false;
  1287.             bCredit = false;
  1288.  
  1289.             uiPhase = 0;
  1290.             uiPhaseTimer = 0;
  1291.  
  1292.             hasBeenInCombat = false;
  1293.  
  1294.             //me->SetReactState(REACT_PASSIVE);
  1295.             // THIS IS A HACK, SHOULD BE REMOVED WHEN THE EVENT IS FULL SCRIPTED
  1296.             //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1297.         }
  1298.  
  1299.         InstanceScript* pInstance;
  1300.  
  1301.         uint8 uiPhase;
  1302.         uint32 uiPhaseTimer;
  1303.         uint32 uiEviscerateTimer;
  1304.         uint32 uiFanKivesTimer;
  1305.         uint32 uiPosionBottleTimer;
  1306.  
  1307.         bool bDone;
  1308.         bool bHome;
  1309.         bool hasBeenInCombat;
  1310.         bool bCredit;
  1311.  
  1312.         void Reset() OVERRIDE
  1313.         {
  1314.             uiEviscerateTimer = 8000;
  1315.             uiFanKivesTimer   = 14000;
  1316.             uiPosionBottleTimer = 19000;
  1317.             Map* pMap = me->GetMap();
  1318.  
  1319.             if (hasBeenInCombat && pMap && pMap->IsDungeon())
  1320.             {
  1321.                 Map::PlayerList const &players = pMap->GetPlayers();
  1322.                 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  1323.                 {
  1324.                     if (itr->GetSource() && itr->GetSource()->IsAlive() && !itr->GetSource()->IsGameMaster())
  1325.                         return;
  1326.                 }
  1327.                 if (pInstance)
  1328.                     pInstance->SetData(BOSS_GRAND_CHAMPIONS, FAIL);
  1329.                 if (pInstance)
  1330.                 {
  1331.                     GameObject* GO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1));
  1332.                     if (GO)
  1333.                         pInstance->HandleGameObject(GO->GetGUID(), true);
  1334.                 }
  1335.  
  1336.                 me->RemoveFromWorld();
  1337.             }
  1338.         }
  1339.  
  1340.         void JustReachedHome() OVERRIDE
  1341.         {
  1342.             ScriptedAI::JustReachedHome();
  1343.  
  1344.             if (!bHome)
  1345.                 return;
  1346.  
  1347.             uiPhaseTimer = 15000;
  1348.             uiPhase = 1;
  1349.  
  1350.             bHome = false;
  1351.         }
  1352.  
  1353.         void EnterCombat(Unit* who) OVERRIDE
  1354.         {
  1355.             _EnterCombat();
  1356.             hasBeenInCombat = true;
  1357.         }
  1358.  
  1359.         void UpdateAI(uint32 uiDiff) OVERRIDE
  1360.         {
  1361.             if (!bDone && GrandChampionsOutVehicle(me))
  1362.             {
  1363.                 bDone = true;
  1364.                 me->RemoveAura(64723); // [DND] ReadyJoust Pose Effect
  1365.  
  1366.                 if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_1))
  1367.                     me->SetHomePosition(739.678f, 662.541f, 413.395f, 4.49f);
  1368.                 else
  1369.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_2))
  1370.                         me->SetHomePosition(746.71f, 661.02f, 412.695f, 4.6f);
  1371.                 else
  1372.                     if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_3))
  1373.                         me->SetHomePosition(754.34f, 660.70f, 413.395f, 4.79f);
  1374.  
  1375.                     if (pInstance)
  1376.                         pInstance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);
  1377.  
  1378.                 EnterEvadeMode();
  1379.                 bHome = true;
  1380.             }
  1381.  
  1382.             if (uiPhaseTimer <= uiDiff)
  1383.             {
  1384.                 if (uiPhase == 1)
  1385.                 {
  1386.                     AggroAllPlayers(me);
  1387.                     uiPhase = 0;
  1388.                 }
  1389.             }
  1390.             else
  1391.                 uiPhaseTimer -= uiDiff;
  1392.  
  1393.             if (!UpdateVictim() || me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) || me->GetVehicle())
  1394.                 return;
  1395.  
  1396.             if (uiEviscerateTimer <= uiDiff)
  1397.             {
  1398.                 DoCast(me->GetVictim(), DUNGEON_MODE(SPELL_EVISCERATE, SPELL_EVISCERATE_H));
  1399.                 uiEviscerateTimer = 12000;
  1400.             }
  1401.             else
  1402.                 uiEviscerateTimer -= uiDiff;
  1403.  
  1404.             if (uiFanKivesTimer <= uiDiff)
  1405.             {
  1406.                 uiFanKivesTimer = 20000;
  1407.             }
  1408.             else
  1409.                 uiFanKivesTimer -= uiDiff;
  1410.  
  1411.             if (uiPosionBottleTimer <= uiDiff)
  1412.             {
  1413.                 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
  1414.                     DoCast(target, SPELL_POISON_BOTTLE);
  1415.                 uiPosionBottleTimer = 19000;
  1416.             }
  1417.             else
  1418.                 uiPosionBottleTimer -= uiDiff;
  1419.  
  1420.             DoMeleeAttackIfReady();
  1421.         }
  1422.  
  1423.         void DamageTaken(Unit* /*who*/, uint32& damage) OVERRIDE
  1424.         {
  1425.             if (damage >= me->GetHealth())
  1426.             {
  1427.                 // Instance encounter counting mechanics
  1428.                 if (!bCredit)
  1429.                 {
  1430.                     bCredit = true;
  1431.                     HandleSpellOnPlayersInInstanceToC5(me, SPELL_GRAND_CHAMPIONS_CREDIT);
  1432.                 }
  1433.  
  1434.                 EnterEvadeMode();
  1435.                 //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1436.                 me->setFaction(35);
  1437.                 me->GetMotionMaster()->MovePoint(0, 746.843f, 695.68f, 412.339f);
  1438.             }
  1439.         }
  1440.  
  1441.         void JustDied(Unit* killer) OVERRIDE
  1442.         {
  1443.             hasBeenInCombat = false;
  1444.             Talk(SAY_CHAMPION_DIED);
  1445.             if (pInstance)
  1446.                 pInstance->SetData(BOSS_GRAND_CHAMPIONS, DONE);
  1447.  
  1448.             //where's the sense in that?
  1449.             if (GameObject* pGO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1)))
  1450.                 pInstance->HandleGameObject(pGO->GetGUID(), true);
  1451.         }
  1452.     };
  1453.  
  1454.     CreatureAI* GetAI(Creature* creature) const OVERRIDE
  1455.     {
  1456.         return GetInstanceAI<boss_rouge_toc5AI>(creature);
  1457.     }
  1458. };
  1459.  
  1460. class achievement_toc5_grand_champions : public AchievementCriteriaScript
  1461. {
  1462.     public:
  1463.         uint32 creature_entry;
  1464.  
  1465.         achievement_toc5_grand_champions(const char* name, uint32 original_entry) : AchievementCriteriaScript(name)
  1466.         {
  1467.             creature_entry = original_entry;
  1468.         }
  1469.  
  1470.         bool OnCheck(Player* source, Unit* target)
  1471.         {
  1472.             if (!target)
  1473.                 return false;
  1474.  
  1475.             if (Creature* creature = target->ToCreature())
  1476.                 if (creature->GetEntry() == creature_entry)
  1477.                     return true;
  1478.  
  1479.             return false;
  1480.         }
  1481. };
  1482.  
  1483. void AddSC_boss_grand_champions()
  1484. {
  1485.     new generic_vehicleAI_toc5();
  1486.     new boss_warrior_toc5();
  1487.     new boss_mage_toc5();
  1488.     new boss_shaman_toc5();
  1489.     new boss_hunter_toc5();
  1490.     new boss_rouge_toc5();
  1491.     new achievement_toc5_grand_champions("achievement_toc5_champions_mokra", NPC_MOKRA);
  1492.     new achievement_toc5_grand_champions("achievement_toc5_champions_eressea", NPC_ERESSEA);
  1493.     new achievement_toc5_grand_champions("achievement_toc5_champions_runok", NPC_RUNOK);
  1494.     new achievement_toc5_grand_champions("achievement_toc5_champions_zultore", NPC_ZULTORE);
  1495.     new achievement_toc5_grand_champions("achievement_toc5_champions_visceri", NPC_VISCERI);
  1496.     new achievement_toc5_grand_champions("achievement_toc5_champions_alerius", NPC_JACOB);
  1497.     new achievement_toc5_grand_champions("achievement_toc5_champions_ambrose", NPC_AMBROSE);
  1498.     new achievement_toc5_grand_champions("achievement_toc5_champions_colosos", NPC_COLOSOS);
  1499.     new achievement_toc5_grand_champions("achievement_toc5_champions_jaelyne", NPC_JAELYNE);
  1500.     new achievement_toc5_grand_champions("achievement_toc5_champions_lana", NPC_LANA);
  1501. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement