Skip to content

Commit

Permalink
Move build range overlay creation to post-mod blueprint loading (FAFo…
Browse files Browse the repository at this point in the history
…rever#6220)

<!-- General useful tooling:
- [ScreenToGif](https://www.screentogif.com/): Free, open source screen
recorder that can export to MP4. If the changes are visual, these can
help you tell us exactly what the changes imply!
-->
<!-- Feel free to remove unused parts of this template. -->
## 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
<!-- A clear and concise description (or visuals) of what the changes
imply. -->
<!-- If it closes an issue, make sure to link the issue by using
"(Closes/Fixes/Resolves) #(Issue Number)" in your pull request. -->
- 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
<!-- List all relevant testing that you've done to confirm the changes
work. -->
- 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 <[email protected]>
  • Loading branch information
lL1l1 and MrRowey authored Jun 26, 2024
1 parent ee3510f commit 8732997
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions changelog/snippets/features.6220.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 0 additions & 9 deletions lua/system/Blueprints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions lua/system/blueprints-units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8732997

Please sign in to comment.