mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Core/Scripts: Add new SpellScript hook OnEffectSuccessfulDispel
Adds SpellScript hook to execute scripts after succesful dispels, example could be warlock pets Devour Magic, which should only trigger when succesfully dispelling an aura.
(cherry picked from commit ebf95e7ed7)
Conflicts:
src/server/game/Spells/SpellEffects.cpp
This commit is contained in:
@@ -7043,6 +7043,19 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMo
|
||||
return preventDefault;
|
||||
}
|
||||
|
||||
void Spell::CallScriptSuccessfulDispel(SpellEffIndex effIndex)
|
||||
{
|
||||
for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
|
||||
{
|
||||
(*scritr)->_PrepareScriptCall(SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL);
|
||||
std::list<SpellScript::EffectHandler>::iterator hookItrEnd = (*scritr)->OnEffectSuccessfulDispel.end(), hookItr = (*scritr)->OnEffectSuccessfulDispel.begin();
|
||||
for (; hookItr != hookItrEnd; ++hookItr)
|
||||
hookItr->Call(*scritr, effIndex);
|
||||
|
||||
(*scritr)->_FinishScriptCall();
|
||||
}
|
||||
}
|
||||
|
||||
void Spell::CallScriptBeforeHitHandlers()
|
||||
{
|
||||
for (std::list<SpellScript*>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end(); ++scritr)
|
||||
|
||||
@@ -644,6 +644,7 @@ class Spell
|
||||
SpellCastResult CallScriptCheckCastHandlers();
|
||||
void PrepareScriptHitHandlers();
|
||||
bool CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMode mode);
|
||||
void CallScriptSuccessfulDispel(SpellEffIndex effIndex);
|
||||
void CallScriptBeforeHitHandlers();
|
||||
void CallScriptOnHitHandlers();
|
||||
void CallScriptAfterHitHandlers();
|
||||
|
||||
@@ -310,6 +310,10 @@ bool SpellScript::_Validate(SpellInfo const* entry)
|
||||
if (!(*itr).GetAffectedEffectsMask(entry))
|
||||
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectHitTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
|
||||
|
||||
for (std::list<EffectHandler>::iterator itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.end(); ++itr)
|
||||
if (!(*itr).GetAffectedEffectsMask(entry))
|
||||
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnEffectSuccessfulDispel` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
|
||||
|
||||
for (std::list<ObjectAreaTargetSelectHandler>::iterator itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.end(); ++itr)
|
||||
if (!(*itr).GetAffectedEffectsMask(entry))
|
||||
TC_LOG_ERROR("scripts", "Spell `%u` Effect `%s` of script `%s` did not match dbc effect data - handler bound to hook `OnObjectAreaTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString().c_str(), m_scriptName->c_str());
|
||||
|
||||
@@ -130,6 +130,7 @@ enum SpellScriptHookType
|
||||
SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET,
|
||||
SPELL_SCRIPT_HOOK_EFFECT_HIT,
|
||||
SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET,
|
||||
SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL,
|
||||
SPELL_SCRIPT_HOOK_BEFORE_HIT,
|
||||
SPELL_SCRIPT_HOOK_HIT,
|
||||
SPELL_SCRIPT_HOOK_AFTER_HIT,
|
||||
@@ -292,6 +293,7 @@ class SpellScript : public _SpellScript
|
||||
HookList<EffectHandler> OnEffectLaunchTarget;
|
||||
HookList<EffectHandler> OnEffectHit;
|
||||
HookList<EffectHandler> OnEffectHitTarget;
|
||||
HookList<EffectHandler> OnEffectSuccessfulDispel;
|
||||
#define SpellEffectFn(F, I, N) EffectHandlerFunction(&F, I, N)
|
||||
|
||||
// example: BeforeHit += SpellHitFn(class::function);
|
||||
@@ -334,6 +336,9 @@ class SpellScript : public _SpellScript
|
||||
// 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
|
||||
|
||||
// this hook is only executed after a successful dispel of any aura
|
||||
// OnEffectSuccessfulDispel - executed just after effect successfully dispelled aura(s)
|
||||
|
||||
//
|
||||
// methods allowing interaction with Spell object
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user