From 6714feb3ee95fbc2967f7ea11c837d3caac90d3a Mon Sep 17 00:00:00 2001 From: QAston Date: Sat, 21 Aug 2010 20:18:54 +0200 Subject: *Add script hooks for SpellScript class - now you can use BeforeHit, OnHit, AfterHit hook lists. --HG-- branch : trunk --- src/server/game/Spells/SpellScript.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/server/game/Spells/SpellScript.h') diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index fae3dfcbd58..081b8035ca1 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -34,6 +34,7 @@ class Item; class WorldLocation; typedef void(SpellScript::*EffectHandlerFnType)(SpellEffIndex); +typedef void(SpellScript::*HitHandlerFnType)(); #define SPELL_EFFECT_ANY (uint16)-1 #define SPELL_AURA_ANY (uint16)-1 @@ -108,6 +109,7 @@ class SpellScript : public _SpellScript private: EffectHandlerFnType pEffectHandlerScript; }; + typedef HitHandlerFnType HitHandler; public: bool _Validate(SpellEntry const * entry, const char * scriptname); bool _Load(Spell * spell); @@ -127,6 +129,20 @@ class SpellScript : public _SpellScript // allows more than one hook // example EffectHandlers += EffectHandlerFn(class::function, EffectIndexSpecifier, EffectNameSpecifier); HookList EffectHandlers; + // List of functions registered by HitHandlerFn + // allows more than one hook + // example: BeforeHit += HitHandlerFn(class::function); + HookList BeforeHit; + // example: OnHit += HitHandlerFn(class::function); + HookList OnHit; + // example: AfterHit += HitHandlerFn(class::function); + HookList AfterHit; + + // hooks are executed in following order, at specified event of spell: + // 1. BeforeHit - executed just before spell hits a target + // 2. EffectHandlers - executed just before specified effect handler call + // 3. OnHit - executed just before spell deals damage and procs auras + // 4. AfterHit - executed just after spell finishes all it's jobs for target // // methods allowing interaction with Spell object @@ -196,6 +212,11 @@ class SpellScript : public _SpellScript // parameters: function to call, EffectIndexSpecifier, EffectNameSpecifier #define EffectHandlerFn(F, I, N) EffectHandler((EffectHandlerFnType)&F, I, N) +// HitHandlerFn +// called at: Spell hit on unit, before or after effect handlers, depends if bound to OnHit or AfterHit +// parameters: function to call +#define HitHandlerFn(F) (HitHandlerFnType)&F + // // definitions: // -- cgit v1.2.3