Guest User

Cico boss_lord_marrowgar

a guest
Feb 24th, 2011
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.52 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify it
  5.  * under the terms of the GNU General Public License as published by the
  6.  * Free Software Foundation; either version 2 of the License, or (at your
  7.  * option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful, but WITHOUT
  10.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11.  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12.  * more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License along
  15.  * with this program. If not, see <http://www.gnu.org/licenses/>.
  16.  */
  17.  
  18. #include "ScriptPCH.h"
  19. #include "icecrown_citadel.h"
  20. #include "SpellAuraEffects.h"
  21. #include "SpellScript.h"
  22. #include "SpellAuras.h"
  23. #include "MapManager.h"
  24. #include "Group.h"
  25.  
  26. enum eScriptTexts
  27. {
  28.     SAY_ENTER_ZONE              = 0,
  29.     SAY_AGGRO                   = 1,
  30.     SAY_BONE_STORM              = 2,
  31.     SAY_BONESPIKE               = 3,
  32.     SAY_KILL                    = 4,
  33.     SAY_DEATH                   = 5,
  34.     SAY_BERSERK                 = 6,
  35.     EMOTE_BONE_STORM            = 7,
  36. };
  37.  
  38. enum eSpells
  39. {
  40.     // Lord Marrowgar
  41.     SPELL_BONE_SLICE            = 69055,
  42.     SPELL_BONE_STORM            = 69076,
  43.     SPELL_BONE_SPIKE_GRAVEYARD  = 69057,
  44.     SPELL_COLDFLAME_NORMAL      = 69140,
  45.     SPELL_COLDFLAME_BONE_STORM  = 72705,
  46.  
  47.     // Bone Spike
  48.     SPELL_IMPALED               = 69065,
  49.     SPELL_RIDE_VEHICLE          = 46598,
  50.  
  51.     // Coldflame
  52.     SPELL_COLDFLAME_PASSIVE     = 69145,
  53.     SPELL_COLDFLAME_SUMMON      = 69147
  54. };
  55.  
  56. static const uint32 boneSpikeSummonId[3] = {69062, 72669, 72670};
  57.  
  58. enum eEvents
  59. {
  60.     EVENT_BONE_SPIKE_GRAVEYARD  = 1,
  61.     EVENT_COLDFLAME             = 2,
  62.     EVENT_BONE_STORM_BEGIN      = 3,
  63.     EVENT_BONE_STORM_MOVE       = 4,
  64.     EVENT_BONE_STORM_END        = 5,
  65.     EVENT_ENABLE_BONE_SLICE     = 6,
  66.     EVENT_ENRAGE                = 7,
  67.     EVENT_WARN_BONE_STORM       = 8,
  68.  
  69.     EVENT_COLDFLAME_TRIGGER     = 9,
  70.     EVENT_FAIL_BONED            = 10,
  71.  
  72.     EVENT_GROUP_SPECIAL         = 1,
  73. };
  74.  
  75. enum eMovementPoints
  76. {
  77.     POINT_TARGET_BONESTORM_PLAYER   = 36612631,
  78.     POINT_TARGET_COLDFLAME          = 36672631,
  79. };
  80.  
  81. class boss_lord_marrowgar : public CreatureScript
  82. {
  83.     public:
  84.         boss_lord_marrowgar() : CreatureScript("boss_lord_marrowgar") { }
  85.  
  86.         struct boss_lord_marrowgarAI : public BossAI
  87.         {
  88.             boss_lord_marrowgarAI(Creature* creature) : BossAI(creature, DATA_LORD_MARROWGAR_EVENT)
  89.             {
  90.                 boneStormDuration = RAID_MODE<uint32>(20000, 30000, 20000, 30000);
  91.                 baseSpeed = creature->GetSpeedRate(MOVE_RUN);
  92.                 coldflameLastPos.Relocate(creature);
  93.                 introDone = false;
  94.                 boneSlice = false;
  95.             }
  96.  
  97.             void InitializeAI()
  98.             {
  99.                 if (!instance || static_cast<InstanceMap*>(me->GetMap())->GetScriptId() != GetScriptId(ICCScriptName))
  100.                     me->IsAIEnabled = false;
  101.                 else if (!me->isDead())
  102.                     Reset();
  103.             }
  104.  
  105.             void Reset()
  106.             {
  107.                 me->SetSpeed(MOVE_RUN, baseSpeed, true);
  108.                 me->RemoveAurasDueToSpell(SPELL_BONE_STORM);
  109.                 me->RemoveAurasDueToSpell(SPELL_BERSERK);
  110.                 events.Reset();
  111.                 events.ScheduleEvent(EVENT_ENABLE_BONE_SLICE, 10000);
  112.                 events.ScheduleEvent(EVENT_BONE_SPIKE_GRAVEYARD, urand(10000, 15000), EVENT_GROUP_SPECIAL);
  113.                 events.ScheduleEvent(EVENT_COLDFLAME, 5000, EVENT_GROUP_SPECIAL);
  114.                 events.ScheduleEvent(EVENT_WARN_BONE_STORM, urand(45000, 50000));
  115.                 events.ScheduleEvent(EVENT_ENRAGE, 600000);
  116.             }
  117.  
  118.             void EnterCombat(Unit* /*who*/)
  119.             {
  120.                 Talk(SAY_AGGRO);
  121.  
  122.                 instance->SetBossState(DATA_LORD_MARROWGAR_EVENT, IN_PROGRESS);
  123.                 instance->SetData(DATA_LORD_MARROWGAR_EVENT, IN_PROGRESS);
  124.             }
  125.  
  126.             void JustDied(Unit* killer)
  127.             {
  128.                 Talk(SAY_DEATH);
  129.                 //Removing "Impaled" aura due to bug.
  130.                 if (killer->GetTypeId() == TYPEID_PLAYER)
  131.                 {
  132.                     Player *pPlayer = (Player*)killer;
  133.                     if (Group* pGroup = pPlayer->GetGroup())
  134.                         for (GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
  135.                             if (Player* pMember = pRef->getSource())
  136.                                 pMember->RemoveAurasDueToSpell(SPELL_IMPALED);
  137.                 }
  138.                 instance->SetBossState(DATA_LORD_MARROWGAR_EVENT, DONE);
  139.                 instance->SetData(DATA_LORD_MARROWGAR_EVENT, DONE);
  140.                 summons.DespawnAll();
  141.             }
  142.  
  143.             void JustReachedHome()
  144.             {
  145.                 instance->SetBossState(DATA_LORD_MARROWGAR_EVENT, FAIL);
  146.                 instance->SetData(DATA_LORD_MARROWGAR_EVENT, FAIL);
  147.                 instance->SetData(DATA_BONED_ACHIEVEMENT, uint32(true));    // reset
  148.             }
  149.  
  150.             void KilledUnit(Unit* victim)
  151.             {
  152.                 if (victim->GetTypeId() == TYPEID_PLAYER)
  153.                     Talk(SAY_KILL);
  154.             }
  155.  
  156.             void MoveInLineOfSight(Unit* who)
  157.             {
  158.                 if (!introDone && me->IsWithinDistInMap(who, 70.0f))
  159.                 {
  160.                     Talk(SAY_ENTER_ZONE);
  161.                     introDone = true;
  162.                 }
  163.             }
  164.  
  165.             void UpdateAI(const uint32 diff)
  166.             {
  167.                 if (!UpdateVictim() || !CheckInRoom())
  168.                     return;
  169.  
  170.                 events.Update(diff);
  171.  
  172.                 if (me->HasUnitState(UNIT_STAT_CASTING))
  173.                     return;
  174.  
  175.                 while (uint32 eventId = events.ExecuteEvent())
  176.                 {
  177.                     switch (eventId)
  178.                     {
  179.                         case EVENT_BONE_SPIKE_GRAVEYARD:
  180.                             if (IsHeroic() || !me->HasAura(SPELL_BONE_STORM))
  181.                                 DoCast(me, SPELL_BONE_SPIKE_GRAVEYARD);
  182.                             events.ScheduleEvent(EVENT_BONE_SPIKE_GRAVEYARD, urand(15000, 20000), EVENT_GROUP_SPECIAL);
  183.                             break;
  184.                         case EVENT_COLDFLAME:
  185.                             coldflameLastPos.Relocate(me);
  186.                             if (!me->HasAura(SPELL_BONE_STORM))
  187.                                 me->CastCustomSpell(SPELL_COLDFLAME_NORMAL, SPELLVALUE_MAX_TARGETS, 1, me);
  188.                             else
  189.                                 DoCast(me, SPELL_COLDFLAME_BONE_STORM);
  190.                             events.ScheduleEvent(EVENT_COLDFLAME, 5000, EVENT_GROUP_SPECIAL);
  191.                             break;
  192.                         case EVENT_WARN_BONE_STORM:
  193.                             boneSlice = false;
  194.                             Talk(EMOTE_BONE_STORM);
  195.                             me->FinishSpell(CURRENT_MELEE_SPELL, false);
  196.                             DoCast(me, SPELL_BONE_STORM);
  197.                             events.DelayEvents(3000, EVENT_GROUP_SPECIAL);
  198.                             events.ScheduleEvent(EVENT_BONE_STORM_BEGIN, 3050);
  199.                             events.ScheduleEvent(EVENT_WARN_BONE_STORM, urand(90000, 95000));
  200.                             break;
  201.                         case EVENT_BONE_STORM_BEGIN:
  202.                             if (Aura* pStorm = me->GetAura(SPELL_BONE_STORM))
  203.                                 pStorm->SetDuration(int32(boneStormDuration));
  204.                             me->SetSpeed(MOVE_RUN, baseSpeed*3.0f, true);
  205.                             Talk(SAY_BONE_STORM);
  206.                             events.ScheduleEvent(EVENT_BONE_STORM_END, boneStormDuration+1);
  207.                             // no break here
  208.                         case EVENT_BONE_STORM_MOVE:
  209.                         {
  210.                             events.ScheduleEvent(EVENT_BONE_STORM_MOVE, boneStormDuration/3);
  211.                             Unit* unit = SelectUnit(SELECT_TARGET_RANDOM, 1);
  212.                             if (!unit)
  213.                                 unit = SelectUnit(SELECT_TARGET_RANDOM, 0);
  214.                             if (unit)
  215.                                 me->GetMotionMaster()->MovePoint(POINT_TARGET_BONESTORM_PLAYER, unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ());
  216.                             break;
  217.                         }
  218.                         case EVENT_BONE_STORM_END:
  219.                             if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
  220.                                 me->GetMotionMaster()->MovementExpired();
  221.                             DoStartMovement(me->getVictim());
  222.                             me->SetSpeed(MOVE_RUN, baseSpeed, true);
  223.                             events.CancelEvent(EVENT_BONE_STORM_MOVE);
  224.                             events.ScheduleEvent(EVENT_ENABLE_BONE_SLICE, 10000);
  225.                             if (!IsHeroic())
  226.                                 events.RescheduleEvent(EVENT_BONE_SPIKE_GRAVEYARD, urand(15000, 20000), EVENT_GROUP_SPECIAL);
  227.                             break;
  228.                         case EVENT_ENABLE_BONE_SLICE:
  229.                             boneSlice = true;
  230.                             break;
  231.                         case EVENT_ENRAGE:
  232.                             DoCast(me, SPELL_BERSERK, true);
  233.                             Talk(SAY_BERSERK);
  234.                             break;
  235.                     }
  236.                 }
  237.  
  238.                 // We should not melee attack when storming
  239.                 if (me->HasAura(SPELL_BONE_STORM))
  240.                     return;
  241.  
  242.                 // After 10 seconds since encounter start Bone Slice replaces melee attacks
  243.                 if (boneSlice && !me->GetCurrentSpell(CURRENT_MELEE_SPELL))
  244.                     DoCastVictim(SPELL_BONE_SLICE);
  245.  
  246.                 DoMeleeAttackIfReady();
  247.             }
  248.  
  249.             void MovementInform(uint32 type, uint32 id)
  250.             {
  251.                 if (type != POINT_MOTION_TYPE || id != POINT_TARGET_BONESTORM_PLAYER)
  252.                     return;
  253.  
  254.                 // lock movement
  255.                 DoStartNoMovement(me->getVictim());
  256.             }
  257.  
  258.             const Position* GetLastColdflamePosition() const
  259.             {
  260.                 return &coldflameLastPos;
  261.             }
  262.  
  263.         private:
  264.             uint32 boneStormDuration;
  265.             float baseSpeed;
  266.             Position coldflameLastPos;
  267.             bool introDone;
  268.             bool boneSlice;
  269.         };
  270.  
  271.         CreatureAI* GetAI(Creature* creature) const
  272.         {
  273.             return new boss_lord_marrowgarAI(creature);
  274.         }
  275. };
  276.  
  277. typedef boss_lord_marrowgar::boss_lord_marrowgarAI MarrowgarAI;
  278.  
  279. class npc_coldflame : public CreatureScript
  280. {
  281.     public:
  282.         npc_coldflame() : CreatureScript("npc_coldflame") { }
  283.  
  284.         struct npc_coldflameAI : public ScriptedAI
  285.         {
  286.             npc_coldflameAI(Creature* creature) : ScriptedAI(creature)
  287.             {
  288.             }
  289.  
  290.             void IsSummonedBy(Unit* owner)
  291.             {
  292.                 if (owner->GetTypeId() != TYPEID_UNIT)
  293.                     return;
  294.                 Creature* creOwner = owner->ToCreature();
  295.  
  296.                 DoCast(me, SPELL_COLDFLAME_PASSIVE, true);
  297.                 // random target case
  298.                 if (!owner->HasAura(SPELL_BONE_STORM))
  299.                 {
  300.                     // select any unit but not the tank (by owners threatlist)
  301.                     Unit* target = creOwner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 1, 40.0f, true, -SPELL_IMPALED);
  302.                     if (!target)
  303.                         target = creOwner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 40.0f, true); // or the tank if its solo
  304.                     if (!target)
  305.                     {
  306.                         me->DespawnOrUnsummon();
  307.                         return;
  308.                     }
  309.  
  310.                     me->SetOrientation(me->GetAngle(target));
  311.                 }
  312.                 else
  313.                 {
  314.                     MarrowgarAI* marrowgarAI = CAST_AI(MarrowgarAI, creOwner->AI());
  315.                     Position const* ownerPos = marrowgarAI->GetLastColdflamePosition();
  316.                     float ang = me->GetAngle(ownerPos) - static_cast<float>(M_PI);
  317.                     MapManager::NormalizeOrientation(ang);
  318.                     me->SetOrientation(ang);
  319.                 }
  320.                 events.ScheduleEvent(EVENT_COLDFLAME_TRIGGER, 1000);
  321.             }
  322.  
  323.             void UpdateAI(const uint32 diff)
  324.             {
  325.                 events.Update(diff);
  326.  
  327.                 if (events.ExecuteEvent() == EVENT_COLDFLAME_TRIGGER)
  328.                 {
  329.                     if (me->HasAura(SPELL_COLDFLAME_PASSIVE))
  330.                     {
  331.                         float x, y;
  332.                         me->GetPosition(x, y);
  333.                         x += 5.5f * cos(me->GetOrientation());
  334.                         y += 5.5f * sin(me->GetOrientation());
  335.                         me->NearTeleportTo(x, y, me->GetPositionZ(), me->GetOrientation());
  336.                         DoCast(SPELL_COLDFLAME_SUMMON);
  337.                     }
  338.                     events.ScheduleEvent(EVENT_COLDFLAME_TRIGGER, 1000);
  339.                 }
  340.             }
  341.  
  342.         private:
  343.             EventMap events;
  344.         };
  345.  
  346.         CreatureAI* GetAI(Creature* creature) const
  347.         {
  348.             return new npc_coldflameAI(creature);
  349.         }
  350. };
  351. class npc_bone_spike : public CreatureScript
  352. {
  353.     public:
  354.         npc_bone_spike() : CreatureScript("npc_bone_spike") { }
  355.  
  356.         struct npc_bone_spikeAI : public Scripted_NoMovementAI
  357.         {
  358.             npc_bone_spikeAI(Creature* creature) : Scripted_NoMovementAI(creature), hasTrappedUnit(false)
  359.             {
  360.                 ASSERT(creature->GetVehicleKit());
  361.             }
  362.  
  363.             void JustDied(Unit* /*killer*/)
  364.             {
  365.                 if (TempSummon* summ = me->ToTempSummon())
  366.                     if (Unit* trapped = summ->GetSummoner())
  367.                         trapped->RemoveAurasDueToSpell(SPELL_IMPALED);
  368.  
  369.                 me->DespawnOrUnsummon();
  370.             }
  371.  
  372.             void KilledUnit(Unit* victim)
  373.             {
  374.                 me->DespawnOrUnsummon();
  375.                 victim->RemoveAurasDueToSpell(SPELL_IMPALED);
  376.             }
  377.  
  378.             void IsSummonedBy(Unit* summoner)
  379.             {
  380.                 DoCast(summoner, SPELL_IMPALED);
  381.                 summoner->CastSpell(me, SPELL_RIDE_VEHICLE, true);
  382.                 events.ScheduleEvent(EVENT_FAIL_BONED, 8000);
  383.                 hasTrappedUnit = true;
  384.             }
  385.  
  386.             void UpdateAI(const uint32 diff)
  387.             {
  388.                 if (!hasTrappedUnit)
  389.                     return;
  390.  
  391.                 events.Update(diff);
  392.  
  393.                 if (events.ExecuteEvent() == EVENT_FAIL_BONED)
  394.                     if (InstanceScript* instance = me->GetInstanceScript())
  395.                         instance->SetData(DATA_BONED_ACHIEVEMENT, uint32(false));
  396.  
  397.                 if (TempSummon* summ = me->ToTempSummon())
  398.                 {
  399.                     if (Unit* trapped = summ->GetSummoner())
  400.                     {
  401.                         if (trapped->isDead())
  402.                         {
  403.                             trapped->RemoveAurasDueToSpell(SPELL_IMPALED);
  404.                             summ->UnSummon();
  405.                         }
  406.                     }
  407.                 }
  408.             }
  409.  
  410.         private:
  411.             EventMap events;
  412.             bool hasTrappedUnit;
  413.         };
  414.  
  415.         CreatureAI* GetAI(Creature* creature) const
  416.         {
  417.             return new npc_bone_spikeAI(creature);
  418.         }
  419. };
  420.  
  421. class spell_marrowgar_coldflame : public SpellScriptLoader
  422. {
  423.     public:
  424.         spell_marrowgar_coldflame() : SpellScriptLoader("spell_marrowgar_coldflame") { }
  425.  
  426.         class spell_marrowgar_coldflame_SpellScript : public SpellScript
  427.         {
  428.             PrepareSpellScript(spell_marrowgar_coldflame_SpellScript);
  429.  
  430.             void HandleScriptEffect(SpellEffIndex effIndex)
  431.             {
  432.                 PreventHitDefaultEffect(effIndex);
  433.                 Unit* caster = GetCaster();
  434.                 uint8 count = 1;
  435.                 if (GetSpellInfo()->Id == SPELL_COLDFLAME_BONE_STORM)
  436.                     count = 4;
  437.  
  438.                 for (uint8 i = 0; i < count; ++i)
  439.                     caster->CastSpell(caster, uint32(GetEffectValue()+i), true);
  440.             }
  441.  
  442.             void Register()
  443.             {
  444.                 OnEffect += SpellEffectFn(spell_marrowgar_coldflame_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
  445.             }
  446.         };
  447.  
  448.         SpellScript* GetSpellScript() const
  449.         {
  450.             return new spell_marrowgar_coldflame_SpellScript();
  451.         }
  452. };
  453.  
  454. class spell_marrowgar_bone_spike_graveyard : public SpellScriptLoader
  455. {
  456.     public:
  457.         spell_marrowgar_bone_spike_graveyard() : SpellScriptLoader("spell_marrowgar_bone_spike_graveyard") { }
  458.  
  459.         class spell_marrowgar_bone_spike_graveyard_SpellScript : public SpellScript
  460.         {
  461.             PrepareSpellScript(spell_marrowgar_bone_spike_graveyard_SpellScript);
  462.  
  463.             void HandleSpikes(SpellEffIndex effIndex)
  464.             {
  465.                 PreventHitDefaultEffect(effIndex);
  466.                 if (Creature* marrowgar = GetCaster()->ToCreature())
  467.                 {
  468.                     CreatureAI* marrowgarAI = marrowgar->AI();
  469.                     bool yell = false;
  470.                     uint8 boneSpikeCount = uint8(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 3 : 1);
  471.                     for (uint8 i = 0; i < boneSpikeCount; ++i)
  472.                     {
  473.                         // select any unit but not the tank
  474.                         Unit* target = marrowgarAI->SelectTarget(SELECT_TARGET_RANDOM, 1, 100.0f, true, -SPELL_IMPALED);
  475.                         //Yes, NOT THE TANK!
  476.                         //if (!target && !i)
  477.                         //    target = marrowgarAI->SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true, -SPELL_IMPALED);
  478.                         if (!target)
  479.                             break;
  480.                         yell = true;
  481.                         target->CastCustomSpell(boneSpikeSummonId[i], SPELLVALUE_BASE_POINT0, 0, target, true);
  482.                     }
  483.  
  484.                     if (yell)
  485.                         marrowgarAI->Talk(SAY_BONESPIKE);
  486.                 }
  487.             }
  488.  
  489.             void Register()
  490.             {
  491.                 OnEffect += SpellEffectFn(spell_marrowgar_bone_spike_graveyard_SpellScript::HandleSpikes, EFFECT_1, SPELL_EFFECT_APPLY_AURA);
  492.             }
  493.         };
  494.  
  495.         SpellScript* GetSpellScript() const
  496.         {
  497.             return new spell_marrowgar_bone_spike_graveyard_SpellScript();
  498.         }
  499. };
  500.  
  501. class spell_marrowgar_bone_storm : public SpellScriptLoader
  502. {
  503.     public:
  504.         spell_marrowgar_bone_storm() : SpellScriptLoader("spell_marrowgar_bone_storm") { }
  505.  
  506.         class spell_marrowgar_bone_storm_SpellScript : public SpellScript
  507.         {
  508.             PrepareSpellScript(spell_marrowgar_bone_storm_SpellScript);
  509.  
  510.             void RecalculateDamage(SpellEffIndex /*effIndex*/)
  511.             {
  512.                 int32 dmg = GetHitDamage();
  513.                 float distance = GetHitUnit()->GetExactDist2d(GetCaster());
  514.                 if (distance < 5.0f)
  515.                     return;
  516.  
  517.                 float distVar = distance >= 20.0f ? 4 : (10.0f/3.0f);
  518.                 SetHitDamage(int32(dmg * distVar / distance));
  519.             }
  520.  
  521.             void Register()
  522.             {
  523.                 OnEffect += SpellEffectFn(spell_marrowgar_bone_storm_SpellScript::RecalculateDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
  524.             }
  525.         };
  526.  
  527.         SpellScript* GetSpellScript() const
  528.         {
  529.             return new spell_marrowgar_bone_storm_SpellScript();
  530.         }
  531. };
  532.  
  533. class spell_marrowgar_coldflame_damage : public SpellScriptLoader
  534. {
  535.     public:
  536.         spell_marrowgar_coldflame_damage() : SpellScriptLoader("spell_marrowgar_coldflame_damage") { }
  537.  
  538.         class spell_marrowgar_coldflame_damage_AuraScript : public AuraScript
  539.         {
  540.             PrepareAuraScript(spell_marrowgar_coldflame_damage_AuraScript);
  541.  
  542.             void OnPeriodic(AuraEffect const* /*aurEff*/)
  543.             {
  544.                 if (DynamicObject* owner = GetDynobjOwner())
  545.                     if (GetTarget()->GetExactDist2d(owner) > owner->GetRadius() || GetTarget()->HasAura(SPELL_IMPALED))
  546.                         PreventDefaultAction();
  547.             }
  548.  
  549.             void Register()
  550.             {
  551.                 OnEffectPeriodic += AuraEffectPeriodicFn(spell_marrowgar_coldflame_damage_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
  552.             }
  553.         };
  554.  
  555.         AuraScript* GetAuraScript() const
  556.         {
  557.             return new spell_marrowgar_coldflame_damage_AuraScript();
  558.         }
  559. };
  560.  
  561. class npc_the_damned : public CreatureScript
  562. {
  563.     enum eSpells
  564.     {
  565.         SPELL_BONE_FLURRY       = 70960,
  566.         SPELL_SHATTERED_BONES    = 70961,
  567.     };
  568.  
  569. public:
  570.     npc_the_damned() : CreatureScript("npc_the_damned") { }
  571.  
  572.     CreatureAI* GetAI(Creature* pCreature) const
  573.     {
  574.         return new npc_the_damnedAI (pCreature);
  575.     }
  576.  
  577.     struct npc_the_damnedAI : public ScriptedAI
  578.     {
  579.         npc_the_damnedAI(Creature *c) : ScriptedAI(c) {}
  580.  
  581.         void JustDied(Unit* /*Killer*/)
  582.         {
  583.             DoCast(me, SPELL_SHATTERED_BONES);
  584.         }
  585.  
  586.         void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/)
  587.         {
  588.             if(HealthBelowPct(25) && !me->HasAura(SPELL_BONE_FLURRY))
  589.                 DoCast(me, SPELL_BONE_FLURRY);
  590.         }
  591.     };
  592. };
  593.  
  594. class npc_servant_of_the_throne : public CreatureScript
  595. {
  596.     enum eEvents
  597.     {
  598.         EVENT_GLACIAL_BLAST = 1,
  599.     };
  600.     enum eSpells
  601.     {
  602.         SPELL_GLACIAL_BLAST  = 71029,
  603.     };
  604.  
  605. public:
  606.     npc_servant_of_the_throne() : CreatureScript("npc_servant_of_the_throne") { }
  607.  
  608.     CreatureAI* GetAI(Creature* pCreature) const
  609.     {
  610.         return new npc_servant_of_the_throneAI (pCreature);
  611.     }
  612.  
  613.     struct npc_servant_of_the_throneAI : public ScriptedAI
  614.     {
  615.         npc_servant_of_the_throneAI(Creature *c) : ScriptedAI(c)
  616.         {
  617.             instance = me->GetInstanceScript();
  618.         }
  619.  
  620.         void Reset()
  621.         {
  622.             events.Reset();
  623.         }
  624.  
  625.         void EnterCombat(Unit* /*who*/)
  626.         {
  627.             events.Reset();
  628.             events.ScheduleEvent(EVENT_GLACIAL_BLAST, 3000);
  629.         }
  630.  
  631.         void UpdateAI(const uint32 diff)
  632.         {
  633.             if (!UpdateVictim())
  634.                 return;
  635.             if (me->HasUnitState(UNIT_STAT_CASTING))
  636.                 return;
  637.             events.Update(diff);
  638.             while (uint32 eventId = events.ExecuteEvent())
  639.             {
  640.                 switch (eventId)
  641.                 {
  642.                     case EVENT_GLACIAL_BLAST:  
  643.                     {
  644.                         DoCast(me, SPELL_GLACIAL_BLAST);
  645.                         events.ScheduleEvent(EVENT_GLACIAL_BLAST, 5000);
  646.                         break;
  647.                     }
  648.                     default:
  649.                         break;
  650.                 }
  651.             }
  652.             DoMeleeAttackIfReady();
  653.         }
  654.     private:
  655.         InstanceScript *instance;
  656.         EventMap events;
  657.     };
  658.  
  659. };
  660. class npc_ancient_skeletal_soldier : public CreatureScript
  661. {
  662.     enum eEvents
  663.     {
  664.         EVENT_SHIELD_BASH = 1,
  665.     };
  666.     enum eSpells
  667.     {
  668.         SPELL_SHIELD_BASH  = 70964,
  669.     };
  670.  
  671. public:
  672.     npc_ancient_skeletal_soldier() : CreatureScript("npc_ancient_skeletal_soldier") { }
  673.  
  674.     CreatureAI* GetAI(Creature* pCreature) const
  675.     {
  676.         return new npc_ancient_skeletal_soldierAI (pCreature);
  677.     }
  678.  
  679.     struct npc_ancient_skeletal_soldierAI : public ScriptedAI
  680.     {
  681.         npc_ancient_skeletal_soldierAI(Creature *c) : ScriptedAI(c)
  682.         {
  683.             instance = me->GetInstanceScript();
  684.         }
  685.  
  686.         void Reset()
  687.         {
  688.             events.Reset();
  689.         }
  690.  
  691.         void EnterCombat(Unit* /*who*/)
  692.         {
  693.             events.Reset();
  694.             events.ScheduleEvent(EVENT_SHIELD_BASH, 3000);
  695.         }
  696.  
  697.         void UpdateAI(const uint32 diff)
  698.         {
  699.             if (!UpdateVictim())
  700.                 return;
  701.             if (me->HasUnitState(UNIT_STAT_CASTING))
  702.                 return;
  703.             events.Update(diff);
  704.             while (uint32 eventId = events.ExecuteEvent())
  705.             {
  706.                 switch (eventId)
  707.                 {
  708.                     case EVENT_SHIELD_BASH:  
  709.                     {
  710.                         DoCastVictim(SPELL_SHIELD_BASH);
  711.                         events.ScheduleEvent(EVENT_SHIELD_BASH, 7000);
  712.                         break;
  713.                     }
  714.                     default:
  715.                         break;
  716.                 }
  717.             }
  718.             DoMeleeAttackIfReady();
  719.         }
  720.     private:
  721.         InstanceScript *instance;
  722.         EventMap events;
  723.     };
  724.  
  725. };
  726. void AddSC_boss_lord_marrowgar()
  727. {
  728.     new boss_lord_marrowgar();
  729.     new npc_coldflame();
  730.     new npc_bone_spike();
  731.     new spell_marrowgar_coldflame();
  732.     new spell_marrowgar_coldflame_damage();
  733.     new spell_marrowgar_bone_spike_graveyard();
  734.     new spell_marrowgar_bone_storm();
  735.     new npc_the_damned();
  736.     new npc_servant_of_the_throne();
  737.     new npc_ancient_skeletal_soldier();
  738. }
Advertisement
Add Comment
Please, Sign In to add comment