From 6cca0951e6058523ea03db7335bf762b9a9ad6d5 Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Mon, 18 Dec 2023 01:53:33 +0600 Subject: [PATCH 1/2] Fix bots getting stuck between the base and first capture point --- ext/Server/PathSwitcher.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/Server/PathSwitcher.lua b/ext/Server/PathSwitcher.lua index fc9a21a6..1c1b18fd 100644 --- a/ext/Server/PathSwitcher.lua +++ b/ext/Server/PathSwitcher.lua @@ -270,7 +270,7 @@ function PathSwitcher:GetNewPath(p_Bot, p_BotName, p_Point, p_Objective, p_InVeh return false end - if #s_ValidPaths == 1 and s_CurrentPriority < s_ValidPaths[1].Priority then + if #s_ValidPaths == 1 and s_CurrentPriority <= s_ValidPaths[1].Priority then -- m_Logger:Write('chose to switch at random ('..s_RandomNumber..' >= '..s_Chance..') | Priority: ( '..s_CurrentPriority..' | '..s_RandomPath.Priority..' )') return true, s_ValidPaths[1].Point end From 612960917859c7b172e53edaa4b7846ab0d1519e Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Mon, 25 Dec 2023 23:53:49 +0600 Subject: [PATCH 2/2] Fix bots constantly switching paths --- ext/Server/PathSwitcher.lua | 44 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/ext/Server/PathSwitcher.lua b/ext/Server/PathSwitcher.lua index 1c1b18fd..95b8d23b 100644 --- a/ext/Server/PathSwitcher.lua +++ b/ext/Server/PathSwitcher.lua @@ -123,47 +123,55 @@ function PathSwitcher:GetNewPath(p_Bot, p_BotName, p_Point, p_Objective, p_InVeh -- Path with a single objective that matches mine, top priority. if #s_PathNode.Data.Objectives == 1 and s_PathNode.Data.Objectives[1] == p_Objective then - if s_HighestPriority < 2 then - s_HighestPriority = 2 + if s_HighestPriority < 3 then + s_HighestPriority = 3 + end + + table.insert(s_Paths, { + Priority = 3, + Point = s_NewPoint, + State = s_NewPathStatus, + Base = s_NewBasePath + }) + + if s_NewPoint.ID == p_Point.ID then + s_CurrentPriority = 3 + end + -- Consider path with other objective, in case everything else fails + elseif #s_PathNode.Data.Objectives == 1 then + if s_HighestPriority < 1 then + s_HighestPriority = 1 end table.insert(s_Paths, { - Priority = 2, + Priority = 1, Point = s_NewPoint, State = s_NewPathStatus, Base = s_NewBasePath }) if s_NewPoint.ID == p_Point.ID then - s_CurrentPriority = 2 + s_CurrentPriority = 1 end - -- Otherwise, check if the path has an objective I want. + -- Otherwise, check if the path has an objective I want. else -- Loop through the path's objectives and compare to mine. for _, l_PathObjective in pairs(s_PathNode.Data.Objectives) do if p_Objective == l_PathObjective then - if s_HighestPriority < 1 then - s_HighestPriority = 1 + if s_HighestPriority < 2 then + s_HighestPriority = 2 end table.insert(s_Paths, { - Priority = 1, + Priority = 2, Point = s_NewPoint, State = s_NewPathStatus, Base = s_NewBasePath }) if s_NewPoint.ID == p_Point.ID then - s_CurrentPriority = 1 + s_CurrentPriority = 2 end - -- Consider path with other objective, in case everything else fails - elseif #s_PathNode.Data.Objectives == 1 then - table.insert(s_Paths, { - Priority = 0, - Point = s_NewPoint, - State = s_NewPathStatus, - Base = s_NewBasePath - }) end end end @@ -270,7 +278,7 @@ function PathSwitcher:GetNewPath(p_Bot, p_BotName, p_Point, p_Objective, p_InVeh return false end - if #s_ValidPaths == 1 and s_CurrentPriority <= s_ValidPaths[1].Priority then + if #s_ValidPaths == 1 and s_CurrentPriority < s_ValidPaths[1].Priority then -- m_Logger:Write('chose to switch at random ('..s_RandomNumber..' >= '..s_Chance..') | Priority: ( '..s_CurrentPriority..' | '..s_RandomPath.Priority..' )') return true, s_ValidPaths[1].Point end