From 8732997235ec7fff6072c6adc87252c1c5efc0fa Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Wed, 26 Jun 2024 03:57:18 -0700 Subject: [PATCH] Move build range overlay creation to post-mod blueprint loading (#6220) ## Issue There are frequently modded games with build range multiplier mods, but the overlay is created before mod loading, so it's not possible to see the new range without UI mods. ## Description of the proposed changes - Moves the build range overlay to post mod blueprint loading so it is compatible with mods. - Adds engineering pods to the overlay since it shouldn't lag and it is helpful to see their build range. - Excludes engineer stations from the build range overlay since being able to see what they will auto-assist is useful for not getting them stuck on hard to assist things like SMD. - Excludes engineers with air staging from the overlay just in case it ever happens. ## Testing done on the proposed changes - Enabled a 1.5x build range mod and made sure that the overlay updated for engineers and not for engineer stations. - Checked that guard scan radius for engineer stations works within the exactly stated radius by disabling the blueprint overlay creation, using the default 25 build range overlay from the blueprint, and placing t1 pd inside/outside that overlay. - Larger build skirts (visible with `dbg grid`) like t1 land facs need to have 2 cells within range of the engineer station. - Also tested placing an SMD nearby outside the guard radius at various places and it has to clearly overlap the radius to be assisted automatically. - Checked that build radius works for engineers with the `MaxBuildDistance+2` range by placing T1 PD 7/8 ogrids away from a t1 engi. It can build land factories even further away (8-9 ogrids away from the build skirt max directly vertically/horizontally, but not diagonally (7-8 max)). ## Checklist - [x] Changes are annotated, including comments where useful - [x] Changes are documented in the changelog for the next game version --------- Co-authored-by: Josh --- changelog/snippets/features.6220.md | 5 +++++ lua/system/Blueprints.lua | 9 --------- lua/system/blueprints-units.lua | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 changelog/snippets/features.6220.md diff --git a/changelog/snippets/features.6220.md b/changelog/snippets/features.6220.md new file mode 100644 index 0000000000..290ff76a9b --- /dev/null +++ b/changelog/snippets/features.6220.md @@ -0,0 +1,5 @@ +- (#6220) Improve the build range overlay's compatibility. + - Add the overlay to engineer drones/pods. + - Correctly display build ranges modded through `ModBlueprints()`. + - Display the auto assist range of engineer stations instead of their build range. + - This is only a -2 displayed range difference without mods, but it will be a larger difference with mods. diff --git a/lua/system/Blueprints.lua b/lua/system/Blueprints.lua index a831e9c324..3744054257 100644 --- a/lua/system/Blueprints.lua +++ b/lua/system/Blueprints.lua @@ -787,15 +787,6 @@ function PreModBlueprints(all_bps) bp.AddCategories = nil end - -- Build range overlay - if bp.CategoriesHash.ENGINEER then -- show build range overlay for engineers - if not bp.AI then bp.AI = {} end - bp.AI.StagingPlatformScanRadius = (bp.Economy.MaxBuildDistance or 5) + 2 - if not (bp.CategoriesHash.POD or bp.CategoriesHash.INSIGNIFICANTUNIT) then -- excluding Build Drones - bp.CategoriesHash.OVERLAYMISC = true - end - end - -- Add common category values for easier lookup -- Add tech category diff --git a/lua/system/blueprints-units.lua b/lua/system/blueprints-units.lua index b51491ed52..a5e458f164 100644 --- a/lua/system/blueprints-units.lua +++ b/lua/system/blueprints-units.lua @@ -223,6 +223,28 @@ local function PostProcessUnit(unit) end end + -- Build range overlay + -- only for engineers, excluding insignificant units such as Cybran build drones or air staging that has its own radius set + if isEngineer and not (unit.CategoriesHash['INSIGNIFICANTUNIT'] or unit.CategoriesHash['AIRSTAGINGPLATFORM']) then + -- guarantee that the table exists + if not unit.AI then unit.AI = {} end + + -- Engine allows building +2 range outside the max distance (or even more for large buildings) + local overlayRadius = (unit.Economy.MaxBuildDistance or 5) + 2 + + -- Display auto-assist range for engineer stations instead of max build distance if it is smaller + if unit.CategoriesHash['ENGINEERSTATION'] then + local guardScanRadius = unit.AI.GuardScanRadius + if guardScanRadius < overlayRadius then + overlayRadius = guardScanRadius + end + end + + unit.AI.StagingPlatformScanRadius = overlayRadius + table.insert(unit.Categories, 'OVERLAYMISC') + unit.CategoriesHash.OVERLAYMISC = true + end + -- sanitize air unit footprints -- value used by formations to determine the distance between other air units. Note