diff options
author | ariel- <ariel-@users.noreply.github.com> | 2017-03-05 04:28:54 -0300 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2019-08-17 20:04:14 +0200 |
commit | 4ab07ae4e18731cfbffed4787a6db2f10fde7933 (patch) | |
tree | a1a377f9aef25d41ff5d6dfe0583f461645793d1 | |
parent | 7f30b474a30b6fdc6182ec497fa3a148dc057e74 (diff) |
Core/SmartAI: Allow scripting GameObjects by spawn id too
(cherrypicked from 05d99c5f58256f2baa16268dd0c310e3d089a229)
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index e09bed95f8f..5152cb8e707 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -210,24 +210,57 @@ void SmartAIMgr::LoadSmartAIFromDB() } else { - CreatureData const* creature = sObjectMgr->GetCreatureData(uint64(-temp.entryOrGuid)); - if (!creature) + switch (source_type) { - TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid (" SI64FMTD ") does not exist, skipped loading.", -temp.entryOrGuid); - continue; - } + case SMART_SCRIPT_TYPE_CREATURE: + { + CreatureData const* creature = sObjectMgr->GetCreatureData(uint64(-temp.entryOrGuid)); + if (!creature) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid (" SI64FMTD ") does not exist, skipped loading.", -temp.entryOrGuid); + continue; + } - CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature->id); - if (!creatureInfo) - { - TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (" SI64FMTD ") does not exist, skipped loading.", creature->id, -temp.entryOrGuid); - continue; - } + CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature->id); + if (!creatureInfo) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (" SI64FMTD ") does not exist, skipped loading.", creature->id, -temp.entryOrGuid); + continue; + } - if (creatureInfo->AIName != "SmartAI") - { - TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (" SI64FMTD ") is not using SmartAI, skipped loading.", creature->id, -temp.entryOrGuid); - continue; + if (creatureInfo->AIName != "SmartAI") + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (" SI64FMTD ") is not using SmartAI, skipped loading.", creature->id, -temp.entryOrGuid); + continue; + } + break; + } + case SMART_SCRIPT_TYPE_GAMEOBJECT: + { + GameObjectData const* gameObject = sObjectMgr->GetGOData(uint64(-temp.entryOrGuid)); + if (!gameObject) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject guid (" SI64FMTD ") does not exist, skipped loading.", -temp.entryOrGuid); + continue; + } + + GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(gameObject->id); + if (!gameObjectInfo) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry (%u) guid (" SI64FMTD ") does not exist, skipped loading.", gameObject->id, -temp.entryOrGuid); + continue; + } + + if (gameObjectInfo->AIName != "SmartGameObjectAI") + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry (%u) guid (" SI64FMTD ") is not using SmartGameObjectAI, skipped loading.", gameObject->id, -temp.entryOrGuid); + continue; + } + break; + } + default: + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GUID-specific scripting not yet implemented for source_type %u", (uint32)source_type); + continue; } } |