beyond-all-reason / beyond-all-reason/RecoilEngine
Fault with 'nochasecategory' sometimes incorrectly invalidating viable targets
- Dominant language
- C++
- Stars
- 679
- Forks
- 290
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 40
Description
To prune a long story short, fight command uses Enemy_InLos_ValidTarget to see if a target is valid, which in turn uses
bool CMobileCAI::IsValidTarget
Which contains
`if (owner->unitDef->noChaseCategory & enemy->category)
return false`
therefore in 'some cases' (I can't see why not all, however), fight commands will not realise an enemy that is in the 'nochasecategory' is something it should consider as a real target and stop moving when in range of.
Nochasecategory is intended to be what it says on the tin, eg a unit will still shoot and engage with units there, but not pursue if they run away. The code seems to not always amount to that end result.
https://github.com/beyond-all-reason/spring/blob/ab88be7e235eba1417dbfa07e95277b480283c0b/rts/Game/GameHelper.cpp#L491
https://github.com/beyond-all-reason/spring/blob/ab88be7e235eba1417dbfa07e95277b480283c0b/rts/Sim/Units/CommandAI/MobileCAI.cpp#L573
Discord discussions and more clips start around here: https://discord.com/channels/549281623154229250/724924957074915358/1233044341866369074
Example, this unit has 'nochasecategory="ALL"', will shoot a target as expected, but will not halt when fight-moved into range.
(However razorbacks with same tag, do halt correctly when given same command, so there is something else at play too)
When the nochasecategory tag is removed, they will halt at fight distance correctly.
https://github.com/beyond-all-reason/spring/assets/37483246/de0a582f-e943-458d-833d-ee69cbce1134
https://github.com/beyond-all-reason/spring/assets/37483246/bbbad070-dd74-456e-99ae-ffee42cdda0e
Contributor guide
Research direction
Start at the linked GameHelper.cpp location and trace Enemy_InLos_ValidTarget into MobileCAI.cpp around IsValidTarget. Reproduce the fight-move case with nochasecategory="ALL", compare it with the tag removed and with the razorback example, and verify that a unit halts at fight range while still not pursuing fleeing targets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100