beyond-all-reason / beyond-all-reason/RecoilEngine

Unit AutoTarget frequency is inconsistently hardcoded

Open
#984 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
679
Forks
290
Avg merge
3d 2h
Merged PRs (30d)
40

Description

Weapon.cpp hardcodes AutoTarget sweeps for every 65 frames:
https://github.com/beyond-all-reason/spring/blob/79c8833ec3163e60476b3b349f65171ba219a45d/rts/Sim/Weapons/Weapon.cpp#L647

MobileCAI.cpp hardcodes AutoTarget sweeps for every 150 frames [30 * 5]
https://github.com/beyond-all-reason/spring/blob/79c8833ec3163e60476b3b349f65171ba219a45d/rts/Sim/Units/CommandAI/MobileCAI.cpp#L1182

Actual AutoTarget sweep frequency takes one additional SlowUpdate due to the early return here: (which also prevents `Execute()` from running on the SlowUpdate frame this early return happens)
https://github.com/beyond-all-reason/spring/blob/79c8833ec3163e60476b3b349f65171ba219a45d/rts/Sim/Units/CommandAI/MobileCAI.cpp#L339

Therefore, units in general only perform an AutoTarget sweep every 165 frames, unless one of the conditions is set here:
https://github.com/beyond-all-reason/spring/blob/79c8833ec3163e60476b3b349f65171ba219a45d/rts/Sim/Units/CommandAI/MobileCAI.cpp#L1192
then the AutoTarget sweep happens every 75 frames (the slowupdate after the 65 frame hardcoded value)

Contributor guide

Open the contributing guide

Research direction

Start with the referenced AutoTarget logic in rts/Sim/Weapons/Weapon.cpp and rts/Sim/Units/CommandAI/MobileCAI.cpp, comparing the hardcoded frame intervals with MobileCAI.cpp's early-return path. Trace how SlowUpdate affects Execute() and sweep timing. Done means the AutoTarget frequency is consistent across the identified paths and the differing intervals are no longer unintentionally hardcoded.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.