1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/maps/biter_battles_v2/biters_landfill.lua

42 lines
1.1 KiB
Lua
Raw Normal View History

2020-01-02 00:56:38 +02:00
-- biters will landfill tiles on death within a tiny radius
2020-01-02 17:09:24 +02:00
local Public = {}
2019-09-08 03:54:02 +02:00
local vectors = {{0,0}, {1,0}, {0,1}, {-1,0}, {0,-1}}
local math_random = math.random
2020-01-02 00:56:38 +02:00
local math_abs = math.abs
2019-09-08 03:54:02 +02:00
2019-09-09 22:41:25 +02:00
local whitelist = {
["big-biter"] = true,
["behemoth-biter"] = true,
}
2019-09-08 03:54:02 +02:00
local function create_particles(surface, position)
local m = math_random(8, 12)
local m2 = m * 0.005
for i = 1, 75, 1 do
2020-01-29 06:55:30 +02:00
surface.create_particle({
2019-09-08 03:54:02 +02:00
name = "stone-particle",
position = position,
frame_speed = 0.1,
vertical_speed = 0.1,
height = 0.1,
movement = {m2 - (math_random(0, m) * 0.01), m2 - (math_random(0, m) * 0.01)}
})
end
end
2020-01-02 17:09:24 +02:00
function Public.entity_died(entity)
2020-01-02 00:56:38 +02:00
if not whitelist[entity.name] then return end
local position = entity.position
2020-01-02 17:09:24 +02:00
if math_abs(position.y) < 8 then return true end
2020-01-02 00:56:38 +02:00
local surface = entity.surface
2019-09-08 03:54:02 +02:00
for _, vector in pairs(vectors) do
local tile = surface.get_tile({position.x + vector[1], position.y + vector[2]})
2020-01-02 00:56:38 +02:00
if tile.collides_with("resource-layer") then
--create_particles(surface, tile.position)
2020-01-02 00:56:38 +02:00
surface.set_tiles({{name = "landfill", position = tile.position}})
end
2019-09-08 03:54:02 +02:00
end
2020-01-02 17:09:24 +02:00
return true
2019-09-08 03:54:02 +02:00
end
2020-01-02 17:09:24 +02:00
return Public