Skip to content

Fixes the multiple reload shots ( https://github.com/Anuken/Mindustry/issues/11636 )#11661

Open
SomeonesShade wants to merge 3 commits intoAnuken:masterfrom
SomeonesShade:reload-bug-fix
Open

Fixes the multiple reload shots ( https://github.com/Anuken/Mindustry/issues/11636 )#11661
SomeonesShade wants to merge 3 commits intoAnuken:masterfrom
SomeonesShade:reload-bug-fix

Conversation

@SomeonesShade
Copy link
Contributor

Fixes #11636 , without reversion.

Proof of it being fixed

Broken Behavior (caused by charging or clicking multiple times)

Screen.Recording.2026-02-12.200054.mp4

Fixed Behavior

Screen.Recording.2026-02-12.200440.mp4

So... what happened?

  • Basically, there is a failsafe system where the turret will fire multiple shots,
  • if the excessReload generated would've been extremely high, (this was mostly done out of just in case, which is questionable),
  • and reload Shots tracks the number of shots it should fire immediately when this happens.
        protected void capReload(){
            //cap reload for visual reasons, need to store the excess reload to keep the firerate consistent
            if(canReload() && reloadCounter >= reload){
                reloadShots += (int)(reloadCounter / reload);
                excessReload += reloadCounter % reload;
            }
            reloadCounter = Math.min(reloadCounter, reload);
            reloadShots = Math.min(reloadShots, 5);

            //if it isn't constantly firing, do not keep excess reload
            if(!wasShooting || shootWarmup < minWarmup){
                reloadShots = 0;
                excessReload = 0;
            }

This updated line !wasShooting || shootWarmup < minWarmup didn't consider that the turret can also not fire if the turret is currently warming up (my bad).

It now does, and it should work.

Notes

  • I'm still thinking if the implementation I did before was okay, maintable, etc.,
  • I guess it was merged and it did have this only bug...
    • Theoretically, wasShooting tracks already if the turret doesn't constantly fire,
    • the !charging() already prevents turrets that are charging like lancer to pile up reload,
    • and the shootWarmup < minWarmup now prevents warmup conditions...
  • completing the list in if(reloadShots > 0 && !charging() && shootWarmup >= minWarmup){ at updateShooting()

If your pull request is not translation or serverlist-related, read the list of requirements below and check each box:

  • I have read the contribution guidelines.
  • I have ensured that my code compiles, if applicable.
  • [n/a] I have ensured that any new features in this PR function correctly in-game, if applicable.

@SomeonesShade
Copy link
Contributor Author

hold up... need to fix something...

@SomeonesShade SomeonesShade marked this pull request as draft February 13, 2026 04:09
@SomeonesShade
Copy link
Contributor Author

managed to test down the code, by using lancer with the !charging() condition removed for testing (this pr doesn't remove it)

it works as expected when excess reload does increase into insane heights (if that ever happens)

(2.5 * 1.9 * 0.75 * 140) = 498.75 theoDPS vs 486 actual dps
image

(2.25 * 1.9 * 0.75 * 140) = 448.875 theoDPS vs 437.68 actual dps
image
(0.75 * 140) = 105 theo dps vs 105.65 actual

image

@SomeonesShade SomeonesShade marked this pull request as ready for review February 13, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant