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
This commit is contained in:
Shauren
2010-07-24 21:51:25 +02:00
parent 47db12b759
commit 32ceff1267
4 changed files with 20 additions and 21 deletions
+1
View File
@@ -7339,6 +7339,7 @@ DROP TABLE IF EXISTS `spell_scripts`;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `spell_scripts` ( CREATE TABLE `spell_scripts` (
`id` mediumint(8) unsigned NOT NULL DEFAULT '0', `id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`effIndex` tinyint(3) unsigned NOT NULL DEFAULT '0',
`delay` int(10) unsigned NOT NULL DEFAULT '0', `delay` int(10) unsigned NOT NULL DEFAULT '0',
`command` mediumint(8) unsigned NOT NULL DEFAULT '0', `command` mediumint(8) unsigned NOT NULL DEFAULT '0',
`datalong` mediumint(8) unsigned NOT NULL DEFAULT '0', `datalong` mediumint(8) unsigned NOT NULL DEFAULT '0',
+1
View File
@@ -0,0 +1 @@
ALTER TABLE `spell_scripts` ADD COLUMN `effIndex` tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER `id`;
+12 -19
View File
@@ -4494,7 +4494,10 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
scripts.clear(); // need for reload support 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; uint32 count = 0;
@@ -4517,6 +4520,8 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
Field *fields = result->Fetch(); Field *fields = result->Fetch();
ScriptInfo tmp; ScriptInfo tmp;
tmp.id = fields[0].GetUInt32(); tmp.id = fields[0].GetUInt32();
if (isSpellScriptTable)
tmp.id |= fields[10].GetUInt32() << 16;
tmp.delay = fields[1].GetUInt32(); tmp.delay = fields[1].GetUInt32();
tmp.command = fields[2].GetUInt32(); tmp.command = fields[2].GetUInt32();
tmp.datalong = fields[3].GetUInt32(); tmp.datalong = fields[3].GetUInt32();
@@ -4806,31 +4811,19 @@ void ObjectMgr::LoadSpellScripts()
// check ids // check ids
for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr) 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) 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; continue;
} }
uint32 i = PAIR32_HIPART(itr->first);
//check for correct spellEffect //check for correct spellEffect
bool found = false; if (!spellInfo->Effect[i] || (spellInfo->Effect[i] != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effect[i] != SPELL_EFFECT_DUMMY))
for (uint8 i=0; i<3; ++i) sLog.outErrorDb("Table `spell_scripts` - spell %u effect %u is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, 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);
} }
} }
+6 -2
View File
@@ -2218,6 +2218,10 @@ void Spell::EffectDummy(uint32 i)
return; 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 // Script based implementation. Must be used only for not good for implementation in core spell effects
// So called only for not proccessed cases // So called only for not proccessed cases
if (gameObjTarget) if (gameObjTarget)
@@ -6478,8 +6482,8 @@ void Spell::EffectScriptEffect(uint32 effIndex)
} }
// normal DB scripted effect // normal DB scripted effect
sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", m_spellInfo->Id); sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect(%u)", m_spellInfo->Id, effIndex);
m_caster->GetMap()->ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget); m_caster->GetMap()->ScriptsStart(sSpellScripts, MAKE_PAIR32(m_spellInfo->Id,effIndex), m_caster, unitTarget);
} }
void Spell::EffectSanctuary(uint32 /*i*/) void Spell::EffectSanctuary(uint32 /*i*/)