mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-06 00:23:49 +02:00
22 lines
547 B
Lua
22 lines
547 B
Lua
-- enemy biters have pseudo double hp -- by mewmew
|
|
|
|
local Event = require 'utils.event'
|
|
|
|
local function on_entity_damaged(event)
|
|
if not event.entity.valid then
|
|
return
|
|
end
|
|
if math.random(1, 2) == 1 then
|
|
return
|
|
end
|
|
if event.entity.type ~= 'unit' then
|
|
return
|
|
end
|
|
if event.final_damage_amount > event.entity.prototype.max_health then
|
|
return
|
|
end
|
|
event.entity.health = event.entity.health + event.final_damage_amount
|
|
end
|
|
|
|
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|