From 08db42917e2826916c369301068466ad1e178fad Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 9 Aug 2021 09:57:11 -0400 Subject: [PATCH] Core/SmartScripts: Rename SMART_ACTION_RESPAWN_TARGET -> SMART_ACTION_ENABLE_TEMP_GOBJ, since that's the only thing it still does in the dynspawn model. Adjust body accordingly to warn on misuse. Port From (https://github.com/TrinityCore/TrinityCore/commit/32997a598992c5be7ad838b52b9e9a185d68d9fb) --- Source/Framework/Constants/SmartAIConst.cs | 2 +- Source/Game/AI/SmartScripts/SmartAIManager.cs | 16 ++++++++++++---- Source/Game/AI/SmartScripts/SmartScript.cs | 9 ++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index 8edc41ca3..251fa77ee 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -324,7 +324,7 @@ namespace Framework.Constants CreateTimedEvent = 67, // Id, Initialmin, Initialmax, Repeatmin(Only If It Repeats), Repeatmax(Only If It Repeats), Chance Playmovie = 68, // Entry MoveToPos = 69, // PointId, transport, disablePathfinding, ContactDistance - RespawnTarget = 70, // + EnableTempGobj = 70, // Equip = 71, // Entry, Slotmask Slot1, Slot2, Slot3 , Only Slots With Mask Set Will Be Sent To Client, Bits Are 1, 2, 4, Leaving Mask 0 Is Defaulted To Mask 7 (Send All), Slots1-3 Are Only Used If No Entry Is Set CloseGossip = 72, // None TriggerTimedEvent = 73, // Id(>1) diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 822af2b5e..b6c72029f 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -1397,6 +1397,15 @@ namespace Game.AI } break; } + case SmartActions.EnableTempGobj: + { + if (e.Action.enableTempGO.duration == 0) + { + Log.outError(LogFilter.Sql, $"Entry {e.EntryOrGuid} SourceType {e.GetScriptType()} Event {e.EventId} Action {e.GetActionType()} does not specify duration"); + return false; + } + break; + } case SmartActions.SetMovementSpeed: { if (e.Action.movementSpeed.movementType >= (int)MovementGeneratorType.Max) @@ -1456,7 +1465,6 @@ namespace Game.AI case SmartActions.RemoveUnitFlag: case SmartActions.Playmovie: case SmartActions.MoveToPos: - case SmartActions.RespawnTarget: case SmartActions.CloseGossip: case SmartActions.TriggerTimedEvent: case SmartActions.RemoveTimedEvent: @@ -2437,7 +2445,7 @@ namespace Game.AI public Flee flee; [FieldOffset(4)] - public RespawnTarget respawnTarget; + public EnableTempGO enableTempGO; [FieldOffset(4)] public MoveToPos moveToPos; @@ -2899,9 +2907,9 @@ namespace Game.AI { public uint fleeTime; } - public struct RespawnTarget + public struct EnableTempGO { - public uint goRespawnTime; + public uint duration; } public struct MoveToPos { diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 8eab444d8..6686e23b4 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1420,19 +1420,18 @@ namespace Game.AI } break; } - case SmartActions.RespawnTarget: + case SmartActions.EnableTempGobj: { foreach (var target in targets) { if (IsCreature(target)) - target.ToCreature().Respawn(); + Log.outWarn(LogFilter.Sql, $"Invalid creature target '{target.GetName()}' (entry {target.GetEntry()}, spawnId {target.ToCreature().GetSpawnId()}) specified for SMART_ACTION_ENABLE_TEMP_GOBJ"); else if (IsGameObject(target)) { - // do not modify respawndelay of already spawned gameobjects if (target.ToGameObject().IsSpawnedByDefault()) - target.ToGameObject().Respawn(); + Log.outWarn(LogFilter.Sql, $"Invalid gameobject target '{target.GetName()}' (entry {target.GetEntry()}, spawnId {target.ToGameObject().GetSpawnId()}) for SMART_ACTION_ENABLE_TEMP_GOBJ - the object is spawned by default"); else - target.ToGameObject().SetRespawnTime((int)e.Action.respawnTarget.goRespawnTime); + target.ToGameObject().SetRespawnTime((int)e.Action.enableTempGO.duration); } } break;