TL;DR Shields regenerate a large fixed amount for 1 tick if you took damage while at max shields
This may be obnoxious to fix. I have had my suspicions that it is slightly off for a while, and this code confirmed it. It looks like the bug where shields get a very large regen boost for exactly 1 tick if you are at max shield. This boost seems to be roughly 30 ticks worth of regeneration in one tick.The main experiment does the following: 1) Record the player's current shield total, 2) damage player, 3) report shield values after X ticks. This uses 8 normal shield Mk2. The first test call was done at max HP. The second was called while the player was still healing. The main difference is: the 1 tick after the player takes damage, if they were at max shield, they get about +53 shield.
---- This uses 31 legendary shield Mk2. The first test call was done at max HP. The second was called while the player was still healing. Player seems to gain 170 extra shield on the very next tick, if they were at max shield.
----
Extra note: Charge your shields to the max, then remove all your batteries/electricity from your grid, then take damage. Your shields still get this 1 frame bonus regeneration.
----
Some other measurements, included for completeness, but the above pics are all you need.
Measurements (after 120 ticks of regen):
- 8 Shield Mk2. Theoretical = 96/s. Actual = 96/s (perfect, measured mid-heal), Actual = 119.2/s (25% higher)
- 1 Shield Mk1. Theoretical = 12/s. Actual = 12.00/s (perfect measured mid-heal), Actual = 13.64/s (13% higher, measured from max shield)
- 2 Shield Mk2. Theoretical = 24/s. Actual = 24.0/s (perfect, measured while damage was taken mid-heal), Actual = 29.8/s (24% higher, damage taken from max HP).
- 20 rare Shield Mk1. Theoretical = 384/s. Actual = 383.99/s (perfect, measured when taking damage mid-heal), Actual = 440.8/s (15% higher, measured from max shield).
- 1 Legendary shield Mk2. Theoretical = 30/s. actual (measure while healing)= 31.08/s. Actual = 32.75/s (9% higher, from max HP),
- 31 Legendary shield Mk2. Theoretical = 930/s. Actual = 1015/s (9% higher)
- 8 Shield Mk2. Theoretical = 96/s. Actual = 95.9 (measured mid-heal), 652.8/s (measured from being topped off)
- 31 Legendary shield Mk2. Theoretical = 930/s. Actual = 930/s (mid-heal), 2976/s (measured from being topped off
This sucks to test, so I am providing some of my test code for this. shield-bug.lua is the main test code. I tore the main pieces out from my mod, so these files may not compile, but recycling some code should save you some time.
rubia.timing_manager's one job is to invoke a function X ticks in the future, and my event_lib manages events. I recommend using the raiguardian FLIB if you are more comfortable with that.
Also, this might be more of a modding interface request, but read access to the actual regen of a LuaEquipment would help test these things more accurately.
------
EDIT: If you want to just have the whole mod with the test code active, go get v0.69.47 of https://mods.factorio.com/mod/rubia . The test code is on landing-cutscene.lua at line 660. You should be able to just run the tests by calling this with my mod installed:
/c __rubia__ rubia.testing.test_shield_regen()
I understand if you would rather test in isolation. For that, shield_bug.lua attached with the post would have the main code from which to recycle.