1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00
RedMew/map_gen/terrain/worms.lua

30 lines
776 B
Lua
Raw Normal View History

2018-01-27 15:49:55 +00:00
local Task = require "utils.Task"
2017-10-06 02:14:38 +02:00
local worms_per_chunk = 50
local small_worm_spawn_distance = 100
local medium_worm_spawn_distance = 150
local big_worm_spawn_distance = 200
2018-05-10 00:21:12 +01:00
local worm_names = {"small-worm-turret", "medium-worm-turret", "big-worm-turret"}
2017-10-06 02:14:38 +02:00
2018-05-10 00:21:12 +01:00
local chance = worms_per_chunk / (32 * 32)
2017-10-06 02:14:38 +02:00
2018-05-10 00:21:12 +01:00
return function(x, y, world)
local x, y = world.x, world.y
local distance = math.sqrt(x * x + y * y)
2017-10-06 02:14:38 +02:00
if distance > small_worm_spawn_distance - 32 then
local lvl = 1
2018-05-10 00:21:12 +01:00
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}}
2017-10-06 02:14:38 +02:00
end
end
end