Skip to content
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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

lL1l1
Copy link
Contributor

@lL1l1 lL1l1 commented Dec 3, 2024

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

  • Changes are annotated, including comments where useful
  • Changes are documented in the changelog for the next game version

@lL1l1 lL1l1 added type: bug area: sim Area that is affected by the Simulation of the Game labels Dec 3, 2024
@lL1l1 lL1l1 added this to the Development I of 2025 milestone Dec 3, 2024
@lL1l1 lL1l1 requested a review from clyfordv December 3, 2024 07:21
@lL1l1 lL1l1 marked this pull request as ready for review December 3, 2024 07:21
-- 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))
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@Garanas
Copy link
Member

Garanas commented Dec 6, 2024

@BlackYps this may also be nice to include.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: sim Area that is affected by the Simulation of the Game type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants