1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Merge remote-tracking branch 'upstream/develop' into snakey_swamp

This commit is contained in:
Soggs 2019-10-21 12:15:26 +02:00
commit f3ffc28512
5 changed files with 368 additions and 103 deletions

View File

@ -126,7 +126,9 @@ global.config = {
['medium-biter'] = {low = 1, high = 3, chance = 0}, ['medium-biter'] = {low = 1, high = 3, chance = 0},
['big-biter'] = {low = 1, high = 5, chance = 0}, ['big-biter'] = {low = 1, high = 5, chance = 0},
['behemoth-biter'] = {low = 1, high = 10, chance = 0} ['behemoth-biter'] = {low = 1, high = 10, chance = 0}
} },
-- will delay the creating of the market in ticks
delay = nil
}, },
-- adds anti-nuke griefing -- adds anti-nuke griefing
nuke_control = { nuke_control = {

View File

@ -326,6 +326,17 @@ Event.add(defines.events.on_entity_died, fish_drop_entity_died)
Event.add(Retailer.events.on_market_purchase, market_item_purchased) Event.add(Retailer.events.on_market_purchase, market_item_purchased)
Event.add(defines.events.on_player_crafted_item, fish_player_crafted_item) Event.add(defines.events.on_player_crafted_item, fish_player_crafted_item)
Event.add(defines.events.on_player_created, player_created) Event.add(defines.events.on_player_created, player_created)
if global.config.market.create_standard_market then
Event.on_init(spawn_market) if market_config.create_standard_market then
local delay = market_config.delay
if delay then
local spawn_market_token = Token.register(spawn_market)
Event.on_init(
function()
Task.set_timeout_in_ticks(delay, spawn_market_token)
end
)
else
Event.on_init(spawn_market)
end
end end

View File

@ -1,102 +1,107 @@
--Hilbert Sand Trap Map, by Jayefuu, R. Nukem, and grilledham --Hilbert Sand Trap Map, by Jayefuu, R. Nukem, and grilledham
local b = require 'map_gen.shared.builders' local b = require 'map_gen.shared.builders'
local degrees = require "utils.math".degrees local degrees = require 'utils.math'.degrees
local RS = require 'map_gen.shared.redmew_surface' local RS = require 'map_gen.shared.redmew_surface'
local MGSP = require 'resources.map_gen_settings' local MGSP = require 'resources.map_gen_settings'
--https://www.fractalus.com/kerry/tutorials/hilbert/hilbert-tutorial.html --https://www.fractalus.com/kerry/tutorials/hilbert/hilbert-tutorial.html
-- Setup the scenario map information because everyone gets upset if you don't -- Setup the scenario map information because everyone gets upset if you don't
local ScenarioInfo = require 'features.gui.info' local ScenarioInfo = require 'features.gui.info'
ScenarioInfo.set_map_name('Hilbert\'s Sand Trap') ScenarioInfo.set_map_name("Hilbert's Sand Trap")
ScenarioInfo.set_map_description('You have crash landed in the middle of Hilbert\'s Labyrinth! Surrounded by quicksand and biters you must survive long enough to launch a rocket.') ScenarioInfo.set_map_description("You have crash landed in the middle of Hilbert's Labyrinth! Surrounded by quicksand and biters you must survive long enough to launch a rocket.")
ScenarioInfo.set_map_extra_info('Only the native grasses are suitable to build on. Ores and trees have sunk into the sand, but biters have adapted to live happily in the barren landscape. Some even speak of a Hydra living deep within the desert. \n\n Map created by R. Nukem and Jayefuu, with help from grilledham and the rest of the Redmew admin team.') ScenarioInfo.set_map_extra_info(
'Only the native grasses are suitable to build on. Ores and trees have sunk into the sand, but biters have adapted to live happily in the barren landscape. Some even speak of a Hydra living deep within the desert. \n\n Map created by R. Nukem and Jayefuu, with help from grilledham and the rest of the Redmew admin team.'
)
--enable Hydra --enable Hydra
local hail_hydra = global.config.hail_hydra local hail_hydra = global.config.hail_hydra
hail_hydra.enabled = true hail_hydra.enabled = true
--tweak hydra settings. Defualt settings are WAY too hard (circa 2019-02-22 hydra) --tweak hydra settings. Defualt settings are WAY too hard (circa 2019-02-22 hydra)
--This section will need updated in the future pending changes to how hydra is configured (PR #795) --This section will need updated in the future pending changes to how hydra is configured (PR #795)
hail_hydra.hydras = { hail_hydra.hydras = {
-- spitters -- spitters
['small-spitter'] = {['small-worm-turret'] = 0.05}, --default 0.2 ['small-spitter'] = {['small-worm-turret'] = 0.05}, --default 0.2
['medium-spitter'] = {['medium-worm-turret'] = 0.05}, --defualt 0.2 ['medium-spitter'] = {['medium-worm-turret'] = 0.05}, --defualt 0.2
['big-spitter'] = {['big-worm-turret'] = 0.05}, --defualt 0.2 ['big-spitter'] = {['big-worm-turret'] = 0.05}, --defualt 0.2
['behemoth-spitter'] = {['big-worm-turret'] = 0.2}, --default 0.4 ['behemoth-spitter'] = {['big-worm-turret'] = 0.2}, --default 0.4
-- biters -- biters
['medium-biter'] = {['small-biter'] = 0.4}, --default 1.2 ['medium-biter'] = {['small-biter'] = 0.4}, --default 1.2
['big-biter'] = {['medium-biter'] = 0.4},--default 1.2 ['big-biter'] = {['medium-biter'] = 0.4},
['behemoth-biter'] = {['big-biter'] = 0.4},--default 1.2 --default 1.2
-- worms ['behemoth-biter'] = {['big-biter'] = 0.4},
['small-worm-turret'] = {['small-biter'] = .75},--defualt 2.5 --default 1.2
['medium-worm-turret'] = {['small-biter'] = .75, ['medium-biter'] = 0.3}, --default 2.5, .6 -- worms
['big-worm-turret'] = {['small-biter'] = 2.0, ['medium-biter'] = 1.0, ['big-biter'] = 0.5} --defualt 3.8, 1.3, 1.1 ['small-worm-turret'] = {['small-biter'] = .75},
} --defualt 2.5
['medium-worm-turret'] = {['small-biter'] = .75, ['medium-biter'] = 0.3}, --default 2.5, .6
['big-worm-turret'] = {['small-biter'] = 2.0, ['medium-biter'] = 1.0, ['big-biter'] = 0.5} --defualt 3.8, 1.3, 1.1
}
hail_hydra.evolution_scale = .7 hail_hydra.evolution_scale = .7
-- define map settings -- define map settings
--Ore settings. I feel very-high frequency is required to keep the sand from eating all the ores --Ore settings. I feel very-high frequency is required to keep the sand from eating all the ores
-- Richness and size can be changed to tweak balance a bit. -- Richness and size can be changed to tweak balance a bit.
local ore_settings = { local ore_settings = {
autoplace_controls = { autoplace_controls = {
coal = { coal = {
frequency = 'very-high', frequency = 'very-high',
richness = 'normal', richness = 'normal',
size = 'normal' size = 'normal'
}, },
['copper-ore'] = { ['copper-ore'] = {
frequency = 'very-high', frequency = 'very-high',
richness = 'normal', richness = 'normal',
size = 'normal' size = 'normal'
}, },
['crude-oil'] = { ['crude-oil'] = {
frequency = 'very-high', frequency = 'very-high',
richness = 'normal', richness = 'normal',
size = 'normal' size = 'normal'
}, },
['iron-ore'] = { ['iron-ore'] = {
frequency = 'very-high', frequency = 'very-high',
richness = 'normal', richness = 'normal',
size = 'normal' size = 'normal'
}, },
stone = { stone = {
frequency = 'very-high', frequency = 'very-high',
richness = 'normal', richness = 'normal',
size = 'normal' size = 'normal'
}, },
['uranium-ore'] = { ['uranium-ore'] = {
frequency = 'very-high', frequency = 'very-high',
richness = 'very-low', richness = 'very-low',
size = 'very-small' size = 'very-small'
} }
} }
} }
-- Another section that can be used for balance. Setting richness above normal is not recommended -- Another section that can be used for balance. Setting richness above normal is not recommended
local tree_settings = { local tree_settings = {
autoplace_controls = { autoplace_controls = {
trees = { trees = {
frequency = 'very-high', frequency = 'very-high',
richness = 'normal', richness = 'normal',
size = 'normal' size = 'normal'
} }
} }
} }
-- This seems to be a decent balance between small pools of water and not blocking entire sections -- This seems to be a decent balance between small pools of water and not blocking entire sections
-- of the maze near spawn by lakes -- of the maze near spawn by lakes
local water_settings = { local water_settings = {
terrain_segmentation = 'high', terrain_segmentation = 'high',
water = 'low' water = 'low'
} }
--Set map settings --Set map settings
RS.set_map_gen_settings( RS.set_map_gen_settings(
{ {
MGSP.cliff_none, MGSP.cliff_none,
MGSP.grass_only, MGSP.grass_only,
MGSP.enable_water, MGSP.enable_water,
MGSP.enemy_very_high, MGSP.enemy_very_high,
MGSP.starting_area_very_low, MGSP.starting_area_very_low,
ore_settings, ore_settings,
tree_settings, tree_settings,
water_settings water_settings
} }
) )
@ -146,7 +151,7 @@ pattern =
b.translate(b.rotate(line_1, degrees(90)), 40, 30) b.translate(b.rotate(line_1, degrees(90)), 40, 30)
} }
-- Tile map in X direction -- Tile map in X direction
local function ribbon(y) local function ribbon(_, y)
local abs_y = math.abs(y) local abs_y = math.abs(y)
return (abs_y < 40) return (abs_y < 40)
end end
@ -162,12 +167,12 @@ local map = b.any {hilbert, ribbon}
map = b.scale(map, scale_factor, scale_factor) map = b.scale(map, scale_factor, scale_factor)
-- make starting area -- make starting area
local start_region = b.rectangle(block_length * scale_factor,block_width * scale_factor) local start_region = b.rectangle(block_length * scale_factor, block_width * scale_factor)
map = b.subtract(map, start_region) map = b.subtract(map, start_region)
start_region = b.change_tile(start_region,true, 'grass-1') start_region = b.change_tile(start_region, true, 'grass-1')
start_region = b.remove_map_gen_resources(start_region) start_region = b.remove_map_gen_resources(start_region)
local start_water = b.change_tile(b.circle(5),true, 'water') local start_water = b.change_tile(b.circle(5), true, 'water')
map = b.any{start_water,start_region,map} map = b.any {start_water, start_region, map}
--make starting ores --make starting ores
local value = b.manhattan_value local value = b.manhattan_value
local ore_shape = b.scale(b.circle(30), 0.15) local ore_shape = b.scale(b.circle(30), 0.15)
@ -198,10 +203,10 @@ Event.add(
return return
end end
local name = entity.name local name = entity.name
local ghost = false local ghost = false
if name == 'tile-ghost' or name == 'entity-ghost' then if name == 'tile-ghost' or name == 'entity-ghost' then
ghost = true ghost = true
end end
-- Check the bounding box for the tile -- Check the bounding box for the tile
local status = true local status = true
@ -209,7 +214,7 @@ Event.add(
local left_top = area.left_top local left_top = area.left_top
local right_bottom = area.right_bottom local right_bottom = area.right_bottom
local p = game.get_player(event.player_index) local p = game.get_player(event.player_index)
--check for sand under all tiles in bounding box --check for sand under all tiles in bounding box
for x = math.floor(left_top.x), math.floor(right_bottom.x), 1 do for x = math.floor(left_top.x), math.floor(right_bottom.x), 1 do
for y = math.floor(left_top.y), math.floor(right_bottom.y), 1 do for y = math.floor(left_top.y), math.floor(right_bottom.y), 1 do
if p.surface.get_tile(x, y).name == 'sand-1' then if p.surface.get_tile(x, y).name == 'sand-1' then
@ -221,7 +226,7 @@ Event.add(
if status == true then if status == true then
return return
else else
--destroy entity and return to player --destroy entity and return to player
if not p or not p.valid then if not p or not p.valid then
return return
end end
@ -236,26 +241,26 @@ Event.add(
Event.add( Event.add(
defines.events.on_player_built_tile, defines.events.on_player_built_tile,
function(event) function(event)
local player = game.get_player(event.player_index) local player = game.get_player(event.player_index)
if not player or not player.valid then if not player or not player.valid then
return return
end end
local tiles = event.tiles local tiles = event.tiles
local replace_tiles = {} local replace_tiles = {}
local refund_count = 0 local refund_count = 0
for i = 1, #tiles do for i = 1, #tiles do
local tile = tiles[i] local tile = tiles[i]
local old_name = tile.old_tile.name local old_name = tile.old_tile.name
if old_name == 'sand-1' then if old_name == 'sand-1' then
tile.name = 'sand-1' tile.name = 'sand-1'
replace_tiles[#replace_tiles + 1] = tile replace_tiles[#replace_tiles + 1] = tile
refund_count = refund_count + 1 refund_count = refund_count + 1
end end
end end
if #replace_tiles > 0 then if #replace_tiles > 0 then
player.surface.set_tiles(replace_tiles, true) player.surface.set_tiles(replace_tiles, true)
player.insert {name = event.item.name, count = refund_count} player.insert {name = event.item.name, count = refund_count}
end end
end end
) )
return map return map

View File

@ -0,0 +1,199 @@
--Hilbert Water Trap Map, by SimonFlapse, based on Hilbert Sand Trap by Jayefuu, R. Nukem, and grilledham
local b = require 'map_gen.shared.builders'
local degrees = require 'utils.math'.degrees
local RS = require 'map_gen.shared.redmew_surface'
local MGSP = require 'resources.map_gen_settings'
local redmew_config = global.config
--https://www.fractalus.com/kerry/tutorials/hilbert/hilbert-tutorial.html
-- Setup the scenario map information because everyone gets upset if you don't
local ScenarioInfo = require 'features.gui.info'
ScenarioInfo.set_map_name("Hilbert's Sand Trap")
ScenarioInfo.set_map_description("You have crash landed in the middle of Hilbert's Labyrinth! Surrounded by quicksand and biters you must survive long enough to launch a rocket.")
ScenarioInfo.set_map_extra_info(
'Only the native grasses are suitable to build on. Ores and trees have sunk into the sand, but biters have adapted to live happily in the barren landscape. Some even speak of a Hydra living deep within the desert. \n\n Map created by R. Nukem and Jayefuu, with help from grilledham and the rest of the Redmew admin team.'
)
--enable Hydra
local hail_hydra = redmew_config.hail_hydra
hail_hydra.enabled = true
--tweak hydra settings. Default settings are WAY too hard (circa 2019-02-22 hydra)
--This section will need updated in the future pending changes to how hydra is configured (PR #795)
hail_hydra.hydras = {
-- spitters
['small-spitter'] = {['small-worm-turret'] = 0.05}, --default 0.2
['medium-spitter'] = {['medium-worm-turret'] = 0.05}, --defualt 0.2
['big-spitter'] = {['big-worm-turret'] = 0.05}, --defualt 0.2
['behemoth-spitter'] = {['big-worm-turret'] = 0.2}, --default 0.4
-- biters
['medium-biter'] = {['small-biter'] = 0.4}, --default 1.2
['big-biter'] = {['medium-biter'] = 0.4},
--default 1.2
['behemoth-biter'] = {['big-biter'] = 0.4},
--default 1.2
-- worms
['small-worm-turret'] = {['small-biter'] = .75},
--defualt 2.5
['medium-worm-turret'] = {['small-biter'] = .75, ['medium-biter'] = 0.3}, --default 2.5, .6
['big-worm-turret'] = {['small-biter'] = 2.0, ['medium-biter'] = 1.0, ['big-biter'] = 0.5} --defualt 3.8, 1.3, 1.1
}
hail_hydra.evolution_scale = .7
local market_config = redmew_config.market
market_config.standard_market_location = {0, -7} -- Some how the market gets removed
market_config.delay = 5 -- delays spawning the market by 5 ticks
-- define map settings
--Ore settings. I feel very-high frequency is required to keep the sand from eating all the ores
-- Richness and size can be changed to tweak balance a bit.
local ore_settings = {
autoplace_controls = {
coal = {
frequency = 'very-high',
richness = 'normal',
size = 'normal'
},
['copper-ore'] = {
frequency = 'very-high',
richness = 'normal',
size = 'normal'
},
['crude-oil'] = {
frequency = 'very-high',
richness = 'normal',
size = 'normal'
},
['iron-ore'] = {
frequency = 'very-high',
richness = 'normal',
size = 'normal'
},
stone = {
frequency = 'very-high',
richness = 'normal',
size = 'normal'
},
['uranium-ore'] = {
frequency = 'very-high',
richness = 'very-low',
size = 'very-small'
}
}
}
-- Another section that can be used for balance. Setting richness above normal is not recommended
local tree_settings = {
autoplace_controls = {
trees = {
frequency = 'very-high',
richness = 'normal',
size = 'normal'
}
}
}
-- This seems to be a decent balance between small pools of water and not blocking entire sections
-- of the maze near spawn by lakes
local water_settings = {
terrain_segmentation = 'high',
water = 'low'
}
--Set map settings
RS.set_map_gen_settings(
{
MGSP.cliff_none,
MGSP.grass_only,
MGSP.enable_water,
MGSP.enemy_very_high,
MGSP.starting_area_very_low,
ore_settings,
tree_settings,
water_settings
}
)
--start hilbert design. Note: The following code does contain bugs. Jayefuu and R.Nukem are aware of
--this and will look into fixing it at a later date. For now keep hilbert_levels = 2
--The following values can be changed to adjust the width of the maze and sand
local block_width = 6
local block_length = 16
local scale_factor = 11
local hilbert_levels = 2 -- do not change unless the algorithm has been fixed
local line_1 = b.translate(b.rectangle(block_width, block_length), -5, 0) --adjust size of rectangle to change maze width
local tier_1 =
b.any {
line_1,
b.rotate(line_1, degrees(-90)),
b.rotate(line_1, degrees(-180))
}
local pattern = tier_1
local var = 20
for i = 1, hilbert_levels do
-- do the rotation stuff
pattern =
b.any {
pattern,
b.translate(b.flip_x(pattern), i * var, 0),
b.translate(b.rotate(pattern, degrees(90)), i * var, i * var),
b.translate(b.rotate(pattern, degrees(-90)), 0, i * var)
}
-- translate the pattern so that the connecting pieces are easier to add
pattern = b.translate(pattern, -0.5 * i * var, -0.5 * i * var)
-- add the 3 connecting pieces
pattern =
b.any {
pattern,
b.translate(line_1, (10 * (i - 1) + (10 * i)) * -1, 0),
b.translate(b.rotate(line_1, degrees(180)), (10 * (i - 1) + (10 * i)), 0),
b.rotate(line_1, degrees(-90))
--b.translate(line_1,-10,0)
}
end
pattern =
b.any {
pattern,
b.translate(b.rotate(line_1, degrees(90)), -40, 30),
b.translate(b.rotate(line_1, degrees(90)), 40, 30)
}
-- Tile map in X direction
local function ribbon(_, y)
local abs_y = math.abs(y)
return (abs_y < 40)
end
ribbon = b.change_tile(ribbon, true, 'water-shallow')
ribbon = b.remove_map_gen_decoratives_by_filter(ribbon)
ribbon = b.remove_map_gen_resources(ribbon)
ribbon = b.remove_map_gen_trees(ribbon)
ribbon = b.translate(ribbon, 0, 6)
pattern = b.translate(pattern, 0, 5)
local hilbert = b.single_x_pattern(pattern, 80)
local map = b.any {hilbert, ribbon}
--Change this to scale map
map = b.scale(map, scale_factor, scale_factor)
-- make starting area
local start_region = b.rectangle(block_length * scale_factor, block_width * scale_factor)
map = b.subtract(map, start_region)
start_region = b.change_map_gen_collision_tile(start_region, 'water-tile', 'landfill')
start_region = b.remove_map_gen_resources(start_region)
local start_water = b.change_tile(b.circle(5), true, 'water')
map = b.any {start_water, start_region, map}
--make starting ores
local value = b.manhattan_value
local ore_shape = b.scale(b.circle(30), 0.15)
local start_ore = b.circle(30)
local start_iron = b.resource(start_ore, 'iron-ore', value(1000, 0))
local start_copper = b.resource(start_ore, 'copper-ore', value(750, 0))
local start_coal = b.resource(start_ore, 'coal', value(500, 0))
local start_stone = b.resource(start_ore, 'stone', value(500, 0))
start_ore = b.segment_pattern({start_coal, start_stone, start_copper, start_iron})
ore_shape = b.choose(b.circle(30), start_ore, ore_shape)
--apply starting ores to map
map = b.apply_entity(map, ore_shape)
--shift spawn so player doesn't die to start water
map = b.translate(map, 0, 30)
return map

View File

@ -779,7 +779,7 @@ function Builders.remove_map_gen_entities_by_filter(shape, filter)
return function(x, y, world) return function(x, y, world)
local tile = shape(x, y, world) local tile = shape(x, y, world)
if not tile then if not tile then
return return tile
end end
local wx, wy = world.x, world.y local wx, wy = world.x, world.y
@ -820,6 +820,56 @@ function Builders.remove_entities_by_name(shape, names)
end end
end end
--- Docs: https://github.com/Refactorio/RedMew/wiki/Using-the-Builders#buildersremove_map_gen_decoratives
function Builders.remove_map_gen_decoratives(shape, optional_filter)
if optional_filter then
optional_filter = shallow_copy(optional_filter)
else
optional_filter = {}
end
return function(x, y, world)
local tile = shape(x, y, world)
if not tile then
return tile
end
local wx, wy = world.x, world.y
optional_filter.area = {{wx, wy}, {wx + 1, wy + 1}}
world.surface.destroy_decoratives(optional_filter)
return tile
end
end
--- Docs: https://github.com/Refactorio/RedMew/wiki/Using-the-Builders/#buildersremove_decoratives_by_name
function Builders.remove_decoratives_by_name(shape, names)
if type(names) ~= 'table' then
names = {names}
end
return function(x, y, world)
local tile = shape(x, y, world)
if type(tile) ~= 'table' then
return tile
end
local decoratives = tile.decoratives
if not decoratives then
return tile
end
for d_index = #decoratives, 1, -1 do
local decorative_name = decoratives[d_index].name
for n_index = 1, #names do
if decorative_name == names[n_index] then
remove(decoratives, d_index)
end
end
end
return tile
end
end
--- Docs: https://github.com/Refactorio/RedMew/wiki/Using-the-Builders#buildersremove_map_gen_resources --- Docs: https://github.com/Refactorio/RedMew/wiki/Using-the-Builders#buildersremove_map_gen_resources
function Builders.remove_map_gen_resources(shape) function Builders.remove_map_gen_resources(shape)
return function(x, y, world) return function(x, y, world)
@ -1038,9 +1088,7 @@ function Builders.single_pattern_overlap(shape, width, height)
y = ((y + half_height) % height) - half_height y = ((y + half_height) % height) - half_height
x = ((x + half_width) % width) - half_width x = ((x + half_width) % width) - half_width
return shape(x, y, world) or shape(x + width, y, world) or shape(x - width, y, world) or return shape(x, y, world) or shape(x + width, y, world) or shape(x - width, y, world) or shape(x, y + height, world) or shape(x, y - height, world)
shape(x, y + height, world) or
shape(x, y - height, world)
end end
end end