Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, a
HaveFreeLineOfFire
check is performed during autotarget sweeps, and during weaponUpdate
.Targets that fail this check during the autotarget sweep are excluded, and targets that fail this check during
Update
are dropped as a valid target before aim scripts are called.This causes behavior problems for units that "deploy" into a different configuration when they acquire a target. No matter if the deployment is as complicated as unfolding a missile tube, or as simple as raising a cannon barrel to correctly angle a shot.
If the
HaveFreeLineOfFire
check fails in the neutral, stowed away position, the unit AimWeaponX is never called and the unit never deploys their weapon into the configuration that may allow them to fire.Previous examples in BAR include:
Sniper not raising rifle if there are small terrain obstructions.
beyond-all-reason/Beyond-All-Reason#1857
corvroc not raising their missile tube due to blocking friendly units.
Plasma bot in the back cannot fire over its friend because its guns are still flat, while the Plasma bot in the front can fire because it has previously angled up its guns
In addition, there are situations where you know the blocked target will be non-blocking soon, such as:
Rounding the corner around friendly walls,
A square of retreating units and the rear units could die soon, giving a free line of fire to the units in the middle
But no pre-aiming can occur due to the engine dropping blocked targets.
This PR adds a UnitDefWeapon boolean
preaimAtBlockedTargets
to allow those weapons to acquire and keep blocked targets. Actual weapon firing is still blocked by the relevantHaveFreeLineOfFire
check, and non-blocked targets are only aimed at if there is nogoodTargetUnit
orbadTargetUnit
available, and if agoodTargetUnit
orbadTargetUnit
becomes available, the next SlowUpdate Autotarget sweep will select that new target.Video of bottom armrock with
preaimAtBlockedTargets = true
and corstorm withouthttps://github.com/beyond-all-reason/spring/assets/44480662/40bfce8d-8b0f-42c5-a12b-551540786e6a