1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-26 03:52:22 +02:00

terrain update

3 more levels
This commit is contained in:
MewMew 2019-10-30 20:00:32 +01:00
parent 0255c0ab18
commit d56f14ee03
3 changed files with 179 additions and 103 deletions

View File

@ -169,9 +169,9 @@ local projectiles = {"grenade", "explosive-rocket", "grenade", "explosive-rocket
local function angry_tree(entity, cause) local function angry_tree(entity, cause)
if entity.type ~= "tree" then return end if entity.type ~= "tree" then return end
if math.abs(entity.position.y) < level_depth then return end if math.abs(entity.position.y) < level_depth then return end
if math.random(1,3) == 1 then hidden_biter(entity) end if math.random(1,4) == 1 then hidden_biter(entity) end
if math.random(1,6) == 1 then hidden_worm(entity) end if math.random(1,8) == 1 then hidden_worm(entity) end
if math.random(1,9) ~= 1 then return end if math.random(1,16) ~= 1 then return end
local position = false local position = false
if cause then if cause then
if cause.valid then if cause.valid then

View File

@ -14,6 +14,8 @@ local noises = {
["cave_ponds"] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}}, ["cave_ponds"] = {{modifier = 0.01, weight = 1}, {modifier = 0.1, weight = 0.06}},
["cave_rivers"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.01}}, ["cave_rivers"] = {{modifier = 0.005, weight = 1}, {modifier = 0.01, weight = 0.25}, {modifier = 0.05, weight = 0.01}},
["cave_rivers_2"] = {{modifier = 0.003, weight = 1}, {modifier = 0.01, weight = 0.21}, {modifier = 0.05, weight = 0.01}}, ["cave_rivers_2"] = {{modifier = 0.003, weight = 1}, {modifier = 0.01, weight = 0.21}, {modifier = 0.05, weight = 0.01}},
["cave_rivers_3"] = {{modifier = 0.002, weight = 1}, {modifier = 0.01, weight = 0.15}, {modifier = 0.05, weight = 0.01}},
["cave_rivers_4"] = {{modifier = 0.001, weight = 1}, {modifier = 0.01, weight = 0.11}, {modifier = 0.05, weight = 0.01}},
} }
local level_depth = 1024 local level_depth = 1024
local worm_level_modifier = 0.25 local worm_level_modifier = 0.25
@ -42,6 +44,156 @@ local function get_replacement_tile(surface, position)
return "grass-1" return "grass-1"
end end
local function process_level_10_position(p, seed, tiles, entities, markets, treasure)
local noise_1 = get_noise("small_caves", p, seed)
local noise_2 = get_noise("no_rocks_2", p, seed + 10000)
if noise_1 > 0.7 then
tiles[#tiles + 1] = {name = "water", position = p}
if math_random(1,48) == 1 then entities[#entities + 1] = {name="fish", position=p} end
return
end
if noise_1 < -0.75 then
tiles[#tiles + 1] = {name = "lab-dark-1", position = p}
entities[#entities + 1] = {name = "uranium-ore", position = p, amount = math.abs(p.y) + 1 * 3}
return
end
if noise_1 > -0.25 and noise_1 < 0.25 then
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if noise_1 > -0.20 and noise_1 < 0.20 then
if math_random(1,10) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
if math_random(1,256) == 1 then treasure[#treasure + 1] = p end
end
return
end
if math_random(1,64) == 1 and noise_2 > 0.65 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 1000} end
if math_random(1,8192) == 1 then markets[#markets + 1] = p end
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
tiles[#tiles + 1] = {name = "tutorial-grid", position = p}
end
local function process_level_9_position(p, seed, tiles, entities, markets, treasure)
local maze_p = {x = math.floor(p.x - p.x % 16), y = math.floor(p.y - p.y % 16)}
local maze_noise = get_noise("no_rocks_2", maze_p, seed)
if maze_noise > -0.3 and maze_noise < 0.3 then
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,4) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end
if math_random(1,256) == 1 then
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
end
return
end
if maze_noise > 0 and maze_noise < 0.4 then
if math_random(1,512) == 1 then markets[#markets + 1] = p end
if math_random(1,256) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 1000} end
if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
return
end
if maze_noise < 0 and maze_noise > -0.35 then
tiles[#tiles + 1] = {name = "deepwater", position = p}
if math_random(1,96) == 1 then entities[#entities + 1] = {name="fish", position=p} end
return
end
tiles[#tiles + 1] = {name = "out-of-map", position = p}
end
local function process_level_8_position(p, seed, tiles, entities, markets, treasure)
local maze_p = {x = math.floor(p.x - p.x % 32), y = math.floor(p.y - p.y % 32)}
local maze_noise = get_noise("no_rocks_2", maze_p, seed)
if maze_noise > -0.3 and maze_noise < 0.3 then
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,4) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
if math_random(1,1024) == 1 then treasure[#treasure + 1] = p end
if math_random(1,512) == 1 then
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
end
return
end
if maze_noise > 0 and maze_noise < 0.4 then
if math_random(1,512) == 1 then markets[#markets + 1] = p end
if math_random(1,256) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 1000} end
if math_random(1,32) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
return
end
if maze_noise < 0 and maze_noise > -0.35 then
tiles[#tiles + 1] = {name = "deepwater", position = p}
if math_random(1,96) == 1 then entities[#entities + 1] = {name="fish", position=p} end
return
end
tiles[#tiles + 1] = {name = "out-of-map", position = p}
end
local function process_level_7_position(p, seed, tiles, entities, markets, treasure)
local cave_rivers_3 = get_noise("cave_rivers_3", p, seed)
local cave_rivers_4 = get_noise("cave_rivers_4", p, seed + 50000)
local no_rocks_2 = get_noise("no_rocks_2", p, seed)
if cave_rivers_3 > -0.025 and cave_rivers_3 < 0.025 and no_rocks_2 > -0.6 then
tiles[#tiles + 1] = {name = "water", position = p}
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
return
end
if cave_rivers_4 > -0.025 and cave_rivers_4 < 0.025 and no_rocks_2 > -0.6 then
tiles[#tiles + 1] = {name = "water", position = p}
if math_random(1,128) == 1 then entities[#entities + 1] = {name="fish", position=p} end
return
end
local noise_ores = get_noise("no_rocks_2", p, seed + 25000)
if cave_rivers_3 > -0.20 and cave_rivers_3 < 0.20 then
tiles[#tiles + 1] = {name = "grass-" .. math.floor(cave_rivers_3 * 32) % 3 + 1, position = p}
if cave_rivers_3 > -0.10 and cave_rivers_3 < 0.10 then
if math_random(1,16) == 1 and no_rocks_2 > 0 then entities[#entities + 1] = {name = "tree-01", position=p} end
if math_random(1,2048) == 1 then markets[#markets + 1] = p end
if noise_ores < -0.5 and no_rocks_2 > -0.6 then
if cave_rivers_3 > 0 and cave_rivers_3 < 0.07 then
entities[#entities + 1] = {name = "iron-ore", position=p, amount = math.abs(p.y) + 1}
end
end
end
if math_random(1,64) == 1 and no_rocks_2 > 0.7 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 1000} end
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
return
end
if cave_rivers_4 > -0.20 and cave_rivers_4 < 0.20 then
tiles[#tiles + 1] = {name = "grass-" .. math.floor(cave_rivers_4 * 32) % 3 + 1, position = p}
if cave_rivers_4 > -0.10 and cave_rivers_4 < 0.10 then
if math_random(1,16) == 1 and no_rocks_2 > 0 then entities[#entities + 1] = {name = "tree-02", position=p} end
if math_random(1,2048) == 1 then markets[#markets + 1] = p end
if noise_ores < -0.5 and no_rocks_2 > -0.6 then
if cave_rivers_4 > 0 and cave_rivers_4 < 0.07 then
entities[#entities + 1] = {name = "copper-ore", position=p, amount = math.abs(p.y) + 1}
end
end
end
if math_random(1,64) == 1 and no_rocks_2 > 0.7 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 1000} end
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
return
end
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
if math_random(1,256) == 1 then treasure[#treasure + 1] = p end
end
local function process_level_6_position(p, seed, tiles, entities, markets, treasure) local function process_level_6_position(p, seed, tiles, entities, markets, treasure)
local large_caves = get_noise("large_caves", p, seed) local large_caves = get_noise("large_caves", p, seed)
local cave_rivers = get_noise("cave_rivers", p, seed) local cave_rivers = get_noise("cave_rivers", p, seed)
@ -54,16 +206,16 @@ local function process_level_6_position(p, seed, tiles, entities, markets, treas
if cave_rivers > -0.05 and cave_rivers < 0.05 then if cave_rivers > -0.05 and cave_rivers < 0.05 then
if math_random(1,48) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end if math_random(1,48) == 1 then entities[#entities + 1] = {name = "tree-0" .. math_random(1, 9), position=p} end
if math_random(1,768) == 1 then if math_random(1,128) == 1 then
Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier) Biters.wave_defense_set_worm_raffle(math.abs(p.y) * worm_level_modifier)
entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"} entities[#entities + 1] = {name = Biters.wave_defense_roll_worm_name(), position = p, force = "enemy"}
end end
else else
tiles[#tiles + 1] = {name = "dirt-7", position = p} tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,8) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end if math_random(1,8) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
if math_random(1,320) == 1 then treasure[#treasure + 1] = p end if math_random(1,512) == 1 then treasure[#treasure + 1] = p end
if math_random(1,1536) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 1000} end if math_random(1,4096) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 1000} end
if math_random(1,4096) == 1 then markets[#markets + 1] = p end if math_random(1,8096) == 1 then markets[#markets + 1] = p end
end end
end end
@ -434,13 +586,17 @@ local function process_level_1_position(p, seed, tiles, entities, markets, treas
if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end if math_random(1,100) > 30 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
end end
local levels = { local levels = {
process_level_1_position, process_level_1_position,
process_level_2_position, process_level_2_position,
process_level_3_position, process_level_3_position,
process_level_4_position, process_level_4_position,
process_level_5_position, process_level_5_position,
process_level_6_position, process_level_6_position,
process_level_7_position,
process_level_8_position,
process_level_9_position,
process_level_10_position,
} }
local function rock_chunk(surface, left_top) local function rock_chunk(surface, left_top)
@ -450,7 +606,7 @@ local function rock_chunk(surface, left_top)
local treasure = {} local treasure = {}
local seed = surface.map_gen_settings.seed local seed = surface.map_gen_settings.seed
local process_level = levels[math.floor(math.abs(left_top.y) / level_depth) + 1] local process_level = levels[math.floor(math.abs(left_top.y) / level_depth) + 1]
if not process_level then process_level = process_level_6_position end if not process_level then process_level = levels[#levels] end
for y = 0, 31, 1 do for y = 0, 31, 1 do
for x = 0, 31, 1 do for x = 0, 31, 1 do
local p = {x = left_top.x + x, y = left_top.y + y} local p = {x = left_top.x + x, y = left_top.y + y}
@ -573,7 +729,7 @@ local function wall(surface, left_top, seed)
local small_caves = get_noise("small_caves", p, seed) local small_caves = get_noise("small_caves", p, seed)
local cave_ponds = get_noise("cave_rivers", p, seed + 100000) local cave_ponds = get_noise("cave_rivers", p, seed + 100000)
if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then if y > 9 + cave_ponds * 6 and y < 23 + small_caves * 6 then
if small_caves > 0.10 or cave_ponds > 0.10 then if small_caves > 0.05 or cave_ponds > 0.05 then
--surface.set_tiles({{name = "water-shallow", position = p}}) --surface.set_tiles({{name = "water-shallow", position = p}})
surface.set_tiles({{name = "deepwater", position = p}}) surface.set_tiles({{name = "deepwater", position = p}})
if math_random(1,48) == 1 then surface.create_entity({name = "fish", position = p}) end if math_random(1,48) == 1 then surface.create_entity({name = "fish", position = p}) end
@ -636,7 +792,7 @@ local function process_chunk(surface, left_top)
if left_top.x >= 768 then return end if left_top.x >= 768 then return end
if left_top.x < -768 then return end if left_top.x < -768 then return end
if left_top.y % level_depth == 0 and left_top.y < 0 and left_top.y > level_depth * -6 then wall(surface, left_top, surface.map_gen_settings.seed) return end if left_top.y % level_depth == 0 and left_top.y < 0 and left_top.y > level_depth * -10 then wall(surface, left_top, surface.map_gen_settings.seed) return end
if left_top.y >= 0 then replace_water(surface, left_top) end if left_top.y >= 0 then replace_water(surface, left_top) end
if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end if left_top.y > 32 then game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) end

View File

@ -1,20 +1,7 @@
require "modules.mineable_wreckage_yields_scrap" require "modules.mineable_wreckage_yields_scrap"
require "modules.wave_defense.main" require "modules.wave_defense.main"
local Map = require "modules.map_info" local Map = require "modules.map_info"
local WD = require "modules.wave_defense.table"
--require "modules.biters_attack_moving_players"
--[[
local difficulties_votes = {
[1] = {tick_increase = 4500, amount_modifier = 0.52, strength_modifier = 0.40, boss_modifier = 3.0},
[2] = {tick_increase = 4100, amount_modifier = 0.76, strength_modifier = 0.65, boss_modifier = 4.0},
[3] = {tick_increase = 3800, amount_modifier = 0.92, strength_modifier = 0.85, boss_modifier = 5.0},
[4] = {tick_increase = 3600, amount_modifier = 1.00, strength_modifier = 1.00, boss_modifier = 6.0},
[5] = {tick_increase = 3400, amount_modifier = 1.08, strength_modifier = 1.25, boss_modifier = 7.0},
[6] = {tick_increase = 3100, amount_modifier = 1.24, strength_modifier = 1.75, boss_modifier = 8.0},
[7] = {tick_increase = 2700, amount_modifier = 1.48, strength_modifier = 2.50, boss_modifier = 9.0}
}
]]
local WD = require "modules.wave_defense.main"
local simplex_noise = require 'utils.simplex_noise'.d2 local simplex_noise = require 'utils.simplex_noise'.d2
local spawn_size = 96 local spawn_size = 96
local wall_thickness = 3 local wall_thickness = 3
@ -118,34 +105,7 @@ local function get_quarter_name(position)
end end
end end
end end
--[[
local function send_peace_quarter_biters()
local surface = game.surfaces[1]
local target = surface.find_nearest_enemy({position = {0, 0}, max_distance = 99999, force = "enemy"})
if target then
target = target.position
else
target = {x = 0, y = 0}
end
local units_nw = {}
local units_se = {}
for _, unit in pairs(surface.find_entities_filtered({type = "unit"})) do
local quarter = get_quarter_name(unit.position)
if quarter == "NW" then units_nw[#units_nw + 1] = unit end
if quarter == "SE" then units_se[#units_se + 1] = unit end
end
if #units_nw > 2 then table.shuffle_table(units_nw) end
if #units_se > 2 then table.shuffle_table(units_se) end
for i = 1, 512, 1 do
if units_nw[i] then
units_nw[i].set_command({type=defines.command.attack_area, destination=target, radius=8, distraction=defines.distraction.by_anything})
end
if units_se[i] then
units_se[i].set_command({type=defines.command.attack_area, destination=target, radius=8, distraction=defines.distraction.by_anything})
end
end
end
]]
local function draw_borders(surface, left_top, area) local function draw_borders(surface, left_top, area)
if left_top.x == 0 or left_top.x == -32 then if left_top.x == 0 or left_top.x == -32 then
for x = 0, 31, 1 do for x = 0, 31, 1 do
@ -194,15 +154,21 @@ local function on_chunk_generated(event)
draw_borders(surface, left_top, event.area) draw_borders(surface, left_top, event.area)
if left_top.x ^ 2 + left_top.y ^ 2 > 360000 then return end if left_top.x > 512 then return end
if left_top.x < -512 then return end
if left_top.y > 512 then return end
if left_top.y < -512 then return end
game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}}) game.forces.player.chart(surface, {{left_top.x, left_top.y},{left_top.x + 31, left_top.y + 31}})
end end
local function set_difficulty() local function set_difficulty()
local wave_defense_table = WD.get_table() local wave_defense_table = WD.get_table()
--20 Players for maximum difficulty
wave_defense_table.wave_interval = 7200 - #game.connected_players * 270 wave_defense_table.threat_gain_multiplier = 2 + #game.connected_players * 0.1
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end --20 Players for fastest wave_interval
wave_defense_table.wave_interval = 3600 - #game.connected_players * 90
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
end end
local function on_player_joined_game(event) local function on_player_joined_game(event)
@ -213,52 +179,6 @@ local function on_player_left_game(event)
set_difficulty() set_difficulty()
end end
--[[
local function tick(event)
local size = math.floor((8 + game.tick / difficulties_votes[global.difficulty_vote_index].tick_increase) * difficulties_votes[global.difficulty_vote_index].amount_modifier)
if size > 80 then size = 80 end
game.map_settings.enemy_expansion.settler_group_min_size = size
game.map_settings.enemy_expansion.settler_group_max_size = size * 2
game.map_settings.enemy_evolution.destroy_factor = global.enemy_evolution_destroy_factor * difficulties_votes[global.difficulty_vote_index].strength_modifier
game.map_settings.enemy_evolution.time_factor = global.enemy_evolution_time_factor * difficulties_votes[global.difficulty_vote_index].strength_modifier
game.map_settings.enemy_evolution.pollution_factor = global.enemy_evolution_pollution_factor * difficulties_votes[global.difficulty_vote_index].strength_modifier
if game.tick % 240 == 0 then
game.forces.player.chart(game.surfaces[1], {{-192, -192},{160, 160}})
end
if game.tick % 18000 == 0 then
send_peace_quarter_biters()
end
--game.map_settings.enemy_expansion.min_expansion_cooldown = difficulties_votes[global.difficulty_vote_index].tick_increase
--game.map_settings.enemy_expansion.max_expansion_cooldown = difficulties_votes[global.difficulty_vote_index].tick_increase
--local amount = 1 + game.tick / 120
--if amount > 32 then amount = 32 end
--game.surfaces[1].pollute({-1 + math.random(0, 2), -1 + math.random(0, 2)}, amount)
end
--Flamethrower Turret Nerf
local function on_research_finished(event)
local research = event.research
local force_name = research.force.name
if research.name == "flamethrower" then
if not global.flamethrower_damage then global.flamethrower_damage = {} end
global.flamethrower_damage[force_name] = -0.6
game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name])
game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name])
end
if string.sub(research.name, 0, 18) == "refined-flammables" then
global.flamethrower_damage[force_name] = global.flamethrower_damage[force_name] + 0.05
game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name])
game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.flamethrower_damage[force_name])
end
end
]]
local function on_init() local function on_init()
local T = Map.Pop_info() local T = Map.Pop_info()
T.main_caption = "4 Quarters" T.main_caption = "4 Quarters"