2019-02-16 17:36:12 +01:00
|
|
|
-- enemy biters have pseudo double hp -- by mewmew
|
|
|
|
|
2021-03-24 20:14:55 +01:00
|
|
|
local Event = require 'utils.event'
|
2019-02-16 17:36:12 +01:00
|
|
|
|
|
|
|
local function on_entity_damaged(event)
|
2021-03-24 16:46:00 +01:00
|
|
|
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
|
2019-02-16 17:36:12 +01:00
|
|
|
end
|
2021-03-24 16:46:00 +01:00
|
|
|
|
2021-03-24 20:14:55 +01:00
|
|
|
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|