diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index c375e38f..d3c04837 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -412,6 +412,7 @@ atsea_loading_tooltip=The next destination is loading. defeat_krakens_tooltip=Defeat the krakens to proceed. leave_anytime_tooltip=The captain chooses when to undock the ship.\n\nThey can undock by pressing this button. atsea_waiting_tooltip=The ship pauses after each destination. When the captain is ready, they can click this button to proceed. +atsea_victorious_tooltip=The crew has won. The captain can click here to proceed on Freeplay. resources_needed_tooltip_0=At the next destination, these resources will be needed in order to undock. @@ -567,6 +568,7 @@ gui_etaframe_autoundock=Auto-undock: gui_etaframe_loading_for=Loading for gui_etaframe_defeat_krakens=Defeat the krakens! gui_etaframe_atsea_waiting=Captain — Click here to Approach +gui_etaframe_atsea_victorious=Captain — Click here to Proceed gui_etaframe_undock=Undock: gui_etaframe_anytime=Anytime gui_etaframe_next_escape_cost=Next escape cost: diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index d332920b..27515fc6 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -100,8 +100,7 @@ end function Public.apply_restrictions_to_machines(tickinterval) local memory = Memory.get_crew_memory() - if Common.activecrewcount() == 0 and not (memory.force_toggle_machine_states) then return end - memory.force_toggle_machine_states = false + if Common.activecrewcount() == 0 then return end local boat = memory.boat local surfaces_to_check = {} @@ -135,7 +134,7 @@ function Public.apply_restrictions_to_machines(tickinterval) force = memory.force_name } - local disable_crafters = boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL + local disable_crafters = boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL or boat.state == Boats.enum_state.ATSEA_VICTORIOUS for _, machine in ipairs(crafters) do if machine and machine.valid then @@ -286,7 +285,7 @@ function Public.victory_continue_reminder() if memory.victory_continue_reminder and game.tick >= memory.victory_continue_reminder then memory.victory_continue_reminder = nil - if memory.boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL then + if memory.boat.state == Boats.enum_state.ATSEA_VICTORIOUS then Common.notify_force(memory.force, {'pirates.victory_continue_reminder'}, CoreData.colors.notify_victory) end end diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index 4986ffe7..f92fa032 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -172,7 +172,7 @@ function Public.try_win() game.play_sound{path='utility/game_won', volume_modifier=0.9} - memory.boat.state = Boats.enum_state.ATSEA_WAITING_TO_SAIL + memory.boat.state = Boats.enum_state.ATSEA_VICTORIOUS memory.victory_continue_reminder = game.tick + 60*14 memory.victory_continue_message = true end diff --git a/maps/pirates/gui/common.lua b/maps/pirates/gui/common.lua index 40908927..ceb21c24 100644 --- a/maps/pirates/gui/common.lua +++ b/maps/pirates/gui/common.lua @@ -398,7 +398,7 @@ function Public.player_and_crew_state_bools(player) local destination = Common.current_destination() local dynamic_data = destination.dynamic_data --assumes this always exists - local in_crowsnest_bool, in_hold_bool, in_cabin_bool, onmap_bool, eta_bool, approaching_bool, retreating_bool, atsea_sailing_bool, landed_bool, quest_bool, silo_bool, charged_bool, launched_bool, captain_bool, atsea_loading_bool, atsea_waiting_bool, character_on_deck_bool, on_deck_standing_near_loco_bool, on_deck_standing_near_cabin_bool, on_deck_standing_near_crowsnest_bool, cost_bool, cost_includes_rocket_launch_bool, approaching_dock_bool, leaving_dock_bool, leave_anytime_bool + local in_crowsnest_bool, in_hold_bool, in_cabin_bool, onmap_bool, eta_bool, approaching_bool, retreating_bool, atsea_sailing_bool, landed_bool, quest_bool, silo_bool, charged_bool, launched_bool, captain_bool, atsea_loading_bool, atsea_waiting_bool, atsea_victorious_bool, character_on_deck_bool, on_deck_standing_near_loco_bool, on_deck_standing_near_cabin_bool, on_deck_standing_near_crowsnest_bool, cost_bool, cost_includes_rocket_launch_bool, approaching_dock_bool, leaving_dock_bool, leave_anytime_bool captain_bool = Common.is_captain(player) @@ -417,13 +417,14 @@ function Public.player_and_crew_state_bools(player) -- approaching_bool = boat and boat.state == Boats.enum_state.APPROACHING atsea_sailing_bool = boat and boat.state == Boats.enum_state.ATSEA_SAILING atsea_waiting_bool = boat and boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL + atsea_victorious_bool = boat and boat.state == Boats.enum_state.ATSEA_VICTORIOUS landed_bool = boat and boat.state == Boats.enum_state.LANDED quest_bool = (dynamic_data.quest_type ~= nil) and onmap_bool charged_bool = dynamic_data.silocharged silo_bool = dynamic_data.rocketsilos and onmap_bool and ((dynamic_data.rocketsilos[1] and dynamic_data.rocketsilos[1].valid) or charged_bool) launched_bool = dynamic_data.rocketlaunched - cost_bool = destination.static_params.base_cost_to_undock and (not atsea_sailing_bool) and (not atsea_waiting_bool) and (not retreating_bool) + cost_bool = destination.static_params.base_cost_to_undock and (not atsea_sailing_bool) and (not atsea_waiting_bool) and (not atsea_victorious_bool) and (not retreating_bool) cost_includes_rocket_launch_bool = cost_bool and destination.static_params.base_cost_to_undock['launch_rocket'] leave_anytime_bool = (landed_bool and not (eta_bool or cost_bool)) @@ -458,6 +459,7 @@ function Public.player_and_crew_state_bools(player) retreating_bool = retreating_bool, atsea_sailing_bool = atsea_sailing_bool, atsea_waiting_bool = atsea_waiting_bool, + atsea_victorious_bool = atsea_victorious_bool, -- landed_bool = landed_bool, quest_bool = quest_bool, silo_bool = silo_bool, diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index 8a564466..205781ca 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -529,7 +529,7 @@ function Public.process_etaframe_update(player, flow1, bools) local flow2 - if bools.cost_bool or bools.atsea_loading_bool or bools.atsea_waiting_bool or bools.eta_bool or bools.retreating_bool or bools.leave_anytime_bool then + if bools.cost_bool or bools.atsea_loading_bool or bools.atsea_waiting_bool or bools.atsea_victorious_bool or bools.eta_bool or bools.retreating_bool or bools.leave_anytime_bool then flow1.visible = true ---@type string|table @@ -596,6 +596,14 @@ function Public.process_etaframe_update(player, flow1, bools) flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_waiting'} + elseif bools.atsea_victorious_bool then + flow2.etaframe_label_1.visible = true + flow2.etaframe_label_2.visible = false + + tooltip = {'pirates.atsea_victorious_tooltip'} + + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_victorious'} + elseif bools.leave_anytime_bool then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = true @@ -1258,6 +1266,18 @@ local function on_gui_click(event) Progression.progress_to_destination(destination_index) memory.loadingticks = 0 end + + elseif memory.boat.state == Boats.enum_state.ATSEA_VICTORIOUS then + if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + memory.boat.state = Boats.enum_state.ATSEA_SAILING + + local force = memory.force + if not (force and force.valid) then return end + if memory.victory_continue_message then + memory.victory_continue_message = false + Common.notify_force(force, {'pirates.crew_continue_on_freeplay'}, CoreData.colors.notify_victory) + end + end end elseif string.sub(event.element.name, -13, -1) and string.sub(event.element.name, -13, -1) == '_piratebutton' then diff --git a/maps/pirates/progression.lua b/maps/pirates/progression.lua index 19c732f7..5d39b0b4 100644 --- a/maps/pirates/progression.lua +++ b/maps/pirates/progression.lua @@ -567,14 +567,13 @@ function Public.go_from_currentdestination_to_sea() Sea.ensure_sea_surface() local seaname = memory.sea_name - local boat = memory.boat - local new_boatposition = Utils.snap_coordinates_for_rails({x = Boats.get_scope(memory.boat).Data.width / 2, y = 0}) + local new_boatposition = Utils.snap_coordinates_for_rails({x = Boats.get_scope(boat).Data.width / 2, y = 0}) Boats.teleport_boat(boat, seaname, new_boatposition, CoreData.static_boat_floor, 'water') - if memory.overworldx == 0 and memory.boat then + if memory.overworldx == 0 and boat then local difficulty_name = CoreData.get_difficulty_option_informal_name_from_value(memory.difficulty) if difficulty_name == 'nightmare' then @@ -601,13 +600,6 @@ function Public.go_from_currentdestination_to_sea() boat.surface_name = seaname boat.fish_caught_while_at_sea = 0 -- how many times a fish was caught, rather than amount of fish caught in total - local force = memory.force - if not (force and force.valid) then return end - if memory.victory_continue_message then - memory.victory_continue_message = false - Common.notify_force(force, {'pirates.crew_continue_on_freeplay'}, CoreData.colors.notify_victory) - end - memory.enemy_force.reset_evolution() --@FIX: This doesn't change the evo during sea travel, which is relevant now that krakens are in the game: diff --git a/maps/pirates/structures/boats/boats.lua b/maps/pirates/structures/boats/boats.lua index 06873ba0..a787b16a 100644 --- a/maps/pirates/structures/boats/boats.lua +++ b/maps/pirates/structures/boats/boats.lua @@ -36,6 +36,7 @@ local enum_state = { ATSEA_SAILING = 'at_sea', ATSEA_LOADING_MAP = 'waiting_for_load', ATSEA_WAITING_TO_SAIL = 'waiting_for_sail', + ATSEA_VICTORIOUS = 'waiting_for_sail', DOCKED = 'docked', } Public.enum_state = enum_state @@ -1494,6 +1495,7 @@ function Public.is_boat_at_sea() ( boat.state == Public.enum_state.ATSEA_SAILING or boat.state == Public.enum_state.ATSEA_WAITING_TO_SAIL or + boat.state == Public.enum_state.ATSEA_VICTORIOUS or boat.state == Public.enum_state.ATSEA_LOADING_MAP ) then