2019-10-13 15:52:03 +02:00
|
|
|
-- Snakey Swamp by Soggs
|
|
|
|
local b = require 'map_gen.shared.builders'
|
|
|
|
local RS = require 'map_gen.shared.redmew_surface'
|
|
|
|
local MGSP = require 'resources.map_gen_settings'
|
|
|
|
local ceil = math.ceil
|
|
|
|
local min = math.min
|
|
|
|
|
|
|
|
-- Disable Landfill by default
|
|
|
|
local Event = require 'utils.event'
|
2019-10-14 09:59:18 +02:00
|
|
|
|
|
|
|
Event.on_init(
|
2019-10-13 15:52:03 +02:00
|
|
|
function()
|
2019-10-14 09:59:18 +02:00
|
|
|
game.forces.player.technologies['landfill'].enabled = false
|
2019-10-13 15:52:03 +02:00
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
local path_width = 30
|
|
|
|
local path_height = 200
|
|
|
|
local divider_width = 10
|
|
|
|
local water_height = 40 -- setting it to 0 eliminates the water border
|
|
|
|
|
|
|
|
local height_setting = {
|
2019-10-14 09:59:18 +02:00
|
|
|
height = path_height + water_height * 2
|
2019-10-13 15:52:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RS.set_map_gen_settings(
|
|
|
|
{
|
2019-10-14 09:59:18 +02:00
|
|
|
MGSP.water_none,
|
2019-10-13 15:52:03 +02:00
|
|
|
height_setting
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Snakey path
|
2019-10-14 09:59:18 +02:00
|
|
|
local tile_width = path_width * 2 + divider_width * 2
|
2019-10-13 15:52:03 +02:00
|
|
|
|
|
|
|
local divider = b.rectangle(divider_width, path_height - path_width)
|
2019-10-14 09:59:18 +02:00
|
|
|
local path =
|
|
|
|
b.any {
|
|
|
|
b.translate(divider, (path_width + divider_width) / 2, path_width / 2),
|
|
|
|
b.translate(divider, -(path_width + divider_width) / 2, -path_width / 2)
|
|
|
|
}
|
2019-10-20 05:24:35 +02:00
|
|
|
path = b.change_tile(path, true, 'water-mud')
|
2019-10-21 12:21:54 +02:00
|
|
|
path = b.remove_map_gen_decoratives(path)
|
2019-10-13 15:52:03 +02:00
|
|
|
|
|
|
|
-- Water Border
|
|
|
|
local water_rectangle = b.rectangle(tile_width, water_height)
|
2019-10-14 09:59:18 +02:00
|
|
|
local water_way =
|
|
|
|
b.any {
|
|
|
|
b.translate(water_rectangle, 0, (path_height + water_height) / 2),
|
|
|
|
b.translate(water_rectangle, 0, -(path_height + water_height) / 2)
|
|
|
|
}
|
2019-10-13 15:52:03 +02:00
|
|
|
water_way = b.change_tile(water_way, true, 'water')
|
|
|
|
|
|
|
|
local tile = b.any {path, water_way}
|
|
|
|
local grid = b.single_x_pattern(tile, tile_width)
|
|
|
|
local map = b.if_else(grid, b.full_shape)
|
|
|
|
|
2019-10-14 09:59:18 +02:00
|
|
|
-- Starting resources
|
2019-10-13 15:52:03 +02:00
|
|
|
local quarter_height = path_height / 4
|
|
|
|
local max_height = 50
|
|
|
|
local max_width = 50
|
2019-10-14 09:59:18 +02:00
|
|
|
local ore_rectangle = b.rectangle(min(path_width - 2, max_height), min(quarter_height - 2, max_width) - 10) -- -10 to allow space for market and other buildings
|
|
|
|
local ore_spacing = min(quarter_height, max_height + 2)
|
2019-10-13 15:52:03 +02:00
|
|
|
local function amount(a)
|
2019-10-14 09:59:18 +02:00
|
|
|
return function(_, _)
|
|
|
|
return ceil(a / min(path_width - 2, max_height) / min(quarter_height - 2, max_width))
|
2019-10-13 15:52:03 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-14 09:59:18 +02:00
|
|
|
-- Removes map gen resources from the first path
|
|
|
|
local starting_zone = b.rectangle(path_width, path_height)
|
|
|
|
starting_zone = b.remove_map_gen_resources(starting_zone)
|
|
|
|
|
|
|
|
map = b.add(starting_zone, map)
|
2019-10-13 15:52:03 +02:00
|
|
|
|
|
|
|
-- Spawn in starting ressources
|
|
|
|
|
|
|
|
local iron = b.translate(ore_rectangle, 0, ore_spacing * 0.5)
|
2019-10-14 09:59:18 +02:00
|
|
|
iron = b.resource(iron, 'iron-ore', amount(750000))
|
2019-10-13 15:52:03 +02:00
|
|
|
local copper = b.translate(ore_rectangle, 0, -ore_spacing * 0.5)
|
2019-10-14 09:59:18 +02:00
|
|
|
copper = b.resource(copper, 'copper-ore', amount(500000))
|
2019-10-13 15:52:03 +02:00
|
|
|
local stone = b.translate(ore_rectangle, 0, ore_spacing * 1.5)
|
2019-10-14 09:59:18 +02:00
|
|
|
stone = b.resource(stone, 'stone', amount(250000))
|
2019-10-13 15:52:03 +02:00
|
|
|
local coal = b.translate(ore_rectangle, 0, -ore_spacing * 1.5)
|
2019-10-14 09:59:18 +02:00
|
|
|
coal = b.resource(coal, 'coal', amount(350000))
|
2019-10-13 15:52:03 +02:00
|
|
|
|
|
|
|
map = b.apply_entities(map, {iron, copper, stone, coal})
|
|
|
|
|
2019-10-13 18:11:06 +02:00
|
|
|
return b.fish(map, 0.0025)
|