diff --git a/maps/spiral_troopers.lua b/maps/spiral_troopers.lua index 45e305a2..538aa60d 100644 --- a/maps/spiral_troopers.lua +++ b/maps/spiral_troopers.lua @@ -44,7 +44,7 @@ local function treasure_chest(position, surface) {{name = "defender-capsule", count = math_random(8,16)}, weight = 10, evolution_min = 0.0, evolution_max = 0.7}, {{name = "distractor-capsule", count = math_random(8,16)}, weight = 10, evolution_min = 0.2, evolution_max = 1}, {{name = "destroyer-capsule", count = math_random(8,16)}, weight = 10, evolution_min = 0.3, evolution_max = 1}, - {{name = "atomic-bomb", count = math_random(8,16)}, weight = 1, evolution_min = 0.3, evolution_max = 1}, + {{name = "atomic-bomb", count = math_random(8,16)}, weight = 1, evolution_min = 0.2, evolution_max = 1}, {{name = "light-armor", count = 1}, weight = 3, evolution_min = 0, evolution_max = 0.1}, {{name = "heavy-armor", count = 1}, weight = 3, evolution_min = 0.1, evolution_max = 0.3}, {{name = "modular-armor", count = 1}, weight = 2, evolution_min = 0.2, evolution_max = 0.6}, @@ -186,9 +186,7 @@ local function level_finished() if evolution > 1 then evolution = 1 end game.forces.enemy.evolution_factor = evolution - for _, e in pairs(entities) do - surface.create_entity(e) - end + for _, player in pairs(game.connected_players) do player.play_sound{path="utility/new_objective", volume_modifier=0.6} end @@ -216,13 +214,15 @@ local function level_finished() for y = 0, 31, 1 do local pos = {x = global.current_beaten_chunk.x * 32 + x, y = global.current_beaten_chunk.y * 32 + y} table.insert(tiles,{name = "water", position = pos}) - if math.random(1,80) == 1 then table.insert(entities,{name = "fish", position = pos}) end + if math.random(1,50) == 1 then table.insert(entities,{name = "fish", position = pos}) end end - end + end surface.set_tiles(tiles, true) end - local radius = global.current_beaten_chunk.x * 32 - if radius < 0 then radius = radius * -1 end + for _, e in pairs(entities) do + surface.create_entity(e) + end + local radius = (global.spiral_troopers_beaten_level / 2)* 32 radius = radius + 160 game.forces.player.chart(surface,{{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}}) end @@ -249,8 +249,8 @@ end local function clear_chunk_of_enemies(chunk, surface) local a = { - left_top = {x = chunk.y * 32, y = chunk.y * 32}, - right_bottom = {x = (chunk.y * 32) + 31, y = (chunk.y * 32) + 31} + left_top = {x = chunk.x * 32, y = chunk.y * 32}, + right_bottom = {x = (chunk.x * 32) + 31, y = (chunk.y * 32) + 31} } local enemies = surface.find_entities_filtered({force = "enemy", area = a}) if enemies[1] then @@ -271,7 +271,7 @@ local function grow_level() {x = 1, y = 0} } if not global.spiral_troopers_level then - global.spiral_troopers_level = 1 + global.spiral_troopers_level = 1 else global.spiral_troopers_level = global.spiral_troopers_level + 1 end @@ -304,11 +304,12 @@ local function grow_level() clear_chunk_of_enemies(checkpoint_chunk, surface) clear_chunk_of_enemies(reward_chunk, surface) - for x = -1, 32, 1 do - for y = -1, 32, 1 do - local pos = {x = checkpoint_chunk.x * 32 + x, y = checkpoint_chunk.y * 32 + y} + for x = 0, 31, 1 do + for y = 0, 31, 1 do + local pos = {x = checkpoint_chunk.x * 32 + x, y = checkpoint_chunk.y * 32 + y} + table.insert(tiles,{name = "water-green", position = pos}) if math.random(1,2) == 1 then - table.insert(entities,{name = rock_raffle[math.random(1,#rock_raffle)], position = pos}) + table.insert(entities,{name = rock_raffle[math.random(1,#rock_raffle)], position = pos}) end end end @@ -317,7 +318,9 @@ local function grow_level() for y = 0, 31, 1 do local pos = {x = reward_chunk.x * 32 + x, y = reward_chunk.y * 32 + y} if x == 16 and y == 16 then - map_functions.draw_smoothed_out_ore_circle(pos, ore_rotation[current_growth_direction], surface, 14, 500 * global.spiral_troopers_level) + local ore = ore_rotation[current_growth_direction] + if global.spiral_troopers_level % 11 == 0 then ore = "uranium-ore" end + map_functions.draw_smoothed_out_ore_circle(pos, ore, surface, 14, 400 * global.spiral_troopers_level) local unlocker = surface.create_entity({name = "burner-inserter", position = pos, force = "player"}) unlocker.destructible = false unlocker.minable = false @@ -365,41 +368,71 @@ worm_raffle[6] = {"small-worm-turret", "medium-worm-turret", "medium-worm-turret worm_raffle[7] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"} worm_raffle[8] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"} worm_raffle[9] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"} -worm_raffle[10] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"} +worm_raffle[10] = {"medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"} local function on_chunk_generated(event) local surface = game.surfaces["spiral_troopers"] if event.surface.name ~= surface.name then return end if not global.spiral_troopers_spawn_ores then - if get_furthest_chunk() > 2 then - map_functions.draw_smoothed_out_ore_circle({x = -16, y = 16}, "iron-ore", surface, 16, 500) - map_functions.draw_smoothed_out_ore_circle({x = 16, y = 16}, "coal", surface, 16, 500) - map_functions.draw_smoothed_out_ore_circle({x = 48, y = 16}, "copper-ore", surface, 16, 500) + if get_furthest_chunk() > 7 then + map_functions.draw_smoothed_out_ore_circle({x = -16, y = 16}, "copper-ore", surface, 16, 450) + map_functions.draw_smoothed_out_ore_circle({x = 16, y = 16}, "coal", surface, 16, 450) + map_functions.draw_smoothed_out_ore_circle({x = 48, y = 16}, "iron-ore", surface, 16, 450) + local radius = 256 + game.forces.player.chart(surface,{{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}}) global.spiral_troopers_spawn_ores = true end end - for x = 0, 31, 1 do - for y = 0, 31, 1 do - local pos = {x = event.area.left_top.x + x, y = event.area.left_top.y + y} - if pos.x > 64 or pos.x < -64 or pos.y > 64 or pos.y < -48 then - if surface.can_place_entity({name = "spitter-spawner", position = pos}) and math.random(1,20) == 1 then - if math.random(1,3) == 1 then - surface.create_entity({name = "spitter-spawner", position = pos}) - else - surface.create_entity({name = "biter-spawner", position = pos}) + local spawner_density_modifier = 100 + local worm_density_modifier = 1000 + if global.spiral_troopers_level then + spawner_density_modifier = spawner_density_modifier - (global.spiral_troopers_level * 10) + worm_density_modifier = worm_density_modifier - (global.spiral_troopers_level * 50) + end + if spawner_density_modifier < 10 then spawner_density_modifier = 10 end + if worm_density_modifier < 5 then worm_density_modifier = 5 end + + if event.area.left_top.x > 64 or event.area.left_top.x < -64 or event.area.left_top.y > 32 or event.area.left_top.y < -48 then + for x = 0, 31, 1 do + for y = 0, 31, 1 do + if math.random(1, spawner_density_modifier) == 1 then + local pos = {x = event.area.left_top.x + x, y = event.area.left_top.y + y} + if surface.can_place_entity({name = "spitter-spawner", position = pos}) then + if math.random(1,3) == 1 then + surface.create_entity({name = "spitter-spawner", position = pos}) + else + surface.create_entity({name = "biter-spawner", position = pos}) + end end end - if surface.can_place_entity({name = "big-worm-turret", position = pos}) and math.random(1,1500) == 1 then + end + end + for x = 0, 31, 1 do + for y = 0, 31, 1 do + if math.random(1, worm_density_modifier) == 1 then + local pos = {x = event.area.left_top.x + x, y = event.area.left_top.y + y} local level = 0.1 if global.spiral_troopers_level then level = global.spiral_troopers_level / 40 end - if level > 1 then level = 1 end local index = math.ceil(level * 10, 0) if index < 1 then index = 1 end if index > 10 then index = 10 end local name = worm_raffle[index][math.random(1, #worm_raffle[index])] - surface.create_entity({name = name, position = pos}) + if surface.can_place_entity({name = name, position = pos}) then + surface.create_entity({name = name, position = pos}) + end + end + end + end + else + for x = 0, 31, 1 do + for y = 0, 31, 1 do + if math.random(1, 10) == 1 then + local pos = {x = event.area.left_top.x + x, y = event.area.left_top.y + y} + if surface.can_place_entity({name = "tree-03", position = pos}) then + surface.create_entity({name = "tree-03", position = pos}) + end end end end @@ -410,7 +443,7 @@ local function on_chunk_generated(event) if chunk_position_x < 0 then chunk_position_x = chunk_position_x * -1 end if chunk_position_y < 0 then chunk_position_y = chunk_position_y * -1 end local level = 1 - if global.spiral_troopers_level then level = (global.spiral_troopers_level / 2) + 3 end + if global.spiral_troopers_level then level = (global.spiral_troopers_level / 2) + 2 end if chunk_position_x > level and chunk_position_y > level then grow_level() end end @@ -428,13 +461,18 @@ local function on_player_joined_game(event) ["uranium-ore"] = {frequency = "none", size = "none", richness = "none"}, ["crude-oil"] = {frequency = "none", size = "none", richness = "none"}, ["trees"] = {frequency = "none", size = "none", richness = "none"}, - ["enemy-base"] = {frequency = "none", size = "none", richness = "none"}, + ["enemy-base"] = {frequency = "none", size = "none", richness = "very-good"}, ["grass"] = {frequency = "normal", size = "normal", richness = "normal"}, ["sand"] = {frequency = "none", size = "none", richness = "none"}, ["desert"] = {frequency = "none", size = "none", richness = "none"}, ["dirt"] = {frequency = "none", size = "none", richness = "none"} } - game.create_surface("spiral_troopers", map_gen_settings) + game.create_surface("spiral_troopers", map_gen_settings) + + game.map_settings.enemy_evolution.destroy_factor = 0.0 + game.map_settings.enemy_evolution.time_factor = 0.0001 + game.map_settings.enemy_evolution.pollution_factor = 0.0 + game.forces["player"].set_spawn_position({0,0},game.surfaces["spiral_troopers"]) game.forces["player"].technologies["artillery-shell-range-1"].enabled = false game.forces["player"].technologies["artillery-shell-speed-1"].enabled = false @@ -487,14 +525,14 @@ end local biter_building_inhabitants = {} biter_building_inhabitants[1] = {{"small-biter",8,16}} -biter_building_inhabitants[2] = {{"small-biter",12,24}} -biter_building_inhabitants[3] = {{"small-biter",8,16},{"medium-biter",1,2}} -biter_building_inhabitants[4] = {{"small-biter",4,8},{"medium-biter",4,8}} -biter_building_inhabitants[5] = {{"small-biter",3,5},{"medium-biter",8,12}} -biter_building_inhabitants[6] = {{"small-biter",3,5},{"medium-biter",5,7},{"big-biter",1,2}} -biter_building_inhabitants[7] = {{"medium-biter",6,8},{"big-biter",3,5}} +biter_building_inhabitants[2] = {{"small-biter",16,24}} +biter_building_inhabitants[3] = {{"small-biter",8,16},{"medium-biter",4,8}} +biter_building_inhabitants[4] = {{"small-biter",4,8},{"medium-biter",6,10}} +biter_building_inhabitants[5] = {{"small-biter",5,6},{"medium-biter",8,12}} +biter_building_inhabitants[6] = {{"small-biter",2,4},{"medium-biter",6,8},{"big-biter",2,4}} +biter_building_inhabitants[7] = {{"medium-biter",6,8},{"big-biter",4,6}} biter_building_inhabitants[8] = {{"medium-biter",2,4},{"big-biter",6,8}} -biter_building_inhabitants[9] = {{"medium-biter",2,3},{"big-biter",7,9}} +biter_building_inhabitants[9] = {{"medium-biter",2,3},{"big-biter",8,10},{"behemoth-biter",1,2}} biter_building_inhabitants[10] = {{"big-biter",4,8},{"behemoth-biter",3,4}} local entity_drop_amount = { ['small-biter'] = {low = 10, high = 20}, @@ -505,7 +543,7 @@ local entity_drop_amount = { ['biter-spawner'] = {low = 50, high = 100}, ['spitter-spawner'] = {low = 50, high = 100} } -local ore_spill_raffle = {"iron-ore","iron-ore","iron-ore","iron-ore","iron-ore","copper-ore","copper-ore","copper-ore","coal","coal","stone","uranium-ore", "landfill", "landfill", "landfill"} +local ore_spill_raffle = {"iron-ore","iron-ore","iron-ore","iron-ore","iron-ore","coal","coal","coal","copper-ore","copper-ore","stone", "landfill"} local function on_entity_died(event) if event.entity.name == "biter-spawner" or event.entity.name == "spitter-spawner" then @@ -516,7 +554,7 @@ local function on_entity_died(event) if p then event.entity.surface.create_entity {name=t[1], position=p} end end end - if math.random(1,50) == 1 then + if math.random(1,150) == 1 then local amount = 100000 * (1 + (game.forces.enemy.evolution_factor * 20)) event.entity.surface.create_entity({name = "crude-oil", position = event.entity.position, amount = amount}) end @@ -529,13 +567,41 @@ local function on_entity_died(event) end end +local function on_player_built_tile(event) + local placed_tiles = event.tiles + local player = game.players[event.player_index] + for _, t in pairs(placed_tiles) do + if t.old_tile.name == "water-green" then + local tiles = {} + table.insert(tiles, {name = "water-green", position = t.position}) + game.surfaces["spiral_troopers"].set_tiles(tiles,true) + end + end +end + local kabooms = {"big-artillery-explosion", "big-explosion", "explosion"} local function on_tick(event) if not global.spiral_troopers_beaten_level then return end if not global.checkpoint_barriers[global.spiral_troopers_beaten_level] then return end if game.tick % 2 == 1 then if global.checkpoint_barriers[global.spiral_troopers_beaten_level][#global.checkpoint_barriers[global.spiral_troopers_beaten_level]].valid == true then - game.surfaces["spiral_troopers"].create_entity{name = kabooms[math.random(1,#kabooms)], position = global.checkpoint_barriers[global.spiral_troopers_beaten_level][#global.checkpoint_barriers[global.spiral_troopers_beaten_level]].position} + local pos = global.checkpoint_barriers[global.spiral_troopers_beaten_level][#global.checkpoint_barriers[global.spiral_troopers_beaten_level]].position + local surface = game.surfaces["spiral_troopers"] + surface.create_entity{name = kabooms[math.random(1,#kabooms)], position = pos} + local a = { + left_top = {x = pos.x - 10, y = pos.y - 10}, + right_bottom = {x = pos.x + 10, y = pos.y + 10} + } + local greenwater = surface.find_tiles_filtered({name = "water-green", area = a}) + if greenwater then + if greenwater[1] then + local tiles = {} + for _, tile in pairs(greenwater) do + table.insert(tiles, {name = "grass-1", position = tile.position}) + end + surface.set_tiles(tiles, true) + end + end global.checkpoint_barriers[global.spiral_troopers_beaten_level][#global.checkpoint_barriers[global.spiral_troopers_beaten_level]].destroy() end global.checkpoint_barriers[global.spiral_troopers_beaten_level][#global.checkpoint_barriers[global.spiral_troopers_beaten_level]] = nil @@ -544,6 +610,7 @@ local function on_tick(event) end event.add(defines.events.on_tick, on_tick) +event.add(defines.events.on_player_built_tile, on_player_built_tile) event.add(defines.events.on_entity_died, on_entity_died) event.add(defines.events.on_player_rotated_entity, on_player_rotated_entity) event.add(defines.events.on_robot_built_entity, on_robot_built_entity)