From 8f11cd766012e93a4487908ec92dc6e2b99a03ff Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 29 May 2022 16:02:53 -0400 Subject: [PATCH] Core/SAI: Temporarily allow SMART_ACTION_WP_START to specify parameter value 3 for reactState Port From (https://github.com/TrinityCore/TrinityCore/commit/fc3e26fdfe68a7b1a7c0dd6f67dc545f40b9465e) --- Source/Game/AI/SmartScripts/SmartAIManager.cs | 6 +++++- Source/Game/AI/SmartScripts/SmartScript.cs | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 2b01c8a02..ceb2485eb 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -1703,7 +1703,11 @@ namespace Game.AI if (e.Action.wpStart.quest != 0 && !IsQuestValid(e, e.Action.wpStart.quest)) return false; - if (e.Action.wpStart.reactState > (uint)ReactStates.Aggressive) + // Allow "invalid" value 3 for a while to allow cleanup the values stored in the db for SMART_ACTION_WP_START. + // Remember to remove this once the clean is complete. + int TEMPORARY_EXTRA_VALUE_FOR_DB_CLEANUP = 1; + + if (e.Action.wpStart.reactState > (uint)(ReactStates.Aggressive + TEMPORARY_EXTRA_VALUE_FOR_DB_CLEANUP)) { Log.outError(LogFilter.ScriptsAi, $"SmartAIMgr: {e} uses invalid React State {e.Action.wpStart.reactState}, skipped."); return false; diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index e582de90f..1ae45b5ca 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1384,13 +1384,15 @@ namespace Game.AI } } - _me.SetReactState((ReactStates)e.Action.wpStart.reactState); - ((SmartAI)_me.GetAI()).StartPath(run, entry, repeat, unit); + // Extra validation to ignore invalid values stored in the db, see comment at TEMPORARY_EXTRA_VALUE_FOR_DB_CLEANUP definition + if ((ReactStates)e.Action.wpStart.reactState <= ReactStates.Aggressive) + _me.SetReactState((ReactStates)e.Action.wpStart.reactState); + _me.GetAI().StartPath(run, entry, repeat, unit); uint quest = e.Action.wpStart.quest; uint DespawnTime = e.Action.wpStart.despawnTime; - ((SmartAI)_me.GetAI()).EscortQuestID = quest; - ((SmartAI)_me.GetAI()).SetDespawnTime(DespawnTime); + _me.GetAI().EscortQuestID = quest; + _me.GetAI().SetDespawnTime(DespawnTime); break; } case SmartActions.WpPause: