-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bombers missing during vertical movement #6572
base: develop
Are you sure you want to change the base?
Conversation
-- The projectile will have velocity in the horizontal plane equal to the unit's 3 dimensional speed | ||
-- Multiply the XZ components by the ratio of the XYZ to XZ speeds to get the correct XZ components | ||
local projVelXZSquareSum = projVelX * projVelX + projVelZ * projVelZ | ||
local multiplier = math.sqrt((projVelXZSquareSum + _ * _) / (projVelXZSquareSum)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the variable is being used, projVelY
shouldn't be called _
anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_
gets reused:
targetVelX, _, targetVelZ = UnitGetVelocity(target) |
targetVelX, _, targetVelZ = UnitGetVelocity(target) |
Should it be initialized as a local here?
local targetPos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end, it's all for readability - here it's just indicating that a variable that needs to be there isn't used. Ideally, it'd be redefined every time so that the function can more easily pop its return values into sequential registers, but I don't recall if shadowed variables in Lua get their register slot freed.
@BlackYps this may also be nice to include. |
Issue
Bombers miss when moving vertically because bombs inherit launcher XYZ momentum rotated onto the XZ plane, but the Lua calculation assumes only launcher XZ momentum is inherited.
Description of the proposed changes
Add a few lines fixing the XZ momentum used by the Lua calcuation.
Testing done on the proposed changes
Order a bomber to attack somewhere where it will be changing altitude, it should be perfectly accurate now. The easiest way is to groundfire in front of a landed bomber. You can also groundfire the peak of a mountain.
Left: no fix. Right: fixed
Fixed.bomber.accuracy.mp4
Additional context
The engine still calculates the bomb drop zone independently for firing the bomb, and may not let the bomb fire at all. You can use
ai_RenderBombDropZone
to see the drop zone.Bombs still have a speed limit in the projectile bp in an effort to reduce the minimum bomb drop time in the case of bombing right under the bomber, but this can make them miss when they fire downwards from a high altitude, where the bomb will accelerate a lot.
Checklist