Skip to content

Commit 5cad7d7

Browse files
authored
Merge pull request #1206 from grilledham/danger_ore_chess
Danger ore chessboard.
2 parents 77ffcd6 + 0fded5f commit 5cad7d7

File tree

5 files changed

+219
-1
lines changed

5 files changed

+219
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
local b = require 'map_gen.shared.builders'
2+
3+
return function(config)
4+
local main_ores = config.main_ores
5+
local shuffle_order = config.main_ores_shuffle_order
6+
7+
return function(tile_builder, ore_builder, spawn_shape, water_shape, random_gen)
8+
local grid_tile_size = 64
9+
10+
local shapes = {}
11+
for _, ore_data in pairs(main_ores) do
12+
local ore_name = ore_data.name
13+
local tiles = ore_data.tiles
14+
local land = tile_builder(tiles)
15+
16+
local ratios = ore_data.ratios
17+
local weighted = b.prepare_weighted_array(ratios)
18+
local amount = ore_data.start
19+
20+
local ore = ore_builder(ore_name, amount, ratios, weighted)
21+
22+
local shape = b.apply_entity(land, ore)
23+
shapes[#shapes + 1] = shape
24+
end
25+
26+
local count = #shapes
27+
28+
local pattern = {}
29+
for r = 1, count do
30+
local row = {}
31+
pattern[r] = row
32+
for c = 1, count do
33+
local index = (c - r) % count + 1
34+
row[c] = shapes[index]
35+
end
36+
end
37+
local ores = b.grid_pattern_no_offset(pattern, count, count, grid_tile_size, grid_tile_size)
38+
39+
if shuffle_order then
40+
local outer_pattern = {}
41+
for r = 1, 50 do
42+
local row = {}
43+
outer_pattern[r] = row
44+
for c = 1, 50 do
45+
local index = random_gen(count)
46+
row[c] = shapes[index]
47+
end
48+
end
49+
50+
local outer_ores = b.grid_pattern_no_offset(outer_pattern, 50, 50, grid_tile_size, grid_tile_size)
51+
52+
local start_size = grid_tile_size * 3
53+
ores = b.choose(b.rectangle(start_size), ores, outer_ores)
54+
end
55+
56+
return b.any {spawn_shape, water_shape, ores}
57+
end
58+
end
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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 Chessboard')
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+
86+
Event.on_init(function()
87+
game.draw_resource_selection = false
88+
game.forces.player.technologies['mining-productivity-1'].enabled = false
89+
game.forces.player.technologies['mining-productivity-2'].enabled = false
90+
game.forces.player.technologies['mining-productivity-3'].enabled = false
91+
game.forces.player.technologies['mining-productivity-4'].enabled = false
92+
93+
game.difficulty_settings.technology_price_multiplier = 25
94+
game.forces.player.technologies.logistics.researched = true
95+
game.forces.player.technologies.automation.researched = true
96+
97+
game.map_settings.enemy_evolution.time_factor = 0.000007 -- default 0.000004
98+
game.map_settings.enemy_evolution.destroy_factor = 0.000010 -- default 0.002
99+
game.map_settings.enemy_evolution.pollution_factor = 0.000000 -- Pollution has no affect on evolution default 0.0000009
100+
101+
RS.get_surface().always_day = true
102+
end)
103+
104+
local terraforming = require 'map_gen.maps.danger_ores.modules.terraforming'
105+
terraforming({start_size = 8 * 32, min_pollution = 400, max_pollution = 16000, pollution_increment = 4})
106+
107+
local rocket_launched = require 'map_gen.maps.danger_ores.modules.rocket_launched_simple'
108+
rocket_launched({win_satellite_count = 500})
109+
110+
local restart_command = require 'map_gen.maps.danger_ores.modules.restart_command'
111+
restart_command({scenario_name = 'danger-ore-next'})
112+
113+
local container_dump = require 'map_gen.maps.danger_ores.modules.container_dump'
114+
container_dump({entity_name = 'coal'})
115+
116+
local main_ores_builder = require 'map_gen.maps.danger_ores.modules.main_ores_chessboard'
117+
118+
local config = {
119+
spawn_shape = b.circle(64),
120+
start_ore_shape = b.circle(68),
121+
main_ores_builder = main_ores_builder,
122+
main_ores = main_ores_config,
123+
main_ores_shuffle_order = true,
124+
resource_patches = resource_patches,
125+
resource_patches_config = resource_patches_config,
126+
water = water,
127+
water_scale = 1 / 96,
128+
water_threshold = 0.4,
129+
deepwater_threshold = 0.45,
130+
trees = trees,
131+
trees_scale = 1 / 64,
132+
trees_threshold = 0.4,
133+
trees_chance = 0.875,
134+
enemy = enemy,
135+
enemy_factor = 10 / (768 * 32),
136+
enemy_max_chance = 1 / 6,
137+
enemy_scale_factor = 32,
138+
fish_spawn_rate = 0.025,
139+
dense_patches = dense_patches,
140+
dense_patches_scale = 1 / 48,
141+
dense_patches_threshold = 0.55,
142+
dense_patches_multiplier = 25
143+
}
144+
145+
return map(config)

map_gen/shared/builders.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,20 @@ function Builders.grid_pattern(pattern, columns, rows, width, height)
11841184
end
11851185
end
11861186

1187+
function Builders.grid_pattern_no_offset(pattern, columns, rows, width, height)
1188+
return function(x, y, world)
1189+
local row_pos = floor(y / height + 0.5)
1190+
local row_i = row_pos % rows + 1
1191+
local row = pattern[row_i] or {}
1192+
1193+
local col_pos = floor(x / width + 0.5)
1194+
local col_i = col_pos % columns + 1
1195+
1196+
local shape = row[col_i] or Builders.empty_shape
1197+
return shape(x, y, world)
1198+
end
1199+
end
1200+
11871201
--- Docs: https://github.com/Refactorio/RedMew/wiki/Using-the-Builders#buildersgrid_pattern_overlap
11881202
function Builders.grid_pattern_overlap(pattern, columns, rows, width, height)
11891203
local half_width = width / 2
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_chessboard'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
return require 'map_gen.maps.danger_ores.presets.danger_ore_split'
1+
return require 'map_gen.maps.danger_ores.presets.danger_ore_chessboard'

0 commit comments

Comments
 (0)