2018-12-24 10:34:54 +02:00
|
|
|
--atoll-- mewmew made this --
|
2018-12-08 22:57:54 +02:00
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
require 'modules.spawners_contain_biters'
|
|
|
|
require 'modules.surrounded_by_worms'
|
2019-02-28 19:53:33 +02:00
|
|
|
|
2024-10-01 16:46:06 +02:00
|
|
|
local simplex_noise = require 'utils.math.simplex_noise'
|
2018-12-08 22:57:54 +02:00
|
|
|
simplex_noise = simplex_noise.d2
|
2021-03-24 21:14:55 +02:00
|
|
|
local Event = require 'utils.event'
|
2018-12-08 22:57:54 +02:00
|
|
|
local table_insert = table.insert
|
|
|
|
local math_random = math.random
|
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
local function get_noise(name, pos)
|
|
|
|
local seed = game.surfaces[1].map_gen_settings.seed
|
|
|
|
local noise_seed_add = 25000
|
|
|
|
seed = seed + noise_seed_add
|
|
|
|
if name == 'ocean' then
|
|
|
|
local noise = {}
|
|
|
|
noise[1] = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed)
|
|
|
|
seed = seed + noise_seed_add
|
|
|
|
noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
|
|
|
|
seed = seed + noise_seed_add
|
|
|
|
noise[3] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
|
|
|
|
seed = seed + noise_seed_add
|
|
|
|
noise[4] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
|
2021-03-24 21:14:55 +02:00
|
|
|
noise = noise[1] + noise[2] * 0.3 + noise[3] * 0.2 + noise[4] * 0.1
|
2021-03-24 17:46:00 +02:00
|
|
|
--noise = noise * 0.5
|
|
|
|
return noise
|
|
|
|
end
|
2018-12-08 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
2021-03-24 17:46:00 +02:00
|
|
|
local function on_player_joined_game(event)
|
|
|
|
local player = game.players[event.player_index]
|
2024-09-24 19:37:11 +02:00
|
|
|
if not storage.map_init_done then
|
2021-03-24 17:46:00 +02:00
|
|
|
game.forces['player'].technologies['landfill'].researched = true
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.average_worm_amount_per_chunk = 6
|
|
|
|
storage.map_init_done = true
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if player.online_time == 0 then
|
|
|
|
--player.insert{name = 'iron-axe', count = 1}
|
2024-09-24 19:37:11 +02:00
|
|
|
player.insert { name = 'landfill', count = 200 }
|
|
|
|
player.insert { name = 'iron-plate', count = 32 }
|
|
|
|
player.insert { name = 'iron-gear-wheel', count = 16 }
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
2018-12-08 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function on_marked_for_deconstruction(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
if event.entity.name == 'fish' then
|
|
|
|
event.entity.cancel_deconstruction(game.players[event.player_index].force.name)
|
|
|
|
end
|
2018-12-08 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
local types = { 'resource', 'simple-entity', 'player' }
|
2018-12-08 22:57:54 +02:00
|
|
|
local function on_chunk_generated(event)
|
2021-03-24 17:46:00 +02:00
|
|
|
local surface = event.surface
|
|
|
|
local left_top = event.area.left_top
|
|
|
|
local tiles = {}
|
|
|
|
local entities = {}
|
|
|
|
|
|
|
|
for x = 0, 31, 1 do
|
|
|
|
for y = 0, 31, 1 do
|
|
|
|
local tile_to_insert = false
|
2024-09-24 19:37:11 +02:00
|
|
|
local pos = { x = left_top.x + x, y = left_top.y + y }
|
2021-03-24 17:46:00 +02:00
|
|
|
local ocean_noise = get_noise('ocean', pos)
|
|
|
|
if ocean_noise > -0.5 then
|
|
|
|
tile_to_insert = 'water'
|
|
|
|
if ocean_noise > -0.25 then
|
|
|
|
tile_to_insert = 'deepwater'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if tile_to_insert then
|
2024-09-24 19:37:11 +02:00
|
|
|
local count = surface.count_entities_filtered({ area = { { pos.x - 1, pos.y - 1 }, { pos.x + 1.99, pos.y + 1.99 } }, limit = 1, type = types })
|
2021-03-24 17:46:00 +02:00
|
|
|
if count == 0 then
|
2024-09-24 19:37:11 +02:00
|
|
|
table_insert(tiles, { name = tile_to_insert, position = pos })
|
2021-03-24 17:46:00 +02:00
|
|
|
if math_random(1, 128) == 1 then
|
2024-09-24 19:37:11 +02:00
|
|
|
table_insert(entities, { name = 'fish', position = pos })
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
surface.set_tiles(tiles, true)
|
|
|
|
|
|
|
|
for _, entity in pairs(entities) do
|
|
|
|
surface.create_entity(entity)
|
|
|
|
end
|
|
|
|
|
2024-09-24 19:37:11 +02:00
|
|
|
if not storage.spawn_generated and left_top.x <= -64 then
|
2021-03-24 17:46:00 +02:00
|
|
|
--map_functions.draw_noise_tile_circle({x = 0, y = 0}, "concrete", surface, 5)
|
|
|
|
--map_functions.draw_smoothed_out_ore_circle({x = -32, y = -32}, "copper-ore", surface, 15, 2500)
|
|
|
|
--map_functions.draw_smoothed_out_ore_circle({x = -32, y = 32}, "iron-ore", surface, 15, 2500)
|
|
|
|
--map_functions.draw_smoothed_out_ore_circle({x = 32, y = 32}, "coal", surface, 15, 2500)
|
|
|
|
--map_functions.draw_smoothed_out_ore_circle({x = 32, y = -32}, "stone", surface, 15, 2500)
|
|
|
|
--map_functions.draw_oil_circle({x = 0, y = 0}, "crude-oil", surface, 5, 200000)
|
2024-09-24 19:37:11 +02:00
|
|
|
storage.spawn_generated = true
|
2021-03-24 17:46:00 +02:00
|
|
|
end
|
2018-12-08 22:57:54 +02:00
|
|
|
end
|
|
|
|
|
2021-03-24 21:14:55 +02:00
|
|
|
Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|
|
|
|
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
|
|
|
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|