From 1f30a755dcc89e7ec160b2d5cad6c8f6b309d82a Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:01:13 -0300 Subject: [PATCH] refactor(Scripts/SCC): Update spell scripts to the new register model (#17726) --- .../boss_fathomlord_karathress.cpp | 18 +- .../boss_hydross_the_unstable.cpp | 107 +++----- .../SerpentShrine/boss_lady_vashj.cpp | 218 +++------------- .../boss_leotheras_the_blind.cpp | 212 ++++++---------- .../SerpentShrine/boss_lurker_below.cpp | 102 +++----- .../boss_morogrim_tidewalker.cpp | 114 ++++----- .../SerpentShrine/instance_serpent_shrine.cpp | 237 +++++++----------- 7 files changed, 330 insertions(+), 678 deletions(-) diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp index cd96bb672..574051d54 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp @@ -78,13 +78,7 @@ const Position advisorsPosition[MAX_ADVISORS] = struct boss_fathomlord_karathress : public BossAI { - boss_fathomlord_karathress(Creature* creature) : BossAI(creature, DATA_FATHOM_LORD_KARATHRESS) - { - scheduler.SetValidator([this] - { - return !me->HasUnitState(UNIT_STATE_CASTING); - }); - } + boss_fathomlord_karathress(Creature* creature) : BossAI(creature, DATA_FATHOM_LORD_KARATHRESS) { } void Reset() override { @@ -192,7 +186,7 @@ struct boss_fathomguard_sharkkis : public ScriptedAI { _instance = creature->GetInstanceScript(); - _scheduler.SetValidator([this] + scheduler.SetValidator([this] { return !me->HasUnitState(UNIT_STATE_CASTING); }); @@ -202,7 +196,7 @@ struct boss_fathomguard_sharkkis : public ScriptedAI void Reset() override { - _scheduler.CancelAll(); + scheduler.CancelAll(); summons.DespawnAll(); summons.clear(); @@ -220,7 +214,8 @@ struct boss_fathomguard_sharkkis : public ScriptedAI { karathress->Attack(who, false); } - _scheduler.Schedule(2500ms, [this](TaskContext context) + + scheduler.Schedule(2500ms, [this](TaskContext context) { DoCastRandomTarget(SPELL_HURL_TRIDENT); context.Repeat(5s); @@ -267,13 +262,12 @@ struct boss_fathomguard_sharkkis : public ScriptedAI return; } - _scheduler.Update(diff); + scheduler.Update(diff); DoMeleeAttackIfReady(); } private: - TaskScheduler _scheduler; InstanceScript* _instance; }; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp index 446f61ef8..3b90246b7 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_hydross_the_unstable.cpp @@ -250,101 +250,68 @@ private: bool _recentlySpoken; }; -class spell_hydross_cleansing_field_aura : public SpellScriptLoader +class spell_hydross_cleansing_field_aura : public AuraScript { -public: - spell_hydross_cleansing_field_aura() : SpellScriptLoader("spell_hydross_cleansing_field_aura") { } + PrepareAuraScript(spell_hydross_cleansing_field_aura); - class spell_hydross_cleansing_field_aura_AuraScript : public AuraScript + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_hydross_cleansing_field_aura_AuraScript) + if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE) + if (Unit* caster = GetCaster()) + caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true); + } - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE) - if (Unit* caster = GetCaster()) - caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true); - } - - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE) - if (Unit* caster = GetCaster()) - caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true); - } - - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_hydross_cleansing_field_aura_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_hydross_cleansing_field_aura_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_hydross_cleansing_field_aura_AuraScript(); + if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE) + if (Unit* caster = GetCaster()) + caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_hydross_cleansing_field_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_hydross_cleansing_field_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_hydross_cleansing_field_command : public SpellScriptLoader +class spell_hydross_cleansing_field_command : public AuraScript { -public: - spell_hydross_cleansing_field_command() : SpellScriptLoader("spell_hydross_cleansing_field_command") { } + PrepareAuraScript(spell_hydross_cleansing_field_command); - class spell_hydross_cleansing_field_command_AuraScript : public AuraScript + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_hydross_cleansing_field_command_AuraScript) + if (GetTarget()->HasUnitState(UNIT_STATE_CASTING)) + GetTarget()->InterruptNonMeleeSpells(false); + else + GetTarget()->CastSpell(GetTarget(), SPELL_BLUE_BEAM, true); + } - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTarget()->HasUnitState(UNIT_STATE_CASTING)) - GetTarget()->InterruptNonMeleeSpells(false); - else - GetTarget()->CastSpell(GetTarget(), SPELL_BLUE_BEAM, true); - } - - void Register() override - { - AfterEffectRemove += AuraEffectApplyFn(spell_hydross_cleansing_field_command_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_hydross_cleansing_field_command_AuraScript(); + AfterEffectRemove += AuraEffectApplyFn(spell_hydross_cleansing_field_command::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_hydross_mark_of_hydross : public SpellScriptLoader +class spell_hydross_mark_of_hydross : public AuraScript { -public: - spell_hydross_mark_of_hydross() : SpellScriptLoader("spell_hydross_mark_of_hydross") { } + PrepareAuraScript(spell_hydross_mark_of_hydross); - class spell_hydross_mark_of_hydross_AuraScript : public AuraScript + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_hydross_mark_of_hydross_AuraScript) + GetTarget()->RemoveAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, GetCasterGUID(), GetAura()); + } - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetTarget()->RemoveAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, GetCasterGUID(), GetAura()); - } - - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_hydross_mark_of_hydross_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_hydross_mark_of_hydross_AuraScript(); + OnEffectApply += AuraEffectApplyFn(spell_hydross_mark_of_hydross::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL); } }; void AddSC_boss_hydross_the_unstable() { RegisterSerpentShrineAI(boss_hydross_the_unstable); - new spell_hydross_cleansing_field_aura(); - new spell_hydross_cleansing_field_command(); - new spell_hydross_mark_of_hydross(); + RegisterSpellScript(spell_hydross_cleansing_field_aura); + RegisterSpellScript(spell_hydross_cleansing_field_command); + RegisterSpellScript(spell_hydross_mark_of_hydross); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp index 1e4354987..5a4e52876 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp @@ -286,226 +286,80 @@ private: std::chrono::seconds _batTimer; }; -/* - -//Toxic Sporebat -//Toxic Spores: Used in Phase 3 by the Spore Bats, it creates a contaminated green patch of ground, dealing about 2775-3225 nature damage every second to anyone who stands in it. -//deprecated -- adds do work -class npc_toxic_sporebat : public CreatureScript +class spell_lady_vashj_magic_barrier : public AuraScript { -public: - npc_toxic_sporebat() : CreatureScript("npc_toxic_sporebat") { } + PrepareAuraScript(spell_lady_vashj_magic_barrier); - CreatureAI* GetAI(Creature* creature) const + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return GetInstanceAI(creature); + Unit::DealDamage(GetTarget(), GetTarget(), GetTarget()->CountPctFromMaxHealth(5)); } - struct npc_toxic_sporebatAI : public ScriptedAI + void Register() override { - npc_toxic_sporebatAI(Creature* creature) : ScriptedAI(creature) - { - instance = creature->GetInstanceScript(); - EnterEvadeMode(); - } - - InstanceScript* instance; - - uint32 MovementTimer; - uint32 ToxicSporeTimer; - uint32 BoltTimer; - uint32 CheckTimer; - - void Reset() - { - me->SetDisableGravity(true); - me->SetFaction(FACTION_MONSTER); - MovementTimer = 0; - ToxicSporeTimer = 5000; - BoltTimer = 5500; - CheckTimer = 1000; - } - - void MoveInLineOfSight(Unit* who) - - { - } - - void MovementInform(uint32 type, uint32 id) - { - if (type != POINT_MOTION_TYPE) - return; - - if (id == 1) - MovementTimer = 0; - } - - void UpdateAI(uint32 diff) - { - // Random movement - if (MovementTimer <= diff) - { - uint32 rndpos = rand()%8; - me->GetMotionMaster()->MovePoint(1, SporebatWPPos[rndpos][0], SporebatWPPos[rndpos][1], SporebatWPPos[rndpos][2]); - MovementTimer = 6000; - } else MovementTimer -= diff; - - // toxic spores - if (BoltTimer <= diff) - { - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) - { - if (Creature* trig = me->SummonCreature(TOXIC_SPORES_TRIGGER, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000)) - { - trig->SetFaction(FACTION_MONSTER); - trig->CastSpell(trig, SPELL_TOXIC_SPORES, true); - } - } - BoltTimer = 10000+rand()%5000; - } - else BoltTimer -= diff; - - // CheckTimer - if (CheckTimer <= diff) - { - // check if vashj is death - Unit* Vashj = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_LADYVASHJ)); - if (!Vashj || !Vashj->IsAlive() || CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3) - { - // remove - me->setDeathState(DeathState::Dead); - me->RemoveCorpse(); - me->SetFaction(FACTION_FRIENDLY); - } - - CheckTimer = 1000; - } - else - CheckTimer -= diff; - } - }; - -}; -*/ - -class spell_lady_vashj_magic_barrier : public SpellScriptLoader -{ -public: - spell_lady_vashj_magic_barrier() : SpellScriptLoader("spell_lady_vashj_magic_barrier") { } - - class spell_lady_vashj_magic_barrier_AuraScript : public AuraScript - { - PrepareAuraScript(spell_lady_vashj_magic_barrier_AuraScript) - - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit::DealDamage(GetTarget(), GetTarget(), GetTarget()->CountPctFromMaxHealth(5)); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_lady_vashj_magic_barrier_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_SCHOOL_IMMUNITY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_lady_vashj_magic_barrier_AuraScript(); + AfterEffectRemove += AuraEffectRemoveFn(spell_lady_vashj_magic_barrier::HandleEffectRemove, EFFECT_0, SPELL_AURA_SCHOOL_IMMUNITY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_lady_vashj_remove_tainted_cores : public SpellScriptLoader +class spell_lady_vashj_remove_tainted_cores : public SpellScript { -public: - spell_lady_vashj_remove_tainted_cores() : SpellScriptLoader("spell_lady_vashj_remove_tainted_cores") { } + PrepareSpellScript(spell_lady_vashj_remove_tainted_cores); - class spell_lady_vashj_remove_tainted_cores_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_lady_vashj_remove_tainted_cores_SpellScript); - - void HandleScriptEffect(SpellEffIndex effIndex) + PreventHitDefaultEffect(effIndex); + if (Player* target = GetHitPlayer()) { - PreventHitDefaultEffect(effIndex); - if (Player* target = GetHitPlayer()) - { - target->DestroyItemCount(ITEM_TAINTED_CORE, -1, true); - } + target->DestroyItemCount(ITEM_TAINTED_CORE, -1, true); } + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_remove_tainted_cores_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_lady_vashj_remove_tainted_cores_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_remove_tainted_cores::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_lady_vashj_summon_sporebat : public SpellScriptLoader +class spell_lady_vashj_summon_sporebat : public SpellScript { -public: - spell_lady_vashj_summon_sporebat() : SpellScriptLoader("spell_lady_vashj_summon_sporebat") { } + PrepareSpellScript(spell_lady_vashj_summon_sporebat); - class spell_lady_vashj_summon_sporebat_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_lady_vashj_summon_sporebat_SpellScript); + PreventHitDefaultEffect(effIndex); + GetCaster()->CastSpell(GetCaster(), RAND(SPELL_SUMMON_SPOREBAT1, SPELL_SUMMON_SPOREBAT2, SPELL_SUMMON_SPOREBAT3, SPELL_SUMMON_SPOREBAT4), true); + } - void HandleScriptEffect(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), RAND(SPELL_SUMMON_SPOREBAT1, SPELL_SUMMON_SPOREBAT2, SPELL_SUMMON_SPOREBAT3, SPELL_SUMMON_SPOREBAT4), true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_summon_sporebat_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_lady_vashj_summon_sporebat_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_summon_sporebat::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_lady_vashj_spore_drop_effect : public SpellScriptLoader +class spell_lady_vashj_spore_drop_effect : public SpellScript { -public: - spell_lady_vashj_spore_drop_effect() : SpellScriptLoader("spell_lady_vashj_spore_drop_effect") { } + PrepareSpellScript(spell_lady_vashj_spore_drop_effect); - class spell_lady_vashj_spore_drop_effect_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_lady_vashj_spore_drop_effect_SpellScript); - - void HandleScriptEffect(SpellEffIndex effIndex) + PreventHitDefaultEffect(effIndex); + if (Unit* target = GetHitUnit()) { - PreventHitDefaultEffect(effIndex); - if (Unit* target = GetHitUnit()) - { - target->CastSpell(target, SPELL_TOXIC_SPORES, true, nullptr, nullptr, GetCaster()->GetGUID()); - } + target->CastSpell(target, SPELL_TOXIC_SPORES, true, nullptr, nullptr, GetCaster()->GetGUID()); } + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_spore_drop_effect_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_lady_vashj_spore_drop_effect_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_spore_drop_effect::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; void AddSC_boss_lady_vashj() { RegisterSerpentShrineAI(boss_lady_vashj); - new spell_lady_vashj_magic_barrier(); - new spell_lady_vashj_remove_tainted_cores(); - new spell_lady_vashj_summon_sporebat(); - new spell_lady_vashj_spore_drop_effect(); + RegisterSpellScript(spell_lady_vashj_magic_barrier); + RegisterSpellScript(spell_lady_vashj_remove_tainted_cores); + RegisterSpellScript(spell_lady_vashj_summon_sporebat); + RegisterSpellScript(spell_lady_vashj_spore_drop_effect); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 26332f534..e162c8ade 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -227,12 +227,10 @@ struct npc_inner_demon : public ScriptedAI { npc_inner_demon(Creature* creature) : ScriptedAI(creature) { - _scheduler.SetValidator([this] + scheduler.SetValidator([this] { return !me->HasUnitState(UNIT_STATE_CASTING); }); - - _instance = creature->GetInstanceScript(); } void IsSummonedBy(WorldObject* summoner) override @@ -247,8 +245,8 @@ struct npc_inner_demon : public ScriptedAI me->Attack(affectedPlayer, true); } - _scheduler.CancelAll(); - _scheduler.Schedule(4s, [this](TaskContext context) + scheduler.CancelAll(); + scheduler.Schedule(4s, [this](TaskContext context) { DoCastVictim(SPELL_SHADOW_BOLT); context.Repeat(6s); @@ -283,196 +281,134 @@ struct npc_inner_demon : public ScriptedAI return; } - _scheduler.Update(diff); + scheduler.Update(diff); DoMeleeAttackIfReady(); } private: - TaskScheduler _scheduler; - InstanceScript* _instance; ObjectGuid _affectedPlayerGUID; }; -class spell_leotheras_whirlwind : public SpellScriptLoader +class spell_leotheras_whirlwind : public SpellScript { -public: - spell_leotheras_whirlwind() : SpellScriptLoader("spell_leotheras_whirlwind") { } + PrepareSpellScript(spell_leotheras_whirlwind); - class spell_leotheras_whirlwind_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_leotheras_whirlwind_SpellScript); + PreventHitDefaultEffect(effIndex); + GetCaster()->GetThreatMgr().ResetAllThreat(); - void HandleScriptEffect(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->GetThreatMgr().ResetAllThreat(); + if (roll_chance_i(33)) + if (Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 30.0f, true)) + target->CastSpell(GetCaster(), SPELL_TAUNT, true); + } - if (roll_chance_i(33)) - if (Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 30.0f, true)) - target->CastSpell(GetCaster(), SPELL_TAUNT, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_leotheras_whirlwind_SpellScript::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_leotheras_whirlwind_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_leotheras_whirlwind::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_leotheras_chaos_blast : public SpellScriptLoader +class spell_leotheras_chaos_blast : public SpellScript { -public: - spell_leotheras_chaos_blast() : SpellScriptLoader("spell_leotheras_chaos_blast") { } + PrepareSpellScript(spell_leotheras_chaos_blast); - class spell_leotheras_chaos_blast_SpellScript : public SpellScript + void HandleDummy(SpellEffIndex effIndex) { - PrepareSpellScript(spell_leotheras_chaos_blast_SpellScript); + PreventHitDefaultEffect(effIndex); + if (Unit* target = GetHitUnit()) + GetCaster()->CastSpell(target, SPELL_CHAOS_BLAST_TRIGGER, true); + } - void HandleDummy(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, SPELL_CHAOS_BLAST_TRIGGER, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_leotheras_chaos_blast_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_leotheras_chaos_blast_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_leotheras_chaos_blast::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; -class spell_leotheras_insidious_whisper : public SpellScriptLoader +class spell_leotheras_insidious_whisper : public SpellScript { -public: - spell_leotheras_insidious_whisper() : SpellScriptLoader("spell_leotheras_insidious_whisper") { } + PrepareSpellScript(spell_leotheras_insidious_whisper); - class spell_leotheras_insidious_whisper_SpellScript : public SpellScript + void FilterTargets(std::list& unitList) { - PrepareSpellScript(spell_leotheras_insidious_whisper_SpellScript); - - void FilterTargets(std::list& unitList) + if (Unit* victim = GetCaster()->GetVictim()) { - if (Unit* victim = GetCaster()->GetVictim()) - { - unitList.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true)); - } + unitList.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true)); } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_leotheras_insidious_whisper_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_leotheras_insidious_whisper_SpellScript(); } - class spell_leotheras_insidious_whisper_AuraScript : public AuraScript + void Register() override { - PrepareAuraScript(spell_leotheras_insidious_whisper_AuraScript) + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_leotheras_insidious_whisper::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + } +}; - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_INNER_DEMON, true); - } +class spell_leotheras_insidious_whisper_aura : public AuraScript +{ + PrepareAuraScript(spell_leotheras_insidious_whisper_aura); - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_INNER_DEMON, true); + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT) { - if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT) + if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) { - if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) + if (Creature* leotheras = instance->GetCreature(DATA_LEOTHERAS_THE_BLIND)) { - if (Creature* leotheras = instance->GetCreature(DATA_LEOTHERAS_THE_BLIND)) - { - leotheras->CastSpell(GetUnitOwner(), SPELL_CONSUMING_MADNESS, true); - } + leotheras->CastSpell(GetUnitOwner(), SPELL_CONSUMING_MADNESS, true); } } } + } - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_leotheras_insidious_whisper_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_leotheras_insidious_whisper_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_leotheras_insidious_whisper_AuraScript(); + AfterEffectApply += AuraEffectApplyFn(spell_leotheras_insidious_whisper_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_leotheras_insidious_whisper_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_leotheras_demon_link : public SpellScriptLoader +class spell_leotheras_demon_link : public AuraScript { -public: - spell_leotheras_demon_link() : SpellScriptLoader("spell_leotheras_demon_link") { } + PrepareAuraScript(spell_leotheras_demon_link); - class spell_leotheras_demon_link_AuraScript : public AuraScript + void OnPeriodic(AuraEffect const* aurEff) { - PrepareAuraScript(spell_leotheras_demon_link_AuraScript); - - void OnPeriodic(AuraEffect const* aurEff) + PreventDefaultAction(); + if (Unit* victim = GetUnitOwner()->GetVictim()) { - PreventDefaultAction(); - if (Unit* victim = GetUnitOwner()->GetVictim()) - { - GetUnitOwner()->CastSpell(victim, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true); - } + GetUnitOwner()->CastSpell(victim, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true); } + } - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_leotheras_demon_link_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_leotheras_demon_link_AuraScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_leotheras_demon_link::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; -class spell_leotheras_clear_consuming_madness : public SpellScriptLoader +class spell_leotheras_clear_consuming_madness : public SpellScript { -public: - spell_leotheras_clear_consuming_madness() : SpellScriptLoader("spell_leotheras_clear_consuming_madness") { } + PrepareSpellScript(spell_leotheras_clear_consuming_madness); - class spell_leotheras_clear_consuming_madness_SpellScript : public SpellScript + void HandleScriptEffect(SpellEffIndex effIndex) { - PrepareSpellScript(spell_leotheras_clear_consuming_madness_SpellScript); - - void HandleScriptEffect(SpellEffIndex effIndex) + PreventHitDefaultEffect(effIndex); + if (Unit* target = GetHitUnit()) { - PreventHitDefaultEffect(effIndex); - if (Unit* target = GetHitUnit()) - { - Unit::Kill(GetCaster(), target); - } + Unit::Kill(GetCaster(), target); } + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_leotheras_clear_consuming_madness_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_leotheras_clear_consuming_madness_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_leotheras_clear_consuming_madness::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -480,9 +416,9 @@ void AddSC_boss_leotheras_the_blind() { RegisterSerpentShrineAI(boss_leotheras_the_blind); RegisterSerpentShrineAI(npc_inner_demon); - new spell_leotheras_whirlwind(); - new spell_leotheras_chaos_blast(); - new spell_leotheras_insidious_whisper(); - new spell_leotheras_demon_link(); - new spell_leotheras_clear_consuming_madness(); + RegisterSpellScript(spell_leotheras_whirlwind); + RegisterSpellScript(spell_leotheras_chaos_blast); + RegisterSpellAndAuraScriptPair(spell_leotheras_insidious_whisper, spell_leotheras_insidious_whisper_aura); + RegisterSpellScript(spell_leotheras_demon_link); + RegisterSpellScript(spell_leotheras_clear_consuming_madness); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index c2287f8ba..b91d66158 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -63,13 +63,7 @@ const Position positions[MAX_SUMMONS] = struct boss_the_lurker_below : public BossAI { - boss_the_lurker_below(Creature* creature) : BossAI(creature, DATA_THE_LURKER_BELOW) - { - scheduler.SetValidator([this] - { - return !me->HasUnitState(UNIT_STATE_CASTING); - }); - } + boss_the_lurker_below(Creature* creature) : BossAI(creature, DATA_THE_LURKER_BELOW) { } void Reset() override { @@ -226,49 +220,38 @@ public: } }; -class spell_lurker_below_spout : public SpellScriptLoader +class spell_lurker_below_spout : public AuraScript { -public: - spell_lurker_below_spout() : SpellScriptLoader("spell_lurker_below_spout") { } + PrepareAuraScript(spell_lurker_below_spout); - class spell_lurker_below_spout_AuraScript : public AuraScript + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_lurker_below_spout_AuraScript); + SetDuration(13000); + } - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - SetDuration(13000); - } - - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Creature* creature = GetUnitOwner()->ToCreature()) - { - creature->resetAttackTimer(); - creature->SetReactState(REACT_AGGRESSIVE); - if (Unit* target = creature->GetVictim()) - creature->SetTarget(target->GetGUID()); - } - } - - void OnPeriodic(AuraEffect const* aurEff) - { - PreventDefaultAction(); - GetUnitOwner()->SetFacingTo(Position::NormalizeOrientation(GetUnitOwner()->GetOrientation() + 0.1f)); - GetUnitOwner()->CastSpell(GetUnitOwner(), aurEff->GetAmount(), true); - } - - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_lurker_below_spout_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_lurker_below_spout_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - OnEffectPeriodic += AuraEffectPeriodicFn(spell_lurker_below_spout_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_lurker_below_spout_AuraScript(); + if (Creature* creature = GetUnitOwner()->ToCreature()) + { + creature->resetAttackTimer(); + creature->SetReactState(REACT_AGGRESSIVE); + if (Unit* target = creature->GetVictim()) + creature->SetTarget(target->GetGUID()); + } + } + + void OnPeriodic(AuraEffect const* aurEff) + { + PreventDefaultAction(); + GetUnitOwner()->SetFacingTo(Position::NormalizeOrientation(GetUnitOwner()->GetOrientation() + 0.1f)); + GetUnitOwner()->CastSpell(GetUnitOwner(), aurEff->GetAmount(), true); + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_lurker_below_spout::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_lurker_below_spout::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_lurker_below_spout::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; @@ -286,29 +269,18 @@ private: Unit* _caster; }; -class spell_lurker_below_spout_cone : public SpellScriptLoader +class spell_lurker_below_spout_cone : public SpellScript { -public: - spell_lurker_below_spout_cone() : SpellScriptLoader("spell_lurker_below_spout_cone") { } + PrepareSpellScript(spell_lurker_below_spout_cone); - class spell_lurker_below_spout_cone_SpellScript : public SpellScript + void FilterTargets(std::list& targets) { - PrepareSpellScript(spell_lurker_below_spout_cone_SpellScript); + targets.remove_if(HasInLineCheck(GetCaster())); + } - void FilterTargets(std::list& targets) - { - targets.remove_if(HasInLineCheck(GetCaster())); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lurker_below_spout_cone_SpellScript::FilterTargets, EFFECT_ALL, TARGET_UNIT_CONE_ENEMY_24); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_lurker_below_spout_cone_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lurker_below_spout_cone::FilterTargets, EFFECT_ALL, TARGET_UNIT_CONE_ENEMY_24); } }; @@ -316,6 +288,6 @@ void AddSC_boss_the_lurker_below() { RegisterSerpentShrineAI(boss_the_lurker_below); new go_strange_pool(); - new spell_lurker_below_spout(); - new spell_lurker_below_spout_cone(); + RegisterSpellScript(spell_lurker_below_spout); + RegisterSpellScript(spell_lurker_below_spout_cone); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp index e16d84e75..fc03a32e9 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp @@ -138,89 +138,67 @@ private: bool _recentlySpoken; }; -class spell_morogrim_tidewalker_watery_grave : public SpellScriptLoader +class spell_morogrim_tidewalker_watery_grave : public SpellScript { -public: - spell_morogrim_tidewalker_watery_grave() : SpellScriptLoader("spell_morogrim_tidewalker_watery_grave") { } + PrepareSpellScript(spell_morogrim_tidewalker_watery_grave); - class spell_morogrim_tidewalker_watery_grave_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_morogrim_tidewalker_watery_grave_SpellScript); - - bool Load() override - { - _targetNumber = 0; - return true; - } - - void HandleDummy(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Unit* target = GetHitUnit()) - if (_targetNumber < 4) - GetCaster()->CastSpell(target, wateryGraveIds[_targetNumber++], true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_watery_grave_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - - private: - uint8 _targetNumber; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_morogrim_tidewalker_watery_grave_SpellScript(); + _targetNumber = 0; + return true; } + + void HandleDummy(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (Unit* target = GetHitUnit()) + if (_targetNumber < 4) + GetCaster()->CastSpell(target, wateryGraveIds[_targetNumber++], true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_watery_grave::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + +private: + uint8 _targetNumber; }; -class spell_morogrim_tidewalker_water_globule_new_target : public SpellScriptLoader +class spell_morogrim_tidewalker_water_globule_new_target : public SpellScript { -public: - spell_morogrim_tidewalker_water_globule_new_target() : SpellScriptLoader("spell_morogrim_tidewalker_water_globule_new_target") { } + PrepareSpellScript(spell_morogrim_tidewalker_water_globule_new_target); - class spell_morogrim_tidewalker_water_globule_new_target_SpellScript : public SpellScript + void FilterTargets(std::list& unitList) { - PrepareSpellScript(spell_morogrim_tidewalker_water_globule_new_target_SpellScript); + Acore::Containers::RandomResize(unitList, 1); + } - void FilterTargets(std::list& unitList) - { - Acore::Containers::RandomResize(unitList, 1); - } - - void HandleDummy(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - - // Xinef: if we have target we currently follow, return - if (Unit* target = GetCaster()->GetVictim()) - if (GetCaster()->GetThreatMgr().GetThreat(target) >= 100000.0f) - return; - - // Xinef: acquire new target - // TODO: sniffs to see how this actually happens - if (Unit* target = GetHitUnit()) - GetCaster()->AddThreat(target, 1000000.0f); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_morogrim_tidewalker_water_globule_new_target_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_water_globule_new_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override + void HandleDummy(SpellEffIndex effIndex) { - return new spell_morogrim_tidewalker_water_globule_new_target_SpellScript(); + PreventHitDefaultEffect(effIndex); + + // Xinef: if we have target we currently follow, return + if (Unit* target = GetCaster()->GetVictim()) + if (GetCaster()->GetThreatMgr().GetThreat(target) >= 100000.0f) + return; + + // Xinef: acquire new target + // TODO: sniffs to see how this actually happens + if (Unit* target = GetHitUnit()) + GetCaster()->AddThreat(target, 1000000.0f); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_morogrim_tidewalker_water_globule_new_target::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_water_globule_new_target::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; void AddSC_boss_morogrim_tidewalker() { RegisterSerpentShrineAI(boss_morogrim_tidewalker); - new spell_morogrim_tidewalker_watery_grave(); - new spell_morogrim_tidewalker_water_globule_new_target(); + RegisterSpellScript(spell_morogrim_tidewalker_watery_grave); + RegisterSpellScript(spell_morogrim_tidewalker_water_globule_new_target); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp index 2aa674ebc..2ca167733 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp @@ -208,185 +208,136 @@ public: } }; -class spell_serpentshrine_cavern_serpentshrine_parasite : public SpellScriptLoader +class spell_serpentshrine_cavern_serpentshrine_parasite : public AuraScript { -public: - spell_serpentshrine_cavern_serpentshrine_parasite() : SpellScriptLoader("spell_serpentshrine_cavern_serpentshrine_parasite") { } + PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite); - class spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript : public AuraScript + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript) + if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress()) + GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true); + } - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress()) - GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript(); + AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); } }; -class spell_serpentshrine_cavern_serpentshrine_parasite_trigger : public SpellScriptLoader +class spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura : public AuraScript { -public: - spell_serpentshrine_cavern_serpentshrine_parasite_trigger() : SpellScriptLoader("spell_serpentshrine_cavern_serpentshrine_parasite_trigger") { } + PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura); - class spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript : public AuraScript + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript) - - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress()) - GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript(); + if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress()) + GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true); } - class spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript : public SpellScript + void Register() override { - PrepareSpellScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript); - - void HandleApplyAura(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Creature* target = GetHitCreature()) - target->DespawnOrUnsummon(1); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript::HandleApplyAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript(); + AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); } }; -class spell_serpentshrine_cavern_infection : public SpellScriptLoader +class spell_serpentshrine_cavern_serpentshrine_parasite_trigger : public SpellScript { -public: - spell_serpentshrine_cavern_infection() : SpellScriptLoader("spell_serpentshrine_cavern_infection") { } + PrepareSpellScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger); - class spell_serpentshrine_cavern_infection_AuraScript : public AuraScript + void HandleApplyAura(SpellEffIndex effIndex) { - PrepareAuraScript(spell_serpentshrine_cavern_infection_AuraScript) + PreventHitDefaultEffect(effIndex); + if (Creature* target = GetHitCreature()) + target->DespawnOrUnsummon(1); + } - void HandleEffectRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTarget()->GetInstanceScript()) - { - CustomSpellValues values; - values.AddSpellMod(SPELLVALUE_MAX_TARGETS, 1); - values.AddSpellMod(SPELLVALUE_BASE_POINT0, aurEff->GetAmount() + 500); - values.AddSpellMod(SPELLVALUE_BASE_POINT1, aurEff->GetAmount() + 500); - GetTarget()->CastCustomSpell(SPELL_RAMPART_INFECTION, values, GetTarget(), TRIGGERED_FULL_MASK, nullptr); - } - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_infection_AuraScript::HandleEffectRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_serpentshrine_cavern_infection_AuraScript(); + OnEffectHitTarget += SpellEffectFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger::HandleApplyAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA); } }; -class spell_serpentshrine_cavern_coilfang_water : public SpellScriptLoader +class spell_serpentshrine_cavern_infection : public AuraScript { -public: - spell_serpentshrine_cavern_coilfang_water() : SpellScriptLoader("spell_serpentshrine_cavern_coilfang_water") { } + PrepareAuraScript(spell_serpentshrine_cavern_infection); - class spell_serpentshrine_cavern_coilfang_water_AuraScript : public AuraScript + void HandleEffectRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_serpentshrine_cavern_coilfang_water_AuraScript) - - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTarget()->GetInstanceScript()) { - if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) - if (instance->GetBossState(DATA_THE_LURKER_BELOW) != DONE) - if (instance->GetData(DATA_ALIVE_KEEPERS) == 0) - GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SCALDING_WATER, true); + CustomSpellValues values; + values.AddSpellMod(SPELLVALUE_MAX_TARGETS, 1); + values.AddSpellMod(SPELLVALUE_BASE_POINT0, aurEff->GetAmount() + 500); + values.AddSpellMod(SPELLVALUE_BASE_POINT1, aurEff->GetAmount() + 500); + GetTarget()->CastCustomSpell(SPELL_RAMPART_INFECTION, values, GetTarget(), TRIGGERED_FULL_MASK, nullptr); } + } - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetUnitOwner()->RemoveAurasDueToSpell(SPELL_SCALDING_WATER); - } - - void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude) - { - InstanceScript* instance = GetUnitOwner()->GetInstanceScript(); - if (!instance || instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE) - return; - - isPeriodic = true; - amplitude = 8 * IN_MILLISECONDS; - } - - void HandlePeriodic(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - InstanceScript* instance = GetUnitOwner()->GetInstanceScript(); - if (!instance || GetUnitOwner()->GetMapId() != 548) - { - SetDuration(0); - return; - } - - if (instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE || instance->GetData(DATA_ALIVE_KEEPERS) == 0 || GetUnitOwner()->GetPositionZ() > -20.5f || !GetUnitOwner()->IsInWater()) - return; - - for (uint8 i = 0; i < 3; ++i) - GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_FRENZY_WATER, true); - } - - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - - DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY); - OnEffectPeriodic += AuraEffectPeriodicFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_serpentshrine_cavern_coilfang_water_AuraScript(); + AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_infection::HandleEffectRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } +}; + +class spell_serpentshrine_cavern_coilfang_water : public AuraScript +{ + PrepareAuraScript(spell_serpentshrine_cavern_coilfang_water); + + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) + if (instance->GetBossState(DATA_THE_LURKER_BELOW) != DONE) + if (instance->GetData(DATA_ALIVE_KEEPERS) == 0) + GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SCALDING_WATER, true); + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetUnitOwner()->RemoveAurasDueToSpell(SPELL_SCALDING_WATER); + } + + void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude) + { + InstanceScript* instance = GetUnitOwner()->GetInstanceScript(); + if (!instance || instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE) + return; + + isPeriodic = true; + amplitude = 8 * IN_MILLISECONDS; + } + + void HandlePeriodic(AuraEffect const* /*aurEff*/) + { + PreventDefaultAction(); + InstanceScript* instance = GetUnitOwner()->GetInstanceScript(); + if (!instance || GetUnitOwner()->GetMapId() != 548) + { + SetDuration(0); + return; + } + + if (instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE || instance->GetData(DATA_ALIVE_KEEPERS) == 0 || GetUnitOwner()->GetPositionZ() > -20.5f || !GetUnitOwner()->IsInWater()) + return; + + for (uint8 i = 0; i < 3; ++i) + GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_FRENZY_WATER, true); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_serpentshrine_cavern_coilfang_water::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_coilfang_water::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + + DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_serpentshrine_cavern_coilfang_water::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_serpentshrine_cavern_coilfang_water::HandlePeriodic, EFFECT_0, SPELL_AURA_DUMMY); } }; void AddSC_instance_serpentshrine_cavern() { new instance_serpent_shrine(); - new spell_serpentshrine_cavern_serpentshrine_parasite(); - new spell_serpentshrine_cavern_serpentshrine_parasite_trigger(); - new spell_serpentshrine_cavern_infection(); - new spell_serpentshrine_cavern_coilfang_water(); + RegisterSpellScript(spell_serpentshrine_cavern_serpentshrine_parasite); + RegisterSpellAndAuraScriptPair(spell_serpentshrine_cavern_serpentshrine_parasite_trigger, spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura); + RegisterSpellScript(spell_serpentshrine_cavern_infection); + RegisterSpellScript(spell_serpentshrine_cavern_coilfang_water); }