Add set-guard-range sexp - #7251
Conversation
62ec9c3 to
56b075a
Compare
56b075a to
1ff2dd7
Compare
|
I realized I should have asked this here just to save any other reviewers the same question: |
9a8f961 to
5d5dca7
Compare
I honestly can't remember why I chose to leave those out. I'll need to do some additional testing. I'm going to set this to draft until I can verify. |
Ok, I remember why I left those untouched. Those places seem to be more about the guarding ship's orbital position rather than the distance at which threats would be intercepted. I didn't think that guard range should really mess with the orbital math or that might cause funny collisions and things. I'm still happy with where this is at. |
|
Sounds good to me and makes sense! That last thing that I wanted to ask about, in FotG and other mods it will be useful to have the ability to set this via script (so it's more optimized then running |
Good asks. Honestly I'm very focused on other PRs right now. Those would be good for follow ups. |
Follow-up to #7251, which added `set-guard-range` This PR exposes that value to scripting, so scripters do not have to use the more expensive `runSEXP` to use it. The value is initialized as -1 (`max_guard_radius = -1.0f;` line 7913 in ship.cpp), hence the default value for the script is -1.
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-rangesexp 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