diff options
| author | Shauren <shauren.trinity@gmail.com> | 2011-03-04 21:18:38 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2011-03-04 21:19:43 +0100 |
| commit | 7120f1eff80c9f057a40831a10d8975c0a8a7439 (patch) | |
| tree | e77c66ff87570d1484b2cf81be6920ad5cd5e7fd /src/server/game/Spells/SpellScript.h | |
| parent | a9582964d3ca140a1ec1d5894b79e72ed15a65a6 (diff) | |
Core/Spells:
* Implemented on CheckCast spell script hook
* Added possibility to send SPELL_FAILED_CUSTOM_ERROR and added enum with all possible options for it
Scripts/Spells:
* Added example script for CheckCast hook with SPELL_FAILED_CUSTOM_ERROR (profession research and Book of Glyph Mastery)
Diffstat (limited to 'src/server/game/Spells/SpellScript.h')
| -rwxr-xr-x | src/server/game/Spells/SpellScript.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 6a57befef41..4510b1b9f3b 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -121,11 +121,12 @@ enum SpellScriptHookType SPELL_SCRIPT_HOOK_HIT, SPELL_SCRIPT_HOOK_AFTER_HIT, SPELL_SCRIPT_HOOK_UNIT_TARGET_SELECT, + SPELL_SCRIPT_HOOK_CHECK_CAST, }; #define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT #define HOOK_SPELL_HIT_END SPELL_SCRIPT_HOOK_AFTER_HIT + 1 #define HOOK_SPELL_START SPELL_SCRIPT_HOOK_EFFECT -#define HOOK_SPELL_END SPELL_SCRIPT_HOOK_UNIT_TARGET_SELECT + 1 +#define HOOK_SPELL_END SPELL_SCRIPT_HOOK_CHECK_CAST + 1 #define HOOK_SPELL_COUNT HOOK_SPELL_END - HOOK_SPELL_START class SpellScript : public _SpellScript @@ -134,12 +135,22 @@ class SpellScript : public _SpellScript // DO NOT OVERRIDE THESE IN SCRIPTS public: #define SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) \ + typedef SpellCastResult(CLASSNAME::*SpellCheckCastFnType)(); \ typedef void(CLASSNAME::*SpellEffectFnType)(SpellEffIndex); \ typedef void(CLASSNAME::*SpellHitFnType)(); \ typedef void(CLASSNAME::*SpellUnitTargetFnType)(std::list<Unit*>&); \ SPELLSCRIPT_FUNCTION_TYPE_DEFINES(SpellScript) + class CheckCastHandler + { + public: + CheckCastHandler(SpellCheckCastFnType checkCastHandlerScript); + SpellCastResult Call(SpellScript* spellScript); + private: + SpellCheckCastFnType _checkCastHandlerScript; + }; + class EffectHandler : public _SpellScript::EffectNameCheck, public _SpellScript::EffectHook { public: @@ -173,6 +184,7 @@ class SpellScript : public _SpellScript }; #define SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) \ + 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) {} }; \ class UnitTargetHandlerFunction : public SpellScript::UnitTargetHandler { public: UnitTargetHandlerFunction(SpellUnitTargetFnType _pUnitTargetHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::UnitTargetHandler((SpellScript::SpellUnitTargetFnType)_pUnitTargetHandlerScript, _effIndex, _targetType) {} }; \ @@ -186,8 +198,9 @@ class SpellScript : public _SpellScript bool _IsDefaultEffectPrevented(SpellEffIndex effIndex) { return m_hitPreventDefaultEffectMask & (1<<effIndex); } void _PrepareScriptCall(SpellScriptHookType hookType); void _FinishScriptCall(); - bool IsInHitPhase() { return (m_currentScriptState >= HOOK_SPELL_HIT_START && m_currentScriptState < HOOK_SPELL_HIT_END); } - bool IsInEffectHook() { return (m_currentScriptState == SPELL_SCRIPT_HOOK_EFFECT); } + bool IsInCheckCastHook() const { return m_currentScriptState == SPELL_SCRIPT_HOOK_CHECK_CAST; } + bool IsInHitPhase() const { return (m_currentScriptState >= HOOK_SPELL_HIT_START && m_currentScriptState < HOOK_SPELL_HIT_END); } + bool IsInEffectHook() const { return (m_currentScriptState == SPELL_SCRIPT_HOOK_EFFECT); } private: Spell * m_spell; uint8 m_hitPreventEffectMask; @@ -197,6 +210,12 @@ class SpellScript : public _SpellScript // SpellScript interface // hooks to which you can attach your functions // + + // example: OnCheckCast += SpellCheckCastFn(); + // where function is SpellCastResult function() + HookList<CheckCastHandler> OnCheckCast; + #define SpellCheckCastFn(F) CheckCastHandlerFunction(&F) + // example: OnEffect += SpellEffectFn(class::function, EffectIndexSpecifier, EffectNameSpecifier); // where function is void function(SpellEffIndex effIndex) HookList<EffectHandler> OnEffect; @@ -294,6 +313,8 @@ class SpellScript : public _SpellScript // finishes spellcast prematurely with selected error message void FinishCast(SpellCastResult result); + + void SetCustomCastResultMessage(SpellCustomErrors result); }; // AuraScript interface - enum used for runtime checks of script function calls @@ -454,7 +475,7 @@ class AuraScript : public _SpellScript // executed when periodic aura effect is updated // example: OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier); - // where function is: void function (AuraEffect const * aurEff); + // where function is: void function (AuraEffect * aurEff); HookList<EffectUpdatePeriodicHandler> OnEffectUpdatePeriodic; #define AuraEffectUpdatePeriodicFn(F, I, N) EffectUpdatePeriodicHandlerFunction(&F, I, N) |
