Skip to content

OnEffectScriptEffect SD2 hook #80

@cmangos-bot

Description

@cmangos-bot

Created by @xfurry on 2013-02-21 06:30:23
Closed on 2013-03-11 08:30:34


I got a proposal for adding a hook for the ScriptEffect (Effect 77) spells to SD2.

Please feel free to propose other possible spell effects hooks which might be required in scripts, so we can integrate them together with the following patch:

diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp
index d92cc91..8258598 100644
--- a/src/game/ScriptMgr.cpp
+++ b/src/game/ScriptMgr.cpp
@@ -1983,6 +1983,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 8efa77b..291003c 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/SpellEffects.cpp b/src/game/SpellEffects.cpp
index d10385d..2162e3c 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -8784,8 +8784,12 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
         }
     }

+    bool libraryResult = false;
+    if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT)
+        libraryResult = sScriptMgr.OnEffectScriptEffect(m_caster, m_spellInfo->Id, eff_idx, (Creature*)unitTarget);
+
     // normal DB scripted effect
-    if (!unitTarget)
+    if (libraryResult || !unitTarget)
         return;

     // Previous effect might have started script

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions