FAForever / FAForever/fa

[Bug]: Units do not end attack tasks when the target is dead

Open
#6,655 2 comments 0 reactions 0 assignees View on GitHub
area: engine type: bug
Dominant language
Lua
Stars
264
Forks
260
Avg merge
3d 2h
Merged PRs (30d)
21

Description

### Describe the Bug

Units given attack orders on aircraft or navy (units that fall or sink after dying before they are destroyed) do not switch targets until they get in range and try to fire, or in some cases, until the unit falls to the ground/seafloor and is destroyed.

Another effect of this bug is that retargeting projectiles from the units given attack orders cannot retarget until the target is destroyed because that is when OnLostTarget gets called.

### Reproduce the bug

1. Spawn 300 hundred ASF, spawn some enemy CZARs in a line, let the ASF spread out, and then issue attack orders on the CZARs. The ASF will not update their command queue until they try to fire at the falling CZAR. This general case applies to land units and navy too.

2. Spawn some sams, fly strats over them, and issue attack orders. The missiles will keep tracking the strats despite the sams updating their command queue properly.
![Image](https://github.com/user-attachments/assets/e62e6d64-b702-4ae6-a931-3f7b635db08b)
This case generally applies to the behavior of any tracking projectiles, for example torpedoes of land or navy units or AA missiles of cybran ASF or torpedoes of torpedo bombers.

3. Spawn a bunch of bouncers and 2 CZARs, and then issue attack orders for the bouncers onto the two CZARs. The bouncers will not stop targeting the CZAR until it falls to the ground entirely. It is unique in that its AA weapon is not index 1 in its blueprint and therefore does not control its AI. This weapon also does not always recheck its target despite being a continuous beam.

4. Spawn some frigs and a large amount of torpedo bombers, then issue an attack order on the frigates with the torpedo bombers. Repeat with automatically attacking attack orders. With attack orders, the torpedoes will keep tracking the sinking unit. Without attack orders, the torpedoes will simply stop and sink, because the torpedo bomber cannot give a new target for the torpedo projectiles because of its bomber targeting behavior.
- This is relevant to the bug because in my prototype of fixing the bug where I destroyed the unit instantly on death, the torpedoes gain retargeting in both cases, but only for the seraphim torpedo bomber.

### Screenshots

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.