From 89a3ec852e66de004a488fd8706f8d6a2d541d75 Mon Sep 17 00:00:00 2001 From: Olion Date: Wed, 17 Feb 2016 23:11:41 +0200 Subject: [PATCH] Allow SD3 scripted dummy and script spelleffects upon players --- src/game/WorldHandlers/ScriptMgr.cpp | 15 ++++++++------- src/game/WorldHandlers/ScriptMgr.h | 4 ++-- src/game/WorldHandlers/SpellEffects.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/game/WorldHandlers/ScriptMgr.cpp b/src/game/WorldHandlers/ScriptMgr.cpp index 0db54884..9e8f891d 100644 --- a/src/game/WorldHandlers/ScriptMgr.cpp +++ b/src/game/WorldHandlers/ScriptMgr.cpp @@ -2420,16 +2420,17 @@ bool ScriptMgr::OnProcessEvent(uint32 eventId, Object* pSource, Object* pTarget, #endif } -bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget, ObjectGuid originalCasterGuid) +bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Unit* pTarget, ObjectGuid originalCasterGuid) { // Used by Eluna #ifdef ENABLE_ELUNA - if (sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget)) - return true; + if (pTarget->ToCreature()) + if (sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget->ToCreature())) + return true; #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 - return SD3::EffectDummyCreature(pCaster, spellId, effIndex, pTarget, originalCasterGuid); + return SD3::EffectDummyUnit(pCaster, spellId, effIndex, pTarget, originalCasterGuid); #else return false; #endif @@ -2465,10 +2466,10 @@ bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex ef #endif } -bool ScriptMgr::OnEffectScriptEffect(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget, ObjectGuid originalCasterGuid) +bool ScriptMgr::OnEffectScriptEffect(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Unit* pTarget, ObjectGuid originalCasterGuid) { #ifdef ENABLE_SD3 - return SD3::EffectScriptEffectCreature(pCaster, spellId, effIndex, pTarget, originalCasterGuid); + return SD3::EffectScriptEffectUnit(pCaster, spellId, effIndex, pTarget, originalCasterGuid); #else return false; #endif @@ -2553,7 +2554,7 @@ void ScriptMgr::CollectPossibleEventIds(std::set& eventIds) } } } -#if defined(TBC) +#if defined(TBC) || defined (WOTLK) // Load all possible event entries from taxi path nodes for (size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx) { diff --git a/src/game/WorldHandlers/ScriptMgr.h b/src/game/WorldHandlers/ScriptMgr.h index aace13af..0e79bc23 100644 --- a/src/game/WorldHandlers/ScriptMgr.h +++ b/src/game/WorldHandlers/ScriptMgr.h @@ -635,10 +635,10 @@ class ScriptMgr bool OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets); bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry); bool OnProcessEvent(uint32 eventId, Object* pSource, Object* pTarget, bool isStart); - bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget, ObjectGuid originalCasterGuid); + bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Unit* pTarget, ObjectGuid originalCasterGuid); bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, GameObject* pTarget, ObjectGuid originalCasterGuid); bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Item* pTarget, ObjectGuid originalCasterGuid); - bool OnEffectScriptEffect(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget, ObjectGuid originalCasterGuid); + bool OnEffectScriptEffect(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Unit* pTarget, ObjectGuid originalCasterGuid); bool OnAuraDummy(Aura const* pAura, bool apply); private: diff --git a/src/game/WorldHandlers/SpellEffects.cpp b/src/game/WorldHandlers/SpellEffects.cpp index 77708af1..8bcaa5f8 100644 --- a/src/game/WorldHandlers/SpellEffects.cpp +++ b/src/game/WorldHandlers/SpellEffects.cpp @@ -1318,8 +1318,8 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) bool libraryResult = false; if (gameObjTarget) { libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, gameObjTarget, m_originalCasterGUID); } - else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT) - { libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, (Creature*)unitTarget, m_originalCasterGUID); } + else if (unitTarget && (unitTarget->GetTypeId() == TYPEID_UNIT || unitTarget->GetTypeId() == TYPEID_PLAYER)) + { libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, unitTarget, m_originalCasterGUID); } else if (itemTarget) { libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, itemTarget, m_originalCasterGUID); } @@ -3811,9 +3811,9 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) // 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 (unitTarget->GetTypeId() == TYPEID_UNIT || unitTarget->GetTypeId() == TYPEID_PLAYER) { - if (sScriptMgr.OnEffectScriptEffect(m_caster, m_spellInfo->Id, eff_idx, (Creature*)unitTarget, m_originalCasterGUID)) + if (sScriptMgr.OnEffectScriptEffect(m_caster, m_spellInfo->Id, eff_idx, unitTarget, m_originalCasterGUID)) { return; } }