2019-01-26 20:43:02 +02:00
|
|
|
-- Original author: MewMew
|
2018-05-23 23:34:19 +02:00
|
|
|
local perlin = require 'map_gen.shared.perlin_noise'
|
2018-06-18 21:35:01 +02:00
|
|
|
local b = require 'map_gen.shared.builders'
|
2019-01-16 22:33:32 +02:00
|
|
|
local RS = require 'map_gen.shared.redmew_surface'
|
|
|
|
local MGSP = require 'resources.map_gen_settings' -- map gen settings presets
|
2017-08-04 23:31:52 +02:00
|
|
|
|
2019-01-26 20:43:02 +02:00
|
|
|
local random = math.random
|
|
|
|
local max = math.max
|
|
|
|
local abs = math.abs
|
|
|
|
local noise = perlin.noise
|
|
|
|
|
2017-08-04 23:31:52 +02:00
|
|
|
local radius = 129
|
2018-05-23 23:34:19 +02:00
|
|
|
local radsquare = radius * radius
|
|
|
|
|
2018-06-18 21:35:01 +02:00
|
|
|
local start_seed = 1234567
|
|
|
|
|
2019-01-16 22:33:32 +02:00
|
|
|
RS.set_map_gen_settings(
|
|
|
|
{
|
|
|
|
MGSP.tree_none,
|
|
|
|
MGSP.ore_oil_none,
|
|
|
|
MGSP.enemy_very_high,
|
|
|
|
MGSP.cliff_none,
|
2019-02-27 22:10:39 +02:00
|
|
|
MGSP.grass_only,
|
|
|
|
MGSP.enable_water
|
2019-01-16 22:33:32 +02:00
|
|
|
}
|
|
|
|
)
|
2018-05-24 15:29:40 +02:00
|
|
|
|
2019-01-16 22:33:32 +02:00
|
|
|
local function map(x, y, world)
|
2018-05-23 23:34:19 +02:00
|
|
|
local entities = {}
|
2018-05-24 00:04:28 +02:00
|
|
|
local decoratives = {}
|
2018-05-23 23:34:19 +02:00
|
|
|
|
2018-06-18 21:35:01 +02:00
|
|
|
local seed = start_seed
|
2018-05-23 23:34:19 +02:00
|
|
|
local seed_increment = 10000
|
|
|
|
|
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_starting_1 = noise(((x + seed) / 30), ((y + seed) / 30), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_starting_2 = noise(((x + seed) / 10), ((y + seed) / 10), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
|
|
|
local noise_island_starting = noise_island_starting_1 + (noise_island_starting_2 * 0.3)
|
|
|
|
noise_island_starting = noise_island_starting * 8000
|
|
|
|
|
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_iron_and_copper_1 = noise(((x + seed) / 300), ((y + seed) / 300), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_iron_and_copper_2 = noise(((x + seed) / 40), ((y + seed) / 40), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_iron_and_copper_3 = noise(((x + seed) / 10), ((y + seed) / 10), 0)
|
2019-01-16 22:33:32 +02:00
|
|
|
local noise_island_iron_and_copper = noise_island_iron_and_copper_1 + (noise_island_iron_and_copper_2 * 0.1) + (noise_island_iron_and_copper_3 * 0.05)
|
2018-05-23 23:34:19 +02:00
|
|
|
|
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_stone_and_coal_1 = noise(((x + seed) / 300), ((y + seed) / 300), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_stone_and_coal_2 = noise(((x + seed) / 40), ((y + seed) / 40), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_stone_and_coal_3 = noise(((x + seed) / 10), ((y + seed) / 10), 0)
|
2019-01-16 22:33:32 +02:00
|
|
|
local noise_island_stone_and_coal = noise_island_stone_and_coal_1 + (noise_island_stone_and_coal_2 * 0.1) + (noise_island_stone_and_coal_3 * 0.05)
|
2018-05-23 23:34:19 +02:00
|
|
|
|
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_oil_and_uranium_1 = noise(((x + seed) / 300), ((y + seed) / 300), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_oil_and_uranium_2 = noise(((x + seed) / 40), ((y + seed) / 40), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_oil_and_uranium_3 = noise(((x + seed) / 10), ((y + seed) / 10), 0)
|
2019-01-16 22:33:32 +02:00
|
|
|
local noise_island_oil_and_uranium = noise_island_oil_and_uranium_1 + (noise_island_oil_and_uranium_2 * 0.1) + (noise_island_oil_and_uranium_3 * 0.05)
|
2018-05-23 23:34:19 +02:00
|
|
|
|
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_resource = noise(((x + seed) / 60), ((y + seed) / 60), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_island_resource_2 = noise(((x + seed) / 10), ((y + seed) / 10), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
noise_island_resource = noise_island_resource + noise_island_resource_2 * 0.15
|
|
|
|
|
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_trees_1 = noise(((x + seed) / 30), ((y + seed) / 30), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_trees_2 = noise(((x + seed) / 10), ((y + seed) / 10), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
local noise_trees = noise_trees_1 + noise_trees_2 * 0.5
|
|
|
|
|
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_decoratives_1 = noise(((x + seed) / 50), ((y + seed) / 50), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
seed = seed + seed_increment
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_decoratives_2 = noise(((x + seed) / 10), ((y + seed) / 10), 0)
|
2018-05-23 23:34:19 +02:00
|
|
|
local noise_decoratives = noise_decoratives_1 + noise_decoratives_2 * 0.5
|
|
|
|
|
|
|
|
local tile_to_insert = 'water'
|
|
|
|
|
|
|
|
--Create starting Island
|
2019-01-16 22:33:32 +02:00
|
|
|
local dist_1 = y * y
|
|
|
|
local dist_2 = x * x
|
|
|
|
local tile_distance_to_center = dist_1 + dist_2
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_distance_to_center + noise_island_starting <= radsquare then
|
|
|
|
tile_to_insert = 'grass-1'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_distance_to_center + noise_island_starting > radsquare + 20000 then
|
2017-08-04 23:31:52 +02:00
|
|
|
--Placement of Island Tiles
|
|
|
|
|
|
|
|
if noise_island_oil_and_uranium > 0.53 then
|
2018-05-23 23:34:19 +02:00
|
|
|
tile_to_insert = 'red-desert-1'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
if noise_island_oil_and_uranium < -0.53 then
|
2018-05-23 23:34:19 +02:00
|
|
|
tile_to_insert = 'red-desert-0'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if noise_island_stone_and_coal > 0.47 then
|
2018-05-23 23:34:19 +02:00
|
|
|
tile_to_insert = 'grass-3'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
if noise_island_stone_and_coal < -0.47 then
|
2018-05-23 23:34:19 +02:00
|
|
|
tile_to_insert = 'grass-2'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if noise_island_iron_and_copper > 0.47 then
|
2018-05-23 23:34:19 +02:00
|
|
|
tile_to_insert = 'sand-1'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
if noise_island_iron_and_copper < -0.47 then
|
2018-05-23 23:34:19 +02:00
|
|
|
tile_to_insert = 'sand-3'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
end
|
2017-08-04 23:31:52 +02:00
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
--Placement of Trees
|
|
|
|
if tile_to_insert ~= 'water' then
|
2017-08-04 23:31:52 +02:00
|
|
|
if noise_trees > 0.1 then
|
2018-05-23 23:34:19 +02:00
|
|
|
local tree = 'tree-01'
|
|
|
|
if tile_to_insert == 'grass-1' then
|
|
|
|
tree = 'tree-05'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'grass-2' then
|
|
|
|
tree = 'tree-02'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'grass-3' then
|
|
|
|
tree = 'tree-04'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'sand-1' then
|
|
|
|
tree = 'tree-07'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'sand-3' then
|
|
|
|
tree = 'dry-hairy-tree'
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_to_insert == 'red-desert-1' then
|
|
|
|
tree = 'dry-tree'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'red-desert-0' then
|
2019-01-26 20:43:02 +02:00
|
|
|
if random(1, 3) == 1 then
|
2018-05-23 23:34:19 +02:00
|
|
|
tree = 'sand-rock-big'
|
|
|
|
else
|
|
|
|
tree = 'sand-rock-big'
|
|
|
|
end
|
|
|
|
end
|
2019-01-26 20:43:02 +02:00
|
|
|
if random(1, 8) == 1 then
|
|
|
|
entities[#entities + 1] = {name = tree}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
end
|
2017-08-04 23:31:52 +02:00
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_to_insert == 'sand-1' or tile_to_insert == 'sand-3' then
|
2019-01-26 20:43:02 +02:00
|
|
|
if random(1, 200) == 1 then
|
|
|
|
entities[#entities + 1] = {name = 'rock-big'}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
end
|
|
|
|
if tile_to_insert == 'grass-1' or tile_to_insert == 'grass-2' or tile_to_insert == 'grass-3' then
|
2019-01-26 20:43:02 +02:00
|
|
|
if random(1, 2000) == 1 then
|
|
|
|
entities[#entities + 1] = {name = 'rock-big'}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
end
|
2017-08-04 23:31:52 +02:00
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
--Placement of Decoratives
|
2018-05-24 00:04:28 +02:00
|
|
|
if tile_to_insert ~= 'water' then
|
2017-08-04 23:31:52 +02:00
|
|
|
if noise_decoratives > 0.3 then
|
2018-05-23 23:34:19 +02:00
|
|
|
local decorative = 'green-carpet-grass-1'
|
|
|
|
if tile_to_insert == 'grass-1' then
|
|
|
|
decorative = 'green-pita'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'grass-2' then
|
|
|
|
decorative = 'green-pita'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'grass-3' then
|
|
|
|
decorative = 'green-pita'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'sand-1' then
|
|
|
|
decorative = 'green-asterisk'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'sand-3' then
|
|
|
|
decorative = 'green-asterisk'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'red-desert-1' then
|
|
|
|
decorative = 'red-asterisk'
|
|
|
|
end
|
|
|
|
if tile_to_insert == 'red-desert-0' then
|
|
|
|
decorative = 'red-asterisk'
|
|
|
|
end
|
2019-01-26 20:43:02 +02:00
|
|
|
if random(1, 5) == 1 then
|
|
|
|
decoratives[#decoratives + 1] = {name = decorative, position = {x, y}, amount = 1}
|
2018-05-23 23:34:19 +02:00
|
|
|
end
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_to_insert == 'red-desert-0' then
|
2019-01-26 20:43:02 +02:00
|
|
|
if random(1, 50) == 1 then
|
|
|
|
decoratives[#decoratives + 1] = {name = 'rock-medium', position = {x, y}, amount = 1}
|
2018-05-23 23:34:19 +02:00
|
|
|
end
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-24 00:04:28 +02:00
|
|
|
end
|
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
--Placement of Island Resources
|
|
|
|
if tile_to_insert ~= 'water' then
|
2019-01-26 20:43:02 +02:00
|
|
|
local c = max(abs(world.x), abs(world.y))
|
2018-05-23 23:34:19 +02:00
|
|
|
|
2017-08-04 23:31:52 +02:00
|
|
|
local resource_amount_distance_multiplicator = (((c + 1) / 75) / 75) + 1
|
2019-01-26 20:43:02 +02:00
|
|
|
local noise_resource_amount_modifier = noise(((world.x + seed) / 200), ((world.y + seed) / 200), 0)
|
2019-01-16 22:33:32 +02:00
|
|
|
local resource_amount = 1 + ((500 + (500 * noise_resource_amount_modifier * 0.2)) * resource_amount_distance_multiplicator)
|
2017-08-04 23:31:52 +02:00
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_to_insert == 'sand-1' or tile_to_insert == 'sand-3' then
|
|
|
|
if noise_island_iron_and_copper > 0.5 and noise_island_resource > 0.2 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'iron-ore', amount = resource_amount}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
if noise_island_iron_and_copper < -0.5 and noise_island_resource > 0.2 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'copper-ore', amount = resource_amount}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_to_insert == 'grass-3' or tile_to_insert == 'grass-2' then
|
|
|
|
if noise_island_stone_and_coal > 0.5 and noise_island_resource > 0.2 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'stone', amount = resource_amount}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
if noise_island_stone_and_coal < -0.5 and noise_island_resource > 0.2 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'coal', amount = resource_amount}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_to_insert == 'red-desert-1' or tile_to_insert == 'red-desert-0' then
|
2019-01-26 20:43:02 +02:00
|
|
|
if noise_island_oil_and_uranium > 0.55 and noise_island_resource > 0.25 and random(60) == 1 then
|
|
|
|
entities[#entities + 1] = {name = 'crude-oil', amount = resource_amount * 400}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
if noise_island_oil_and_uranium < -0.55 and noise_island_resource > 0.35 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'uranium-ore', amount = resource_amount}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
|
2017-08-04 23:31:52 +02:00
|
|
|
noise_island_starting = noise_island_starting * 0.08
|
|
|
|
--Starting Resources
|
|
|
|
if tile_distance_to_center <= radsquare then
|
2019-01-16 22:33:32 +02:00
|
|
|
if tile_distance_to_center + noise_island_starting > radsquare * 0.09 and tile_distance_to_center + noise_island_starting <= radsquare * 0.15 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'stone', amount = resource_amount * 1.5}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2019-01-16 22:33:32 +02:00
|
|
|
if tile_distance_to_center + noise_island_starting > radsquare * 0.05 and tile_distance_to_center + noise_island_starting <= radsquare * 0.09 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'coal', amount = resource_amount * 1.5}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2019-01-16 22:33:32 +02:00
|
|
|
if tile_distance_to_center + noise_island_starting > radsquare * 0.02 and tile_distance_to_center + noise_island_starting <= radsquare * 0.05 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'iron-ore', amount = resource_amount * 1.5}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2019-01-16 22:33:32 +02:00
|
|
|
if tile_distance_to_center + noise_island_starting > radsquare * 0.003 and tile_distance_to_center + noise_island_starting <= radsquare * 0.02 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'copper-ore', amount = resource_amount * 1.5}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
if tile_distance_to_center + noise_island_starting <= radsquare * 0.002 then
|
2019-01-26 20:43:02 +02:00
|
|
|
entities[#entities + 1] = {name = 'crude-oil', amount = resource_amount * 400}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
|
|
|
end
|
2018-05-23 23:34:19 +02:00
|
|
|
end
|
2017-10-11 17:01:27 +02:00
|
|
|
|
2018-05-24 00:04:28 +02:00
|
|
|
return {tile = tile_to_insert, entities = entities, decoratives = decoratives}
|
2017-08-04 23:31:52 +02:00
|
|
|
end
|
2018-06-18 21:35:01 +02:00
|
|
|
|
|
|
|
return b.fish(map, 0.0025)
|