From 6625471d6762dd0b421a17233b709c5597ac8fb2 Mon Sep 17 00:00:00 2001 From: Aaron Warner <34614077+relent0r@users.noreply.github.com> Date: Mon, 27 May 2024 07:59:22 +1200 Subject: [PATCH] AI - Increase distance limits for Naval Area marker generation (#6048) --- changelog/snippets/ai.6048.md | 1 + lua/sim/MarkerUtilities/NavalAreas.lua | 32 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 changelog/snippets/ai.6048.md diff --git a/changelog/snippets/ai.6048.md b/changelog/snippets/ai.6048.md new file mode 100644 index 0000000000..13780bf56c --- /dev/null +++ b/changelog/snippets/ai.6048.md @@ -0,0 +1 @@ +- (#6048) Increase maximum distances for Naval Area marker generation to improve AI naval presence on certain maps. diff --git a/lua/sim/MarkerUtilities/NavalAreas.lua b/lua/sim/MarkerUtilities/NavalAreas.lua index 558d29db92..b918e515fa 100644 --- a/lua/sim/MarkerUtilities/NavalAreas.lua +++ b/lua/sim/MarkerUtilities/NavalAreas.lua @@ -43,13 +43,14 @@ end ---@param distance number ---@param thresholdSize number ---@param thresholdArea number -local function GenerateForExpansion(expansion, distance, thresholdSize, thresholdArea) +local function GenerateForExpansion(expansion, distance, thresholdSize, thresholdArea, maximumCount) -- local imports to make debugging easier local NavUtils = import("/lua/sim/navutils.lua") local position = expansion.position local points, count = NavUtils.GetPositionsInRadius('Water', position, distance, thresholdSize, { }) if points then + local unsortedExpansionMarkers = {} for k = 1, count do local point = points[k] @@ -83,9 +84,20 @@ local function GenerateForExpansion(expansion, distance, thresholdSize, threshol Type = 'Naval Area', } - -- keep track of the marker - MarkerCount = MarkerCount + 1 - Markers[MarkerCount] = marker + table.insert(unsortedExpansionMarkers, marker) + end + table.sort(unsortedExpansionMarkers,function(a,b) return VDist3Sq(position,a.position) 1024 then thresholdDistance = 30 end - GenerateForExpansion(smallExpansions[k], thresholdDistance, thresholdSize, thresholdArea) + GenerateForExpansion(smallExpansions[k], thresholdDistance, thresholdSize, thresholdArea, 2) end -- generate for large expansions @@ -144,16 +156,18 @@ function Generate() if mapSize > 1024 then thresholdDistance = 50 end - GenerateForExpansion(largeExpansions[k], thresholdDistance, thresholdSize, thresholdArea) + GenerateForExpansion(largeExpansions[k], thresholdDistance, thresholdSize, thresholdArea, 4) end -- generate for spawn locations for k = 1, spawnCount do local thresholdDistance = 40 - if mapSize > 1024 then - thresholdDistance = 50 + if mapSize >= 2048 then + thresholdDistance = 650 + elseif mapSize >= 1024 then + thresholdDistance = 150 end - GenerateForExpansion(spawns[k], thresholdDistance, thresholdSize, thresholdArea) + GenerateForExpansion(spawns[k], thresholdDistance, thresholdSize, thresholdArea, 6) end import("/lua/sim/markerutilities.lua").OverwriteMarkerByType('Naval Area', Markers)