From dcc087a360b05782c0caf3f953c97858db1bf20f Mon Sep 17 00:00:00 2001 From: Xfurry Date: Fri, 31 May 2013 09:57:17 +0100 Subject: [PATCH] [c12571] Allow spell effect 77 (ScriptEffect) and aura 226 (PeriodicDummy) to be handled by script library --- src/game/ScriptMgr.cpp | 5 +++++ src/game/ScriptMgr.h | 2 ++ src/game/SpellAuras.cpp | 6 ++++++ src/game/SpellEffects.cpp | 8 ++++++++ src/shared/revision_nr.h | 2 +- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index 94cdff015..b8a631677 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -1997,6 +1997,11 @@ bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex ef return m_pOnEffectDummyItem != NULL && m_pOnEffectDummyItem(pCaster, spellId, effIndex, pTarget); } +bool ScriptMgr::OnEffectScriptEffect(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget) +{ + return m_pOnEffectScriptEffectCreature != NULL && m_pOnEffectScriptEffectCreature(pCaster, spellId, effIndex, pTarget); +} + bool ScriptMgr::OnAuraDummy(Aura const* pAura, bool apply) { return m_pOnAuraDummy != NULL && m_pOnAuraDummy(pAura, apply); diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h index d8eaee3f3..f50d80c30 100644 --- a/src/game/ScriptMgr.h +++ b/src/game/ScriptMgr.h @@ -502,6 +502,7 @@ class ScriptMgr bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget); bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, GameObject* pTarget); bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Item* pTarget); + bool OnEffectScriptEffect(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget); bool OnAuraDummy(Aura const* pAura, bool apply); private: @@ -555,6 +556,7 @@ class ScriptMgr bool (MANGOS_IMPORT* m_pOnEffectDummyCreature)(Unit*, uint32, SpellEffectIndex, Creature*); bool (MANGOS_IMPORT* m_pOnEffectDummyGO)(Unit*, uint32, SpellEffectIndex, GameObject*); bool (MANGOS_IMPORT* m_pOnEffectDummyItem)(Unit*, uint32, SpellEffectIndex, Item*); + bool (MANGOS_IMPORT* m_pOnEffectScriptEffectCreature)(Unit*, uint32, SpellEffectIndex, Creature*); bool (MANGOS_IMPORT* m_pOnAuraDummy)(Aura const*, bool); }; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 8027d43c5..38e80d732 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -8468,6 +8468,12 @@ void Aura::PeriodicDummyTick() default: break; } + + if (Unit* caster = GetCaster()) + { + if (target && target->GetTypeId() == TYPEID_UNIT) + sScriptMgr.OnEffectDummy(caster, GetId(), GetEffIndex(), (Creature*)target); + } } void Aura::HandlePreventFleeing(bool apply, bool Real) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 303d784f0..4a8171857 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -8898,6 +8898,14 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) if (!unitTarget) return; + // Script based implementation. Must be used only for not good for implementation in core spell effects + // So called only for not processed cases + if (unitTarget->GetTypeId() == TYPEID_UNIT) + { + if (sScriptMgr.OnEffectScriptEffect(m_caster, m_spellInfo->Id, SpellEffectIndex(effect->EffectIndex), (Creature*)unitTarget)) + return; + } + // Previous effect might have started script if (!ScriptMgr::CanSpellEffectStartDBScript(m_spellInfo, SpellEffectIndex(effect->EffectIndex))) return; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 23ad51567..642898013 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12570" + #define REVISION_NR "12571" #endif // __REVISION_NR_H__