2018-05-22 14:55:37 +02:00
local b = require ' map_gen.shared.builders '
2019-01-16 22:33:32 +02:00
local math = require ' utils.math '
2018-11-06 14:08:33 +02:00
local degrees = math.degrees
2019-01-16 22:33:32 +02:00
local RS = require ' map_gen.shared.redmew_surface '
local MGSP = require ' resources.map_gen_settings '
2019-06-20 19:35:19 +02:00
local ScenarioInfo = require ' features.gui.info '
local Event = require ' utils.event '
2019-01-16 22:33:32 +02:00
RS.set_map_gen_settings (
{
MGSP.ore_oil_none ,
MGSP.cliff_none
}
)
2018-05-08 22:23:07 +02:00
2019-06-20 19:35:19 +02:00
--Special thanks to the following beta testers for their help with the map and map info: melechkibitzer
ScenarioInfo.set_map_name ( ' DNA ' )
ScenarioInfo.set_map_description ( ' Help research the gigantic genome, and turn this molecule into a megafactory. \n The mutations in this DNA have blessed you with generous ore patches. ' )
ScenarioInfo.set_map_extra_info ( ' Double-helix shaped map generation. \n Circular ore patches with rich cores, connected by thin land strips. \n Landfill disabled. ' )
2018-01-21 17:30:42 +02:00
local ball_r = 16
2018-05-08 22:23:07 +02:00
local big_circle = b.circle ( ball_r )
local small_circle = b.circle ( 0.6 * ball_r )
2018-01-21 17:30:42 +02:00
local ribben = { big_circle }
local count = 8
local angle = math.pi / count
local offset_x = 32
local offset_y = 96
2018-05-22 14:55:37 +02:00
for i = 1 , count do
2018-01-21 17:30:42 +02:00
local x = offset_x * i
local y = offset_y * math.sin ( angle * i )
2018-05-08 22:23:07 +02:00
local c = b.translate ( big_circle , x , y )
2018-01-21 17:30:42 +02:00
table.insert ( ribben , c )
end
2018-05-22 14:55:37 +02:00
for i = 0 , count - 1 do
2018-01-21 17:30:42 +02:00
local j = i + 0.5
local x = offset_x * j
local y = offset_y * math.sin ( angle * j )
2018-05-08 22:23:07 +02:00
local c = b.translate ( small_circle , x , y )
2018-01-21 17:30:42 +02:00
table.insert ( ribben , c )
end
2018-05-08 22:23:07 +02:00
ribben = b.any ( ribben )
2018-01-21 17:30:42 +02:00
2018-05-22 14:55:37 +02:00
local value = b.manhattan_value
local inf = function ( )
return 100000000
2018-01-21 17:30:42 +02:00
end
2018-05-08 22:23:07 +02:00
local oil_shape = b.circle ( 0.16 * ball_r )
oil_shape = b.throttle_world_xy ( oil_shape , 1 , 4 , 1 , 4 )
2018-01-21 17:30:42 +02:00
2018-05-22 14:55:37 +02:00
local resources = {
b.any {
b.resource ( b.circle ( 0.02 * ball_r ) , ' iron-ore ' , inf ) ,
b.resource ( b.circle ( 0.2 * ball_r ) , ' iron-ore ' , value ( 750 , 0.5 ) )
} ,
b.any {
b.resource ( b.circle ( 0.02 * ball_r ) , ' copper-ore ' , inf ) ,
b.resource ( b.circle ( 0.2 * ball_r ) , ' copper-ore ' , value ( 750 , 0.5 ) )
} ,
b.any {
b.resource ( b.circle ( 0.015 * ball_r ) , ' stone ' , inf ) ,
b.resource ( b.circle ( 0.15 * ball_r ) , ' stone ' , value ( 400 , 0.2 ) )
} ,
b.any {
b.resource ( b.circle ( 0.005 * ball_r ) , ' uranium-ore ' , inf ) ,
b.resource ( b.circle ( 0.05 * ball_r ) , ' uranium-ore ' , value ( 600 , 0.2 ) )
} ,
b.resource ( oil_shape , ' crude-oil ' , value ( 120000 , 50 ) ) ,
b.any {
b.resource ( b.circle ( 0.02 * ball_r ) , ' coal ' , inf ) ,
b.resource ( b.circle ( 0.2 * ball_r ) , ' coal ' , value ( 600 , 0.2 ) )
} ,
b.any {
b.resource ( b.circle ( 0.02 * ball_r ) , ' iron-ore ' , inf ) ,
b.resource ( b.circle ( 0.2 * ball_r ) , ' iron-ore ' , value ( 750 , 0.5 ) )
}
2018-01-21 17:30:42 +02:00
}
local lines = { }
2018-05-08 22:23:07 +02:00
local lines_circle = b.circle ( 0.6 * ball_r )
2018-01-21 17:30:42 +02:00
for i = 1 , count - 1 do
local x = offset_x * i
local y = offset_y * math.sin ( angle * i )
2018-05-08 22:23:07 +02:00
local l = b.rectangle ( 2 , 2 * y + ball_r )
l = b.translate ( l , x , 0 )
2018-05-22 14:55:37 +02:00
2018-01-21 17:30:42 +02:00
local c = lines_circle
2018-05-08 22:23:07 +02:00
c = b.apply_entity ( c , resources [ i ] )
2018-05-22 14:55:37 +02:00
c = b.change_map_gen_collision_tile ( c , ' water-tile ' , ' grass-1 ' )
2019-01-16 22:33:32 +02:00
c = b.translate ( c , x , 0 )
2018-01-21 17:30:42 +02:00
table.insert ( lines , c )
table.insert ( lines , l )
end
2018-05-08 22:23:07 +02:00
lines = b.any ( lines )
2018-01-21 17:30:42 +02:00
2018-05-22 14:55:37 +02:00
local dna = b.any { lines , ribben , b.flip_y ( ribben ) }
2018-01-21 17:30:42 +02:00
local widith = offset_x * count
2018-05-22 14:55:37 +02:00
dna = b.translate ( dna , - widith / 2 , 0 )
2018-05-08 22:23:07 +02:00
local map = b.single_x_pattern ( dna , widith )
2018-05-22 14:55:37 +02:00
map = b.translate ( map , - widith / 2 , 0 )
2018-03-29 20:23:47 +02:00
2018-05-08 22:23:07 +02:00
local sea = b.sine_fill ( 512 , 208 )
2018-05-22 14:55:37 +02:00
sea = b.any { b.line_x ( 2 ) , sea , b.flip_y ( sea ) }
sea = b.change_tile ( sea , true , ' water ' )
sea = b.fish ( sea , 0.0025 )
2018-03-29 20:23:47 +02:00
2018-05-22 14:55:37 +02:00
map = b.any { map , sea }
2018-03-29 20:23:47 +02:00
2018-05-08 22:23:07 +02:00
map = b.rotate ( map , degrees ( 45 ) )
2018-01-21 17:30:42 +02:00
2018-05-22 14:55:37 +02:00
local start_circle = b.circle ( 0.3 * ball_r )
local start_iron =
b.any {
b.resource ( b.rectangle ( 0.2 ) , ' iron-ore ' , inf ) ,
b.resource ( b.full_shape , ' iron-ore ' , value ( 700 , 0 ) )
}
local start_copper =
b.any {
b.resource ( b.rectangle ( 0.2 ) , ' copper-ore ' , inf ) ,
b.resource ( b.full_shape , ' copper-ore ' , value ( 500 , 0 ) )
}
local start_stone =
b.any {
b.resource ( b.rectangle ( 0.2 ) , ' stone ' , inf ) ,
b.resource ( b.full_shape , ' stone ' , value ( 250 , 0 ) )
}
local start_coal =
b.any {
b.resource ( b.rectangle ( 0.2 ) , ' coal ' , inf ) ,
b.resource ( b.full_shape , ' coal ' , value ( 800 , 0 ) )
}
2018-01-21 17:30:42 +02:00
2018-05-22 14:55:37 +02:00
local iron = b.apply_entity ( b.scale ( start_circle , 0.5 , 0.5 ) , start_iron )
local copper = b.apply_entity ( b.scale ( start_circle , 0.5 , 0.5 ) , start_copper )
local stone = b.apply_entity ( b.scale ( start_circle , 0.5 , 0.5 ) , start_stone )
local oil = b.apply_entity ( b.scale ( start_circle , 0.1 , 0.1 ) , b.resource ( b.full_shape , ' crude-oil ' , value ( 40000 , 0 ) ) )
local coal = b.apply_entity ( b.scale ( start_circle , 0.5 , 0.5 ) , start_coal )
2018-01-21 17:30:42 +02:00
2018-05-22 14:55:37 +02:00
local start =
b.any {
2018-05-08 22:23:07 +02:00
b.translate ( iron , 0 , - 9 ) ,
b.translate ( copper , 0 , 9 ) ,
b.translate ( stone , - 9 , 0 ) ,
b.translate ( oil , 9 , 9 ) ,
2018-05-22 14:55:37 +02:00
b.translate ( coal , 9 , 0 )
2018-01-21 17:30:42 +02:00
}
2018-05-22 14:55:37 +02:00
start = b.any { start , big_circle }
2018-01-21 17:30:42 +02:00
2018-05-08 22:23:07 +02:00
map = b.choose ( big_circle , start , map )
2018-05-22 14:55:37 +02:00
map = b.change_map_gen_collision_tile ( map , ' water-tile ' , ' grass-1 ' )
2018-01-21 17:30:42 +02:00
2018-05-22 14:55:37 +02:00
map = b.scale ( map , 5 , 5 )
2018-03-29 20:23:47 +02:00
2019-06-20 19:35:19 +02:00
Event.on_init ( function ( )
game.forces [ ' player ' ] . technologies [ ' landfill ' ] . enabled = false
end )
2018-01-21 17:30:42 +02:00
return map