Hi there
Thanks, that's interesting. I haven't actually been personally using this mod in quite a long time, just keeping it ticking over between major Factorio versions, so any UPS hits have gone unnoticed.
That said, I'm kind of surprised by this. The loop is basically "do nothing" if the damage didn't come from a bot (though I can see that enough very simple checks like that could eventually cause a UPS hit), and if I understand your code correctly this won't change if any player has bots deployed - it'll still be running that same check and bounce usage back up?
Another way around it (though also imperfect) is to trigger based on on_entity_died instead, and lower ammo counts accordingly. It'd be less "realistic" (though that was never an aim) and large enough deaths/tick would run into the same issues eventually, but should raise the bar a bit. It would also make Zapp Branigan proud.
I don't suppose you have a save game handy to demonstrate the UPS hit? I can try and take a look some time.
Thanks
Jack