diff options
author | megamage <none@none> | 2009-05-05 16:56:15 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-05-05 16:56:15 -0500 |
commit | e69d2cbed95b6cddd009f68dd80fd4614342d1fc (patch) | |
tree | 8dd0777d15adf284f2b0146e791ac4cd868b36e3 /src/game/ObjectMgr.cpp | |
parent | dcb2b5aa019c409b1b9b1061aa4dd24c8ecacb5d (diff) |
[7776] Completed implementation of CMSG_SPELLCLICK Author: arrai
For vehicles, you have to add the correct SPELL_AURA_CONTROL_VEHICLE spells to
npc_spellclick_spells, otherwise you won't be able to use them
--HG--
branch : trunk
Diffstat (limited to 'src/game/ObjectMgr.cpp')
-rw-r--r-- | src/game/ObjectMgr.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index a2af970e9f3..12fb26f0ad8 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -6207,6 +6207,76 @@ void ObjectMgr::LoadPointsOfInterest() sLog.outString(">> Loaded %u Points of Interest definitions", count); } +void ObjectMgr::LoadNPCSpellClickSpells() +{ + uint32 count = 0; + + mSpellClickInfoMap.clear(); + + QueryResult *result = WorldDatabase.Query("SELECT npc_entry, spell_id, quest_id, cast_flags FROM npc_spellclick_spells"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 npc_entry = fields[0].GetUInt32(); + CreatureInfo const* cInfo = GetCreatureTemplate(npc_entry); + if (!cInfo) + { + sLog.outErrorDb("Table npc_spellclick_spells references unknown creature_template %u. Skipping entry.", npc_entry); + continue; + } + + uint32 spellid = fields[1].GetUInt32(); + SpellEntry const *spellinfo = sSpellStore.LookupEntry(spellid); + if (!spellinfo) + { + sLog.outErrorDb("Table npc_spellclick_spells references unknown spellid %u. Skipping entry.", spellid); + continue; + } + + uint32 quest = fields[2].GetUInt32(); + + // quest might be 0 to enable spellclick independent of any quest + if (quest) + { + if(mQuestTemplates.find(quest) == mQuestTemplates.end()) + { + sLog.outErrorDb("Table npc_spellclick_spells references unknown quest %u. Skipping entry.", spellid); + continue; + } + + } + + uint8 castFlags = fields[3].GetUInt8(); + SpellClickInfo info; + info.spellId = spellid; + info.questId = quest; + info.castFlags = castFlags; + mSpellClickInfoMap.insert(SpellClickInfoMap::value_type(npc_entry, info)); + ++count; + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString(">> Loaded %u spellclick definitions", count); +} + void ObjectMgr::LoadWeatherZoneChances() { uint32 count = 0; |