diff --git a/locale/en/mtn_fortress_v3.cfg b/locale/en/mtn_fortress_v3.cfg index 2e70ffca..49b5ac38 100644 --- a/locale/en/mtn_fortress_v3.cfg +++ b/locale/en/mtn_fortress_v3.cfg @@ -12,6 +12,8 @@ first_to_reach=[color=blue]Mapkeeper:[/color]\n__1__ was the first to reach zone artillery_warning=[color=blue]Mapkeeper:[/color]\nWarning, Artillery have been spotted north! cheating_through=[color=blue]Mapkeeper:[/color] __1__ tried to cheat their way north with their spidertron! hinder=[color=blue]Mapkeeper:[/color] You are too far away from the main locomotive. You cannot go beyond this point. +warning=Breaching the far side wall will start collapse. +warning_teleport=[color=blue]Mapkeeper:[/color] __1__ wants to go north, but was given a last chance to rethink their choice. The next player that does this will trigger collapse! [entity] treasure_1=[color=blue]Mapkeeper:[/color] You notice an old crate within the rubble. It's filled with treasure! diff --git a/maps/biter_hatchery/main.lua b/maps/biter_hatchery/main.lua index 5732c1e4..1578b50f 100644 --- a/maps/biter_hatchery/main.lua +++ b/maps/biter_hatchery/main.lua @@ -1,12 +1,12 @@ --luacheck: ignore require 'modules.no_turrets' require 'modules.no_acid_puddles' -local Gui = require 'utils.gui' +local CoreGui = require 'utils.gui' +require 'maps.biter_hatchery.share_chat' local Map_score = require 'utils.gui.map_score' local unit_raffle = require 'maps.biter_hatchery.raffle_tables' local Terrain = require 'maps.biter_hatchery.terrain' local Gui = require 'maps.biter_hatchery.gui' -require 'maps.biter_hatchery.share_chat' local Team = require 'maps.biter_hatchery.team' local Unit_health_booster = require 'modules.biter_health_booster' local Map = require 'modules.map_info' @@ -95,7 +95,7 @@ local function spawn_units(belt, food_item, removed_item_count) end end if math_random(1, 8) == 1 then - spawn_worm_turret(belt.surface, belt.force.name, food_item) + spawn_worm_turret(belt.surface, belt.force.name) end end @@ -117,7 +117,7 @@ local function feed_floaty_text(entity) entity.surface.create_entity({name = 'flying-text', position = entity.position, text = nom_msg[math_random(1, 4)], color = {math_random(50, 100), 0, 255}}) local position = {x = entity.position.x - 0.75, y = entity.position.y - 1} local b = 1.35 - for a = 1, math_random(0, 2), 1 do + for _ = 1, math_random(0, 2), 1 do local p = {(position.x + 0.4) + (b * -1 + math_random(0, b * 20) * 0.1), position.y + (b * -1 + math_random(0, b * 20) * 0.1)} entity.surface.create_entity({name = 'flying-text', position = p, text = '♥', color = {math_random(150, 255), 0, 255}}) end @@ -126,7 +126,7 @@ end local function eat_food_from_belt(belt) for i = 1, 2, 1 do local line = belt.get_transport_line(i) - for food_item, raffle in pairs(unit_raffle) do + for food_item, _ in pairs(unit_raffle) do if global.map_forces[belt.force.name].unit_count > global.map_forces[belt.force.name].max_unit_count then return end @@ -140,8 +140,7 @@ local function eat_food_from_belt(belt) end local function nom() - local surface = game.surfaces.nauvis - for key, force in pairs(global.map_forces) do + for _, force in pairs(global.map_forces) do if not force.hatchery then return end @@ -310,7 +309,7 @@ local function on_entity_died(event) for _, child in pairs(player.gui.left.children) do child.destroy() end - Gui.call_existing_tab(player, 'Map Scores') + CoreGui.call_existing_tab(player, 'Map Scores') end for _, e in pairs(entity.surface.find_entities_filtered({type = 'unit'})) do @@ -320,7 +319,6 @@ end local function on_player_joined_game(event) local player = game.players[event.player_index] - local surface = game.surfaces.nauvis Gui.unit_health_buttons(player) Gui.spectate_button(player) diff --git a/maps/biter_hatchery/team.lua b/maps/biter_hatchery/team.lua index 70c616e4..6754ad8a 100644 --- a/maps/biter_hatchery/team.lua +++ b/maps/biter_hatchery/team.lua @@ -119,8 +119,7 @@ function Public.spawn_players(hatchery) if game.tick % 90 ~= 0 then return end - game.print('spawning characters', {150, 150, 150}) - local surface = game.surfaces.nauvis + -- game.print('spawning characters', {150, 150, 150}) for _, player in pairs(game.connected_players) do if player.force.name ~= 'spectator' then Public.assign_force_to_player(player) diff --git a/maps/biter_hatchery/terrain.lua b/maps/biter_hatchery/terrain.lua index 74213ffd..a3875bab 100644 --- a/maps/biter_hatchery/terrain.lua +++ b/maps/biter_hatchery/terrain.lua @@ -10,7 +10,7 @@ local function get_replacement_tile(surface, position) for i = 1, 128, 1 do local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}} table.shuffle_table(vectors) - for k, v in pairs(vectors) do + for _, v in pairs(vectors) do local tile = surface.get_tile(position.x + v[1], position.y + v[2]) if not tile.collides_with('resource-layer') then return tile.name @@ -58,6 +58,7 @@ end function Public.reset_nauvis(hatchery) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings + ---@diagnostic disable-next-line: assign-type-mismatch mgs.seed = math_random(1, 99999999) mgs.water = 1 mgs.starting_area = 1 @@ -70,6 +71,7 @@ function Public.reset_nauvis(hatchery) ['iron-ore'] = {frequency = 8, size = 0.7, richness = 1}, ['uranium-ore'] = {frequency = 5, size = 0.5, richness = 0.5}, ['crude-oil'] = {frequency = 5, size = 1, richness = 1}, + ---@diagnostic disable-next-line: assign-type-mismatch ['trees'] = {frequency = math.random(4, 32) * 0.1, size = math.random(4, 16) * 0.1, richness = math.random(1, 10) * 0.1}, ['enemy-base'] = {frequency = 0, size = 0, richness = 0} } @@ -79,7 +81,7 @@ function Public.reset_nauvis(hatchery) surface.delete_chunk({chunk.x, chunk.y}) end hatchery.gamestate = 'prepare_east' - game.print('preparing east', {150, 150, 150}) + -- game.print('preparing east', {150, 150, 150}) print(hatchery.gamestate) end @@ -109,7 +111,7 @@ function Public.prepare_east(hatchery) end draw_spawn_ore(surface, {x = 240, y = 0}) hatchery.gamestate = 'clear_west' - game.print('clearing west chunks', {150, 150, 150}) + -- game.print('clearing west chunks', {150, 150, 150}) print(hatchery.gamestate) end @@ -125,7 +127,7 @@ function Public.clear_west(hatchery) end hatchery.mirror_queue = {} hatchery.gamestate = 'prepare_west' - game.print('preparing west chunks', {150, 150, 150}) + -- game.print('preparing west chunks', {150, 150, 150}) print(hatchery.gamestate) end @@ -147,11 +149,14 @@ function Public.draw_team_nests(hatchery) if game.tick % 90 ~= 0 then return end - game.print('placing nests', {150, 150, 150}) + -- game.print('placing nests', {150, 150, 150}) local surface = game.surfaces.nauvis local x = hatchery_position.x local e = surface.create_entity({name = 'biter-spawner', position = {x * -1, 0}, force = 'west'}) + if not e or not e.valid then + return + end for _, p in pairs({{x * -1 + 6, 0}, {x * -1 + 3, 6}, {x * -1 + 3, -5}}) do surface.create_entity({name = 'small-worm-turret', position = p, force = 'west'}) surface.create_decoratives {check_collision = false, decoratives = {{name = 'enemy-decal', position = p, amount = 1}}} @@ -162,6 +167,9 @@ function Public.draw_team_nests(hatchery) surface.create_decoratives {check_collision = false, decoratives = {{name = 'enemy-decal', position = e.position, amount = 3}}} local e = surface.create_entity({name = 'biter-spawner', position = {x, 0}, force = 'east'}) + if not e or not e.valid then + return + end for _, p in pairs({{x - 6, 0}, {x - 3, 6}, {x - 3, -5}}) do surface.create_entity({name = 'small-worm-turret', position = p, force = 'east'}) surface.create_decoratives {check_collision = false, decoratives = {{name = 'enemy-decal', position = p, amount = 1}}} diff --git a/maps/mountain_fortress_v3/breached_wall.lua b/maps/mountain_fortress_v3/breached_wall.lua index 0649b47b..f464e9e0 100644 --- a/maps/mountain_fortress_v3/breached_wall.lua +++ b/maps/mountain_fortress_v3/breached_wall.lua @@ -2,6 +2,7 @@ local Event = require 'utils.event' local Public = require 'maps.mountain_fortress_v3.table' local Collapse = require 'modules.collapse' local RPG = require 'modules.rpg.main' +local WD = require 'modules.wave_defense.table' local Alert = require 'utils.alert' local Task = require 'utils.task' local Token = require 'utils.token' @@ -25,15 +26,15 @@ local clear_breach_text_and_render = function() end local zone1_text1 = Public.get('zone1_text1') if zone1_text1 then - rendering.set_text(zone1_text1, 'Collapse has started!') + rendering.set_text(zone1_text1, 'Collapse has begun!') end local zone1_text2 = Public.get('zone1_text2') if zone1_text2 then - rendering.set_text(zone1_text2, 'Collapse has started!') + rendering.set_text(zone1_text2, 'Collapse has begun!') end local zone1_text3 = Public.get('zone1_text3') if zone1_text3 then - rendering.set_text(zone1_text3, 'Collapse has started!') + rendering.set_text(zone1_text3, 'Collapse has begun!') end end @@ -84,6 +85,27 @@ local artillery_warning = end ) +local breach_wall_warning_teleport = function(player) + if not player or not player.valid then + return + end + + local wave_number = WD.get('wave_number') + if wave_number > 200 then + return + end + + local message = ({'breached_wall.warning_teleport', player.name}) + Alert.alert_all_players(40, message) + local pos = player.surface.find_non_colliding_position('character', player.force.get_spawn_position(player.surface), 3, 0) + if pos then + player.teleport(pos, player.surface) + else + pos = game.forces.player.get_spawn_position(player.surface) + player.teleport(pos, player.surface) + end +end + local spidertron_too_far = Token.register( function(data) @@ -232,11 +254,18 @@ local function distance(player) return end + local breach_wall_warning = Public.get('breach_wall_warning') + local max = zone_settings.zone_depth * bonus local breach_max = zone_settings.zone_depth * breached_wall local breach_max_times = location >= breach_max local max_times = location >= max if max_times then + if not breach_wall_warning then + Public.set('breach_wall_warning', true) + breach_wall_warning_teleport(player) + return + end if breach_max_times then local placed_trains_in_zone = Public.get('placed_trains_in_zone') local biters = Public.get('biters') diff --git a/maps/mountain_fortress_v3/gui.lua b/maps/mountain_fortress_v3/gui.lua index 175c9343..9320a382 100644 --- a/maps/mountain_fortress_v3/gui.lua +++ b/maps/mountain_fortress_v3/gui.lua @@ -158,7 +158,7 @@ end local function hide_all_gui(player) for _, child in pairs(player.gui.top.children) do - if child.name ~= spectate_button_name and child.name ~= 'minimap_button' then + if child.name ~= spectate_button_name and child.name ~= 'minimap_button' and child.name ~= 'wave_defense' then child.visible = false end end diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index 836294a7..55e0547f 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -96,6 +96,7 @@ function Public.reset_main_table() this.announced_message = false this.game_saved = false -- @end + this.breach_wall_warning = false this.icw_locomotive = nil this.game_lost = false this.death_mode = false diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index c4c524c2..6e295fc7 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -355,11 +355,11 @@ local function wall(p, data) Public.set( 'zone1_text1', rendering.draw_text { - text = 'Breaching the far side wall will start collapse.', + text = ({'breached_wall.warning'}), surface = surface, target = {0, p.y + 35}, - color = {r = 0.98, g = 0.66, b = 0.22}, - scale = 8, + color = {r = 255, g = 106, b = 0}, + scale = 10, font = 'heading-1', alignment = 'center', scale_with_zoom = false @@ -368,11 +368,11 @@ local function wall(p, data) Public.set( 'zone1_text2', rendering.draw_text { - text = 'Breaching the far side wall will start collapse', + text = ({'breached_wall.warning'}), surface = surface, target = {-180, p.y + 35}, - color = {r = 0.98, g = 0.66, b = 0.22}, - scale = 8, + color = {r = 255, g = 106, b = 0}, + scale = 10, font = 'heading-1', alignment = 'center', scale_with_zoom = false @@ -381,11 +381,11 @@ local function wall(p, data) Public.set( 'zone1_text3', rendering.draw_text { - text = 'Breaching the far side wall will start collapse', + text = ({'breached_wall.warning'}), surface = surface, target = {180, p.y + 35}, - color = {r = 0.98, g = 0.66, b = 0.22}, - scale = 8, + color = {r = 255, g = 106, b = 0}, + scale = 10, font = 'heading-1', alignment = 'center', scale_with_zoom = false