1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-02-03 13:11:21 +02:00

Add Poor man's coal fields danger ore map. (#1363)

This commit is contained in:
grilledham 2023-05-14 20:31:04 +01:00 committed by GitHub
parent bc83f8870d
commit 2f169ee28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 461 additions and 18 deletions

View File

@ -0,0 +1,141 @@
local b = require 'map_gen.shared.builders'
local start_value = b.euclidean_value(0, 0.35)
local value = b.exponential_value(0, 0.06, 1.55)
local function resource(primary_ore, secondary_ore)
return function(_, _, world)
local v = value(world.x, world.y)
local ore
if v > 1500 then
ore = primary_ore
else
ore = secondary_ore
end
return {
name = ore,
amount = v
}
end
end
return {
{
name = 'copper-ore',
['tiles'] = {
[1] = 'red-desert-0',
[2] = 'red-desert-1',
[3] = 'red-desert-2',
[4] = 'red-desert-3'
},
['start'] = start_value,
['weight'] = 1,
['ratios'] = {
{
resource = resource('copper-ore', 'iron-ore'),
weight = 15
},
{
resource = resource('copper-ore', 'copper-ore'),
weight = 70
},
{
resource = resource('copper-ore', 'stone'),
weight = 10
},
{
resource = resource('copper-ore', 'coal'),
weight = 5
}
}
},
{
name = 'coal',
['tiles'] = {
[1] = 'dirt-1',
[2] = 'dirt-2',
[3] = 'dirt-3',
[4] = 'dirt-4',
[5] = 'dirt-5',
[6] = 'dirt-6',
[7] = 'dirt-7'
},
['start'] = start_value,
['weight'] = 1,
['ratios'] = {
{
resource = resource('coal', 'iron-ore'),
weight = 14
},
{
resource = resource('coal', 'copper-ore'),
weight = 6
},
{
resource = resource('coal', 'stone'),
weight = 10
},
{
resource = resource('coal', 'coal'),
weight = 70
}
}
},
{
name = 'iron-ore',
['tiles'] = {
[1] = 'grass-1',
[2] = 'grass-2',
[3] = 'grass-3',
[4] = 'grass-4'
},
['start'] = start_value,
['weight'] = 1,
['ratios'] = {
{
resource = resource('iron-ore', 'iron-ore'),
weight = 75
},
{
resource = resource('iron-ore', 'copper-ore'),
weight = 13
},
{
resource = resource('iron-ore', 'stone'),
weight = 7
},
{
resource = resource('iron-ore', 'coal'),
weight = 5
}
}
},
{
name = 'stone',
['tiles'] = {
[1] = 'sand-1',
[2] = 'sand-2',
[3] = 'sand-3'
},
['start'] = start_value,
['weight'] = 1,
['ratios'] = {
{
resource = resource('stone', 'iron-ore'),
weight = 25
},
{
resource = resource('stone', 'copper-ore'),
weight = 10
},
{
resource = resource('stone', 'stone'),
weight = 60
},
{
resource = resource('stone', 'coal'),
weight = 5
}
}
}
}

View File

@ -0,0 +1,77 @@
local Helper = require 'map_gen.maps.danger_ores.modules.helper'
local b = require 'map_gen.shared.builders'
return function(config)
local main_ores = config.main_ores
local main_ores_split_count = config.main_ores_split_count or 1
main_ores = Helper.split_ore(main_ores, main_ores_split_count)
return function(tile_builder, ore_builder, spawn_shape, water_shape)
local shapes = {}
for _, ore_data in pairs(main_ores) do
local ore_name = ore_data.name
local tiles = ore_data.tiles
local land = tile_builder(tiles)
local ratios = ore_data.ratios
local weighted = b.prepare_weighted_array(ratios)
local amount = ore_data.start
local ore = ore_builder(ore_name, amount, ratios, weighted)
local shape = b.apply_entity(land, ore)
shapes[#shapes + 1] = shape
end
local copper_shape = shapes[1]
local coal_shape = shapes[2]
local iron_shape = shapes[3]
local stone_shape = shapes[4]
local function iron_bounds(x, y)
return x < 0 and y < 0
end
local function copper_bounds(x, y)
return x >= 0 and y < 0
end
local function coal_bounds(_, y)
return y >= 0
end
local h_water_bounds = b.line_x(3)
local v_water_bounds = b.translate(b.line_y(3), -1, 0)
local water_bounds = b.add(h_water_bounds, v_water_bounds)
local water_sector = b.change_tile(water_bounds, true, 'water-shallow')
local h_stone_bounds = b.line_x(7)
local function v_stone_bounds(x, y)
return x > -4 and x < 3 and y < 0
end
local stone_bounds = b.add(h_stone_bounds, v_stone_bounds)
local iron_sector = b.choose(iron_bounds, iron_shape, b.empty_shape)
local copper_sector = b.choose(copper_bounds, copper_shape, b.empty_shape)
local coal_sector = b.choose(coal_bounds, coal_shape, b.empty_shape)
local stone_sector = b.choose(stone_bounds, stone_shape, b.empty_shape)
local ores = b.any({
water_sector,
stone_sector,
iron_sector,
copper_sector,
coal_sector
})
local main_ores_shape = b.any {
spawn_shape,
water_shape,
ores
}
return main_ores_shape
end
end

View File

@ -17,9 +17,10 @@ local bnot = bit32.bnot
local function spawn_builder(config)
local spawn_circle = config.spawn_shape or b.circle(64)
local spawn_tile = config.spawn_tile or 'grass-1'
local spawn_water_tile = config.spawn_water_tile or 'water'
local water = b.circle(14)
water = b.change_tile(water, true, 'water')
water = b.change_tile(water, true, spawn_water_tile)
water = b.any {b.rectangle(32, 4), b.rectangle(4, 32), water}
local start = b.if_else(water, spawn_circle)

View File

@ -47,7 +47,7 @@ local maps = {
{
name = 'danger-ore-square-beltboxes-ore-only',
mod_pack = normal_mod_pack,
display_name = 'Square (corner start)'
display_name = 'square (corner start)'
},
{
name = 'danger-ore-chessboard-beltboxes-ore-only',
@ -94,6 +94,11 @@ local maps = {
mod_pack = normal_mod_pack,
display_name = 'patches (ore islands in coal)'
},
--[[ {
name = 'danger_ore_poor_mans_coal_fields',
mod_pack = normal_mod_pack,
display_name = 'poor man\'s coal fields (Alex Gaming\'s map)'
}, ]]
{
name = 'danger-ore-xmas-tree-beltboxes-ore-only',
mod_pack = normal_mod_pack,

View File

@ -3,7 +3,7 @@ local Event = require 'utils.event'
local Token = require 'utils.token'
local Task = require 'utils.task'
local allowed_recipes = {
local default_allowed_recipes = {
['deadlock-stacks-stack-iron-ore'] = true,
['deadlock-stacks-unstack-iron-ore'] = true,
['deadlock-stacks-stack-copper-ore'] = true,
@ -20,22 +20,9 @@ local function is_deadlock_stacks_recipe(name)
return name:sub(1, #'deadlock-stacks') == 'deadlock-stacks'
end
local disable_recipes_callback = Token.register(function()
local recipes = game.forces['player'].recipes
for name, recipe in pairs(recipes) do
if allowed_recipes[name] then
goto continue
end
return function(config_allowed_recipes)
local allowed_recipes = config_allowed_recipes or default_allowed_recipes
if is_deadlock_stacks_recipe(name) then
recipe.enabled = false
end
::continue::
end
end)
return function()
Event.add(defines.events.on_research_finished, function(event)
local research = event.research
if not research.valid then
@ -60,6 +47,21 @@ return function()
end
end)
local disable_recipes_callback = Token.register(function()
local recipes = game.forces['player'].recipes
for name, recipe in pairs(recipes) do
if allowed_recipes[name] then
goto continue
end
if is_deadlock_stacks_recipe(name) then
recipe.enabled = false
end
::continue::
end
end)
Event.on_configuration_changed(function()
Task.set_timeout_in_ticks(1, disable_recipes_callback)
end)

View File

@ -0,0 +1,216 @@
local RS = require 'map_gen.shared.redmew_surface'
local MGSP = require 'resources.map_gen_settings'
local Event = require 'utils.event'
local b = require 'map_gen.shared.builders'
local Config = require 'config'
local ScenarioInfo = require 'features.gui.info'
ScenarioInfo.set_map_name('Danger Ore Poor man\'s coal fields')
ScenarioInfo.set_map_description([[
Clear the ore to expand the base,
focus mining efforts on specific sectors to ensure
proper material ratios, expand the map with pollution!
]])
ScenarioInfo.add_map_extra_info([[
This map is split in three sectors [item=iron-ore] [item=copper-ore] [item=coal].
Each sector has a main resource and the other resources at a lower ratio.
You may not build the factory on ore patches. Exceptions:
[item=burner-mining-drill] [item=electric-mining-drill] [item=pumpjack] [item=small-electric-pole] [item=medium-electric-pole] [item=big-electric-pole] [item=substation] [item=car] [item=tank] [item=spidertron] [item=locomotive] [item=cargo-wagon] [item=fluid-wagon] [item=artillery-wagon]
[item=transport-belt] [item=fast-transport-belt] [item=express-transport-belt] [item=underground-belt] [item=fast-underground-belt] [item=express-underground-belt] [item=rail] [item=rail-signal] [item=rail-chain-signal] [item=train-stop]
The map size is restricted to the pollution generated. A significant amount of
pollution must affect a section of the map before it is revealed. Pollution
does not affect biter evolution.]])
ScenarioInfo.set_new_info([[
2019-04-24:
- Stone ore density reduced by 1/2
- Ore quadrants randomized
- Increased time factor of biter evolution from 5 to 7
- Added win conditions (+5% evolution every 5 rockets until 100%, +100 rockets until biters are wiped)
2019-03-30:
- Uranium ore patch threshold increased slightly
- Bug fix: Cars and tanks can now be placed onto ore!
- Starting minimum pollution to expand map set to 650
View current pollution via Debug Settings [F4] show-pollution-values,
then open map and turn on pollution via the red box.
- Starting water at spawn increased from radius 8 to radius 16 circle.
2019-03-27:
- Ore arranged into quadrants to allow for more controlled resource gathering.
2020-09-02:
- Destroyed chests dump their content as coal ore.
2020-12-28:
- Changed win condition. First satellite kills all biters, launch 500 to win the map.
2021-04-06:
- Rail signals and train stations now allowed on ore.
]])
ScenarioInfo.add_extra_rule({
'info.rules_text_danger_ore'
})
global.config.redmew_qol.loaders = false
local map = require 'map_gen.maps.danger_ores.modules.map'
local main_ores_config = require 'map_gen.maps.danger_ores.config.poor_mans_coal_fields_ores'
-- local resource_patches = require 'map_gen.maps.danger_ores.modules.resource_patches'
-- local resource_patches_config = require 'map_gen.maps.danger_ores.config.deadlock_beltboxes_resource_patches'
local water = require 'map_gen.maps.danger_ores.modules.water'
local trees = require 'map_gen.maps.danger_ores.modules.trees'
local enemy = require 'map_gen.maps.danger_ores.modules.enemy'
-- local dense_patches = require 'map_gen.maps.danger_ores.modules.dense_patches'
local banned_entities = require 'map_gen.maps.danger_ores.modules.banned_entities'
local allowed_entities = require 'map_gen.maps.danger_ores.config.deadlock_beltboxes_allowed_entities'
banned_entities(allowed_entities)
RS.set_map_gen_settings({
MGSP.grass_only,
MGSP.enable_water,
{
terrain_segmentation = 'normal',
water = 'normal'
},
MGSP.starting_area_very_low,
MGSP.ore_oil_none,
MGSP.enemy_none,
MGSP.cliff_none,
MGSP.tree_none
})
Config.market.enabled = false
Config.player_rewards.enabled = false
Config.player_create.starting_items = {}
Config.dump_offline_inventories = {
enabled = true,
offline_timout_mins = 30 -- time after which a player logs off that their inventory is provided to the team
}
Config.paint.enabled = false
Event.on_init(function()
-- game.draw_resource_selection = false
game.forces.player.technologies['mining-productivity-1'].enabled = false
game.forces.player.technologies['mining-productivity-2'].enabled = false
game.forces.player.technologies['mining-productivity-3'].enabled = false
game.forces.player.technologies['mining-productivity-4'].enabled = false
game.forces.player.technologies['atomic-bomb'].enabled = false
game.forces.player.technologies['cliff-explosives'].enabled = false
game.forces.player.technologies['railway'].enabled = false
game.difficulty_settings.recipe_difficulty = defines.difficulty_settings.recipe_difficulty.expensive
game.difficulty_settings.technology_difficulty = defines.difficulty_settings.technology_difficulty.expensive
game.difficulty_settings.technology_price_multiplier = 6
game.forces.player.technologies.logistics.researched = true
game.forces.player.technologies.automation.researched = true
-- game.forces.player.technologies['logistic-system'].enabled = false
-- game.forces.player.technologies['warehouse-logistics-research-2'].enabled = false
game.map_settings.enemy_evolution.time_factor = 0.000007 -- default 0.000004
game.map_settings.enemy_evolution.destroy_factor = 0.000010 -- default 0.002
game.map_settings.enemy_evolution.pollution_factor = 0.000000 -- Pollution has no affect on evolution default 0.0000009
game.map_settings.pollution.pollution_per_tree_damage = 0
game.map_settings.pollution.pollution_restored_per_tree_damage = 0
game.forces.player.manual_mining_speed_modifier = 1
RS.get_surface().always_day = true
RS.get_surface().peaceful_mode = true
end)
local terraforming = require 'map_gen.maps.danger_ores.modules.terraforming'
terraforming({
start_size = 8 * 32,
min_pollution = 600,
max_pollution = 24000,
pollution_increment = 9
})
local rocket_launched = require 'map_gen.maps.danger_ores.modules.rocket_launched_simple'
rocket_launched({
win_satellite_count = 300
})
local restart_command = require 'map_gen.maps.danger_ores.modules.restart_command'
restart_command({
scenario_name = 'danger-ore-poor-mans-coal-fields'
})
local container_dump = require 'map_gen.maps.danger_ores.modules.container_dump'
container_dump({
entity_name = 'coal'
})
local concrete_on_landfill = require 'map_gen.maps.danger_ores.modules.concrete_on_landfill'
concrete_on_landfill({
tile = 'blue-refined-concrete'
})
local remove_non_ore_stacked_recipes = require 'map_gen.maps.danger_ores.modules.remove_non_ore_stacked_recipes'
local allowed_recipes = {
['deadlock-stacks-stack-iron-ore'] = true,
['deadlock-stacks-unstack-iron-ore'] = true,
['deadlock-stacks-stack-copper-ore'] = true,
['deadlock-stacks-unstack-copper-ore'] = true,
['deadlock-stacks-stack-stone'] = true,
['deadlock-stacks-unstack-stone'] = true,
['deadlock-stacks-stack-coal'] = true,
['deadlock-stacks-unstack-coal'] = true,
['deadlock-stacks-stack-iron-plate'] = true,
['deadlock-stacks-unstack-iron-plate'] = true,
['deadlock-stacks-stack-copper-plate'] = true,
['deadlock-stacks-unstack-copper-plate'] = true,
-- ['deadlock-stacks-stack-steel-plate'] = true,
-- ['deadlock-stacks-unstack-steel-plate'] = true,
-- ['deadlock-stacks-stack-iron-gear-wheel'] = true,
-- ['deadlock-stacks-unstack-iron-gear-wheel'] = true,
['deadlock-stacks-stack-electronic-circuit'] = true,
['deadlock-stacks-unstack-electronic-circuit'] = true
}
remove_non_ore_stacked_recipes(allowed_recipes)
require 'map_gen.maps.danger_ores.modules.biter_drops'
require 'map_gen.maps.danger_ores.modules.map_poll'
local main_ores_builder = require 'map_gen.maps.danger_ores.modules.main_ores_poor_mans_coal_fields'
local config = {
-- spawn_shape = b.circle(36),
-- start_ore_shape = b.circle(44),
spawn_shape = b.rectangle(32 * 3),
start_ore_shape = b.rectangle(32 * 3 + 15),
spawn_water_tile = 'water-shallow',
no_resource_patch_shape = b.circle(80),
main_ores_builder = main_ores_builder,
main_ores = main_ores_config,
main_ores_shuffle_order = true,
main_ores_rotate = 30,
-- resource_patches = resource_patches,
-- resource_patches_config = resource_patches_config,
water = water,
water_scale = 1 / 96,
water_threshold = 0.4,
deepwater_threshold = 0.45,
trees = trees,
trees_scale = 1 / 64,
trees_threshold = 0.4,
trees_chance = 0.875,
enemy = enemy,
enemy_factor = 10 / (768 * 32),
enemy_max_chance = 1 / 6,
enemy_scale_factor = 32,
fish_spawn_rate = 0.025,
-- dense_patches = dense_patches,
dense_patches_scale = 1 / 48,
dense_patches_threshold = 0.55,
dense_patches_multiplier = 25
}
return map(config)

View File

@ -0,0 +1 @@
return require 'map_gen.maps.danger_ores.presets.danger_ore_poor_mans_coal_fields'