[11989] Add support to call spell_scripts in more cases

* Support to script Dummy spells with spell_scripts
* Support to script TriggerSpell spells which have no existing triggered spell
Note that the order which spell-effect actually triggers the DB script is well-defined (SCRIPT_EFFECT before DUMMY before other)

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Schmoozerd 2012-05-08 17:28:30 +02:00
parent dd1d913ff2
commit 83d7d86255
9 changed files with 86 additions and 22 deletions

View file

@ -3333,12 +3333,23 @@ void Spell::EffectDummy(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
bool libraryResult = false;
if (gameObjTarget)
sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, gameObjTarget);
libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, gameObjTarget);
else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT)
sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, (Creature*)unitTarget);
libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, (Creature*)unitTarget);
else if (itemTarget)
sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, itemTarget);
libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, eff_idx, itemTarget);
if (libraryResult || !unitTarget)
return;
// Previous effect might have started script
if (!ScriptMgr::CanSpellEffectStartDBScript(m_spellInfo, eff_idx))
return;
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectDummy", m_spellInfo->Id);
m_caster->GetMap()->ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget);
}
void Spell::EffectTriggerSpellWithValue(SpellEffectIndex eff_idx)
@ -3518,10 +3529,19 @@ void Spell::EffectTriggerSpell(SpellEffectIndex effIndex)
}
// normal case
SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id );
SpellEntry const* spellInfo = sSpellStore.LookupEntry(triggered_spell_id);
if (!spellInfo)
{
sLog.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id);
// No previous Effect might have started a script
bool startDBScript = unitTarget && ScriptMgr::CanSpellEffectStartDBScript(m_spellInfo, effIndex);
if (startDBScript)
{
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectTriggerSpell", m_spellInfo->Id);
startDBScript = m_caster->GetMap()->ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget);
}
if (!startDBScript)
sLog.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo->Id, triggered_spell_id);
return;
}
@ -8039,7 +8059,11 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
if (!unitTarget)
return;
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectScriptEffect ", m_spellInfo->Id);
// Previous effect might have started script
if (!ScriptMgr::CanSpellEffectStartDBScript(m_spellInfo, eff_idx))
return;
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectScriptEffect", m_spellInfo->Id);
m_caster->GetMap()->ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget);
}