diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-03-05 04:28:54 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-03-05 04:30:01 -0300 |
| commit | 05d99c5f58256f2baa16268dd0c310e3d089a229 (patch) | |
| tree | 4d21da5bb9984189e5b80675910b6f24a33e892e /src | |
| parent | 61b8c90eb880778e116d646eb659ab5ffa69212b (diff) | |
Core/SmartAI: Allow scripting GameObjects by spawn id too
Diffstat (limited to 'src')
| -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 a44537ea91a..96fa864f310 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -199,24 +199,57 @@ void SmartAIMgr::LoadSmartAIFromDB() } else { - CreatureData const* creature = sObjectMgr->GetCreatureData(uint32(std::abs(temp.entryOrGuid))); - if (!creature) + switch (source_type) { - TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid (%u) does not exist, skipped loading.", uint32(std::abs(temp.entryOrGuid))); - continue; - } + case SMART_SCRIPT_TYPE_CREATURE: + { + CreatureData const* creature = sObjectMgr->GetCreatureData(uint32(std::abs(temp.entryOrGuid))); + if (!creature) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid (%u) does not exist, skipped loading.", uint32(std::abs(temp.entryOrGuid))); + continue; + } - CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature->id); - if (!creatureInfo) - { - TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (%u) does not exist, skipped loading.", creature->id, uint32(std::abs(temp.entryOrGuid))); - continue; - } + CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature->id); + if (!creatureInfo) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (%u) does not exist, skipped loading.", creature->id, uint32(std::abs(temp.entryOrGuid))); + continue; + } - if (creatureInfo->AIName != "SmartAI") - { - TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (%u) is not using SmartAI, skipped loading.", creature->id, uint32(std::abs(temp.entryOrGuid))); - continue; + if (creatureInfo->AIName != "SmartAI") + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) guid (%u) is not using SmartAI, skipped loading.", creature->id, uint32(std::abs(temp.entryOrGuid))); + continue; + } + break; + } + case SMART_SCRIPT_TYPE_GAMEOBJECT: + { + GameObjectData const* gameObject = sObjectMgr->GetGOData(uint32(std::abs(temp.entryOrGuid))); + if (!gameObject) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject guid (%u) does not exist, skipped loading.", uint32(std::abs(temp.entryOrGuid))); + continue; + } + + GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(gameObject->id); + if (!gameObjectInfo) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry (%u) guid (%u) does not exist, skipped loading.", gameObject->id, uint32(std::abs(temp.entryOrGuid))); + continue; + } + + if (gameObjectInfo->AIName != "SmartGameObjectAI") + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: GameObject entry (%u) guid (%u) is not using SmartGameObjectAI, skipped loading.", gameObject->id, uint32(std::abs(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; } } |
