diff options
Diffstat (limited to 'src/server/game/Spells/SpellScript.h')
-rwxr-xr-x | src/server/game/Spells/SpellScript.h | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index dab77f6533d..67886becb74 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -64,6 +64,7 @@ class _SpellScript virtual void _Register(); virtual void _Unload(); virtual void _Init(std::string const* scriptname, uint32 spellId); + std::string const* _GetScriptName() const; protected: class EffectHook @@ -131,6 +132,9 @@ enum SpellScriptHookType SPELL_SCRIPT_HOOK_AFTER_HIT, SPELL_SCRIPT_HOOK_UNIT_TARGET_SELECT, SPELL_SCRIPT_HOOK_CHECK_CAST, + SPELL_SCRIPT_HOOK_BEFORE_CAST, + SPELL_SCRIPT_HOOK_ON_CAST, + SPELL_SCRIPT_HOOK_AFTER_CAST, }; #define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT_HIT @@ -148,10 +152,20 @@ class SpellScript : public _SpellScript typedef SpellCastResult(CLASSNAME::*SpellCheckCastFnType)(); \ typedef void(CLASSNAME::*SpellEffectFnType)(SpellEffIndex); \ typedef void(CLASSNAME::*SpellHitFnType)(); \ + typedef void(CLASSNAME::*SpellCastFnType)(); \ typedef void(CLASSNAME::*SpellUnitTargetFnType)(std::list<Unit*>&); \ SPELLSCRIPT_FUNCTION_TYPE_DEFINES(SpellScript) + class CastHandler + { + public: + CastHandler(SpellCastFnType _pCastHandlerScript); + void Call(SpellScript* spellScript); + private: + SpellCastFnType pCastHandlerScript; + }; + class CheckCastHandler { public: @@ -194,6 +208,7 @@ class SpellScript : public _SpellScript }; #define SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) \ + class CastHandlerFunction : public SpellScript::CastHandler { public: CastHandlerFunction(SpellCastFnType _pCastHandlerScript) : SpellScript::CastHandler((SpellScript::SpellCastFnType)_pCastHandlerScript) {} }; \ class CheckCastHandlerFunction : public SpellScript::CheckCastHandler { public: CheckCastHandlerFunction(SpellCheckCastFnType _checkCastHandlerScript) : SpellScript::CheckCastHandler((SpellScript::SpellCheckCastFnType)_checkCastHandlerScript) {} }; \ class EffectHandlerFunction : public SpellScript::EffectHandler { public: EffectHandlerFunction(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : SpellScript::EffectHandler((SpellScript::SpellEffectFnType)_pEffectHandlerScript, _effIndex, _effName) {} }; \ class HitHandlerFunction : public SpellScript::HitHandler { public: HitHandlerFunction(SpellHitFnType _pHitHandlerScript) : SpellScript::HitHandler((SpellScript::SpellHitFnType)_pHitHandlerScript) {} }; \ @@ -221,6 +236,13 @@ class SpellScript : public _SpellScript // SpellScript interface // hooks to which you can attach your functions // + // example: BeforeCast += SpellCastFn(class::function); + HookList<CastHandler> BeforeCast; + // example: OnCast += SpellCastFn(class::function); + HookList<CastHandler> OnCast; + // example: AfterCast += SpellCastFn(class::function); + HookList<CastHandler> AfterCast; + #define SpellCastFn(F) CastHandlerFunction(&F) // example: OnCheckCast += SpellCheckCastFn(); // where function is SpellCastResult function() @@ -250,14 +272,18 @@ class SpellScript : public _SpellScript #define SpellUnitTargetFn(F, I, N) UnitTargetHandlerFunction(&F, I, N) // hooks are executed in following order, at specified event of spell: - // 1. OnUnitTargetSelect - executed just before adding selected targets to final target list - // 2. OnEffectLaunch - executed just before specified effect handler call - when spell missile is launched - // 3. OnEffectLaunchTarget - executed just before specified effect handler call - when spell missile is launched - called for each target from spell target map - // 4. OnEffectHit - executed just before specified effect handler call - when spell missile hits dest - // 5. BeforeHit - executed just before spell hits a target - called for each target from spell target map - // 6. OnEffectHitTarget - executed just before specified effect handler call - called for each target from spell target map - // 7. OnHit - executed just before spell deals damage and procs auras - when spell hits target - called for each target from spell target map - // 8. AfterHit - executed just after spell finishes all it's jobs for target - called for each target from spell target map + // 1. BeforeCast - executed when spell preparation is finished (when cast bar becomes full) before cast is handled + // 2. OnCheckCast - allows to override result of CheckCast function + // 3. OnUnitTargetSelect - executed just before adding selected targets to final target list + // 4. OnCast - executed just before spell is launched (creates missile) or executed + // 5. AfterCast - executed after spell missile is launched and immediate spell actions are done + // 6. OnEffectLaunch - executed just before specified effect handler call - when spell missile is launched + // 7. OnEffectLaunchTarget - executed just before specified effect handler call - when spell missile is launched - called for each target from spell target map + // 8. OnEffectHit - executed just before specified effect handler call - when spell missile hits dest + // 9. BeforeHit - executed just before spell hits a target - called for each target from spell target map + // 10. OnEffectHitTarget - executed just before specified effect handler call - called for each target from spell target map + // 11. OnHit - executed just before spell deals damage and procs auras - when spell hits target - called for each target from spell target map + // 12. AfterHit - executed just after spell finishes all it's jobs for target - called for each target from spell target map // // methods allowing interaction with Spell object |