From a413bae9f2554709fc64a0ab8aa267a11fbfe185 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sun, 2 Jun 2024 17:33:54 +0200 Subject: [PATCH] Fix broken things --- maps/mountain_fortress_v3/functions.lua | 8 ++++-- maps/mountain_fortress_v3/stateful/table.lua | 26 ++++++++++++++++++-- maps/mountain_fortress_v3/table.lua | 1 + utils/core.lua | 11 +++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index dbd46e0f..6ab7441c 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -1642,13 +1642,17 @@ function Public.on_research_finished(event) local research_name = research.name local force = research.force - if event.tick > 1000 then + if event.tick > 100 then if Public.get('print_tech_to_discord') and force.name == 'player' then Server.to_discord_embed_raw(' ' .. research_name:gsub('^%l', string.upper) .. ' has been researched!') end end - research.force.character_inventory_slots_bonus = player.mining_drill_productivity_bonus * 50 -- +5 Slots / + if research.name == 'toolbelt' then + Public.set('toobelt_researched_count', 10) + end + + research.force.character_inventory_slots_bonus = (player.mining_drill_productivity_bonus * 50) + Public.get('toobelt_researched_count') if bonus_drill then bonus_drill.mining_drill_productivity_bonus = bonus_drill.mining_drill_productivity_bonus + 0.03 if bonus_drill.mining_drill_productivity_bonus >= 3 then diff --git a/maps/mountain_fortress_v3/stateful/table.lua b/maps/mountain_fortress_v3/stateful/table.lua index d0ea7b3d..ded97498 100644 --- a/maps/mountain_fortress_v3/stateful/table.lua +++ b/maps/mountain_fortress_v3/stateful/table.lua @@ -1698,13 +1698,18 @@ function Public.move_all_players() return end + local locomotive = Public.get('locomotive') + if not locomotive or not locomotive.valid then + return + end + ICWF.disable_auto_minimap() local message = ({'stateful.final_boss_message_start'}) Alert.alert_all_players(50, message, nil, nil, 1) Core.iter_connected_players( function(player) - local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0) + local pos = surface.find_non_colliding_position('character', locomotive.position, 10, 0) Public.stateful_gui.boss_frame(player, true) @@ -1712,11 +1717,28 @@ function Public.move_all_players() player.teleport(pos) else pos = game.forces.player.get_spawn_position(surface) - player.teleport(pos) + player.teleport(locomotive.position) Public.unstuck_player(player.index) end end ) + + if _DEBUG then + Core.iter_fake_connected_players( + global.characters, + function(player) + local pos = surface.find_non_colliding_position('character', locomotive.position, 10, 0) + + if pos then + player.teleport(pos) + else + pos = game.forces.player.get_spawn_position(surface) + player.teleport(locomotive.position) + Public.unstuck_player(player.index) + end + end + ) + end end function Public.set_final_battle() diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index b9a408db..e09c5c9c 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -137,6 +137,7 @@ function Public.reset_main_table() this.locomotive_health = 10000 this.locomotive_max_health = 10000 this.extra_wagons = 0 + this.toobelt_researched_count = 0 this.all_the_fish = false this.reverse_collapse_warning = false this.gap_between_zones = { diff --git a/utils/core.lua b/utils/core.lua index 3c24e9ad..8a0ecda8 100644 --- a/utils/core.lua +++ b/utils/core.lua @@ -115,6 +115,17 @@ function Public.iter_connected_players(callback) end end +--- Iterates over all connected players +---@param callback function +function Public.iter_fake_connected_players(players, callback) + for i = 1, #players do + local player = players[i] + if player and player.valid then + callback(player, i) + end + end +end + --- Iterates over all players ---@param callback function function Public.iter_players(callback)