SoftbearStudios / mk48

Mk48.io ship combat game
https://mk48.io
GNU Affero General Public License v3.0
337 stars 58 forks source link

Weapon guidance is broken #158

Closed finnbear closed 2 years ago

finnbear commented 2 years ago

Explanation

Explanation (In the form of a meme, by Iron Shrimp)

image

finnbear commented 2 years ago

Fixes coming in next update.

For the torpedo altitude bug, I identified the issue being a false assumption in the code, related to how weapons move to the right altitude combined with how weapon guidance works.

The procedure is for each target to be added (in parallel) to a collection, which is sorted from worst to best.

Then, the guidance information for each target is applied sequentially. Since best target is last, we assumed that its guidance information would be the sole influence on the weapon guidance.

However, this assumption was incorrect, since the code to update altitudes uses a different system than direction and velocity. Whereas direction and velocity have target values that are simply overwritten, altitude only has the current value, which must be incremented or decremented at the time of targeting.

Combining this all together, the effect was that all targets (good or bad) would impose a change on the altitude of the torpedo.

The fix is to skip applying all but the last (best) targeting info, and is coming in the next update.

I have verified that, with the fix in place, the determining factor between whether torpedoes hit a Kirov or a nearby submerged Ohio is whether the torpedoes were launched at sea level (will hit the Kirov) or at depth (will hit the Ohio).