About the previous discussion in Krastorio compatibility, I have another suggestion to give u.
I see that u use on_entity_damaged for modify the incoming damage, "WITHOUT FILTERS", this mean that each time there's a wave of biters ur mod will consume a lot of ups because ur script manage an event for each shot on a biters, in end game this is very high quantities of callbacks.
Fortunately on_entity_damaged event support LuaEntityDamagedEventFilters, apply a filter like:
filter = {
{ filter = "vehicle" }
}
script.blabla(eventname, func, filter)
Will improve ur ups consume.