1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/map_gen/presets/fish_islands.lua

230 lines
6.8 KiB
Lua
Raw Normal View History

2018-03-03 15:13:48 +02:00
--[[
This map uses custom ore gen. When generating the map, under the resource settings tab use Size = 'None' for all resources.
This map removes and adds it's own water, in terrain settings use water frequency = very low and water size = only in starting area.
This map has isolated areas, it's recommend turning biters to peaceful to reduce stress on the pathfinder.
]]
2018-06-05 13:41:42 +02:00
local b = require 'map_gen.shared.builders'
2018-10-04 17:56:49 +02:00
local math = require "utils.math"
2018-11-06 14:08:33 +02:00
local degrees = math.degrees
2018-05-08 22:23:07 +02:00
2018-03-03 14:55:33 +02:00
-- change these to change the pattern.
2018-09-29 14:37:34 +02:00
local seed1 = 12345
local seed2 = 56789
2018-03-03 14:55:33 +02:00
2018-09-29 14:37:34 +02:00
local fish_scale = 1.75
local value = b.exponential_value
2018-03-03 14:55:33 +02:00
2018-06-05 13:41:42 +02:00
local pic = require 'map_gen.data.presets.fish'
pic = b.decompress(pic)
2018-05-08 22:23:07 +02:00
local fish = b.picture(pic)
2018-03-03 14:55:33 +02:00
2018-06-05 13:41:42 +02:00
fish = b.change_tile(fish, 'water', false)
2018-09-29 14:37:34 +02:00
fish = b.scale(fish, fish_scale)
2018-03-03 14:55:33 +02:00
2018-06-05 13:41:42 +02:00
local ores = {
2018-09-29 14:37:34 +02:00
{resource_type = 'iron-ore', value = value(75, 0.25, 1.15)},
{resource_type = 'copper-ore', value = value(65, 0.2, 1.15)},
{resource_type = 'stone', value = value(50, 0.2, 1.1)},
{resource_type = 'coal', value = value(50, 0.15, 1.1)},
{resource_type = 'uranium-ore', value = value(10, 0.1, 1.075)},
{resource_type = 'crude-oil', value = value(25000, 25, 1.15)}
2018-06-05 13:41:42 +02:00
}
2018-03-03 14:55:33 +02:00
2018-09-29 14:37:34 +02:00
local cap = b.translate(b.rectangle(48 * fish_scale, 48 * fish_scale), 100 * fish_scale, 0)
local rich_tile = b.rectangle(3, 3)
rich_tile = b.translate(rich_tile, 100 * fish_scale, 0)
local function rich_value()
return 1111111
end
2018-03-03 14:55:33 +02:00
2018-09-29 14:37:34 +02:00
local iron =
b.any {
b.resource(rich_tile, ores[1].resource_type, rich_value),
b.resource(cap, ores[1].resource_type, ores[1].value)
}
local copper =
b.any {
b.resource(rich_tile, ores[2].resource_type, rich_value),
b.resource(cap, ores[2].resource_type, ores[2].value)
}
local stone =
b.any {
b.resource(rich_tile, ores[3].resource_type, rich_value),
b.resource(cap, ores[3].resource_type, ores[3].value)
}
local coal =
b.any {
b.resource(rich_tile, ores[4].resource_type, rich_value),
b.resource(cap, ores[4].resource_type, ores[4].value)
}
local uranium =
b.any {
b.resource(rich_tile, ores[5].resource_type, rich_value),
b.resource(cap, ores[5].resource_type, ores[5].value)
}
2018-05-08 22:23:07 +02:00
local oil = b.resource(b.throttle_world_xy(cap, 1, 8, 1, 8), ores[6].resource_type, ores[6].value)
2018-03-03 14:55:33 +02:00
2018-09-29 14:37:34 +02:00
local worm_names = {
'small-worm-turret',
'medium-worm-turret',
'big-worm-turret'
}
local max_worm_chance = 1 / 64
local worm_chance_factor = 1 / 256
2018-06-05 13:41:42 +02:00
local function worms(x, y, world)
if not cap(x, y) then
return nil
end
2018-09-29 14:37:34 +02:00
local wx, wy = world.x, world.y
local d = math.sqrt(wx * wx + wy * wy)
local worm_chance = d - 64
if worm_chance > 0 then
worm_chance = worm_chance * worm_chance_factor
worm_chance = math.min(worm_chance, max_worm_chance)
if math.random() < worm_chance then
if d < 512 then
return {name = 'small-worm-turret'}
else
local max_lvl
local min_lvl
if d < 1024 then
max_lvl = 2
min_lvl = 1
else
max_lvl = 3
min_lvl = 2
end
local lvl = math.random() ^ (512 / d) * max_lvl
lvl = math.ceil(lvl)
lvl = math.clamp(lvl, min_lvl, 3)
return {name = worm_names[lvl]}
end
end
2018-06-05 13:41:42 +02:00
end
end
local iron_fish = b.apply_entities(fish, {iron, worms})
local copper_fish = b.apply_entities(fish, {copper, worms})
local stone_fish = b.apply_entities(fish, {stone, worms})
local coal_fish = b.apply_entities(fish, {coal, worms})
local uranium_fish = b.apply_entities(fish, {uranium, worms})
local oil_fish = b.apply_entities(fish, {oil, worms})
local fishes = {
{iron_fish, 24},
{copper_fish, 12},
{stone_fish, 6},
{coal_fish, 6},
{uranium_fish, 1},
{oil_fish, 4}
}
local Random = require 'map_gen.shared.random'
2018-03-03 14:55:33 +02:00
local random = Random.new(seed1, seed2)
local total_weights = {}
local t = 0
for _, v in pairs(fishes) do
t = t + v[2]
table.insert(total_weights, t)
end
local p_cols = 50
local p_rows = 50
local pattern = {}
for c = 1, p_cols do
local row = {}
table.insert(pattern, row)
for r = 1, p_rows do
if (r <= 1) and (c <= 2 or c > p_cols - 1) then
2018-05-08 22:23:07 +02:00
table.insert(row, b.empty_shape)
2018-03-03 14:55:33 +02:00
else
local i = random:next_int(1, t)
2018-06-05 13:41:42 +02:00
2018-03-03 14:55:33 +02:00
local index = table.binary_search(total_weights, i)
if (index < 0) then
index = bit32.bnot(index)
end
2018-06-05 13:41:42 +02:00
2018-03-03 14:55:33 +02:00
local shape = fishes[index][1]
2018-06-05 13:41:42 +02:00
2018-03-03 14:55:33 +02:00
local x = random:next_int(-48, 48)
local y = random:next_int(-48, 48)
2018-11-06 13:55:52 +02:00
local angle = random:next() * math.tau
2018-06-05 13:41:42 +02:00
shape = b.rotate(shape, angle)
2018-05-08 22:23:07 +02:00
shape = b.translate(shape, x, y)
2018-06-05 13:41:42 +02:00
2018-03-03 14:55:33 +02:00
table.insert(row, shape)
end
end
end
2018-09-29 14:37:34 +02:00
local map = b.grid_pattern_full_overlap(pattern, p_cols, p_rows, 215 * fish_scale, 215 * fish_scale)
2018-03-03 14:55:33 +02:00
2018-06-05 13:41:42 +02:00
local start = require 'map_gen.data.presets.soy_sauce'
2018-05-08 22:23:07 +02:00
start = b.decompress(start)
start = b.picture(start)
2018-06-05 13:41:42 +02:00
start = b.change_tile(start, 'water', false)
2018-03-03 14:55:33 +02:00
2018-06-05 13:41:42 +02:00
local pic = require 'map_gen.data.presets.fish_black_and_white'
2018-05-08 22:23:07 +02:00
local pic = b.decompress(pic)
local fish_bw = b.picture(pic)
fish_bw = b.scale(fish_bw, 0.25, 0.25)
2018-03-03 14:55:33 +02:00
2018-05-08 22:23:07 +02:00
local start_copper = b.rotate(fish_bw, degrees(180))
local start_stone = b.rotate(fish_bw, degrees(90))
local start_coal = b.rotate(fish_bw, degrees(-90))
2018-03-03 14:55:33 +02:00
2018-05-08 22:23:07 +02:00
local start_iron = b.translate(fish_bw, -32, 0)
start_copper = b.translate(start_copper, 32, 0)
start_stone = b.translate(start_stone, 0, 32)
start_coal = b.translate(start_coal, 0, -32)
2018-03-03 14:55:33 +02:00
2018-09-29 14:37:34 +02:00
start_iron = b.resource(start_iron, ores[1].resource_type, value(1000, 0.5, 1))
start_copper = b.resource(start_copper, ores[2].resource_type, value(800, 0.5, 1))
start_stone = b.resource(start_stone, ores[3].resource_type, value(600, 0.5, 1))
start_coal = b.resource(start_coal, ores[4].resource_type, value(600, 0.5, 1))
2018-03-03 16:35:06 +02:00
2018-05-08 22:23:07 +02:00
local start_oil = b.translate(b.rectangle(1, 1), -44, 74)
2018-09-29 14:37:34 +02:00
start_oil = b.resource(start_oil, ores[6].resource_type, value(100000, 0, 1))
2018-03-03 16:35:06 +02:00
2018-06-05 13:41:42 +02:00
local worms_area = b.rectangle(150, 72)
worms_area = b.translate(worms_area, 0, -210)
local function worms_top(x, y, world)
if worms_area(x, y) then
local entities = world.surface.find_entities {{world.x, world.y}, {world.x + 1, world.y + 1}}
for _, e in ipairs(entities) do
e.destroy()
end
return {name = 'big-worm-turret'}
end
end
--worms = b.entity(worms, 'big-worm-turret')
2018-03-03 16:35:06 +02:00
2018-06-05 13:41:42 +02:00
local start = b.apply_entity(start, b.any {start_iron, start_copper, start_stone, start_coal, start_oil, worms_top})
2018-03-03 14:55:33 +02:00
2018-05-08 22:23:07 +02:00
map = b.if_else(start, map)
2018-03-03 14:55:33 +02:00
2018-06-05 13:41:42 +02:00
map = b.change_map_gen_collision_tile(map, 'water-tile', 'grass-1')
2018-03-03 14:55:33 +02:00
2018-06-05 13:41:42 +02:00
local sea = b.tile('water')
local sea = b.fish(sea, 0.0025)
2018-03-03 14:55:33 +02:00
2018-05-08 22:23:07 +02:00
map = b.if_else(map, sea)
2018-03-03 14:55:33 +02:00
2018-05-08 22:23:07 +02:00
--map = b.scale(map, 2, 2)
2018-09-29 14:37:34 +02:00
--map = b.apply_entity(b.full_shape, iron)
2018-03-03 14:55:33 +02:00
return map