mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
30 lines
776 B
Lua
30 lines
776 B
Lua
local Task = require "utils.Task"
|
|
|
|
local worms_per_chunk = 50
|
|
local small_worm_spawn_distance = 100
|
|
local medium_worm_spawn_distance = 150
|
|
local big_worm_spawn_distance = 200
|
|
|
|
local worm_names = {"small-worm-turret", "medium-worm-turret", "big-worm-turret"}
|
|
|
|
local chance = worms_per_chunk / (32 * 32)
|
|
|
|
return function(x, y, world)
|
|
local x, y = world.x, world.y
|
|
local distance = math.sqrt(x * x + y * y)
|
|
|
|
if distance > small_worm_spawn_distance - 32 then
|
|
local lvl = 1
|
|
if distance > medium_worm_spawn_distance then
|
|
lvl = 2
|
|
end
|
|
if distance > big_worm_spawn_distance then
|
|
lvl = 3
|
|
end
|
|
if math.random() < chance then
|
|
local worm_id = math.random(1, lvl)
|
|
return {name = worm_names[worm_id], position = {x, y}}
|
|
end
|
|
end
|
|
end
|