Skip to content

Add set-guard-range sexp#7251

Open
MjnMixael wants to merge 1 commit intoscp-fs2open:masterfrom
MjnMixael:set_guard_range
Open

Add set-guard-range sexp#7251
MjnMixael wants to merge 1 commit intoscp-fs2open:masterfrom
MjnMixael:set_guard_range

Conversation

@MjnMixael
Copy link
Contributor

I spent some time looking in to #7025 and it's actually a touch more complex than expected. The AI code limits the guard range with various hardcoded multipliers based on the offending object (weapon, hostile ship, asteroid, etc) and in one instance has an actual hardcoded distance in meters. These values also take in to account the size of the guardee. So it's really pretty complex.

I felt a Guard Tight order would further muddy this up by adding more hardcoded values or multipliers and it wouldn't be easily tunable or readily apparent what the actual difference is for players or mission designers.

After some experimentation I landed on a design that is maybe a touch overly simplistic in some ways but also more configurable. I've added a set-guard-range sexp that works as a clamp for the guard order ranges. The game will use the normal hardcoded logic but if the guard range is > 0 for the guardee ship then it will clamp the calculated range to the guard range. This can be done per-ship which gives mission designers flexibility to tune the guard range based on context. There is not any checking for positive values so you could probably get some pretty interesting AI behavior if the range is set to a value that's too small for the guardee ship class (50m for an Orion might be strange). However, I felt that adding a bunch of dynamic checks was overkill here and mission designers are smart enough to set realistic ranges.

This setup has the advantage of allowing the opposite as well. With set-guard-range you could expand the guard distance if the mission design calls for that sort of thing. Bonus!

Fixes #7025

@wookieejedi wookieejedi added enhancement A new feature or upgrade of an existing feature to add additional functionality. ai A feature or issue related to the AI algorithms labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai A feature or issue related to the AI algorithms enhancement A new feature or upgrade of an existing feature to add additional functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guard Tight option needed

2 participants