From b7e36cc46a2a122f3452bc96aca0613cefa47ac6 Mon Sep 17 00:00:00 2001 From: grilledham Date: Mon, 6 Dec 2021 20:52:16 +0000 Subject: [PATCH] Add danger_ore_xmas_tree (#1260) --- .../config/one_direction_beltboxes_ores.lua | 2 +- .../one_direction_beltboxes_ores_xmas.lua | 74 +++++++ .../modules/main_ores_xmas_tree.lua | 162 ++++++++++++++ ...nger_ore_hub_spiral_beltboxes_ore_only.lua | 2 +- ...anger_ore_xmas_tree_beltboxes_ore_only.lua | 208 ++++++++++++++++++ .../map_selection.lua | 1 + 6 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 map_gen/maps/danger_ores/config/one_direction_beltboxes_ores_xmas.lua create mode 100644 map_gen/maps/danger_ores/modules/main_ores_xmas_tree.lua create mode 100644 map_gen/maps/danger_ores/presets/danger_ore_xmas_tree_beltboxes_ore_only.lua create mode 100644 scenario_templates/danger-ore-xmas-tree-beltboxes-ore-only/map_selection.lua diff --git a/map_gen/maps/danger_ores/config/one_direction_beltboxes_ores.lua b/map_gen/maps/danger_ores/config/one_direction_beltboxes_ores.lua index be7e1527..4194de6c 100644 --- a/map_gen/maps/danger_ores/config/one_direction_beltboxes_ores.lua +++ b/map_gen/maps/danger_ores/config/one_direction_beltboxes_ores.lua @@ -1,5 +1,5 @@ local b = require 'map_gen.shared.builders' -local start_value = b.euclidean_value(0, 0.35) +local start_value = b.exponential_value(0, 0.15, 1.3) local value = b.exponential_value(0, 0.15, 1.3) return { diff --git a/map_gen/maps/danger_ores/config/one_direction_beltboxes_ores_xmas.lua b/map_gen/maps/danger_ores/config/one_direction_beltboxes_ores_xmas.lua new file mode 100644 index 00000000..3348bdbb --- /dev/null +++ b/map_gen/maps/danger_ores/config/one_direction_beltboxes_ores_xmas.lua @@ -0,0 +1,74 @@ +local b = require 'map_gen.shared.builders' +local start_value = b.exponential_value(0, 0.15, 1.3) +local value = b.exponential_value(0, 0.15, 1.3) + +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 = b.resource(b.full_shape, 'iron-ore', value), weight = 15}, + {resource = b.resource(b.full_shape, 'copper-ore', value), weight = 70}, + {resource = b.resource(b.full_shape, 'stone', value), weight = 10}, + {resource = b.resource(b.full_shape, 'coal', value), weight = 5} + } + }, + { + name = 'coal', + ['tiles'] = { + [1] = 'dirt-1', + [2] = 'dirt-2', + [3] = 'dirt-3', + [4] = 'dirt-5', + [5] = 'dirt-6', + [6] = 'dirt-7' + }, + ['start'] = start_value, + ['weight'] = 1, + ['ratios'] = { + {resource = b.resource(b.full_shape, 'iron-ore', value), weight = 18}, + {resource = b.resource(b.full_shape, 'copper-ore', value), weight = 9}, + {resource = b.resource(b.full_shape, 'stone', value), weight = 8}, + {resource = b.resource(b.full_shape, 'coal', value), weight = 65} + } + }, + { + name = 'iron-ore', + ['tiles'] = { + [1] = 'grass-2', + [2] = 'grass-3', + [3] = 'grass-4' + }, + ['start'] = start_value, + ['weight'] = 1, + ['ratios'] = { + {resource = b.resource(b.full_shape, 'iron-ore', value), weight = 75}, + {resource = b.resource(b.full_shape, 'copper-ore', value), weight = 13}, + {resource = b.resource(b.full_shape, 'stone', value), weight = 7}, + {resource = b.resource(b.full_shape, 'coal', value), weight = 5} + } + }, + --[[ { + name = 'stone', + ['tiles'] = { + [1] = 'sand-1', + [2] = 'sand-2', + [3] = 'sand-3' + }, + ['start'] = start_value, + ['weight'] = 1, + ['ratios'] = { + {resource = b.resource(b.full_shape, 'iron-ore', value), weight = 25}, + {resource = b.resource(b.full_shape, 'copper-ore', value), weight = 10}, + {resource = b.resource(b.full_shape, 'stone', value), weight = 60}, + {resource = b.resource(b.full_shape, 'coal', value), weight = 5} + } + } ]] +} diff --git a/map_gen/maps/danger_ores/modules/main_ores_xmas_tree.lua b/map_gen/maps/danger_ores/modules/main_ores_xmas_tree.lua new file mode 100644 index 00000000..f35dd856 --- /dev/null +++ b/map_gen/maps/danger_ores/modules/main_ores_xmas_tree.lua @@ -0,0 +1,162 @@ +local Helper = require 'map_gen.maps.danger_ores.modules.helper' +local b = require 'map_gen.shared.builders' +local table = require 'utils.table' + +-- MAP SHAPE GENERATION +local gradient = 0.5 +local segment_height = 64 +local branch_gradient = 0.3 + +local baubel_1 = b.picture(require 'map_gen.data.presets.baubel_1') +baubel_1 = b.scale(baubel_1, 0.4) + +local baubel_2 = b.picture(require 'map_gen.data.presets.baubel_2') +baubel_2 = b.scale(baubel_2, 0.1) + +local baubel_3 = b.picture(require 'map_gen.data.presets.baubel_3') +baubel_3 = b.scale(baubel_3, 0.1) + +local baubel_4 = b.picture(require 'map_gen.data.presets.baubel_4') +baubel_4 = b.scale(baubel_4, 0.1) + +local star = b.picture(require 'map_gen.data.presets.star') +star = b.scale(star, 0.1) +star = b.change_tile(star, true, 'sand-1') +star = b.translate(star, 0, -70) + +return function(config) + local raw_spawn_shape = config.spawn_shape + local raw_start_ore_shape = config.start_ore_shape + 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, _, _, random_gen) + + local function tree(x, y) + local abs_x = math.abs(x) + local abs_y = math.abs(y) + return abs_x <= ((abs_y * gradient) + (branch_gradient * (abs_y % segment_height))) and y >= 0 + end + + tree = b.translate(tree, 0, -30) + tree = b.change_tile(tree, true, 'grass-2') + + local icons = {baubel_1, baubel_2, baubel_3, baubel_4} + + local icons_count = #icons + local value = b.euclidean_value + local ore_value = b.exponential_value(0, 0.3, 1.3) + + local function non_transform(shape) + return shape + end + + local function empty_transform() + return b.empty_shape + end + + local full_oil_shape = b.translate(b.throttle_xy(b.full_shape, 3, 6, 3, 6), -1, -1) + full_oil_shape = b.use_world_as_local(full_oil_shape) + local oil_shape = b.throttle_world_xy(b.full_shape, 1, 6, 1, 6) + + local ores = { + {transform = non_transform, resource = 'iron-ore', value = ore_value, weight = 10}, + {transform = non_transform, resource = 'copper-ore', value = ore_value, weight = 10}, + {transform = non_transform, resource = 'stone', value = ore_value, weight = 2}, + {transform = non_transform, resource = 'coal', value = ore_value, weight = 10}, + {transform = non_transform, resource = 'uranium-ore', value = value(100, 1.55), weight = 5}, + {transform = non_transform, resource = 'crude-oil', value = value(100000, 3500), weight = 15}, + {transform = empty_transform, weight = 100} + } + + local total_weights = {} + local t = 0 + for _, v in ipairs(ores) do + t = t + v.weight + table.insert(total_weights, t) + end + + local p_cols = 50 + local p_rows = 50 + local pattern = {} + + for _ = 1, p_rows do + local row = {} + table.insert(pattern, row) + for _ = 1, p_cols do + local shape = icons[random_gen(1, icons_count)] + + local i = random_gen(1, t) + local index = table.binary_search(total_weights, i) + if (index < 0) then + index = bit32.bnot(index) + end + + local ore_data = ores[index] + shape = ore_data.transform(shape) + + local x = random_gen(-24, 24) + local y = random_gen(-24, 24) + shape = b.translate(shape, x, y) + + local filter_shape = b.full_shape + if ore_data.resource == 'crude-oil' then + filter_shape = oil_shape + shape = b.all {shape, full_oil_shape} + end + + local ore = b.resource(filter_shape, ore_data.resource, ore_data.value) + + table.insert(row, b.apply_entity(shape, ore)) + end + end + + local ore_shape = b.project_pattern(pattern, 250, 1.0625, 50, 50) + ore_shape = b.scale(ore_shape, 0.1) + ore_shape = b.if_else(ore_shape, b.no_entity) + + local baubel_ore = b.choose(b.subtract(tree, raw_start_ore_shape), ore_shape, b.empty_shape) + + -- COMBINGING IT ALL + local sea = b.change_tile(b.full_shape, true, 'water') -- turn the void to water. + + local shapes = {} + + -- Move iron ore to middle. + main_ores = {main_ores[1], main_ores[3], main_ores[2]} + + 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 = shape, weight = ore_data.weight} + end + + local ore_weight = 3 + local additional_weight = 9.75 + local total_weight = ore_weight + additional_weight + local rotation = (0.25 - (ore_weight / total_weight / 2)) * 2 * math.pi + + shapes[#shapes + 1] = {shape = b.full_shape, weight = additional_weight} + + local ores_part = b.segment_weighted_pattern(shapes) + ores_part = b.rotate(ores_part, rotation) + + local main_ores_shape = b.any {raw_spawn_shape, ores_part} + main_ores_shape = b.choose(tree, main_ores_shape, b.empty_shape) + main_ores_shape = b.any {star, baubel_ore, main_ores_shape, sea} + main_ores_shape = b.change_map_gen_collision_tile(main_ores_shape, 'water-tile', 'grass-2') + + return main_ores_shape + end +end diff --git a/map_gen/maps/danger_ores/presets/danger_ore_hub_spiral_beltboxes_ore_only.lua b/map_gen/maps/danger_ores/presets/danger_ore_hub_spiral_beltboxes_ore_only.lua index bc1e9be7..1f42fa83 100644 --- a/map_gen/maps/danger_ores/presets/danger_ore_hub_spiral_beltboxes_ore_only.lua +++ b/map_gen/maps/danger_ores/presets/danger_ore_hub_spiral_beltboxes_ore_only.lua @@ -63,7 +63,7 @@ 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.vanilla_allowed_entities' +local allowed_entities = require 'map_gen.maps.danger_ores.config.deadlock_betlboxes_allowed_entities' banned_entities(allowed_entities) RS.set_map_gen_settings( diff --git a/map_gen/maps/danger_ores/presets/danger_ore_xmas_tree_beltboxes_ore_only.lua b/map_gen/maps/danger_ores/presets/danger_ore_xmas_tree_beltboxes_ore_only.lua new file mode 100644 index 00000000..0e1a63ec --- /dev/null +++ b/map_gen/maps/danger_ores/presets/danger_ore_xmas_tree_beltboxes_ore_only.lua @@ -0,0 +1,208 @@ +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 Christmas Tree Deadlock Beltboxes (ore only)') +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. +]]) + +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.one_direction_beltboxes_ores_xmas' +--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_betlboxes_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 +Config.day_night.enabled = true +Config.day_night.use_fixed_brightness = true +Config.day_night.fixed_brightness = 0.70 + +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['landfill'].enabled = false + + game.difficulty_settings.technology_price_multiplier = 25 + game.forces.player.technologies.logistics.researched = true + game.forces.player.technologies.automation.researched = true + + 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.forces.player.manual_mining_speed_modifier = 1 + + --RS.get_surface().always_day = true + RS.get_surface().peaceful_mode = true + end +) + +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-uranium-ore"] = true, + ["deadlock-stacks-unstack-uranium-ore"] = true +} + +Event.add(defines.events.on_research_finished, function(event) + local research = event.research + if not research.valid then + return + end + + for _, effect in pairs(research.effects) do + if effect.type ~= 'unlock-recipe' then + goto continue + end + + local name = effect.recipe + if allowed_recipes[name] then + goto continue + end + + if name:sub(1, #'deadlock-stacks') == 'deadlock-stacks' then + game.forces.player.recipes[name].enabled = false + end + + ::continue:: + end +end) + +local terraforming = require 'map_gen.maps.danger_ores.modules.terraforming' +terraforming({start_size = 12 * 32, min_pollution = 250, max_pollution = 16000, pollution_increment = 6}) + +local rocket_launched = require 'map_gen.maps.danger_ores.modules.rocket_launched_simple' +rocket_launched({win_satellite_count = 500}) + +local restart_command = require 'map_gen.maps.danger_ores.modules.restart_command' +restart_command({scenario_name = 'danger-ore-xmas-tree-beltboxes-ore-only'}) + +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 main_ores_builder = require 'map_gen.maps.danger_ores.modules.main_ores_xmas_tree' + +--local sqrt = math.sqrt + +local config = { + spawn_shape = b.circle(72), + start_ore_shape = b.circle(76), + main_ores_builder = main_ores_builder, + main_ores = main_ores_config, + main_ores_shuffle_order = true, + --main_ores_rotate = 45, + --resource_patches = resource_patches, + --resource_patches_config = resource_patches_config, + --water = water, + --[[water_scale = function(x, y) + local d = sqrt(x * x + y * y) + return 1 / (24 + (0.1 * d)) + end,]] + --water_threshold = 0.35, + --deepwater_threshold = 0.4, + trees = trees, + trees_scale = 1 / 64, + trees_threshold = 0.35, + trees_chance = 0.875, + enemy = enemy, + enemy_factor = 10 / (768 * 32), + enemy_max_chance = 1 / 6, + enemy_scale_factor = 32, + fish_spawn_rate = 0.00625, + --dense_patches = dense_patches, + dense_patches_scale = 1 / 48, + dense_patches_threshold = 0.55, + dense_patches_multiplier = 50 +} + +return map(config) diff --git a/scenario_templates/danger-ore-xmas-tree-beltboxes-ore-only/map_selection.lua b/scenario_templates/danger-ore-xmas-tree-beltboxes-ore-only/map_selection.lua new file mode 100644 index 00000000..6e0feebb --- /dev/null +++ b/scenario_templates/danger-ore-xmas-tree-beltboxes-ore-only/map_selection.lua @@ -0,0 +1 @@ +return require 'map_gen.maps.danger_ores.presets.danger_ore_xmas_tree_beltboxes_ore_only' \ No newline at end of file