aboutsummaryrefslogtreecommitdiff
path: root/src/game/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/ObjectMgr.cpp')
-rw-r--r--src/game/ObjectMgr.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 8c0e5d6e1bd..350bf5d3a15 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -2117,6 +2117,106 @@ void ObjectMgr::LoadItemPrototypes()
}
}
+void ObjectMgr::LoadItemRequiredTarget()
+{
+ m_ItemRequiredTarget.clear(); // needed for reload case
+
+ uint32 count = 0;
+
+ QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM item_required_target");
+
+ if (!result)
+ {
+ barGoLink bar(1);
+
+ bar.step();
+
+ sLog.outString();
+ sLog.outErrorDb(">> Loaded 0 ItemRequiredTarget. DB table `item_required_target` is empty.");
+ return;
+ }
+
+ barGoLink bar(result->GetRowCount());
+
+ do
+ {
+ Field *fields = result->Fetch();
+ bar.step();
+
+ uint32 uiItemId = fields[0].GetUInt32();
+ uint32 uiType = fields[1].GetUInt32();
+ uint32 uiTargetEntry = fields[2].GetUInt32();
+
+ ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(uiItemId);
+
+ if (!pItemProto)
+ {
+ sLog.outErrorDb("Table `item_required_target`: Entry %u listed for TargetEntry %u does not exist in `item_template`.",uiItemId,uiTargetEntry);
+ continue;
+ }
+
+ bool bIsItemSpellValid = false;
+
+ for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
+ {
+ if (SpellEntry const* pSpellInfo = sSpellStore.LookupEntry(pItemProto->Spells[i].SpellId))
+ {
+ if (pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE ||
+ pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)
+ {
+ SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(pSpellInfo->Id);
+ SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(pSpellInfo->Id);
+
+ if (lower != upper)
+ break;
+
+ if (pSpellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ENEMY ||
+ pSpellInfo->EffectImplicitTargetB[i] == TARGET_UNIT_TARGET_ENEMY ||
+ pSpellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ANY ||
+ pSpellInfo->EffectImplicitTargetB[i] == TARGET_UNIT_TARGET_ANY)
+ {
+ bIsItemSpellValid = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!bIsItemSpellValid)
+ {
+ sLog.outErrorDb("Table `item_required_target`: Spell used by item %u does not have implicit target TARGET_CHAIN_DAMAGE(6), TARGET_DUELVSPLAYER(25), already listed in `spell_script_target` or doesn't have item spelltrigger.",uiItemId);
+ continue;
+ }
+
+ if (!uiType || uiType > MAX_ITEM_REQ_TARGET_TYPE)
+ {
+ sLog.outErrorDb("Table `item_required_target`: Type %u for TargetEntry %u is incorrect.",uiType,uiTargetEntry);
+ continue;
+ }
+
+ if (!uiTargetEntry)
+ {
+ sLog.outErrorDb("Table `item_required_target`: TargetEntry == 0 for Type (%u).",uiType);
+ continue;
+ }
+
+ if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiTargetEntry))
+ {
+ sLog.outErrorDb("Table `item_required_target`: creature template entry %u does not exist.",uiTargetEntry);
+ continue;
+ }
+
+ m_ItemRequiredTarget.insert(ItemRequiredTargetMap::value_type(uiItemId,ItemRequiredTarget(ItemRequiredTargetType(uiType),uiTargetEntry)));
+
+ ++count;
+ } while (result->NextRow());
+
+ delete result;
+
+ sLog.outString();
+ sLog.outString(">> Loaded %u Item required targets", count);
+}
+
void ObjectMgr::LoadPetLevelInfo()
{
// Loading levels data