Open KyleAnthonyShepherd opened 1 year ago
The cannon pointing west in the gif is due to this separate issue https://github.com/beyond-all-reason/spring/issues/659
This is CWeapon
so affects ~all weapons, not just cannons. Old mantis ticket with similar info https://springrts.com/mantis/view.php?id=5680
Unit at A tries to shoot unit B (who is moving towards C with speed 5) with a weapon of projectile speed 10.
Target distance is 173, so ETA = ~17. During that time, B will move a distance of 85 so A shoots at position D.
But D is only 108 distance from A so ETA = ~11. The target hasn't yet arrived -> overshoot.
The correct place to shoot would be about 60 distance from B which is 120 distance from A, so that both the projectile and the unit arrive after 12 time.
20230407_183710_DSDR 4_105.1.1-1544-g058c8ea BAR105.zip
GIF and replay from BAR. tank unit unitdef modded with predictboost = 1.
Cannon units do not accurately lead their targets. CWeapon::GetLeadVec at Weapon.cpp#L1272 is assuming projectile travel time is constant, no matter how the target location changes. But this causes errors when the target is moving towards or away from the shooter. If the target is moving towards the shooter, the lead position is closer to the shooter and the projectile has a shorter travel time. So the projectile arrives early and does not hit the target.