[boskid][2.1.20] Electric turret firing projectiles can suddenly drain its buffer

This subforum contains all the issues which we already resolved.
User avatar
Shemp
Long Handed Inserter
Long Handed Inserter
Posts: 89
Joined: Mon Jan 19, 2026 6:51 pm
Contact:

[boskid][2.1.20] Electric turret firing projectiles can suddenly drain its buffer

Post by Shemp »

I'm not familiar with this part of the API concerning turrets, so I apologise if this ends up being programmer error.

zzz-ShempDebug_0.2.1.zip
(5.18 KiB) Downloaded 15 times
I've created a reproduction mod that defines a new "Zap turret". This turret
  • Fires an exploding ball projectile
  • Has a slow rate of fire and an expensive energy cost per projectile
  • Has a long, limited-angle range with a minimum range (similar to flamethrower turrets)
TurretBufferBug.zip
(2.2 MiB) Downloaded 18 times
If you load the game using the mod and this save file, you will see the following setup:
  • The game is in Editor mode, paused and ready to be started
  • Two Zap turrets are behind a wall, as the front-line of defence
  • Four standard Laser turrets are behind them, to serve as backup
  • A group of biters are spawned to the east, ready to attack
defence-setup.png
defence-setup.png (1.26 MiB) Viewed 243 times
Steps to reproduce:
  • Load into the save file
  • Advance time by 270 ticks. Keep an eye on the southern Zap turret
  • Near the end of this time period, this turret's buffer will drain completely, but it will not fire any projectile.
  • Advance time by a few more ticks and watch the northern Zap turret, and the same thing will happen to it.
Even if the turrets' buffer is increased to 20 or 30MJ, this bug will cause it to drain completely whenever it occurs.

I expect buffer energy to not be expended if the turret is unable to fire or needs to cancel out of its animation.

-------------------------------------------------

You can see a second bug by turning on the mod's startup setting "Enable exact-sized buffer bug". This lowers the energy buffer to 10MJ, exactly equal to the energy cost of the projectile.

This causes the Zap turret to track the enemy, but it can never fire despite having the required energy.

-------------------------------------------------

I do not believe either of these behaviours occurred in Factorio 1.1.110.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4949
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.1.20] Electric turret firing projectiles can suddenly drain its buffer

Post by boskid »

Thanks for the report and providing a useful reproduction. Issue is now fixed for 2.1.21. It was related to electric turrets consuming energy before they even fired, which was a problem because firing code does range checks and so when biters became closer than min range, it was consuming energy but not firing. Fix is that electric turret will only consume energy after fire succeds.
Post Reply

Return to “Resolved Problems and Bugs”