*Add base scripting interfce for spells - thanks to Brian for help in making it compile with GCC.
*Add hook for handling spell effects in new scripting system. --HG-- branch : trunk
This commit is contained in:
@@ -46,6 +46,8 @@
|
||||
#include "Vehicle.h"
|
||||
#include "AchievementMgr.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SpellScript.h"
|
||||
|
||||
ScriptMapMap sQuestEndScripts;
|
||||
ScriptMapMap sQuestStartScripts;
|
||||
@@ -4893,6 +4895,106 @@ void ObjectMgr::LoadWaypointScripts()
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadSpellScriptNames()
|
||||
{
|
||||
mSpellScripts.clear(); // need for reload case
|
||||
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT spell_id, ScriptName FROM spell_script_names");
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
if (!result)
|
||||
{
|
||||
barGoLink bar(1);
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u spell script names", count);
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar(result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
++count;
|
||||
bar.step();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
int32 spellId = fields[0].GetInt32();
|
||||
const char *scriptName = fields[1].GetString();
|
||||
|
||||
bool allRanks = false;
|
||||
if (spellId <=0)
|
||||
{
|
||||
allRanks = true;
|
||||
spellId = -spellId;
|
||||
}
|
||||
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId);
|
||||
if (!spellEntry)
|
||||
{
|
||||
sLog.outErrorDb("Scriptname:`%s` spell (spell_id:%d) does not exist in `Spell.dbc`.",scriptName,fields[0].GetInt32());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (allRanks)
|
||||
{
|
||||
if (spellmgr.GetFirstSpellInChain(spellId) != spellId)
|
||||
{
|
||||
sLog.outErrorDb("Scriptname:`%s` spell (spell_id:%d) is not first rank of spell.",scriptName,fields[0].GetInt32());
|
||||
continue;
|
||||
}
|
||||
while(spellId)
|
||||
{
|
||||
mSpellScripts.insert(SpellScriptsMap::value_type(spellId, GetScriptId(scriptName)));
|
||||
spellId = spellmgr.GetNextSpellInChain(spellId);
|
||||
}
|
||||
}
|
||||
else
|
||||
mSpellScripts.insert(SpellScriptsMap::value_type(spellId, GetScriptId(scriptName)));
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u spell script names", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::ValidateSpellScripts()
|
||||
{
|
||||
if (mSpellScripts.empty())
|
||||
{
|
||||
barGoLink bar(1);
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Validation done");
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar(mSpellScripts.size());
|
||||
for (SpellScriptsMap::iterator itr = mSpellScripts.begin(); itr != mSpellScripts.end();)
|
||||
{
|
||||
SpellEntry const * spellEntry = sSpellStore.LookupEntry(itr->first);
|
||||
std::vector<std::pair<SpellScript *, SpellScriptsMap::iterator> > spellScripts;
|
||||
sScriptMgr.CreateSpellScripts(itr->first, spellScripts);
|
||||
SpellScriptsMap::iterator bitr;
|
||||
itr = mSpellScripts.upper_bound(itr->first);
|
||||
|
||||
for (std::vector<std::pair<SpellScript *, SpellScriptsMap::iterator> >::iterator sitr = spellScripts.begin(); sitr != spellScripts.end(); ++sitr)
|
||||
{
|
||||
bar.step();
|
||||
sitr->first->Register();
|
||||
if (!sitr->first->_Validate(spellEntry, objmgr.GetScriptName(sitr->second->second)))
|
||||
mSpellScripts.erase(sitr->second);
|
||||
delete sitr->first;
|
||||
}
|
||||
}
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Validation done");
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGossipScripts()
|
||||
{
|
||||
LoadScripts(sGossipScripts, "gossip_scripts");
|
||||
@@ -7658,6 +7760,11 @@ uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SpellScriptsBounds ObjectMgr::GetSpellScriptsBounds(uint32 spell_id)
|
||||
{
|
||||
return SpellScriptsBounds(mSpellScripts.lower_bound(spell_id),mSpellScripts.upper_bound(spell_id));
|
||||
}
|
||||
|
||||
SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial)
|
||||
{
|
||||
switch(pSkill->categoryId)
|
||||
@@ -8451,6 +8558,8 @@ void ObjectMgr::LoadScriptNames()
|
||||
"UNION "
|
||||
"SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
|
||||
"UNION "
|
||||
"SELECT DISTINCT(ScriptName) FROM spell_script_names WHERE ScriptName <> '' "
|
||||
"UNION "
|
||||
"SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
|
||||
|
||||
if (!result)
|
||||
|
||||
@@ -90,6 +90,8 @@ struct ScriptInfo
|
||||
|
||||
typedef std::multimap<uint32, ScriptInfo> ScriptMap;
|
||||
typedef std::map<uint32, ScriptMap > ScriptMapMap;
|
||||
typedef std::multimap<uint32, uint32> SpellScriptsMap;
|
||||
typedef std::pair<SpellScriptsMap::iterator, SpellScriptsMap::iterator> SpellScriptsBounds;
|
||||
extern ScriptMapMap sQuestEndScripts;
|
||||
extern ScriptMapMap sQuestStartScripts;
|
||||
extern ScriptMapMap sSpellScripts;
|
||||
@@ -521,6 +523,7 @@ class ObjectMgr
|
||||
AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const;
|
||||
|
||||
uint32 GetAreaTriggerScriptId(uint32 trigger_id);
|
||||
SpellScriptsBounds GetSpellScriptsBounds(uint32 spell_id);
|
||||
|
||||
ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
|
||||
{
|
||||
@@ -587,6 +590,9 @@ class ObjectMgr
|
||||
void LoadGossipScripts();
|
||||
void LoadWaypointScripts();
|
||||
|
||||
void LoadSpellScriptNames();
|
||||
void ValidateSpellScripts();
|
||||
|
||||
bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
|
||||
bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); }
|
||||
void LoadDbScriptStrings();
|
||||
@@ -1002,6 +1008,8 @@ class ObjectMgr
|
||||
|
||||
SpellClickInfoMap mSpellClickInfoMap;
|
||||
|
||||
SpellScriptsMap mSpellScripts;
|
||||
|
||||
ItemRequiredTargetMap m_ItemRequiredTarget;
|
||||
|
||||
VehicleAccessoryMap m_VehicleAccessoryMap;
|
||||
|
||||
Reference in New Issue
Block a user