From def167d7cc3e0787b89e72800b62896c6fcd9d93 Mon Sep 17 00:00:00 2001 From: Dan <83884799+elthehablo@users.noreply.github.com> Date: Sun, 25 Feb 2024 15:49:19 +0100 Subject: [PATCH] fix(Scripts/TheEye): Kael'thas - allow phases to progress as well when all creatures die as well as other fixes (#18397) --- .../pending_db_world/weapon_action.sql | 19 + .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 494 ++++++++---------- 2 files changed, 233 insertions(+), 280 deletions(-) create mode 100644 data/sql/updates/pending_db_world/weapon_action.sql diff --git a/data/sql/updates/pending_db_world/weapon_action.sql b/data/sql/updates/pending_db_world/weapon_action.sql new file mode 100644 index 000000000..5d28d796a --- /dev/null +++ b/data/sql/updates/pending_db_world/weapon_action.sql @@ -0,0 +1,19 @@ +-- +DELETE FROM `smart_scripts` WHERE `source_type` = 0 AND `entryorguid` BETWEEN 21268 AND 21274; +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(21268, 0, 0, 0, 0, 0, 100, 0, 0, 0, 2000, 2000, 0, 0, 11, 36980, 64, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Netherstrand Longbow - In Combat - Cast Shot'), +(21268, 0, 1, 0, 0, 0, 100, 0, 4000, 8000, 12000, 15000, 0, 0, 11, 36979, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Netherstrand Longbow - In Combat - Cast Multi-Shot'), +(21268, 0, 2, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 223, 4, 0, 0, 0, 0, 0, 9, 19622, 0, 2000, 1, 0, 0, 0, 0, 'Netherstrand Longbow - On death - Do Action'), +(21269, 0, 0, 0, 0, 0, 100, 0, 4000, 8000, 12000, 15000, 0, 0, 11, 36981, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Devastation - In Combat - Cast Whirlwind'), +(21269, 0, 1, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 223, 4, 0, 0, 0, 0, 0, 9, 19622, 0, 2000, 1, 0, 0, 0, 0, 'Devastation - On death - Do Action'), +(21270, 0, 0, 0, 0, 0, 100, 0, 3000, 5000, 7000, 9000, 0, 0, 11, 36985, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Cosmic Infuser - In Combat - Cast Holy Nova'), +(21270, 0, 1, 0, 14, 0, 100, 0, 30000, 40, 10000, 10000, 0, 0, 11, 36983, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Cosmic Infuser - Friendly Missing HP - Cast Heal'), +(21270, 0, 2, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 223, 4, 0, 0, 0, 0, 0, 9, 19622, 0, 2000, 1, 0, 0, 0, 0, 'Cosmic Infuser - On death - Do Action'), +(21271, 0, 0, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 223, 4, 0, 0, 0, 0, 0, 9, 19622, 0, 2000, 1, 0, 0, 0, 0, 'Infinity Blades - On death - Do Action'), +(21272, 0, 0, 0, 0, 0, 100, 0, 3000, 5000, 6000, 8000, 0, 0, 11, 36991, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Warp Slicer - In Combat - Cast Rend'), +(21272, 0, 1, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 223, 4, 0, 0, 0, 0, 0, 9, 19622, 0, 2000, 1, 0, 0, 0, 0, 'Warp Slicer - On death - Do Action'), +(21273, 0, 0, 0, 105, 0, 100, 0, 10000, 10000, 10000, 10000, 0, 5, 11, 36988, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Phaseshift Bulwark - Victim Casting - Cast Shield Bash'), +(21273, 0, 1, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 223, 4, 0, 0, 0, 0, 0, 9, 19622, 0, 2000, 1, 0, 0, 0, 0, 'Phaseshift Bulwark - On death - Do Action'), +(21274, 0, 0, 0, 0, 0, 100, 0, 0, 0, 2200, 2200, 0, 0, 11, 36990, 64, 0, 0, 0, 0, 5, 50, 0, 0, 0, 0, 0, 0, 0, 'Staff of Disintegration - In Combat - Cast Frost Bolt'), +(21274, 0, 1, 0, 106, 0, 100, 0, 5000, 5000, 10000, 10000, 0, 10, 11, 36989, 0, 0, 0, 0, 0, 5, 10, 0, 0, 0, 0, 0, 0, 0, 'Staff of Disintegration - In Combat - Cast Frost Nova'), +(21274, 0, 2, 0, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 223, 4, 0, 0, 0, 0, 0, 9, 19622, 0, 2000, 1, 0, 0, 0, 0, 'Staff of Disintegration - On death - Do Action'); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index c822eafc9..c284c3b8c 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -145,6 +145,8 @@ enum Misc DATA_RESURRECT_CAST = 1, NPC_WORLD_TRIGGER = 19871, NPC_NETHER_VAPOR = 21002, + NPC_NETHERSTRAND_LONGBOW = 21268, + NPC_STAFF_OF_DISINTEGRATION = 21274, PHASE_NONE = 0, PHASE_SINGLE_ADVISOR = 1, @@ -207,14 +209,16 @@ enum KaelActions ACTION_START_SANGUINAR = 0, ACTION_START_CAPERNIAN = 1, ACTION_START_TELONICUS = 2, - ACTION_START_WEAPONS = 3 + ACTION_START_WEAPONS = 3, + ACTION_PROGRESS_PHASE_CHECK = 4 }; enum SpellGroups { - GROUP_PYROBLAST = 0, - GROUP_SHOCK_BARRIER = 1, - GROUP_NETHER_BEAM = 2 + GROUP_PROGRESS_PHASE = 0, + GROUP_PYROBLAST = 1, + GROUP_SHOCK_BARRIER = 2, + GROUP_NETHER_BEAM = 3 }; const Position triggersPos[6] = @@ -253,9 +257,12 @@ struct boss_kaelthas : public BossAI summons.DoForAllSummons([&](WorldObject* summon){ if (Creature* summonedCreature = summon->ToCreature()) { - summonedCreature->SetReactState(REACT_PASSIVE); - summonedCreature->setDeathState(DeathState::JustRespawned); - summonedCreature->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + if (summonedCreature->GetEntry() >= NPC_LORD_SANGUINAR && summonedCreature->GetEntry() <= NPC_THALADRED) + { + summonedCreature->SetReactState(REACT_PASSIVE); + summonedCreature->setDeathState(DeathState::JustRespawned); + summonedCreature->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + } } }); } @@ -382,11 +389,53 @@ struct boss_kaelthas : public BossAI } } }); - ScheduleUniqueTimedEvent(2min, [&]{ + scheduler.Schedule(2min, GROUP_PROGRESS_PHASE, [this](TaskContext) + { PhaseAllAdvisorsExecute(); - }, EVENT_PREFIGHT_PHASE61); + }); }, EVENT_PREFIGHT_PHASE52); break; + case ACTION_PROGRESS_PHASE_CHECK: + if (_phase == PHASE_WEAPONS) + { + bool aliveWeapon = false; + summons.DoForAllSummons([&aliveWeapon](WorldObject* summon) + { + if (Creature* summonedCreature = summon->ToCreature()) + { + if (summonedCreature->IsAlive()) + { + if (summonedCreature->GetEntry() >= NPC_NETHERSTRAND_LONGBOW && summonedCreature->GetEntry() <= NPC_STAFF_OF_DISINTEGRATION) + { + aliveWeapon = true; + return; + } + } + } + }); + if (!aliveWeapon) + PhaseAllAdvisorsExecute(); + } + else if (_phase == PHASE_ALL_ADVISORS) + { + bool advisorAlive = false; + summons.DoForAllSummons([&advisorAlive](WorldObject* summon) + { + if (Creature* summonedCreature = summon->ToCreature()) + { + if (summonedCreature->IsAlive()) + { + if (summonedCreature->GetEntry() >= NPC_LORD_SANGUINAR && summonedCreature->GetEntry() <= NPC_THALADRED) + { + advisorAlive = true; + return; + } + } + } + }); + if (!advisorAlive) + PhaseKaelExecute(); + } default: break; } @@ -629,17 +678,7 @@ struct boss_kaelthas : public BossAI void PhaseAllAdvisorsExecute() { - //remove all weapons so they don't get revived - summons.DoForAllSummons([&](WorldObject* summon) - { - if (Creature* summonedCreature = summon->ToCreature()) - { - if (summonedCreature->GetEntry() >= 21268 && summonedCreature->GetEntry() <= 21274) - { - summonedCreature->DespawnOrUnsummon(); - } - } - }); + scheduler.CancelGroup(GROUP_PROGRESS_PHASE); _phase = PHASE_ALL_ADVISORS; Talk(SAY_PHASE3_ADVANCE); ScheduleUniqueTimedEvent(6s, [&]{ @@ -662,9 +701,10 @@ struct boss_kaelthas : public BossAI } } }); - ScheduleUniqueTimedEvent(3min, [&]{ + scheduler.Schedule(3min, GROUP_PROGRESS_PHASE, [this](TaskContext) + { PhaseKaelExecute(); - }, EVENT_PREFIGHT_PHASE71); + }); }, EVENT_PREFIGHT_PHASE63); } @@ -778,15 +818,16 @@ struct npc_lord_sanguinar : public ScriptedAI void JustDied(Unit* /*killer*/) override { - if (!_hasDied) + if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) { - Talk(SAY_SANGUINAR_DEATH); - DoCastSelf(SPELL_KAEL_PHASE_TWO, true); - if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) + kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK); + if (!_hasDied) { + Talk(SAY_SANGUINAR_DEATH); + DoCastSelf(SPELL_KAEL_PHASE_TWO, true); kael->AI()->DoAction(ACTION_START_CAPERNIAN); + _hasDied = true; } - _hasDied = true; } } @@ -865,15 +906,16 @@ struct npc_capernian : public ScriptedAI void JustDied(Unit* /*killer*/) override { - if (!_hasDied) + if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) { - Talk(SAY_CAPERNIAN_DEATH); - DoCastSelf(SPELL_KAEL_PHASE_TWO, true); - if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) + kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK); + if (!_hasDied) { + Talk(SAY_CAPERNIAN_DEATH); + DoCastSelf(SPELL_KAEL_PHASE_TWO, true); kael->AI()->DoAction(ACTION_START_TELONICUS); + _hasDied = true; } - _hasDied = true; } } @@ -927,15 +969,16 @@ struct npc_telonicus : public ScriptedAI void JustDied(Unit* /*killer*/) override { - if (!_hasDied) + if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) { - Talk(SAY_TELONICUS_DEATH); - DoCastSelf(SPELL_KAEL_PHASE_TWO, true); - if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) + kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK); + if (!_hasDied) { + Talk(SAY_TELONICUS_DEATH); + DoCastSelf(SPELL_KAEL_PHASE_TWO, true); kael->AI()->DoAction(ACTION_START_WEAPONS); + _hasDied = true; } - _hasDied = true; } } @@ -1011,15 +1054,16 @@ struct npc_thaladred : public ScriptedAI void JustDied(Unit* /*killer*/) override { - if (!_hasDied) + if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) { - Talk(SAY_THALADRED_DEATH); - DoCastSelf(SPELL_KAEL_PHASE_TWO, true); - if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS)) + kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK); + if (!_hasDied) { + Talk(SAY_THALADRED_DEATH); + DoCastSelf(SPELL_KAEL_PHASE_TWO, true); kael->AI()->DoAction(ACTION_START_SANGUINAR); + _hasDied = true; } - _hasDied = true; } } @@ -1040,200 +1084,123 @@ private: bool _hasDied; }; -class spell_kaelthas_kael_phase_two : public SpellScriptLoader +class spell_kaelthas_kael_phase_two : public SpellScript { -public: - spell_kaelthas_kael_phase_two() : SpellScriptLoader("spell_kaelthas_kael_phase_two") { } + PrepareSpellScript(spell_kaelthas_kael_phase_two); - class spell_kaelthas_kael_phase_two_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_kaelthas_kael_phase_two_SpellScript); + if (GetCaster()->GetTypeId() == TYPEID_UNIT) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* kael = instance->GetCreature(DATA_KAELTHAS)) + kael->AI()->SummonedCreatureDies(GetCaster()->ToCreature(), nullptr); + return true; + } - bool Load() override - { - if (GetCaster()->GetTypeId() == TYPEID_UNIT) - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* kael = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(NPC_KAELTHAS))) - kael->AI()->SummonedCreatureDies(GetCaster()->ToCreature(), nullptr); - return true; - } - - void Register() override - { - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_kaelthas_kael_phase_two_SpellScript(); } }; -class spell_kaelthas_remote_toy : public SpellScriptLoader +class spell_kaelthas_remote_toy : public AuraScript { -public: - spell_kaelthas_remote_toy() : SpellScriptLoader("spell_kaelthas_remote_toy") { } + PrepareAuraScript(spell_kaelthas_remote_toy); - class spell_kaelthas_remote_toy_AuraScript : public AuraScript + void HandlePeriodic(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_kaelthas_remote_toy_AuraScript); + PreventDefaultAction(); + if (roll_chance_i(66)) + GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_REMOTE_TOY_STUN, true); + } - void HandlePeriodic(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - if (roll_chance_i(66)) - GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_REMOTE_TOY_STUN, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_kaelthas_remote_toy_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_kaelthas_remote_toy_AuraScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_kaelthas_remote_toy::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; -class spell_kaelthas_summon_weapons : public SpellScriptLoader +class spell_kaelthas_summon_weapons : public SpellScript { -public: - spell_kaelthas_summon_weapons() : SpellScriptLoader("spell_kaelthas_summon_weapons") { } + PrepareSpellScript(spell_kaelthas_summon_weapons); - class spell_kaelthas_summon_weapons_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_kaelthas_summon_weapons_SpellScript); + PreventHitEffect(effIndex); + for (uint32 i = SPELL_SUMMON_WEAPONA; i <= SPELL_SUMMON_WEAPONG; ++i) + GetCaster()->CastSpell(GetCaster(), i, true); + } - void HandleScriptEffect(SpellEffIndex effIndex) - { - PreventHitEffect(effIndex); - for (uint32 i = SPELL_SUMMON_WEAPONA; i <= SPELL_SUMMON_WEAPONG; ++i) - GetCaster()->CastSpell(GetCaster(), i, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_kaelthas_summon_weapons_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_kaelthas_summon_weapons_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_kaelthas_summon_weapons::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_kaelthas_resurrection : public SpellScriptLoader +class spell_kaelthas_resurrection : public SpellScript { -public: - spell_kaelthas_resurrection() : SpellScriptLoader("spell_kaelthas_resurrection") { } + PrepareSpellScript(spell_kaelthas_resurrection); - class spell_kaelthas_resurrection_SpellScript : public SpellScript + void HandleBeforeCast() { - PrepareSpellScript(spell_kaelthas_resurrection_SpellScript); + GetCaster()->GetAI()->SetData(DATA_RESURRECT_CAST, DATA_RESURRECT_CAST); + } - void HandleBeforeCast() - { - GetCaster()->GetAI()->SetData(DATA_RESURRECT_CAST, DATA_RESURRECT_CAST); - } - - void Register() override - { - BeforeCast += SpellCastFn(spell_kaelthas_resurrection_SpellScript::HandleBeforeCast); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_kaelthas_resurrection_SpellScript(); + BeforeCast += SpellCastFn(spell_kaelthas_resurrection::HandleBeforeCast); } }; -class spell_kaelthas_mind_control : public SpellScriptLoader +class spell_kaelthas_mind_control : public SpellScript { -public: - spell_kaelthas_mind_control() : SpellScriptLoader("spell_kaelthas_mind_control") { } + PrepareSpellScript(spell_kaelthas_mind_control); - class spell_kaelthas_mind_control_SpellScript : public SpellScript + void SelectTarget(std::list& targets) { - PrepareSpellScript(spell_kaelthas_mind_control_SpellScript); + if (Unit* victim = GetCaster()->GetVictim()) + targets.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true)); + } - void SelectTarget(std::list& targets) - { - if (Unit* victim = GetCaster()->GetVictim()) - targets.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true)); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_kaelthas_mind_control_SpellScript::SelectTarget, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_kaelthas_mind_control_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_kaelthas_mind_control::SelectTarget, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ENEMY); } }; -class spell_kaelthas_burn : public SpellScriptLoader +class spell_kaelthas_burn : public AuraScript { -public: - spell_kaelthas_burn() : SpellScriptLoader("spell_kaelthas_burn") { } + PrepareAuraScript(spell_kaelthas_burn); - class spell_kaelthas_burn_AuraScript : public AuraScript + void HandlePeriodic(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_kaelthas_burn_AuraScript); + Unit::DealDamage(GetUnitOwner(), GetUnitOwner(), GetUnitOwner()->CountPctFromMaxHealth(5) + 1); + } - void HandlePeriodic(AuraEffect const* /*aurEff*/) - { - Unit::DealDamage(GetUnitOwner(), GetUnitOwner(), GetUnitOwner()->CountPctFromMaxHealth(5) + 1); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_kaelthas_burn_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_kaelthas_burn_AuraScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_kaelthas_burn::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; -class spell_kaelthas_flame_strike : public SpellScriptLoader +class spell_kaelthas_flame_strike : public AuraScript { -public: - spell_kaelthas_flame_strike() : SpellScriptLoader("spell_kaelthas_flame_strike") { } + PrepareAuraScript(spell_kaelthas_flame_strike); - class spell_kaelthas_flame_strike_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_kaelthas_flame_strike_AuraScript); + return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; + } - bool Load() override - { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetUnitOwner()->RemoveAllAuras(); - GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_FLAME_STRIKE_DAMAGE, true); - GetUnitOwner()->ToCreature()->DespawnOrUnsummon(2000); - } - - void Register() override - { - OnEffectRemove += AuraEffectRemoveFn(spell_kaelthas_flame_strike_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_kaelthas_flame_strike_AuraScript(); + GetUnitOwner()->RemoveAllAuras(); + GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_FLAME_STRIKE_DAMAGE, true); + GetUnitOwner()->ToCreature()->DespawnOrUnsummon(2000); + } + + void Register() override + { + OnEffectRemove += AuraEffectRemoveFn(spell_kaelthas_flame_strike::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; @@ -1260,111 +1227,78 @@ private: Player* _owner; }; -class spell_kaelthas_gravity_lapse : public SpellScriptLoader +class spell_kaelthas_gravity_lapse : public SpellScript { -public: - spell_kaelthas_gravity_lapse() : SpellScriptLoader("spell_kaelthas_gravity_lapse") { } + PrepareSpellScript(spell_kaelthas_gravity_lapse); - class spell_kaelthas_gravity_lapse_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_kaelthas_gravity_lapse_SpellScript); - - bool Load() override - { - _currentSpellId = SPELL_GRAVITY_LAPSE_TELEPORT1; - return true; - } - - void HandleScriptEffect(SpellEffIndex effIndex) - { - PreventHitEffect(effIndex); - if (_currentSpellId < SPELL_GRAVITY_LAPSE_TELEPORT1 + 25) - if (Player* target = GetHitPlayer()) - { - GetCaster()->CastSpell(target, _currentSpellId++, true); - target->m_Events.AddEvent(new lapseTeleport(target), target->m_Events.CalculateTime(1)); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_kaelthas_gravity_lapse_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - - private: - uint32 _currentSpellId; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_kaelthas_gravity_lapse_SpellScript(); + _currentSpellId = SPELL_GRAVITY_LAPSE_TELEPORT1; + return true; } -}; -class spell_kaelthas_nether_beam : public SpellScriptLoader -{ -public: - spell_kaelthas_nether_beam() : SpellScriptLoader("spell_kaelthas_nether_beam") { } - - class spell_kaelthas_nether_beam_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_kaelthas_nether_beam_SpellScript); - - void HandleScriptEffect(SpellEffIndex effIndex) - { - PreventHitEffect(effIndex); - - ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().GetThreatList(); - std::list targetList; - for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) + PreventHitEffect(effIndex); + if (_currentSpellId < SPELL_GRAVITY_LAPSE_TELEPORT1 + 25) + if (Player* target = GetHitPlayer()) { - Unit* target = ObjectAccessor::GetUnit(*GetCaster(), (*itr)->getUnitGuid()); - if (target && target->GetTypeId() == TYPEID_PLAYER) - targetList.push_back(target); + GetCaster()->CastSpell(target, _currentSpellId++, true); + target->m_Events.AddEvent(new lapseTeleport(target), target->m_Events.CalculateTime(1)); } + } - Acore::Containers::RandomResize(targetList, 5); - for (std::list::const_iterator itr = targetList.begin(); itr != targetList.end(); ++itr) - GetCaster()->CastSpell(*itr, SPELL_NETHER_BEAM_DAMAGE, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_kaelthas_nether_beam_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_kaelthas_nether_beam_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_kaelthas_gravity_lapse::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + +private: + uint32 _currentSpellId; +}; + +class spell_kaelthas_nether_beam : public SpellScript +{ + PrepareSpellScript(spell_kaelthas_nether_beam); + + void HandleScriptEffect(SpellEffIndex effIndex) + { + PreventHitEffect(effIndex); + + ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().GetThreatList(); + std::list targetList; + for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) + { + Unit* target = ObjectAccessor::GetUnit(*GetCaster(), (*itr)->getUnitGuid()); + if (target && target->GetTypeId() == TYPEID_PLAYER) + targetList.push_back(target); + } + + Acore::Containers::RandomResize(targetList, 5); + for (std::list::const_iterator itr = targetList.begin(); itr != targetList.end(); ++itr) + GetCaster()->CastSpell(*itr, SPELL_NETHER_BEAM_DAMAGE, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_kaelthas_nether_beam::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_kaelthas_summon_nether_vapor : public SpellScriptLoader +class spell_kaelthas_summon_nether_vapor : public SpellScript { -public: - spell_kaelthas_summon_nether_vapor() : SpellScriptLoader("spell_kaelthas_summon_nether_vapor") { } + PrepareSpellScript(spell_kaelthas_summon_nether_vapor); - class spell_kaelthas_summon_nether_vapor_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_kaelthas_summon_nether_vapor_SpellScript); + PreventHitEffect(effIndex); + for (uint32 i = 0; i < 5; ++i) + GetCaster()->SummonCreature(NPC_NETHER_VAPOR, GetCaster()->GetPositionX() + 6 * cos(i / 5.0f * 2 * M_PI), GetCaster()->GetPositionY() + 6 * std::sin(i / 5.0f * 2 * M_PI), GetCaster()->GetPositionZ() + 7.0f + i, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 30000); + } - void HandleScriptEffect(SpellEffIndex effIndex) - { - PreventHitEffect(effIndex); - for (uint32 i = 0; i < 5; ++i) - GetCaster()->SummonCreature(NPC_NETHER_VAPOR, GetCaster()->GetPositionX() + 6 * cos(i / 5.0f * 2 * M_PI), GetCaster()->GetPositionY() + 6 * std::sin(i / 5.0f * 2 * M_PI), GetCaster()->GetPositionZ() + 7.0f + i, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 30000); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_kaelthas_summon_nether_vapor_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_kaelthas_summon_nether_vapor_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_kaelthas_summon_nether_vapor::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -1375,15 +1309,15 @@ void AddSC_boss_kaelthas() RegisterTheEyeAI(npc_capernian); RegisterTheEyeAI(npc_telonicus); RegisterTheEyeAI(npc_thaladred); - new spell_kaelthas_kael_phase_two(); - new spell_kaelthas_remote_toy(); - new spell_kaelthas_summon_weapons(); - new spell_kaelthas_resurrection(); - new spell_kaelthas_mind_control(); - new spell_kaelthas_burn(); - new spell_kaelthas_flame_strike(); - new spell_kaelthas_gravity_lapse(); - new spell_kaelthas_nether_beam(); - new spell_kaelthas_summon_nether_vapor(); + RegisterSpellScript(spell_kaelthas_kael_phase_two); + RegisterSpellScript(spell_kaelthas_remote_toy); + RegisterSpellScript(spell_kaelthas_summon_weapons); + RegisterSpellScript(spell_kaelthas_resurrection); + RegisterSpellScript(spell_kaelthas_mind_control); + RegisterSpellScript(spell_kaelthas_burn); + RegisterSpellScript(spell_kaelthas_flame_strike); + RegisterSpellScript(spell_kaelthas_gravity_lapse); + RegisterSpellScript(spell_kaelthas_nether_beam); + RegisterSpellScript(spell_kaelthas_summon_nether_vapor); }