aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellScript.h
diff options
context:
space:
mode:
authorjoschiwald <joschiwald@online.de>2013-01-11 01:21:44 +0100
committerjoschiwald <joschiwald@online.de>2013-01-11 01:21:44 +0100
commit89490e4d7f4abff0eb756fcf07fbf21d7ca6381b (patch)
tree5c0635680c6c44d9d51e2784d83eb26f3c16a561 /src/server/game/Spells/SpellScript.h
parent5f28502c0a5a6a480055705c59b074b5333d7d63 (diff)
Core/SpellScripts: implement Spell Proc Hooks and use it in old and new proc system
Hooks: - DoCheckProc: executed when aura checks if it can proc - DoPrepareProc: executed before aura procs (possibility to prevent charge drop/cooldown) - OnProc: executed when aura procs - OnEffectProc: executed when aura effect procs - AfterEffectProc: executed after aura effect proced - AfterProc: executed after aura proced and charges removed using PreventDefaultAction() in DoPrepareProc will prevent charge drop and cooldown default execution of a proc can prevented in OnEffectProc with PreventDefaultAction() Now we should be able to convert almost all procs from Unit::ProcDamageAndSpellFor to SpellScripts Notes to old proc system: - if a proc has a cooldown we must check it in spellscript and add it when we handle the proc - behavior with charge drops is possible undefined (use PreventDefaultAction() in OnEffectProc to notify that the script is executed)
Diffstat (limited to 'src/server/game/Spells/SpellScript.h')
-rw-r--r--src/server/game/Spells/SpellScript.h72
1 files changed, 70 insertions, 2 deletions
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 5791c701c07..6f1df2560dc 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -428,14 +428,22 @@ enum AuraScriptHookType
AURA_SCRIPT_HOOK_EFFECT_SPLIT,
AURA_SCRIPT_HOOK_CHECK_AREA_TARGET,
AURA_SCRIPT_HOOK_DISPEL,
- AURA_SCRIPT_HOOK_AFTER_DISPEL
+ AURA_SCRIPT_HOOK_AFTER_DISPEL,
+ // Spell Proc Hooks
+ AURA_SCRIPT_HOOK_CHECK_PROC,
+ AURA_SCRIPT_HOOK_PREPARE_PROC,
+ AURA_SCRIPT_HOOK_PROC,
+ AURA_SCRIPT_HOOK_EFFECT_PROC,
+ AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC,
+ AURA_SCRIPT_HOOK_AFTER_PROC,
/*AURA_SCRIPT_HOOK_APPLY,
AURA_SCRIPT_HOOK_REMOVE, */
};
+/*
#define HOOK_AURA_EFFECT_START HOOK_AURA_EFFECT_APPLY
#define HOOK_AURA_EFFECT_END HOOK_AURA_EFFECT_CALC_SPELLMOD + 1
#define HOOK_AURA_EFFECT_COUNT HOOK_AURA_EFFECT_END - HOOK_AURA_EFFECT_START
-
+*/
class AuraScript : public _SpellScript
{
// internal use classes & functions
@@ -453,6 +461,9 @@ class AuraScript : public _SpellScript
typedef void(CLASSNAME::*AuraEffectCalcSpellModFnType)(AuraEffect const*, SpellModifier* &); \
typedef void(CLASSNAME::*AuraEffectAbsorbFnType)(AuraEffect*, DamageInfo &, uint32 &); \
typedef void(CLASSNAME::*AuraEffectSplitFnType)(AuraEffect*, DamageInfo &, uint32 &); \
+ typedef bool(CLASSNAME::*AuraCheckProcFnType)(ProcEventInfo&); \
+ typedef void(CLASSNAME::*AuraProcFnType)(ProcEventInfo&); \
+ typedef void(CLASSNAME::*AuraEffectProcFnType)(AuraEffect const*, ProcEventInfo&); \
AURASCRIPT_FUNCTION_TYPE_DEFINES(AuraScript)
@@ -552,6 +563,30 @@ class AuraScript : public _SpellScript
private:
AuraEffectSplitFnType pEffectHandlerScript;
};
+ class CheckProcHandler
+ {
+ public:
+ CheckProcHandler(AuraCheckProcFnType handlerScript);
+ bool Call(AuraScript* auraScript, ProcEventInfo& eventInfo);
+ private:
+ AuraCheckProcFnType _HandlerScript;
+ };
+ class AuraProcHandler
+ {
+ public:
+ AuraProcHandler(AuraProcFnType handlerScript);
+ void Call(AuraScript* auraScript, ProcEventInfo& eventInfo);
+ private:
+ AuraProcFnType _HandlerScript;
+ };
+ class EffectProcHandler : public EffectBase
+ {
+ public:
+ EffectProcHandler(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName);
+ void Call(AuraScript* auraScript, AuraEffect const* aurEff, ProcEventInfo& eventInfo);
+ private:
+ AuraEffectProcFnType _EffectHandlerScript;
+ };
#define AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) \
class CheckAreaTargetFunction : public AuraScript::CheckAreaTargetHandler { public: CheckAreaTargetFunction(AuraCheckAreaTargetFnType _pHandlerScript) : AuraScript::CheckAreaTargetHandler((AuraScript::AuraCheckAreaTargetFnType)_pHandlerScript) {} }; \
@@ -565,6 +600,9 @@ class AuraScript : public _SpellScript
class EffectAbsorbFunction : public AuraScript::EffectAbsorbHandler { public: EffectAbsorbFunction(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectAbsorbHandler((AuraScript::AuraEffectAbsorbFnType)_pEffectHandlerScript, _effIndex) {} }; \
class EffectManaShieldFunction : public AuraScript::EffectManaShieldHandler { public: EffectManaShieldFunction(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectManaShieldHandler((AuraScript::AuraEffectAbsorbFnType)_pEffectHandlerScript, _effIndex) {} }; \
class EffectSplitFunction : public AuraScript::EffectSplitHandler { public: EffectSplitFunction(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectSplitHandler((AuraScript::AuraEffectSplitFnType)_pEffectHandlerScript, _effIndex) {} }; \
+ class CheckProcHandlerFunction : public AuraScript::CheckProcHandler { public: CheckProcHandlerFunction(AuraCheckProcFnType handlerScript) : AuraScript::CheckProcHandler((AuraScript::AuraCheckProcFnType)handlerScript) {} }; \
+ class AuraProcHandlerFunction : public AuraScript::AuraProcHandler { public: AuraProcHandlerFunction(AuraProcFnType handlerScript) : AuraScript::AuraProcHandler((AuraScript::AuraProcFnType)handlerScript) {} }; \
+ class EffectProcHandlerFunction : public AuraScript::EffectProcHandler { public: EffectProcHandlerFunction(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName) : AuraScript::EffectProcHandler((AuraScript::AuraEffectProcFnType)effectHandlerScript, effIndex, effName) {} }; \
#define PrepareAuraScript(CLASSNAME) AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
@@ -695,6 +733,36 @@ class AuraScript : public _SpellScript
HookList<EffectSplitHandler> OnEffectSplit;
#define AuraEffectSplitFn(F, I) EffectSplitFunction(&F, I)
+ // executed when aura checks if it can proc
+ // example: DoCheckProc += AuraCheckProcFn(class::function);
+ // where function is: bool function (ProcEventInfo& eventInfo);
+ HookList<CheckProcHandler> DoCheckProc;
+ #define AuraCheckProcFn(F) CheckProcHandlerFunction(&F)
+
+ // executed before aura procs (possibility to prevent charge drop/cooldown)
+ // example: DoPrepareProc += AuraProcFn(class::function);
+ // where function is: void function (ProcEventInfo& eventInfo);
+ HookList<AuraProcHandler> DoPrepareProc;
+ // executed when aura procs
+ // example: OnProc += AuraProcFn(class::function);
+ // where function is: void function (ProcEventInfo& eventInfo);
+ HookList<AuraProcHandler> OnProc;
+ // executed after aura proced
+ // example: AfterProc += AuraProcFn(class::function);
+ // where function is: void function (ProcEventInfo& eventInfo);
+ HookList<AuraProcHandler> AfterProc;
+ #define AuraProcFn(F) AuraProcHandlerFunction(&F)
+
+ // executed when aura effect procs
+ // example: OnEffectProc += AuraEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
+ // where function is: void function (AuraEffect const* aurEff, ProcEventInfo& procInfo);
+ HookList<EffectProcHandler> OnEffectProc;
+ // executed after aura effect proced
+ // example: AfterEffectProc += AuraEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
+ // where function is: void function (AuraEffect const* aurEff, ProcEventInfo& procInfo);
+ HookList<EffectProcHandler> AfterEffectProc;
+ #define AuraEffectProcFn(F, I, N) EffectProcHandlerFunction(&F, I, N)
+
// AuraScript interface - hook/effect execution manipulators
// prevents default action of a hook from being executed (works only while called in a hook which default action can be prevented)