Skip to content

Commit

Permalink
Core/Scripts: Add new SpellScript hook OnEffectSuccessfulDispel
Browse files Browse the repository at this point in the history
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 ebf95e7)

Conflicts:
	src/server/game/Spells/SpellEffects.cpp
  • Loading branch information
LuqJensen authored and DDuarte committed Dec 25, 2014
1 parent 3cb6ac0 commit d130364
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/server/game/Spells/Spell.cpp
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Spells/Spell.h
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/server/game/Spells/SpellScript.cpp
Expand Up @@ -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());
Expand Down
5 changes: 5 additions & 0 deletions src/server/game/Spells/SpellScript.h
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
//
Expand Down

0 comments on commit d130364

Please sign in to comment.