1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00
ComfyFactorio/modules/splice.lua

26 lines
946 B
Lua
Raw Normal View History

2018-12-31 02:55:18 +02:00
-- biter splicing -- global.splice_modifier can be increased for increased difficulty -- by mewmew
local event = require 'utils.event'
local biter_fragmentation = {
["medium-biter"] = {"small-biter", 1},
2019-01-03 22:50:31 +02:00
["big-biter"] = {"medium-biter", 1},
["behemoth-biter"] = {"big-biter", 1}
2018-12-31 02:55:18 +02:00
}
local function on_entity_died(event)
2019-02-09 12:42:02 +02:00
if not event.entity.valid then return end
2018-12-31 02:55:18 +02:00
if biter_fragmentation[event.entity.name] then
local entity = event.entity
local amount = 1
2019-01-03 22:50:31 +02:00
if global.splice_modifier then amount = math.ceil(global.splice_modifier * biter_fragmentation[entity.name][2]) end
if amount < 1 then return end
2018-12-31 02:55:18 +02:00
for x = 1, amount, 1 do
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}) end
end
end
end
event.add(defines.events.on_entity_died, on_entity_died)