Skip to content

Commit 864b5dd

Browse files
authored
Merge pull request #1214 from Soggs/master
Added a Circles preset for Danger Ores.
2 parents f4b2ba7 + 2c61140 commit 864b5dd

File tree

3 files changed

+220
-0
lines changed

3 files changed

+220
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
local Helper = require 'map_gen.maps.danger_ores.modules.helper'
2+
local b = require 'map_gen.shared.builders'
3+
local table = require 'utils.table'
4+
5+
local binary_search = table.binary_search
6+
local bnot = bit32.bnot
7+
local sqrt = math.sqrt
8+
local floor = math.floor
9+
local value = b.manhattan_value
10+
11+
return function(config)
12+
local main_ores = config.main_ores
13+
local main_ores_split_count = config.main_ores_split_count or 1
14+
local start_ore_shape = config.start_ore_shape
15+
16+
main_ores = Helper.split_ore(main_ores, main_ores_split_count)
17+
18+
if config.main_ores_shuffle_order then
19+
table.shuffle_table(main_ores)
20+
end
21+
22+
local function condition_factory(ore_name)
23+
local scale = config.circle_scale or 1
24+
--local randomize_scale = config.randomize_scale or false
25+
local ore_table = {}
26+
for _, ore_data in pairs(main_ores) do
27+
table.insert(ore_table, {name = ore_data.name, weight = ore_data.weight})
28+
end
29+
local weighted = b.prepare_weighted_array(ore_table)
30+
return function(x, y, _)
31+
local i = floor(sqrt(x * x + y * y) * scale) % weighted.total + 1
32+
local index = binary_search(weighted, i)
33+
if index < 0 then
34+
index = bnot(index)
35+
end
36+
return ore_table[index].name == ore_name
37+
end
38+
end
39+
40+
return function(tile_builder, ore_builder, spawn_shape, water_shape, _)
41+
42+
local shapes = {}
43+
local starting_ores_list = {}
44+
for _, ore_data in pairs(main_ores) do
45+
local ore_name = ore_data.name
46+
local tiles = ore_data.tiles
47+
local land = tile_builder(tiles)
48+
49+
table.insert(starting_ores_list, b.resource(start_ore_shape, ore_name, value(100, 0)))
50+
51+
local ratios = ore_data.ratios
52+
local weighted = b.prepare_weighted_array(ratios)
53+
local amount = ore_data.start
54+
55+
local ore = ore_builder(ore_name, amount, ratios, weighted)
56+
local condition = condition_factory(ore_name)
57+
local shape = b.choose(condition, b.apply_entity(land, ore), b.empty_shape)
58+
table.insert(shapes, shape)
59+
end
60+
61+
local ores = b.any(shapes)
62+
63+
local starting_ores = b.change_map_gen_collision_tile(start_ore_shape, 'water-tile', 'grass-1')
64+
starting_ores = b.apply_entity(starting_ores, b.segment_pattern(starting_ores_list))
65+
66+
return b.any {spawn_shape, starting_ores ,water_shape, ores}
67+
end
68+
end
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
local RS = require 'map_gen.shared.redmew_surface'
2+
local MGSP = require 'resources.map_gen_settings'
3+
local Event = require 'utils.event'
4+
local b = require 'map_gen.shared.builders'
5+
local Config = require 'config'
6+
7+
local ScenarioInfo = require 'features.gui.info'
8+
ScenarioInfo.set_map_name('Danger Ore Circles')
9+
ScenarioInfo.set_map_description([[
10+
Clear the ore to expand the base,
11+
focus mining efforts on specific sectors to ensure
12+
proper material ratios, expand the map with pollution!
13+
]])
14+
ScenarioInfo.add_map_extra_info([[
15+
This map is split in three sectors [item=iron-ore] [item=copper-ore] [item=coal].
16+
Each sector has a main resource and the other resources at a lower ratio.
17+
18+
You may not build the factory on ore patches. Exceptions:
19+
[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]
20+
[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]
21+
22+
The map size is restricted to the pollution generated. A significant amount of
23+
pollution must affect a section of the map before it is revealed. Pollution
24+
does not affect biter evolution.]])
25+
26+
ScenarioInfo.set_new_info([[
27+
2019-04-24:
28+
- Stone ore density reduced by 1/2
29+
- Ore quadrants randomized
30+
- Increased time factor of biter evolution from 5 to 7
31+
- Added win conditions (+5% evolution every 5 rockets until 100%, +100 rockets until biters are wiped)
32+
33+
2019-03-30:
34+
- Uranium ore patch threshold increased slightly
35+
- Bug fix: Cars and tanks can now be placed onto ore!
36+
- Starting minimum pollution to expand map set to 650
37+
View current pollution via Debug Settings [F4] show-pollution-values,
38+
then open map and turn on pollution via the red box.
39+
- Starting water at spawn increased from radius 8 to radius 16 circle.
40+
41+
2019-03-27:
42+
- Ore arranged into quadrants to allow for more controlled resource gathering.
43+
44+
2020-09-02:
45+
- Destroyed chests dump their content as coal ore.
46+
47+
2020-12-28:
48+
- Changed win condition. First satellite kills all biters, launch 500 to win the map.
49+
50+
2021-04-06:
51+
- Rail signals and train stations now allowed on ore.
52+
]])
53+
54+
local map = require 'map_gen.maps.danger_ores.modules.map'
55+
local main_ores_config = require 'map_gen.maps.danger_ores.config.vanilla_ores'
56+
local resource_patches = require 'map_gen.maps.danger_ores.modules.resource_patches'
57+
local resource_patches_config = require 'map_gen.maps.danger_ores.config.vanilla_resource_patches'
58+
local water = require 'map_gen.maps.danger_ores.modules.water'
59+
local trees = require 'map_gen.maps.danger_ores.modules.trees'
60+
local enemy = require 'map_gen.maps.danger_ores.modules.enemy'
61+
local dense_patches = require 'map_gen.maps.danger_ores.modules.dense_patches'
62+
63+
local banned_entities = require 'map_gen.maps.danger_ores.modules.banned_entities'
64+
local allowed_entities = require 'map_gen.maps.danger_ores.config.vanilla_allowed_entities'
65+
banned_entities(allowed_entities)
66+
67+
RS.set_map_gen_settings({
68+
MGSP.grass_only,
69+
MGSP.enable_water,
70+
{terrain_segmentation = 'normal', water = 'normal'},
71+
MGSP.starting_area_very_low,
72+
MGSP.ore_oil_none,
73+
MGSP.enemy_none,
74+
MGSP.cliff_none,
75+
MGSP.tree_none
76+
})
77+
78+
Config.market.enabled = false
79+
Config.player_rewards.enabled = false
80+
Config.player_create.starting_items = {}
81+
Config.dump_offline_inventories = {
82+
enabled = true,
83+
offline_timout_mins = 30, -- time after which a player logs off that their inventory is provided to the team
84+
}
85+
Config.paint.enabled = false
86+
87+
Event.on_init(function()
88+
game.draw_resource_selection = false
89+
game.forces.player.technologies['mining-productivity-1'].enabled = false
90+
game.forces.player.technologies['mining-productivity-2'].enabled = false
91+
game.forces.player.technologies['mining-productivity-3'].enabled = false
92+
game.forces.player.technologies['mining-productivity-4'].enabled = false
93+
94+
game.difficulty_settings.technology_price_multiplier = 25
95+
game.forces.player.technologies.logistics.researched = true
96+
game.forces.player.technologies.automation.researched = true
97+
98+
game.map_settings.enemy_evolution.time_factor = 0.000007 -- default 0.000004
99+
game.map_settings.enemy_evolution.destroy_factor = 0.000010 -- default 0.002
100+
game.map_settings.enemy_evolution.pollution_factor = 0.000000 -- Pollution has no affect on evolution default 0.0000009
101+
102+
RS.get_surface().always_day = true
103+
end)
104+
105+
local terraforming = require 'map_gen.maps.danger_ores.modules.terraforming'
106+
terraforming({start_size = 8 * 32, min_pollution = 400, max_pollution = 16000, pollution_increment = 4})
107+
108+
local rocket_launched = require 'map_gen.maps.danger_ores.modules.rocket_launched_simple'
109+
rocket_launched({win_satellite_count = 500})
110+
111+
local restart_command = require 'map_gen.maps.danger_ores.modules.restart_command'
112+
restart_command({scenario_name = 'danger-ore-gradient'})
113+
114+
local container_dump = require 'map_gen.maps.danger_ores.modules.container_dump'
115+
container_dump({entity_name = 'coal'})
116+
117+
local concrete_on_landfill = require 'map_gen.maps.danger_ores.modules.concrete_on_landfill'
118+
concrete_on_landfill({tile = 'blue-refined-concrete'})
119+
120+
local main_ores_builder = require 'map_gen.maps.danger_ores.modules.main_ores_circles'
121+
122+
local config = {
123+
spawn_shape = b.circle(64),
124+
start_ore_shape = b.circle(68),
125+
main_ores_builder = main_ores_builder,
126+
main_ores = main_ores_config,
127+
main_ores_shuffle_order = true,
128+
main_ores_rotate = 0,
129+
resource_patches = resource_patches,
130+
resource_patches_config = resource_patches_config,
131+
water = water,
132+
water_scale = 1 / 96,
133+
water_threshold = 0.45,
134+
deepwater_threshold = 0.5,
135+
trees = trees,
136+
trees_scale = 1 / 64,
137+
trees_threshold = 0.4,
138+
trees_chance = 0.875,
139+
enemy = enemy,
140+
enemy_factor = 10 / (768 * 32),
141+
enemy_max_chance = 1 / 6,
142+
enemy_scale_factor = 32,
143+
fish_spawn_rate = 0.025,
144+
dense_patches = dense_patches,
145+
dense_patches_scale = 1 / 48,
146+
dense_patches_threshold = 0.55,
147+
dense_patches_multiplier = 25,
148+
circle_scale = 1/16 -- regulates the width of each circle
149+
}
150+
151+
return map(config)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
return require 'map_gen.maps.danger_ores.presets.danger_ore_circles'

0 commit comments

Comments
 (0)