From 737bb0208343cb188c79da53bb74b7b37ae7e357 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Wed, 8 Nov 2023 22:27:34 +0100 Subject: [PATCH] Mtn v3 Fixes cheese mode (currently enabled until season reset) Fixes that players could run north when terrain was not generated Increased collapse speed if main locomotive is too far north --- locale/en/mtn_fortress_v3.cfg | 1 + maps/mountain_fortress_v3/breached_wall.lua | 27 ++++-- .../icw/linked_chests.lua | 90 +++++++++++-------- maps/mountain_fortress_v3/main.lua | 2 +- maps/mountain_fortress_v3/stateful/table.lua | 6 +- maps/mountain_fortress_v3/table.lua | 1 + 6 files changed, 80 insertions(+), 47 deletions(-) diff --git a/locale/en/mtn_fortress_v3.cfg b/locale/en/mtn_fortress_v3.cfg index d72e4eac..05bcd957 100644 --- a/locale/en/mtn_fortress_v3.cfg +++ b/locale/en/mtn_fortress_v3.cfg @@ -12,6 +12,7 @@ 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. +hinder_collapse=[color=blue]Mapkeeper:[/color] Collapse is too far away. 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! diff --git a/maps/mountain_fortress_v3/breached_wall.lua b/maps/mountain_fortress_v3/breached_wall.lua index 19c36718..ed10359b 100644 --- a/maps/mountain_fortress_v3/breached_wall.lua +++ b/maps/mountain_fortress_v3/breached_wall.lua @@ -153,19 +153,17 @@ local check_distance_between_player_and_locomotive = function(player) return end + local collapse_position = Collapse.get_position() + local gap_between_locomotive = Public.get('gap_between_locomotive') - - if not gap_between_locomotive.highest_pos then - gap_between_locomotive.highest_pos = locomotive.position - end - gap_between_locomotive.highest_pos = locomotive.position gap_between_locomotive = Public.get('gap_between_locomotive') - local c_y = position.y + local p_y = position.y local t_y = gap_between_locomotive.highest_pos.y + local c_y = collapse_position.y - if c_y - t_y <= gap_between_locomotive.neg_gap then + if p_y - t_y <= gap_between_locomotive.neg_gap then player.teleport({position.x, locomotive.position.y + gap_between_locomotive.neg_gap + 2}, surface) player.print(({'breached_wall.hinder'}), Color.warning) if player.driving then @@ -179,6 +177,21 @@ local check_distance_between_player_and_locomotive = function(player) end end end + + if p_y - c_y <= gap_between_locomotive.neg_gap_collapse then + player.teleport({position.x, c_y + gap_between_locomotive.neg_gap_collapse + 2}, surface) + player.print(({'breached_wall.hinder_collapse'}), Color.warning) + if player.driving then + player.driving = false + end + if player.character then + player.character.health = player.character.health - 5 + player.character.surface.create_entity({name = 'water-splash', position = position}) + if player.character.health <= 0 then + player.character.die('enemy') + end + end + end end local compare_player_pos = function(player) diff --git a/maps/mountain_fortress_v3/icw/linked_chests.lua b/maps/mountain_fortress_v3/icw/linked_chests.lua index 7f11ba1e..ac4b2485 100644 --- a/maps/mountain_fortress_v3/icw/linked_chests.lua +++ b/maps/mountain_fortress_v3/icw/linked_chests.lua @@ -660,50 +660,64 @@ local function built_entity_robot(event) return end + local active_surface_index = WPT.get('active_surface_index') + local disable_link_chest_cheese_mode = WPT.get('disable_link_chest_cheese_mode') + local net_point = robot.logistic_network - if net_point and net_point.storage_points and net_point.storage_points[1] and net_point.storage_points[1].owner and net_point.storage_points[1].owner.valid then - if (net_point.storage_points[1].owner.name == 'character') then - local player = net_point.storage_points[1].owner.player - if not player or not player.valid then - return - end + if net_point and net_point.storage_points then + for _, point in pairs(net_point.storage_points) do + if point then + if point.owner and point.owner.valid and point.owner.name == 'character' then + local player = point.owner.player + if not player or not player.valid then + return + end - local active_surface_index = WPT.get('active_surface_index') + if player.surface.index ~= active_surface_index then + if entity.type ~= 'entity-ghost' then + player.insert({name = 'linked-chest', count = 1}) + end + entity.destroy() + player.print(module_name .. 'Linked chests only work on the main surface.', Color.warning) + return + end - if player.surface.index ~= active_surface_index then - if entity.type ~= 'entity-ghost' then - player.insert({name = 'linked-chest', count = 1}) + if not WPT.locomotive.is_around_train(entity) then + if entity.type ~= 'entity-ghost' then + player.insert({name = 'linked-chest', count = 1}) + end + entity.destroy() + player.print(module_name .. 'Linked chests only work inside the locomotive aura.', Color.warning) + return + end + + local trusted_player = Session.get_trusted_player(player) + + if not trusted_player then + if entity.type ~= 'entity-ghost' then + player.insert({name = 'linked-chest', count = 1}) + end + entity.destroy() + player.print('[Antigrief] You have not grown accustomed to this technology yet.', Color.warning) + return + end + + local s = create_chest(entity) + if s then + gui_opened(event) + end + else + local created = event.created_entity + if created and created.valid then + local inventory = robot.get_inventory(defines.inventory.robot_cargo) + inventory.insert({name = created.name, count = 1}) + created.destroy() + end end - entity.destroy() - player.print(module_name .. 'Linked chests only work on the main surface.', Color.warning) - return end + end - if not WPT.locomotive.is_around_train(entity) then - if entity.type ~= 'entity-ghost' then - player.insert({name = 'linked-chest', count = 1}) - end - entity.destroy() - player.print(module_name .. 'Linked chests only work inside the locomotive aura.', Color.warning) - return - end - - local trusted_player = Session.get_trusted_player(player) - - if not trusted_player then - if entity.type ~= 'entity-ghost' then - player.insert({name = 'linked-chest', count = 1}) - end - entity.destroy() - player.print('[Antigrief] You have not grown accustomed to this technology yet.', Color.warning) - return - end - - local s = create_chest(entity) - if s then - gui_opened(event) - end - else + if disable_link_chest_cheese_mode then local created = event.created_entity if created and created.valid then local inventory = robot.get_inventory(defines.inventory.robot_cargo) diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 5c9d499d..a8a009f4 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -442,7 +442,7 @@ local compare_collapse_and_train = function() Public.set_difficulty() else Collapse.set_speed(1) - Collapse.set_amount(4) + Collapse.set_amount(40) end end diff --git a/maps/mountain_fortress_v3/stateful/table.lua b/maps/mountain_fortress_v3/stateful/table.lua index 7094f0d5..f4e935b8 100644 --- a/maps/mountain_fortress_v3/stateful/table.lua +++ b/maps/mountain_fortress_v3/stateful/table.lua @@ -191,7 +191,7 @@ local function get_random_buff() modifier = 'starting_items', limit = nil, items = { - {name = 'assembling-machine', count = 1} + {name = 'assembling-machine-1', count = 1} } }, { @@ -708,6 +708,10 @@ local apply_settings_token = return end + if not settings.current_date then + settings.current_date = tonumber(current_time) + end + this.current_date = settings.current_date this.buffs = settings.buffs diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index 6886f525..14bd8499 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -125,6 +125,7 @@ function Public.reset_main_table() hinders = {}, gap = 900, neg_gap = -3520, -- earlier 2112 (3 zones, whereas 704 is one zone) + neg_gap_collapse = -5520, -- earlier 2112 (3 zones, whereas 704 is one zone) highest_pos = nil } this.force_chunk = false