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 a bug that could freeze up a weapon and even the simulation #6345

Merged
merged 2 commits into from
Jul 13, 2024

Conversation

Garanas
Copy link
Member

@Garanas Garanas commented Jul 13, 2024

Description of the proposed changes

Related to this forum post and this Discord post.

Weapons now properly use the AttackGroundTries field because of #6277. For the average unit this is fine, but for bombers and specifically bombers with multiple projectiles per salvo it introduced an unusual problem: the first projectile would aim at the current target. All remaining projectiles may aim at the next target. This doesn't apply to all bombers, but in particular the UEF Tech 1 bomber (Scorcher) fell victim to this bug.

When the bug happens we end up in an unstable state. To the user this would show as:

  • (1) A bomber with a weapon that is no longer functional.
  • (2) The simulation freezes up.

These issues are related to how we re-compute the (vertical) bomb trajectory in Lua. We do this in Lua to fix an engine bug where bombers would constantly miss their target. For a salvo the code assumes that the ground target does not suddenly shift as the salvo is being processed. This is a safe assumption as any normal interrupt would also cancel the salvo. But now that the engine can use the AttackGroundTries field again it is suddenly very possible that this happens throughout the salvo. And as a result the computations are all messed up. And because of that we try to get the square root of a negative number. This imaginary number does not exist in the real world and since we simulate the real world here (ha) the game returns an invalid number: -1.#ND.

This introduces all sorts of problems. One of them is (1). The other is (2) as we pass the invalid number to SetBallisticAcceleration. The moment that happens the simulation freezes.

Testing done on the proposed changes

Spawn in various bombers and make them bomb random patches of ground.

Additional context

The behavior of the Scorcher is consistent between FAForever and Steam - for some odd reason the Janus works as expected and the Scorcher appears to switch targets too soon. Could it be because it is the primary weapon of the Scorcher?

Checklist

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

Copy link
Contributor

@ErikMekkes ErikMekkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves the bugged weapon fire state for the scorcher due to target switching after 3 attempts on the current target 👍

some issues with retargeting for ground attacks remain but were not as critical

  • trajectory issues for zeus, scorcher, possibly others salvo projectiles on 3rd attack
  • skipped attack but with reload 'penalty' for 3rd salvo of Janus, Ravager, possibly others

@Garanas Garanas merged commit 3eb5132 into develop Jul 13, 2024
5 checks passed
@Garanas Garanas deleted the Fix/weapon-freeze-bug branch July 13, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants