1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-06 00:23:49 +02:00
ComfyFactorio/modules/splice.lua

34 lines
1.1 KiB
Lua
Raw Normal View History

-- biter splicing -- storage.splice_modifier can be increased for increased difficulty -- by mewmew
2018-12-31 02:55:18 +02:00
2021-03-24 21:14:55 +02:00
local Event = require 'utils.event'
2018-12-31 02:55:18 +02:00
local biter_fragmentation = {
['medium-biter'] = { 'small-biter', 1 },
['big-biter'] = { 'medium-biter', 1 },
['behemoth-biter'] = { 'big-biter', 1 }
2021-03-24 17:46:00 +02:00
}
2018-12-31 02:55:18 +02:00
2021-03-24 17:46:00 +02:00
local function on_entity_died(event)
if not event.entity.valid then
return
end
if biter_fragmentation[event.entity.name] then
local entity = event.entity
local amount = 1
if storage.splice_modifier then
amount = math.ceil(storage.splice_modifier * biter_fragmentation[entity.name][2])
2021-03-24 17:46:00 +02:00
end
if amount < 1 then
return
end
2021-03-24 21:14:55 +02:00
for _ = 1, amount, 1 do
2021-03-24 17:46:00 +02:00
local p = entity.surface.find_non_colliding_position(biter_fragmentation[entity.name][1], entity.position, 3, 0.5)
if p then
entity.surface.create_entity({ name = biter_fragmentation[entity.name][1], position = p })
2021-03-24 17:46:00 +02:00
end
end
end
2018-12-31 02:55:18 +02:00
end
2021-03-24 17:46:00 +02:00
2021-03-24 21:14:55 +02:00
Event.add(defines.events.on_entity_died, on_entity_died)