From a1b8fd2054eb705f32dea20fa27ded4624e49f57 Mon Sep 17 00:00:00 2001 From: QAston Date: Wed, 25 May 2011 17:13:32 +0200 Subject: Core/AuraScripts: Add AfterEffectRemove and AfterEffectApply hooks, to allow safe triggering of spellcasts or other actions which may call linked events while OnEffectApply and OnEffectRemove are still there for overriding the way effect is handled on target. --- src/server/scripts/Examples/example_spell.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/server/scripts/Examples') diff --git a/src/server/scripts/Examples/example_spell.cpp b/src/server/scripts/Examples/example_spell.cpp index 212ed450ed5..22dc9adea37 100644 --- a/src/server/scripts/Examples/example_spell.cpp +++ b/src/server/scripts/Examples/example_spell.cpp @@ -166,17 +166,31 @@ class spell_ex_66244 : public SpellScriptLoader return false; } - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + + void HandleOnEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { sLog->outString("Aura Effect is about to be applied on target!"); + // this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler + //PreventDefaultAction(); + } + void HandleOnEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + sLog->outString("Aura Effect is about to be removed from target!"); + // this hook allows you to prevent execution of AuraEffect handler, or to replace it with your own handler + //PreventDefaultAction(); + } + + void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + sLog->outString("Aura Effect has just been applied on target!"); Unit* target = GetTarget(); // cast spell on target on aura apply target->CastSpell(target, SPELL_TRIGGERED, true); } - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void HandleAfterEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - sLog->outString("Aura Effect is just removed on target!"); + sLog->outString("Aura Effect has just been just removed from target!"); Unit* target = GetTarget(); Unit* caster = GetCaster(); // caster may be not avalible (logged out for example) @@ -243,8 +257,10 @@ class spell_ex_66244 : public SpellScriptLoader // function registering void Register() { - OnEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleOnEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleOnEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectApply += AuraEffectApplyFn(spell_ex_66244AuraScript::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_ex_66244AuraScript::HandleAfterEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); OnEffectPeriodic += AuraEffectPeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_DUMMY); OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_ex_66244AuraScript::HandleEffectPeriodicUpdate, EFFECT_0, SPELL_AURA_DUMMY); DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ex_66244AuraScript::HandleEffectCalcAmount, EFFECT_0, SPELL_AURA_DUMMY); -- cgit v1.2.3