1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00
ComfyFactorio/modules/splice.lua
Gerkiz e91b6a352f 2.0 changes
Change global -> storage
Rework how rendering works
Game prototypes are now stored inside 'prototypes.#'
Renamed entity names
2024-10-22 21:47:11 +02:00

34 lines
1.1 KiB
Lua

-- biter splicing -- storage.splice_modifier can be increased for increased difficulty -- by mewmew
local Event = require 'utils.event'
local biter_fragmentation = {
['medium-biter'] = { 'small-biter', 1 },
['big-biter'] = { 'medium-biter', 1 },
['behemoth-biter'] = { 'big-biter', 1 }
}
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])
end
if amount < 1 then
return
end
for _ = 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)