aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <none@none>2010-07-24 21:51:25 +0200
committerShauren <none@none>2010-07-24 21:51:25 +0200
commit32ceff1267fc74bb72cf421e0e016d8ec5b51c39 (patch)
treeeb0bab86c9d2b6e37ac0d59498915008d5d43167 /src
parent47db12b759b00ee2177e5b5ff0103d0d9e513a64 (diff)
Modified spell_scripts table, it is now possible to add different scripts for each spell effect
Allow SPELL_EFFECT_DUMMY spells to use spell_scripts --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp31
-rw-r--r--src/server/game/Spells/SpellEffects.cpp8
2 files changed, 18 insertions, 21 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 9997fcf865c..87f8202ddcc 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -4494,7 +4494,10 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
scripts.clear(); // need for reload support
- QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename);
+ char buff[125];
+ bool isSpellScriptTable = !strcmp(tablename, "spell_scripts");
+ sprintf(buff, "SELECT id,delay,command,datalong,datalong2,dataint,x,y,z,o%s FROM %s", isSpellScriptTable ? ",effIndex" : "", tablename);
+ QueryResult_AutoPtr result = WorldDatabase.Query(buff);
uint32 count = 0;
@@ -4517,6 +4520,8 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
Field *fields = result->Fetch();
ScriptInfo tmp;
tmp.id = fields[0].GetUInt32();
+ if (isSpellScriptTable)
+ tmp.id |= fields[10].GetUInt32() << 16;
tmp.delay = fields[1].GetUInt32();
tmp.command = fields[2].GetUInt32();
tmp.datalong = fields[3].GetUInt32();
@@ -4806,31 +4811,19 @@ void ObjectMgr::LoadSpellScripts()
// check ids
for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
{
- SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first);
+ uint32 spellId = PAIR32_LOPART(itr->first);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
- sLog.outErrorDb("Table `spell_scripts` has not existing spell (Id: %u) as script id",itr->first);
+ sLog.outErrorDb("Table `spell_scripts` has not existing spell (Id: %u) as script id", spellId);
continue;
}
+ uint32 i = PAIR32_HIPART(itr->first);
//check for correct spellEffect
- bool found = false;
- for (uint8 i=0; i<3; ++i)
- {
- // skip empty effects
- if (!spellInfo->Effect[i])
- continue;
-
- if (spellInfo->Effect[i] == SPELL_EFFECT_SCRIPT_EFFECT)
- {
- found = true;
- break;
- }
- }
-
- if (!found)
- sLog.outErrorDb("Table `spell_scripts` has unsupported spell (Id: %u) without SPELL_EFFECT_SCRIPT_EFFECT (%u) spell effect",itr->first,SPELL_EFFECT_SCRIPT_EFFECT);
+ if (!spellInfo->Effect[i] || (spellInfo->Effect[i] != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effect[i] != SPELL_EFFECT_DUMMY))
+ sLog.outErrorDb("Table `spell_scripts` - spell %u effect %u is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, i);
}
}
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 2b1acc55b5e..0f71f29906e 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -2218,6 +2218,10 @@ void Spell::EffectDummy(uint32 i)
return;
}
+ // normal DB scripted effect
+ sLog.outDebug("Spell ScriptStart spellid %u in EffectDummy(%u)", m_spellInfo->Id, i);
+ m_caster->GetMap()->ScriptsStart(sSpellScripts, MAKE_PAIR32(m_spellInfo->Id,i), m_caster, unitTarget);
+
// Script based implementation. Must be used only for not good for implementation in core spell effects
// So called only for not proccessed cases
if (gameObjTarget)
@@ -6478,8 +6482,8 @@ void Spell::EffectScriptEffect(uint32 effIndex)
}
// normal DB scripted effect
- sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", m_spellInfo->Id);
- m_caster->GetMap()->ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget);
+ sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect(%u)", m_spellInfo->Id, effIndex);
+ m_caster->GetMap()->ScriptsStart(sSpellScripts, MAKE_PAIR32(m_spellInfo->Id,effIndex), m_caster, unitTarget);
}
void Spell::EffectSanctuary(uint32 /*i*/)