Rocko suffers from bad engine projectile leading
I was playing a game on Intersection, and while I built Rockos to deal with snoke's Warriors, the Rockos kept over-leading their shots slightly and barely missing. I'm not sure if this is a speed issue, a unitAI issue, a collision volume issue, or an issue with Warriors using the pathfinder instead of ignoring it for raw move (Anarchid's suspicion).
Game: http://zero-k.info/Battles/Detail/444850 Rocko-Warrior engagements start around 11 minutes in.
On closer inspection i no longer suspect raw move:
- Warriors don't UnitAI against Rockos.
- Rockos in the game seem to correctly lead Warriors as long as those move in perfectly straight lines.
There are a lot of incredibly narrow misses against seemingly straight moving Warriors but again on closer inspection they seem to be imperfectly straight world lines. They stutter, make pauses, and make small heading changes. That these small heading changes are sufficient to dodge may be an issue.
But i'm not sure i want to see map-spanning lines of rockos again.
Is this still a problem after Hoko projectile speed buff f315e830ab2d2fcff3cebc856350bf12e4502d9c ?
Engine. Engine leading is wrong: https://github.com/spring/spring/blob/d5771b9cfdf35491853f6130106535585bf5b6bb/rts/Sim/Weapons/Weapon.cpp#L1244
A shoots B with a projectile, 10 speed
B walks towards C at 5 speed
Projectile ETA from A to B = 17 time
17 time * 5 speed = 85 distance (point D)
Projectile ETA from A to D = 11 time
Projectile arrives at D 6 time units before the target. Overshoot.
So raw move made units move in lines that are straight enough to reveal aiming issues?
I think it might rather be lines not straight enough over time. Rocko seems to be able to lead just at the edge of the hitbox so any tiny changes in heading can cause a miss. Raw move can apply such tiny changes when spamming orders but regular move just keeps going along the 8 cardinal directions.
https://springrts.com/mantis/view.php?id=5680
Apparently Bandit can fail to hit Glaive, unsure if the same root cause: https://zero-k.info/Battles/Detail/1192709
https://github.com/ZeroK-RTS/Zero-K/blob/master/LuaRules/Gadgets/weapon_projectile_retarget.lua now exists and reproduces the engine behaviour. Maybe it could implement a proper solution and then any problematic units (rocko etc) could be handled there.
Just so we don't lose it.
Niarteloc — Yesterday at 14:38 100% accurate single sqrt flight time for projectile leading equation:
t = (-2*dot(v_unit, dist_to_unit) + sqrt(4*dot(v_unit, dist_to_unit)^2 + 4*(v_projectile^2 - v_unit^2)*dist_to_unit))/(2*(v_projectile^2 - v_unit^2)
Engine ticket beyond-all-reason/spring#746
There's now a weapon accurateLeading tag (goes in the table with bad cats, not weapondef) which is an integer that specifies a limit of how many iterations of the above equation to apply (where 0 is the current naive approximation). The reason 1 iteration may not be sufficient is that ballistic weapons have different horizontal projectile speeds at different ranges. If a frame-accurate solution is found (which will always be after 1 iteration for non-ballistic) it stops iterating, so setting everything to 9999 is supposed to be "fine".
I expect setting everything to like 2 or 3 in posts would solve the issue without noticeable perf costs.
The issue reports wrong lead for Rocko shots.
Commit 4b5660c0d, “Better aiming.” enables accurate lead for this weapon. Rocko is now called Ronin.
Current master sets accurateLeading = 1 for the rocket.
No test was run; this is from the code and history.
This looks resolved; it can be closed if the reporter agrees.
Found with help from OpenAI Codex and Claude Code.