Also, the number of hits required is off by one due to floating point rounding (I think).
As you can see, the number of prints is 1 higher than the number of hits.
Tested by adding the following event on a clean safe without any techs unlocked:
local bugfix_on_entity_damage = function(event)
if string.sub(event.entity.name, 1, 25) ~= "mining-drone-attack-proxy" then
return
end
game.print(string.format("Damage %s | final amount: %s | final health: %s ", event.original_damage_amount, event.final_damage_amount, event.final_health))
end
And in the mining_drone:make_attack_proxy
method adding this line: game.print("Number of hits: " .. number_of_hits)
.
Setting data.mining_damage
to 1 fixes it. But I don't fully understand why the damage is set to 5 in the first place so maybe that has some side effects I'm unaware of and the actual solution is more complicated.