From 0ab3c5240171070c26966a579eeeddc0eec34445 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Wed, 27 Mar 2024 11:08:26 +0100 Subject: [PATCH] Mtn v3 - Wave defense Fixes that biters tried to path north --- maps/mountain_fortress_v3/main.lua | 2 ++ maps/mountain_fortress_v3/terrain.lua | 16 +++++++++++++-- modules/wave_defense/main.lua | 28 +++++++++++++++++++++------ modules/wave_defense/table.lua | 7 ++++++- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 1a81da5e..df20bc72 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -278,12 +278,14 @@ function Public.reset_map() surface.force_generate_chunk_requests() end game.forces.player.set_spawn_position({x = -27, y = -25}, surface) + WD.set_spawn_position({x = -16, y = -80}) else if not surface.is_chunk_generated({x = -20, y = 22}) then surface.request_to_generate_chunks({x = -20, y = 22}, 0.1) surface.force_generate_chunk_requests() end game.forces.player.set_spawn_position({x = -27, y = 25}, surface) + WD.set_spawn_position({x = -16, y = 80}) end game.speed = 1 diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index 001ed6cc..659cf1a4 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -2808,6 +2808,16 @@ local function border_chunk(p, data) local pos = p + if data.reversed then + if p.y < -74 then + return + end + else + if p.y > 74 then + return + end + end + if random(1, ceil(abs(pos.y) + abs(pos.y)) + 64) == 1 then entities[#entities + 1] = {name = trees[random(1, #trees)], position = pos} end @@ -2900,20 +2910,22 @@ function Public.heavy_functions(data) if string.sub(surface.name, 0, #map_name) ~= map_name then return end + local adjusted_zones = Public.get('adjusted_zones') + data.reversed = adjusted_zones.reversed local p = data.position - local adjusted_zones = Public.get('adjusted_zones') if adjusted_zones.disable_terrain then return end + init_terrain(adjusted_zones) if not data.seed then data.seed = Public.get('random_seed') end - if adjusted_zones.reversed then + if data.reversed then if top_y % zone_settings.zone_depth == 0 and top_y > 0 then Public.set('left_top', data.left_top) return wall(p, data) diff --git a/modules/wave_defense/main.lua b/modules/wave_defense/main.lua index 8a107c5e..f407f236 100644 --- a/modules/wave_defense/main.lua +++ b/modules/wave_defense/main.lua @@ -32,9 +32,16 @@ end local function normalize_spawn_position() local collapse_spawn_position = Collapse.get_position() - local new_pos = {x = 0, y = collapse_spawn_position.y - 40} - Public.set_spawn_position(new_pos) - return new_pos + local inverted = Public.get('inverted') + if inverted then + local new_pos = {x = 0, y = collapse_spawn_position.y + 40} + Public.set_spawn_position(new_pos) + return new_pos + else + local new_pos = {x = 0, y = collapse_spawn_position.y - 40} + Public.set_spawn_position(new_pos) + return new_pos + end end local function find_initial_spot(surface, position) @@ -180,10 +187,19 @@ local function get_spawn_pos() local target = Public.get('target') if initial_position.y - target.position.y > 10 then - if random(1, 2) == 1 then - initial_position = {x = initial_position.x, y = initial_position.y - 30} + local inverted = Public.get('inverted') + if inverted then + if random(1, 2) == 1 then + initial_position = {x = initial_position.x, y = initial_position.y + 30} + else + initial_position = {x = initial_position.x, y = initial_position.y + 20} + end else - initial_position = {x = initial_position.x, y = initial_position.y - 20} + if random(1, 2) == 1 then + initial_position = {x = initial_position.x, y = initial_position.y - 30} + else + initial_position = {x = initial_position.x, y = initial_position.y - 20} + end end end diff --git a/modules/wave_defense/table.lua b/modules/wave_defense/table.lua index b158a989..ee1c4c45 100644 --- a/modules/wave_defense/table.lua +++ b/modules/wave_defense/table.lua @@ -63,6 +63,7 @@ function Public.reset_wave_defense() this.average_unit_group_size = 24 this.biter_raffle = {} this.debug = false + this.inverted = false this.debug_health = false this.disable_spawn_near_target = true this.log_wave_to_discord = true @@ -479,8 +480,12 @@ end -- @param function Public.enable_grace_time(boolean) this.enable_grace_time.enabled = boolean or false +end - return this.debug_health +--- Toggles a reverse search function +-- @param +function Public.enable_inverted(boolean) + this.inverted = boolean or false end -- Event.on_nth_tick(30, Public.debug_module)