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
This commit is contained in:
Jeremy
2023-05-09 05:20:35 +02:00
committed by GitHub
parent dc28475096
commit 205aba1ff3
26 changed files with 312 additions and 415 deletions
+116
View File
@@ -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);
}