diff options
| author | Jeremy <Golrag@users.noreply.github.com> | 2023-05-09 05:20:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-09 05:20:35 +0200 |
| commit | 205aba1ff3a6f1ff92a8b26af646fd25f139c697 (patch) | |
| tree | a2273ad956ee236dd4044d114759d9e24211468c /src/server/scripts/Spells | |
| parent | dc284750968d1816cc4271f4c6a6dbcdcdfd3f51 (diff) | |
Core/Battlegrounds: Moved AreaSpiritHealer resurrection handling to respective npc flags (#28508)
* UNIT_NPC_FLAG_AREA_SPIRIT_HEALER
* UNIT_NPC_FLAG_2_AREA_SPIRIT_HEALER_INDIVIDUAL
Diffstat (limited to 'src/server/scripts/Spells')
| -rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index e5346f910bb..3176c5704fa 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -5415,6 +5415,118 @@ private: uint32 _exhaustionSpellId; }; +// AoE resurrections by spirit guides +// 22012 - Spirit Heal +class spell_gen_spirit_heal_aoe : public SpellScript +{ + PrepareSpellScript(spell_gen_spirit_heal_aoe); + + void FilterTargets(std::list<WorldObject*>& targets) + { + Unit* caster = GetCaster(); + targets.remove_if([caster](WorldObject* target) -> bool + { + if (Player* playerTarget = target->ToPlayer()) + return !playerTarget->CanAcceptAreaSpiritHealFrom(caster); + + return true; + }); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_gen_spirit_heal_aoe::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY); + } +}; + +// Personal resurrections in battlegrounds +// 156758 - Spirit Heal +class spell_gen_spirit_heal_personal : public AuraScript +{ + static constexpr uint32 SPELL_SPIRIT_HEAL_EFFECT = 156763; + + PrepareAuraScript(spell_gen_spirit_heal_personal); + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) + return; + + Player* targetPlayer = GetTarget()->ToPlayer(); + if (!targetPlayer) + return; + + Unit* caster = GetCaster(); + if (!caster) + return; + + if (targetPlayer->CanAcceptAreaSpiritHealFrom(caster)) + caster->CastSpell(targetPlayer, SPELL_SPIRIT_HEAL_EFFECT); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_gen_spirit_heal_personal::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } +}; + +class RecastSpiritHealChannelEvent : public BasicEvent +{ +public: + RecastSpiritHealChannelEvent(Unit* caster) : _caster(caster) { } + + bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) override + { + if (_caster->GetChannelSpellId() == 0) + _caster->CastSpell(nullptr, SPELL_SPIRIT_HEAL_CHANNEL_AOE, false); + + return true; + } + +private: + Unit* _caster; +}; + +// 22011 - Spirit Heal Channel +class spell_gen_spirit_heal_channel : public AuraScript +{ + PrepareAuraScript(spell_gen_spirit_heal_channel); + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) + return; + + Unit* target = GetTarget(); + target->m_Events.AddEventAtOffset(new RecastSpiritHealChannelEvent(target), 1s); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_gen_spirit_heal_channel::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + } +}; + +// 2584 - Waiting to Resurrect +class spell_gen_waiting_to_resurrect : public AuraScript +{ + PrepareAuraScript(spell_gen_waiting_to_resurrect); + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Player* targetPlayer = GetTarget()->ToPlayer(); + if (!targetPlayer) + return; + + targetPlayer->SetAreaSpiritHealer(nullptr); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_gen_waiting_to_resurrect::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } +}; + void AddSC_generic_spell_scripts() { RegisterSpellScript(spell_gen_absorb0_hitlimit1); @@ -5584,4 +5696,8 @@ void AddSC_generic_spell_scripts() RegisterSpellScriptWithArgs(spell_gen_bloodlust, "spell_hun_primal_rage", SPELL_HUNTER_FATIGUED); RegisterSpellScriptWithArgs(spell_gen_bloodlust, "spell_evo_fury_of_the_aspects", SPELL_EVOKER_EXHAUSTION); RegisterSpellScriptWithArgs(spell_gen_bloodlust, "spell_item_bloodlust_drums", SPELL_SHAMAN_EXHAUSTION); + RegisterSpellScript(spell_gen_spirit_heal_aoe); + RegisterSpellScript(spell_gen_spirit_heal_personal); + RegisterSpellScript(spell_gen_spirit_heal_channel); + RegisterSpellScript(spell_gen_waiting_to_resurrect); } |
