2018-01-23 17:50:28 +02:00
|
|
|
--Author: MewMew / (Threaded by Valansch)
|
2017-08-16 16:58:45 +02:00
|
|
|
|
2018-05-23 23:34:47 +02:00
|
|
|
local perlin = require 'map_gen.shared.perlin_noise'
|
|
|
|
local Event = require 'utils.event'
|
2019-01-16 20:44:55 +02:00
|
|
|
local RS = require 'map_gen.shared.redmew_surface'
|
2018-01-23 17:50:28 +02:00
|
|
|
|
|
|
|
--SETTINGS:
|
|
|
|
local width_modifier = 0.8
|
2018-05-10 21:42:24 +02:00
|
|
|
local ore_base_amounts = {
|
2018-05-23 23:34:47 +02:00
|
|
|
['iron-ore'] = 700,
|
|
|
|
['coal'] = 400,
|
|
|
|
['copper-ore'] = 400,
|
|
|
|
['stone'] = 400,
|
|
|
|
['uranium-ore'] = 400
|
2018-01-23 17:50:28 +02:00
|
|
|
}
|
|
|
|
|
2018-05-10 21:42:24 +02:00
|
|
|
local function init()
|
2019-01-16 20:44:55 +02:00
|
|
|
global.perlin_noise_seed = RS.get_surface().map_gen_settings.seed
|
2018-05-26 14:31:23 +02:00
|
|
|
-- math.random(1000, 1000000)
|
2018-01-23 17:50:28 +02:00
|
|
|
end
|
|
|
|
|
2018-05-10 21:42:24 +02:00
|
|
|
Event.on_init(init)
|
2018-01-23 17:50:28 +02:00
|
|
|
|
2018-05-10 21:42:24 +02:00
|
|
|
local function do_resource(name, x, y, world, noise_terrain, noise_band_high, noise_band_low, seed)
|
2018-05-23 23:34:47 +02:00
|
|
|
if noise_terrain > -noise_band_high * width_modifier and noise_terrain <= -noise_band_low * width_modifier then
|
2018-06-12 17:57:39 +02:00
|
|
|
local noise_resource_amount_modifier = perlin.noise(((x + seed) / 200), ((y + seed) / 200), 0)
|
2018-05-23 23:34:47 +02:00
|
|
|
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
|
2018-01-23 17:50:28 +02:00
|
|
|
end
|
|
|
|
|
2018-05-10 21:42:24 +02:00
|
|
|
return function(x, y, world)
|
2018-05-23 23:34:47 +02:00
|
|
|
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
|
|
|
|
|
2018-05-26 14:31:23 +02:00
|
|
|
--[[ local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = 'resource'}
|
2018-05-23 23:34:47 +02:00
|
|
|
for _, e in ipairs(entities) do
|
|
|
|
if e.name ~= 'crude-oil' then
|
|
|
|
e.destroy()
|
|
|
|
end
|
2018-05-26 14:31:23 +02:00
|
|
|
end ]]
|
2017-08-16 16:58:45 +02:00
|
|
|
|
2018-05-23 23:34:47 +02:00
|
|
|
local seed = global.perlin_noise_seed
|
2017-08-16 16:58:45 +02:00
|
|
|
|
2018-06-12 17:57:39 +02:00
|
|
|
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)
|
2018-05-23 23:34:47 +02:00
|
|
|
local noise_terrain = noise_terrain_1 + (noise_terrain_2 * 0.01)
|
2018-01-23 17:50:28 +02:00
|
|
|
|
2018-05-26 14:31:23 +02:00
|
|
|
return do_resource('iron-ore', x, y, world, noise_terrain, 0.11, 0.085, seed) or
|
|
|
|
do_resource('copper-ore', x, y, world, noise_terrain, 0.085, 0.06, seed) or
|
|
|
|
do_resource('stone', x, y, world, noise_terrain, 0.06, 0.05, seed) or
|
|
|
|
do_resource('coal', x, y, world, noise_terrain, 0.05, 0.03, seed) or
|
2018-05-24 00:12:18 +02:00
|
|
|
do_resource('uranium-ore', x, y, world, noise_terrain, 0.02, 0.01, seed)
|
2017-08-16 16:58:45 +02:00
|
|
|
end
|