Core/SmartAI: Allow scripting GameObjects by spawn id too

Port From (https://github.com/TrinityCore/TrinityCore/commit/4ab07ae4e18731cfbffed4787a6db2f10fde7933)
This commit is contained in:
hondacrx
2019-09-01 10:53:09 -04:00
parent 4f66987965
commit 74a1025f41
+50 -3
View File
@@ -118,10 +118,57 @@ namespace Game.AI
}
else
{
if (Global.ObjectMgr.GetCreatureData((uint)Math.Abs(temp.entryOrGuid)) == null)
switch (source_type)
{
Log.outError(LogFilter.Sql, "SmartAIMgr.LoadSmartAI: Creature guid ({0}) does not exist, skipped loading.", Math.Abs(temp.entryOrGuid));
continue;
case SmartScriptType.Creature:
{
CreatureData creature = Global.ObjectMgr.GetCreatureData((ulong)-temp.entryOrGuid);
if (creature == null)
{
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadSmartAIFromDB: Creature guid ({-temp.entryOrGuid}) does not exist, skipped loading.");
continue;
}
CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(creature.id);
if (creatureInfo == null)
{
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadSmartAIFromDB: Creature entry ({creature.id}) guid ({-temp.entryOrGuid}) does not exist, skipped loading.");
continue;
}
if (creatureInfo.AIName != "SmartAI")
{
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadSmartAIFromDB: Creature entry ({creature.id}) guid ({-temp.entryOrGuid}) is not using SmartAI, skipped loading.");
continue;
}
break;
}
case SmartScriptType.GameObject:
{
GameObjectData gameObject = Global.ObjectMgr.GetGOData((ulong)-temp.entryOrGuid);
if (gameObject == null)
{
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadSmartAIFromDB: GameObject guid ({-temp.entryOrGuid}) does not exist, skipped loading.");
continue;
}
GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(gameObject.id);
if (gameObjectInfo == null)
{
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadSmartAIFromDB: GameObject entry ({gameObject.id}) guid ({-temp.entryOrGuid}) does not exist, skipped loading.");
continue;
}
if (gameObjectInfo.AIName != "SmartGameObjectAI")
{
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadSmartAIFromDB: GameObject entry ({gameObject.id}) guid ({-temp.entryOrGuid}) is not using SmartGameObjectAI, skipped loading.");
continue;
}
break;
}
default:
Log.outError(LogFilter.Sql, $"SmartAIMgr.LoadSmartAIFromDB: GUID-specific scripting not yet implemented for source_type {source_type}");
continue;
}
}