mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-09-16 09:16:22 +02:00
changed to new module system
This commit is contained in:
@@ -1,161 +1,15 @@
|
||||
chunk_grid_module = {}
|
||||
-- Drops a grid of concrete, hazard and brick along the chunk edges
|
||||
local b = require "map_gen.shared.builders"
|
||||
|
||||
local function run_terrain_module_setup()
|
||||
grid = {}
|
||||
-- Widths will always double, due to how we draw on the edge of the chunks
|
||||
grid_widths = {
|
||||
["concrete"] = 2,
|
||||
["hazard-concrete-left"] = 1,
|
||||
["stone-path"] = 1
|
||||
}
|
||||
grid_chunk_size = 8
|
||||
local size = 8 * 32
|
||||
|
||||
grid_width = 0
|
||||
-- Prime the array
|
||||
for a,b in pairs(grid_widths) do
|
||||
for i=1, b do
|
||||
grid_width = grid_width + 1
|
||||
grid[grid_width] = a
|
||||
end
|
||||
end
|
||||
end
|
||||
local concrete = b.tile("concrete")
|
||||
local hazard = b.change_tile(b.rectangle(size - 4, size - 4), true, "hazard-concrete-left")
|
||||
local stone = b.change_tile(b.rectangle(size- 6, size -6), true, "stone-path")
|
||||
local empty = b.rectangle(size-8, size-8)
|
||||
|
||||
local no_grid = {}
|
||||
no_grid["out-of-map"] = 1;
|
||||
no_grid["water"] = 1;
|
||||
no_grid["water-green"] = 1;
|
||||
no_grid["deepwater"] = 1;
|
||||
no_grid["deepwater-green"] = 1;
|
||||
local shape = b.any{stone, hazard, concrete}
|
||||
shape = b.subtract(shape, empty)
|
||||
|
||||
run_terrain_module_setup()
|
||||
shape = b.single_pattern(shape, size, size)
|
||||
|
||||
function chunk_grid_module.on_chunk_generated(event)
|
||||
-- Draw the grid
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
local tile
|
||||
|
||||
local rel_x = event.area.left_top.x
|
||||
local rel_y = event.area.left_top.y
|
||||
|
||||
local y = rel_y
|
||||
local x = 0
|
||||
|
||||
local do_top = ( ( ( rel_y / 32 ) % grid_chunk_size ) == 0 )
|
||||
local do_bottom = ( ( ( rel_y / 32 ) % grid_chunk_size ) == ( grid_chunk_size - 1) )
|
||||
local do_left = ( ( ( rel_x / 32 ) % grid_chunk_size ) == 0 )
|
||||
local do_right = ( ( ( rel_x / 32 ) % grid_chunk_size ) == ( grid_chunk_size - 1) )
|
||||
local do_corner_tl = do_top and do_left
|
||||
local do_corner_tr = do_top and do_right
|
||||
local do_corner_bl = do_bottom and do_left
|
||||
local do_corner_br = do_bottom and do_right
|
||||
|
||||
-- Walk the chunk edge
|
||||
for y=rel_y, rel_y+31 do
|
||||
-- Along the left
|
||||
if ( do_left ) then
|
||||
for pos = 1, grid_width do
|
||||
tile_name = grid[grid_width+1 - pos]
|
||||
|
||||
position = {rel_x + grid_width - pos, y}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position = position})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if ( do_right ) then
|
||||
-- Along the right
|
||||
for pos = 1, grid_width do
|
||||
tile_name = grid[grid_width+1 - pos]
|
||||
|
||||
position = {pos + rel_x + 31 - grid_width, y}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position = position})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Top/bottom Edges
|
||||
for x=rel_x, rel_x + 31 do
|
||||
-- Along the top
|
||||
if ( do_top ) then
|
||||
for pos = 1, grid_width do
|
||||
tile_name = grid[grid_width+1 - pos]
|
||||
|
||||
position = {x, rel_y + grid_width - pos}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position = position})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (do_bottom) then
|
||||
-- Along the bottom
|
||||
for pos = 1, grid_width do
|
||||
tile_name = grid[grid_width+1 - pos]
|
||||
position = {x, pos + rel_y + 31 - grid_width}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position = position})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- clean up corners
|
||||
for pos_x = 1, grid_width do
|
||||
for pos_y = 1, grid_width do
|
||||
if pos_x < pos_y then
|
||||
tile_name = grid[pos_x]
|
||||
else
|
||||
tile_name = grid[pos_y]
|
||||
end
|
||||
|
||||
if ( do_corner_tl ) then
|
||||
-- Top Left
|
||||
position = {rel_x - 1 + pos_x, rel_y - 1 + pos_y}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position=position})
|
||||
end
|
||||
end
|
||||
|
||||
if ( do_corner_tr ) then
|
||||
-- Top Right
|
||||
position = {rel_x + 32 - pos_x, rel_y - 1 + pos_y}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position=position})
|
||||
end
|
||||
end
|
||||
|
||||
if ( do_corner_bl ) then
|
||||
-- Bottom Left
|
||||
position = {rel_x - 1 + pos_x, rel_y + 32 - pos_y}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position=position})
|
||||
end
|
||||
end
|
||||
|
||||
if ( do_corner_br ) then
|
||||
-- Bottom right
|
||||
position = {rel_x + 32 - pos_x, rel_y + 32 - pos_y}
|
||||
tile = surface.get_tile( position )
|
||||
if no_grid[tile.name] == nil then
|
||||
table.insert(tiles, {name = tile_name, position=position})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles,true)
|
||||
end
|
||||
|
||||
return chunk_grid_module
|
||||
return shape
|
||||
|
@@ -1,57 +1,63 @@
|
||||
wreck_items_module = {}
|
||||
|
||||
-- adds some wrecked items around the map, good for MP, reduces total resources pulled from factory, and adds incentive to push out
|
||||
|
||||
wreck_item_pool = {}
|
||||
wreck_item_pool = {{name="iron-gear-wheel", count=32},{name="iron-plate", count=64},{name="rocket-control-unit", count=1},{name = "atomic-bomb", count = 1},{name="rocket-fuel", count=7} ,{name="coal", count=8},{name="rocket-launcher", count=1},{name="rocket", count=32},{name="copper-cable", count=128},{name="land-mine", count=64},{name="railgun", count=1},{name="railgun-dart", count=128},{name="fast-inserter", count=8},{name="stack-filter-inserter", count=2},{name="belt-immunity-equipment", count=1},{name="fusion-reactor-equipment", count=1},{name="electric-engine-unit", count=8},{name="exoskeleton-equipment", count=1},{name="rocket-fuel", count=10},{name="used-up-uranium-fuel-cell", count=3},{name="uranium-fuel-cell", count=2},{name="power-armor", count=1},{name="modular-armor", count=1},{name="water-barrel", count=4},{name="sulfuric-acid-barrel", count=6},{name="crude-oil-barrel", count=8},{name="energy-shield-equipment", count=1},{name="explosive-rocket", count=32}}
|
||||
local Token = require "utils.global_token"
|
||||
|
||||
local function place_entities(surface, entity_list)
|
||||
local directions = {defines.direction.north, defines.direction.east, defines.direction.south, defines.direction.west}
|
||||
for _, entity in pairs(entity_list) do
|
||||
local r = math.random(1,entity.chance)
|
||||
if r == 1 then
|
||||
if not entity.force then entity.force = "player" end
|
||||
local r = math.random(1,4)
|
||||
if surface.can_place_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force} then
|
||||
local e = surface.create_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force}
|
||||
if entity.health then
|
||||
if entity.health == "low" then e.health = ((e.health / 1000) * math.random(33,330)) end
|
||||
if entity.health == "medium" then e.health = ((e.health / 1000) * math.random(333,666)) end
|
||||
if entity.health == "high" then e.health = ((e.health / 1000) * math.random(666,999)) end
|
||||
if entity.health == "random" then e.health = ((e.health / 1000) * math.random(1,1000)) end
|
||||
end
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
local wreck_item_pool = {
|
||||
{name = "iron-gear-wheel", count = 32},
|
||||
{name = "iron-plate", count = 64},
|
||||
{name = "rocket-control-unit", count = 1},
|
||||
{name = "atomic-bomb", count = 1},
|
||||
{name = "rocket-fuel", count = 7},
|
||||
{name = "coal", count = 8},
|
||||
{name = "rocket-launcher", count = 1},
|
||||
{name = "rocket", count = 32},
|
||||
{name = "copper-cable", count = 128},
|
||||
{name = "land-mine", count = 64},
|
||||
{name = "railgun", count = 1},
|
||||
{name = "railgun-dart", count = 128},
|
||||
{name = "fast-inserter", count = 8},
|
||||
{name = "stack-filter-inserter", count = 2},
|
||||
{name = "belt-immunity-equipment", count = 1},
|
||||
{name = "fusion-reactor-equipment", count = 1},
|
||||
{name = "electric-engine-unit", count = 8},
|
||||
{name = "exoskeleton-equipment", count = 1},
|
||||
{name = "rocket-fuel", count = 10},
|
||||
{name = "used-up-uranium-fuel-cell", count = 3},
|
||||
{name = "uranium-fuel-cell", count = 2},
|
||||
{name = "power-armor", count = 1},
|
||||
{name = "modular-armor", count = 1},
|
||||
{name = "water-barrel", count = 4},
|
||||
{name = "sulfuric-acid-barrel", count = 6},
|
||||
{name = "crude-oil-barrel", count = 8},
|
||||
{name = "energy-shield-equipment", count = 1},
|
||||
{name = "explosive-rocket", count = 32}
|
||||
}
|
||||
|
||||
local entity_list = {
|
||||
{name = "big-ship-wreck-1", chance = 35000, force = "player"},
|
||||
{name = "big-ship-wreck-2", chance = 45000, force = "player"},
|
||||
{name = "big-ship-wreck-3", chance = 55000, force = "player"}
|
||||
}
|
||||
|
||||
local callback =
|
||||
Token.register(
|
||||
function(entity)
|
||||
entity.health = math.random(entity.health)
|
||||
|
||||
entity.insert(wreck_item_pool[math.random(#wreck_item_pool)])
|
||||
entity.insert(wreck_item_pool[math.random(#wreck_item_pool)])
|
||||
entity.insert(wreck_item_pool[math.random(#wreck_item_pool)])
|
||||
end
|
||||
return false
|
||||
end
|
||||
)
|
||||
|
||||
function wreck_items_module.on_chunk_generated(event)
|
||||
local surface = event.surface
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos_x = event.area.left_top.x + x
|
||||
local pos_y = event.area.left_top.y + y
|
||||
local pos = {x = pos_x,y = pos_y}
|
||||
local entity_list = {}
|
||||
return function(x, y, world)
|
||||
local ship = entity_list[math.random(#entity_list)]
|
||||
|
||||
table.insert(entity_list, {name="big-ship-wreck-1", pos={pos_x,pos_y},chance = 35000, health="random"})
|
||||
table.insert(entity_list, {name="big-ship-wreck-2", pos={pos_x,pos_y},chance = 45000, health="random"})
|
||||
table.insert(entity_list, {name="big-ship-wreck-3", pos={pos_x,pos_y},chance = 55000, health="random"})
|
||||
|
||||
local b, placed_entity = place_entities(surface, entity_list)
|
||||
if b == true then
|
||||
if placed_entity.name == "big-ship-wreck-1" or placed_entity.name == "big-ship-wreck-2" or placed_entity.name == "big-ship-wreck-3" then
|
||||
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
|
||||
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
|
||||
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
if math.random(ship.chance) ~= 1 then
|
||||
return nil
|
||||
end
|
||||
|
||||
ship.callback = callback
|
||||
|
||||
return ship
|
||||
end
|
||||
|
||||
|
||||
return wreck_items_module
|
||||
|
@@ -1,64 +1,59 @@
|
||||
--Author: MewMew / (Threaded by Valansch)
|
||||
|
||||
require "map_gen.shared.perlin_noise"
|
||||
local Task = require "utils.Task"
|
||||
local Event = require "utils.event"
|
||||
|
||||
--SETTINGS:
|
||||
local width_modifier = 0.8
|
||||
ore_base_amounts = {
|
||||
["iron-ore"] = 700,
|
||||
["coal"] = 400,
|
||||
["copper-ore"] = 400,
|
||||
["stone"] = 400,
|
||||
["uranium-ore"] = 400
|
||||
local ore_base_amounts = {
|
||||
["iron-ore"] = 700,
|
||||
["coal"] = 400,
|
||||
["copper-ore"] = 400,
|
||||
["stone"] = 400,
|
||||
["uranium-ore"] = 400
|
||||
}
|
||||
|
||||
local function do_resource(name, x, y, noise_terrain, args, noise_band_high, noise_band_low, seed)
|
||||
local function init()
|
||||
global.perlin_noise_seed = math.random(1000, 1000000)
|
||||
end
|
||||
|
||||
Event.on_init(init)
|
||||
|
||||
local function do_resource(name, x, y, world, noise_terrain, noise_band_high, noise_band_low, seed)
|
||||
if noise_terrain > -noise_band_high * width_modifier and noise_terrain <= -noise_band_low * width_modifier then
|
||||
local noise_resource_amount_modifier = perlin:noise(((x+seed)/200),((y+seed)/200),0)
|
||||
local resource_amount = 1 + ((ore_base_amounts[name] + (ore_base_amounts[name] * noise_resource_amount_modifier * 0.2)) * args.amount_distance_multiplicator)
|
||||
if args.surface.can_place_entity {name=name, position={x,y}} then
|
||||
args.surface.create_entity {name=name, position={x,y}, amount=resource_amount}
|
||||
end
|
||||
local noise_resource_amount_modifier = perlin:noise(((x + seed) / 200), ((y + seed) / 200), 0)
|
||||
local resource_amount =
|
||||
1 +
|
||||
((ore_base_amounts[name] + (ore_base_amounts[name] * noise_resource_amount_modifier * 0.2)) *
|
||||
world.amount_distance_multiplicator)
|
||||
|
||||
return {name = name, amount = resource_amount}
|
||||
end
|
||||
end
|
||||
|
||||
local function do_row(y, args)
|
||||
local y = y + args.area.left_top.y
|
||||
local seed = args.seed
|
||||
for x= args.area.left_top.x, args.area.left_top.x + 31 do
|
||||
local noise_terrain_1 = perlin:noise(((x+seed)/350),((y+seed)/350),0)
|
||||
local noise_terrain_2 = perlin:noise(((x+seed)/50),((y+seed)/50),0)
|
||||
local noise_terrain = noise_terrain_1 + (noise_terrain_2 * 0.01)
|
||||
|
||||
do_resource("iron-ore", x, y, noise_terrain, args, 0.1, 0.075, seed)
|
||||
do_resource("copper-ore", x, y, noise_terrain, args, 0.075, 0.05, seed)
|
||||
do_resource("stone", x, y, noise_terrain, args, 0.05, 0.04, seed)
|
||||
do_resource("coal", x, y, noise_terrain, args, 0.04, 0.03, seed)
|
||||
do_resource("uranium-ore", x, y, noise_terrain, args, 0.03, 0.02, seed)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function fluffy_rainbows_task(args)
|
||||
do_row(args.y, args)
|
||||
args.y = args.y + 1
|
||||
return (args.y < 32)
|
||||
end
|
||||
|
||||
function run_combined_module(event)
|
||||
if not global.perlin_noise_seed then global.perlin_noise_seed = math.random(1000,1000000) end
|
||||
local seed = global.perlin_noise_seed
|
||||
local entities = event.surface.find_entities(event.area)
|
||||
for _, entity in pairs(entities) do
|
||||
if entity.type == "resource" and entity.name ~= "crude-oil" then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local distance = math.sqrt(event.area.left_top.x * event.area.left_top.x + event.area.left_top.y * event.area.left_top.y)
|
||||
return function(x, y, world)
|
||||
if not world.amount_distance_multiplicator then
|
||||
local distance = math.sqrt(world.x * world.x + world.y * world.y)
|
||||
local amount_distance_multiplicator = (((distance + 1) / 75) / 75) + 1
|
||||
world.amount_distance_multiplicator = amount_distance_multiplicator
|
||||
end
|
||||
|
||||
Task.queue_task("fluffy_rainbows_task", {surface = event.surface, y = 0, area = event.area, amount_distance_multiplicator = amount_distance_multiplicator, seed = seed})
|
||||
local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = "resource"}
|
||||
for _, e in ipairs(entities) do
|
||||
if e.name ~= "crude-oil" then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local seed = global.perlin_noise_seed
|
||||
|
||||
local noise_terrain_1 = perlin:noise(((x + seed) / 350), ((y + seed) / 350), 0)
|
||||
local noise_terrain_2 = perlin:noise(((x + seed) / 50), ((y + seed) / 50), 0)
|
||||
local noise_terrain = noise_terrain_1 + (noise_terrain_2 * 0.01)
|
||||
|
||||
return do_resource("iron-ore", x, y, world, noise_terrain, 0.1, 0.075, seed) or
|
||||
do_resource("copper-ore", x, y, world, noise_terrain, 0.075, 0.05, seed) or
|
||||
do_resource("stone", x, y, world, noise_terrain, 0.05, 0.04, seed) or
|
||||
do_resource("coal", x, y, world, noise_terrain, 0.04, 0.03, seed) or
|
||||
do_resource("uranium-ore", x, y, world, noise_terrain, 0.03, 0.02, seed)
|
||||
end
|
||||
|
@@ -46,8 +46,7 @@ return function(x, y, world)
|
||||
entity.destroy()
|
||||
|
||||
return {
|
||||
name = ore_mix[math.random(ore_mix_max)],
|
||||
position = pos,
|
||||
name = ore_mix[math.random(ore_mix_max)],
|
||||
amount = amount_old
|
||||
}
|
||||
end
|
||||
|
@@ -14,39 +14,34 @@ local function harmonic(x, y)
|
||||
local max = -1
|
||||
local richness = 0
|
||||
for i, e in ipairs(ctrs) do
|
||||
local noise = perlin:noise(x/32, y/32, ctrs[i][6])
|
||||
local h_coeff = 1/(1 + .05*math.sqrt((x/32 - ctrs[i][1])*(x/32 - ctrs[i][1]) + (y/32 - ctrs[i][2])*(y/32 - ctrs[i][2])))
|
||||
if noise > max and noise > h_coeff*ctrs[i][4] + (1-h_coeff) then
|
||||
local noise = perlin:noise(x / 32, y / 32, ctrs[i][6])
|
||||
local h_coeff =
|
||||
1 /
|
||||
(1 + .05 * math.sqrt((x / 32 - ctrs[i][1]) * (x / 32 - ctrs[i][1]) + (y / 32 - ctrs[i][2]) * (y / 32 - ctrs[i][2])))
|
||||
if noise > max and noise > h_coeff * ctrs[i][4] + (1 - h_coeff) then
|
||||
max = noise
|
||||
max_idx = i
|
||||
richness = (40*(1-h_coeff) + 0.5*h_coeff) * ctrs[i][5]
|
||||
richness = (40 * (1 - h_coeff) + 0.5 * h_coeff) * ctrs[i][5]
|
||||
end
|
||||
end
|
||||
return max, max_idx, richness
|
||||
end
|
||||
|
||||
--generate ores for entire chunk
|
||||
function run_ores_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
if math.abs(area.left_top.x / 32) < 3 and math.abs(area.left_top.y / 32) < 3 then
|
||||
return function(x, y, world)
|
||||
if math.abs(world.x / 32) < 3 and math.abs(world.y / 32) < 3 then
|
||||
return
|
||||
end
|
||||
local entities = surface.find_entities_filtered{type="resource", area=area}
|
||||
for _, entity in ipairs(entities) do
|
||||
entity.destroy()
|
||||
end
|
||||
local eties = {}
|
||||
for i = 0,31 do
|
||||
for j = 0,31 do
|
||||
local pos = {area.left_top.x + i, area.left_top.y + j}
|
||||
local max, max_idx, richness = harmonic(pos[1], pos[2])
|
||||
if -1 ~= max then
|
||||
local ety = {name = ctrs[max_idx][3], position = pos, force="neutral", amount=richness}
|
||||
if surface.can_place_entity(ety) then
|
||||
surface.create_entity(ety)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = "resource"}
|
||||
for _, e in ipairs(entities) do
|
||||
if e.name ~= "crude-oil" then
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local max, max_idx, richness = harmonic(world.x, world.y)
|
||||
|
||||
if -1 ~= max then
|
||||
return {name = ctrs[max_idx][3], amount = richness}
|
||||
end
|
||||
end
|
||||
|
@@ -1,92 +1,49 @@
|
||||
require "map_gen.shared.perlin_noise"
|
||||
local Event = require "utils.event"
|
||||
|
||||
local random_ores = {"iron-ore","coal","copper-ore","stone","uranium-ore"}
|
||||
local random_dense = {1.15,0.8,1,0.9, 0.5} --ore density reference
|
||||
local random_ores = {"iron-ore", "coal", "copper-ore", "stone", "uranium-ore"}
|
||||
local random_dense = {1.15, 0.8, 1, 0.9, 0.5} --ore density reference
|
||||
|
||||
function run_ores_module_setup()
|
||||
if not global.ores_seed_A then global.ores_seed_A = math.random(10,10000) end
|
||||
if not global.ores_seed_B then global.ores_seed_B = math.random(10,10000) end
|
||||
local function run_ores_module_setup()
|
||||
if not global.ores_seed_A then
|
||||
global.ores_seed_A = math.random(10, 10000)
|
||||
end
|
||||
if not global.ores_seed_B then
|
||||
global.ores_seed_B = math.random(10, 10000)
|
||||
end
|
||||
end
|
||||
|
||||
--generate ores for entire chunk
|
||||
function run_ores_module(event)
|
||||
--game.print("gen crazy ores")
|
||||
run_ores_module_setup()
|
||||
--if not global.ores_seed_A then global.ores_seed_A = math.random(10,10000) end
|
||||
--if not global.ores_seed_B then global.ores_seed_B = math.random(10,10000) end
|
||||
Event.on_init(run_ores_module_setup)
|
||||
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
return function(x, y, world)
|
||||
local pos = {world.x + 0.5, world.y + 0.5}
|
||||
|
||||
local entities = world.surface.find_entities_filtered {position = pos, type = "resource"}
|
||||
for _, e in ipairs(entities) do
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
local entities = surface.find_entities(area)
|
||||
for _, entity in pairs(entities) do
|
||||
if entity.type == "resource" then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
local distance_bonus = 200 + math.sqrt(world.x * world.x + world.y * world.y) * 0.2
|
||||
|
||||
local top_left = area.left_top --make a more direct reference
|
||||
local wiggle = 100 + perlin:noise((x * 0.005), (y * 0.005), global.ores_seed_A + 41) * 60
|
||||
local Ores_A = perlin:noise((x * 0.01), (y * 0.01), global.ores_seed_B + 57) * wiggle
|
||||
|
||||
local distance_bonus = 200 + math.sqrt(top_left.x*top_left.x + top_left.y*top_left.y) * 0.2
|
||||
|
||||
for x = top_left.x, top_left.x + 31 do
|
||||
for y = top_left.y, top_left.y + 31 do
|
||||
--table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
|
||||
local wiggle = 100 + perlin:noise((x*0.005),(y*0.005),global.ores_seed_A + 41) * 60
|
||||
local Ores_A = perlin:noise((x*0.01),(y*0.01),global.ores_seed_B + 57) * wiggle
|
||||
|
||||
|
||||
if Ores_A > 35 then --we place ores
|
||||
local Ores_B = perlin:noise((x*0.02),(y*0.02),global.ores_seed_B + 13) * wiggle
|
||||
local a = 5
|
||||
--
|
||||
if Ores_A < 76 then a = math.floor(Ores_A*0.75 + Ores_B*0.5) % 4 + 1 end --if its not super high we place normal ores
|
||||
--
|
||||
local res_amount = distance_bonus
|
||||
res_amount = math.floor(res_amount * random_dense[a])
|
||||
--
|
||||
if surface.can_place_entity {name=random_ores[a], position={x,y}} then
|
||||
surface.create_entity {name=random_ores[a], position={x,y}, amount=res_amount}
|
||||
end
|
||||
elseif Ores_A < -60 then
|
||||
if math.random(1,200) == 1 and surface.can_place_entity {name="crude-oil", position={x,y}} then
|
||||
surface.create_entity {name="crude-oil", position={x,y}, amount = math.random(5000,20000) +math.floor(distance_bonus)* 1500 }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--used when terrain modual passes to it, can save extra calculations
|
||||
function run_ores_module_tile(surface,x,y)
|
||||
|
||||
distance_bonus = 200 + math.sqrt(x*x + y*y) * 0.2
|
||||
|
||||
local wiggle = 100 + perlin:noise((x*0.005),(y*0.005),global.ores_seed_A + 41) * 60
|
||||
local Ores_A = perlin:noise((x*0.01),(y*0.01),global.ores_seed_B + 57) * wiggle
|
||||
|
||||
if Ores_A > 35 then --we place ores
|
||||
local Ores_B = perlin:noise((x*0.02),(y*0.02),global.ores_seed_B + 13) * wiggle
|
||||
if Ores_A > 35 then --we place ores
|
||||
local Ores_B = perlin:noise((x * 0.02), (y * 0.02), global.ores_seed_B + 13) * wiggle
|
||||
local a = 5
|
||||
--
|
||||
if Ores_A < 76 then a = math.floor(Ores_A*0.75 + Ores_B*0.5) % 4 + 1 end --if its not super high we place normal ores
|
||||
--
|
||||
--
|
||||
if Ores_A < 76 then
|
||||
a = math.floor(Ores_A * 0.75 + Ores_B * 0.5) % 4 + 1
|
||||
end --if its not super high we place normal ores
|
||||
--
|
||||
local res_amount = distance_bonus
|
||||
res_amount = math.floor(res_amount * random_dense[a])
|
||||
--
|
||||
--if surface.can_place_entity {name=random_ores[a], position={x,y}} then
|
||||
--We assume it can be places because terrain gen told us to.
|
||||
surface.create_entity {name=random_ores[a], position={x,y}, amount=res_amount}
|
||||
--end
|
||||
--
|
||||
|
||||
return {name = random_ores[a], amount = res_amount}
|
||||
elseif Ores_A < -60 then
|
||||
if math.random(1,200) == 1 then
|
||||
surface.create_entity {name="crude-oil", position={x,y}, amount = math.random(5000,20000) +math.floor(distance_bonus)* 1500 }
|
||||
if math.random(1, 200) == 1 then
|
||||
return {name = "crude-oil", amount = math.random(5000, 20000) + math.floor(distance_bonus) * 1500}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@@ -7,29 +7,12 @@ local donut_width = 128
|
||||
--dont touch these
|
||||
local donut_half = donut_width * 0.5
|
||||
local x_offset = donut_radius - donut_half
|
||||
local donut_low = x_offset^2
|
||||
local donut_high = (x_offset+donut_width)^2
|
||||
local donut_low = x_offset ^ 2
|
||||
local donut_high = (x_offset + donut_width) ^ 2
|
||||
|
||||
return function(x, y, world)
|
||||
local x_off = x - donut_radius
|
||||
local distance = x_off ^ 2 + y ^ 2 -- we dont bother to get sqr of it, because we just want the cubed answer to compare to donut_low/high
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
local top_left = area.left_top --make a more direct reference
|
||||
|
||||
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
|
||||
local x_off = x - donut_radius
|
||||
local distance = x_off^2 + y^2 -- we dont bother to get sqr of it, because we just want the cubed answer to compare to donut_low/high
|
||||
if distance > donut_high or distance < donut_low then
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
return true
|
||||
return not (distance > donut_high or distance < donut_low)
|
||||
end
|
||||
|
@@ -7,28 +7,13 @@ local tiles_intersect = 384
|
||||
---dont edit these
|
||||
local tiles_half = tiles_wide * 0.5
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
return function(x, y)
|
||||
local offset_1 = x + y + tiles_half
|
||||
local offset_2 = x - y + tiles_half
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
|
||||
local offset_1 = x + y + tiles_half
|
||||
local offset_2 = x - y + tiles_half
|
||||
|
||||
if offset_1 % tiles_intersect > tiles_wide then
|
||||
if offset_2 % tiles_intersect > tiles_wide then
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
if offset_1 % tiles_intersect > tiles_wide then
|
||||
return offset_2 % tiles_intersect <= tiles_wide
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@@ -1,20 +1,3 @@
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
if top_left.x > 100 or top_left.y > 200 or top_left.y < -200 then
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
return function(x, y, world)
|
||||
return not (x > 100 or y > 200 or y < -200)
|
||||
end
|
||||
|
@@ -4,35 +4,18 @@ local grid_width = 40
|
||||
local grid_height = 40
|
||||
local grid_scale = 32 -- 4/8/16/32 are good values here
|
||||
|
||||
-- local starting_grid = require "pacman_grids.classic"
|
||||
local starting_grid = require "pacman_grids.rotated_rectangles"
|
||||
local starting_grid = require "pacman_grids.classic"
|
||||
--local starting_grid = require "pacman_grids.rotated_rectangles"
|
||||
|
||||
local image_grid = starting_grid.image_grid
|
||||
local mult = 1 / grid_scale
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
return function(x, y)
|
||||
x = x * mult - 20
|
||||
y = y * mult - 21
|
||||
x = math.floor(x) % grid_width + 1
|
||||
y = math.floor(y) % grid_height + 1
|
||||
|
||||
local top_left_x = area.left_top.x --make a more direct reference
|
||||
local top_left_y = area.left_top.y --make a more direct reference
|
||||
-- chunk_region = top_left_x / grid_scale
|
||||
|
||||
for x = top_left_x, top_left_x + 32, grid_scale do
|
||||
image_grid_position_x = ( ( x / grid_scale ) + 20 ) % grid_width + 1
|
||||
for y = top_left_y, top_left_y + 32, grid_scale do
|
||||
image_grid_position_y = ( ( y / grid_scale ) + 19 ) % grid_height + 1
|
||||
if image_grid[image_grid_position_y][image_grid_position_x] ~= nil then
|
||||
if image_grid[image_grid_position_y][image_grid_position_x] == 0 then
|
||||
for x_1 = x, x + grid_scale do
|
||||
for y_1 = y, y + grid_scale do
|
||||
table.insert(tiles, {name = "out-of-map", position = {x_1,y_1}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles)
|
||||
return true
|
||||
local pixel = image_grid[y][x]
|
||||
return pixel == 1
|
||||
end
|
||||
|
@@ -2,44 +2,36 @@ require "map_gen.shared.compass"
|
||||
require "map_gen.shared.chunk_utils"
|
||||
|
||||
local compass = Compass.new()
|
||||
local pixels={}
|
||||
local pixels = {}
|
||||
pixels["-1,-1"] = true
|
||||
width = 4
|
||||
local width = 4
|
||||
|
||||
function build()
|
||||
local p = {-1,-1}
|
||||
local function add(p)
|
||||
pixels[p[1] .. "," .. p[2]] = true
|
||||
end
|
||||
|
||||
local function build()
|
||||
local p = {-1, -1}
|
||||
local n = 1
|
||||
for x=1,300 do
|
||||
for x = 1, 300 do
|
||||
for i = 1, n do
|
||||
p[1] = p[1] + compass:get_direction()["x"]
|
||||
p[2] = p[2] + compass:get_direction()["y"]
|
||||
add(p)
|
||||
p[1] = p[1] + compass:get_direction()["x"]
|
||||
p[2] = p[2] + compass:get_direction()["y"]
|
||||
add(p)
|
||||
end
|
||||
compass:turn_left()
|
||||
n = n + 1
|
||||
end
|
||||
end
|
||||
|
||||
local function onshape(p)
|
||||
x = math.floor(p[1]/32/width)
|
||||
y = math.floor(p[2]/32/width)
|
||||
|
||||
|
||||
if pixels[x .. "," .. y] ~= nil then
|
||||
end
|
||||
return pixels[x .. "," .. y] ~= nil
|
||||
end
|
||||
|
||||
function add(p)
|
||||
pixels[p[1].. "," .. p[2]] = true
|
||||
end
|
||||
|
||||
|
||||
build()
|
||||
|
||||
function run_shape_module(event)
|
||||
if not onshape({event.area.left_top.x - width/2 * 32,event.area.left_top.y - width/2 * 32}) then
|
||||
removeChunk(event)
|
||||
return false
|
||||
end
|
||||
local offset = width * 0.5 * 32
|
||||
local mult = 1 / (width * 32)
|
||||
|
||||
return function(x, y)
|
||||
x = math.floor((x - offset) * mult)
|
||||
y = math.floor((y - offset) * mult)
|
||||
|
||||
return pixels[x .. "," .. y] ~= nil
|
||||
end
|
||||
|
@@ -1,20 +1,3 @@
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
if top_left.x < -150 or top_left.y > 32 or top_left.y < -568 then
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
return function(x, y, world)
|
||||
return not (x < -150 or y > 32 or y < -568)
|
||||
end
|
||||
|
@@ -1,33 +1,16 @@
|
||||
return function(x, y, world)
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
if distance > 128 then
|
||||
local angle = 180 + math.deg(math.atan2(x, y))
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
--if top_left.y > 80 or top_left.x > 180 or top_left.x < -180 then
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
|
||||
local distance = math.sqrt(x*x + y*y)
|
||||
if distance > 128 then
|
||||
local angle = 180 + math.deg(math.atan2(x,y))
|
||||
|
||||
local offset = distance
|
||||
if angle ~= 0 then offset = offset + angle /3.75 end
|
||||
--if angle ~= 0 then offset = offset + angle /1.33333333 end
|
||||
|
||||
if offset % 96 < 48 then
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
local offset = distance
|
||||
if angle ~= 0 then
|
||||
offset = offset + angle / 3.75
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
--if angle ~= 0 then offset = offset + angle /1.33333333 end
|
||||
|
||||
--return false
|
||||
--end
|
||||
return offset % 96 >= 48
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
@@ -1,39 +1,20 @@
|
||||
return function(x, y, world)
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
if distance > 128 then
|
||||
local angle = 180 + math.deg(math.atan2(x, y))
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
--if top_left.y > 80 or top_left.x > 180 or top_left.x < -180 then
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
|
||||
local distance = math.sqrt(x*x + y*y)
|
||||
if distance > 128 then
|
||||
local angle = 180 + math.deg(math.atan2(x,y))
|
||||
|
||||
local offset = distance
|
||||
local offset2 = distance
|
||||
if angle ~= 0 then
|
||||
offset2 = offset - angle /3.75
|
||||
offset = offset + angle /3.75
|
||||
end
|
||||
--if angle ~= 0 then offset = offset + angle /1.33333333 end
|
||||
|
||||
if (offset) % 96 < 64 then
|
||||
if (offset2) % 96 < 64 then
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local offset = distance
|
||||
local offset2 = distance
|
||||
if angle ~= 0 then
|
||||
offset2 = offset - angle / 3.75
|
||||
offset = offset + angle / 3.75
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
--if angle ~= 0 then offset = offset + angle /1.33333333 end
|
||||
|
||||
--return false
|
||||
--end
|
||||
if offset % 96 < 64 then
|
||||
return offset2 % 96 >= 64
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
@@ -1,38 +1,23 @@
|
||||
return function(x, y, world)
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
if distance > 128 then
|
||||
local angle = (180 + math.deg(math.atan2(x, y))) * 3
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
--if top_left.y > 80 or top_left.x > 180 or top_left.x < -180 then
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
|
||||
local distance = math.sqrt(x*x + y*y)
|
||||
if distance > 128 then
|
||||
local angle = (180 + math.deg(math.atan2(x,y)))*3
|
||||
|
||||
local offset = distance * 0.75
|
||||
if angle ~= 0 then offset = offset + angle /3.75 end
|
||||
--if angle ~= 0 then offset = offset + angle /1.33333333 end
|
||||
|
||||
if offset % 96 < 48 then
|
||||
local offset2 = distance * 0.125
|
||||
if angle ~= 0 then offset2 = offset2 - angle /3.75 end
|
||||
|
||||
if offset2 % 96 < 80 then
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local offset = distance * 0.75
|
||||
if angle ~= 0 then
|
||||
offset = offset + angle / 3.75
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
--if angle ~= 0 then offset = offset + angle /1.33333333 end
|
||||
|
||||
--return false
|
||||
--end
|
||||
if offset % 96 < 48 then
|
||||
local offset2 = distance * 0.125
|
||||
if angle ~= 0 then
|
||||
offset2 = offset2 - angle / 3.75
|
||||
end
|
||||
|
||||
return offset2 % 96 >= 80
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
@@ -3,26 +3,19 @@
|
||||
local arm_width = 96
|
||||
|
||||
local function is_on_spiral(x, y, distance, angle_offset)
|
||||
local angle = angle_offset + math.deg(math.atan2(x,y))
|
||||
local angle = angle_offset + math.deg(math.atan2(x, y))
|
||||
|
||||
local offset = distance
|
||||
if angle ~= 0 then offset = offset + angle / 3.75 * 2 end
|
||||
if angle ~= 0 then
|
||||
offset = offset + angle / 3.75 * 2
|
||||
end
|
||||
return offset % 96 * 2 >= 48 * 2
|
||||
end
|
||||
|
||||
function run_shape_module(event)
|
||||
local tiles = {}
|
||||
local left_top = event.area.left_top
|
||||
for x = left_top.x-1, left_top.x + 32 do
|
||||
for y = left_top.y-1, left_top.y + 32 do
|
||||
local pseudo_x = x / (arm_width / 48)
|
||||
local pseudo_y = y / (arm_width / 48)
|
||||
local distance = math.sqrt(pseudo_x * pseudo_x + pseudo_y * pseudo_y)
|
||||
if distance > 100 and not is_on_spiral(x,y, distance, 0) then
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
event.surface.set_tiles(tiles)
|
||||
return true
|
||||
return function(x, y, world)
|
||||
local pseudo_x = x / (arm_width / 48)
|
||||
local pseudo_y = y / (arm_width / 48)
|
||||
local distance = math.sqrt(pseudo_x * pseudo_x + pseudo_y * pseudo_y)
|
||||
|
||||
return not (distance > 100 and not is_on_spiral(x, y, distance, 0))
|
||||
end
|
||||
|
@@ -1,20 +1,3 @@
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
if top_left.y > 80 or top_left.x > 180 or top_left.x < -180 then
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
return function(x, y, world)
|
||||
return not (x > 180 or x < -180 or y > 80)
|
||||
end
|
||||
|
@@ -6,24 +6,9 @@ local tiles_wide = 172
|
||||
---dont edit these
|
||||
local tiles_half = tiles_wide * 0.5
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
return function(x, y)
|
||||
local abs_x = math.abs(x)
|
||||
local abs_y = math.abs(y)
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
for x = top_left.x-1, top_left.x + 32 do
|
||||
for y = top_left.y-1, top_left.y + 32 do
|
||||
|
||||
local abs_x = math.abs(x)
|
||||
local abs_y = math.abs(y)
|
||||
if abs_x < abs_y - tiles_half or abs_x > abs_y + tiles_half then
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
return true
|
||||
end
|
||||
return not (abs_x < abs_y - tiles_half or abs_x > abs_y + tiles_half)
|
||||
end
|
||||
|
@@ -39,9 +39,8 @@ local function player_died()
|
||||
end
|
||||
Event.add(defines.events.on_player_died, player_died)
|
||||
|
||||
return function(x, y, world)
|
||||
local x, y = world.x, world.y
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
return function(x, y, world)
|
||||
local distance = math.sqrt(world.x * world.x + world.y * world.y)
|
||||
|
||||
if distance <= 100 then
|
||||
return nil
|
||||
@@ -50,6 +49,6 @@ return function(x, y, world)
|
||||
local magic_number = math.floor(mines_factor / distance) + 1
|
||||
|
||||
if math.random(1, magic_number) == 1 then
|
||||
return {name = "land-mine", position = {x, y}, force = "enemy"}
|
||||
return {name = "land-mine", force = "enemy"}
|
||||
end
|
||||
end
|
||||
|
@@ -10,8 +10,7 @@ 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)
|
||||
local distance = math.sqrt(world.x * world.x + world.y * world.y)
|
||||
|
||||
if distance > small_worm_spawn_distance - 32 then
|
||||
local lvl = 1
|
||||
@@ -23,7 +22,7 @@ return function(x, y, world)
|
||||
end
|
||||
if math.random() < chance then
|
||||
local worm_id = math.random(1, lvl)
|
||||
return {name = worm_names[worm_id], position = {x, y}}
|
||||
return {name = worm_names[worm_id]}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -61,45 +61,48 @@ local shape = nil
|
||||
--shape = require "map_gen.presets.test"
|
||||
|
||||
--shapes--
|
||||
--require "map_gen.shape.left"
|
||||
--require "map_gen.shape.right"
|
||||
--require "map_gen.shape.up"
|
||||
--shape = require "map_gen.shape.left"
|
||||
--shape = require "map_gen.shape.right"
|
||||
--shape = require "map_gen.shape.up"
|
||||
--require "map_gen.shape.maze"
|
||||
--require "map_gen.shape.spiral"
|
||||
--require "map_gen.shape.threaded_spirals"
|
||||
--require "map_gen.shape.spiral_tri"
|
||||
--require "map_gen.shape.spiral2"
|
||||
--require "map_gen.shape.donut"
|
||||
--require "map_gen.shape.rectangular_spiral"
|
||||
--require "map_gen.shape.lattice"
|
||||
--shape = require "map_gen.shape.spiral"
|
||||
--shape = require "map_gen.shape.threaded_spirals"
|
||||
--shape = require "map_gen.shape.spiral_tri"
|
||||
--shape = require "map_gen.shape.spiral2"
|
||||
--shape = require "map_gen.shape.donut"
|
||||
--shape = require "map_gen.shape.rectangular_spiral"
|
||||
--shape = require "map_gen.shape.lattice"
|
||||
--require "map_gen.shape.infinite_mazes"
|
||||
--require "map_gen.shape.x_shape"
|
||||
--require "map_gen.shape.pacman"
|
||||
--shape = require "map_gen.shape.x_shape"
|
||||
--shape = require "map_gen.shape.pacman"
|
||||
|
||||
--terrain--
|
||||
--require "map_gen.terrain.neko_bridged_rivers"
|
||||
--require "map_gen.terrain.neko_river_overlay"
|
||||
|
||||
|
||||
--ores--
|
||||
--require "map_gen.ores.neko_crazy_ores"
|
||||
--require "map_gen.ores.fluffy_rainbows"
|
||||
--require "map_gen.ores.rso.rso_control"
|
||||
--require "map_gen.ores.harmonic_gen"
|
||||
|
||||
|
||||
-- modules that only return max one entity per tile
|
||||
local entity_modules = {
|
||||
--require "map_gen.ores.glitter_ores",
|
||||
--require "map_gen.terrain.mines",
|
||||
--require "map_gen.terrain.worms",
|
||||
--require "map_gen.misc.wreck_items",
|
||||
--require "map_gen.ores.neko_crazy_ores",
|
||||
--require "map_gen.ores.fluffy_rainbows",
|
||||
--require "map_gen.ores.harmonic_gen",
|
||||
}
|
||||
|
||||
local terrain_modules ={
|
||||
--require "map_gen.misc.tris_chunk_grid",
|
||||
}
|
||||
|
||||
--everything else. You may use more than one of these, but beware they might not be compatible
|
||||
miscs = {}
|
||||
--require "map_gen.misc.rusky_pvp"
|
||||
--table.insert(miscs, require("map_gen.misc.rail_grid")) -- used for map_gen.presets.UK
|
||||
--table.insert(miscs, require("map_gen.misc.wreck_items"))
|
||||
--table.insert(miscs, require("map_gen.misc.tris_chunk_grid"))
|
||||
|
||||
if #entity_modules > 0 then
|
||||
shape = shape or b.full_shape
|
||||
@@ -107,6 +110,14 @@ if #entity_modules > 0 then
|
||||
shape = b.apply_entities(shape, entity_modules)
|
||||
end
|
||||
|
||||
if #terrain_modules > 0 then
|
||||
shape = shape or b.full_shape
|
||||
|
||||
for _, m in ipairs(terrain_modules) do
|
||||
shape = b.overlay_tile_land(shape, m)
|
||||
end
|
||||
end
|
||||
|
||||
if shape then
|
||||
--local gen = require "map_gen.shared.generate"
|
||||
local gen = require "map_gen.shared.generate_not_threaded"
|
||||
|
Reference in New Issue
Block a user