From f78b2ff0c69fa7bb8fbe5c86e199f3eddf8f2d11 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:23:26 +0100 Subject: [PATCH 01/50] fix halting load when other player is waiting at sea --- maps/pirates/api_on_tick.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index 14fde4f7..65a907d9 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -1008,7 +1008,9 @@ function Public.loading_update(tickinterval) local crew_fighting_kraken = nil for id, crew_memory in pairs(global_memory.crew_memories) do - if crew_memory.loadingticks and (crew_memory.loadingticks > memory.loadingticks or (crew_memory.loadingticks == memory.loadingticks and id < memory.id)) then + local is_loading = crew_memory.loadingticks ~= nil and crew_memory.boat and crew_memory.boat.state and crew_memory.boat.state == Boats.enum_state.ATSEA_LOADING_MAP + + if is_loading and (crew_memory.loadingticks > memory.loadingticks or (crew_memory.loadingticks == memory.loadingticks and id < memory.id)) then other_crew_loading = id end From 0340d7fe64024783aa230b457b4a61c54ffc17e6 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:31:33 +0100 Subject: [PATCH 02/50] start on the ship closest to you --- maps/pirates/api_on_tick.lua | 2 +- maps/pirates/commands.lua | 2 +- maps/pirates/crew.lua | 17 ++-- maps/pirates/gui/runs.lua | 165 +++++++++++++++++------------------ 4 files changed, 96 insertions(+), 90 deletions(-) diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index 65a907d9..3872b5fd 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -1010,7 +1010,7 @@ function Public.loading_update(tickinterval) for id, crew_memory in pairs(global_memory.crew_memories) do local is_loading = crew_memory.loadingticks ~= nil and crew_memory.boat and crew_memory.boat.state and crew_memory.boat.state == Boats.enum_state.ATSEA_LOADING_MAP - if is_loading and (crew_memory.loadingticks > memory.loadingticks or (crew_memory.loadingticks == memory.loadingticks and id < memory.id)) then + if is_loading and (crew_memory.loadingticks > memory.loadingticks or (crew_memory.loadingticks == memory.loadingticks and crew_memory.age < memory.age)) then other_crew_loading = id end diff --git a/maps/pirates/commands.lua b/maps/pirates/commands.lua index 823d6a63..9b4a5004 100644 --- a/maps/pirates/commands.lua +++ b/maps/pirates/commands.lua @@ -632,7 +632,7 @@ if _DEBUG then created_by_player = cmd.player_index } - Crew.initialise_crew(proposal) + Crew.initialise_crew(proposal, player.position) Crew.initialise_crowsnest() --contains a Task local memory = Memory.get_crew_memory() diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index 9fafb98a..313b8d03 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -635,17 +635,24 @@ function Public.disband_crew(donotprint) Lobby.place_starting_dock_showboat(id) end -function Public.generate_new_crew_id() +function Public.generate_new_crew_id(player_position) local global_memory = Memory.get_global_memory() local max_crews = Common.starting_ships_count + local closest_id = nil + local closest_distance = math.huge for id = 1, max_crews do if not global_memory.crew_memories[id] then - return id + local boat_position = Lobby.StartingBoats[id].position + local distance = Math.distance(player_position, boat_position) + if distance < closest_distance then + closest_distance = distance + closest_id = id + end end end - return nil + return closest_id end function Public.player_abandon_proposal(player) @@ -680,10 +687,10 @@ function Public.initialise_crowsnest_2() Crowsnest.crowsnest_surface_delayed_init() end -function Public.initialise_crew(accepted_proposal) +function Public.initialise_crew(accepted_proposal, player_position) local global_memory = Memory.get_global_memory() - local new_id = Public.generate_new_crew_id() + local new_id = Public.generate_new_crew_id(player_position) if not new_id then return end game.reset_time_played() -- affects the multiplayer lobby view diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index ac6bfce1..7f28a1f8 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -29,8 +29,8 @@ local function flow_add_proposal_slider(flow, name, displayname, indices_count, type = 'flow', direction = 'vertical', }) - flow2.style.horizontal_align = 'left' - flow2.style.width = 130 + flow2.style.horizontal_align = 'left' + flow2.style.width = 130 flow3 = flow2.add({ type = 'label', @@ -38,10 +38,10 @@ local function flow_add_proposal_slider(flow, name, displayname, indices_count, }) flow3.style.font = 'heading-3' flow3.style.height = 20 - flow3.style.margin = 0 - flow3.style.padding = 0 - flow3.style.top_padding = -4 - flow3.style.bottom_margin = 0 + flow3.style.margin = 0 + flow3.style.padding = 0 + flow3.style.top_padding = -4 + flow3.style.bottom_margin = 0 flow3.style.font_color = GuiCommon.subsection_header_font_color flow3.tooltip = tooltip @@ -50,8 +50,8 @@ local function flow_add_proposal_slider(flow, name, displayname, indices_count, type = 'flow', direction = 'vertical', }) - flow3.style.horizontal_align = 'center' - flow3.style.width = 130 + flow3.style.horizontal_align = 'center' + flow3.style.width = 130 flow4 = flow3.add({ name = 'slider', @@ -64,7 +64,7 @@ local function flow_add_proposal_slider(flow, name, displayname, indices_count, discrete_slider = true, }) flow4.style.width = 100 - flow4.style.margin = 0 + flow4.style.margin = 0 flow4.tooltip = tooltip flow4 = flow3.add({ @@ -74,10 +74,10 @@ local function flow_add_proposal_slider(flow, name, displayname, indices_count, }) flow4.style.font = 'default-listbox' flow4.style.height = 20 - flow4.style.margin = 0 - flow4.style.padding = 0 - flow4.style.top_padding = 0 - flow4.style.bottom_margin = 16 + flow4.style.margin = 0 + flow4.style.padding = 0 + flow4.style.top_padding = 0 + flow4.style.bottom_margin = 16 flow4.tooltip = tooltip flow2 = flow.add({ @@ -167,31 +167,34 @@ function Public.toggle_window(player) local flow, flow2, flow3, flow4, flow5 --*** OVERALL FLOW ***-- - if player.gui.screen[window_name .. '_piratewindow'] then player.gui.screen[window_name .. '_piratewindow'].destroy() return end + if player.gui.screen[window_name .. '_piratewindow'] then + player.gui.screen[window_name .. '_piratewindow'].destroy() + return + end window = GuiCommon.new_window(player, window_name) - window.caption = {'pirates.gui_runs_play'} + window.caption = { 'pirates.gui_runs_play' } flow = window.add { - type = 'scroll-pane', - name = 'scroll_pane', - direction = 'vertical', - horizontal_scroll_policy = 'never', + type = 'scroll-pane', + name = 'scroll_pane', + direction = 'vertical', + horizontal_scroll_policy = 'never', vertical_scroll_policy = 'auto-and-reserve-space' - } - flow.style.maximal_height = 500 + } + flow.style.maximal_height = 500 flow.style.bottom_margin = 10 --*** ONGOING RUNS ***-- - flow2 = GuiCommon.flow_add_section(flow, 'ongoing_runs', {'pirates.gui_runs_ongoing_runs'}) + flow2 = GuiCommon.flow_add_section(flow, 'ongoing_runs', { 'pirates.gui_runs_ongoing_runs' }) flow3 = flow2.add({ name = 'helpful_tip', type = 'label', - caption = {'pirates.gui_runs_ongoing_runs_helpful_tip'}, + caption = { 'pirates.gui_runs_ongoing_runs_helpful_tip' }, }) - flow3.style.font_color = {r=0.90, g=0.90, b=0.90} + flow3.style.font_color = { r = 0.90, g = 0.90, b = 0.90 } flow3.style.single_line = false flow3.style.maximal_width = 160 @@ -206,7 +209,7 @@ function Public.toggle_window(player) flow3 = flow2.add({ name = 'join_protected_crew_info', type = 'label', - caption = {'pirates.gui_join_protected_run_info', 0, 0, 0}, + caption = { 'pirates.gui_join_protected_run_info', 0, 0, 0 }, visible = false, }) flow3.style.single_line = false @@ -214,7 +217,7 @@ function Public.toggle_window(player) flow3 = flow2.add({ name = 'join_private_crew_info', type = 'label', - caption = {'pirates.gui_join_private_run_info', 0, 0, 0}, + caption = { 'pirates.gui_join_private_run_info', 0, 0, 0 }, visible = false, }) flow3.style.single_line = false @@ -239,29 +242,29 @@ function Public.toggle_window(player) flow4 = flow3.add({ name = 'join_spectators', type = 'button', - caption = {'pirates.gui_runs_ongoing_runs_spectate'}, + caption = { 'pirates.gui_runs_ongoing_runs_spectate' }, }) flow4.style.minimal_width = 95 flow4.style.font = 'default-bold' - flow4.style.font_color = {r=0.10, g=0.10, b=0.10} + flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 } flow4 = flow3.add({ name = 'join_crew', type = 'button', - caption = {'pirates.gui_runs_ongoing_runs_join_crew'}, + caption = { 'pirates.gui_runs_ongoing_runs_join_crew' }, }) flow4.style.minimal_width = 95 flow4.style.font = 'default-bold' - flow4.style.font_color = {r=0.10, g=0.10, b=0.10} + flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 } flow4 = flow3.add({ name = 'leave_spectators', type = 'button', - caption = {'pirates.gui_runs_ongoing_runs_return_to_lobby'}, + caption = { 'pirates.gui_runs_ongoing_runs_return_to_lobby' }, }) flow4.style.minimal_width = 95 flow4.style.font = 'default-bold' - flow4.style.font_color = {r=0.10, g=0.10, b=0.10} + flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 } flow3 = flow2.add({ name = 'wait_to_join', @@ -272,14 +275,14 @@ function Public.toggle_window(player) flow3 = flow2.add({ name = 'leaving_prompt', type = 'label', - caption = {'pirates.gui_runs_ongoing_runs_hop_on_board'}, + caption = { 'pirates.gui_runs_ongoing_runs_hop_on_board' }, }) flow3.style.left_margin = 5 -- PROPOSALS -- - flow2 = GuiCommon.flow_add_section(flow, 'proposals', {'pirates.gui_runs_proposals'}) + flow2 = GuiCommon.flow_add_section(flow, 'proposals', { 'pirates.gui_runs_proposals' }) flow3 = flow2.add({ name = 'proposals_listbox', @@ -298,11 +301,11 @@ function Public.toggle_window(player) flow4 = flow3.add({ name = 'abandon_proposal', type = 'button', - caption = {'pirates.gui_runs_proposals_abandon_proposal'}, + caption = { 'pirates.gui_runs_proposals_abandon_proposal' }, }) flow4.style.minimal_width = 150 flow4.style.font = 'default-bold' - flow4.style.font_color = {r=0.10, g=0.10, b=0.10} + flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 } flow4.style.bottom_margin = 9 @@ -315,19 +318,19 @@ function Public.toggle_window(player) type = 'flow', direction = 'vertical', }) - flow4.style.horizontal_align = 'center' - flow4.style.vertical_align = 'center' + flow4.style.horizontal_align = 'center' + flow4.style.vertical_align = 'center' flow5 = flow4.add({ type = 'label', - caption = {'pirates.gui_runs_proposal_maker_run_name'}, + caption = { 'pirates.gui_runs_proposal_maker_run_name' }, }) flow5.style.font = 'heading-3' flow5 = flow4.add({ name = 'namefield', type = 'textfield', - caption = {'pirates.gui_runs_proposal_maker_run_name_2'}, + caption = { 'pirates.gui_runs_proposal_maker_run_name_2' }, text = '', }) flow5.style.width = 150 @@ -340,9 +343,9 @@ function Public.toggle_window(player) flow4.add({ name = 'protected_checkbox', type = 'checkbox', - caption = {'pirates.gui_runs_proposal_maker_protected'}, + caption = { 'pirates.gui_runs_proposal_maker_protected' }, state = false, - tooltip = {'pirates.gui_runs_proposal_maker_protected_tooltip', CoreData.protected_run_lock_amount_hr} + tooltip = { 'pirates.gui_runs_proposal_maker_protected_tooltip', CoreData.protected_run_lock_amount_hr } }) -- PRIVATE RUN ELEMENTS -- @@ -350,15 +353,15 @@ function Public.toggle_window(player) flow4.add({ name = 'private_checkbox', type = 'checkbox', - caption = {'pirates.gui_runs_proposal_maker_private'}, + caption = { 'pirates.gui_runs_proposal_maker_private' }, state = false, - tooltip = {'pirates.gui_runs_proposal_maker_private_tooltip', CoreData.private_run_lock_amount_hr} + tooltip = { 'pirates.gui_runs_proposal_maker_private_tooltip', CoreData.private_run_lock_amount_hr } }) flow5 = flow4.add({ name = 'password_label', type = 'label', - caption = {'pirates.gui_runs_proposal_maker_password'}, + caption = { 'pirates.gui_runs_proposal_maker_password' }, }) flow5.style.font = 'heading-3' @@ -375,7 +378,7 @@ function Public.toggle_window(player) flow5 = flow4.add({ name = 'confirm_password_label', type = 'label', - caption = {'pirates.gui_runs_proposal_maker_confirm_password'}, + caption = { 'pirates.gui_runs_proposal_maker_confirm_password' }, }) flow5.style.font = 'heading-3' @@ -399,7 +402,7 @@ function Public.toggle_window(player) flow5.style.width = 200 flow5.style.margin = 0 - flow_add_proposal_slider(flow5, 'capacity', {'pirates.gui_runs_proposal_maker_capacity'}, #CoreData.capacity_options, 5, {'pirates.capacity_tooltip'}) + flow_add_proposal_slider(flow5, 'capacity', { 'pirates.gui_runs_proposal_maker_capacity' }, #CoreData.capacity_options, 5, { 'pirates.capacity_tooltip' }) -- flow_add_proposal_slider(flow5, 'difficulty', 'Difficulty', #CoreData.difficulty_options, 2, {'pirates.difficulty_tooltip'}) -- flow_add_proposal_switch(flow5, 'mode', 'Mode', 'left', {'pirates.mode_tooltip'}) @@ -414,7 +417,7 @@ function Public.toggle_window(player) flow5 = flow4.add({ name = 'proposal_disabled_low_crew_caps', type = 'label', - caption = {'pirates.gui_runs_proposal_maker_capacity_disabled'}, + caption = { 'pirates.gui_runs_proposal_maker_capacity_disabled' }, }) flow5.style.single_line = false flow5.style.maximal_width = 200 @@ -422,11 +425,11 @@ function Public.toggle_window(player) flow5 = flow4.add({ name = 'propose_crew', type = 'button', - caption = {'pirates.gui_runs_proposal_maker_propose'}, + caption = { 'pirates.gui_runs_proposal_maker_propose' }, }) flow5.style.minimal_width = 75 flow5.style.font = 'default-bold' - flow5.style.font_color = {r=0.10, g=0.10, b=0.10} + flow5.style.font_color = { r = 0.10, g = 0.10, b = 0.10 } -- LAUNCH YOUR PROPOSAL -- @@ -440,33 +443,30 @@ function Public.toggle_window(player) flow4 = flow3.add({ name = 'proposal_crew_count_capped', type = 'label', - caption = {'pirates.gui_runs_launch_error_2'}, + caption = { 'pirates.gui_runs_launch_error_2' }, }) flow4.style.single_line = false flow4 = flow3.add({ name = 'proposal_insufficient_sloops', type = 'label', - caption = {'pirates.gui_runs_launch_error_4'}, + caption = { 'pirates.gui_runs_launch_error_4' }, }) flow4.style.single_line = false flow4 = flow3.add({ name = 'launch_crew', type = 'button', - caption = {'pirates.gui_runs_launch'}, + caption = { 'pirates.gui_runs_launch' }, }) flow4.style.minimal_width = 150 flow4.style.font = 'default-bold' - flow4.style.font_color = {r=0.10, g=0.10, b=0.10} + flow4.style.font_color = { r = 0.10, g = 0.10, b = 0.10 } GuiCommon.flow_add_close_button(window, window_name .. '_piratebutton') end - - - -- function Public.regular_update(player) -- end @@ -505,7 +505,7 @@ function Public.full_update(player) flow.ongoing_runs.body.wait_to_join.visible = selected_joinable_bool and crewid and global_memory.crew_memories[crewid] and (global_memory.crew_memories[crewid].tempbanned_from_joining_data and global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] and game.tick < global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks) and (not (global_memory.crew_memories[crewid].crewstatus == Crew.enum.LEAVING_INITIAL_DOCK or #global_memory.crew_memories[crewid].crewplayerindices >= global_memory.crew_memories[crewid].capacity)) if flow.ongoing_runs.body.wait_to_join.visible then - flow.ongoing_runs.body.wait_to_join.caption = {'pirates.gui_runs_wait_to_join', Math.ceil(((global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] - (game.tick - Common.ban_from_rejoining_crew_ticks)))/60)} + flow.ongoing_runs.body.wait_to_join.caption = { 'pirates.gui_runs_wait_to_join', Math.ceil(((global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] - (game.tick - Common.ban_from_rejoining_crew_ticks))) / 60) } end if not selected_joinable_bool then flow.ongoing_runs.body.ongoing_runs_listbox.selected_index = 0 end @@ -576,7 +576,7 @@ function Public.full_update(player) elseif mem.run_is_protected then extraCrewText = ' (protected)' end - wrappedmemories[#wrappedmemories + 1] = {'pirates.run_displayform', mem.id, {'', mem.name .. extraCrewText .. ', ', CoreData.difficulty_options[mem.difficulty_option].text, ', [item=light-armor]' .. count .. CoreData.capacity_options[mem.capacity_option].text2 .. ', [item=rail] ' .. (mem.overworldx or 0)}} + wrappedmemories[#wrappedmemories + 1] = { 'pirates.run_displayform', mem.id, { '', mem.name .. extraCrewText .. ', ', CoreData.difficulty_options[mem.difficulty_option].text, ', [item=light-armor]' .. count .. CoreData.capacity_options[mem.capacity_option].text2 .. ', [item=rail] ' .. (mem.overworldx or 0) } } -- wrappedmemories[#wrappedmemories + 1] = {'pirates.run_displayform', mem.id, mem.name, Utils.spritepath_to_richtext(CoreData.difficulty_options[mem.difficulty_option].icon), count, CoreData.capacity_options[mem.capacity_option].text2, ' [item=rail] ', mem.overworldx or 0} end GuiCommon.update_listbox(flow.ongoing_runs.body.ongoing_runs_listbox, wrappedmemories) @@ -593,7 +593,7 @@ function Public.full_update(player) local sec = Math.floor((lock_timer / (60)) % 60) local min = Math.floor((lock_timer / (60 * 60)) % 60) local hrs = Math.floor((lock_timer / (60 * 60 * 60)) % 60) - flow.ongoing_runs.body.join_protected_crew_info.caption = {'pirates.gui_join_protected_run_info', hrs, min, sec} + flow.ongoing_runs.body.join_protected_crew_info.caption = { 'pirates.gui_join_protected_run_info', hrs, min, sec } end -- Update timer when run will become public @@ -602,14 +602,14 @@ function Public.full_update(player) local sec = Math.floor((lock_timer / (60)) % 60) local min = Math.floor((lock_timer / (60 * 60)) % 60) local hrs = Math.floor((lock_timer / (60 * 60 * 60)) % 60) - flow.ongoing_runs.body.join_private_crew_info.caption = {'pirates.gui_join_private_run_info', hrs, min, sec} + flow.ongoing_runs.body.join_private_crew_info.caption = { 'pirates.gui_join_private_run_info', hrs, min, sec } end end if flow.proposals.visible then local wrappedproposals = {} for _, proposal in pairs(global_memory.crewproposals) do - wrappedproposals[#wrappedproposals + 1] = {'pirates.proposal_displayform', proposal.name, Utils.spritepath_to_richtext(CoreData.capacity_options[proposal.capacity_option].icon)} + wrappedproposals[#wrappedproposals + 1] = { 'pirates.proposal_displayform', proposal.name, Utils.spritepath_to_richtext(CoreData.capacity_options[proposal.capacity_option].icon) } -- wrappedproposals[#wrappedproposals + 1] = {'pirates.proposal_displayform', proposal.name, Utils.spritepath_to_richtext(CoreData.difficulty_options[proposal.difficulty_option].icon), Utils.spritepath_to_richtext(CoreData.capacity_options[proposal.capacity_option].icon)} end GuiCommon.update_listbox(flow.proposals.body.proposals_listbox, wrappedproposals) @@ -624,7 +624,7 @@ function Public.full_update(player) flow.proposals.body.proposal_maker.body.options.capacity_readoff_icon.sprite = opt.icon end end - if flow.proposals.body.proposal_maker.body.options.capacity.capacity.readoff_text.caption == '∞' then flow.proposals.body.proposal_maker.body.options.capacity.capacity.readoff_text.caption = {'pirates.gui_runs_proposal_maker_no_limit'} end + if flow.proposals.body.proposal_maker.body.options.capacity.capacity.readoff_text.caption == '∞' then flow.proposals.body.proposal_maker.body.options.capacity.capacity.readoff_text.caption = { 'pirates.gui_runs_proposal_maker_no_limit' } end -- local difficulty_slider_value = flow.proposals.body.proposal_maker.body.options.difficulty.difficulty.slider.slider_value -- for i, opt in pairs(CoreData.difficulty_options) do @@ -644,7 +644,6 @@ function Public.full_update(player) end end - function Public.click(event) if not event.element then return end if not event.element.valid then return end @@ -695,18 +694,18 @@ function Public.click(event) flow.ongoing_runs.body.password_namefield.visible = false if memory.run_is_protected and (not Roles.captain_exists()) then - Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'}) - Common.notify_player_expected(player, {'pirates.create_new_crew_tip'}) + Common.notify_player_expected(player, { 'pirates.player_joins_protected_run_with_no_captain' }) + Common.notify_player_expected(player, { 'pirates.create_new_crew_tip' }) end else - Common.notify_player_error(player, {'pirates.gui_join_private_run_error_wrong_password'}) + Common.notify_player_error(player, { 'pirates.gui_join_private_run_error_wrong_password' }) end else Crew.join_crew(player) if memory.run_is_protected and (not Roles.captain_exists()) then - Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'}) - Common.notify_player_expected(player, {'pirates.create_new_crew_tip'}) + Common.notify_player_expected(player, { 'pirates.player_joins_protected_run_with_no_captain' }) + Common.notify_player_expected(player, { 'pirates.create_new_crew_tip' }) end end @@ -716,7 +715,7 @@ function Public.click(event) if eventname == 'propose_crew' then if #global_memory.crew_active_ids >= global_memory.active_crews_cap_in_memory then - Common.notify_player_error(player, {'pirates.gui_runs_launch_error_5'}) + Common.notify_player_error(player, { 'pirates.gui_runs_launch_error_5' }) return end @@ -741,40 +740,40 @@ function Public.click(event) if run_is_private then -- Make sure private run can be created if private_run_count >= global_memory.private_run_cap then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_private_run_limit'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_private_run_limit' }) return end -- check if the player created any other private runs for _, id in pairs(global_memory.crew_active_ids) do if global_memory.crew_memories[id].run_is_private then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_two_private_runs'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_two_private_runs' }) return end end -- Check if passwords match if flow.proposals.body.proposal_maker.body.password_namefield.text ~= flow.proposals.body.proposal_maker.body.confirm_password_namefield.text then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_private_run_password_no_match'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_private_run_password_no_match' }) return end -- Check if passwords aren't empty if flow.proposals.body.proposal_maker.body.password_namefield.text == '' then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_private_run_password_empty'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_private_run_password_empty' }) return end elseif run_is_protected then -- Make sure protected run can be created if protected_but_not_private_run_count >= global_memory.protected_but_not_private_run_cap then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_protected_run_limit'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_protected_run_limit' }) return end -- check if the player created any other protected runs for _, id in pairs(global_memory.crew_active_ids) do if global_memory.crew_memories[id].run_is_protected then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_two_protected_runs'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_two_protected_runs' }) return end end @@ -788,7 +787,7 @@ function Public.click(event) end end if player_run_count >= 2 then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_three_runs'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_three_runs' }) return end @@ -848,9 +847,9 @@ function Public.click(event) global_memory.crewproposals[#global_memory.crewproposals + 1] = proposal if run_is_private then - Common.notify_lobby({'pirates.proposal_propose_private', player.name, proposal_name, CoreData.capacity_options[capacity_option].text3}) + Common.notify_lobby({ 'pirates.proposal_propose_private', player.name, proposal_name, CoreData.capacity_options[capacity_option].text3 }) else - Common.notify_lobby({'pirates.proposal_propose', player.name, proposal_name, CoreData.capacity_options[capacity_option].text3}) + Common.notify_lobby({ 'pirates.proposal_propose', player.name, proposal_name, CoreData.capacity_options[capacity_option].text3 }) end -- local message = player.name .. ' proposed the run ' .. proposal_name .. ' (difficulty ' .. CoreData.difficulty_options[difficulty_option].text .. ', capacity ' .. CoreData.capacity_options[capacity_option].text3 .. ').' @@ -877,7 +876,7 @@ function Public.click(event) end if private_run_count >= global_memory.private_run_cap then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_private_run_limit'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_private_run_limit' }) return end elseif proposal.run_is_protected then @@ -889,12 +888,12 @@ function Public.click(event) end if protected_but_not_private_run_count >= global_memory.protected_but_not_private_run_cap then - Common.notify_player_error(player, {'pirates.gui_runs_proposal_maker_error_protected_run_limit'}) + Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_protected_run_limit' }) return end end - Crew.initialise_crew(proposal) + Crew.initialise_crew(proposal, player.position) global_memory.crewproposals[k] = nil Progression.set_off_from_starting_dock() @@ -905,4 +904,4 @@ function Public.click(event) end end -return Public \ No newline at end of file +return Public From c998e1d35680deecc2909834cf15643915d82047 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:35:05 +0100 Subject: [PATCH 03/50] allow editing permissions on debug mode --- locale/en/pirates.cfg | 2 +- maps/pirates/roles/roles.lua | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 3d7f29e1..b565a5e9 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -15,7 +15,7 @@ softmod_info_new_players_2=Mine coal and other resources and bring them to the s softmod_info_tips_1=Features of the game that are hard to work out alone softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax -softmod_info_updates_1=v1.6.0 +softmod_info_updates_1=v1.6.1 softmod_info_updates_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Productivity modules are removed from the game until a later feature is released.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market softmod_info_credits_1=Credits diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index 949f8878..8d58fc8e 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -565,7 +565,9 @@ end function Public.try_create_permissions_groups() if not game.permissions.get_group('restricted_area') then local group = game.permissions.create_group('restricted_area') - group.set_allows_action(defines.input_action.edit_permission_group, false) + if not _DEBUG then + group.set_allows_action(defines.input_action.edit_permission_group, false) + end group.set_allows_action(defines.input_action.import_permissions_string, false) group.set_allows_action(defines.input_action.delete_permission_group, false) group.set_allows_action(defines.input_action.add_permission_group, false) @@ -602,7 +604,9 @@ function Public.try_create_permissions_groups() if not game.permissions.get_group('restricted_area_privileged') then local group = game.permissions.create_group('restricted_area_privileged') - group.set_allows_action(defines.input_action.edit_permission_group, false) + if not _DEBUG then + group.set_allows_action(defines.input_action.edit_permission_group, false) + end group.set_allows_action(defines.input_action.import_permissions_string, false) group.set_allows_action(defines.input_action.delete_permission_group, false) group.set_allows_action(defines.input_action.add_permission_group, false) @@ -634,7 +638,9 @@ function Public.try_create_permissions_groups() if not game.permissions.get_group('plebs') then local group = game.permissions.create_group('plebs') - group.set_allows_action(defines.input_action.edit_permission_group, false) + if not _DEBUG then + group.set_allows_action(defines.input_action.edit_permission_group, false) + end group.set_allows_action(defines.input_action.import_permissions_string, false) group.set_allows_action(defines.input_action.delete_permission_group, false) group.set_allows_action(defines.input_action.add_permission_group, false) @@ -653,7 +659,9 @@ function Public.try_create_permissions_groups() if not game.permissions.get_group('not_trusted') then local group = game.permissions.create_group('not_trusted') -- not_trusted.set_allows_action(defines.input_action.cancel_craft, false) - group.set_allows_action(defines.input_action.edit_permission_group, false) + if not _DEBUG then + group.set_allows_action(defines.input_action.edit_permission_group, false) + end group.set_allows_action(defines.input_action.import_permissions_string, false) group.set_allows_action(defines.input_action.delete_permission_group, false) group.set_allows_action(defines.input_action.add_permission_group, false) From 98ab3515735796cb99f87e6b4520086c55f2ad67 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:35:52 +0100 Subject: [PATCH 04/50] can't mark for deconstruction in restricted areas --- maps/pirates/roles/roles.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index 8d58fc8e..5c61be1b 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -586,6 +586,7 @@ function Public.try_create_permissions_groups() group.set_allows_action(defines.input_action.activate_cut, false) group.set_allows_action(defines.input_action.activate_paste, false) group.set_allows_action(defines.input_action.upgrade, false) + group.set_allows_action(defines.input_action.deconstruct, false) group.set_allows_action(defines.input_action.grab_blueprint_record, false) if not CoreData.blueprint_library_allowed then @@ -625,6 +626,7 @@ function Public.try_create_permissions_groups() group.set_allows_action(defines.input_action.activate_cut, false) group.set_allows_action(defines.input_action.activate_paste, false) group.set_allows_action(defines.input_action.upgrade, false) + group.set_allows_action(defines.input_action.deconstruct, false) if not CoreData.blueprint_library_allowed then group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) From bf14c4b935223f1176a753d733beb95f9a04f536 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:36:32 +0100 Subject: [PATCH 05/50] turn enemy expansion off --- maps/pirates/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index eca8837a..048c5ef3 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -1620,7 +1620,7 @@ function Public.init_game_settings(technology_price_multiplier) game.map_settings.path_finder.short_cache_min_algo_steps_to_cache = 100 game.map_settings.path_finder.cache_accept_path_start_distance_ratio = 0.1 - game.map_settings.enemy_expansion.enabled = true + game.map_settings.enemy_expansion.enabled = false -- faster expansion: -- game.map_settings.enemy_expansion.min_expansion_cooldown = 4 * 3600 -- game.map_settings.enemy_expansion.max_expansion_cooldown = 30 * 3600 From 0cfa6e34f16b3927346c207beab9db3c27ae4e44 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:38:24 +0100 Subject: [PATCH 06/50] scale up weapon damage upgrade cost --- maps/pirates/balance.lua | 5 ++++- maps/pirates/shop/shop.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index a06682e3..e33d6a8d 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -514,7 +514,10 @@ function Public.weapon_damage_upgrade_percentage() end function Public.weapon_damage_upgrade_price() - return { { name = 'coin', amount = 2000 }, { name = 'steel-plate', amount = 100 } } --NOTE: Should be different to other 'nothing' costs. See the use of this function in shop.lua. + -- local steel_plate_cost = 100 + local steel_plate_cost = 100 * (1 + 0.1 * (Common.overworldx() / 40)) + + return { { name = 'coin', amount = 2000 }, { name = 'steel-plate', amount = steel_plate_cost } } --NOTE: Coin cost should be different to other 'nothing' costs. See the use of this function in shop.lua. end Public.quest_structures_first_appear_at = 40 diff --git a/maps/pirates/shop/shop.lua b/maps/pirates/shop/shop.lua index 64af9525..a6da1da4 100644 --- a/maps/pirates/shop/shop.lua +++ b/maps/pirates/shop/shop.lua @@ -216,7 +216,7 @@ function Public.event_on_market_item_purchased(event) end else if thisPurchaseData.offer_type == 'nothing' then - local isDamageUpgrade = thisPurchaseData.price[1].amount == Balance.weapon_damage_upgrade_price()[1].amount and thisPurchaseData.price[1].name == Balance.weapon_damage_upgrade_price()[1].name and thisPurchaseData.price[2] and thisPurchaseData.price[2].amount == Balance.weapon_damage_upgrade_price()[2].amount and thisPurchaseData.price[2].name == Balance.weapon_damage_upgrade_price()[2].name + local isDamageUpgrade = thisPurchaseData.price[1].amount == Balance.weapon_damage_upgrade_price()[1].amount and thisPurchaseData.price[1].name == Balance.weapon_damage_upgrade_price()[1].name if isDamageUpgrade then Common.notify_force_light(player.force, { 'pirates.market_event_attack_upgrade_purchased', player.name, Balance.weapon_damage_upgrade_percentage() }) From 2637e47a162092274313a45858666202008e6bea Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:39:09 +0100 Subject: [PATCH 07/50] tweak --- maps/pirates/balance.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index e33d6a8d..de824e37 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -109,7 +109,7 @@ Public.EEI_stages = { --multipliers function Public.scripted_biters_pollution_cost_multiplier() local early_game_factor = 1 + 1.2 / ((1 + (Common.overworldx() / 40)) ^ (1.5 + Common.difficulty_scale())) -- the complicated factor makes the early-game easier; in particular the first island, but on easier difficulties the next few islands as well - local factor_accounting_for_new_damage_upgrades = 0.98 ^ (Common.overworldx() / 40) + local factor_accounting_for_new_damage_upgrades = 0.985 ^ (Common.overworldx() / 40) return (1.1 / Math.sloped(Common.difficulty_scale(), 0.7)) * early_game_factor * factor_accounting_for_new_damage_upgrades end From 6b9313ef4a51bf71effdc5dc03284bb2da931b4a Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:45:58 +0100 Subject: [PATCH 08/50] fix version number --- locale/en/pirates.cfg | 2 +- maps/pirates/coredata.lua | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index b565a5e9..3d7f29e1 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -15,7 +15,7 @@ softmod_info_new_players_2=Mine coal and other resources and bring them to the s softmod_info_tips_1=Features of the game that are hard to work out alone softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax -softmod_info_updates_1=v1.6.1 +softmod_info_updates_1=v1.6.0 softmod_info_updates_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Productivity modules are removed from the game until a later feature is released.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market softmod_info_credits_1=Credits diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 258a72c5..30564610 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -7,7 +7,7 @@ local _inspect = require 'utils.inspect'.inspect local Public = {} Public.scenario_id_name = 'pirates' -Public.version_string = '1.6.0' --major.minor.patch versioning, to match factorio mod portal +Public.version_string = '1.6.1' --major.minor.patch versioning, to match factorio mod portal Public.blueprint_library_allowed = true Public.blueprint_importing_allowed = true @@ -122,11 +122,11 @@ Public.difficulty_options = { -- The difficulty values we currently offer --For the value of Easy difficulty, we are pulled in two directions: We wish to make the game comfy to play for those who haven't played it, but we also wish to represent the game mechanics faithfully so that Normal is not a crazy distance away. - { value = 0.5, icon = 'item/firearm-magazine', text = { 'pirates.difficulty_easy' }, associated_color = { r = 50, g = 255, b = 50 } }, + { value = 0.5, icon = 'item/firearm-magazine', text = { 'pirates.difficulty_easy' }, associated_color = { r = 50, g = 255, b = 50 } }, - { value = 1.0, icon = 'item/piercing-rounds-magazine', text = { 'pirates.difficulty_normal' }, associated_color = { r = 255, g = 255, b = 50 } }, + { value = 1.0, icon = 'item/piercing-rounds-magazine', text = { 'pirates.difficulty_normal' }, associated_color = { r = 255, g = 255, b = 50 } }, - { value = 1.5, icon = 'item/uranium-rounds-magazine', text = { 'pirates.difficutly_hard' }, associated_color = { r = 255, g = 50, b = 50 } }, + { value = 1.5, icon = 'item/uranium-rounds-magazine', text = { 'pirates.difficutly_hard' }, associated_color = { r = 255, g = 50, b = 50 } }, { value = 2, icon = 'item/atomic-bomb', text = { 'pirates.difficulty_nightmare' }, associated_color = { r = 170, g = 60, b = 60 } }, } @@ -162,10 +162,10 @@ end -- } Public.daynightcycle_types = { - { displayname = { 'pirates.daynightcycle_static' }, 0 }, - { displayname = { 'pirates.daynightcycle_slowcyclic' }, ticksperday = 100000 }, - { displayname = { 'pirates.daynightcycle_cyclic' }, ticksperday = 80000 }, - { displayname = { 'pirates.daynightcycle_fastcyclic' }, ticksperday = 60000 }, + { displayname = { 'pirates.daynightcycle_static' }, 0 }, + { displayname = { 'pirates.daynightcycle_slowcyclic' }, ticksperday = 100000 }, + { displayname = { 'pirates.daynightcycle_cyclic' }, ticksperday = 80000 }, + { displayname = { 'pirates.daynightcycle_fastcyclic' }, ticksperday = 60000 }, { displayname = { 'pirates.daynightcycle_rapidcyclic' }, ticksperday = 40000 }, } From 09572254647472db67554379fa0e626a7abf11d2 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 12:57:44 +0100 Subject: [PATCH 09/50] space out waves slightly --- maps/pirates/ai.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/maps/pirates/ai.lua b/maps/pirates/ai.lua index 13783042..a81f6c96 100644 --- a/maps/pirates/ai.lua +++ b/maps/pirates/ai.lua @@ -66,7 +66,7 @@ function Public.Tick_actions(tickinterval) -- if destination.subtype == IslandEnum.enum.RED_DESERT then return end -- This was a hack to stop biter boats causing attacks, but, it has the even worse effect of stopping all floating_pollution gathering. - local minute_cycle = { -- warning: use even seconds only + local ai_cycle_seconds = { -- warning: use even seconds only [2] = Public.tell_biters_near_silo_to_attack_it, [4] = Public.poke_script_groups, [6] = Public.try_main_attack, @@ -75,18 +75,18 @@ function Public.Tick_actions(tickinterval) [18] = Public.poke_script_groups, [20] = Public.try_secondary_attack, - [32] = Public.tell_biters_near_silo_to_attack_it, - [34] = Public.poke_script_groups, - [36] = Public.try_rogue_attack, + [42] = Public.tell_biters_near_silo_to_attack_it, + [44] = Public.poke_script_groups, + [46] = Public.try_rogue_attack, - [46] = Public.poke_inactive_scripted_biters, - [48] = Public.create_mail_delivery_biters, + [56] = Public.poke_inactive_scripted_biters, + [58] = Public.create_mail_delivery_biters, - [54] = Public.try_boat_biters_attack, + [74] = Public.try_boat_biters_attack, } - if minute_cycle[(game.tick / 60) % 60] then - minute_cycle[(game.tick / 60) % 60]() + if ai_cycle_seconds[(game.tick / 60) % 80] then + ai_cycle_seconds[(game.tick / 60) % 80]() end end From 6d89f5247ff304a6d65fda9a0cd9277709656db8 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 14:52:32 +0100 Subject: [PATCH 10/50] reset_password command --- locale/en/pirates.cfg | 4 +++- maps/pirates/commands.lua | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 3d7f29e1..e2fc1868 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -13,7 +13,7 @@ softmod_info_new_players_1=For New Players softmod_info_new_players_2=Mine coal and other resources and bring them to the ship to keep things going, or try asking the captain for more specific tasks. softmod_info_tips_1=Features of the game that are hard to work out alone -softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax +softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password softmod_info_updates_1=v1.6.0 softmod_info_updates_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Productivity modules are removed from the game until a later feature is released.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market @@ -546,6 +546,7 @@ gui_runs_proposal_maker_error_private_run_password_empty=Passwords can't be empt gui_join_protected_run_info=This crew is protected.\nThis means when captain leaves the game, other members won't get the captain role (unless there are officers).\nCaptain protection expires in __1__:__2__:__3__ gui_join_private_run_info=This crew is private.\nPlease enter a password to join the crew.\nThis crew will become public in __1__:__2__:__3__ gui_join_private_run_error_wrong_password=The password you've entered is incorrect. +cmd_notify_set_private_run_password=The password for __1__ has been set to __2__ @@ -613,6 +614,7 @@ cmd_error_not_captain=[ERROR] Only captains can run this command. cmd_error_invalid_player_name=[ERROR] Player __1__ not found. cmd_error_invalid_class_name=[ERROR] Class __1__ not found. cmd_error_color_not_found=[ERROR] Color __1__ not found. +cmd_error_not_creator_of_crew=[ERROR] Only the original creator of the crew can run this command. cmd_explain_set_max_crews=is an admin command to set the maximum number of concurrent crews allowed on the server. cmd_explain_sail=is an admin command to set the ship sailing after an island, in case there's a problem with the captain doing so. diff --git a/maps/pirates/commands.lua b/maps/pirates/commands.lua index 9b4a5004..6d861eba 100644 --- a/maps/pirates/commands.lua +++ b/maps/pirates/commands.lua @@ -102,6 +102,28 @@ local function check_captain_or_admin(cmd) return true end +local function check_creator_of_crew(cmd) + local player = game.players[cmd.player_index] + local p + if player then + if player ~= nil then + p = player.print + + cmd_set_memory(cmd) + + local memory = Memory.get_crew_memory() + if not Common.is_id_valid(memory.id) then return end + + local creator = memory.original_proposal.created_by_player + + if creator ~= player.index then + Common.notify_player_error(player, { 'pirates.cmd_error_not_creator_of_crew' }) + return false + end + end + end +end + -- @UNUSED -- local function check_trusted(cmd) @@ -335,6 +357,30 @@ commands.add_command( end end) +-- *** *** -- +--*** CREATOR OF CREW COMMANDS ***-- +-- *** *** -- + +commands.add_command( + 'reset_password', + { 'pirates.cmd_explain_set_private_run_password' }, + function (cmd) + cmd_set_memory(cmd) + + local memory = Memory.get_crew_memory() + if not Common.is_id_valid(memory.id) then return end + + local param = tostring(cmd.parameter) + if check_creator_of_crew(cmd) then + local player = game.players[cmd.player_index] + + memory.private_run_password = param + Common.notify_player_expected(player, { 'pirates.cmd_notify_set_private_run_password', memory.name, param }) + end + end) + + + -- *** *** -- --*** ADMIN COMMANDS ***-- -- *** *** -- From 74a502d25a05e2422580221e3b16735bd5f81cd2 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 15:01:29 +0100 Subject: [PATCH 11/50] can only overwrite existing passwords --- locale/en/pirates.cfg | 2 ++ maps/pirates/commands.lua | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index e2fc1868..fb17f04c 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -550,6 +550,7 @@ cmd_notify_set_private_run_password=The password for __1__ has been set to __2__ + gui_runs_launch=Launch crew gui_runs_launch_error_2=The number of concurrent crews on the server has reached the cap set by the admins. gui_runs_launch_error_4=No sloops available. Join an existing crew instead. @@ -615,6 +616,7 @@ cmd_error_invalid_player_name=[ERROR] Player __1__ not found. cmd_error_invalid_class_name=[ERROR] Class __1__ not found. cmd_error_color_not_found=[ERROR] Color __1__ not found. cmd_error_not_creator_of_crew=[ERROR] Only the original creator of the crew can run this command. +cmd_error_no_existing_password=There is no existing password to overwrite for this crew. cmd_explain_set_max_crews=is an admin command to set the maximum number of concurrent crews allowed on the server. cmd_explain_sail=is an admin command to set the ship sailing after an island, in case there's a problem with the captain doing so. diff --git a/maps/pirates/commands.lua b/maps/pirates/commands.lua index 6d861eba..38c0a1b6 100644 --- a/maps/pirates/commands.lua +++ b/maps/pirates/commands.lua @@ -374,6 +374,11 @@ commands.add_command( if check_creator_of_crew(cmd) then local player = game.players[cmd.player_index] + if not memory.private_run_password then + Common.notify_player_error(player, { 'pirates.cmd_error_no_existing_password' }) + return false + end + memory.private_run_password = param Common.notify_player_expected(player, { 'pirates.cmd_notify_set_private_run_password', memory.name, param }) end From 91834b680b86a660a20e2d11f925d5a8c72b2e35 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Fri, 13 Sep 2024 20:14:04 +0100 Subject: [PATCH 12/50] autodisband 3 days -> 5 days --- maps/pirates/common.lua | 4 ++-- maps/pirates/crew.lua | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index 048c5ef3..b343ab02 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -27,8 +27,8 @@ Public.minimumCapacitySliderValue = 1 Public.minimum_run_capacity_to_enforce_space_for = 22 -- auto-disbanding when there are no players left in the crew: --- Public.autodisband_ticks = nil -Public.autodisband_ticks = 60 * 60 * 60 * 24 * 3 -- should not be zero (as this messes with saving and loading a game, which boots the player for a moment.) Also note that the server may run very slowly when no-one is on it. +-- Public.autodisband_hours = nil +Public.autodisband_hours = 24 * 5 -- should not be zero (as this messes with saving and loading a game, which boots the player for a moment.) Also note that the server may run very slowly when no-one is on it. Public.boat_steps_at_a_time = 1 diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index 313b8d03..d0ce7ac5 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -279,8 +279,8 @@ function Public.join_spectators(player, crewid) end if #Common.crew_get_crew_members() == 0 then - if Common.autodisband_ticks then - memory.crew_disband_tick = game.tick + Common.autodisband_ticks + if Common.autodisband_hours then + memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60 end end @@ -312,8 +312,8 @@ function Public.leave_spectators(player, quiet) memory.spectatorplayerindices = Utils.ordered_table_with_values_removed(memory.spectatorplayerindices, player.index) if #Common.crew_get_crew_members() == 0 then - if Common.autodisband_ticks then - memory.crew_disband_tick = game.tick + Common.autodisband_ticks + if Common.autodisband_hours then + memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60 end end @@ -492,8 +492,8 @@ function Public.leave_crew(player, to_lobby, quiet) if #Common.crew_get_crew_members() == 0 then local exists_disband_tick = memory.crew_disband_tick and memory.crew_disband_tick > game.tick - if Common.autodisband_ticks and not exists_disband_tick then - memory.crew_disband_tick = game.tick + Common.autodisband_ticks + if Common.autodisband_hours and not exists_disband_tick then + memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60 end -- if _DEBUG then memory.crew_disband_tick = game.tick + 30*60*60 end From 19f8c23ec7160cfc84433b1604f2b7a5f8299dfa Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sat, 14 Sep 2024 12:46:02 +0100 Subject: [PATCH 13/50] fix starting multiple private runs --- maps/pirates/gui/runs.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index 7f28a1f8..0d2cd3d6 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -746,7 +746,7 @@ function Public.click(event) -- check if the player created any other private runs for _, id in pairs(global_memory.crew_active_ids) do - if global_memory.crew_memories[id].run_is_private then + if global_memory.crew_memories[id].run_is_private and global_memory.crew_memories[id].created_by_player == player.index then Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_two_private_runs' }) return end @@ -772,7 +772,7 @@ function Public.click(event) -- check if the player created any other protected runs for _, id in pairs(global_memory.crew_active_ids) do - if global_memory.crew_memories[id].run_is_protected then + if global_memory.crew_memories[id].run_is_protected and global_memory.crew_memories[id].created_by_player == player.index then Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_two_protected_runs' }) return end From f8d26364fb6a52fad62eb1207add38e60ed60567 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sat, 14 Sep 2024 12:46:17 +0100 Subject: [PATCH 14/50] Update coredata.lua --- maps/pirates/coredata.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 30564610..90ec980e 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -7,7 +7,7 @@ local _inspect = require 'utils.inspect'.inspect local Public = {} Public.scenario_id_name = 'pirates' -Public.version_string = '1.6.1' --major.minor.patch versioning, to match factorio mod portal +Public.version_string = '1.6.2' --major.minor.patch versioning, to match factorio mod portal Public.blueprint_library_allowed = true Public.blueprint_importing_allowed = true From 5a974edd60b4e904d35993c3d41775355309e956 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sat, 14 Sep 2024 12:47:51 +0100 Subject: [PATCH 15/50] don't show info window unless they click --- maps/pirates/api_events.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index f8df727e..d5c5ab75 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -1455,6 +1455,10 @@ local function event_on_player_joined_game(event) end end + -- if not _DEBUG then + -- Gui.info.toggle_window(player) + -- end + if crew_to_put_back_in then log('INFO: ' .. player.name .. ' (crew ID: ' .. crew_to_put_back_in .. ') joined the game') @@ -1551,10 +1555,6 @@ local function event_on_player_joined_game(event) -- end end - if not _DEBUG then - Gui.info.toggle_window(player) - end - global_memory.last_players_health[event.player_index] = player.character.health -- player.teleport(surface.find_non_colliding_position('character', spawnpoint, 32, 0.5), surface) From 6d8ee55c6a01c65823d45248bbaf09ffd3e942e9 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sat, 14 Sep 2024 12:56:51 +0100 Subject: [PATCH 16/50] dont show extra icons --- maps/pirates/gui/gui.lua | 289 ++++++++++++++++------------------ maps/pirates/gui/progress.lua | 4 - 2 files changed, 134 insertions(+), 159 deletions(-) diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index 205781ca..a10c1310 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -71,11 +71,13 @@ end function Public.update_crew_progress_gui() return Public.update_crew_gui('progress') end + Event.add(CustomEvents.enum['update_crew_progress_gui'], Public.update_crew_progress_gui) -- script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) function Public.update_crew_fuel_gui() return Public.update_crew_gui('fuel') end + Event.add(CustomEvents.enum['update_crew_fuel_gui'], Public.update_crew_fuel_gui) @@ -87,19 +89,19 @@ local function create_gui(player) flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'info_piratebutton') flow2.caption = '?' flow2.style.font = 'debug' - flow2.tooltip = {'pirates.gui_info_main_tooltip'} - flow2.style.font_color = {r=1, g=1, b=1} - flow2.style.hovered_font_color = {r=1, g=1, b=1} - flow2.style.clicked_font_color = {r=1, g=1, b=1} + flow2.tooltip = { 'pirates.gui_info_main_tooltip' } + flow2.style.font_color = { r = 1, g = 1, b = 1 } + flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 } + flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 } flow2.parent.style.left_padding = -6 flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'runs_piratebutton', 70) - flow2.caption = {'pirates.gui_crews'} - flow2.tooltip = {'pirates.gui_crews_main_tooltip'} + flow2.caption = { 'pirates.gui_crews' } + flow2.tooltip = { 'pirates.gui_crews_main_tooltip' } flow2.style.font = 'debug' - flow2.style.font_color = {r=1, g=1, b=1} - flow2.style.hovered_font_color = {r=1, g=1, b=1} - flow2.style.clicked_font_color = {r=1, g=1, b=1} + flow2.style.font_color = { r = 1, g = 1, b = 1 } + flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 } + flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 } flow2.parent.style.width = 67 flow2.parent.style.left_padding = -6 @@ -131,11 +133,11 @@ local function create_gui(player) flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'evo_piratebutton') flow2.sprite = 'entity/small-biter' - flow2.mouse_button_filter = {'middle'} --hack to avoid press visual + flow2.mouse_button_filter = { 'middle' } --hack to avoid press visual flow2.show_percent_for_small_numbers = true --as of factorio v1.1.59, there is a bug in which 1.002 displays as like 1e-2% or something. but after 1.01 it's ok flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'minimap_piratebutton') - flow2.tooltip = {'pirates.gui_minimap_main_tooltip'} + flow2.tooltip = { 'pirates.gui_minimap_main_tooltip' } flow2.sprite = 'utility/map' -- flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'shop_piratebutton') @@ -167,7 +169,7 @@ local function create_gui(player) }) flow3.style.font = 'default-large-semibold' flow3.style.font_color = GuiCommon.bold_font_color - flow3.caption = {'pirates.gui_fuel_1'} + flow3.caption = { 'pirates.gui_fuel_1' } flow3 = flow2.add({ name = 'fuel_label_1', @@ -222,9 +224,9 @@ local function create_gui(player) flow3.style.font = 'default-large-semibold' flow3.style.font_color = GuiCommon.bold_font_color - flow3 = flow2.add({type = 'table', name = 'cost_table', column_count = #CoreData.cost_items}) + flow3 = flow2.add({ type = 'table', name = 'cost_table', column_count = #CoreData.cost_items }) for i = 1, #CoreData.cost_items do - flow4 = flow3.add({type = 'sprite-button', name = 'cost_' .. i, number = 0}) + flow4 = flow3.add({ type = 'sprite-button', name = 'cost_' .. i, number = 0 }) -- flow4.mouse_button_filter = {'middle'} flow4.sprite = CoreData.cost_items[i].sprite_name flow4.enabled = false @@ -234,14 +236,14 @@ local function create_gui(player) flow4.visible = false end -- and - flow4 = flow3.add({type = 'sprite-button', name = 'cost_launch_rocket'}) - -- flow4.mouse_button_filter = {'middle'} - flow4.sprite = 'item/rocket-silo' - flow4.enabled = false - flow4.style.top_margin = -6 - flow4.style.right_margin = -6 - flow4.style.maximal_height = 38 - flow4.visible = false + flow4 = flow3.add({ type = 'sprite-button', name = 'cost_launch_rocket' }) + -- flow4.mouse_button_filter = {'middle'} + flow4.sprite = 'item/rocket-silo' + flow4.enabled = false + flow4.style.top_margin = -6 + flow4.style.right_margin = -6 + flow4.style.maximal_height = 38 + flow4.visible = false flow3.style.left_margin = -1 flow3.style.right_margin = -2 --to get to the end of the button frame @@ -485,13 +487,13 @@ local function create_gui(player) -- spontaneous inside view of the hold: flow1 = - player.gui.screen.add( - { - type = 'camera', - name = 'pirates_spontaneous_camera', - position = {x=0,y=0}, - } - ) + player.gui.screen.add( + { + type = 'camera', + name = 'pirates_spontaneous_camera', + position = { x = 0, y = 0 }, + } + ) flow1.visible = false flow1.style.margin = 8 -- flow2.style.minimal_height = 64 @@ -546,34 +548,32 @@ function Public.process_etaframe_update(player, flow1, bools) flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = {'pirates.gui_etaframe_board_warning_tooltip'} - - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_board_warning'} + tooltip = { 'pirates.gui_etaframe_board_warning_tooltip' } + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_board_warning' } elseif bools.eta_bool then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = true - tooltip = {'pirates.auto_undock_tooltip'} + tooltip = { 'pirates.auto_undock_tooltip' } local passive_eta = dynamic_data.time_remaining - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_autoundock'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_autoundock' } flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(passive_eta) - elseif bools.atsea_loading_bool then if Kraken.get_active_kraken_count(memory.id) > 0 then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = {'pirates.defeat_krakens_tooltip'} + tooltip = { 'pirates.defeat_krakens_tooltip' } - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_defeat_krakens'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_defeat_krakens' } else flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = true - tooltip = {'pirates.atsea_loading_tooltip'} + tooltip = { 'pirates.atsea_loading_tooltip' } local total = Common.map_loading_ticks_atsea if destination.type == Surfaces.enum.DOCK then @@ -584,34 +584,31 @@ function Public.process_etaframe_update(player, flow1, bools) local eta_ticks = total + (memory.extra_time_at_sea or 0) - memory.loadingticks - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_loading_for'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_loading_for' } flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(eta_ticks / 60) end - elseif bools.atsea_waiting_bool then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = {'pirates.atsea_waiting_tooltip'} - - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_waiting'} + tooltip = { 'pirates.atsea_waiting_tooltip' } + 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'} + 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 - tooltip = {'pirates.leave_anytime_tooltip'} + tooltip = { 'pirates.leave_anytime_tooltip' } - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock'} - flow2.etaframe_label_2.caption = {'pirates.gui_etaframe_anytime'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock' } + flow2.etaframe_label_2.caption = { 'pirates.gui_etaframe_anytime' } end if bools.cost_bool and Kraken.get_active_kraken_count(memory.id) == 0 then @@ -624,65 +621,65 @@ function Public.process_etaframe_update(player, flow1, bools) cost_table.visible = true if flow2.etaframe_label_2.visible then - flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.' + flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.' end -- local caption if bools.atsea_loading_bool then - flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_next_escape_cost'} + flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_next_escape_cost' } if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_4_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_4_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_4'} + tooltip = { 'pirates.resources_needed_tooltip_4' } end elseif destination.static_params.undock_cost_decreases == true then if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_1_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_1_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_1'} + tooltip = { 'pirates.resources_needed_tooltip_1' } end else if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_0a_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_0a_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_0a'} + tooltip = { 'pirates.resources_needed_tooltip_0a' } end end elseif (not bools.eta_bool) then -- Shown when ship doesn't have auto undock timer flow2.etaframe_label_3.visible = false flow2.etaframe_label_1.visible = true - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_to_escape_store'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_to_escape_store' } if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_3'} + tooltip = { 'pirates.resources_needed_tooltip_3' } end else -- Shown when at island if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then flow2.etaframe_label_3.visible = false if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_5_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_5_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_5'} + tooltip = { 'pirates.resources_needed_tooltip_5' } end elseif destination.static_params.undock_cost_decreases == true then - flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_or_store'} + flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_or_store' } local adjusted_costs_resources_strings = Common.time_adjusted_departure_cost_resources_strings(memory) if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} + tooltip = { 'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] } else --@Future reference: localisation handling - tooltip = {'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} + tooltip = { 'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] } end else if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_3'} + tooltip = { 'pirates.resources_needed_tooltip_3' } end end end @@ -710,7 +707,7 @@ function Public.process_etaframe_update(player, flow1, bools) else cost_table['cost_launch_rocket'].number = 0 end - cost_table['cost_launch_rocket'].tooltip = {'pirates.gui_etaframe_rocket_requirement_tooltip'} + cost_table['cost_launch_rocket'].tooltip = { 'pirates.gui_etaframe_rocket_requirement_tooltip' } cost_table['cost_launch_rocket'].visible = true else cost_table['cost_launch_rocket'].visible = false @@ -721,24 +718,22 @@ function Public.process_etaframe_update(player, flow1, bools) flow2.tooltip = tooltip if bools.captain_bool and (not bools.retreating_bool) and (bools.leave_anytime_bool or bools.atsea_waiting_bool or bools.eta_bool or (bools.cost_bool and (not bools.atsea_loading_bool))) then - flow1.etaframe_piratebutton.mouse_button_filter = {'left'} + flow1.etaframe_piratebutton.mouse_button_filter = { 'left' } if memory.undock_shortcut_are_you_sure_data and memory.undock_shortcut_are_you_sure_data[player.index] and memory.undock_shortcut_are_you_sure_data[player.index] > game.tick - 60 * 4 then flow2.etaframe_label_1.visible = true - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock_are_you_sure'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock_are_you_sure' } flow2.etaframe_label_2.visible = false flow2.etaframe_label_3.visible = false end else - flow1.etaframe_piratebutton.mouse_button_filter = {'middle'} --hack to avoid press visual + flow1.etaframe_piratebutton.mouse_button_filter = { 'middle' } --hack to avoid press visual end else flow1.visible = false end end - function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bools) - local destination = Common.current_destination() local dynamic_data = destination.dynamic_data --assumes this always exists @@ -747,40 +742,37 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1 = flowsilo if flow1 then - if bools.silo_bool then flow1.visible = true if bools.charged_bool then - if bools.launched_bool then - flow1.silo_progressbar.visible = false flow1.silo_label_2.visible = false flow1.silo_label_3.visible = true -- flow1.silo_label_1.caption = string.format('[achievement=there-is-no-spoon]: +%.0f[item=sulfur]', dynamic_data.rocketcoalreward) - flow1.silo_label_1.caption = {'pirates.gui_etaframe_launched'} + flow1.silo_label_1.caption = { 'pirates.gui_etaframe_launched' } -- flow1.silo_label_1.caption = string.format('Launched for %.0f[item=coal] , ' .. Balance.rocket_launch_coin_reward .. '[item=coin]', dynamic_data.rocketcoalreward) flow1.silo_label_1.style.font_color = GuiCommon.achieved_font_color local rocket_launch_coal_reward = Balance.rocket_launch_fuel_reward() local rocket_launch_coin_reward = Balance.rocket_launch_coin_reward() - flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward/100)/10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward/100)/10 .. 'k[item=coin]' + flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward / 100) / 10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward / 100) / 10 .. 'k[item=coin]' - local tooltip = {'pirates.gui_etaframe_launched_tooltip'} + local tooltip = { 'pirates.gui_etaframe_launched_tooltip' } flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_label_3.tooltip = tooltip else - local tooltip = {'pirates.gui_etaframe_launching'} + local tooltip = { 'pirates.gui_etaframe_launching' } flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_progressbar.tooltip = tooltip - flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} + flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' } flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_2.visible = false flow1.silo_label_3.visible = false @@ -788,9 +780,8 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1.silo_progressbar.value = 1 end - else - flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} + flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' } flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_2.visible = true flow1.silo_progressbar.visible = true @@ -800,9 +791,9 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo local needed = dynamic_data.rocketsiloenergyneeded local recent = (dynamic_data.rocketsiloenergyconsumedwithinlasthalfsecond * 2) - flow1.silo_progressbar.value = consumed/needed + flow1.silo_progressbar.value = consumed / needed - local tooltip = {'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000)/10), string.format('%.1f', Math.floor(needed / 100000000)/10)} + local tooltip = { 'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000) / 10), string.format('%.1f', Math.floor(needed / 100000000) / 10) } flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_label_2.tooltip = tooltip @@ -836,16 +827,15 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo local quest_reward = dynamic_data.quest_reward or nil local quest_progress = dynamic_data.quest_progress or 0 local quest_progressneeded = dynamic_data.quest_progressneeded or 0 - local quest_complete = dynamic_data.quest_complete or false + local quest_complete = dynamic_data.quest_complete or false if quest_type then - ---@type string|table local tooltip = '' if quest_complete and quest_reward then - tooltip = {'pirates.gui_questframe_complete_tooltip', quest_type} - flow1.quest_label_1.caption = {'pirates.gui_questframe'} + tooltip = { 'pirates.gui_questframe_complete_tooltip', quest_type } + flow1.quest_label_1.caption = { 'pirates.gui_questframe' } flow1.quest_label_1.style.font_color = GuiCommon.achieved_font_color flow1.quest_label_2.visible = true flow1.quest_label_3.visible = false @@ -853,7 +843,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1.quest_label_2.caption = quest_reward.display_amount .. ' ' .. quest_reward.display_sprite elseif quest_reward then if quest_progress < quest_progressneeded then - flow1.quest_label_1.caption = {'pirates.gui_questframe'} + flow1.quest_label_1.caption = { 'pirates.gui_questframe' } flow1.quest_label_1.style.font_color = GuiCommon.bold_font_color flow1.quest_label_2.visible = true flow1.quest_label_3.visible = true @@ -867,7 +857,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end if quest_type == Quest.enum.TIME then - if tooltip == '' then tooltip = {'pirates.gui_questframe_time'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_time' } end if quest_progress >= 0 then flow1.quest_label_3.caption = string.format('%.0fm%.0fs', Math.floor(quest_progress / 60), quest_progress % 60) @@ -885,49 +875,42 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end end else - flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} + flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' } flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color end - elseif quest_type == Quest.enum.WORMS then - if tooltip == '' then tooltip = {'pirates.gui_questframe_worms'} end - + if tooltip == '' then tooltip = { 'pirates.gui_questframe_worms' } end elseif quest_type == Quest.enum.FIND then - if tooltip == '' then tooltip = {'pirates.gui_questframe_find'} end - + if tooltip == '' then tooltip = { 'pirates.gui_questframe_find' } end elseif quest_type == Quest.enum.RESOURCEFLOW then - if tooltip == '' then tooltip = {'pirates.gui_questframe_resourceflow'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourceflow' } end -- out of date: - if quest_progressneeded/60 % 1 == 0 then - flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) + if quest_progressneeded / 60 % 1 == 0 then + flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) else - flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) + flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) end - elseif quest_type == Quest.enum.RESOURCECOUNT then - if tooltip == '' then tooltip = {'pirates.gui_questframe_resourcecount'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourcecount' } end flow1.quest_label_2.caption = string.format('%s ', '[item=' .. quest_params.item .. ']') - elseif quest_type == Quest.enum.NODAMAGE then - if tooltip == '' then tooltip = {'pirates.gui_questframe_nodamage'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_nodamage' } end if bools.approaching_bool or (dynamic_data.rocketsilos and dynamic_data.rocketsilos[1] and dynamic_data.rocketsilos[1].valid and dynamic_data.rocketsilohp == dynamic_data.rocketsilomaxhp) then - flow1.quest_label_3.caption = {'pirates.gui_questframe_ok'} + flow1.quest_label_3.caption = { 'pirates.gui_questframe_ok' } flow1.quest_label_3.style.font_color = GuiCommon.sufficient_font_color else - flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} + flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' } flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color end - elseif quest_type == Quest.enum.FISH then - if tooltip == '' then tooltip = {'pirates.gui_questframe_fish'} end - + if tooltip == '' then tooltip = { 'pirates.gui_questframe_fish' } end elseif quest_type == Quest.enum.COMPILATRON then - if tooltip == '' then tooltip = {'pirates.gui_questframe_compilatron'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_compilatron' } end end end @@ -943,7 +926,6 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end end - -- local function create_gui_2() -- end @@ -965,27 +947,29 @@ function Public.update_gui(player) flow1 = pirates_flow.crew_piratebutton_frame.crew_piratebutton if Common.is_id_valid(memory.id) then - flow1.tooltip = {'pirates.gui_crew_tooltip_1'} - flow1.mouse_button_filter = {'left','right'} + flow1.tooltip = { 'pirates.gui_crew_tooltip_1' } + flow1.mouse_button_filter = { 'left', 'right' } else - flow1.tooltip = {'pirates.gui_crew_tooltip_2'} - flow1.mouse_button_filter = {'middle'} --hack to avoid press visual + flow1.tooltip = { 'pirates.gui_crew_tooltip_2' } + flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual if player.gui.screen['crew_piratewindow'] then player.gui.screen['crew_piratewindow'].destroy() end end - flow1 = pirates_flow.classes_piratebutton_frame.classes_piratebutton + flow1 = pirates_flow.classes_piratebutton_frame if Common.is_id_valid(memory.id) then - flow1.tooltip = {'pirates.gui_classes_tooltip_1'} - flow1.mouse_button_filter = {'left','right'} + flow1.classes_piratebutton.tooltip = { 'pirates.gui_classes_tooltip_1' } + flow1.classes_piratebutton.mouse_button_filter = { 'left', 'right' } else - flow1.tooltip = {'pirates.gui_classes_tooltip_2'} - flow1.mouse_button_filter = {'middle'} --hack to avoid press visual - if player.gui.screen['classes_piratewindow'] then - player.gui.screen['classes_piratewindow'].destroy() - end + -- flow1.tooltip = { 'pirates.gui_classes_tooltip_2' } + -- flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual + -- if player.gui.screen['classes_piratewindow'] then + -- player.gui.screen['classes_piratewindow'].destroy() + -- end + + flow1.visible = false end if GuiEvo.full_update then GuiEvo.full_update(player) end @@ -1013,7 +997,7 @@ function Public.update_gui(player) flow1 = pirates_flow.fuel_flow -- flow1 = pirates_flow.fuel_piratebutton_flow_1 - local tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} + local tooltip = { 'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0) } flow1.tooltip = tooltip -- flow1.fuel_piratebutton.tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} @@ -1023,11 +1007,11 @@ function Public.update_gui(player) flow2.fuel_label_1.caption = Utils.bignumber_abbrevform(memory.stored_fuel or 0) .. '[item=coal]' flow2.fuel_label_2.caption = Utils.negative_rate_abbrevform(memory.fuel_depletion_rate_memoized or 0) - local color_scale = Math.clamp(0, 1, (- (memory.fuel_depletion_rate_memoized or 0))/30) + local color_scale = Math.clamp(0, 1, (-(memory.fuel_depletion_rate_memoized or 0)) / 30) flow2.fuel_label_2.style.font_color = { - r = GuiCommon.fuel_color_1.r * (1-color_scale) + GuiCommon.fuel_color_2.r * color_scale, - g = GuiCommon.fuel_color_1.g * (1-color_scale) + GuiCommon.fuel_color_2.g * color_scale, - b = GuiCommon.fuel_color_1.b * (1-color_scale) + GuiCommon.fuel_color_2.b * color_scale, + r = GuiCommon.fuel_color_1.r * (1 - color_scale) + GuiCommon.fuel_color_2.r * color_scale, + g = GuiCommon.fuel_color_1.g * (1 - color_scale) + GuiCommon.fuel_color_2.g * color_scale, + b = GuiCommon.fuel_color_1.b * (1 - color_scale) + GuiCommon.fuel_color_2.b * color_scale, } flow2.fuel_label_0.tooltip = tooltip flow2.fuel_label_1.tooltip = tooltip @@ -1037,7 +1021,7 @@ function Public.update_gui(player) flow1 = pirates_flow.progress_piratebutton_frame.progress_piratebutton flow1.number = (memory.overworldx or 0) - flow1.tooltip = {'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x} + flow1.tooltip = { 'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x } -- pirates_flow.destination_piratebutton_frame.destination_piratebutton.number = memory.destinationsvisited_indices and #memory.destinationsvisited_indices or 0 @@ -1178,41 +1162,41 @@ function Public.update_gui(player) if not flow1 then --comfy panel might possibly destroy this, so this puts it back flow1 = - player.gui.screen.add( - { - type = 'camera', - name = 'pirates_spontaneous_camera', - position = {x=0,y=0}, - } - ) + player.gui.screen.add( + { + type = 'camera', + name = 'pirates_spontaneous_camera', + position = { x = 0, y = 0 }, + } + ) flow1.visible = false flow1.style.margin = 8 end if flow1 then flow1.visible = false - flow1.location = {x = 8, y = 48} + flow1.location = { x = 8, y = 48 } if bools.on_deck_standing_near_loco_bool then flow1.visible = true flow1.surface_index = Hold.get_hold_surface(1).index flow1.zoom = 0.182 flow1.style.minimal_height = 292 flow1.style.minimal_width = 540 - flow1.position = {x=0,y=-2} + flow1.position = { x = 0, y = -2 } elseif bools.on_deck_standing_near_cabin_bool then flow1.visible = true flow1.surface_index = Cabin.get_cabin_surface().index flow1.zoom = 0.468 flow1.style.minimal_height = 400 flow1.style.minimal_width = 280 - flow1.position = {x=0,y=-1} + flow1.position = { x = 0, y = -1 } elseif bools.on_deck_standing_near_crowsnest_bool then flow1.visible = true flow1.surface_index = Crowsnest.get_crowsnest_surface().index flow1.zoom = 0.21 flow1.style.minimal_height = 384 flow1.style.minimal_width = 384 - flow1.position = {x=memory.overworldx,y=memory.overworldy} + flow1.position = { x = memory.overworldx, y = memory.overworldy } elseif bools.in_crowsnest_bool then flow1.visible = true flow1.surface_index = game.surfaces[memory.boat.surface_name].index @@ -1223,15 +1207,13 @@ function Public.update_gui(player) local position = memory.boat.position if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and memory.boat.surface_name and memory.boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then -- nicer viewing position: - position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} + position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 } end flow1.position = position end end end - - -- ATTENTION: Giving same names to GUI elements can cause issues, because click events are dispatched to all GUI windows! local function on_gui_click(event) if not event then return end @@ -1258,7 +1240,6 @@ local function on_gui_click(event) memory.undock_shortcut_are_you_sure_data[player.index] = game.tick end end - elseif memory.boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL then if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then local destination_index = memory.mapbeingloadeddestination_index @@ -1266,7 +1247,6 @@ 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 @@ -1275,17 +1255,16 @@ local function on_gui_click(event) 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) + 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 - local name = string.sub(event.element.name, 1, -14) - if Public[name] then - Public[name].toggle_window(player) - Public[name].full_update(player) - end + local name = string.sub(event.element.name, 1, -14) + if Public[name] then + Public[name].toggle_window(player) + Public[name].full_update(player) + end -- elseif event.element.name == 'fuel_label_1' or event.element.name == 'fuel_label_2' then -- Public.fuel.toggle_window(player) -- Public.fuel.full_update(player) @@ -1297,7 +1276,7 @@ local function on_gui_click(event) if GuiFuel.click then GuiFuel.click(event) end if GuiMinimap.click then GuiMinimap.click(event) end if GuiInfo.click then GuiInfo.click(event) end - end + end end local function on_gui_location_changed(event) @@ -1320,4 +1299,4 @@ event.add(defines.events.on_gui_location_changed, on_gui_location_changed) -return Public \ No newline at end of file +return Public diff --git a/maps/pirates/gui/progress.lua b/maps/pirates/gui/progress.lua index a900d820..2b832b33 100644 --- a/maps/pirates/gui/progress.lua +++ b/maps/pirates/gui/progress.lua @@ -85,12 +85,8 @@ function Public.toggle_window(player) end --- function Public.regular_update(player) - --- end function Public.full_update(player) - if Public.regular_update then Public.regular_update(player) end if not player.gui.screen[window_name .. '_piratewindow'] then return end local flow = player.gui.screen[window_name .. '_piratewindow'] From d7eff5940f93d9ba0afe63aba7dc124336d9e781 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sat, 14 Sep 2024 12:56:53 +0100 Subject: [PATCH 17/50] Revert "dont show extra icons" This reverts commit 7c6b791aaf6307dcaddcb9902b78cfaf45c86eb2. --- maps/pirates/gui/gui.lua | 289 ++++++++++++++++++---------------- maps/pirates/gui/progress.lua | 4 + 2 files changed, 159 insertions(+), 134 deletions(-) diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index a10c1310..205781ca 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -71,13 +71,11 @@ end function Public.update_crew_progress_gui() return Public.update_crew_gui('progress') end - Event.add(CustomEvents.enum['update_crew_progress_gui'], Public.update_crew_progress_gui) -- script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) function Public.update_crew_fuel_gui() return Public.update_crew_gui('fuel') end - Event.add(CustomEvents.enum['update_crew_fuel_gui'], Public.update_crew_fuel_gui) @@ -89,19 +87,19 @@ local function create_gui(player) flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'info_piratebutton') flow2.caption = '?' flow2.style.font = 'debug' - flow2.tooltip = { 'pirates.gui_info_main_tooltip' } - flow2.style.font_color = { r = 1, g = 1, b = 1 } - flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 } - flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 } + flow2.tooltip = {'pirates.gui_info_main_tooltip'} + flow2.style.font_color = {r=1, g=1, b=1} + flow2.style.hovered_font_color = {r=1, g=1, b=1} + flow2.style.clicked_font_color = {r=1, g=1, b=1} flow2.parent.style.left_padding = -6 flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'runs_piratebutton', 70) - flow2.caption = { 'pirates.gui_crews' } - flow2.tooltip = { 'pirates.gui_crews_main_tooltip' } + flow2.caption = {'pirates.gui_crews'} + flow2.tooltip = {'pirates.gui_crews_main_tooltip'} flow2.style.font = 'debug' - flow2.style.font_color = { r = 1, g = 1, b = 1 } - flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 } - flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 } + flow2.style.font_color = {r=1, g=1, b=1} + flow2.style.hovered_font_color = {r=1, g=1, b=1} + flow2.style.clicked_font_color = {r=1, g=1, b=1} flow2.parent.style.width = 67 flow2.parent.style.left_padding = -6 @@ -133,11 +131,11 @@ local function create_gui(player) flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'evo_piratebutton') flow2.sprite = 'entity/small-biter' - flow2.mouse_button_filter = { 'middle' } --hack to avoid press visual + flow2.mouse_button_filter = {'middle'} --hack to avoid press visual flow2.show_percent_for_small_numbers = true --as of factorio v1.1.59, there is a bug in which 1.002 displays as like 1e-2% or something. but after 1.01 it's ok flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'minimap_piratebutton') - flow2.tooltip = { 'pirates.gui_minimap_main_tooltip' } + flow2.tooltip = {'pirates.gui_minimap_main_tooltip'} flow2.sprite = 'utility/map' -- flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'shop_piratebutton') @@ -169,7 +167,7 @@ local function create_gui(player) }) flow3.style.font = 'default-large-semibold' flow3.style.font_color = GuiCommon.bold_font_color - flow3.caption = { 'pirates.gui_fuel_1' } + flow3.caption = {'pirates.gui_fuel_1'} flow3 = flow2.add({ name = 'fuel_label_1', @@ -224,9 +222,9 @@ local function create_gui(player) flow3.style.font = 'default-large-semibold' flow3.style.font_color = GuiCommon.bold_font_color - flow3 = flow2.add({ type = 'table', name = 'cost_table', column_count = #CoreData.cost_items }) + flow3 = flow2.add({type = 'table', name = 'cost_table', column_count = #CoreData.cost_items}) for i = 1, #CoreData.cost_items do - flow4 = flow3.add({ type = 'sprite-button', name = 'cost_' .. i, number = 0 }) + flow4 = flow3.add({type = 'sprite-button', name = 'cost_' .. i, number = 0}) -- flow4.mouse_button_filter = {'middle'} flow4.sprite = CoreData.cost_items[i].sprite_name flow4.enabled = false @@ -236,14 +234,14 @@ local function create_gui(player) flow4.visible = false end -- and - flow4 = flow3.add({ type = 'sprite-button', name = 'cost_launch_rocket' }) - -- flow4.mouse_button_filter = {'middle'} - flow4.sprite = 'item/rocket-silo' - flow4.enabled = false - flow4.style.top_margin = -6 - flow4.style.right_margin = -6 - flow4.style.maximal_height = 38 - flow4.visible = false + flow4 = flow3.add({type = 'sprite-button', name = 'cost_launch_rocket'}) + -- flow4.mouse_button_filter = {'middle'} + flow4.sprite = 'item/rocket-silo' + flow4.enabled = false + flow4.style.top_margin = -6 + flow4.style.right_margin = -6 + flow4.style.maximal_height = 38 + flow4.visible = false flow3.style.left_margin = -1 flow3.style.right_margin = -2 --to get to the end of the button frame @@ -487,13 +485,13 @@ local function create_gui(player) -- spontaneous inside view of the hold: flow1 = - player.gui.screen.add( - { - type = 'camera', - name = 'pirates_spontaneous_camera', - position = { x = 0, y = 0 }, - } - ) + player.gui.screen.add( + { + type = 'camera', + name = 'pirates_spontaneous_camera', + position = {x=0,y=0}, + } + ) flow1.visible = false flow1.style.margin = 8 -- flow2.style.minimal_height = 64 @@ -548,32 +546,34 @@ function Public.process_etaframe_update(player, flow1, bools) flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = { 'pirates.gui_etaframe_board_warning_tooltip' } + tooltip = {'pirates.gui_etaframe_board_warning_tooltip'} + + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_board_warning'} - flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_board_warning' } elseif bools.eta_bool then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = true - tooltip = { 'pirates.auto_undock_tooltip' } + tooltip = {'pirates.auto_undock_tooltip'} local passive_eta = dynamic_data.time_remaining - flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_autoundock' } + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_autoundock'} flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(passive_eta) + elseif bools.atsea_loading_bool then if Kraken.get_active_kraken_count(memory.id) > 0 then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = { 'pirates.defeat_krakens_tooltip' } + tooltip = {'pirates.defeat_krakens_tooltip'} - flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_defeat_krakens' } + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_defeat_krakens'} else flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = true - tooltip = { 'pirates.atsea_loading_tooltip' } + tooltip = {'pirates.atsea_loading_tooltip'} local total = Common.map_loading_ticks_atsea if destination.type == Surfaces.enum.DOCK then @@ -584,31 +584,34 @@ function Public.process_etaframe_update(player, flow1, bools) local eta_ticks = total + (memory.extra_time_at_sea or 0) - memory.loadingticks - flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_loading_for' } + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_loading_for'} flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(eta_ticks / 60) end + elseif bools.atsea_waiting_bool then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = { 'pirates.atsea_waiting_tooltip' } + tooltip = {'pirates.atsea_waiting_tooltip'} + + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_waiting'} - 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' } + tooltip = {'pirates.atsea_victorious_tooltip'} + + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_victorious'} - 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 - tooltip = { 'pirates.leave_anytime_tooltip' } + tooltip = {'pirates.leave_anytime_tooltip'} - flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock' } - flow2.etaframe_label_2.caption = { 'pirates.gui_etaframe_anytime' } + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock'} + flow2.etaframe_label_2.caption = {'pirates.gui_etaframe_anytime'} end if bools.cost_bool and Kraken.get_active_kraken_count(memory.id) == 0 then @@ -621,65 +624,65 @@ function Public.process_etaframe_update(player, flow1, bools) cost_table.visible = true if flow2.etaframe_label_2.visible then - flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.' + flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.' end -- local caption if bools.atsea_loading_bool then - flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_next_escape_cost' } + flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_next_escape_cost'} if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then if bools.cost_includes_rocket_launch_bool then - tooltip = { 'pirates.resources_needed_tooltip_4_rocketvariant' } + tooltip = {'pirates.resources_needed_tooltip_4_rocketvariant'} else - tooltip = { 'pirates.resources_needed_tooltip_4' } + tooltip = {'pirates.resources_needed_tooltip_4'} end elseif destination.static_params.undock_cost_decreases == true then if bools.cost_includes_rocket_launch_bool then - tooltip = { 'pirates.resources_needed_tooltip_1_rocketvariant' } + tooltip = {'pirates.resources_needed_tooltip_1_rocketvariant'} else - tooltip = { 'pirates.resources_needed_tooltip_1' } + tooltip = {'pirates.resources_needed_tooltip_1'} end else if bools.cost_includes_rocket_launch_bool then - tooltip = { 'pirates.resources_needed_tooltip_0a_rocketvariant' } + tooltip = {'pirates.resources_needed_tooltip_0a_rocketvariant'} else - tooltip = { 'pirates.resources_needed_tooltip_0a' } + tooltip = {'pirates.resources_needed_tooltip_0a'} end end elseif (not bools.eta_bool) then -- Shown when ship doesn't have auto undock timer flow2.etaframe_label_3.visible = false flow2.etaframe_label_1.visible = true - flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_to_escape_store' } + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_to_escape_store'} if bools.cost_includes_rocket_launch_bool then - tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' } + tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} else - tooltip = { 'pirates.resources_needed_tooltip_3' } + tooltip = {'pirates.resources_needed_tooltip_3'} end else -- Shown when at island if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then flow2.etaframe_label_3.visible = false if bools.cost_includes_rocket_launch_bool then - tooltip = { 'pirates.resources_needed_tooltip_5_rocketvariant' } + tooltip = {'pirates.resources_needed_tooltip_5_rocketvariant'} else - tooltip = { 'pirates.resources_needed_tooltip_5' } + tooltip = {'pirates.resources_needed_tooltip_5'} end elseif destination.static_params.undock_cost_decreases == true then - flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_or_store' } + flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_or_store'} local adjusted_costs_resources_strings = Common.time_adjusted_departure_cost_resources_strings(memory) if bools.cost_includes_rocket_launch_bool then - tooltip = { 'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] } + tooltip = {'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} else --@Future reference: localisation handling - tooltip = { 'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] } + tooltip = {'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} end else if bools.cost_includes_rocket_launch_bool then - tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' } + tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} else - tooltip = { 'pirates.resources_needed_tooltip_3' } + tooltip = {'pirates.resources_needed_tooltip_3'} end end end @@ -707,7 +710,7 @@ function Public.process_etaframe_update(player, flow1, bools) else cost_table['cost_launch_rocket'].number = 0 end - cost_table['cost_launch_rocket'].tooltip = { 'pirates.gui_etaframe_rocket_requirement_tooltip' } + cost_table['cost_launch_rocket'].tooltip = {'pirates.gui_etaframe_rocket_requirement_tooltip'} cost_table['cost_launch_rocket'].visible = true else cost_table['cost_launch_rocket'].visible = false @@ -718,22 +721,24 @@ function Public.process_etaframe_update(player, flow1, bools) flow2.tooltip = tooltip if bools.captain_bool and (not bools.retreating_bool) and (bools.leave_anytime_bool or bools.atsea_waiting_bool or bools.eta_bool or (bools.cost_bool and (not bools.atsea_loading_bool))) then - flow1.etaframe_piratebutton.mouse_button_filter = { 'left' } + flow1.etaframe_piratebutton.mouse_button_filter = {'left'} if memory.undock_shortcut_are_you_sure_data and memory.undock_shortcut_are_you_sure_data[player.index] and memory.undock_shortcut_are_you_sure_data[player.index] > game.tick - 60 * 4 then flow2.etaframe_label_1.visible = true - flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock_are_you_sure' } + flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock_are_you_sure'} flow2.etaframe_label_2.visible = false flow2.etaframe_label_3.visible = false end else - flow1.etaframe_piratebutton.mouse_button_filter = { 'middle' } --hack to avoid press visual + flow1.etaframe_piratebutton.mouse_button_filter = {'middle'} --hack to avoid press visual end else flow1.visible = false end end + function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bools) + local destination = Common.current_destination() local dynamic_data = destination.dynamic_data --assumes this always exists @@ -742,37 +747,40 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1 = flowsilo if flow1 then + if bools.silo_bool then flow1.visible = true if bools.charged_bool then + if bools.launched_bool then + flow1.silo_progressbar.visible = false flow1.silo_label_2.visible = false flow1.silo_label_3.visible = true -- flow1.silo_label_1.caption = string.format('[achievement=there-is-no-spoon]: +%.0f[item=sulfur]', dynamic_data.rocketcoalreward) - flow1.silo_label_1.caption = { 'pirates.gui_etaframe_launched' } + flow1.silo_label_1.caption = {'pirates.gui_etaframe_launched'} -- flow1.silo_label_1.caption = string.format('Launched for %.0f[item=coal] , ' .. Balance.rocket_launch_coin_reward .. '[item=coin]', dynamic_data.rocketcoalreward) flow1.silo_label_1.style.font_color = GuiCommon.achieved_font_color local rocket_launch_coal_reward = Balance.rocket_launch_fuel_reward() local rocket_launch_coin_reward = Balance.rocket_launch_coin_reward() - flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward / 100) / 10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward / 100) / 10 .. 'k[item=coin]' + flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward/100)/10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward/100)/10 .. 'k[item=coin]' - local tooltip = { 'pirates.gui_etaframe_launched_tooltip' } + local tooltip = {'pirates.gui_etaframe_launched_tooltip'} flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_label_3.tooltip = tooltip else - local tooltip = { 'pirates.gui_etaframe_launching' } + local tooltip = {'pirates.gui_etaframe_launching'} flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_progressbar.tooltip = tooltip - flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' } + flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_2.visible = false flow1.silo_label_3.visible = false @@ -780,8 +788,9 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1.silo_progressbar.value = 1 end + else - flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' } + flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_2.visible = true flow1.silo_progressbar.visible = true @@ -791,9 +800,9 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo local needed = dynamic_data.rocketsiloenergyneeded local recent = (dynamic_data.rocketsiloenergyconsumedwithinlasthalfsecond * 2) - flow1.silo_progressbar.value = consumed / needed + flow1.silo_progressbar.value = consumed/needed - local tooltip = { 'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000) / 10), string.format('%.1f', Math.floor(needed / 100000000) / 10) } + local tooltip = {'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000)/10), string.format('%.1f', Math.floor(needed / 100000000)/10)} flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_label_2.tooltip = tooltip @@ -827,15 +836,16 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo local quest_reward = dynamic_data.quest_reward or nil local quest_progress = dynamic_data.quest_progress or 0 local quest_progressneeded = dynamic_data.quest_progressneeded or 0 - local quest_complete = dynamic_data.quest_complete or false + local quest_complete = dynamic_data.quest_complete or false if quest_type then + ---@type string|table local tooltip = '' if quest_complete and quest_reward then - tooltip = { 'pirates.gui_questframe_complete_tooltip', quest_type } - flow1.quest_label_1.caption = { 'pirates.gui_questframe' } + tooltip = {'pirates.gui_questframe_complete_tooltip', quest_type} + flow1.quest_label_1.caption = {'pirates.gui_questframe'} flow1.quest_label_1.style.font_color = GuiCommon.achieved_font_color flow1.quest_label_2.visible = true flow1.quest_label_3.visible = false @@ -843,7 +853,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1.quest_label_2.caption = quest_reward.display_amount .. ' ' .. quest_reward.display_sprite elseif quest_reward then if quest_progress < quest_progressneeded then - flow1.quest_label_1.caption = { 'pirates.gui_questframe' } + flow1.quest_label_1.caption = {'pirates.gui_questframe'} flow1.quest_label_1.style.font_color = GuiCommon.bold_font_color flow1.quest_label_2.visible = true flow1.quest_label_3.visible = true @@ -857,7 +867,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end if quest_type == Quest.enum.TIME then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_time' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_time'} end if quest_progress >= 0 then flow1.quest_label_3.caption = string.format('%.0fm%.0fs', Math.floor(quest_progress / 60), quest_progress % 60) @@ -875,42 +885,49 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end end else - flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' } + flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color end + elseif quest_type == Quest.enum.WORMS then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_worms' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_worms'} end + elseif quest_type == Quest.enum.FIND then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_find' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_find'} end + elseif quest_type == Quest.enum.RESOURCEFLOW then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourceflow' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_resourceflow'} end -- out of date: - if quest_progressneeded / 60 % 1 == 0 then - flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60) + if quest_progressneeded/60 % 1 == 0 then + flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) else - flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60) + flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) end + elseif quest_type == Quest.enum.RESOURCECOUNT then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourcecount' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_resourcecount'} end flow1.quest_label_2.caption = string.format('%s ', '[item=' .. quest_params.item .. ']') + elseif quest_type == Quest.enum.NODAMAGE then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_nodamage' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_nodamage'} end if bools.approaching_bool or (dynamic_data.rocketsilos and dynamic_data.rocketsilos[1] and dynamic_data.rocketsilos[1].valid and dynamic_data.rocketsilohp == dynamic_data.rocketsilomaxhp) then - flow1.quest_label_3.caption = { 'pirates.gui_questframe_ok' } + flow1.quest_label_3.caption = {'pirates.gui_questframe_ok'} flow1.quest_label_3.style.font_color = GuiCommon.sufficient_font_color else - flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' } + flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color end + elseif quest_type == Quest.enum.FISH then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_fish' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_fish'} end + elseif quest_type == Quest.enum.COMPILATRON then - if tooltip == '' then tooltip = { 'pirates.gui_questframe_compilatron' } end + if tooltip == '' then tooltip = {'pirates.gui_questframe_compilatron'} end end end @@ -926,6 +943,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end end + -- local function create_gui_2() -- end @@ -947,29 +965,27 @@ function Public.update_gui(player) flow1 = pirates_flow.crew_piratebutton_frame.crew_piratebutton if Common.is_id_valid(memory.id) then - flow1.tooltip = { 'pirates.gui_crew_tooltip_1' } - flow1.mouse_button_filter = { 'left', 'right' } + flow1.tooltip = {'pirates.gui_crew_tooltip_1'} + flow1.mouse_button_filter = {'left','right'} else - flow1.tooltip = { 'pirates.gui_crew_tooltip_2' } - flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual + flow1.tooltip = {'pirates.gui_crew_tooltip_2'} + flow1.mouse_button_filter = {'middle'} --hack to avoid press visual if player.gui.screen['crew_piratewindow'] then player.gui.screen['crew_piratewindow'].destroy() end end - flow1 = pirates_flow.classes_piratebutton_frame + flow1 = pirates_flow.classes_piratebutton_frame.classes_piratebutton if Common.is_id_valid(memory.id) then - flow1.classes_piratebutton.tooltip = { 'pirates.gui_classes_tooltip_1' } - flow1.classes_piratebutton.mouse_button_filter = { 'left', 'right' } + flow1.tooltip = {'pirates.gui_classes_tooltip_1'} + flow1.mouse_button_filter = {'left','right'} else - -- flow1.tooltip = { 'pirates.gui_classes_tooltip_2' } - -- flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual - -- if player.gui.screen['classes_piratewindow'] then - -- player.gui.screen['classes_piratewindow'].destroy() - -- end - - flow1.visible = false + flow1.tooltip = {'pirates.gui_classes_tooltip_2'} + flow1.mouse_button_filter = {'middle'} --hack to avoid press visual + if player.gui.screen['classes_piratewindow'] then + player.gui.screen['classes_piratewindow'].destroy() + end end if GuiEvo.full_update then GuiEvo.full_update(player) end @@ -997,7 +1013,7 @@ function Public.update_gui(player) flow1 = pirates_flow.fuel_flow -- flow1 = pirates_flow.fuel_piratebutton_flow_1 - local tooltip = { 'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0) } + local tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} flow1.tooltip = tooltip -- flow1.fuel_piratebutton.tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} @@ -1007,11 +1023,11 @@ function Public.update_gui(player) flow2.fuel_label_1.caption = Utils.bignumber_abbrevform(memory.stored_fuel or 0) .. '[item=coal]' flow2.fuel_label_2.caption = Utils.negative_rate_abbrevform(memory.fuel_depletion_rate_memoized or 0) - local color_scale = Math.clamp(0, 1, (-(memory.fuel_depletion_rate_memoized or 0)) / 30) + local color_scale = Math.clamp(0, 1, (- (memory.fuel_depletion_rate_memoized or 0))/30) flow2.fuel_label_2.style.font_color = { - r = GuiCommon.fuel_color_1.r * (1 - color_scale) + GuiCommon.fuel_color_2.r * color_scale, - g = GuiCommon.fuel_color_1.g * (1 - color_scale) + GuiCommon.fuel_color_2.g * color_scale, - b = GuiCommon.fuel_color_1.b * (1 - color_scale) + GuiCommon.fuel_color_2.b * color_scale, + r = GuiCommon.fuel_color_1.r * (1-color_scale) + GuiCommon.fuel_color_2.r * color_scale, + g = GuiCommon.fuel_color_1.g * (1-color_scale) + GuiCommon.fuel_color_2.g * color_scale, + b = GuiCommon.fuel_color_1.b * (1-color_scale) + GuiCommon.fuel_color_2.b * color_scale, } flow2.fuel_label_0.tooltip = tooltip flow2.fuel_label_1.tooltip = tooltip @@ -1021,7 +1037,7 @@ function Public.update_gui(player) flow1 = pirates_flow.progress_piratebutton_frame.progress_piratebutton flow1.number = (memory.overworldx or 0) - flow1.tooltip = { 'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x } + flow1.tooltip = {'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x} -- pirates_flow.destination_piratebutton_frame.destination_piratebutton.number = memory.destinationsvisited_indices and #memory.destinationsvisited_indices or 0 @@ -1162,41 +1178,41 @@ function Public.update_gui(player) if not flow1 then --comfy panel might possibly destroy this, so this puts it back flow1 = - player.gui.screen.add( - { - type = 'camera', - name = 'pirates_spontaneous_camera', - position = { x = 0, y = 0 }, - } - ) + player.gui.screen.add( + { + type = 'camera', + name = 'pirates_spontaneous_camera', + position = {x=0,y=0}, + } + ) flow1.visible = false flow1.style.margin = 8 end if flow1 then flow1.visible = false - flow1.location = { x = 8, y = 48 } + flow1.location = {x = 8, y = 48} if bools.on_deck_standing_near_loco_bool then flow1.visible = true flow1.surface_index = Hold.get_hold_surface(1).index flow1.zoom = 0.182 flow1.style.minimal_height = 292 flow1.style.minimal_width = 540 - flow1.position = { x = 0, y = -2 } + flow1.position = {x=0,y=-2} elseif bools.on_deck_standing_near_cabin_bool then flow1.visible = true flow1.surface_index = Cabin.get_cabin_surface().index flow1.zoom = 0.468 flow1.style.minimal_height = 400 flow1.style.minimal_width = 280 - flow1.position = { x = 0, y = -1 } + flow1.position = {x=0,y=-1} elseif bools.on_deck_standing_near_crowsnest_bool then flow1.visible = true flow1.surface_index = Crowsnest.get_crowsnest_surface().index flow1.zoom = 0.21 flow1.style.minimal_height = 384 flow1.style.minimal_width = 384 - flow1.position = { x = memory.overworldx, y = memory.overworldy } + flow1.position = {x=memory.overworldx,y=memory.overworldy} elseif bools.in_crowsnest_bool then flow1.visible = true flow1.surface_index = game.surfaces[memory.boat.surface_name].index @@ -1207,13 +1223,15 @@ function Public.update_gui(player) local position = memory.boat.position if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and memory.boat.surface_name and memory.boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then -- nicer viewing position: - position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 } + position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} end flow1.position = position end end end + + -- ATTENTION: Giving same names to GUI elements can cause issues, because click events are dispatched to all GUI windows! local function on_gui_click(event) if not event then return end @@ -1240,6 +1258,7 @@ local function on_gui_click(event) memory.undock_shortcut_are_you_sure_data[player.index] = game.tick end end + elseif memory.boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL then if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then local destination_index = memory.mapbeingloadeddestination_index @@ -1247,6 +1266,7 @@ 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 @@ -1255,16 +1275,17 @@ local function on_gui_click(event) 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) + 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 - local name = string.sub(event.element.name, 1, -14) - if Public[name] then - Public[name].toggle_window(player) - Public[name].full_update(player) - end + local name = string.sub(event.element.name, 1, -14) + if Public[name] then + Public[name].toggle_window(player) + Public[name].full_update(player) + end -- elseif event.element.name == 'fuel_label_1' or event.element.name == 'fuel_label_2' then -- Public.fuel.toggle_window(player) -- Public.fuel.full_update(player) @@ -1276,7 +1297,7 @@ local function on_gui_click(event) if GuiFuel.click then GuiFuel.click(event) end if GuiMinimap.click then GuiMinimap.click(event) end if GuiInfo.click then GuiInfo.click(event) end - end + end end local function on_gui_location_changed(event) @@ -1299,4 +1320,4 @@ event.add(defines.events.on_gui_location_changed, on_gui_location_changed) -return Public +return Public \ No newline at end of file diff --git a/maps/pirates/gui/progress.lua b/maps/pirates/gui/progress.lua index 2b832b33..a900d820 100644 --- a/maps/pirates/gui/progress.lua +++ b/maps/pirates/gui/progress.lua @@ -85,8 +85,12 @@ function Public.toggle_window(player) end +-- function Public.regular_update(player) + +-- end function Public.full_update(player) + if Public.regular_update then Public.regular_update(player) end if not player.gui.screen[window_name .. '_piratewindow'] then return end local flow = player.gui.screen[window_name .. '_piratewindow'] From 4cf88305853adaac8c655830cc4b49d14f08eb55 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 17:39:56 +0100 Subject: [PATCH 18/50] grace period to 150s, evo bump on killing nests removed --- maps/pirates/ai.lua | 4 +-- maps/pirates/balance.lua | 58 +++++++++++++++++++++------------------ maps/pirates/common.lua | 2 +- maps/pirates/coredata.lua | 1 + 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/maps/pirates/ai.lua b/maps/pirates/ai.lua index a81f6c96..4304337a 100644 --- a/maps/pirates/ai.lua +++ b/maps/pirates/ai.lua @@ -54,7 +54,7 @@ function Public.Tick_actions(tickinterval) if destination.type ~= Surfaces.enum.ISLAND then return end if memory.boat.state ~= Boats.enum_state.LANDED and memory.boat.state ~= Boats.enum_state.RETREATING then return end - if (memory.game_lost) or (destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Common.seconds_after_landing_to_enable_AI) then return end + if (memory.game_lost) or (destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Common.grace_period_on_arriving_at_island_seconds) then return end if game.tick % (tickinterval * 2) == 0 and memory.boat.state == Boats.enum_state.LANDED then local extra_evo = 2 * tickinterval / 60 * Balance.evolution_per_second() @@ -239,7 +239,7 @@ function Public.tell_biters_near_silo_to_attack_it() local enemy_force_name = memory.enemy_force_name -- don't do this too early - if destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Common.seconds_after_landing_to_enable_AI * 4 then return end + if destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Common.grace_period_on_arriving_at_island_seconds * 2 then return end if not (destination.dynamic_data.rocketsilos and destination.dynamic_data.rocketsilos[1] and destination.dynamic_data.rocketsilos[1].valid and destination.dynamic_data.rocketsilos[1].destructible) then return end local attackcommand = Public.attack_target_entity(destination.dynamic_data.rocketsilos[1]) diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index de824e37..e35a5f0f 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -215,7 +215,7 @@ end Public.expected_time_fraction = 0.7 function Public.expected_time_on_island() --always >0 - return Public.expected_time_fraction * Public.max_time_on_island_formula_seconds() + return Public.expected_time_fraction * Public.max_time_on_island_formula_seconds() + Public.grace_period_on_arriving_at_island_seconds end function Public.fuel_depletion_rate_static() @@ -255,21 +255,23 @@ function Public.boat_passive_pollution_per_minute(time) local boost if time then --sharp rise approaching T, steady increase thereafter - if time > T then - boost = 20 + 10 * (time - T) / (30 / 100 * T) - elseif time >= 90 / 100 * T then + local adjusted_time = Math.max(0, time - Public.grace_period_on_arriving_at_island_seconds) + + if adjusted_time > T then + boost = 20 + 10 * (adjusted_time - T) / (30 / 100 * T) + elseif adjusted_time >= 90 / 100 * T then boost = 16 - elseif time >= 85 / 100 * T then + elseif adjusted_time >= 85 / 100 * T then boost = 12 - elseif time >= 80 / 100 * T then + elseif adjusted_time >= 80 / 100 * T then boost = 8 - elseif time >= 70 / 100 * T then + elseif adjusted_time >= 70 / 100 * T then boost = 5 - elseif time >= 60 / 100 * T then + elseif adjusted_time >= 60 / 100 * T then boost = 3 - elseif time >= 50 / 100 * T then + elseif adjusted_time >= 50 / 100 * T then boost = 2 - elseif time >= 40 / 100 * T then + elseif adjusted_time >= 40 / 100 * T then boost = 1.5 else boost = 1 @@ -346,25 +348,27 @@ function Public.evolution_per_second() end function Public.evolution_per_nest_kill() --it's important to have evo go up with biter base kills, to provide resistance if you try to plow through all the bases - local destination = Common.current_destination() - if Common.overworldx() == 0 then return 0 end + -- local destination = Common.current_destination() + -- if Common.overworldx() == 0 then return 0 end - if destination and destination.dynamic_data and destination.dynamic_data.timer and destination.dynamic_data.timer > 0 and destination.dynamic_data.initial_spawner_count and destination.dynamic_data.initial_spawner_count > 0 then - local initial_spawner_count = destination.dynamic_data.initial_spawner_count - local base_evo_jump = 0.04 * (1 / initial_spawner_count) --extra friction to make them hard to mow through, even at late times + -- if destination and destination.dynamic_data and destination.dynamic_data.timer and destination.dynamic_data.timer > 0 and destination.dynamic_data.initial_spawner_count and destination.dynamic_data.initial_spawner_count > 0 then + -- local initial_spawner_count = destination.dynamic_data.initial_spawner_count + -- local base_evo_jump = 0.04 * (1 / initial_spawner_count) --extra friction to make them hard to mow through, even at late times - local time = destination.dynamic_data.timer - -- local time_to_jump_to = Public.expected_time_on_island() * ((1/Public.expected_time_fraction)^(2/3)) - local time_to_jump_to = Public.max_time_on_island_formula_seconds() - if time > time_to_jump_to then - return base_evo_jump - else - -- evo it 'would have' contributed: - return (1 / initial_spawner_count) * Public.expected_time_evo() * (time_to_jump_to - time) / time_to_jump_to + base_evo_jump - end - else - return 0 - end + -- local time = destination.dynamic_data.timer + -- -- local time_to_jump_to = Public.expected_time_on_island() * ((1/Public.expected_time_fraction)^(2/3)) + -- local time_to_jump_to = Public.max_time_on_island_formula_seconds() + -- if time > time_to_jump_to then + -- return base_evo_jump + -- else + -- -- evo it 'would have' contributed: + -- return (1 / initial_spawner_count) * Public.expected_time_evo() * (time_to_jump_to - time) / time_to_jump_to + base_evo_jump + -- end + -- else + -- return 0 + -- end + + return 0 -- return 0.003 * Common.difficulty_scale() end diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index b343ab02..bc77b305 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -32,7 +32,7 @@ Public.autodisband_hours = 24 * 5 -- should not be zero (as this messes with sav Public.boat_steps_at_a_time = 1 -Public.seconds_after_landing_to_enable_AI = 45 +Public.grace_period_on_arriving_at_island_seconds = 150 Public.boat_default_starting_distance_from_shore = 22 -- Public.mapedge_distance_from_boat_starting_position = 136 diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 90ec980e..3cb124b0 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -130,6 +130,7 @@ Public.difficulty_options = { { value = 2, icon = 'item/atomic-bomb', text = { 'pirates.difficulty_nightmare' }, associated_color = { r = 170, g = 60, b = 60 } }, } + function Public.get_difficulty_option_from_value(difficulty_value) -- given a difficulty value, key in to the closesy entry in the above table. (organising things this way allows us to make changes to the 'value' keys in the above table without disrupting e.g. past highscores data) if difficulty_value <= 0.75 then From 0b0a980cf298811b4225545a96692cbf1a129266 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 17:44:35 +0100 Subject: [PATCH 19/50] log --- maps/pirates/api_on_tick.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index 3872b5fd..da87f38e 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -1075,8 +1075,6 @@ function Public.loading_update(tickinterval) Overworld.ensure_lane_generated_up_to(24, Crowsnest.Data.visibilitywidth) Overworld.ensure_lane_generated_up_to(-24, Crowsnest.Data.visibilitywidth) - log(_inspect(memory.destinations)) - for i = 1, #memory.destinations do if memory.destinations[i].overworld_position.x == 0 then memory.mapbeingloadeddestination_index = i @@ -1112,6 +1110,8 @@ function Public.loading_update(tickinterval) end Progression.go_from_starting_dock_to_first_destination() + + log("starting game for crew " .. memory.name) elseif memory.loadingticks > 1230 then if boat then boat.speed = 0 From e1e591fa03f3df142ac26185be063ea2294a2619 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 17:52:16 +0100 Subject: [PATCH 20/50] limit overly large wave sizes --- maps/pirates/ai.lua | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/maps/pirates/ai.lua b/maps/pirates/ai.lua index 4304337a..5d7aa35d 100644 --- a/maps/pirates/ai.lua +++ b/maps/pirates/ai.lua @@ -155,10 +155,8 @@ function Public.wave_size_rng() -- random variance in attack sizes wave_size_multiplier = 1.5 elseif rng2 >= 15 * rng_scale then wave_size_multiplier = 2 - elseif rng2 >= 5 * rng_scale then - wave_size_multiplier = 3 else - wave_size_multiplier = 4 + wave_size_multiplier = 3 end end @@ -413,19 +411,7 @@ function Public.try_spawner_spend_fraction_of_available_pollution_on_biters(spaw if initial_spawner_count > 0 then local spawnerscount = Common.spawner_count(surface) if spawnerscount > 0 then - -- if Common.current_destination().subtype and Common.current_destination().subtype == IslandEnum.enum.RADIOACTIVE then - -- -- destroying spawners doesn't do quite as much here: - -- base_pollution_cost_multiplier = (initial_spawner_count/spawnerscount)^(1/3) - -- else - -- base_pollution_cost_multiplier = (initial_spawner_count/spawnerscount)^(1/2) - -- end - -- base_pollution_cost_multiplier = (initial_spawner_count/spawnerscount)^(1/2) - -- Now directly proportional: - map_pollution_cost_multiplier = initial_spawner_count / spawnerscount - - if memory.overworldx == 0 then - map_pollution_cost_multiplier = Math.max(1, map_pollution_cost_multiplier) - end -- The first map not being fully loaded when you get there commonly means it records too few initial spawners, which this helps fix + map_pollution_cost_multiplier = Math.max(initial_spawner_count / spawnerscount, 1) else map_pollution_cost_multiplier = 1000000 end From 753c43615d57b09d9cc57e412bfaab77bb3cb75f Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 17:57:57 +0100 Subject: [PATCH 21/50] revert island size increasese --- maps/pirates/overworld.lua | 2 +- .../surfaces/islands/horseshoe/data.lua | 8 +-- .../surfaces/islands/horseshoe/horseshoe.lua | 2 +- maps/pirates/surfaces/islands/hunt.lua | 2 +- .../surfaces/islands/standard/data.lua | 6 +- .../surfaces/islands/standard/standard.lua | 54 ++++++++--------- .../standard_variant/standard_variant.lua | 58 +++++++++---------- maps/pirates/surfaces/islands/swamp/data.lua | 6 +- 8 files changed, 63 insertions(+), 75 deletions(-) diff --git a/maps/pirates/overworld.lua b/maps/pirates/overworld.lua index 23af1544..8b614af7 100644 --- a/maps/pirates/overworld.lua +++ b/maps/pirates/overworld.lua @@ -70,7 +70,7 @@ local destinationScheme = { [15] = { DOCK, B, B }, [16] = { RADIOACTIVE, RADIOACTIVE, RADIOACTIVE }, [17] = { B, B, B }, - [18] = { C, C, C }, --first showing of robot frame cost + [18] = { C, C, C }, --first showing of robot frame cost [19] = { DOCK, B, B }, [20] = { WALKWAYS, WALKWAYS, WALKWAYS }, --rocket launch cost begins [21] = { SWAMP, RED_DESERT, STANDARD2 }, -- uniquely, this has a rocket launch cost, but still has an auto-undock timer diff --git a/maps/pirates/surfaces/islands/horseshoe/data.lua b/maps/pirates/surfaces/islands/horseshoe/data.lua index 45c30ea0..8eba0ae0 100644 --- a/maps/pirates/surfaces/islands/horseshoe/data.lua +++ b/maps/pirates/surfaces/islands/horseshoe/data.lua @@ -9,8 +9,8 @@ local Public = {} Public.display_names = { { 'pirates.location_displayname_horseshoe_1' }, { 'pirates.location_displayname_horseshoe_2' }, { 'pirates.location_displayname_horseshoe_3' } } -Public.terraingen_frame_width = 992 -Public.terraingen_frame_height = 992 +Public.terraingen_frame_width = 896 +Public.terraingen_frame_height = 896 Public.static_params_default = { starting_time_of_day = 0, daynightcycletype = 1, @@ -30,8 +30,8 @@ function Public.base_ores() } end -local rscale1 = 264 -local rscale2 = 230 +local rscale1 = 240 +local rscale2 = 210 local hscale = 0.1 Public.noiseparams = { radius1 = { diff --git a/maps/pirates/surfaces/islands/horseshoe/horseshoe.lua b/maps/pirates/surfaces/islands/horseshoe/horseshoe.lua index 7bef7591..3f4927a9 100644 --- a/maps/pirates/surfaces/islands/horseshoe/horseshoe.lua +++ b/maps/pirates/surfaces/islands/horseshoe/horseshoe.lua @@ -114,7 +114,7 @@ function Public.chunk_structures(args) return { placeable = noises.farness(p) > 0.36, -- spawners_indestructible = false, - spawners_indestructible = noises.farness(p) > 0.82, + spawners_indestructible = noises.farness(p) > 0.8, density_perchunk = 9 * Math.slopefromto(noises.mood(p), 0.12, -0.18) * Math.slopefromto(noises.farness(p), 0.36, 1) * args.biter_base_density_scale, } end diff --git a/maps/pirates/surfaces/islands/hunt.lua b/maps/pirates/surfaces/islands/hunt.lua index 710f3eb6..eaad45b0 100644 --- a/maps/pirates/surfaces/islands/hunt.lua +++ b/maps/pirates/surfaces/islands/hunt.lua @@ -101,7 +101,7 @@ function Public.mid_farness_position_1(args, points_to_avoid) if (not Utils.contains(CoreData.tiles_that_conflict_with_resource_layer, tile.name)) and (not Utils.contains(CoreData.edgemost_tile_names, tile.name)) then local p3 = { x = p2.x + args.static_params.terraingen_coordinates_offset.x, y = p2.y + args.static_params.terraingen_coordinates_offset.y } - if IslandsCommon.island_farness_1(args)(p3) > 0.1 and IslandsCommon.island_farness_1(args)(p3) < 0.7 then + if IslandsCommon.island_farness_1(args)(p3) > 0.1 and IslandsCommon.island_farness_1(args)(p3) < 0.75 then local allowed = true for _, pa in pairs(points_to_avoid) do if Math.distance({ x = pa.x, y = pa.y }, p2) < pa.r then diff --git a/maps/pirates/surfaces/islands/standard/data.lua b/maps/pirates/surfaces/islands/standard/data.lua index 9e49cdbb..db77da81 100644 --- a/maps/pirates/surfaces/islands/standard/data.lua +++ b/maps/pirates/surfaces/islands/standard/data.lua @@ -9,8 +9,8 @@ local Public = {} Public.display_names = { { 'pirates.location_displayname_standard_1' } } -Public.terraingen_frame_width = 1024 -Public.terraingen_frame_height = 1024 +Public.terraingen_frame_width = 896 +Public.terraingen_frame_height = 896 Public.static_params_default = { default_decoratives = true, base_starting_treasure = 1000, @@ -32,7 +32,7 @@ function Public.base_ores() } end -local rscale = 280 +local rscale = 250 local hscale = 0.1 Public.noiseparams = { radius = { diff --git a/maps/pirates/surfaces/islands/standard/standard.lua b/maps/pirates/surfaces/islands/standard/standard.lua index b64a9ace..67fc99a1 100644 --- a/maps/pirates/surfaces/islands/standard/standard.lua +++ b/maps/pirates/surfaces/islands/standard/standard.lua @@ -30,7 +30,6 @@ function Public.noises(args) return ret end - function Public.terrain(args) local noises = Public.noises(args) local p = args.p @@ -39,63 +38,62 @@ function Public.terrain(args) if IslandsCommon.place_water_tile(args) then return end if noises.height(p) < 0 then - args.tiles[#args.tiles + 1] = {name = 'water', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'water', position = args.p } return end if noises.height(p) < 0.05 then - args.tiles[#args.tiles + 1] = {name = 'sand-1', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'sand-1', position = args.p } if (not args.iconized_generation) and noises.farness(p) > 0.02 and noises.farness(p) < 0.6 and Math.random(500) == 1 then - args.specials[#args.specials + 1] = {name = 'buried-treasure', position = args.p} + args.specials[#args.specials + 1] = { name = 'buried-treasure', position = args.p } end elseif noises.height(p) < 0.12 then - args.tiles[#args.tiles + 1] = {name = 'sand-2', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'sand-2', position = args.p } else if noises.forest_abs_suppressed(p) > 0.3 and noises.rock(p) < 0.3 then - args.tiles[#args.tiles + 1] = {name = 'dry-dirt', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'dry-dirt', position = args.p } elseif noises.forest_abs_suppressed(p) > 0.15 and noises.rock(p) < 0.3 then - args.tiles[#args.tiles + 1] = {name = 'dirt-3', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'dirt-3', position = args.p } else - args.tiles[#args.tiles + 1] = {name = 'dirt-2', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'dirt-2', position = args.p } end end if noises.height(p) > 0.06 then if noises.forest_abs_suppressed(p) > 0.5 then - if (not args.iconized_generation) and noises.forest_abs_suppressed(p) < 0.75 and Math.random(1300) == 1 then - args.specials[#args.specials + 1] = {name = 'chest', position = args.p} + if (not args.iconized_generation) and noises.forest_abs_suppressed(p) < 0.75 and Math.random(1300) == 1 then + args.specials[#args.specials + 1] = { name = 'chest', position = args.p } else local forest_noise = noises.forest(p) local treedensity = 0.7 * Math.slopefromto(noises.forest_abs_suppressed(p), 0.5, 0.7) if forest_noise > 0 then if noises.rock(p) > 0 then - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-06', position = args.p, visible_on_overworld = true} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-06', position = args.p, visible_on_overworld = true } end else - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-06-brown', position = args.p} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-06-brown', position = args.p } end end elseif forest_noise < -1 then - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-03', position = args.p, visible_on_overworld = true} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-03', position = args.p, visible_on_overworld = true } end else - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-07', position = args.p} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-07', position = args.p } end end end end end if noises.forest_abs_suppressed(p) < 0.45 then - if noises.height(p) > 0.12 then if noises.rock_abs(p) > 0.22 then - local rockdensity = 1/600 * Math.slopefromto(noises.rock_abs(p), 0.22, 0.6) + 1/5 * Math.slopefromto(noises.rock_abs(p), 2.4, 2.6) + local rockdensity = 1 / 600 * Math.slopefromto(noises.rock_abs(p), 0.22, 0.6) + 1 / 5 * Math.slopefromto(noises.rock_abs(p), 2.4, 2.6) local rockrng = Math.random() if rockrng < rockdensity then args.entities[#args.entities + 1] = IslandsCommon.random_rock_1(args.p) elseif rockrng < rockdensity * 1.5 then - args.decoratives[#args.decoratives + 1] = {name = 'rock-medium', position = args.p} + args.decoratives[#args.decoratives + 1] = { name = 'rock-medium', position = args.p } elseif rockrng < rockdensity * 2 then - args.decoratives[#args.decoratives + 1] = {name = 'rock-small', position = args.p} + args.decoratives[#args.decoratives + 1] = { name = 'rock-small', position = args.p } elseif rockrng < rockdensity * 2.5 then - args.decoratives[#args.decoratives + 1] = {name = 'rock-tiny', position = args.p} + args.decoratives[#args.decoratives + 1] = { name = 'rock-tiny', position = args.p } end end end @@ -103,29 +101,27 @@ function Public.terrain(args) if noises.height(p) > 0.18 and noises.mood(p) > 0.6 then if noises.forest_abs(p) < 0.2 and noises.rock_abs(p) > 1.5 then - args.entities[#args.entities + 1] = {name = 'coal', position = args.p, amount = 7} + args.entities[#args.entities + 1] = { name = 'coal', position = args.p, amount = 7 } end end end - function Public.chunk_structures(args) - - local spec = function(p) - local noises = Public.noises{p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed} + local spec = function (p) + local noises = Public.noises { p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed } return { placeable = noises.farness(p) > 0.3, spawners_indestructible = noises.farness(p) > 0.7, -- spawners_indestructible = false, - density_perchunk = 30 * Math.slopefromto(noises.mood(p), 0.14, -0.1) * Math.slopefromto(noises.farness(p), 0.3, 1)^(1.5) * args.biter_base_density_scale, + density_perchunk = 30 * Math.slopefromto(noises.mood(p), 0.14, -0.1) * Math.slopefromto(noises.farness(p), 0.3, 1) ^ 1.5 * args.biter_base_density_scale, } end IslandsCommon.enemies_1(args, spec) - local spec2 = function(p) - local noises = Public.noises{p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed} + local spec2 = function (p) + local noises = Public.noises { p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed } return { -- placeable = noises.height(p) >= 0 and noises.forest_abs_suppressed(p) < 0.3 + Math.max(0, 0.2 - noises.height(p)), @@ -137,7 +133,6 @@ function Public.chunk_structures(args) IslandsCommon.assorted_structures_1(args, spec2) end - -- function Public.break_rock(surface, p, entity_name) -- -- return Ores.try_ore_spawn(surface, p, entity_name) -- end @@ -147,5 +142,4 @@ function Public.generate_silo_setup_position(points_to_avoid) return Hunt.silo_setup_position(points_to_avoid) end - -return Public \ No newline at end of file +return Public diff --git a/maps/pirates/surfaces/islands/standard_variant/standard_variant.lua b/maps/pirates/surfaces/islands/standard_variant/standard_variant.lua index 8962fe77..dbbbf382 100644 --- a/maps/pirates/surfaces/islands/standard_variant/standard_variant.lua +++ b/maps/pirates/surfaces/islands/standard_variant/standard_variant.lua @@ -30,7 +30,6 @@ function Public.noises(args) return ret end - function Public.terrain(args) local noises = Public.noises(args) local p = args.p @@ -39,67 +38,66 @@ function Public.terrain(args) if IslandsCommon.place_water_tile(args) then return end if noises.height(p) < 0 then - args.tiles[#args.tiles + 1] = {name = 'water', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'water', position = args.p } return end if noises.height(p) < 0.04 then - args.tiles[#args.tiles + 1] = {name = 'sand-1', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'sand-1', position = args.p } if (not args.iconized_generation) and noises.farness(p) > 0.02 and noises.farness(p) < 0.6 and Math.random(500) == 1 then - args.specials[#args.specials + 1] = {name = 'buried-treasure', position = args.p} + args.specials[#args.specials + 1] = { name = 'buried-treasure', position = args.p } end elseif noises.height(p) < 0.05 then - args.tiles[#args.tiles + 1] = {name = 'sand-2', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'sand-2', position = args.p } elseif noises.height(p) < 0.11 then - args.tiles[#args.tiles + 1] = {name = 'dry-dirt', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'dry-dirt', position = args.p } elseif noises.height(p) < 0.12 then - args.tiles[#args.tiles + 1] = {name = 'grass-4', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'grass-4', position = args.p } else if noises.forest_abs_suppressed(p) > 0.3 and noises.rock(p) < 0.3 then - args.tiles[#args.tiles + 1] = {name = 'dirt-7', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'dirt-7', position = args.p } elseif noises.forest_abs_suppressed(p) > 0.15 and noises.rock(p) < 0.3 then - args.tiles[#args.tiles + 1] = {name = 'grass-4', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'grass-4', position = args.p } else - args.tiles[#args.tiles + 1] = {name = 'grass-3', position = args.p} + args.tiles[#args.tiles + 1] = { name = 'grass-3', position = args.p } end end if noises.height(p) > 0.11 then if noises.forest_abs_suppressed(p) > 0.7 then - if (not args.iconized_generation) and noises.forest_abs_suppressed(p) < 1 and Math.random(700) == 1 then -- high amounts of this - args.specials[#args.specials + 1] = {name = 'chest', position = args.p} + if (not args.iconized_generation) and noises.forest_abs_suppressed(p) < 1 and Math.random(700) == 1 then -- high amounts of this + args.specials[#args.specials + 1] = { name = 'chest', position = args.p } else local forest_noise = noises.forest(p) local treedensity = 0.7 * Math.slopefromto(noises.forest_abs_suppressed(p), 0.61, 0.76) if forest_noise > 0 then if noises.rock(p) > 0.05 then - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-08-red', position = args.p, visible_on_overworld = true} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-08-red', position = args.p, visible_on_overworld = true } end elseif noises.rock(p) < -0.05 then - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-09-brown', position = args.p} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-09-brown', position = args.p } end end elseif forest_noise < -1.2 then - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-09', position = args.p, visible_on_overworld = true} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-09', position = args.p, visible_on_overworld = true } end else - if Math.random(1,100) < treedensity*100 then args.entities[#args.entities + 1] = {name = 'tree-02-red', position = args.p} end + if Math.random(1, 100) < treedensity * 100 then args.entities[#args.entities + 1] = { name = 'tree-02-red', position = args.p } end end end end end if noises.forest_abs_suppressed(p) < 0.45 then - if noises.height(p) > 0.12 then if noises.rock_abs(p) > 0.25 then - local rockdensity = 1/600 * Math.slopefromto(noises.rock_abs(p), 0.25, 0.6) + 1/5 * Math.slopefromto(noises.rock_abs(p), 2.4, 2.6) + local rockdensity = 1 / 600 * Math.slopefromto(noises.rock_abs(p), 0.25, 0.6) + 1 / 5 * Math.slopefromto(noises.rock_abs(p), 2.4, 2.6) local rockrng = Math.random() if rockrng < rockdensity then args.entities[#args.entities + 1] = IslandsCommon.random_rock_1(args.p) elseif rockrng < rockdensity * 1.5 then - args.decoratives[#args.decoratives + 1] = {name = 'rock-medium', position = args.p} + args.decoratives[#args.decoratives + 1] = { name = 'rock-medium', position = args.p } elseif rockrng < rockdensity * 2 then - args.decoratives[#args.decoratives + 1] = {name = 'rock-small', position = args.p} + args.decoratives[#args.decoratives + 1] = { name = 'rock-small', position = args.p } elseif rockrng < rockdensity * 2.5 then - args.decoratives[#args.decoratives + 1] = {name = 'rock-tiny', position = args.p} + args.decoratives[#args.decoratives + 1] = { name = 'rock-tiny', position = args.p } end end end @@ -107,29 +105,27 @@ function Public.terrain(args) if noises.height(p) > 0.18 and noises.mood(p) > 0.3 then if noises.forest_abs(p) < 0.2 and noises.rock_abs(p) > 1.5 then - args.entities[#args.entities + 1] = {name = 'coal', position = args.p, amount = 7} + args.entities[#args.entities + 1] = { name = 'coal', position = args.p, amount = 7 } end end end - function Public.chunk_structures(args) - - local spec = function(p) - local noises = Public.noises{p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed} + local spec = function (p) + local noises = Public.noises { p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed } return { placeable = noises.farness(p) > 0.3, -- spawners_indestructible = false, spawners_indestructible = noises.farness(p) > 0.7, - density_perchunk = 25 * Math.slopefromto(noises.mood(p), 0.16, -0.1) * Math.slopefromto(noises.farness(p), 0.3, 1)^2 * args.biter_base_density_scale, + density_perchunk = 25 * Math.slopefromto(noises.mood(p), 0.16, -0.1) * Math.slopefromto(noises.farness(p), 0.3, 1) ^ 2 * args.biter_base_density_scale, } end IslandsCommon.enemies_1(args, spec) - local spec2 = function(p) - local noises = Public.noises{p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed} + local spec2 = function (p) + local noises = Public.noises { p = p, noise_generator = args.noise_generator, static_params = args.static_params, seed = args.seed } return { -- placeable = noises.height(p) >= 0 and noises.forest_abs_suppressed(p) < 0.3 + Math.max(0, 0.2 - noises.height(p)), @@ -141,7 +137,6 @@ function Public.chunk_structures(args) IslandsCommon.assorted_structures_1(args, spec2) end - -- function Public.break_rock(surface, p, entity_name) -- -- return Ores.try_ore_spawn(surface, p, entity_name) -- end @@ -151,5 +146,4 @@ function Public.generate_silo_setup_position(points_to_avoid) return Hunt.silo_setup_position(points_to_avoid) end - -return Public \ No newline at end of file +return Public diff --git a/maps/pirates/surfaces/islands/swamp/data.lua b/maps/pirates/surfaces/islands/swamp/data.lua index 3e2bfab7..98a82cfe 100644 --- a/maps/pirates/surfaces/islands/swamp/data.lua +++ b/maps/pirates/surfaces/islands/swamp/data.lua @@ -9,8 +9,8 @@ local Public = {} Public.display_names = { { 'pirates.location_displayname_swamp_1' } } -Public.terraingen_frame_width = 480 -Public.terraingen_frame_height = 480 +Public.terraingen_frame_width = 400 +Public.terraingen_frame_height = 400 Public.static_params_default = { starting_time_of_day = 0.26, daynightcycletype = 1, @@ -32,7 +32,7 @@ function Public.base_ores() } end -local rscale = 185 +local rscale = 170 Public.noiseparams = { radius = { type = 'simplex_2d', From 1d6ce41f115f78adb821524c66bc23b5e48c5880 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 18:07:42 +0100 Subject: [PATCH 22/50] fix grace period --- maps/pirates/ai.lua | 8 +++++--- maps/pirates/balance.lua | 2 ++ maps/pirates/common.lua | 2 -- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/maps/pirates/ai.lua b/maps/pirates/ai.lua index 5d7aa35d..b458cacf 100644 --- a/maps/pirates/ai.lua +++ b/maps/pirates/ai.lua @@ -54,7 +54,7 @@ function Public.Tick_actions(tickinterval) if destination.type ~= Surfaces.enum.ISLAND then return end if memory.boat.state ~= Boats.enum_state.LANDED and memory.boat.state ~= Boats.enum_state.RETREATING then return end - if (memory.game_lost) or (destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Common.grace_period_on_arriving_at_island_seconds) then return end + if (memory.game_lost) or (destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Balance.grace_period_on_arriving_at_island_seconds) then return end if game.tick % (tickinterval * 2) == 0 and memory.boat.state == Boats.enum_state.LANDED then local extra_evo = 2 * tickinterval / 60 * Balance.evolution_per_second() @@ -155,8 +155,10 @@ function Public.wave_size_rng() -- random variance in attack sizes wave_size_multiplier = 1.5 elseif rng2 >= 15 * rng_scale then wave_size_multiplier = 2 - else + elseif rng2 >= 2 * rng_scale then wave_size_multiplier = 3 + else + wave_size_multiplier = 4 end end @@ -237,7 +239,7 @@ function Public.tell_biters_near_silo_to_attack_it() local enemy_force_name = memory.enemy_force_name -- don't do this too early - if destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Common.grace_period_on_arriving_at_island_seconds * 2 then return end + if destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer < destination.dynamic_data.timeratlandingtime + Balance.grace_period_on_arriving_at_island_seconds * 2 then return end if not (destination.dynamic_data.rocketsilos and destination.dynamic_data.rocketsilos[1] and destination.dynamic_data.rocketsilos[1].valid and destination.dynamic_data.rocketsilos[1].destructible) then return end local attackcommand = Public.attack_target_entity(destination.dynamic_data.rocketsilos[1]) diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index e35a5f0f..10b543ac 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -214,6 +214,8 @@ end Public.expected_time_fraction = 0.7 +Public.grace_period_on_arriving_at_island_seconds = 120 + function Public.expected_time_on_island() --always >0 return Public.expected_time_fraction * Public.max_time_on_island_formula_seconds() + Public.grace_period_on_arriving_at_island_seconds end diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index bc77b305..16cc2a7e 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -32,8 +32,6 @@ Public.autodisband_hours = 24 * 5 -- should not be zero (as this messes with sav Public.boat_steps_at_a_time = 1 -Public.grace_period_on_arriving_at_island_seconds = 150 - Public.boat_default_starting_distance_from_shore = 22 -- Public.mapedge_distance_from_boat_starting_position = 136 Public.mapedge_distance_from_boat_starting_position = 272 -- to accommodate horseshoe From f10ee917d91cee9fda4f19ef343c1da9aab5451f Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 18:10:08 +0100 Subject: [PATCH 23/50] captains can no longer open red chests in restricted areas --- maps/pirates/api_events.lua | 13 ++- maps/pirates/roles/roles.lua | 179 +++++++++++++++-------------------- 2 files changed, 83 insertions(+), 109 deletions(-) diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index d5c5ab75..166da532 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -2225,10 +2225,15 @@ local function event_on_gui_opened(event) if not player then return end if not player.valid then return end - if player.permission_group.name ~= 'restricted_area' then return end - - if entity.name == 'wooden-chest' or entity.name == 'iron-chest' or entity.name == 'steel-chest' or entity.name == 'red-chest' or entity.name == 'blue-chest' then - player.opened = nil + if player.permission_group.name == 'cabin_privileged' then + if entity.name == 'red-chest' then + -- Even the captain has to wait for items to be removed from the red chests by loaders: + player.opened = nil + end + elseif player.permission_group.name == 'cabin' then + if entity.name == 'wooden-chest' or entity.name == 'iron-chest' or entity.name == 'steel-chest' or entity.name == 'red-chest' or entity.name == 'blue-chest' then + player.opened = nil + end end end diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index 5c61be1b..b732393a 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -562,112 +562,92 @@ function Public.captain_tax(captain_index) end end -function Public.try_create_permissions_groups() - if not game.permissions.get_group('restricted_area') then - local group = game.permissions.create_group('restricted_area') - if not _DEBUG then - group.set_allows_action(defines.input_action.edit_permission_group, false) - end - group.set_allows_action(defines.input_action.import_permissions_string, false) - group.set_allows_action(defines.input_action.delete_permission_group, false) - group.set_allows_action(defines.input_action.add_permission_group, false) - group.set_allows_action(defines.input_action.admin_action, false) - - group.set_allows_action(defines.input_action.cancel_craft, false) - group.set_allows_action(defines.input_action.drop_item, false) - group.set_allows_action(defines.input_action.drop_blueprint_record, false) - group.set_allows_action(defines.input_action.build, false) - group.set_allows_action(defines.input_action.build_rail, false) - group.set_allows_action(defines.input_action.build_terrain, false) - group.set_allows_action(defines.input_action.begin_mining, false) - group.set_allows_action(defines.input_action.begin_mining_terrain, false) - -- group.set_allows_action(defines.input_action.deconstruct, false) --pick up dead players - group.set_allows_action(defines.input_action.activate_copy, false) - group.set_allows_action(defines.input_action.activate_cut, false) - group.set_allows_action(defines.input_action.activate_paste, false) - group.set_allows_action(defines.input_action.upgrade, false) - group.set_allows_action(defines.input_action.deconstruct, false) +local function set_normal_permissions(group) + if not _DEBUG then + group.set_allows_action(defines.input_action.edit_permission_group, false) + end + group.set_allows_action(defines.input_action.import_permissions_string, false) + group.set_allows_action(defines.input_action.delete_permission_group, false) + group.set_allows_action(defines.input_action.add_permission_group, false) + group.set_allows_action(defines.input_action.admin_action, false) + if not CoreData.blueprint_library_allowed then + group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) group.set_allows_action(defines.input_action.grab_blueprint_record, false) - if not CoreData.blueprint_library_allowed then - group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) - end - if not CoreData.blueprint_importing_allowed then - group.set_allows_action(defines.input_action.import_blueprint_string, false) - group.set_allows_action(defines.input_action.import_blueprint, false) - end + end + if not CoreData.blueprint_importing_allowed then + group.set_allows_action(defines.input_action.import_blueprint_string, false) + group.set_allows_action(defines.input_action.import_blueprint, false) + end +end - group.set_allows_action(defines.input_action.fast_entity_transfer, false) - group.set_allows_action(defines.input_action.fast_entity_split, false) +local function set_restricted_permissions(group) + set_normal_permissions(group) + + group.set_allows_action(defines.input_action.cancel_craft, false) + group.set_allows_action(defines.input_action.drop_item, false) + group.set_allows_action(defines.input_action.drop_blueprint_record, false) + group.set_allows_action(defines.input_action.build, false) + group.set_allows_action(defines.input_action.build_rail, false) + group.set_allows_action(defines.input_action.build_terrain, false) + group.set_allows_action(defines.input_action.begin_mining, false) + group.set_allows_action(defines.input_action.begin_mining_terrain, false) + group.set_allows_action(defines.input_action.activate_copy, false) + group.set_allows_action(defines.input_action.activate_cut, false) + group.set_allows_action(defines.input_action.activate_paste, false) + group.set_allows_action(defines.input_action.upgrade, false) + group.set_allows_action(defines.input_action.deconstruct, false) + group.set_allows_action(defines.input_action.fast_entity_transfer, false) + group.set_allows_action(defines.input_action.fast_entity_split, false) +end + +function Public.try_create_permissions_groups() + if not game.permissions.get_group('lobby') then + local group = game.permissions.create_group('lobby') + set_restricted_permissions(group) + end + + if not game.permissions.get_group('crowsnest') then + local group = game.permissions.create_group('crowsnest') + set_restricted_permissions(group) + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + end + + if not game.permissions.get_group('crowsnest_privileged') then + local group = game.permissions.create_group('crowsnest_privileged') + set_restricted_permissions(group) + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + + group.set_allows_action(defines.input_action.fast_entity_transfer, true) + group.set_allows_action(defines.input_action.fast_entity_split, true) + end + + if not game.permissions.get_group('cabin') then + local group = game.permissions.create_group('cabin') + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + set_restricted_permissions(group) -- Note there is other code to prevent these players from opening chests end - if not game.permissions.get_group('restricted_area_privileged') then - local group = game.permissions.create_group('restricted_area_privileged') - if not _DEBUG then - group.set_allows_action(defines.input_action.edit_permission_group, false) - end - group.set_allows_action(defines.input_action.import_permissions_string, false) - group.set_allows_action(defines.input_action.delete_permission_group, false) - group.set_allows_action(defines.input_action.add_permission_group, false) - group.set_allows_action(defines.input_action.admin_action, false) + if not game.permissions.get_group('cabin_privileged') then + local group = game.permissions.create_group('cabin_privileged') + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + set_restricted_permissions(group) - group.set_allows_action(defines.input_action.cancel_craft, false) - group.set_allows_action(defines.input_action.drop_item, false) - group.set_allows_action(defines.input_action.drop_blueprint_record, false) - group.set_allows_action(defines.input_action.build, false) - group.set_allows_action(defines.input_action.build_rail, false) - group.set_allows_action(defines.input_action.build_terrain, false) - group.set_allows_action(defines.input_action.begin_mining, false) - group.set_allows_action(defines.input_action.begin_mining_terrain, false) - -- group.set_allows_action(defines.input_action.deconstruct, false) --pick up dead players - group.set_allows_action(defines.input_action.activate_copy, false) - group.set_allows_action(defines.input_action.activate_cut, false) - group.set_allows_action(defines.input_action.activate_paste, false) - group.set_allows_action(defines.input_action.upgrade, false) - group.set_allows_action(defines.input_action.deconstruct, false) - - if not CoreData.blueprint_library_allowed then - group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) - group.set_allows_action(defines.input_action.grab_blueprint_record, false) - end - if not CoreData.blueprint_importing_allowed then - group.set_allows_action(defines.input_action.import_blueprint_string, false) - group.set_allows_action(defines.input_action.import_blueprint, false) - end + -- Note there is other code to prevent these players from opening chests end if not game.permissions.get_group('plebs') then local group = game.permissions.create_group('plebs') - if not _DEBUG then - group.set_allows_action(defines.input_action.edit_permission_group, false) - end - group.set_allows_action(defines.input_action.import_permissions_string, false) - group.set_allows_action(defines.input_action.delete_permission_group, false) - group.set_allows_action(defines.input_action.add_permission_group, false) - group.set_allows_action(defines.input_action.admin_action, false) - - if not CoreData.blueprint_library_allowed then - group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) - group.set_allows_action(defines.input_action.grab_blueprint_record, false) - end - if not CoreData.blueprint_importing_allowed then - group.set_allows_action(defines.input_action.import_blueprint_string, false) - group.set_allows_action(defines.input_action.import_blueprint, false) - end + set_normal_permissions(group) end if not game.permissions.get_group('not_trusted') then local group = game.permissions.create_group('not_trusted') + set_normal_permissions(group) + -- not_trusted.set_allows_action(defines.input_action.cancel_craft, false) - if not _DEBUG then - group.set_allows_action(defines.input_action.edit_permission_group, false) - end - group.set_allows_action(defines.input_action.import_permissions_string, false) - group.set_allows_action(defines.input_action.delete_permission_group, false) - group.set_allows_action(defines.input_action.add_permission_group, false) - group.set_allows_action(defines.input_action.admin_action, false) -- not_trusted.set_allows_action(defines.input_action.drop_item, false) group.set_allows_action(defines.input_action.disconnect_rolling_stock, false) group.set_allows_action(defines.input_action.connect_rolling_stock, false) @@ -683,15 +663,6 @@ function Public.try_create_permissions_groups() group.set_allows_action(defines.input_action.remove_train_station, false) group.set_allows_action(defines.input_action.set_trains_limit, false) group.set_allows_action(defines.input_action.set_train_stopped, false) - - group.set_allows_action(defines.input_action.grab_blueprint_record, false) - if not CoreData.blueprint_library_allowed then - group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) - end - if not CoreData.blueprint_importing_allowed then - group.set_allows_action(defines.input_action.import_blueprint_string, false) - group.set_allows_action(defines.input_action.import_blueprint, false) - end end end @@ -749,20 +720,18 @@ function Public.update_privileges(player) if string.sub(player.surface.name, 9, 17) == 'Crowsnest' then if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then - return Public.add_player_to_permission_group(player, 'restricted_area_privileged') + return Public.add_player_to_permission_group(player, 'crowsnest_privileged') else - return Public.add_player_to_permission_group(player, 'restricted_area') + return Public.add_player_to_permission_group(player, 'crowsnest') end elseif string.sub(player.surface.name, 9, 13) == 'Cabin' then if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then - return Public.add_player_to_permission_group(player, 'restricted_area_privileged') + return Public.add_player_to_permission_group(player, 'cabin_privileged') else - -- return Public.add_player_to_permission_group(player, 'restricted_area') - -- Moved to restricted_area to prevent them messing with items in the blue chests.ssd - return Public.add_player_to_permission_group(player, 'restricted_area') + return Public.add_player_to_permission_group(player, 'cabin') end elseif player.surface.name == CoreData.lobby_surface_name then - return Public.add_player_to_permission_group(player, 'restricted_area') + return Public.add_player_to_permission_group(player, 'lobby') else return Public.add_player_to_permission_group(player) end From 6f0af64bbe1a42ef5e375300f24d87c7f65c7b13 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 18:30:39 +0100 Subject: [PATCH 24/50] fix showing time when protections unlock stuck at 24hr --- maps/pirates/gui/runs.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index 0d2cd3d6..bf16f876 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -512,10 +512,10 @@ function Public.full_update(player) flow.ongoing_runs.body.leaving_prompt.visible = playercrew_status.leaving - local show_protected_info = crewid and global_memory.crew_memories[crewid].run_is_protected + local show_protected_info = crewid and global_memory.crew_memories[crewid].run_is_protected and global_memory.crew_memories[crewid].protected_run_lock_timer < 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr flow.ongoing_runs.body.join_protected_crew_info.visible = show_protected_info - local show_private_info = crewid and global_memory.crew_memories[crewid].run_is_private + local show_private_info = crewid and global_memory.crew_memories[crewid].run_is_private and global_memory.crew_memories[crewid].private_run_lock_timer < 60 * 60 * 60 * CoreData.private_run_lock_amount_hr flow.ongoing_runs.body.join_private_crew_info.visible = show_private_info flow.ongoing_runs.body.password_namefield.visible = show_private_info end From 45d62f78b74588ef2bb16652eccb90c894075530 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 18:40:00 +0100 Subject: [PATCH 25/50] bump private run cap to 4 --- maps/pirates/common.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index 16cc2a7e..3c911d20 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -21,8 +21,8 @@ local Public = {} Public.starting_ships_count = 7 Public.active_crews_cap = 7 -Public.private_run_cap = 3 -Public.protected_but_not_private_run_cap = 3 +Public.private_run_cap = 4 +Public.protected_but_not_private_run_cap = 2 Public.minimumCapacitySliderValue = 1 Public.minimum_run_capacity_to_enforce_space_for = 22 From 3c3ff9f166f8771550936103a726b9293ed68c82 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 18:53:38 +0100 Subject: [PATCH 26/50] disable blueprints setting --- locale/en/pirates.cfg | 4 +- maps/pirates/common.lua | 1 - maps/pirates/coredata.lua | 4 +- maps/pirates/crew.lua | 1 + maps/pirates/gui/runs.lua | 147 ++++++++++++++--------------------- maps/pirates/main.lua | 2 - maps/pirates/roles/roles.lua | 80 ++++++++++++------- 7 files changed, 117 insertions(+), 122 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index fb17f04c..1b05b331 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -527,10 +527,10 @@ gui_runs_proposals_abandon_proposal=Abandon Proposal gui_runs_proposal_maker_run_name=Crew name gui_runs_proposal_maker_run_name_2=Name gui_runs_proposal_maker_capacity=Capacity -gui_runs_proposal_maker_capacity_disabled=This capacity setting isn't available at the moment. gui_runs_proposal_maker_propose=Propose gui_runs_proposal_maker_no_limit=No limit -gui_runs_proposal_maker_protected=Protected +gui_runs_proposal_maker_blueprints_disabled=Blueprints disabled +gui_runs_proposal_maker_protected=Captain-Protected gui_runs_proposal_maker_protected_tooltip=Captain-protected crew. If the captain leaves or becomes afk, and there are no officers, the captain role stays vacant.\nIf the crew is empty or inactive for __1__ hours, it becomes unprotected. gui_runs_proposal_maker_private=Private gui_runs_proposal_maker_private_tooltip=Private crew. Once the crew has launched, players must enter the password in order to join.\nIf the crew is empty or inactive for __1__ hours, the password is removed. diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index 3c911d20..2898a50d 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -23,7 +23,6 @@ Public.starting_ships_count = 7 Public.active_crews_cap = 7 Public.private_run_cap = 4 Public.protected_but_not_private_run_cap = 2 -Public.minimumCapacitySliderValue = 1 Public.minimum_run_capacity_to_enforce_space_for = 22 -- auto-disbanding when there are no players left in the crew: diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 3cb124b0..5619c151 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -9,8 +9,8 @@ local Public = {} Public.scenario_id_name = 'pirates' Public.version_string = '1.6.2' --major.minor.patch versioning, to match factorio mod portal -Public.blueprint_library_allowed = true -Public.blueprint_importing_allowed = true +-- Public.blueprint_library_allowed = true +-- Public.blueprint_importing_allowed = true Public.rocket_silo_death_causes_loss = false diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index d0ce7ac5..41b9e52d 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -752,6 +752,7 @@ function Public.initialise_crew(accepted_proposal, player_position) memory.difficulty = CoreData.difficulty_options[accepted_proposal.difficulty_option].value memory.capacity = CoreData.capacity_options[accepted_proposal.capacity_option].value -- memory.mode = CoreData.mode_options[accepted_proposal.mode_option].value + memory.run_has_blueprints_disabled = accepted_proposal.run_has_blueprints_disabled memory.run_is_protected = accepted_proposal.run_is_protected memory.protected_run_lock_timer = 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr memory.run_is_private = accepted_proposal.run_is_private diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index bf16f876..13b0f8dd 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -164,7 +164,7 @@ end function Public.toggle_window(player) local window - local flow, flow2, flow3, flow4, flow5 + local flow, flow2, flow3, flow4, flow5, flow6 --*** OVERALL FLOW ***-- if player.gui.screen[window_name .. '_piratewindow'] then @@ -223,7 +223,7 @@ function Public.toggle_window(player) flow3.style.single_line = false flow3 = flow2.add({ - name = 'password_namefield', + name = 'password', type = 'textfield', text = '', visible = false, @@ -336,11 +336,25 @@ function Public.toggle_window(player) flow5.style.width = 150 flow5.style.height = 24 flow5.style.top_margin = -3 - flow5.style.bottom_margin = 3 - -- PROTECTED RUN ELEMENTS -- + -- CREW SETTINGS -- - flow4.add({ + flow5 = flow4.add({ + name = 'settings', + type = 'flow', + direction = 'vertical', + }) + flow5.style.horizontal_align = 'left' + flow5.style.bottom_margin = 5 + + flow5.add({ + name = 'blueprints_disabled_checkbox', + type = 'checkbox', + caption = { 'pirates.gui_runs_proposal_maker_blueprints_disabled' }, + state = false, + }) + + flow5.add({ name = 'protected_checkbox', type = 'checkbox', caption = { 'pirates.gui_runs_proposal_maker_protected' }, @@ -348,9 +362,7 @@ function Public.toggle_window(player) tooltip = { 'pirates.gui_runs_proposal_maker_protected_tooltip', CoreData.protected_run_lock_amount_hr } }) - -- PRIVATE RUN ELEMENTS -- - - flow4.add({ + flow5.add({ name = 'private_checkbox', type = 'checkbox', caption = { 'pirates.gui_runs_proposal_maker_private' }, @@ -358,44 +370,44 @@ function Public.toggle_window(player) tooltip = { 'pirates.gui_runs_proposal_maker_private_tooltip', CoreData.private_run_lock_amount_hr } }) - flow5 = flow4.add({ + flow6 = flow5.add({ name = 'password_label', type = 'label', caption = { 'pirates.gui_runs_proposal_maker_password' }, }) - flow5.style.font = 'heading-3' + flow6.style.font = 'heading-3' - flow5 = flow4.add({ - name = 'password_namefield', + flow6 = flow5.add({ + name = 'password', type = 'textfield', text = '', }) - flow5.style.width = 150 - flow5.style.height = 24 - flow5.style.top_margin = -3 - flow5.style.bottom_margin = 3 + flow6.style.width = 150 + flow6.style.height = 24 + flow6.style.top_margin = -3 + flow6.style.bottom_margin = 3 - flow5 = flow4.add({ + flow6 = flow5.add({ name = 'confirm_password_label', type = 'label', caption = { 'pirates.gui_runs_proposal_maker_confirm_password' }, }) - flow5.style.font = 'heading-3' + flow6.style.font = 'heading-3' - flow5 = flow4.add({ - name = 'confirm_password_namefield', + flow6 = flow5.add({ + name = 'confirm_password', type = 'textfield', text = '', }) - flow5.style.width = 150 - flow5.style.height = 24 - flow5.style.top_margin = -3 - flow5.style.bottom_margin = 3 + flow6.style.width = 150 + flow6.style.height = 24 + flow6.style.top_margin = -3 + flow6.style.bottom_margin = 3 -- CREW SIZE LIMIT SLIDER -- flow5 = flow4.add({ - name = 'options', + name = 'capacity_options', type = 'table', column_count = 2, }) @@ -406,22 +418,6 @@ function Public.toggle_window(player) -- flow_add_proposal_slider(flow5, 'difficulty', 'Difficulty', #CoreData.difficulty_options, 2, {'pirates.difficulty_tooltip'}) -- flow_add_proposal_switch(flow5, 'mode', 'Mode', 'left', {'pirates.mode_tooltip'}) - -- flow5 = flow4.add({ - -- name = 'proposal_cant_do_infinity_mode', - -- type = 'label', - -- caption = 'Infinity mode isn\'t available at the moment.', - -- }) - -- flow5.style.single_line = false - -- flow5.style.maximal_width = 200 - - flow5 = flow4.add({ - name = 'proposal_disabled_low_crew_caps', - type = 'label', - caption = { 'pirates.gui_runs_proposal_maker_capacity_disabled' }, - }) - flow5.style.single_line = false - flow5.style.maximal_width = 200 - flow5 = flow4.add({ name = 'propose_crew', type = 'button', @@ -515,9 +511,9 @@ function Public.full_update(player) local show_protected_info = crewid and global_memory.crew_memories[crewid].run_is_protected and global_memory.crew_memories[crewid].protected_run_lock_timer < 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr flow.ongoing_runs.body.join_protected_crew_info.visible = show_protected_info - local show_private_info = crewid and global_memory.crew_memories[crewid].run_is_private and global_memory.crew_memories[crewid].private_run_lock_timer < 60 * 60 * 60 * CoreData.private_run_lock_amount_hr + local show_private_info = crewid and global_memory.crew_memories[crewid].run_is_private flow.ongoing_runs.body.join_private_crew_info.visible = show_private_info - flow.ongoing_runs.body.password_namefield.visible = show_private_info + flow.ongoing_runs.body.password.visible = show_private_info end flow.proposals.visible = (memory.crewstatus == nil and not playercrew_status.leaving) @@ -537,21 +533,13 @@ function Public.full_update(player) flow.proposals.body.flow_proposal_launch.proposal_crew_count_capped.visible = playercrew_status.crew_count_capped - -- flow.proposals.body.proposal_maker.body.proposal_cant_do_infinity_mode.visible = (flow.proposals.body.proposal_maker.body.options.mode.mode.switch.switch_state == 'right') - - -- flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible = false - flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible = (flow.proposals.body.proposal_maker.body.options.capacity.capacity.slider.slider_value < global_memory.minimumCapacitySliderValue) - - flow.proposals.body.proposal_maker.body.propose_crew.visible = (flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible == false) - -- flow.proposals.body.proposal_maker.body.propose_crew.visible = (flow.proposals.body.proposal_maker.body.proposal_cant_do_infinity_mode.visible == false) and (flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible == false) - flow.proposals.body.flow_proposal_launch.launch_crew.visible = playercrew_status.proposal_can_launch - local checkbox_state = flow.proposals.body.proposal_maker.body.private_checkbox.state - flow.proposals.body.proposal_maker.body.password_label.visible = checkbox_state - flow.proposals.body.proposal_maker.body.password_namefield.visible = checkbox_state - flow.proposals.body.proposal_maker.body.confirm_password_label.visible = checkbox_state - flow.proposals.body.proposal_maker.body.confirm_password_namefield.visible = checkbox_state + local checkbox_state = flow.proposals.body.proposal_maker.body.settings.private_checkbox.state + flow.proposals.body.proposal_maker.body.settings.password_label.visible = checkbox_state + flow.proposals.body.proposal_maker.body.settings.password.visible = checkbox_state + flow.proposals.body.proposal_maker.body.settings.confirm_password_label.visible = checkbox_state + flow.proposals.body.proposal_maker.body.settings.confirm_password.visible = checkbox_state end @@ -577,7 +565,6 @@ function Public.full_update(player) extraCrewText = ' (protected)' end wrappedmemories[#wrappedmemories + 1] = { 'pirates.run_displayform', mem.id, { '', mem.name .. extraCrewText .. ', ', CoreData.difficulty_options[mem.difficulty_option].text, ', [item=light-armor]' .. count .. CoreData.capacity_options[mem.capacity_option].text2 .. ', [item=rail] ' .. (mem.overworldx or 0) } } - -- wrappedmemories[#wrappedmemories + 1] = {'pirates.run_displayform', mem.id, mem.name, Utils.spritepath_to_richtext(CoreData.difficulty_options[mem.difficulty_option].icon), count, CoreData.capacity_options[mem.capacity_option].text2, ' [item=rail] ', mem.overworldx or 0} end GuiCommon.update_listbox(flow.ongoing_runs.body.ongoing_runs_listbox, wrappedmemories) @@ -610,37 +597,20 @@ function Public.full_update(player) local wrappedproposals = {} for _, proposal in pairs(global_memory.crewproposals) do wrappedproposals[#wrappedproposals + 1] = { 'pirates.proposal_displayform', proposal.name, Utils.spritepath_to_richtext(CoreData.capacity_options[proposal.capacity_option].icon) } - -- wrappedproposals[#wrappedproposals + 1] = {'pirates.proposal_displayform', proposal.name, Utils.spritepath_to_richtext(CoreData.difficulty_options[proposal.difficulty_option].icon), Utils.spritepath_to_richtext(CoreData.capacity_options[proposal.capacity_option].icon)} end GuiCommon.update_listbox(flow.proposals.body.proposals_listbox, wrappedproposals) end -- update proposal maker if flow.proposals.body.proposal_maker.visible then - local capacity_slider_value = flow.proposals.body.proposal_maker.body.options.capacity.capacity.slider.slider_value + local capacity_slider_value = flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.slider.slider_value for i, opt in pairs(CoreData.capacity_options) do if capacity_slider_value == i then - flow.proposals.body.proposal_maker.body.options.capacity.capacity.readoff_text.caption = opt.text - flow.proposals.body.proposal_maker.body.options.capacity_readoff_icon.sprite = opt.icon + flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.readoff_text.caption = opt.text + flow.proposals.body.proposal_maker.body.capacity_options.capacity_readoff_icon.sprite = opt.icon end end - if flow.proposals.body.proposal_maker.body.options.capacity.capacity.readoff_text.caption == '∞' then flow.proposals.body.proposal_maker.body.options.capacity.capacity.readoff_text.caption = { 'pirates.gui_runs_proposal_maker_no_limit' } end - - -- local difficulty_slider_value = flow.proposals.body.proposal_maker.body.options.difficulty.difficulty.slider.slider_value - -- for i, opt in pairs(CoreData.difficulty_options) do - -- if difficulty_slider_value == i then - -- flow.proposals.body.proposal_maker.body.options.difficulty.difficulty.readoff_text.caption = opt.text - -- flow.proposals.body.proposal_maker.body.options.difficulty_readoff_icon.sprite = opt.icon - -- end - -- end - - -- local mode_switch_state = flow.proposals.body.proposal_maker.body.options.mode.mode.switch.switch_state - -- for i, opt in pairs(CoreData.mode_options) do - -- if mode_switch_state == i then - -- flow.proposals.body.proposal_maker.body.options.mode.mode.readoff_text.caption = opt.text - -- flow.proposals.body.proposal_maker.body.options.mode_readoff_icon.sprite = opt.icon - -- end - -- end + if flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.readoff_text.caption == '∞' then flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.readoff_text.caption = { 'pirates.gui_runs_proposal_maker_no_limit' } end end end @@ -688,10 +658,10 @@ function Public.click(event) -- If run is private if memory.run_is_private then - if memory.private_run_password == flow.ongoing_runs.body.password_namefield.text then + if memory.private_run_password == flow.ongoing_runs.body.password.text then Crew.join_crew(player) flow.ongoing_runs.body.join_private_crew_info.visible = false - flow.ongoing_runs.body.password_namefield.visible = false + flow.ongoing_runs.body.password.visible = false if memory.run_is_protected and (not Roles.captain_exists()) then Common.notify_player_expected(player, { 'pirates.player_joins_protected_run_with_no_captain' }) @@ -735,8 +705,9 @@ function Public.click(event) end end - local run_is_protected = flow.proposals.body.proposal_maker.body.protected_checkbox.state - local run_is_private = flow.proposals.body.proposal_maker.body.private_checkbox.state + local run_has_blueprints_disabled = flow.proposals.body.proposal_maker.body.settings.blueprints_disabled_checkbox.state + local run_is_protected = flow.proposals.body.proposal_maker.body.settings.protected_checkbox.state + local run_is_private = flow.proposals.body.proposal_maker.body.settings.private_checkbox.state if run_is_private then -- Make sure private run can be created if private_run_count >= global_memory.private_run_cap then @@ -753,13 +724,13 @@ function Public.click(event) end -- Check if passwords match - if flow.proposals.body.proposal_maker.body.password_namefield.text ~= flow.proposals.body.proposal_maker.body.confirm_password_namefield.text then + if flow.proposals.body.proposal_maker.body.settings.password.text ~= flow.proposals.body.proposal_maker.body.settings.confirm_password.text then Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_private_run_password_no_match' }) return end -- Check if passwords aren't empty - if flow.proposals.body.proposal_maker.body.password_namefield.text == '' then + if flow.proposals.body.proposal_maker.body.settings.password.text == '' then Common.notify_player_error(player, { 'pirates.gui_runs_proposal_maker_error_private_run_password_empty' }) return end @@ -791,14 +762,11 @@ function Public.click(event) return end - local private_run_password = flow.proposals.body.proposal_maker.body.password_namefield.text + local private_run_password = flow.proposals.body.proposal_maker.body.settings.password.text local proposal_name = flow.proposals.body.proposal_maker.body.namefield.text - -- local proposal_name = string.sub(flow.proposals.body.proposal_maker.body.namefield.text, 1, 30) - local capacity_option = flow.proposals.body.proposal_maker.body.options.capacity.capacity.slider.slider_value + local capacity_option = flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.slider.slider_value local difficulty_option = 1 - -- local difficulty_option = flow.proposals.body.proposal_maker.body.options.difficulty.difficulty.slider.slider_value - -- local mode_option = flow.proposals.body.proposal_maker.body.options.mode.mode.switch.switch_state if (not proposal_name) or (proposal_name == '') then proposal_name = 'NoName' end @@ -841,6 +809,7 @@ function Public.click(event) created_by_player = player.index, run_is_protected = run_is_protected, run_is_private = run_is_private, + run_has_blueprints_disabled = run_has_blueprints_disabled, private_run_password = private_run_password, } diff --git a/maps/pirates/main.lua b/maps/pirates/main.lua index d67ccb1b..51fcfecd 100644 --- a/maps/pirates/main.lua +++ b/maps/pirates/main.lua @@ -112,8 +112,6 @@ local function on_init() global_memory.protected_but_not_private_run_cap = Common.protected_but_not_private_run_cap global_memory.private_run_cap = Common.private_run_cap - global_memory.minimumCapacitySliderValue = Common.minimumCapacitySliderValue - Surfaces.Lobby.create_starting_dock_surface() local lobby = game.surfaces[CoreData.lobby_surface_name] game.forces.player.set_spawn_position(Common.lobby_spawnpoint, lobby) diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index b732393a..d1a13eb2 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -605,6 +605,11 @@ function Public.try_create_permissions_groups() if not game.permissions.get_group('lobby') then local group = game.permissions.create_group('lobby') set_restricted_permissions(group) + + group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) + group.set_allows_action(defines.input_action.grab_blueprint_record, false) + group.set_allows_action(defines.input_action.import_blueprint_string, false) + group.set_allows_action(defines.input_action.import_blueprint, false) end if not game.permissions.get_group('crowsnest') then @@ -664,13 +669,39 @@ function Public.try_create_permissions_groups() group.set_allows_action(defines.input_action.set_trains_limit, false) group.set_allows_action(defines.input_action.set_train_stopped, false) end + + local blueprint_disabled_groups = { + 'crowsnest_bps_disabled', + 'crowsnest_privileged_bps_disabled', + 'cabin_bps_disabled', + 'cabin_privileged_bps_disabled', + 'plebs_bps_disabled', + 'not_trusted_bps_disabled' + } + + for _, group_name in ipairs(blueprint_disabled_groups) do + if not game.permissions.get_group(group_name) then + local group = game.permissions.create_group(group_name) + local base_group_name = group_name:gsub('_bps_disabled', '') + local base_group = game.permissions.get_group(base_group_name) + + for _, action in pairs(defines.input_action) do + group.set_allows_action(action, base_group.allows_action(action)) + end + + group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) + group.set_allows_action(defines.input_action.grab_blueprint_record, false) + group.set_allows_action(defines.input_action.import_blueprint_string, false) + group.set_allows_action(defines.input_action.import_blueprint, false) + end + end end function Public.add_player_to_permission_group(player, group_override) + Public.try_create_permissions_groups() + -- local jailed = Jailed.get_jailed_table() -- local enable_permission_group_disconnect = WPT.get('disconnect_wagon') - local session = Session.get_session_table() - local AG = Antigrief.get() local gulag = game.permissions.get_group('gulag') local tbl = gulag and gulag.players @@ -684,29 +715,11 @@ function Public.add_player_to_permission_group(player, group_override) -- return -- end - local playtime = player.online_time - if session and session[player.name] then - playtime = player.online_time + session[player.name] - end - -- if jailed[player.name] then -- return -- end - Public.try_create_permissions_groups() - - local group - if group_override then - group = game.permissions.get_group(group_override) - else - if AG.enabled and not player.admin and playtime < 5184000 then -- 24 hours - group = game.permissions.get_group('not_trusted') - else - group = game.permissions.get_group('plebs') - end - end - - -- if _DEBUG then return end + local group = game.permissions.get_group(group_override) group.add_player(player) end @@ -718,22 +731,37 @@ function Public.update_privileges(player) return end + local memory = Memory.get_crew_memory() + local bps_disabled_suffix = memory.run_has_blueprints_disabled and '_bps_disabled' or '' + if string.sub(player.surface.name, 9, 17) == 'Crowsnest' then if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then - return Public.add_player_to_permission_group(player, 'crowsnest_privileged') + return Public.add_player_to_permission_group(player, 'crowsnest_privileged' .. bps_disabled_suffix) else - return Public.add_player_to_permission_group(player, 'crowsnest') + return Public.add_player_to_permission_group(player, 'crowsnest' .. bps_disabled_suffix) end elseif string.sub(player.surface.name, 9, 13) == 'Cabin' then if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then - return Public.add_player_to_permission_group(player, 'cabin_privileged') + return Public.add_player_to_permission_group(player, 'cabin_privileged' .. bps_disabled_suffix) else - return Public.add_player_to_permission_group(player, 'cabin') + return Public.add_player_to_permission_group(player, 'cabin' .. bps_disabled_suffix) end elseif player.surface.name == CoreData.lobby_surface_name then return Public.add_player_to_permission_group(player, 'lobby') else - return Public.add_player_to_permission_group(player) + local session = Session.get_session_table() + local AG = Antigrief.get() + + local playtime = player.online_time + if session and session[player.name] then + playtime = player.online_time + session[player.name] + end + + if AG and AG.enabled and not player.admin and playtime < 5184000 then -- 24 hours + Public.add_player_to_permission_group(player, 'not_trusted' .. bps_disabled_suffix) + else + Public.add_player_to_permission_group(player, 'plebs' .. bps_disabled_suffix) + end end end From 5df3144ce5e2c0c22e20ec8085fdc36e4a456017 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 19:51:36 +0100 Subject: [PATCH 27/50] adjust game slowness scale --- maps/pirates/balance.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index 10b543ac..01e409bc 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -171,7 +171,7 @@ function Public.game_slowness_scale() -- return 1 / (Public.crew_scale()^(50/100) / Math.sloped(Common.difficulty_scale(), 1/4)) --changed crew_scale factor significantly to help smaller crews -- local scale = 0.3 + Math.sloped(Common.difficulty_scale(), -0.15) / (Public.crew_scale()^(1/8)) - local scale = 2.6 * Math.sloped(Common.difficulty_scale(), -0.2) - Public.crew_scale() ^ (1 / 4) + local scale = 2.6 * Math.sloped(Common.difficulty_scale(), -0.2) - Public.crew_scale() ^ (1 / 2) return Math.max(1, scale) end @@ -187,7 +187,7 @@ end -- Waiting at sea forever isn't generally fun for your teammates, so we encourage keeping the action moving: function Public.seconds_until_machines_shut_down_at_sea() - local minimum_mins = 3 + local minimum_mins = 7 return Math.ceil(60 * minimum_mins * Public.game_slowness_scale()) end From c224527c5b7a7a88a59ec3036dbd061ab7dd079c Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 19:53:59 +0100 Subject: [PATCH 28/50] changelog --- locale/en/pirates.cfg | 7 +++- maps/pirates/coredata.lua | 2 +- maps/pirates/gui/info.lua | 83 ++++++++++++++++++--------------------- 3 files changed, 45 insertions(+), 47 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 1b05b331..ac1e693a 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -15,8 +15,11 @@ softmod_info_new_players_2=Mine coal and other resources and bring them to the s softmod_info_tips_1=Features of the game that are hard to work out alone softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password -softmod_info_updates_1=v1.6.0 -softmod_info_updates_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Productivity modules are removed from the game until a later feature is released.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market +softmod_info_1_1=v1.6.3 highlights +softmod_info_1_2=• Gameplay further slowed down for small crews.\n• Optional setting for new crews to disable blueprints.\n• Fixed a bug causing large waves.\n• Grace period of 2 minutes on each island before attacks. + +softmod_info_2_1=v1.6.0 highlights +softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Productivity modules are removed from the game until a later feature is released.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market softmod_info_credits_1=Credits softmod_info_credits_2=Designed/developed by thesixthroc. Updates from Piratux. Comfy codebase and help from Gerkiz, Hanakocz and Mew @ Comfy Industries (https://getcomfy.eu). Island structure blueprints contributed by Mattisso.\n\nCome chat with us: https://getcomfy.eu/discord\n\n"Those white gloves. I'll never forget them 'till the day I die." - Dr. John diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 5619c151..8bc60b13 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -7,7 +7,7 @@ local _inspect = require 'utils.inspect'.inspect local Public = {} Public.scenario_id_name = 'pirates' -Public.version_string = '1.6.2' --major.minor.patch versioning, to match factorio mod portal +Public.version_string = '1.6.3' --major.minor.patch versioning, to match factorio mod portal -- Public.blueprint_library_allowed = true -- Public.blueprint_importing_allowed = true diff --git a/maps/pirates/gui/info.lua b/maps/pirates/gui/info.lua index 7192ac4b..a74a012d 100644 --- a/maps/pirates/gui/info.lua +++ b/maps/pirates/gui/info.lua @@ -25,24 +25,27 @@ local width = 400 function Public.toggle_window(player) local flow, flow2, flow3, flow4 - if player.gui.screen[window_name .. '_piratewindow'] then player.gui.screen[window_name .. '_piratewindow'].destroy() return end + if player.gui.screen[window_name .. '_piratewindow'] then + player.gui.screen[window_name .. '_piratewindow'].destroy() + return + end - flow = player.gui.screen.add{ - type = 'tabbed-pane', - name = window_name .. '_piratewindow', - direction = 'vertical' - } - flow.location = {x = 90, y = 90} + flow = player.gui.screen.add { + type = 'tabbed-pane', + name = window_name .. '_piratewindow', + direction = 'vertical' + } + flow.location = { x = 90, y = 90 } flow.selected_tab_index = 1 flow.style = 'frame_tabbed_pane' flow.style.width = width flow.style.height = 420 - flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_info'}) + flow2 = Public.flow_add_info_tab(flow, { 'pirates.gui_info_info' }) flow3 = flow2.parent.last_info_flow_1.last_info_flow_2 - flow4 = flow3.add{type = "label", caption = {"pirates.softmod_info_body_1"}} + flow4 = flow3.add { type = "label", caption = { "pirates.softmod_info_body_1" } } flow4.style.font_color = GuiCommon.friendly_font_color flow4.style.single_line = false flow4.style.font = 'debug' @@ -50,36 +53,35 @@ function Public.toggle_window(player) flow4.style.bottom_margin = 0 -- flow4.style.bottom_margin = 16 - Public.flow_add_info_sections(flow2, {'game_description'}) + Public.flow_add_info_sections(flow2, { 'game_description' }) - flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_tips'}) + flow2 = Public.flow_add_info_tab(flow, { 'pirates.gui_info_tips' }) - Public.flow_add_info_sections(flow2, {'new_players', 'tips'}) + Public.flow_add_info_sections(flow2, { 'new_players', 'tips' }) - flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_updates'}) + flow2 = Public.flow_add_info_tab(flow, { 'pirates.gui_info_updates' }) - Public.flow_add_info_sections(flow2, {'updates'}) + Public.flow_add_info_sections(flow2, { '1', '2' }) -- Public.flow_add_info_sections(flow2, {'updates', 'bugs'}) - flow2 = Public.flow_add_info_tab(flow, {'pirates.gui_info_credits'}) + flow2 = Public.flow_add_info_tab(flow, { 'pirates.gui_info_credits' }) - Public.flow_add_info_sections(flow2, {'credits'}) + Public.flow_add_info_sections(flow2, { 'credits' }) end - function Public.flow_add_info_sections(flow, sections_list) local flow2 for j = 1, #sections_list do local i = sections_list[j] - flow2 = flow.add{type = "label", caption = {"pirates.softmod_info_" .. i .. "_1"}} + flow2 = flow.add { type = "label", caption = { "pirates.softmod_info_" .. i .. "_1" } } flow2.style.font_color = GuiCommon.friendly_font_color flow2.style.single_line = false flow2.style.font = 'heading-3' flow2.style.bottom_margin = -4 - flow2 = flow.add{type = "label", caption = {"pirates.softmod_info_" .. i .. "_2"}} + flow2 = flow.add { type = "label", caption = { "pirates.softmod_info_" .. i .. "_2" } } flow2.style.font_color = GuiCommon.friendly_font_color flow2.style.single_line = false flow2.style.font = 'default' @@ -88,12 +90,10 @@ function Public.flow_add_info_sections(flow, sections_list) end end - function Public.flow_add_info_tab(flow, tab_name) - local tab, contents, ret, flow3, flow4, flow5 - tab = flow.add{type='tab', caption=tab_name} + tab = flow.add { type = 'tab', caption = tab_name } tab.style = 'frame_tab' contents = flow.add({ @@ -114,7 +114,7 @@ function Public.flow_add_info_tab(flow, tab_name) direction = 'horizontal', }) flow3.style.horizontally_stretchable = true - flow3.style.horizontal_align = 'center' + flow3.style.horizontal_align = 'center' flow4 = flow3.add({ type = 'flow', @@ -122,14 +122,14 @@ function Public.flow_add_info_tab(flow, tab_name) direction = 'vertical', }) flow4.style.horizontally_stretchable = true - flow4.style.horizontal_align = 'center' + flow4.style.horizontal_align = 'center' - flow5 = flow4.add{type = "label", caption = {"", {"pirates.softmod_info_header_before_version_number"}, CoreData.version_string, {"pirates.softmod_info_header_after_version_number"}}} + flow5 = flow4.add { type = "label", caption = { "", { "pirates.softmod_info_header_before_version_number" }, CoreData.version_string, { "pirates.softmod_info_header_after_version_number" } } } flow5.style.font_color = GuiCommon.friendly_font_color flow5.style.font = 'heading-1' flow5.style.bottom_margin = 2 - flow5 = flow4.add{type = "label", caption = {"pirates.softmod_info_body_promote"}} + flow5 = flow4.add { type = "label", caption = { "pirates.softmod_info_body_promote" } } flow5.style.font_color = GuiCommon.friendly_font_color flow5.style.single_line = false flow5.style.font = 'default-small' @@ -149,7 +149,7 @@ function Public.flow_add_info_tab(flow, tab_name) direction = 'horizontal', }) flow3.style.horizontally_stretchable = true - flow3.style.horizontal_align = 'center' + flow3.style.horizontal_align = 'center' flow4 = flow3.add({ type = 'flow', @@ -157,7 +157,7 @@ function Public.flow_add_info_tab(flow, tab_name) direction = 'vertical', }) flow4.style.horizontally_stretchable = true - flow4.style.horizontal_align = 'center' + flow4.style.horizontal_align = 'center' flow3 = contents.add({ type = 'flow', @@ -171,10 +171,10 @@ function Public.flow_add_info_tab(flow, tab_name) direction = 'horizontal', }) flow3.style.horizontally_stretchable = true - flow3.style.horizontal_align = 'center' + flow3.style.horizontal_align = 'center' - flow4 = flow3.add{type = "label", caption = {"pirates.softmod_info_body_clicky"}} - flow4.style.font = 'default-small' + flow4 = flow3.add { type = "label", caption = { "pirates.softmod_info_body_clicky" } } + flow4.style.font = 'default-small' flow4.style.font_color = GuiCommon.friendly_font_color flow4.style.single_line = false flow4.style.bottom_margin = 4 @@ -185,7 +185,6 @@ function Public.flow_add_info_tab(flow, tab_name) return ret end - function Public.click(event) if not event.element then return end if not event.element.valid then return end @@ -201,19 +200,17 @@ function Public.click(event) -- local memory = Memory.get_crew_memory() if eventtype ~= 'tab' and ( - element.name == (window_name .. '_piratewindow') or - (element.parent and element.parent.name == (window_name .. '_piratewindow')) or - (element.parent and element.parent.parent and element.parent.parent.name == (window_name .. '_piratewindow')) or - (element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.name == (window_name .. '_piratewindow')) or - (element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.parent and element.parent.parent.parent.parent.name == (window_name .. '_piratewindow')) or - (element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.parent and element.parent.parent.parent.parent.parent and element.parent.parent.parent.parent.parent.name == (window_name .. '_piratewindow')) - ) then + element.name == (window_name .. '_piratewindow') or + (element.parent and element.parent.name == (window_name .. '_piratewindow')) or + (element.parent and element.parent.parent and element.parent.parent.name == (window_name .. '_piratewindow')) or + (element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.name == (window_name .. '_piratewindow')) or + (element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.parent and element.parent.parent.parent.parent.name == (window_name .. '_piratewindow')) or + (element.parent and element.parent.parent and element.parent.parent.parent and element.parent.parent.parent.parent and element.parent.parent.parent.parent.parent and element.parent.parent.parent.parent.parent.name == (window_name .. '_piratewindow')) + ) then Public.toggle_window(player) end end - - -- function Public.regular_update(player) -- end @@ -238,6 +235,4 @@ function Public.full_update(player) end end - - -return Public \ No newline at end of file +return Public From 1b9d9067dd5628acd3537fb810530e8936261a20 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 20:19:44 +0100 Subject: [PATCH 29/50] display run conditions better --- locale/en/pirates.cfg | 7 ++++--- maps/pirates/coredata.lua | 43 ++++++++++++++++++++++++++------------- maps/pirates/gui/crew.lua | 2 +- maps/pirates/gui/runs.lua | 30 ++++++++++++++++++--------- 4 files changed, 54 insertions(+), 28 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index ac1e693a..3de6134a 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -404,8 +404,9 @@ highscore_heading_difficulty=Difficulty highscore_heading_peak_players=PeakPlayers -proposal_displayform=__1__ — __2__ -run_displayform= __2__ +run_condition_private=, private +run_condition_captain_protected=, cap'n-protected +run_condition_blueprints_disabled=, BPs disabled crewmember_displayform=[color=__2__,__3__,__4__]__5__[/color] [color=1,1,1]__6__[/color] capacity_tooltip=Capacity. Sets the maximum number of crewmembers allowed. difficulty_tooltip=Difficulty.\n\nHigher difficulties have higher pollution and evo, higher biter damage, lower gold loot, but higher chest loot, along with small effects on the time per island, quest requirements, and silo position.\n\nDifficulty also determines the material the ship is made out of. @@ -533,7 +534,7 @@ gui_runs_proposal_maker_capacity=Capacity gui_runs_proposal_maker_propose=Propose gui_runs_proposal_maker_no_limit=No limit gui_runs_proposal_maker_blueprints_disabled=Blueprints disabled -gui_runs_proposal_maker_protected=Captain-Protected +gui_runs_proposal_maker_protected=Captain-protected gui_runs_proposal_maker_protected_tooltip=Captain-protected crew. If the captain leaves or becomes afk, and there are no officers, the captain role stays vacant.\nIf the crew is empty or inactive for __1__ hours, it becomes unprotected. gui_runs_proposal_maker_private=Private gui_runs_proposal_maker_private_tooltip=Private crew. Once the crew has launched, players must enter the password in order to join.\nIf the crew is empty or inactive for __1__ hours, the password is removed. diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 8bc60b13..063a917f 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -109,26 +109,41 @@ Public.comfy_emojis = { } Public.capacity_options = { - { value = 2, icon = 'virtual-signal/signal-2', text = '2', text2 = '/2', text3 = '2' }, - { value = 4, icon = 'virtual-signal/signal-4', text = '4', text2 = '/4', text3 = '4' }, - { value = 8, icon = 'virtual-signal/signal-8', text = '8', text2 = '/8', text3 = '8' }, - { value = 24, icon = 'virtual-signal/signal-blue', text = '24', text2 = '/24', text3 = '24' }, - { value = 999, icon = 'virtual-signal/signal-white', text = 'Inf.', text2 = '', text3 = 'Inf' }, + { value = 2, icon = 'virtual-signal/signal-2', text = '2', text2 = '/2', text3 = '2' }, + { value = 4, icon = 'virtual-signal/signal-4', text = '4', text2 = '/4', text3 = '4' }, + { value = 8, icon = 'virtual-signal/signal-8', text = '8', text2 = '/8', text3 = '8' }, + { value = 24, icon = 'virtual-signal/signal-blue', text = '24', text2 = '/24', text3 = '24' }, + { value = 999, icon = 'virtual-signal/signal-white', text = 'Inf.', text2 = '/inf', text3 = 'Inf' }, -- {value = 64, icon = 'item/storage-tank', text = '64'}, } -- Prefer not to change difficulty values if possible, since even tiny value change can have big effect on some formulas that rely on it. Public.difficulty_options = { - -- The difficulty values we currently offer - --For the value of Easy difficulty, we are pulled in two directions: We wish to make the game comfy to play for those who haven't played it, but we also wish to represent the game mechanics faithfully so that Normal is not a crazy distance away. - { value = 0.5, icon = 'item/firearm-magazine', text = { 'pirates.difficulty_easy' }, associated_color = { r = 50, g = 255, b = 50 } }, - - { value = 1.0, icon = 'item/piercing-rounds-magazine', text = { 'pirates.difficulty_normal' }, associated_color = { r = 255, g = 255, b = 50 } }, - - { value = 1.5, icon = 'item/uranium-rounds-magazine', text = { 'pirates.difficutly_hard' }, associated_color = { r = 255, g = 50, b = 50 } }, - - { value = 2, icon = 'item/atomic-bomb', text = { 'pirates.difficulty_nightmare' }, associated_color = { r = 170, g = 60, b = 60 } }, + { + value = 0.5, + icon = 'firearm-magazine', + text = { 'pirates.difficulty_easy' }, + associated_color = { r = 50, g = 255, b = 50 } + }, + { + value = 1.0, + icon = 'piercing-rounds-magazine', + text = { 'pirates.difficulty_normal' }, + associated_color = { r = 255, g = 255, b = 50 } + }, + { + value = 1.5, + icon = 'uranium-rounds-magazine', + text = { 'pirates.difficutly_hard' }, + associated_color = { r = 255, g = 50, b = 50 } + }, + { + value = 2, + icon = 'atomic-bomb', + text = { 'pirates.difficulty_nightmare' }, + associated_color = { r = 170, g = 60, b = 60 } + }, } function Public.get_difficulty_option_from_value(difficulty_value) diff --git a/maps/pirates/gui/crew.lua b/maps/pirates/gui/crew.lua index 4308237f..39ff08aa 100644 --- a/maps/pirates/gui/crew.lua +++ b/maps/pirates/gui/crew.lua @@ -226,7 +226,7 @@ function Public.toggle_window(player) { name = 'difficulty_option_' .. i, type = 'button', - caption = o.text + caption = { "", "[item=", o.icon, "] ", o.text } } ) flow3.style.minimal_width = 95 diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index 13b0f8dd..46faab4f 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -418,6 +418,8 @@ function Public.toggle_window(player) -- flow_add_proposal_slider(flow5, 'difficulty', 'Difficulty', #CoreData.difficulty_options, 2, {'pirates.difficulty_tooltip'}) -- flow_add_proposal_switch(flow5, 'mode', 'Mode', 'left', {'pirates.mode_tooltip'}) + flow5.visible = false --maybe will bring this back for the speedrun ship? + flow5 = flow4.add({ name = 'propose_crew', type = 'button', @@ -556,15 +558,16 @@ function Public.full_update(player) count = #mem.crewplayerindices end - local extraCrewText = '' - if mem.run_is_protected and mem.run_is_private then - extraCrewText = ' (private & protected)' - elseif mem.run_is_private then - extraCrewText = ' (private)' - elseif mem.run_is_protected then - extraCrewText = ' (protected)' - end - wrappedmemories[#wrappedmemories + 1] = { 'pirates.run_displayform', mem.id, { '', mem.name .. extraCrewText .. ', ', CoreData.difficulty_options[mem.difficulty_option].text, ', [item=light-armor]' .. count .. CoreData.capacity_options[mem.capacity_option].text2 .. ', [item=rail] ' .. (mem.overworldx or 0) } } + wrappedmemories[#wrappedmemories + 1] = { '', + mem.name .. " (" .. count .. (count == 1 and ' player' or ' players') .. ") — ", + '[item=', CoreData.difficulty_options[mem.difficulty_option].icon, '], ', + -- Utils.spritepath_to_richtext(CoreData.capacity_options[mem.capacity_option].icon) .. ", ", + '[item=rail]', + mem.overworldx or 0, + mem.run_is_private and { 'pirates.run_condition_private' } or '', + mem.run_is_protected and { 'pirates.run_condition_captain_protected' } or '', + mem.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '' + } end GuiCommon.update_listbox(flow.ongoing_runs.body.ongoing_runs_listbox, wrappedmemories) @@ -596,7 +599,14 @@ function Public.full_update(player) if flow.proposals.visible then local wrappedproposals = {} for _, proposal in pairs(global_memory.crewproposals) do - wrappedproposals[#wrappedproposals + 1] = { 'pirates.proposal_displayform', proposal.name, Utils.spritepath_to_richtext(CoreData.capacity_options[proposal.capacity_option].icon) } + wrappedproposals[#wrappedproposals + 1] = { '', + proposal.name .. ' — ', + '[item=rail]', + 0, + proposal.run_is_private and { 'pirates.run_condition_private' } or '', + proposal.run_is_protected and { 'pirates.run_condition_captain_protected' } or '', + proposal.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '' + } end GuiCommon.update_listbox(flow.proposals.body.proposals_listbox, wrappedproposals) end From 43d981d5bdf19bed37ef6c06e099c5724056a649 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 21:12:26 +0100 Subject: [PATCH 30/50] remove old captain's shop code --- maps/pirates/api_on_tick.lua | 2 - maps/pirates/commands.lua | 2 +- maps/pirates/custom_events.lua | 1 - maps/pirates/gui/common.lua | 88 ------ maps/pirates/gui/fuel.lua | 194 ------------ maps/pirates/gui/gui.lua | 289 ++++++++---------- maps/pirates/gui/minimap.lua | 107 +++---- maps/pirates/main.lua | 2 +- maps/pirates/overworld.lua | 16 +- maps/pirates/progression.lua | 10 +- maps/pirates/{ => shop}/boat_upgrades.lua | 79 ++++- maps/pirates/shop/captains.lua | 347 ---------------------- maps/pirates/shop/covered.lua | 18 +- maps/pirates/shop/dock.lua | 100 +++---- maps/pirates/shop/shop.lua | 5 +- maps/pirates/surfaces/dock.lua | 2 - 16 files changed, 321 insertions(+), 941 deletions(-) delete mode 100644 maps/pirates/gui/fuel.lua rename maps/pirates/{ => shop}/boat_upgrades.lua (63%) delete mode 100644 maps/pirates/shop/captains.lua diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index da87f38e..648824ab 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -1155,8 +1155,6 @@ function Public.loading_update(tickinterval) local force = memory.force if not (force and force.valid) then return end - - script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {}) else PiratesApiEvents.load_some_map_chunks_random_order(surface, currentdestination, fraction) --random order is good for maze world if currentdestination.subtype == IslandEnum.enum.CAVE then diff --git a/maps/pirates/commands.lua b/maps/pirates/commands.lua index 38c0a1b6..e32b3ae4 100644 --- a/maps/pirates/commands.lua +++ b/maps/pirates/commands.lua @@ -21,7 +21,7 @@ local Islands = require 'maps.pirates.surfaces.islands.islands' local Progression = require 'maps.pirates.progression' local Crowsnest = require 'maps.pirates.surfaces.crowsnest' local PiratesApiEvents = require 'maps.pirates.api_events' -local Upgrades = require 'maps.pirates.boat_upgrades' +local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Effects = require 'maps.pirates.effects' local Kraken = require 'maps.pirates.surfaces.sea.kraken' local _inspect = require 'utils.inspect'.inspect diff --git a/maps/pirates/custom_events.lua b/maps/pirates/custom_events.lua index cbe28a2f..7e09c4d3 100644 --- a/maps/pirates/custom_events.lua +++ b/maps/pirates/custom_events.lua @@ -9,7 +9,6 @@ local Public = {} local enum = { update_crew_progress_gui = Event.generate_event_name('update_crew_progress_gui'), - update_crew_fuel_gui = Event.generate_event_name('update_crew_fuel_gui'), } Public.enum = enum diff --git a/maps/pirates/gui/common.lua b/maps/pirates/gui/common.lua index 829485a0..f64fb43b 100644 --- a/maps/pirates/gui/common.lua +++ b/maps/pirates/gui/common.lua @@ -156,94 +156,6 @@ function Public.flow_add_floating_button(flow1, button_name) return flow3 end -function Public.flow_add_shop_item(flow, name) - local flow2, flow3 - - local shop_data_1 = Shop.Captains.main_shop_data_1 - local shop_data_2 = Shop.Captains.main_shop_data_2 - local trade_data = shop_data_1[name] or shop_data_2[name] - if not trade_data then return end - - flow2 = flow.add({ - name = name, - type = 'flow', - direction = 'horizontal', - }) - flow2.style.top_margin = 3 - flow2.style.horizontal_align = 'center' - flow2.style.vertical_align = 'center' - flow2.tooltip = trade_data.tooltip - - - for k, v in pairs(trade_data.what_you_get_sprite_buttons) do - flow3 = flow2.add({ - type = 'sprite-button', - name = k, - sprite = k, - enabled = false, - }) - flow3.style.minimal_height = 40 - flow3.style.maximal_height = 40 - if v == false then - flow3.number = nil - else - flow3.number = v - end - flow3.tooltip = trade_data.tooltip - end - - flow3 = flow2.add({ - type = 'label', - name = 'for', - caption = 'for' - }) - flow3.style.font = 'default-large' - flow3.style.font_color = Public.default_font_color - flow3.tooltip = trade_data.tooltip - - for k, _ in pairs(trade_data.base_cost) do - flow3 = flow2.add({ - name = 'cost_' .. k, - type = 'sprite-button', - enabled = false, - }) - flow3.style.minimal_height = 40 - flow3.style.maximal_height = 40 - flow3.tooltip = trade_data.tooltip - if k == 'fuel' then - flow3.sprite = 'item/coal' - elseif k == 'coins' then - flow3.sprite = 'item/coin' - elseif k == 'iron_plates' then - flow3.sprite = 'item/iron-plate' - elseif k == 'copper_plates' then - flow3.sprite = 'item/copper-plate' - end - end - - - flow3 = flow2.add({ - name = 'spacing', - type = 'flow', - direction = 'horizontal', - }) - flow3.style.horizontally_stretchable = true - - flow3 = flow2.add({ - type = 'sprite-button', - name = 'buy_button', - caption = 'Buy' - }) - flow3.style.font = 'default-large' - flow3.style.font_color = Public.default_font_color - flow3.style.height = 32 - flow3.style.width = 50 - flow3.style.padding = 0 - flow3.style.margin = 0 - - return flow2 -end - function Public.flow_add_section(flow, name, caption) local flow2, flow3 diff --git a/maps/pirates/gui/fuel.lua b/maps/pirates/gui/fuel.lua deleted file mode 100644 index 94c494e3..00000000 --- a/maps/pirates/gui/fuel.lua +++ /dev/null @@ -1,194 +0,0 @@ --- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates. - - -local Memory = require 'maps.pirates.memory' --- local Common = require 'maps.pirates.common' --- local CoreData = require 'maps.pirates.coredata' -local Utils = require 'maps.pirates.utils_local' --- local Math = require 'maps.pirates.math' -local Balance = require 'maps.pirates.balance' --- local Surfaces = require 'maps.pirates.surfaces.surfaces' -local Roles = require 'maps.pirates.roles.roles' -local Crew = require 'maps.pirates.crew' -local Shop = require 'maps.pirates.shop.shop' --- local Progression = require 'maps.pirates.progression' --- local Structures = require 'maps.pirates.structures.structures' -local _inspect = require 'utils.inspect'.inspect --- local Boats = require 'maps.pirates.structures.boats.boats' -local GuiCommon = require 'maps.pirates.gui.common' -local Public = {} - -local window_name = 'fuel' - -function Public.toggle_window(player) - local flow, flow2, flow3 - - local shop_data_1 = Shop.Captains.main_shop_data_1 - local shop_data_2 = Shop.Captains.main_shop_data_2 - - if player.gui.screen[window_name .. '_piratewindow'] then - player.gui.screen[window_name .. '_piratewindow'].destroy() - return - end - - flow = GuiCommon.new_window(player, window_name) - flow.caption = 'Captain\'s Store' - - - flow2 = flow.add({ - name = 'trades', - type = 'flow', - direction = 'vertical', - }) - flow2.style.top_margin = 3 - flow2.style.bottom_margin = 3 - flow2.style.horizontal_align = 'center' - flow2.style.vertical_align = 'center' - - for k, _ in pairs(shop_data_1) do - GuiCommon.flow_add_shop_item(flow2, k) - end - - flow3 = flow2.add({ - name = 'line_1', - type = 'line', - }) - flow3.style.width = 100 - - for k, _ in pairs(shop_data_2) do - GuiCommon.flow_add_shop_item(flow2, k) - end - - - flow2 = GuiCommon.flow_add_close_button(flow, window_name .. '_piratebutton') - - flow2.add({ - name = 'tospend', - type = 'sprite-button', - sprite = 'item/coin', - index = 1, - enabled = false, - }) -end - -function Public.regular_update(player) - local flow - - -- local memory = Memory.get_crew_memory() - - if not player.gui.screen[window_name .. '_piratewindow'] then return end - flow = player.gui.screen[window_name .. '_piratewindow'] - - if Roles.player_privilege_level(player) >= Roles.privilege_levels.OFFICER then - flow.close_button_flow.hflow.tospend.visible = true - - local inv = player.get_inventory(defines.inventory.character_main) - if inv and inv.valid then - local coin_amount = inv.get_item_count('coin') or 0 - - flow.close_button_flow.hflow.tospend.number = coin_amount - flow.close_button_flow.hflow.tospend.tooltip = string.format("You're holding " .. Utils.bignumber_abbrevform2(coin_amount) .. " doubloons.") - end - else - flow.close_button_flow.hflow.tospend.visible = false - end -end - -function Public.full_update(player) - if Public.regular_update then Public.regular_update(player) end - - local flow - - - local memory = Memory.get_crew_memory() - local shop_data = Utils.nonrepeating_join_dict(Shop.Captains.main_shop_data_1, Shop.Captains.main_shop_data_2) - local shop_data_1 = Shop.Captains.main_shop_data_1 - local shop_data_2 = Shop.Captains.main_shop_data_2 - - local availability_data = memory.mainshop_availability_bools - - if not player.gui.screen[window_name .. '_piratewindow'] then return end - flow = player.gui.screen[window_name .. '_piratewindow'] - - - --*** WHAT TO SHOW ***-- - - -- if memory.stored_fuel then - -- flow.close_button_flow.hflow.tospend.number = memory.stored_fuel - -- flow.close_button_flow.hflow.tospend.tooltip = string.format('The crew has %01d stored coal.', memory.stored_fuel) - -- else - -- flow.close_button_flow.hflow.tospend.number = 0 - -- flow.close_button_flow.hflow.tospend.tooltip = string.format('The crew has %01d stored coal.', 0) - -- end - - - - if memory.crewstatus == Crew.enum.ADVENTURING then - flow.trades.visible = true - else - flow.trades.visible = false - end - - local anything_in_shop_1 = false - for k, _ in pairs(shop_data_1) do - if availability_data and availability_data[k] == true then - flow.trades[k].visible = true - anything_in_shop_1 = true - if Roles.player_privilege_level(player) >= Roles.privilege_levels.OFFICER then - flow.trades[k].buy_button.visible = true - else - flow.trades[k].buy_button.visible = false - end - else - flow.trades[k].visible = false - end - end - flow.trades.line_1.visible = anything_in_shop_1 - for k, _ in pairs(shop_data_2) do - if availability_data and availability_data[k] == true then - flow.trades[k].visible = true - if Roles.player_privilege_level(player) >= Roles.privilege_levels.OFFICER then - flow.trades[k].buy_button.visible = true - else - flow.trades[k].buy_button.visible = false - end - else - flow.trades[k].visible = false - end - end - - - --*** UPDATE CONTENT ***-- - - local multiplier = Balance.main_shop_cost_multiplier() - - for k, v in pairs(shop_data) do - for k2, v2 in pairs(v.base_cost) do - if v2 == false then - flow.trades[k]['cost_' .. k2].number = nil - else - flow.trades[k]['cost_' .. k2].number = multiplier * v2 - end - end - end -end - -function Public.click(event) - if not event.element then return end - if not event.element.valid then return end - - local player = game.players[event.element.player_index] - - local eventname = event.element.name - - if not player.gui.screen[window_name .. '_piratewindow'] then return end - -- local flow = player.gui.screen[window_name .. '_piratewindow'] - - -- local memory = Memory.get_crew_memory() - - if eventname == 'buy_button' then - Shop.Captains.main_shop_try_purchase(player, event.element.parent.name) - end -end - -return Public diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index 205781ca..60bf8950 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -10,7 +10,6 @@ local GuiProgress = require 'maps.pirates.gui.progress' local GuiRuns = require 'maps.pirates.gui.runs' local GuiCrew = require 'maps.pirates.gui.crew' local GuiClasses = require 'maps.pirates.gui.classes' -local GuiFuel = require 'maps.pirates.gui.fuel' local GuiMinimap = require 'maps.pirates.gui.minimap' local GuiInfo = require 'maps.pirates.gui.info' local Quest = require 'maps.pirates.quest' @@ -42,7 +41,6 @@ local enum = { RUNS = 'runs', CREW = 'crew', CLASSES = 'classes', - FUEL = 'fuel', MINIMAP = 'minimap', INFO = 'info', COLOR = 'color', @@ -52,7 +50,6 @@ Public.progress = require 'maps.pirates.gui.progress' Public.runs = require 'maps.pirates.gui.runs' Public.crew = require 'maps.pirates.gui.crew' Public.classes = require 'maps.pirates.gui.classes' -Public.fuel = require 'maps.pirates.gui.fuel' Public.minimap = require 'maps.pirates.gui.minimap' Public.info = require 'maps.pirates.gui.info' Public.color = require 'maps.pirates.gui.color' @@ -71,13 +68,8 @@ end function Public.update_crew_progress_gui() return Public.update_crew_gui('progress') end -Event.add(CustomEvents.enum['update_crew_progress_gui'], Public.update_crew_progress_gui) --- script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) -function Public.update_crew_fuel_gui() - return Public.update_crew_gui('fuel') -end -Event.add(CustomEvents.enum['update_crew_fuel_gui'], Public.update_crew_fuel_gui) +Event.add(CustomEvents.enum['update_crew_progress_gui'], Public.update_crew_progress_gui) local function create_gui(player) local flow1, flow2, flow3, flow4 @@ -87,19 +79,19 @@ local function create_gui(player) flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'info_piratebutton') flow2.caption = '?' flow2.style.font = 'debug' - flow2.tooltip = {'pirates.gui_info_main_tooltip'} - flow2.style.font_color = {r=1, g=1, b=1} - flow2.style.hovered_font_color = {r=1, g=1, b=1} - flow2.style.clicked_font_color = {r=1, g=1, b=1} + flow2.tooltip = { 'pirates.gui_info_main_tooltip' } + flow2.style.font_color = { r = 1, g = 1, b = 1 } + flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 } + flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 } flow2.parent.style.left_padding = -6 flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'runs_piratebutton', 70) - flow2.caption = {'pirates.gui_crews'} - flow2.tooltip = {'pirates.gui_crews_main_tooltip'} + flow2.caption = { 'pirates.gui_crews' } + flow2.tooltip = { 'pirates.gui_crews_main_tooltip' } flow2.style.font = 'debug' - flow2.style.font_color = {r=1, g=1, b=1} - flow2.style.hovered_font_color = {r=1, g=1, b=1} - flow2.style.clicked_font_color = {r=1, g=1, b=1} + flow2.style.font_color = { r = 1, g = 1, b = 1 } + flow2.style.hovered_font_color = { r = 1, g = 1, b = 1 } + flow2.style.clicked_font_color = { r = 1, g = 1, b = 1 } flow2.parent.style.width = 67 flow2.parent.style.left_padding = -6 @@ -131,11 +123,11 @@ local function create_gui(player) flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'evo_piratebutton') flow2.sprite = 'entity/small-biter' - flow2.mouse_button_filter = {'middle'} --hack to avoid press visual + flow2.mouse_button_filter = { 'middle' } --hack to avoid press visual flow2.show_percent_for_small_numbers = true --as of factorio v1.1.59, there is a bug in which 1.002 displays as like 1e-2% or something. but after 1.01 it's ok flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'minimap_piratebutton') - flow2.tooltip = {'pirates.gui_minimap_main_tooltip'} + flow2.tooltip = { 'pirates.gui_minimap_main_tooltip' } flow2.sprite = 'utility/map' -- flow2 = GuiCommon.flow_add_floating_sprite_button(flow1, 'shop_piratebutton') @@ -167,7 +159,7 @@ local function create_gui(player) }) flow3.style.font = 'default-large-semibold' flow3.style.font_color = GuiCommon.bold_font_color - flow3.caption = {'pirates.gui_fuel_1'} + flow3.caption = { 'pirates.gui_fuel_1' } flow3 = flow2.add({ name = 'fuel_label_1', @@ -222,9 +214,9 @@ local function create_gui(player) flow3.style.font = 'default-large-semibold' flow3.style.font_color = GuiCommon.bold_font_color - flow3 = flow2.add({type = 'table', name = 'cost_table', column_count = #CoreData.cost_items}) + flow3 = flow2.add({ type = 'table', name = 'cost_table', column_count = #CoreData.cost_items }) for i = 1, #CoreData.cost_items do - flow4 = flow3.add({type = 'sprite-button', name = 'cost_' .. i, number = 0}) + flow4 = flow3.add({ type = 'sprite-button', name = 'cost_' .. i, number = 0 }) -- flow4.mouse_button_filter = {'middle'} flow4.sprite = CoreData.cost_items[i].sprite_name flow4.enabled = false @@ -234,14 +226,14 @@ local function create_gui(player) flow4.visible = false end -- and - flow4 = flow3.add({type = 'sprite-button', name = 'cost_launch_rocket'}) - -- flow4.mouse_button_filter = {'middle'} - flow4.sprite = 'item/rocket-silo' - flow4.enabled = false - flow4.style.top_margin = -6 - flow4.style.right_margin = -6 - flow4.style.maximal_height = 38 - flow4.visible = false + flow4 = flow3.add({ type = 'sprite-button', name = 'cost_launch_rocket' }) + -- flow4.mouse_button_filter = {'middle'} + flow4.sprite = 'item/rocket-silo' + flow4.enabled = false + flow4.style.top_margin = -6 + flow4.style.right_margin = -6 + flow4.style.maximal_height = 38 + flow4.visible = false flow3.style.left_margin = -1 flow3.style.right_margin = -2 --to get to the end of the button frame @@ -485,13 +477,13 @@ local function create_gui(player) -- spontaneous inside view of the hold: flow1 = - player.gui.screen.add( - { - type = 'camera', - name = 'pirates_spontaneous_camera', - position = {x=0,y=0}, - } - ) + player.gui.screen.add( + { + type = 'camera', + name = 'pirates_spontaneous_camera', + position = { x = 0, y = 0 }, + } + ) flow1.visible = false flow1.style.margin = 8 -- flow2.style.minimal_height = 64 @@ -546,34 +538,32 @@ function Public.process_etaframe_update(player, flow1, bools) flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = {'pirates.gui_etaframe_board_warning_tooltip'} - - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_board_warning'} + tooltip = { 'pirates.gui_etaframe_board_warning_tooltip' } + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_board_warning' } elseif bools.eta_bool then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = true - tooltip = {'pirates.auto_undock_tooltip'} + tooltip = { 'pirates.auto_undock_tooltip' } local passive_eta = dynamic_data.time_remaining - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_autoundock'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_autoundock' } flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(passive_eta) - elseif bools.atsea_loading_bool then if Kraken.get_active_kraken_count(memory.id) > 0 then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = {'pirates.defeat_krakens_tooltip'} + tooltip = { 'pirates.defeat_krakens_tooltip' } - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_defeat_krakens'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_defeat_krakens' } else flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = true - tooltip = {'pirates.atsea_loading_tooltip'} + tooltip = { 'pirates.atsea_loading_tooltip' } local total = Common.map_loading_ticks_atsea if destination.type == Surfaces.enum.DOCK then @@ -584,34 +574,31 @@ function Public.process_etaframe_update(player, flow1, bools) local eta_ticks = total + (memory.extra_time_at_sea or 0) - memory.loadingticks - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_loading_for'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_loading_for' } flow2.etaframe_label_2.caption = Utils.standard_string_form_of_time_in_seconds(eta_ticks / 60) end - elseif bools.atsea_waiting_bool then flow2.etaframe_label_1.visible = true flow2.etaframe_label_2.visible = false - tooltip = {'pirates.atsea_waiting_tooltip'} - - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_atsea_waiting'} + tooltip = { 'pirates.atsea_waiting_tooltip' } + 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'} + 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 - tooltip = {'pirates.leave_anytime_tooltip'} + tooltip = { 'pirates.leave_anytime_tooltip' } - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock'} - flow2.etaframe_label_2.caption = {'pirates.gui_etaframe_anytime'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock' } + flow2.etaframe_label_2.caption = { 'pirates.gui_etaframe_anytime' } end if bools.cost_bool and Kraken.get_active_kraken_count(memory.id) == 0 then @@ -624,65 +611,65 @@ function Public.process_etaframe_update(player, flow1, bools) cost_table.visible = true if flow2.etaframe_label_2.visible then - flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.' + flow2.etaframe_label_2.caption = flow2.etaframe_label_2.caption .. '.' end -- local caption if bools.atsea_loading_bool then - flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_next_escape_cost'} + flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_next_escape_cost' } if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_4_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_4_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_4'} + tooltip = { 'pirates.resources_needed_tooltip_4' } end elseif destination.static_params.undock_cost_decreases == true then if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_1_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_1_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_1'} + tooltip = { 'pirates.resources_needed_tooltip_1' } end else if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_0a_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_0a_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_0a'} + tooltip = { 'pirates.resources_needed_tooltip_0a' } end end elseif (not bools.eta_bool) then -- Shown when ship doesn't have auto undock timer flow2.etaframe_label_3.visible = false flow2.etaframe_label_1.visible = true - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_to_escape_store'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_to_escape_store' } if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_3'} + tooltip = { 'pirates.resources_needed_tooltip_3' } end else -- Shown when at island if Boats.need_resources_to_undock(Common.overworldx(), destination.subtype) then flow2.etaframe_label_3.visible = false if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_5_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_5_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_5'} + tooltip = { 'pirates.resources_needed_tooltip_5' } end elseif destination.static_params.undock_cost_decreases == true then - flow2.etaframe_label_3.caption = {'pirates.gui_etaframe_or_store'} + flow2.etaframe_label_3.caption = { 'pirates.gui_etaframe_or_store' } local adjusted_costs_resources_strings = Common.time_adjusted_departure_cost_resources_strings(memory) if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} + tooltip = { 'pirates.resources_needed_tooltip_2_rocketvariant', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] } else --@Future reference: localisation handling - tooltip = {'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2]} + tooltip = { 'pirates.resources_needed_tooltip_2', adjusted_costs_resources_strings[1], adjusted_costs_resources_strings[2] } end else if bools.cost_includes_rocket_launch_bool then - tooltip = {'pirates.resources_needed_tooltip_3_rocketvariant'} + tooltip = { 'pirates.resources_needed_tooltip_3_rocketvariant' } else - tooltip = {'pirates.resources_needed_tooltip_3'} + tooltip = { 'pirates.resources_needed_tooltip_3' } end end end @@ -710,7 +697,7 @@ function Public.process_etaframe_update(player, flow1, bools) else cost_table['cost_launch_rocket'].number = 0 end - cost_table['cost_launch_rocket'].tooltip = {'pirates.gui_etaframe_rocket_requirement_tooltip'} + cost_table['cost_launch_rocket'].tooltip = { 'pirates.gui_etaframe_rocket_requirement_tooltip' } cost_table['cost_launch_rocket'].visible = true else cost_table['cost_launch_rocket'].visible = false @@ -721,24 +708,22 @@ function Public.process_etaframe_update(player, flow1, bools) flow2.tooltip = tooltip if bools.captain_bool and (not bools.retreating_bool) and (bools.leave_anytime_bool or bools.atsea_waiting_bool or bools.eta_bool or (bools.cost_bool and (not bools.atsea_loading_bool))) then - flow1.etaframe_piratebutton.mouse_button_filter = {'left'} + flow1.etaframe_piratebutton.mouse_button_filter = { 'left' } if memory.undock_shortcut_are_you_sure_data and memory.undock_shortcut_are_you_sure_data[player.index] and memory.undock_shortcut_are_you_sure_data[player.index] > game.tick - 60 * 4 then flow2.etaframe_label_1.visible = true - flow2.etaframe_label_1.caption = {'pirates.gui_etaframe_undock_are_you_sure'} + flow2.etaframe_label_1.caption = { 'pirates.gui_etaframe_undock_are_you_sure' } flow2.etaframe_label_2.visible = false flow2.etaframe_label_3.visible = false end else - flow1.etaframe_piratebutton.mouse_button_filter = {'middle'} --hack to avoid press visual + flow1.etaframe_piratebutton.mouse_button_filter = { 'middle' } --hack to avoid press visual end else flow1.visible = false end end - function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bools) - local destination = Common.current_destination() local dynamic_data = destination.dynamic_data --assumes this always exists @@ -747,40 +732,37 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1 = flowsilo if flow1 then - if bools.silo_bool then flow1.visible = true if bools.charged_bool then - if bools.launched_bool then - flow1.silo_progressbar.visible = false flow1.silo_label_2.visible = false flow1.silo_label_3.visible = true -- flow1.silo_label_1.caption = string.format('[achievement=there-is-no-spoon]: +%.0f[item=sulfur]', dynamic_data.rocketcoalreward) - flow1.silo_label_1.caption = {'pirates.gui_etaframe_launched'} + flow1.silo_label_1.caption = { 'pirates.gui_etaframe_launched' } -- flow1.silo_label_1.caption = string.format('Launched for %.0f[item=coal] , ' .. Balance.rocket_launch_coin_reward .. '[item=coin]', dynamic_data.rocketcoalreward) flow1.silo_label_1.style.font_color = GuiCommon.achieved_font_color local rocket_launch_coal_reward = Balance.rocket_launch_fuel_reward() local rocket_launch_coin_reward = Balance.rocket_launch_coin_reward() - flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward/100)/10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward/100)/10 .. 'k[item=coin]' + flow1.silo_label_3.caption = Math.floor(rocket_launch_coal_reward / 100) / 10 .. 'k[item=coal], ' .. Math.floor(rocket_launch_coin_reward / 100) / 10 .. 'k[item=coin]' - local tooltip = {'pirates.gui_etaframe_launched_tooltip'} + local tooltip = { 'pirates.gui_etaframe_launched_tooltip' } flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_label_3.tooltip = tooltip else - local tooltip = {'pirates.gui_etaframe_launching'} + local tooltip = { 'pirates.gui_etaframe_launching' } flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_progressbar.tooltip = tooltip - flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} + flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' } flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_2.visible = false flow1.silo_label_3.visible = false @@ -788,9 +770,8 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1.silo_progressbar.value = 1 end - else - flow1.silo_label_1.caption = {'pirates.gui_etaframe_charge'} + flow1.silo_label_1.caption = { 'pirates.gui_etaframe_charge' } flow1.silo_label_1.style.font_color = GuiCommon.bold_font_color flow1.silo_label_2.visible = true flow1.silo_progressbar.visible = true @@ -800,9 +781,9 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo local needed = dynamic_data.rocketsiloenergyneeded local recent = (dynamic_data.rocketsiloenergyconsumedwithinlasthalfsecond * 2) - flow1.silo_progressbar.value = consumed/needed + flow1.silo_progressbar.value = consumed / needed - local tooltip = {'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000)/10), string.format('%.1f', Math.floor(needed / 100000000)/10)} + local tooltip = { 'pirates.gui_etaframe_charge_tooltip', string.format('%.1f', Math.floor(consumed / 100000000) / 10), string.format('%.1f', Math.floor(needed / 100000000) / 10) } flow1.tooltip = tooltip flow1.silo_label_1.tooltip = tooltip flow1.silo_label_2.tooltip = tooltip @@ -836,16 +817,15 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo local quest_reward = dynamic_data.quest_reward or nil local quest_progress = dynamic_data.quest_progress or 0 local quest_progressneeded = dynamic_data.quest_progressneeded or 0 - local quest_complete = dynamic_data.quest_complete or false + local quest_complete = dynamic_data.quest_complete or false if quest_type then - ---@type string|table local tooltip = '' if quest_complete and quest_reward then - tooltip = {'pirates.gui_questframe_complete_tooltip', quest_type} - flow1.quest_label_1.caption = {'pirates.gui_questframe'} + tooltip = { 'pirates.gui_questframe_complete_tooltip', quest_type } + flow1.quest_label_1.caption = { 'pirates.gui_questframe' } flow1.quest_label_1.style.font_color = GuiCommon.achieved_font_color flow1.quest_label_2.visible = true flow1.quest_label_3.visible = false @@ -853,7 +833,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo flow1.quest_label_2.caption = quest_reward.display_amount .. ' ' .. quest_reward.display_sprite elseif quest_reward then if quest_progress < quest_progressneeded then - flow1.quest_label_1.caption = {'pirates.gui_questframe'} + flow1.quest_label_1.caption = { 'pirates.gui_questframe' } flow1.quest_label_1.style.font_color = GuiCommon.bold_font_color flow1.quest_label_2.visible = true flow1.quest_label_3.visible = true @@ -867,7 +847,7 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end if quest_type == Quest.enum.TIME then - if tooltip == '' then tooltip = {'pirates.gui_questframe_time'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_time' } end if quest_progress >= 0 then flow1.quest_label_3.caption = string.format('%.0fm%.0fs', Math.floor(quest_progress / 60), quest_progress % 60) @@ -885,49 +865,42 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end end else - flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} + flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' } flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color end - elseif quest_type == Quest.enum.WORMS then - if tooltip == '' then tooltip = {'pirates.gui_questframe_worms'} end - + if tooltip == '' then tooltip = { 'pirates.gui_questframe_worms' } end elseif quest_type == Quest.enum.FIND then - if tooltip == '' then tooltip = {'pirates.gui_questframe_find'} end - + if tooltip == '' then tooltip = { 'pirates.gui_questframe_find' } end elseif quest_type == Quest.enum.RESOURCEFLOW then - if tooltip == '' then tooltip = {'pirates.gui_questframe_resourceflow'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourceflow' } end -- out of date: - if quest_progressneeded/60 % 1 == 0 then - flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) + if quest_progressneeded / 60 % 1 == 0 then + flow1.quest_label_2.caption = string.format('%s %.1f/%.0f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) else - flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress/60, quest_progressneeded/60) + flow1.quest_label_2.caption = string.format('%s %.1f/%.1f /s', '[item=' .. quest_params.item .. ']', quest_progress / 60, quest_progressneeded / 60) flow1.quest_label_3.caption = string.format(' for %s', quest_reward.display_sprite) end - elseif quest_type == Quest.enum.RESOURCECOUNT then - if tooltip == '' then tooltip = {'pirates.gui_questframe_resourcecount'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_resourcecount' } end flow1.quest_label_2.caption = string.format('%s ', '[item=' .. quest_params.item .. ']') - elseif quest_type == Quest.enum.NODAMAGE then - if tooltip == '' then tooltip = {'pirates.gui_questframe_nodamage'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_nodamage' } end if bools.approaching_bool or (dynamic_data.rocketsilos and dynamic_data.rocketsilos[1] and dynamic_data.rocketsilos[1].valid and dynamic_data.rocketsilohp == dynamic_data.rocketsilomaxhp) then - flow1.quest_label_3.caption = {'pirates.gui_questframe_ok'} + flow1.quest_label_3.caption = { 'pirates.gui_questframe_ok' } flow1.quest_label_3.style.font_color = GuiCommon.sufficient_font_color else - flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'} + flow1.quest_label_3.caption = { 'pirates.gui_questframe_fail' } flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color end - elseif quest_type == Quest.enum.FISH then - if tooltip == '' then tooltip = {'pirates.gui_questframe_fish'} end - + if tooltip == '' then tooltip = { 'pirates.gui_questframe_fish' } end elseif quest_type == Quest.enum.COMPILATRON then - if tooltip == '' then tooltip = {'pirates.gui_questframe_compilatron'} end + if tooltip == '' then tooltip = { 'pirates.gui_questframe_compilatron' } end end end @@ -943,7 +916,6 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo end end - -- local function create_gui_2() -- end @@ -965,11 +937,11 @@ function Public.update_gui(player) flow1 = pirates_flow.crew_piratebutton_frame.crew_piratebutton if Common.is_id_valid(memory.id) then - flow1.tooltip = {'pirates.gui_crew_tooltip_1'} - flow1.mouse_button_filter = {'left','right'} + flow1.tooltip = { 'pirates.gui_crew_tooltip_1' } + flow1.mouse_button_filter = { 'left', 'right' } else - flow1.tooltip = {'pirates.gui_crew_tooltip_2'} - flow1.mouse_button_filter = {'middle'} --hack to avoid press visual + flow1.tooltip = { 'pirates.gui_crew_tooltip_2' } + flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual if player.gui.screen['crew_piratewindow'] then player.gui.screen['crew_piratewindow'].destroy() end @@ -978,11 +950,11 @@ function Public.update_gui(player) flow1 = pirates_flow.classes_piratebutton_frame.classes_piratebutton if Common.is_id_valid(memory.id) then - flow1.tooltip = {'pirates.gui_classes_tooltip_1'} - flow1.mouse_button_filter = {'left','right'} + flow1.tooltip = { 'pirates.gui_classes_tooltip_1' } + flow1.mouse_button_filter = { 'left', 'right' } else - flow1.tooltip = {'pirates.gui_classes_tooltip_2'} - flow1.mouse_button_filter = {'middle'} --hack to avoid press visual + flow1.tooltip = { 'pirates.gui_classes_tooltip_2' } + flow1.mouse_button_filter = { 'middle' } --hack to avoid press visual if player.gui.screen['classes_piratewindow'] then player.gui.screen['classes_piratewindow'].destroy() end @@ -993,7 +965,6 @@ function Public.update_gui(player) if GuiRuns.full_update then GuiRuns.full_update(player) end if GuiCrew.full_update then GuiCrew.full_update(player) end if GuiClasses.full_update then GuiClasses.full_update(player) end - if GuiFuel.regular_update then GuiFuel.regular_update(player) end --moved to event if GuiMinimap.full_update then GuiMinimap.full_update(player) end if GuiInfo.full_update then GuiInfo.full_update(player) end @@ -1013,7 +984,7 @@ function Public.update_gui(player) flow1 = pirates_flow.fuel_flow -- flow1 = pirates_flow.fuel_piratebutton_flow_1 - local tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} + local tooltip = { 'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0) } flow1.tooltip = tooltip -- flow1.fuel_piratebutton.tooltip = {'pirates.fuel_tooltip', Math.floor(memory.stored_fuel or 0)} @@ -1023,11 +994,11 @@ function Public.update_gui(player) flow2.fuel_label_1.caption = Utils.bignumber_abbrevform(memory.stored_fuel or 0) .. '[item=coal]' flow2.fuel_label_2.caption = Utils.negative_rate_abbrevform(memory.fuel_depletion_rate_memoized or 0) - local color_scale = Math.clamp(0, 1, (- (memory.fuel_depletion_rate_memoized or 0))/30) + local color_scale = Math.clamp(0, 1, (-(memory.fuel_depletion_rate_memoized or 0)) / 30) flow2.fuel_label_2.style.font_color = { - r = GuiCommon.fuel_color_1.r * (1-color_scale) + GuiCommon.fuel_color_2.r * color_scale, - g = GuiCommon.fuel_color_1.g * (1-color_scale) + GuiCommon.fuel_color_2.g * color_scale, - b = GuiCommon.fuel_color_1.b * (1-color_scale) + GuiCommon.fuel_color_2.b * color_scale, + r = GuiCommon.fuel_color_1.r * (1 - color_scale) + GuiCommon.fuel_color_2.r * color_scale, + g = GuiCommon.fuel_color_1.g * (1 - color_scale) + GuiCommon.fuel_color_2.g * color_scale, + b = GuiCommon.fuel_color_1.b * (1 - color_scale) + GuiCommon.fuel_color_2.b * color_scale, } flow2.fuel_label_0.tooltip = tooltip flow2.fuel_label_1.tooltip = tooltip @@ -1037,7 +1008,7 @@ function Public.update_gui(player) flow1 = pirates_flow.progress_piratebutton_frame.progress_piratebutton flow1.number = (memory.overworldx or 0) - flow1.tooltip = {'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x} + flow1.tooltip = { 'pirates.gui_progress_tooltip', memory.overworldx or 0, CoreData.victory_x } -- pirates_flow.destination_piratebutton_frame.destination_piratebutton.number = memory.destinationsvisited_indices and #memory.destinationsvisited_indices or 0 @@ -1178,41 +1149,41 @@ function Public.update_gui(player) if not flow1 then --comfy panel might possibly destroy this, so this puts it back flow1 = - player.gui.screen.add( - { - type = 'camera', - name = 'pirates_spontaneous_camera', - position = {x=0,y=0}, - } - ) + player.gui.screen.add( + { + type = 'camera', + name = 'pirates_spontaneous_camera', + position = { x = 0, y = 0 }, + } + ) flow1.visible = false flow1.style.margin = 8 end if flow1 then flow1.visible = false - flow1.location = {x = 8, y = 48} + flow1.location = { x = 8, y = 48 } if bools.on_deck_standing_near_loco_bool then flow1.visible = true flow1.surface_index = Hold.get_hold_surface(1).index flow1.zoom = 0.182 flow1.style.minimal_height = 292 flow1.style.minimal_width = 540 - flow1.position = {x=0,y=-2} + flow1.position = { x = 0, y = -2 } elseif bools.on_deck_standing_near_cabin_bool then flow1.visible = true flow1.surface_index = Cabin.get_cabin_surface().index flow1.zoom = 0.468 flow1.style.minimal_height = 400 flow1.style.minimal_width = 280 - flow1.position = {x=0,y=-1} + flow1.position = { x = 0, y = -1 } elseif bools.on_deck_standing_near_crowsnest_bool then flow1.visible = true flow1.surface_index = Crowsnest.get_crowsnest_surface().index flow1.zoom = 0.21 flow1.style.minimal_height = 384 flow1.style.minimal_width = 384 - flow1.position = {x=memory.overworldx,y=memory.overworldy} + flow1.position = { x = memory.overworldx, y = memory.overworldy } elseif bools.in_crowsnest_bool then flow1.visible = true flow1.surface_index = game.surfaces[memory.boat.surface_name].index @@ -1223,15 +1194,13 @@ function Public.update_gui(player) local position = memory.boat.position if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and memory.boat.surface_name and memory.boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then -- nicer viewing position: - position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} + position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 } end flow1.position = position end end end - - -- ATTENTION: Giving same names to GUI elements can cause issues, because click events are dispatched to all GUI windows! local function on_gui_click(event) if not event then return end @@ -1258,7 +1227,6 @@ local function on_gui_click(event) memory.undock_shortcut_are_you_sure_data[player.index] = game.tick end end - elseif memory.boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL then if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then local destination_index = memory.mapbeingloadeddestination_index @@ -1266,7 +1234,6 @@ 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 @@ -1275,17 +1242,16 @@ local function on_gui_click(event) 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) + 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 - local name = string.sub(event.element.name, 1, -14) - if Public[name] then - Public[name].toggle_window(player) - Public[name].full_update(player) - end + local name = string.sub(event.element.name, 1, -14) + if Public[name] then + Public[name].toggle_window(player) + Public[name].full_update(player) + end -- elseif event.element.name == 'fuel_label_1' or event.element.name == 'fuel_label_2' then -- Public.fuel.toggle_window(player) -- Public.fuel.full_update(player) @@ -1294,10 +1260,9 @@ local function on_gui_click(event) if GuiRuns.click then GuiRuns.click(event) end if GuiCrew.click then GuiCrew.click(event) end if GuiClasses.click then GuiClasses.click(event) end - if GuiFuel.click then GuiFuel.click(event) end if GuiMinimap.click then GuiMinimap.click(event) end if GuiInfo.click then GuiInfo.click(event) end - end + end end local function on_gui_location_changed(event) @@ -1320,4 +1285,4 @@ event.add(defines.events.on_gui_location_changed, on_gui_location_changed) -return Public \ No newline at end of file +return Public diff --git a/maps/pirates/gui/minimap.lua b/maps/pirates/gui/minimap.lua index a93eeb18..08c7adbc 100644 --- a/maps/pirates/gui/minimap.lua +++ b/maps/pirates/gui/minimap.lua @@ -40,7 +40,7 @@ function Public.toggle_window(player) end -- else: flow = GuiCommon.new_window(player, window_name) - flow.caption = {'pirates.gui_minimap_outside_view'} + flow.caption = { 'pirates.gui_minimap_outside_view' } flow.style.maximal_width = 800 local memory = Memory.get_crew_memory() @@ -60,11 +60,11 @@ function Public.toggle_window(player) if not (memory.boat and memory.boat.position and memory.boat.surface_name) then return end - local position = memory.boat.position + local position = memory.boat.position local destination = Common.current_destination() if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and destination.static_params and destination.static_params.boat_starting_xposition) then -- nicer viewing position: - position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} + position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 } end local zoom if gui_memory and gui_memory[window_name] and gui_memory[window_name].zoom then @@ -79,25 +79,25 @@ function Public.toggle_window(player) size = default_size end - local element = flow['camera'] - if not element then - element = - flow.add( - { - type = 'camera', - name = 'camera', - position = position, - surface_index = game.surfaces[memory.boat.surface_name].index, - zoom = zoom, - tooltip = {'pirates.gui_minimap_tooltip'} - } - ) - element.style.margin = 1 - element.style.minimal_height = size - element.style.minimal_width = size - element.style.maximal_height = size - element.style.maximal_width = size - end + local element = flow['camera'] + if not element then + element = + flow.add( + { + type = 'camera', + name = 'camera', + position = position, + surface_index = game.surfaces[memory.boat.surface_name].index, + zoom = zoom, + tooltip = { 'pirates.gui_minimap_tooltip' } + } + ) + element.style.margin = 1 + element.style.minimal_height = size + element.style.minimal_width = size + element.style.maximal_height = size + element.style.maximal_width = size + end flow2 = GuiCommon.flow_add_close_button(flow, window_name .. '_piratebutton') flow2.add( @@ -107,16 +107,12 @@ function Public.toggle_window(player) index = 1, allow_none_state = false, switch_state = switch_state, - left_label_caption = {'pirates.gui_minimap_switch_left'}, - right_label_caption = {'pirates.gui_minimap_switch_right'}, + left_label_caption = { 'pirates.gui_minimap_switch_left' }, + right_label_caption = { 'pirates.gui_minimap_switch_right' }, } ) end - - - - -- function Public.regular_update(player) -- end @@ -131,13 +127,13 @@ function Public.full_update(player) if not player.gui.screen[window_name .. '_piratewindow'] then return end flow = player.gui.screen[window_name .. '_piratewindow'] - local element = flow['camera'] + local element = flow['camera'] if element then local position = boat.position local destination = Common.current_destination() if (destination and destination.type and destination.type == Surfaces.enum.ISLAND and boat.surface_name and boat.surface_name == destination.surface_name and destination.static_params and destination.static_params.boat_starting_xposition) then -- nicer viewing position: - position = {x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0} + position = { x = destination.static_params.boat_starting_xposition + 50, y = destination.static_params.boat_starting_yposition or 0 } end if position then @@ -149,7 +145,6 @@ function Public.full_update(player) end end - function Public.click(event) if not event.element then return end if not event.element.valid then return end @@ -162,13 +157,8 @@ function Public.click(event) -- local flow = player.gui.screen[window_name .. '_piratewindow'] -- local memory = Memory.get_crew_memory() - -- local shop_data = Shop.main_shop_data - -- if eventname == 'buy_button' then - -- Shop.Captains.main_shop_try_purchase(event.element.parent.name) - -- end - - if eventname ~= 'camera' then return end + if eventname ~= 'camera' then return end local zoom = default_zoom local size = default_size @@ -181,7 +171,7 @@ function Public.click(event) size = gui_memory[window_name].size or default_size end - if event.button == defines.mouse_button_type.right then + if event.button == defines.mouse_button_type.right then if zoom == 0.15 then zoom = 0.11 elseif zoom == 0.11 then @@ -189,9 +179,9 @@ function Public.click(event) else zoom = 0.04 end - event.element.zoom = zoom - end - if event.button == defines.mouse_button_type.left then + event.element.zoom = zoom + end + if event.button == defines.mouse_button_type.left then if zoom == 0.04 then zoom = 0.07 elseif zoom == 0.07 then @@ -199,9 +189,9 @@ function Public.click(event) else zoom = 0.15 end - event.element.zoom = zoom - end - if event.button == defines.mouse_button_type.middle then + event.element.zoom = zoom + end + if event.button == defines.mouse_button_type.middle then if size == 340 then size = 440 elseif size == 440 then @@ -213,31 +203,29 @@ function Public.click(event) else size = 340 end - event.element.style.minimal_height = size - event.element.style.minimal_width = size - event.element.style.maximal_height = size - event.element.style.maximal_width = size - end + event.element.style.minimal_height = size + event.element.style.minimal_width = size + event.element.style.maximal_height = size + event.element.style.maximal_width = size + end GuiCommon.update_gui_memory(player, window_name, 'zoom', zoom) GuiCommon.update_gui_memory(player, window_name, 'size', size) end - - local function on_player_changed_surface(event) - local player = game.players[event.player_index] - if not Common.validate_player_and_character(player) then - return - end + local player = game.players[event.player_index] + if not Common.validate_player_and_character(player) then + return + end local window = player.gui.screen[window_name .. '_piratewindow'] local from_hold_or_cabin_bool = string.sub(game.surfaces[event.surface_index].name, 9, 12) == 'Hold' or string.sub(game.surfaces[event.surface_index].name, 9, 13) == 'Cabin' local to_hold_or_cabin_bool = string.sub(player.surface.name, 9, 12) == 'Hold' or string.sub(player.surface.name, 9, 13) == 'Cabin' - if from_hold_or_cabin_bool and (not to_hold_or_cabin_bool) then - if window then + if from_hold_or_cabin_bool and (not to_hold_or_cabin_bool) then + if window then Public.toggle_window(player) end elseif to_hold_or_cabin_bool and (not from_hold_or_cabin_bool) then @@ -247,11 +235,10 @@ local function on_player_changed_surface(event) if (gui_memory and gui_memory[window_name] and gui_memory[window_name].auto_map) or (not gui_memory) or (gui_memory and (not gui_memory[window_name])) then --if no gui memory exists for this, default to opening the minimap Public.toggle_window(player) end - end - + end end local event = require 'utils.event' event.add(defines.events.on_player_changed_surface, on_player_changed_surface) -return Public \ No newline at end of file +return Public diff --git a/maps/pirates/main.lua b/maps/pirates/main.lua index 51fcfecd..67785171 100644 --- a/maps/pirates/main.lua +++ b/maps/pirates/main.lua @@ -57,7 +57,7 @@ require 'maps.pirates.ores' require 'maps.pirates.quest' require 'maps.pirates.parrot' require 'maps.pirates.shop.shop' -require 'maps.pirates.boat_upgrades' +require 'maps.pirates.shop.boat_upgrades' local Token = require 'utils.token' local Task = require 'utils.task' local Server = require 'utils.server' diff --git a/maps/pirates/overworld.lua b/maps/pirates/overworld.lua index 8b614af7..957cc7fc 100644 --- a/maps/pirates/overworld.lua +++ b/maps/pirates/overworld.lua @@ -26,7 +26,7 @@ local Crew = require 'maps.pirates.crew' -- local Hold = require 'maps.pirates.surfaces.hold' -- local Cabin = require 'maps.pirates.surfaces.cabin' local Shop = require 'maps.pirates.shop.shop' -local Upgrades = require 'maps.pirates.boat_upgrades' +local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Kraken = require 'maps.pirates.surfaces.sea.kraken' local Highscore = require 'maps.pirates.highscore' local CustomEvents = require 'maps.pirates.custom_events' @@ -424,12 +424,13 @@ function Public.generate_overworld_destination(p) } local i = 1 - for price_name, price_count in pairs(Shop.Captains.main_shop_data_1[dest.static_params.upgrade_for_sale].base_cost) do + for _, price_data in ipairs(Upgrades.upgrades_data[dest.static_params.upgrade_for_sale].market_item.price) do + local price_name, price_count = price_data[1], price_data[2] local sprite - if price_name == 'fuel' then + if price_name == 'coal' then sprite = 'item/coal' else - sprite = 'item/coin' + sprite = 'item/' .. price_name end dest.dynamic_data.crowsnest_renderings[price_name] = { text_rendering = rendering.draw_text { @@ -516,7 +517,12 @@ function Public.ensure_lane_generated_up_to(lane_yvalue, x) end for rendering_name, r in pairs(dest.dynamic_data.crowsnest_renderings) do if type(r) == 'table' and r.text_rendering and rendering.is_valid(r.text_rendering) then - rendering.set_text(r.text_rendering, Utils.bignumber_abbrevform2(Shop.Captains.main_shop_data_1[dest.static_params.upgrade_for_sale].base_cost[rendering_name])) + for _, price_data in ipairs(Upgrades.upgrades_data[dest.static_params.upgrade_for_sale].market_item.price) do + if price_data[1] == rendering_name then + rendering.set_text(r.text_rendering, Utils.bignumber_abbrevform2(price_data[2])) + break + end + end end end end diff --git a/maps/pirates/progression.lua b/maps/pirates/progression.lua index e966b76d..6c531a9d 100644 --- a/maps/pirates/progression.lua +++ b/maps/pirates/progression.lua @@ -29,7 +29,7 @@ local Shop = require 'maps.pirates.shop.shop' local Overworld = require 'maps.pirates.overworld' local Hold = require 'maps.pirates.surfaces.hold' local Cabin = require 'maps.pirates.surfaces.cabin' -local Upgrades = require 'maps.pirates.boat_upgrades' +local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Task = require 'utils.task' local Token = require 'utils.token' local ShopDock = require 'maps.pirates.shop.dock' @@ -133,8 +133,6 @@ function Public.go_from_starting_dock_to_first_destination() boat.stored_resources = {} - Shop.Captains.initialise_captains_shop() - Hold.create_hold_surface(1) boat.EEI_stage = 1 boat.random_class_purchase_count = 0 @@ -261,8 +259,6 @@ function Public.progress_to_destination(destination_index) end end - script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {}) - -- Delay.add(Delay.enum.PLACE_DOCK_JETTY_AND_BOATS) Task.set_timeout_in_ticks(2, place_dock_jetty_and_boats, { crew_id = memory.id }) else @@ -413,8 +409,6 @@ function Public.check_for_end_of_boat_movement(boat) memory.mainshop_availability_bools.unlock_merchants = false memory.mainshop_availability_bools.rockets_for_sale = false - script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {}) - Public.go_from_currentdestination_to_sea() return true @@ -492,8 +486,6 @@ function Public.undock_from_dock(manual) memory.mainshop_availability_bools.new_boat_cutter_with_hold = false memory.mainshop_availability_bools.new_boat_sloop_with_hold = false - script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {}) - Crew.summon_crew() local force = memory.force diff --git a/maps/pirates/boat_upgrades.lua b/maps/pirates/shop/boat_upgrades.lua similarity index 63% rename from maps/pirates/boat_upgrades.lua rename to maps/pirates/shop/boat_upgrades.lua index 254b20c6..e97b11c1 100644 --- a/maps/pirates/boat_upgrades.lua +++ b/maps/pirates/shop/boat_upgrades.lua @@ -49,13 +49,78 @@ Public.crowsnest_display_form = { [enum.UPGRADE_CANNONS] = { 'pirates.upgrade_cannons_crowsnest_form' }, } --- WARNING: The dock market pulls from these values, but the Crowsnest caption pulls data from main_shop_data_1. So don't change one without the other -Public.market_offer_form = { - [enum.MORE_POWER] = { price = { { 'coin', 7000 }, { 'coal', 500 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_power' } } }, - [enum.EXTRA_HOLD] = { price = { { 'coin', 7000 }, { 'coal', 500 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_hold' } } }, - [enum.UNLOCK_MERCHANTS] = { price = { { 'coin', 14000 }, { 'coal', 1000 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_merchants' } } }, - [enum.ROCKETS_FOR_SALE] = { price = { { 'coin', 21000 }, { 'coal', 1000 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_rockets' } } }, - [enum.UPGRADE_CANNONS] = { price = { { 'repair-pack', 20 }, { 'coin', 5000 }, { 'coal', 800 } }, offer = { type = 'nothing', effect_description = { 'pirates.market_description_upgrade_turrets' } } }, +Public.upgrades_data = { + [enum.MORE_POWER] = { + market_item = { + price = { + { 'coin', 7000 }, + { 'coal', 500 } + }, + offer = { + type = 'nothing', + effect_description = { 'pirates.market_description_upgrade_power' } + }, + }, + tooltip = { 'pirates.market_description_upgrade_power' }, + what_you_get_sprite_buttons = { ['utility/status_working'] = false }, + }, + [enum.EXTRA_HOLD] = { + market_item = { + price = { + { 'coin', 7000 }, + { 'coal', 500 } + }, + offer = { + type = 'nothing', + effect_description = { 'pirates.market_description_upgrade_hold' } + }, + }, + tooltip = { 'pirates.market_description_upgrade_hold' }, + what_you_get_sprite_buttons = { ['item/steel-chest'] = false }, + }, + [enum.UNLOCK_MERCHANTS] = { + market_item = { + price = { + { 'coin', 14000 }, + { 'coal', 1000 } + }, + offer = { + type = 'nothing', + effect_description = { 'pirates.market_description_upgrade_merchants' } + }, + }, + tooltip = { 'pirates.market_description_upgrade_merchants' }, + what_you_get_sprite_buttons = { ['entity/market'] = false }, + }, + [enum.ROCKETS_FOR_SALE] = { + market_item = { + price = { + { 'coin', 21000 }, + { 'coal', 1000 } + }, + offer = { + type = 'nothing', + effect_description = { 'pirates.market_description_upgrade_rockets' } + }, + }, + tooltip = { 'pirates.market_description_upgrade_rockets' }, + what_you_get_sprite_buttons = { ['item/rocket-launcher'] = false }, + }, + [enum.UPGRADE_CANNONS] = { + market_item = { + price = { + { 'repair-pack', 20 }, + { 'coin', 5000 }, + { 'coal', 800 } + }, + offer = { + type = 'nothing', + effect_description = { 'pirates.market_description_upgrade_turrets' } + }, + }, + tooltip = { 'pirates.market_description_upgrade_turrets' }, + what_you_get_sprite_buttons = { ['item/artillery-turret'] = false }, + }, } function Public.execute_upgade(upgrade_type, player) diff --git a/maps/pirates/shop/captains.lua b/maps/pirates/shop/captains.lua deleted file mode 100644 index 2bdc2d3c..00000000 --- a/maps/pirates/shop/captains.lua +++ /dev/null @@ -1,347 +0,0 @@ --- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates. - - -local Memory = require 'maps.pirates.memory' --- local Roles = require 'maps.pirates.roles.roles' --- local Balance = require 'maps.pirates.balance' --- local Common = require 'maps.pirates.common' --- local Utils = require 'maps.pirates.utils_local' --- local Math = require 'maps.pirates.math' --- local Loot = require 'maps.pirates.loot' -local _inspect = require 'utils.inspect'.inspect -local Upgrades = require 'maps.pirates.boat_upgrades' --- local Hold = require 'maps.pirates.surfaces.hold' --- local Crew = require 'maps.pirates.crew' --- local Boats = require 'maps.pirates.structures.boats.boats' --- local Dock = require 'maps.pirates.surfaces.dock' -local CustomEvents = require 'maps.pirates.custom_events' - -local Public = {} - - - --- Note! This file is deprecated. It is replaced with a dedicated market at the dock and inside the captain's cabin. The exception is main_shop_data_1 as noted below, which is consulted for the Crowsnest caption. (Haven't had time to unify this yet.) - - - ---== Warning: If something only costs fuel, then we need to check the player can't buy it whilst they're dead - --- WARNING: The Crowsnest caption pulls data from this data. But the actual dock market pulls from boat_upgrades.lua. -Public.main_shop_data_1 = { - -- upgrade_cannons = { - -- tooltip = 'Increase cannons max health. This will also repair them.', - -- what_you_get_sprite_buttons = {['item/artillery-turret'] = false}, - -- base_cost = {coins = 1000}, - -- }, - new_boat_cutter = { - tooltip = 'Purchase a cutter.', - what_you_get_sprite_buttons = { ['utility/spawn_flag'] = false }, - base_cost = { fuel = 3000 }, - }, - new_boat_sloop_with_hold = { - tooltip = 'Purchase a sloop (with hold).', - what_you_get_sprite_buttons = { ['utility/spawn_flag'] = false }, - base_cost = { fuel = 3500 }, - }, - new_boat_cutter_with_hold = { - tooltip = 'Purchase a cutter (with hold).', - what_you_get_sprite_buttons = { ['utility/spawn_flag'] = false }, - base_cost = { fuel = 5000 }, - }, - -- buy_iron = { - -- tooltip = 'Purchase 250 iron plates for 300 stored fuel.', - -- what_you_get_sprite_buttons = {['item/iron-plate'] = 250}, - -- base_cost = {fuel = 300}, - -- }, - -- buy_copper = { - -- tooltip = 'Purchase 250 copper plates for 300 stored fuel.', - -- what_you_get_sprite_buttons = {['item/copper-plate'] = 250}, - -- base_cost = {fuel = 300}, - -- }, - -- sell_iron = { - -- tooltip = 'Purchase 200 stored fuel for 2000 iron plates.', - -- what_you_get_sprite_buttons = {['item/sulfur'] = 200}, - -- base_cost = {iron_plates = 2000}, - -- }, - -- sell_copper = { - -- tooltip = 'Purchase 100 stored fuel for 2500 copper plates', - -- what_you_get_sprite_buttons = {['item/sulfur'] = 100}, - -- base_cost = {copper_plates = 2500}, - -- }, - -- as as initial pass let's try making the fuel values half of the old gold values... - [Upgrades.enum.MORE_POWER] = { - tooltip = { 'pirates.market_description_upgrade_power' }, - what_you_get_sprite_buttons = { ['utility/status_working'] = false }, - base_cost = { coins = 7000, fuel = 500 }, - }, - [Upgrades.enum.EXTRA_HOLD] = { - tooltip = { 'pirates.market_description_upgrade_hold' }, - what_you_get_sprite_buttons = { ['item/steel-chest'] = false }, - base_cost = { coins = 7000, fuel = 500 }, - }, - [Upgrades.enum.UNLOCK_MERCHANTS] = { - tooltip = { 'pirates.market_description_upgrade_merchants' }, - what_you_get_sprite_buttons = { ['entity/market'] = false }, - base_cost = { coins = 14000, fuel = 1000 }, - }, - [Upgrades.enum.ROCKETS_FOR_SALE] = { - tooltip = { 'pirates.market_description_upgrade_rockets' }, - what_you_get_sprite_buttons = { ['item/rocket-launcher'] = false }, - base_cost = { coins = 21000, fuel = 1000 }, - }, - [Upgrades.enum.UPGRADE_CANNONS] = { - tooltip = { 'pirates.market_description_upgrade_turrets' }, - what_you_get_sprite_buttons = { ['item/artillery-turret'] = false }, - base_cost = { coins = 5000, fuel = 800 }, - }, -} - -Public.main_shop_data_2 = { - rail_signal = { - tooltip = "50 signals, used to steer the boat one space in the Crow's Nest View.", - what_you_get_sprite_buttons = { ['item/rail-signal'] = 50 }, - base_cost = { coins = 500, fuel = 50 }, - }, - artillery_shell = { - tooltip = '8 cannon shells.', - what_you_get_sprite_buttons = { ['item/artillery-shell'] = 8 }, - base_cost = { coins = 800, fuel = 30 }, - }, - -- artillery_remote = { - -- tooltip = 'An artillery targeting remote.', - -- what_you_get_sprite_buttons = {['item/artillery-targeting-remote'] = 1}, - -- base_cost = {coins = 12000, fuel = 2500}, - -- }, - -- buy_fast_loader = { - -- tooltip = 'A fast loader for 500 stored fuel.', - -- what_you_get_sprite_buttons = {['item/fast-loader'] = 1}, - -- base_cost = {fuel = 500}, - -- }, - uranium_ore = { - tooltip = '10 green rocks of unknown origin.', - what_you_get_sprite_buttons = { ['item/uranium-238'] = 10 }, - base_cost = { coins = 1000, fuel = 100 }, - }, - extra_time = { - tooltip = 'Relax at sea for an extra minute. (Increases the next destination\'s loading time.)', - what_you_get_sprite_buttons = { ['utility/time_editor_icon'] = 60 }, - base_cost = { coins = 10, fuel = 1 }, - }, -} - - - -function Public.initialise_captains_shop() - local memory = Memory.get_crew_memory() - - memory.mainshop_availability_bools = { - uranium_ore = true, - rail_signal = true, - artillery_shell = true, - artillery_remote = false, --good way to get trolled by crew and remove skill - extra_time = false, - new_boat_sloop_with_hold = false, - new_boat_cutter_with_hold = false, - new_boat_cutter = false, - buy_iron = false, - upgrade_cannons = false, - -- sell_iron = false, - -- buy_fast_loader = true, - -- sell_copper = false, - } - - script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {}) -end - --- function Public.main_shop_try_purchase(player, purchase_name) --- local memory = Memory.get_crew_memory() --- local destination = Common.current_destination() --- local shop_data_1 = Public.main_shop_data_1 --- local shop_data_2 = Public.main_shop_data_2 --- local trade_data = shop_data_1[purchase_name] or shop_data_2[purchase_name] --- if not trade_data then return end - --- local stored_fuel = memory.stored_fuel --- if not stored_fuel then return end --- -- local captain_index = memory.playerindex_captain --- -- if not (stored_fuel and captain_index) then return end --- -- local captain = game.players[captain_index] --- if not Common.validate_player_and_character(player) then return end - --- local inv = player.get_inventory(defines.inventory.character_main) --- if not (inv and inv.valid) then return end - --- local multiplier = Balance.main_shop_cost_multiplier() - --- -- local rate_limit_ok = not (memory.mainshop_rate_limit_ticker and memory.mainshop_rate_limit_ticker > 0) --- local rate_limit_ok = true --- local enough_fuel = true --- local enough_iron_plates = true --- local enough_coins = true --- local enough_copper_plates = true --- local coins_got --- local iron_plates_got --- local copper_plates_got --- -- local able_to_buy_boats = memory.boat.state == Boats.enum_state.DOCKED --disabled for now --- local able_to_buy_boats = false --- -- local able_to_buy_boats = (memory.boat.state == Boats.enum_state.DOCKED or memory.boat.state == Boats.enum_state.APPROACHING) --problem with this if you buy whilst approaching, the original one no longer moves - --- for k, v in pairs(trade_data.base_cost) do --- if k == 'fuel' then --- enough_fuel = (stored_fuel >= v * multiplier) --- elseif k == 'coins' then --- coins_got = inv.get_item_count('coin') --- enough_coins = coins_got >= v * multiplier --- elseif k == 'iron_plates' then --- iron_plates_got = inv.get_item_count('iron-plate') --- enough_iron_plates = iron_plates_got >= v * multiplier --- elseif k == 'copper_plates' then --- copper_plates_got = inv.get_item_count('copper-plate') --- enough_copper_plates = copper_plates_got >= v * multiplier --- end --- end - --- local can_buy = rate_limit_ok and enough_coins and enough_fuel and enough_iron_plates and enough_copper_plates - --- if purchase_name == 'new_boat_sloop_with_hold' or purchase_name == 'new_boat_cutter_with_hold' or purchase_name == 'new_boat_cutter' then can_buy = can_buy and able_to_buy_boats end - --- -- @TODO: prevent people from buying things whilst marooned - --- if can_buy then --- for k, v in pairs(trade_data.base_cost) do --- if k == 'fuel' then --- memory.stored_fuel = memory.stored_fuel - v * multiplier --- elseif k == 'coins' then --- inv.remove{name="coin", count=v * multiplier} --- elseif k == 'iron_plates' then --- inv.remove{name="iron-plate", count=v * multiplier} --- elseif k == 'copper_plates' then --- inv.remove{name="copper-plate", count=v * multiplier} --- end --- end - --- local force = memory.force --- if not (force and force.valid) then return end - --- local gotamount --- if purchase_name == 'uranium_ore' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/uranium-238'] --- Common.give(player, {{name = 'uranium-238', count = gotamount}}) --- Common.notify_force_light(force,string.format('%s is buying green rocks...', player.name)) - --- elseif purchase_name == 'extra_time' then --- local success = Crew.try_add_extra_time_at_sea(60 * 60) --- if success then --- Common.notify_force_light(force,string.format('%s is buying extra time at sea...', player.name)) --- else --- Common.notify_player_error(player, string.format('Purchase error: Can\'t buy more time than this.', player.name)) --- -- refund: --- memory.stored_fuel = memory.stored_fuel + trade_data.base_cost.fuel * multiplier --- end - --- elseif purchase_name == 'rail_signal' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/rail-signal'] --- Common.give(player, {{name = 'rail-signal', count = gotamount}}) --- Common.notify_force_light(force,string.format('%s is buying signals...', player.name)) - --- elseif purchase_name == 'artillery_shell' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/artillery-shell'] --- Common.give(player, {{name = 'artillery-shell', count = gotamount}}) --- Common.notify_force_light(force,string.format('%s is buying cannon shells...', player.name)) - --- elseif purchase_name == 'artillery_remote' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/artillery-targeting-remote'] --- Common.give(player, {{name = 'artillery-targeting-remote', count = gotamount}}) --- Common.notify_force_light(force,string.format('%s is buying an artillery targeting remote...', player.name)) - --- elseif purchase_name == 'new_boat_cutter' or purchase_name == 'new_boat_cutter_with_hold' or purchase_name == 'new_boat_sloop_with_hold' then --- Dock.execute_boat_purchase() --- Common.notify_force(force,string.format('[font=heading-1]%s bought a %s.[/font]', player.name, Boats[Common.current_destination().static_params.boat_for_sale_type].Data.display_name)) - --- elseif purchase_name == 'repair_cannons' then --- -- heal all cannons: --- local cannons = game.surfaces[destination.surface_name].find_entities_filtered({type = 'artillery-turret'}) --- for _, c in pairs(cannons) do --- local unit_number = c.unit_number - --- local healthbar = memory.healthbars[unit_number] --- if _DEBUG then game.print(unit_number) end --- if healthbar then --- healthbar.health = healthbar.max_health --- Public.update_healthbar_rendering(healthbar, healthbar.max_health) --- end --- end --- Common.notify_force(force,string.format('[font=heading-1]%s repaired the cannons.[/font]', player.name)) --- memory.mainshop_availability_bools[purchase_name] = false - --- elseif purchase_name == Upgrades.enum.MORE_POWER then --- Upgrades.execute_upgade(Upgrades.enum.MORE_POWER) --- memory.mainshop_availability_bools[purchase_name] = false - --- elseif purchase_name == Upgrades.enum.EXTRA_HOLD then --- Upgrades.execute_upgade(Upgrades.enum.EXTRA_HOLD) --- memory.mainshop_availability_bools[purchase_name] = false - --- elseif purchase_name == Upgrades.enum.UNLOCK_MERCHANTS then --- Upgrades.execute_upgade(Upgrades.enum.UNLOCK_MERCHANTS) --- memory.mainshop_availability_bools[purchase_name] = false - --- elseif purchase_name == Upgrades.enum.ROCKETS_FOR_SALE then --- Upgrades.execute_upgade(Upgrades.enum.ROCKETS_FOR_SALE) --- memory.mainshop_availability_bools[purchase_name] = false - --- elseif purchase_name == 'sell_iron' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/coal'] --- Common.give(player, {{name = 'fuel', count = gotamount}}) --- Common.notify_force_light(force,string.format('%s is selling iron...', player.name)) - --- elseif purchase_name == 'buy_iron' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/iron-plate'] --- Common.give_items_to_crew{{name = 'iron-plate', count = gotamount}} --- Common.notify_force_light(force,string.format('%s is buying iron...', player.name)) - --- elseif purchase_name == 'buy_copper' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/copper-plate'] --- Common.give_items_to_crew{{name = 'copper-plate', count = gotamount}} --- Common.notify_force_light(force,string.format('%s is buying copper...', player.name)) - --- -- elseif name == 'buy_fast_loader' then --- -- gotamount = trade_data.what_you_get_sprite_buttons['item/fast-loader'] --- -- Common.give(player, {{name = 'fast-loader', count = gotamount}}) --- -- Common.notify_force_light(force,string.format('%s bought a fast loader...', player.name)) - --- elseif purchase_name == 'sell_copper' then --- gotamount = trade_data.what_you_get_sprite_buttons['item/coal'] --- Common.give(player, {{name = 'fuel', count = gotamount}}) --- Common.notify_force_light(force,string.format('%s is selling copper...', player.name)) - --- end - --- script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {}) - --- -- memory.mainshop_rate_limit_ticker = Common.mainshop_rate_limit_ticks --- else --- -- play sound? --- if rate_limit_ok == false then --- Common.notify_player_error(player, 'Purchase error: Shop rate limit exceeded.') --- end --- if enough_fuel == false then --- Common.notify_player_error(player, 'Purchase error: Not enough stored fuel.') --- end --- if enough_coins == false then --- Common.notify_player_error(player, 'Purchase error: Not enough doubloons.') --- end --- if enough_iron_plates == false then --- Common.notify_player_error(player, 'Purchase error: Not enough iron plates.') --- end --- if enough_copper_plates == false then --- Common.notify_player_error(player, 'Purchase error: Not enough copper plates.') --- end - --- if (purchase_name == 'new_boat_cutter' or purchase_name == 'new_boat_sloop_with_hold' or purchase_name == 'new_boat_cutter_with_hold') and (not able_to_buy_boats) then --- Common.notify_player_error(player, 'Purchase error: Not able to purchase ships right now.') --- end --- end --- end - -return Public diff --git a/maps/pirates/shop/covered.lua b/maps/pirates/shop/covered.lua index 5a01584c..51d2e6d4 100644 --- a/maps/pirates/shop/covered.lua +++ b/maps/pirates/shop/covered.lua @@ -13,7 +13,7 @@ local Utils = require 'maps.pirates.utils_local' local Math = require 'maps.pirates.math' local _inspect = require 'utils.inspect'.inspect --- local Upgrades = require 'maps.pirates.boat_upgrades' +-- local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Public = {} @@ -26,7 +26,7 @@ Public.offers_loaders = { } Public.offers_rockets = { - { price = { { 'coin', 250 }, { 'electronic-circuit', 80 } }, offer = { type = 'give-item', item = 'rocket-launcher', count = 1 } }, + { price = { { 'coin', 250 }, { 'electronic-circuit', 80 } }, offer = { type = 'give-item', item = 'rocket-launcher', count = 1 } }, { price = { { 'coin', 1200 }, { 'explosives', 20 }, { 'electronic-circuit', 20 } }, offer = { type = 'give-item', item = 'rocket', count = 20 } }, } @@ -34,19 +34,19 @@ Public.offers_default = { { price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'copper-plate', count = 300 } }, { price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'iron-plate', count = 300 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine', count = 60 } }, - { price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'heavy-armor', count = 1 } }, + { price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'heavy-armor', count = 1 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'grenade', count = 30 } }, { price = { { 'coin', 1200 } }, offer = { type = 'give-item', item = 'defender-capsule', count = 15 } }, { price = { { 'coin', 1500 } }, offer = { type = 'give-item', item = 'distractor-capsule', count = 15 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'slowdown-capsule', count = 25 } }, { price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'poison-capsule', count = 15 } }, { price = { { 'coin', 1400 } }, offer = { type = 'give-item', item = 'gate', count = 25 } }, - { price = { { 'coin', 800 } }, offer = { type = 'give-item', item = 'storage-tank', count = 20 } }, - { price = { { 'coin', 600 } }, offer = { type = 'give-item', item = 'big-electric-pole', count = 15 } }, - { price = { { 'coin', 850 } }, offer = { type = 'give-item', item = 'stack-inserter', count = 7 } }, - { price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 15 } }, - { price = { { 'coin', 960 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } }, - { price = { { 'coin', 980 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } }, + { price = { { 'coin', 800 } }, offer = { type = 'give-item', item = 'storage-tank', count = 20 } }, + { price = { { 'coin', 600 } }, offer = { type = 'give-item', item = 'big-electric-pole', count = 15 } }, + { price = { { 'coin', 850 } }, offer = { type = 'give-item', item = 'stack-inserter', count = 7 } }, + { price = { { 'coin', 900 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 15 } }, + { price = { { 'coin', 960 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } }, + { price = { { 'coin', 980 } }, offer = { type = 'give-item', item = 'flamethrower', count = 1 } }, { price = { { 'coin', 1700 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 15 } }, { price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 20 } }, { price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flying-robot-frame', count = 5 } }, diff --git a/maps/pirates/shop/dock.lua b/maps/pirates/shop/dock.lua index 874adfe8..333c1631 100644 --- a/maps/pirates/shop/dock.lua +++ b/maps/pirates/shop/dock.lua @@ -12,10 +12,10 @@ local Balance = require 'maps.pirates.balance' local Common = require 'maps.pirates.common' local Utils = require 'maps.pirates.utils_local' local Math = require 'maps.pirates.math' -local Upgrades = require 'maps.pirates.boat_upgrades' +local Upgrades = require 'maps.pirates.shop.boat_upgrades' local _inspect = require 'utils.inspect'.inspect --- local Upgrades = require 'maps.pirates.boat_upgrades' +-- local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Public = {} @@ -23,67 +23,67 @@ local Public = {} Public.market_barters = { - { price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, + { price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, { price = { { 'copper-plate', 300 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, --repeating these: - { price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, + { price = { { 'iron-plate', 300 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, { price = { { 'copper-plate', 300 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, - { price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, - { price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, - { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'coal', count = 500 } }, - { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'iron-plate', count = 750 } }, - { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'copper-plate', count = 750 } }, - { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'steel-plate', count = 150 } }, - { price = { { 'wood', 200 } }, offer = { type = 'give-item', item = 'coin', count = 360 } }, - { price = { { 'wood', 150 } }, offer = { type = 'give-item', item = 'coal', count = 150 } }, - { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, - { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, - { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'steel-plate', count = 160 } }, + { price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, + { price = { { 'steel-plate', 40 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, + { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'coal', count = 500 } }, + { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'iron-plate', count = 750 } }, + { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'copper-plate', count = 750 } }, + { price = { { 'raw-fish', 80 } }, offer = { type = 'give-item', item = 'steel-plate', count = 150 } }, + { price = { { 'wood', 200 } }, offer = { type = 'give-item', item = 'coin', count = 360 } }, + { price = { { 'wood', 150 } }, offer = { type = 'give-item', item = 'coal', count = 150 } }, + { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'iron-plate', count = 500 } }, + { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'copper-plate', count = 500 } }, + { price = { { 'stone-brick', 200 } }, offer = { type = 'give-item', item = 'steel-plate', count = 160 } }, } -- permanent means you can buy more than once (but only some items???) Public.market_permanent_offers = { - { price = { { 'pistol', 1 } }, offer = { type = 'give-item', item = 'coin', count = Balance.coin_sell_amount } }, - { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'iron-ore', count = 800 } }, - { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'copper-ore', count = 800 } }, - { price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'crude-oil-barrel', count = 100 } }, - { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'fast-loader', count = 1 } }, - { price = { { 'coin', 6200 } }, offer = { type = 'give-item', item = 'beacon', count = 2 } }, - { price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'speed-module-2', count = 2 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'explosives', count = 50 } }, + { price = { { 'pistol', 1 } }, offer = { type = 'give-item', item = 'coin', count = Balance.coin_sell_amount } }, + { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'iron-ore', count = 800 } }, + { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'copper-ore', count = 800 } }, + { price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'crude-oil-barrel', count = 100 } }, + { price = { { 'coin', 3600 } }, offer = { type = 'give-item', item = 'fast-loader', count = 1 } }, + { price = { { 'coin', 6200 } }, offer = { type = 'give-item', item = 'beacon', count = 2 } }, + { price = { { 'coin', 4200 } }, offer = { type = 'give-item', item = 'speed-module-2', count = 2 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'explosives', count = 50 } }, { price = { { 'coin', 6500 }, { 'steel-plate', 25 }, { 'explosives', 50 } }, offer = { type = 'give-item', item = 'land-mine', count = 100 } }, -- {price = {{'coin', 30000}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}}, } -- cheap but one-off Public.market_sales = { - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coal', count = 900 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine', count = 75 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine', count = 20 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 50 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'raw-fish', count = 300 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'laser-turret', count = 1 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 2 } }, - { price = { { 'coin', 6000 } }, offer = { type = 'give-item', item = 'modular-armor', count = 1 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'distractor-capsule', count = 20 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'poison-capsule', count = 20 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'slowdown-capsule', count = 20 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coin', count = 6000 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'roboport', count = 1 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'construction-robot', count = 10 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-chest-passive-provider', count = 2 } }, - { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-robot', count = 2 } }, - { price = { { 'transport-belt', 100 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-transport-belt', count = 100 } }, - { price = { { 'fast-transport-belt', 100 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-transport-belt', count = 100 } }, - { price = { { 'underground-belt', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-underground-belt', count = 10 } }, - { price = { { 'fast-underground-belt', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-underground-belt', count = 10 } }, - { price = { { 'splitter', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-splitter', count = 10 } }, - { price = { { 'fast-splitter', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-splitter', count = 10 } }, - { price = { { 'pistol', 1 }, { 'coin', 300 } }, offer = { type = 'give-item', item = 'submachine-gun', count = 1 } }, - { price = { { 'submachine-gun', 1 }, { 'coin', 1000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 1 } }, - { price = { { 'shotgun', 1 }, { 'coin', 3500 } }, offer = { type = 'give-item', item = 'combat-shotgun', count = 1 } }, - { price = { { 'shotgun-shell', 100 }, { 'coin', 2000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 100 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coal', count = 900 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine', count = 75 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine', count = 20 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 50 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'raw-fish', count = 300 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'laser-turret', count = 1 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 2 } }, + { price = { { 'coin', 6000 } }, offer = { type = 'give-item', item = 'modular-armor', count = 1 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'distractor-capsule', count = 20 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'poison-capsule', count = 20 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'slowdown-capsule', count = 20 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coin', count = 6000 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'roboport', count = 1 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'construction-robot', count = 10 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-chest-passive-provider', count = 2 } }, + { price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-robot', count = 2 } }, + { price = { { 'transport-belt', 100 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-transport-belt', count = 100 } }, + { price = { { 'fast-transport-belt', 100 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-transport-belt', count = 100 } }, + { price = { { 'underground-belt', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-underground-belt', count = 10 } }, + { price = { { 'fast-underground-belt', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-underground-belt', count = 10 } }, + { price = { { 'splitter', 10 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-splitter', count = 10 } }, + { price = { { 'fast-splitter', 10 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-splitter', count = 10 } }, + { price = { { 'pistol', 1 }, { 'coin', 300 } }, offer = { type = 'give-item', item = 'submachine-gun', count = 1 } }, + { price = { { 'submachine-gun', 1 }, { 'coin', 1000 } }, offer = { type = 'give-item', item = 'vehicle-machine-gun', count = 1 } }, + { price = { { 'shotgun', 1 }, { 'coin', 3500 } }, offer = { type = 'give-item', item = 'combat-shotgun', count = 1 } }, + { price = { { 'shotgun-shell', 100 }, { 'coin', 2000 } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell', count = 100 } }, { price = { { 'piercing-rounds-magazine', 100 }, { 'coin', 3500 } }, offer = { type = 'give-item', item = 'uranium-rounds-magazine', count = 100 } }, } @@ -162,7 +162,7 @@ function Public.create_dock_markets(surface, p) local upgrade_for_sale = Common.current_destination().static_params.upgrade_for_sale if upgrade_for_sale then - e.add_market_item(Upgrades.market_offer_form[upgrade_for_sale]) + e.add_market_item(Upgrades.upgrades_data[upgrade_for_sale].market_item) end destination.dynamic_data.dock_captains_market = e diff --git a/maps/pirates/shop/shop.lua b/maps/pirates/shop/shop.lua index a6da1da4..b591a3ac 100644 --- a/maps/pirates/shop/shop.lua +++ b/maps/pirates/shop/shop.lua @@ -14,12 +14,11 @@ local Roles = require 'maps.pirates.roles.roles' local Math = require 'maps.pirates.math' local _inspect = require 'utils.inspect'.inspect local SurfacesCommon = require 'maps.pirates.surfaces.common' -local Upgrades = require 'maps.pirates.boat_upgrades' +local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Cabin = require 'maps.pirates.surfaces.cabin' --- local Upgrades = require 'maps.pirates.boat_upgrades' +-- local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Public = {} -Public.Captains = require 'maps.pirates.shop.captains' Public.Covered = require 'maps.pirates.shop.covered' Public.Merchants = require 'maps.pirates.shop.merchants' Public.Minimarket = require 'maps.pirates.shop.dock' diff --git a/maps/pirates/surfaces/dock.lua b/maps/pirates/surfaces/dock.lua index 72f174c1..bd40e9ce 100644 --- a/maps/pirates/surfaces/dock.lua +++ b/maps/pirates/surfaces/dock.lua @@ -75,8 +75,6 @@ function Public.execute_boat_purchase() -- memory.mainshop_availability_bools.new_boat_cutter_with_hold = false -- memory.mainshop_availability_bools.new_boat_sloop_with_hold = false -- memory.mainshop_availability_bools.new_boat_cutter = false - - script.raise_event(CustomEvents.enum['update_crew_fuel_gui'], {}) end function Public.place_dock_jetty_and_boats() From a31c1c5a10fce4f404e022a54fc42ee3ad4c4c1f Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 21:37:12 +0100 Subject: [PATCH 31/50] remove events system --- maps/pirates/api_on_tick.lua | 2 +- maps/pirates/commands.lua | 3 +- maps/pirates/custom_events.lua | 15 -------- maps/pirates/gui/gui.lua | 36 ++----------------- maps/pirates/main.lua | 1 - maps/pirates/ores.lua | 4 +-- maps/pirates/overworld.lua | 6 ++-- maps/pirates/progression.lua | 6 ++-- .../quest_structures/furnace1/furnace1.lua | 2 +- .../quest_structures/market1/market1.lua | 2 +- .../quest_structures/quest_structures.lua | 2 +- maps/pirates/surfaces/crowsnest.lua | 4 +-- maps/pirates/surfaces/dock.lua | 2 +- 13 files changed, 14 insertions(+), 71 deletions(-) delete mode 100644 maps/pirates/custom_events.lua diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index 648824ab..af02fb0e 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -27,7 +27,7 @@ local Crew = require 'maps.pirates.crew' local Math = require 'maps.pirates.math' local _inspect = require 'utils.inspect'.inspect local Kraken = require 'maps.pirates.surfaces.sea.kraken' -local CustomEvents = require 'maps.pirates.custom_events' + local Quest = require 'maps.pirates.quest' -- local ShopDock = require 'maps.pirates.shop.dock' diff --git a/maps/pirates/commands.lua b/maps/pirates/commands.lua index e32b3ae4..52fb293f 100644 --- a/maps/pirates/commands.lua +++ b/maps/pirates/commands.lua @@ -29,7 +29,7 @@ local simplex_noise = require 'utils.simplex_noise'.d2 local Token = require 'utils.token' local Task = require 'utils.task' local Highscore = require 'maps.pirates.highscore' -local CustomEvents = require 'maps.pirates.custom_events' + local Classes = require 'maps.pirates.roles.classes' local Gui = require 'maps.pirates.gui.gui' -- local Session = require 'utils.datastore.session_data' @@ -616,7 +616,6 @@ if _DEBUG then end memory.currentdestination_index = memory.mapbeingloadeddestination_index - script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) Surfaces.create_surface(Common.current_destination()) Task.set_timeout_in_ticks(60, go_2, { id = data.id }) end diff --git a/maps/pirates/custom_events.lua b/maps/pirates/custom_events.lua deleted file mode 100644 index 7e09c4d3..00000000 --- a/maps/pirates/custom_events.lua +++ /dev/null @@ -1,15 +0,0 @@ --- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates. - - -local Event = require 'utils.event' - -local Public = {} - --- just beginning this, gotta finish reformulating the gui updates in terms of events: - -local enum = { - update_crew_progress_gui = Event.generate_event_name('update_crew_progress_gui'), -} -Public.enum = enum - -return Public diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index 60bf8950..5baf8e9b 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -24,7 +24,7 @@ local Progression = require 'maps.pirates.progression' local Surfaces = require 'maps.pirates.surfaces.surfaces' local Roles = require 'maps.pirates.roles.roles' local Event = require 'utils.event' -local CustomEvents = require 'maps.pirates.custom_events' + local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' local Kraken = require 'maps.pirates.surfaces.sea.kraken' local GuiWelcome = require 'maps.pirates.gui.welcome' @@ -33,19 +33,8 @@ local ComfyGui = require 'utils.gui' ComfyGui.set_disabled_tab('Scoreboard', true) ComfyGui.set_disabled_tab('Groups', true) - local Public = {} --- this seems to be never used -local enum = { - PROGRESS = 'progress', - RUNS = 'runs', - CREW = 'crew', - CLASSES = 'classes', - MINIMAP = 'minimap', - INFO = 'info', - COLOR = 'color', -} -Public.enum = enum + Public.progress = require 'maps.pirates.gui.progress' Public.runs = require 'maps.pirates.gui.runs' Public.crew = require 'maps.pirates.gui.crew' @@ -54,23 +43,6 @@ Public.minimap = require 'maps.pirates.gui.minimap' Public.info = require 'maps.pirates.gui.info' Public.color = require 'maps.pirates.gui.color' - -function Public.update_crew_gui(which_gui) - if not Public[which_gui] then return end - - local players = Common.crew_get_crew_members_and_spectators() - - for _, player in pairs(players) do - Public[which_gui].full_update(player) - end -end - -function Public.update_crew_progress_gui() - return Public.update_crew_gui('progress') -end - -Event.add(CustomEvents.enum['update_crew_progress_gui'], Public.update_crew_progress_gui) - local function create_gui(player) local flow1, flow2, flow3, flow4 @@ -1277,12 +1249,8 @@ local function on_gui_location_changed(event) end - - local event = require 'utils.event' event.add(defines.events.on_gui_click, on_gui_click) event.add(defines.events.on_gui_location_changed, on_gui_location_changed) - - return Public diff --git a/maps/pirates/main.lua b/maps/pirates/main.lua index 67785171..96def92c 100644 --- a/maps/pirates/main.lua +++ b/maps/pirates/main.lua @@ -24,7 +24,6 @@ The scenario is quite complex, but there are ways to get started, even if you do -- require 'modules.biters_yield_coins' require 'modules.biter_noms_you' require 'modules.no_deconstruction_of_neutral_entities' -require 'maps.pirates.custom_events' --probably do this before anything else require 'utils.server' local _inspect = require 'utils.inspect'.inspect -- local Modifers = require 'player_modifiers' diff --git a/maps/pirates/ores.lua b/maps/pirates/ores.lua index d65b1017..5c3dcbf0 100644 --- a/maps/pirates/ores.lua +++ b/maps/pirates/ores.lua @@ -9,7 +9,7 @@ local _inspect = require 'utils.inspect'.inspect local Common = require 'maps.pirates.common' local Utils = require 'maps.pirates.utils_local' local simplex_noise = require 'utils.simplex_noise'.d2 --- local CustomEvents = require 'maps.pirates.custom_events' +-- local Public = {} @@ -151,8 +151,6 @@ function Public.try_ore_spawn(surface, realp, source_name, density_bonus, from_t end end - -- script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) - return ret end diff --git a/maps/pirates/overworld.lua b/maps/pirates/overworld.lua index 957cc7fc..3f31d66f 100644 --- a/maps/pirates/overworld.lua +++ b/maps/pirates/overworld.lua @@ -25,11 +25,11 @@ local Crew = require 'maps.pirates.crew' -- local Parrot = require 'maps.pirates.parrot' -- local Hold = require 'maps.pirates.surfaces.hold' -- local Cabin = require 'maps.pirates.surfaces.cabin' -local Shop = require 'maps.pirates.shop.shop' +-- local Shop = require 'maps.pirates.shop.shop' local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Kraken = require 'maps.pirates.surfaces.sea.kraken' local Highscore = require 'maps.pirates.highscore' -local CustomEvents = require 'maps.pirates.custom_events' + local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' @@ -591,8 +591,6 @@ function Public.check_for_destination_collisions() memory.currentdestination_index = index memory.boat.state = Boats.enum_state.ATSEA_LOADING_MAP - script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) - local destination = Common.current_destination() Surfaces.destination_on_collide(destination) diff --git a/maps/pirates/progression.lua b/maps/pirates/progression.lua index 6c531a9d..55bd2d68 100644 --- a/maps/pirates/progression.lua +++ b/maps/pirates/progression.lua @@ -10,7 +10,7 @@ local Common = require 'maps.pirates.common' local CoreData = require 'maps.pirates.coredata' local Utils = require 'maps.pirates.utils_local' local _inspect = require 'utils.inspect'.inspect -local CustomEvents = require 'maps.pirates.custom_events' + -- local Structures = require 'maps.pirates.structures.structures' local Boats = require 'maps.pirates.structures.boats.boats' @@ -25,7 +25,7 @@ local Roles = require 'maps.pirates.roles.roles' -- local Parrot = require 'maps.pirates.parrot' -- local Quest = require 'maps.pirates.quest' -local Shop = require 'maps.pirates.shop.shop' +-- local Shop = require 'maps.pirates.shop.shop' local Overworld = require 'maps.pirates.overworld' local Hold = require 'maps.pirates.surfaces.hold' local Cabin = require 'maps.pirates.surfaces.cabin' @@ -305,8 +305,6 @@ function Public.progress_to_destination(destination_index) memory.currentdestination_index = destination_index --already done when we collide with it typically local destination = Common.current_destination() - script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) - destination.dynamic_data.timer = 0 destination.dynamic_data.timeratlandingtime = nil destination.dynamic_data.enemyboats = {} diff --git a/maps/pirates/structures/quest_structures/furnace1/furnace1.lua b/maps/pirates/structures/quest_structures/furnace1/furnace1.lua index 795c5f12..35576353 100644 --- a/maps/pirates/structures/quest_structures/furnace1/furnace1.lua +++ b/maps/pirates/structures/quest_structures/furnace1/furnace1.lua @@ -8,7 +8,7 @@ local Common = require 'maps.pirates.common' -- local CoreData = require 'maps.pirates.coredata' -- local Utils = require 'maps.pirates.utils_local' local _inspect = require 'utils.inspect'.inspect --- local CustomEvents = require 'maps.pirates.custom_events' +-- -- local SurfacesCommon = require 'maps.pirates.surfaces.common' local Raffle = require 'maps.pirates.raffle' local ShopCovered = require 'maps.pirates.shop.covered' diff --git a/maps/pirates/structures/quest_structures/market1/market1.lua b/maps/pirates/structures/quest_structures/market1/market1.lua index 94705336..130b2e23 100644 --- a/maps/pirates/structures/quest_structures/market1/market1.lua +++ b/maps/pirates/structures/quest_structures/market1/market1.lua @@ -8,7 +8,7 @@ local Common = require 'maps.pirates.common' -- local CoreData = require 'maps.pirates.coredata' -- local Utils = require 'maps.pirates.utils_local' local _inspect = require 'utils.inspect'.inspect --- local CustomEvents = require 'maps.pirates.custom_events' +-- -- local SurfacesCommon = require 'maps.pirates.surfaces.common' local Raffle = require 'maps.pirates.raffle' local ShopCovered = require 'maps.pirates.shop.covered' diff --git a/maps/pirates/structures/quest_structures/quest_structures.lua b/maps/pirates/structures/quest_structures/quest_structures.lua index 672bd6b8..07aee3b2 100644 --- a/maps/pirates/structures/quest_structures/quest_structures.lua +++ b/maps/pirates/structures/quest_structures/quest_structures.lua @@ -8,7 +8,7 @@ local Common = require 'maps.pirates.common' local CoreData = require 'maps.pirates.coredata' local Utils = require 'maps.pirates.utils_local' local _inspect = require 'utils.inspect'.inspect --- local CustomEvents = require 'maps.pirates.custom_events' +-- local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' -- local Raffle = require 'maps.pirates.raffle' -- local ShopCovered = require 'maps.pirates.shop.covered' diff --git a/maps/pirates/surfaces/crowsnest.lua b/maps/pirates/surfaces/crowsnest.lua index 6046094c..a7d1ae0a 100644 --- a/maps/pirates/surfaces/crowsnest.lua +++ b/maps/pirates/surfaces/crowsnest.lua @@ -7,7 +7,7 @@ local Common = require 'maps.pirates.common' local CoreData = require 'maps.pirates.coredata' local Utils = require 'maps.pirates.utils_local' -- local Math = require 'maps.pirates.math' -local CustomEvents = require 'maps.pirates.custom_events' + local _inspect = require 'utils.inspect'.inspect local Token = require 'utils.token' @@ -119,8 +119,6 @@ function Public.move_crowsnest(vectorx, vectory) -- crew_force.clear_chart(surface) crew_force.chart(surface, area) end - - script.raise_event(CustomEvents.enum['update_crew_progress_gui'], {}) end function Public.update_destination_renderings() diff --git a/maps/pirates/surfaces/dock.lua b/maps/pirates/surfaces/dock.lua index bd40e9ce..eada911f 100644 --- a/maps/pirates/surfaces/dock.lua +++ b/maps/pirates/surfaces/dock.lua @@ -12,7 +12,7 @@ local Cabin = require 'maps.pirates.surfaces.cabin' local CoreData = require 'maps.pirates.coredata' local Utils = require 'maps.pirates.utils_local' local _inspect = require 'utils.inspect'.inspect -local CustomEvents = require 'maps.pirates.custom_events' + local Public = {} From e7fa32ab2fd7c376202388c0cbc05b310ca3182e Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 21:59:25 +0100 Subject: [PATCH 32/50] fix selecting runs --- locale/en/pirates.cfg | 2 +- maps/pirates/gui/runs.lua | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 3de6134a..253af2fc 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -403,7 +403,7 @@ highscore_heading_version=Version highscore_heading_difficulty=Difficulty highscore_heading_peak_players=PeakPlayers - +second_element=__2__ run_condition_private=, private run_condition_captain_protected=, cap'n-protected run_condition_blueprints_disabled=, BPs disabled diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index 46faab4f..c0c365d4 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -558,7 +558,7 @@ function Public.full_update(player) count = #mem.crewplayerindices end - wrappedmemories[#wrappedmemories + 1] = { '', + wrappedmemories[#wrappedmemories + 1] = { 'pirates.second_element', mem.id, { '', mem.name .. " (" .. count .. (count == 1 and ' player' or ' players') .. ") — ", '[item=', CoreData.difficulty_options[mem.difficulty_option].icon, '], ', -- Utils.spritepath_to_richtext(CoreData.capacity_options[mem.capacity_option].icon) .. ", ", @@ -567,6 +567,7 @@ function Public.full_update(player) mem.run_is_private and { 'pirates.run_condition_private' } or '', mem.run_is_protected and { 'pirates.run_condition_captain_protected' } or '', mem.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '' + }, } end GuiCommon.update_listbox(flow.ongoing_runs.body.ongoing_runs_listbox, wrappedmemories) From ab89eb9467f00a938d4852e0b8dc53aae5bf86aa Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 22:13:31 +0100 Subject: [PATCH 33/50] clean up gui/runs --- maps/pirates/gui/progress.lua | 24 ++--- maps/pirates/gui/runs.lua | 196 +++++++++++++--------------------- 2 files changed, 89 insertions(+), 131 deletions(-) diff --git a/maps/pirates/gui/progress.lua b/maps/pirates/gui/progress.lua index a900d820..33964e46 100644 --- a/maps/pirates/gui/progress.lua +++ b/maps/pirates/gui/progress.lua @@ -17,14 +17,16 @@ local Public = {} local window_name = 'progress' function Public.toggle_window(player) - - if player.gui.screen[window_name .. '_piratewindow'] then player.gui.screen[window_name .. '_piratewindow'].destroy() return end + if player.gui.screen[window_name .. '_piratewindow'] then + player.gui.screen[window_name .. '_piratewindow'].destroy() + return + end local flow, flow2, flow3 flow = GuiCommon.new_window(player, window_name) - flow.caption = {'pirates.gui_progress'} + flow.caption = { 'pirates.gui_progress' } - flow2 = GuiCommon.flow_add_section(flow, 'distance_travelled', {'pirates.gui_progress_distance_travelled'}) + flow2 = GuiCommon.flow_add_section(flow, 'distance_travelled', { 'pirates.gui_progress_distance_travelled' }) flow3 = flow2.add({ name = 'leagues', @@ -37,7 +39,7 @@ function Public.toggle_window(player) flow3.style.maximal_width = 160 flow3.style.font = 'default-dropdown' - flow2 = GuiCommon.flow_add_section(flow, 'current_location', {'pirates.gui_progress_current_location', ''}) + flow2 = GuiCommon.flow_add_section(flow, 'current_location', { 'pirates.gui_progress_current_location', '' }) -- flow3 = flow2.add({ -- name = 'location_name', @@ -67,7 +69,7 @@ function Public.toggle_window(player) -- flow3 = flow2.add({type = 'label', name = 'patch_size', caption = ''}) -- flow3.style.top_margin = -3 - flow3 = flow2.add({type = 'label', name = 'daynight', caption = ''}) + flow3 = flow2.add({ type = 'label', name = 'daynight', caption = '' }) flow3.style.top_margin = -3 @@ -84,7 +86,6 @@ function Public.toggle_window(player) return nil end - -- function Public.regular_update(player) -- end @@ -109,8 +110,8 @@ function Public.full_update(player) name = Lobby.Data.display_name end - flow.current_location.header.caption = {'pirates.gui_progress_current_location', name} - flow.distance_travelled.body.leagues.caption = {'pirates.gui_progress_leagues', memory.overworldx or 0} + flow.current_location.header.caption = { 'pirates.gui_progress_current_location', name } + flow.distance_travelled.body.leagues.caption = { 'pirates.gui_progress_leagues', memory.overworldx or 0 } -- local daynighttype -- if destination.static_params and destination.static_params.daynightcycletype then @@ -145,7 +146,7 @@ function Public.full_update(player) -- flow.current_location.body.daynight.visible = false -- end local daynightcycletype = destination.static_params.daynightcycletype or 1 - flow.current_location.body.daynight.caption = {'pirates.gui_progress_time_of_day', CoreData.daynightcycle_types[daynightcycletype].displayname} + flow.current_location.body.daynight.caption = { 'pirates.gui_progress_time_of_day', CoreData.daynightcycle_types[daynightcycletype].displayname } -- local ores @@ -173,5 +174,4 @@ function Public.full_update(player) -- end end - -return Public \ No newline at end of file +return Public diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index c0c365d4..44254ae7 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -475,132 +475,81 @@ function Public.full_update(player) local global_memory = Memory.get_global_memory() local memory = Memory.get_crew_memory() - if not player.gui.screen['runs_piratewindow'] then return end - local flow = player.gui.screen['runs_piratewindow'].scroll_pane + local window = player.gui.screen['runs_piratewindow'] + if not window then return end + local flow = window.scroll_pane local playercrew_status = GuiCommon.crew_overall_state_bools(player.index) if not playercrew_status then return end + local ongoing_runs = flow.ongoing_runs + ongoing_runs.visible = (#global_memory.crew_active_ids > 0) - --*** WHAT TO SHOW ***-- - - flow.ongoing_runs.visible = (#global_memory.crew_active_ids > 0) - if flow.ongoing_runs.visible then - local bool1 = (not playercrew_status.leaving) and (not playercrew_status.adventuring) and (not playercrew_status.spectating) and (flow.ongoing_runs.body.ongoing_runs_listbox.selected_index ~= 0) - - local selected_joinable_bool = false - local crewid - if bool1 then - crewid = tonumber((flow.ongoing_runs.body.ongoing_runs_listbox.get_item(flow.ongoing_runs.body.ongoing_runs_listbox.selected_index))[2]) - selected_joinable_bool = bool1 and crewid ~= nil and global_memory.crew_memories[crewid] ~= nil and (global_memory.crew_memories[crewid].crewstatus == Crew.enum.ADVENTURING) - end - - flow.ongoing_runs.body.helpful_tip.visible = not (playercrew_status.leaving or playercrew_status.adventuring or playercrew_status.spectating) - - flow.ongoing_runs.body.flow_buttons.visible = selected_joinable_bool or playercrew_status.spectating - flow.ongoing_runs.body.flow_buttons.join_spectators.visible = selected_joinable_bool - flow.ongoing_runs.body.flow_buttons.leave_spectators.visible = playercrew_status.spectating - flow.ongoing_runs.body.flow_buttons.join_crew.visible = selected_joinable_bool and (not (crewid and global_memory.crew_memories[crewid] and (global_memory.crew_memories[crewid].crewstatus == Crew.enum.LEAVING_INITIAL_DOCK or #global_memory.crew_memories[crewid].crewplayerindices >= global_memory.crew_memories[crewid].capacity or (global_memory.crew_memories[crewid].tempbanned_from_joining_data and global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] and game.tick < global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks)))) - - flow.ongoing_runs.body.wait_to_join.visible = selected_joinable_bool and crewid and global_memory.crew_memories[crewid] and (global_memory.crew_memories[crewid].tempbanned_from_joining_data and global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] and game.tick < global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks) and (not (global_memory.crew_memories[crewid].crewstatus == Crew.enum.LEAVING_INITIAL_DOCK or #global_memory.crew_memories[crewid].crewplayerindices >= global_memory.crew_memories[crewid].capacity)) - if flow.ongoing_runs.body.wait_to_join.visible then - flow.ongoing_runs.body.wait_to_join.caption = { 'pirates.gui_runs_wait_to_join', Math.ceil(((global_memory.crew_memories[crewid].tempbanned_from_joining_data[player.index] - (game.tick - Common.ban_from_rejoining_crew_ticks))) / 60) } - end - - if not selected_joinable_bool then flow.ongoing_runs.body.ongoing_runs_listbox.selected_index = 0 end - - flow.ongoing_runs.body.leaving_prompt.visible = playercrew_status.leaving - - local show_protected_info = crewid and global_memory.crew_memories[crewid].run_is_protected and global_memory.crew_memories[crewid].protected_run_lock_timer < 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr - flow.ongoing_runs.body.join_protected_crew_info.visible = show_protected_info - - local show_private_info = crewid and global_memory.crew_memories[crewid].run_is_private - flow.ongoing_runs.body.join_private_crew_info.visible = show_private_info - flow.ongoing_runs.body.password.visible = show_private_info - end - - flow.proposals.visible = (memory.crewstatus == nil and not playercrew_status.leaving) - if flow.proposals.visible then - if playercrew_status.proposing then - flow.proposals.body.proposals_listbox.selected_index = 0 - flow.proposals.body.proposals_listbox.selected_index = 0 - end - - flow.proposals.body.proposals_listbox.visible = (not playercrew_status.leaving) and (#global_memory.crewproposals > 0) - - flow.proposals.body.flow_buttons.abandon_proposal.visible = (not playercrew_status.leaving) and playercrew_status.created_crew and playercrew_status.proposing and (#global_memory.crewproposals > 0) - - flow.proposals.body.proposal_maker.visible = (not playercrew_status.leaving) and (not playercrew_status.created_crew) - - flow.proposals.body.flow_proposal_launch.proposal_insufficient_sloops.visible = playercrew_status.sloops_full - - flow.proposals.body.flow_proposal_launch.proposal_crew_count_capped.visible = playercrew_status.crew_count_capped - - flow.proposals.body.flow_proposal_launch.launch_crew.visible = playercrew_status.proposal_can_launch - - local checkbox_state = flow.proposals.body.proposal_maker.body.settings.private_checkbox.state - flow.proposals.body.proposal_maker.body.settings.password_label.visible = checkbox_state - flow.proposals.body.proposal_maker.body.settings.password.visible = checkbox_state - flow.proposals.body.proposal_maker.body.settings.confirm_password_label.visible = checkbox_state - flow.proposals.body.proposal_maker.body.settings.confirm_password.visible = checkbox_state - end - - - - --*** UPDATE CONTENT ***-- - - if flow.ongoing_runs.visible then + if ongoing_runs.visible then local wrappedmemories = {} for _, mem in pairs(global_memory.crew_memories) do - local count = 0 - if mem.crewstatus and mem.crewstatus == Crew.enum.LEAVING_INITIAL_DOCK then - count = Boats.players_on_boat_count(mem.boat) - elseif mem.crewplayerindices then - count = #mem.crewplayerindices - end - - wrappedmemories[#wrappedmemories + 1] = { 'pirates.second_element', mem.id, { '', - mem.name .. " (" .. count .. (count == 1 and ' player' or ' players') .. ") — ", - '[item=', CoreData.difficulty_options[mem.difficulty_option].icon, '], ', - -- Utils.spritepath_to_richtext(CoreData.capacity_options[mem.capacity_option].icon) .. ", ", - '[item=rail]', - mem.overworldx or 0, - mem.run_is_private and { 'pirates.run_condition_private' } or '', - mem.run_is_protected and { 'pirates.run_condition_captain_protected' } or '', - mem.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '' - }, + local count = (mem.crewstatus == Crew.enum.LEAVING_INITIAL_DOCK) and Boats.players_on_boat_count(mem.boat) or #mem.crewplayerindices + local crew_info = { + 'pirates.second_element', + mem.id, + { '', mem.name .. " (" .. count .. (count == 1 and ' player' or ' players') .. ") — ", + '[item=', CoreData.difficulty_options[mem.difficulty_option].icon, '], ', + '[item=rail]', mem.overworldx or 0, + mem.run_is_private and { 'pirates.run_condition_private' } or '', + mem.run_is_protected and { 'pirates.run_condition_captain_protected' } or '', + mem.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '' } } + table.insert(wrappedmemories, crew_info) end - GuiCommon.update_listbox(flow.ongoing_runs.body.ongoing_runs_listbox, wrappedmemories) + GuiCommon.update_listbox(ongoing_runs.body.ongoing_runs_listbox, wrappedmemories) - local crewid = nil - local bool1 = (not playercrew_status.leaving) and (not playercrew_status.adventuring) and (not playercrew_status.spectating) and (flow.ongoing_runs.body.ongoing_runs_listbox.selected_index ~= 0) - if bool1 then - crewid = tonumber((flow.ongoing_runs.body.ongoing_runs_listbox.get_item(flow.ongoing_runs.body.ongoing_runs_listbox.selected_index))[2]) + local selected_index = ongoing_runs.body.ongoing_runs_listbox.selected_index + local selected_crew = selected_index ~= 0 and global_memory.crew_memories[tonumber(ongoing_runs.body.ongoing_runs_listbox.get_item(selected_index)[2])] + + if playercrew_status.leaving or playercrew_status.adventuring or playercrew_status.spectating then + selected_crew = false end - -- Update timer when captain protection expires - if crewid and flow.ongoing_runs.body.join_protected_crew_info.visible then - local lock_timer = global_memory.crew_memories[crewid].protected_run_lock_timer - local sec = Math.floor((lock_timer / (60)) % 60) - local min = Math.floor((lock_timer / (60 * 60)) % 60) - local hrs = Math.floor((lock_timer / (60 * 60 * 60)) % 60) - flow.ongoing_runs.body.join_protected_crew_info.caption = { 'pirates.gui_join_protected_run_info', hrs, min, sec } + local can_join = selected_crew and selected_crew.crewstatus == Crew.enum.ADVENTURING + + ongoing_runs.body.helpful_tip.visible = not (playercrew_status.leaving or playercrew_status.adventuring or playercrew_status.spectating) + ongoing_runs.body.flow_buttons.visible = can_join or playercrew_status.spectating + ongoing_runs.body.flow_buttons.join_spectators.visible = can_join + ongoing_runs.body.flow_buttons.leave_spectators.visible = playercrew_status.spectating + ongoing_runs.body.flow_buttons.join_crew.visible = can_join and selected_crew and not (selected_crew.crewstatus == Crew.enum.LEAVING_INITIAL_DOCK or #selected_crew.crewplayerindices >= selected_crew.capacity or (selected_crew.tempbanned_from_joining_data and selected_crew.tempbanned_from_joining_data[player.index] and game.tick < selected_crew.tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks)) + + local show_wait_message = can_join and selected_crew and selected_crew.tempbanned_from_joining_data and selected_crew.tempbanned_from_joining_data[player.index] and game.tick < selected_crew.tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks + ongoing_runs.body.wait_to_join.visible = show_wait_message + if show_wait_message then + local wait_time = selected_crew and Math.ceil((selected_crew.tempbanned_from_joining_data[player.index] - (game.tick - Common.ban_from_rejoining_crew_ticks)) / 60) or 0 + ongoing_runs.body.wait_to_join.caption = { 'pirates.gui_runs_wait_to_join', wait_time } end - -- Update timer when run will become public - if crewid and flow.ongoing_runs.body.join_private_crew_info.visible then - local lock_timer = global_memory.crew_memories[crewid].private_run_lock_timer - local sec = Math.floor((lock_timer / (60)) % 60) - local min = Math.floor((lock_timer / (60 * 60)) % 60) - local hrs = Math.floor((lock_timer / (60 * 60 * 60)) % 60) - flow.ongoing_runs.body.join_private_crew_info.caption = { 'pirates.gui_join_private_run_info', hrs, min, sec } + ongoing_runs.body.leaving_prompt.visible = playercrew_status.leaving + ongoing_runs.body.join_protected_crew_info.visible = selected_crew and selected_crew.run_is_protected and selected_crew.protected_run_lock_timer < 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr + ongoing_runs.body.join_private_crew_info.visible = selected_crew and selected_crew.run_is_private + ongoing_runs.body.password.visible = selected_crew and selected_crew.run_is_private + + if selected_crew then + if ongoing_runs.body.join_protected_crew_info.visible then + local lock_timer = selected_crew.protected_run_lock_timer + local hrs, min, sec = Math.floor((lock_timer / (60 * 60 * 60)) % 60), Math.floor((lock_timer / (60 * 60)) % 60), Math.floor((lock_timer / 60) % 60) + ongoing_runs.body.join_protected_crew_info.caption = { 'pirates.gui_join_protected_run_info', hrs, min, sec } + end + if ongoing_runs.body.join_private_crew_info.visible then + local lock_timer = selected_crew.private_run_lock_timer + local hrs, min, sec = Math.floor((lock_timer / (60 * 60 * 60)) % 60), Math.floor((lock_timer / (60 * 60)) % 60), Math.floor((lock_timer / 60) % 60) + ongoing_runs.body.join_private_crew_info.caption = { 'pirates.gui_join_private_run_info', hrs, min, sec } + end end end - if flow.proposals.visible then + local proposals = flow.proposals + proposals.visible = (memory.crewstatus == nil and not playercrew_status.leaving) + + if proposals.visible then local wrappedproposals = {} for _, proposal in pairs(global_memory.crewproposals) do - wrappedproposals[#wrappedproposals + 1] = { '', + local proposal_info = { '', proposal.name .. ' — ', '[item=rail]', 0, @@ -608,20 +557,29 @@ function Public.full_update(player) proposal.run_is_protected and { 'pirates.run_condition_captain_protected' } or '', proposal.run_has_blueprints_disabled and { 'pirates.run_condition_blueprints_disabled' } or '' } + table.insert(wrappedproposals, proposal_info) end - GuiCommon.update_listbox(flow.proposals.body.proposals_listbox, wrappedproposals) - end + GuiCommon.update_listbox(proposals.body.proposals_listbox, wrappedproposals) - -- update proposal maker - if flow.proposals.body.proposal_maker.visible then - local capacity_slider_value = flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.slider.slider_value - for i, opt in pairs(CoreData.capacity_options) do - if capacity_slider_value == i then - flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.readoff_text.caption = opt.text - flow.proposals.body.proposal_maker.body.capacity_options.capacity_readoff_icon.sprite = opt.icon - end + proposals.body.proposals_listbox.visible = not playercrew_status.leaving and #global_memory.crewproposals > 0 + proposals.body.flow_buttons.abandon_proposal.visible = not playercrew_status.leaving and playercrew_status.created_crew and playercrew_status.proposing and #global_memory.crewproposals > 0 + proposals.body.proposal_maker.visible = not playercrew_status.leaving and not playercrew_status.created_crew + proposals.body.flow_proposal_launch.proposal_insufficient_sloops.visible = playercrew_status.sloops_full + proposals.body.flow_proposal_launch.proposal_crew_count_capped.visible = playercrew_status.crew_count_capped + proposals.body.flow_proposal_launch.launch_crew.visible = playercrew_status.proposal_can_launch + + if proposals.body.proposal_maker.visible then + local capacity_slider = proposals.body.proposal_maker.body.capacity_options.capacity.capacity + local capacity_option = CoreData.capacity_options[capacity_slider.slider.slider_value] + capacity_slider.readoff_text.caption = capacity_option.text == '∞' and { 'pirates.gui_runs_proposal_maker_no_limit' } or capacity_option.text + proposals.body.proposal_maker.body.capacity_options.capacity_readoff_icon.sprite = capacity_option.icon + + local is_private = proposals.body.proposal_maker.body.settings.private_checkbox.state + proposals.body.proposal_maker.body.settings.password_label.visible = is_private + proposals.body.proposal_maker.body.settings.password.visible = is_private + proposals.body.proposal_maker.body.settings.confirm_password_label.visible = is_private + proposals.body.proposal_maker.body.settings.confirm_password.visible = is_private end - if flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.readoff_text.caption == '∞' then flow.proposals.body.proposal_maker.body.capacity_options.capacity.capacity.readoff_text.caption = { 'pirates.gui_runs_proposal_maker_no_limit' } end end end From ddb5a50ec3c64b2e054580e0540849a09f5f0aef Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 22:19:10 +0100 Subject: [PATCH 34/50] unused imports --- maps/pirates/api_events.lua | 2 +- maps/pirates/gui/common.lua | 2 +- maps/pirates/gui/gui.lua | 1 - maps/pirates/gui/runs.lua | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index 166da532..ef76c620 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -16,7 +16,7 @@ local Surfaces = require 'maps.pirates.surfaces.surfaces' -- local Progression = require 'maps.pirates.progression' local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' local Roles = require 'maps.pirates.roles.roles' -local Gui = require 'maps.pirates.gui.gui' +-- local Gui = require 'maps.pirates.gui.gui' -- local Sea = require 'maps.pirates.surfaces.sea.sea' -- local Hold = require 'maps.pirates.surfaces.hold' -- local Cabin = require 'maps.pirates.surfaces.cabin' diff --git a/maps/pirates/gui/common.lua b/maps/pirates/gui/common.lua index f64fb43b..4ddc68c6 100644 --- a/maps/pirates/gui/common.lua +++ b/maps/pirates/gui/common.lua @@ -11,7 +11,7 @@ local _inspect = require 'utils.inspect'.inspect local Crew = require 'maps.pirates.crew' -- local Progression = require 'maps.pirates.progression' -- local Structures = require 'maps.pirates.structures.structures' -local Shop = require 'maps.pirates.shop.shop' +-- local Shop = require 'maps.pirates.shop.shop' local Boats = require 'maps.pirates.structures.boats.boats' local Surfaces = require 'maps.pirates.surfaces.surfaces' diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index 5baf8e9b..15f33e35 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -23,7 +23,6 @@ local Crowsnest = require 'maps.pirates.surfaces.crowsnest' local Progression = require 'maps.pirates.progression' local Surfaces = require 'maps.pirates.surfaces.surfaces' local Roles = require 'maps.pirates.roles.roles' -local Event = require 'utils.event' local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' local Kraken = require 'maps.pirates.surfaces.sea.kraken' diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index 44254ae7..cb39fc43 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -3,7 +3,7 @@ local Memory = require 'maps.pirates.memory' local Common = require 'maps.pirates.common' local CoreData = require 'maps.pirates.coredata' -local Utils = require 'maps.pirates.utils_local' +-- local Utils = require 'maps.pirates.utils_local' local Math = require 'maps.pirates.math' -- local Surfaces = require 'maps.pirates.surfaces.surfaces' local Roles = require 'maps.pirates.roles.roles' From 7879de1ee998f48446f324931a615f9b000bb162 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 22:29:48 +0100 Subject: [PATCH 35/50] fix permission groups --- maps/pirates/roles/roles.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index d1a13eb2..1018c245 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -597,6 +597,7 @@ local function set_restricted_permissions(group) group.set_allows_action(defines.input_action.activate_paste, false) group.set_allows_action(defines.input_action.upgrade, false) group.set_allows_action(defines.input_action.deconstruct, false) + group.set_allows_action(defines.input_action.open_gui, false) group.set_allows_action(defines.input_action.fast_entity_transfer, false) group.set_allows_action(defines.input_action.fast_entity_split, false) end @@ -623,6 +624,7 @@ function Public.try_create_permissions_groups() set_restricted_permissions(group) group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + group.set_allows_action(defines.input_action.open_gui, true) group.set_allows_action(defines.input_action.fast_entity_transfer, true) group.set_allows_action(defines.input_action.fast_entity_split, true) end @@ -632,7 +634,7 @@ function Public.try_create_permissions_groups() group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players set_restricted_permissions(group) - -- Note there is other code to prevent these players from opening chests + group.set_allows_action(defines.input_action.open_gui, true) -- We want you to open the market, but there is other code to prevent you from opening certain chests end if not game.permissions.get_group('cabin_privileged') then @@ -640,7 +642,7 @@ function Public.try_create_permissions_groups() group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players set_restricted_permissions(group) - -- Note there is other code to prevent these players from opening chests + group.set_allows_action(defines.input_action.open_gui, true) -- We want you to open the market, but there is other code to prevent you from opening certain chests end if not game.permissions.get_group('plebs') then From 584161e2cab5b828287060872bc8f2502d8a0c73 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 22:48:22 +0100 Subject: [PATCH 36/50] Remove mainshop_availability_bools --- maps/pirates/progression.lua | 47 ---------------------------------- maps/pirates/surfaces/dock.lua | 4 --- 2 files changed, 51 deletions(-) diff --git a/maps/pirates/progression.lua b/maps/pirates/progression.lua index 55bd2d68..6ea43775 100644 --- a/maps/pirates/progression.lua +++ b/maps/pirates/progression.lua @@ -231,34 +231,6 @@ function Public.progress_to_destination(destination_index) -- starting_boatposition = {x = -destination_data.static_params.width/2 + BoatData.width + 10, y = Dock.Data.player_boat_top - BoatData.height/2} Common.current_destination().dynamic_data.time_remaining = 180 - -- memory.mainshop_availability_bools.sell_iron = true - memory.mainshop_availability_bools.buy_iron = true - memory.mainshop_availability_bools.buy_copper = true - -- memory.mainshop_availability_bools.buy_fast_loader = true - -- memory.mainshop_availability_bools.sell_copper = true - - memory.mainshop_availability_bools.upgrade_cannons = true - - local boat_for_sale_type = Common.current_destination().static_params.boat_for_sale_type - if boat_for_sale_type then - if boat_for_sale_type == Boats.enum.CUTTER then - memory.mainshop_availability_bools.new_boat_cutter = true - elseif boat_for_sale_type == Boats.enum.CUTTER_WITH_HOLD then - memory.mainshop_availability_bools.new_boat_cutter_with_hold = true - elseif boat_for_sale_type == Boats.enum.SLOOP_WITH_HOLD then - memory.mainshop_availability_bools.new_boat_sloop_with_hold = true - end - end - - local upgrade_for_sale = Common.current_destination().static_params.upgrade_for_sale - if upgrade_for_sale then - for _, u in pairs(Upgrades.List) do - if upgrade_for_sale == u then - memory.mainshop_availability_bools[u] = true - end - end - end - -- Delay.add(Delay.enum.PLACE_DOCK_JETTY_AND_BOATS) Task.set_timeout_in_ticks(2, place_dock_jetty_and_boats, { crew_id = memory.id }) else @@ -392,21 +364,6 @@ function Public.check_for_end_of_boat_movement(boat) Boats.place_boat(boat, CoreData.static_boat_floor, false, false) return true elseif leaving_dock and boat.position.x >= game.surfaces[boat.surface_name].map_gen_settings.width / 2 - 60 then - memory.mainshop_availability_bools.new_boat_cutter = false - memory.mainshop_availability_bools.new_boat_cutter_with_hold = false - memory.mainshop_availability_bools.new_boat_sloop_with_hold = false - -- memory.mainshop_availability_bools.sell_iron = false - memory.mainshop_availability_bools.buy_iron = false - memory.mainshop_availability_bools.buy_copper = false - -- memory.mainshop_availability_bools.buy_fast_loader = false - -- memory.mainshop_availability_bools.sell_copper = false - memory.mainshop_availability_bools.upgrade_cannons = false - - memory.mainshop_availability_bools.extra_hold = false - memory.mainshop_availability_bools.upgrade_power = false - memory.mainshop_availability_bools.unlock_merchants = false - memory.mainshop_availability_bools.rockets_for_sale = false - Public.go_from_currentdestination_to_sea() return true @@ -480,10 +437,6 @@ function Public.undock_from_dock(manual) Boats.place_boat(boat, CoreData.moving_boat_floor, false, false) - memory.mainshop_availability_bools.new_boat_cutter = false - memory.mainshop_availability_bools.new_boat_cutter_with_hold = false - memory.mainshop_availability_bools.new_boat_sloop_with_hold = false - Crew.summon_crew() local force = memory.force diff --git a/maps/pirates/surfaces/dock.lua b/maps/pirates/surfaces/dock.lua index eada911f..8bf12453 100644 --- a/maps/pirates/surfaces/dock.lua +++ b/maps/pirates/surfaces/dock.lua @@ -71,10 +71,6 @@ function Public.execute_boat_purchase() Hold.connect_up_linked_belts_to_deck() Cabin.connect_up_linked_belts_to_deck() - - -- memory.mainshop_availability_bools.new_boat_cutter_with_hold = false - -- memory.mainshop_availability_bools.new_boat_sloop_with_hold = false - -- memory.mainshop_availability_bools.new_boat_cutter = false end function Public.place_dock_jetty_and_boats() From fbc1422d06b6a33b1d9372ccc607c770864a7611 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 22:53:19 +0100 Subject: [PATCH 37/50] fix map not continuing to load properly --- maps/pirates/gui/gui.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index 15f33e35..76dfb54c 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -1203,7 +1203,6 @@ local function on_gui_click(event) local destination_index = memory.mapbeingloadeddestination_index 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 From d02a4beb569d4ba5be26276bcffca5b43408f7df Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Sun, 15 Sep 2024 22:53:32 +0100 Subject: [PATCH 38/50] no long waits at docks --- maps/pirates/api_on_tick.lua | 11 ++++++----- maps/pirates/progression.lua | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index af02fb0e..d1c2cc55 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -1150,11 +1150,12 @@ function Public.loading_update(tickinterval) local fraction = memory.loadingticks / (total + (memory.extra_time_at_sea or 0)) if fraction > Common.fraction_of_map_loaded_at_sea then - boat.state = Boats.enum_state.ATSEA_WAITING_TO_SAIL - memory.at_sea_waiting_game_tick = game.tick - - local force = memory.force - if not (force and force.valid) then return end + if currentdestination.type == Surfaces.enum.DOCK then + Progression.progress_to_destination(destination_index) + else + boat.state = Boats.enum_state.ATSEA_WAITING_TO_SAIL + memory.at_sea_waiting_game_tick = game.tick + end else PiratesApiEvents.load_some_map_chunks_random_order(surface, currentdestination, fraction) --random order is good for maze world if currentdestination.subtype == IslandEnum.enum.CAVE then diff --git a/maps/pirates/progression.lua b/maps/pirates/progression.lua index 6ea43775..776bf372 100644 --- a/maps/pirates/progression.lua +++ b/maps/pirates/progression.lua @@ -29,7 +29,7 @@ local Roles = require 'maps.pirates.roles.roles' local Overworld = require 'maps.pirates.overworld' local Hold = require 'maps.pirates.surfaces.hold' local Cabin = require 'maps.pirates.surfaces.cabin' -local Upgrades = require 'maps.pirates.shop.boat_upgrades' +-- local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Task = require 'utils.task' local Token = require 'utils.token' local ShopDock = require 'maps.pirates.shop.dock' From 4014340e8965d4557a366171932a5b9cdd353a3a Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 16 Sep 2024 14:29:15 +0100 Subject: [PATCH 39/50] fix blueprints always disabled --- maps/pirates/api_events.lua | 5 +- maps/pirates/coredata.lua | 3 - maps/pirates/permissions.lua | 209 ++++++++++++++++++++++++++++++++++ maps/pirates/roles/roles.lua | 214 +---------------------------------- 4 files changed, 217 insertions(+), 214 deletions(-) create mode 100644 maps/pirates/permissions.lua diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index ef76c620..65dd4c18 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -16,6 +16,7 @@ local Surfaces = require 'maps.pirates.surfaces.surfaces' -- local Progression = require 'maps.pirates.progression' local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' local Roles = require 'maps.pirates.roles.roles' +local Permissions = require 'maps.pirates.permissions' -- local Gui = require 'maps.pirates.gui.gui' -- local Sea = require 'maps.pirates.surfaces.sea.sea' -- local Hold = require 'maps.pirates.surfaces.hold' @@ -1483,7 +1484,7 @@ local function event_on_player_joined_game(event) local surface = game.surfaces[CoreData.lobby_surface_name] player.teleport(surface.find_non_colliding_position('character', spawnpoint, 32, 0.5) or spawnpoint, surface) - Roles.update_privileges(player) + Permissions.update_privileges(player) if not player.name then return end @@ -1672,7 +1673,7 @@ local function on_player_changed_surface(event) end end - Roles.update_privileges(player) + Permissions.update_privileges(player) GuiWelcome.close_welcome_window(player) end diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 063a917f..9dfd5203 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -9,9 +9,6 @@ local Public = {} Public.scenario_id_name = 'pirates' Public.version_string = '1.6.3' --major.minor.patch versioning, to match factorio mod portal --- Public.blueprint_library_allowed = true --- Public.blueprint_importing_allowed = true - Public.rocket_silo_death_causes_loss = false Public.victory_x = 1000 diff --git a/maps/pirates/permissions.lua b/maps/pirates/permissions.lua new file mode 100644 index 00000000..73f4032e --- /dev/null +++ b/maps/pirates/permissions.lua @@ -0,0 +1,209 @@ +-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates. + +local Session = require 'utils.datastore.session_data' +local Antigrief = require 'utils.antigrief' +-- local Balance = require 'maps.pirates.balance' +local _inspect = require 'utils.inspect'.inspect +local Memory = require 'maps.pirates.memory' +local Common = require 'maps.pirates.common' +local CoreData = require 'maps.pirates.coredata' + +local Public = {} + +local function set_normal_permissions(group) + if not _DEBUG then + group.set_allows_action(defines.input_action.edit_permission_group, false) + end + group.set_allows_action(defines.input_action.import_permissions_string, false) + group.set_allows_action(defines.input_action.delete_permission_group, false) + group.set_allows_action(defines.input_action.add_permission_group, false) + group.set_allows_action(defines.input_action.admin_action, false) +end + +local function set_restricted_permissions(group) + set_normal_permissions(group) + + group.set_allows_action(defines.input_action.cancel_craft, false) + group.set_allows_action(defines.input_action.drop_item, false) + group.set_allows_action(defines.input_action.drop_blueprint_record, false) + group.set_allows_action(defines.input_action.build, false) + group.set_allows_action(defines.input_action.build_rail, false) + group.set_allows_action(defines.input_action.build_terrain, false) + group.set_allows_action(defines.input_action.begin_mining, false) + group.set_allows_action(defines.input_action.begin_mining_terrain, false) + group.set_allows_action(defines.input_action.activate_copy, false) + group.set_allows_action(defines.input_action.activate_cut, false) + group.set_allows_action(defines.input_action.activate_paste, false) + group.set_allows_action(defines.input_action.upgrade, false) + group.set_allows_action(defines.input_action.deconstruct, false) + group.set_allows_action(defines.input_action.open_gui, false) + group.set_allows_action(defines.input_action.fast_entity_transfer, false) + group.set_allows_action(defines.input_action.fast_entity_split, false) +end + +function Public.try_create_permissions_groups() + if not game.permissions.get_group('lobby') then + local group = game.permissions.create_group('lobby') + set_restricted_permissions(group) + + group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) + group.set_allows_action(defines.input_action.grab_blueprint_record, false) + group.set_allows_action(defines.input_action.import_blueprint_string, false) + group.set_allows_action(defines.input_action.import_blueprint, false) + end + + if not game.permissions.get_group('crowsnest') then + local group = game.permissions.create_group('crowsnest') + set_restricted_permissions(group) + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + end + + if not game.permissions.get_group('crowsnest_privileged') then + local group = game.permissions.create_group('crowsnest_privileged') + set_restricted_permissions(group) + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + + group.set_allows_action(defines.input_action.open_gui, true) + group.set_allows_action(defines.input_action.fast_entity_transfer, true) + group.set_allows_action(defines.input_action.fast_entity_split, true) + end + + if not game.permissions.get_group('cabin') then + local group = game.permissions.create_group('cabin') + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + set_restricted_permissions(group) + + group.set_allows_action(defines.input_action.open_gui, true) -- We want you to open the market, but there is other code to prevent you from opening certain chests + end + + if not game.permissions.get_group('cabin_privileged') then + local group = game.permissions.create_group('cabin_privileged') + group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players + set_restricted_permissions(group) + + group.set_allows_action(defines.input_action.open_gui, true) -- We want you to open the market, but there is other code to prevent you from opening certain chests + end + + if not game.permissions.get_group('plebs') then + local group = game.permissions.create_group('plebs') + set_normal_permissions(group) + end + + if not game.permissions.get_group('not_trusted') then + local group = game.permissions.create_group('not_trusted') + set_normal_permissions(group) + + -- not_trusted.set_allows_action(defines.input_action.cancel_craft, false) + -- not_trusted.set_allows_action(defines.input_action.drop_item, false) + group.set_allows_action(defines.input_action.disconnect_rolling_stock, false) + group.set_allows_action(defines.input_action.connect_rolling_stock, false) + group.set_allows_action(defines.input_action.open_train_gui, false) + group.set_allows_action(defines.input_action.open_train_station_gui, false) + group.set_allows_action(defines.input_action.open_trains_gui, false) + group.set_allows_action(defines.input_action.change_train_stop_station, false) + group.set_allows_action(defines.input_action.change_train_wait_condition, false) + group.set_allows_action(defines.input_action.change_train_wait_condition_data, false) + group.set_allows_action(defines.input_action.drag_train_schedule, false) + group.set_allows_action(defines.input_action.drag_train_wait_condition, false) + group.set_allows_action(defines.input_action.go_to_train_station, false) + group.set_allows_action(defines.input_action.remove_train_station, false) + group.set_allows_action(defines.input_action.set_trains_limit, false) + group.set_allows_action(defines.input_action.set_train_stopped, false) + end + + local blueprint_disabled_groups = { + 'crowsnest_bps_disabled', + 'crowsnest_privileged_bps_disabled', + 'cabin_bps_disabled', + 'cabin_privileged_bps_disabled', + 'plebs_bps_disabled', + 'not_trusted_bps_disabled' + } + + for _, group_name in ipairs(blueprint_disabled_groups) do + if not game.permissions.get_group(group_name) then + local group = game.permissions.create_group(group_name) + local base_group_name = group_name:gsub('_bps_disabled', '') + local base_group = game.permissions.get_group(base_group_name) + + for _, action in pairs(defines.input_action) do + group.set_allows_action(action, base_group.allows_action(action)) + end + + group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) + group.set_allows_action(defines.input_action.grab_blueprint_record, false) + group.set_allows_action(defines.input_action.import_blueprint_string, false) + group.set_allows_action(defines.input_action.import_blueprint, false) + end + end +end + +local function add_player_to_permission_group(player, group_override) + Public.try_create_permissions_groups() + + -- local jailed = Jailed.get_jailed_table() + -- local enable_permission_group_disconnect = WPT.get('disconnect_wagon') + + local gulag = game.permissions.get_group('gulag') + local tbl = gulag and gulag.players + for i = 1, #tbl do + if tbl[i].index == player.index then + return + end + end + + -- if player.admin then + -- return + -- end + + -- if jailed[player.name] then + -- return + -- end + + local group = game.permissions.get_group(group_override) + + group.add_player(player) +end + +function Public.update_privileges(player) + Public.try_create_permissions_groups() + + if not Common.validate_player_and_character(player) then + return + end + + local memory = Memory.get_crew_memory() + local bps_disabled_suffix = memory.run_has_blueprints_disabled and '_bps_disabled' or '' + + if string.sub(player.surface.name, 9, 17) == 'Crowsnest' then + if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then + return add_player_to_permission_group(player, 'crowsnest_privileged' .. bps_disabled_suffix) + else + return add_player_to_permission_group(player, 'crowsnest' .. bps_disabled_suffix) + end + elseif string.sub(player.surface.name, 9, 13) == 'Cabin' then + if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then + return add_player_to_permission_group(player, 'cabin_privileged' .. bps_disabled_suffix) + else + return add_player_to_permission_group(player, 'cabin' .. bps_disabled_suffix) + end + elseif player.surface.name == CoreData.lobby_surface_name then + return add_player_to_permission_group(player, 'lobby') + else + local session = Session.get_session_table() + local AG = Antigrief.get() + + local playtime = player.online_time + if session and session[player.name] then + playtime = player.online_time + session[player.name] + end + + if AG and AG.enabled and not player.admin and playtime < 5184000 then -- 24 hours + add_player_to_permission_group(player, 'not_trusted' .. bps_disabled_suffix) + else + add_player_to_permission_group(player, 'plebs' .. bps_disabled_suffix) + end + end +end + +return Public diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index 1018c245..b298020a 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -11,6 +11,7 @@ local Utils = require 'maps.pirates.utils_local' local CoreData = require 'maps.pirates.coredata' local Server = require 'utils.server' local Classes = require 'maps.pirates.roles.classes' +local Permissions = require 'maps.pirates.permissions' local Public = {} local privilege_levels = { @@ -38,7 +39,7 @@ function Public.make_officer(captain, player) memory.officers_table[player.index] = true Common.notify_force_light(force, { 'pirates.roles_make_officer', captain.name, player.name }) - Public.update_privileges(player) + Permissions.update_privileges(player) else Common.notify_player_error(captain, { 'pirates.roles_make_officer_error_1' }) return false @@ -62,7 +63,7 @@ function Public.unmake_officer(captain, player) memory.officers_table[player.index] = nil Common.notify_force_light(force, { 'pirates.roles_unmake_officer', captain.name, player.name }) - Public.update_privileges(player) + Permissions.update_privileges(player) return true else Common.notify_player_error(captain, { 'pirates.roles_unmake_officer_error_1' }) @@ -177,7 +178,7 @@ function Public.make_captain(player) end if memory.playerindex_captain then - Public.update_privileges(game.players[memory.playerindex_captain]) + Permissions.update_privileges(game.players[memory.playerindex_captain]) end memory.playerindex_captain = player.index @@ -192,7 +193,7 @@ function Public.make_captain(player) -- don't use "unmake_officer" as it prints additional messages memory.officers_table[player.index] = nil - Public.update_privileges(player) + Permissions.update_privileges(player) local force = player.force if force and force.valid then @@ -562,209 +563,4 @@ function Public.captain_tax(captain_index) end end -local function set_normal_permissions(group) - if not _DEBUG then - group.set_allows_action(defines.input_action.edit_permission_group, false) - end - group.set_allows_action(defines.input_action.import_permissions_string, false) - group.set_allows_action(defines.input_action.delete_permission_group, false) - group.set_allows_action(defines.input_action.add_permission_group, false) - group.set_allows_action(defines.input_action.admin_action, false) - - if not CoreData.blueprint_library_allowed then - group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) - group.set_allows_action(defines.input_action.grab_blueprint_record, false) - end - if not CoreData.blueprint_importing_allowed then - group.set_allows_action(defines.input_action.import_blueprint_string, false) - group.set_allows_action(defines.input_action.import_blueprint, false) - end -end - -local function set_restricted_permissions(group) - set_normal_permissions(group) - - group.set_allows_action(defines.input_action.cancel_craft, false) - group.set_allows_action(defines.input_action.drop_item, false) - group.set_allows_action(defines.input_action.drop_blueprint_record, false) - group.set_allows_action(defines.input_action.build, false) - group.set_allows_action(defines.input_action.build_rail, false) - group.set_allows_action(defines.input_action.build_terrain, false) - group.set_allows_action(defines.input_action.begin_mining, false) - group.set_allows_action(defines.input_action.begin_mining_terrain, false) - group.set_allows_action(defines.input_action.activate_copy, false) - group.set_allows_action(defines.input_action.activate_cut, false) - group.set_allows_action(defines.input_action.activate_paste, false) - group.set_allows_action(defines.input_action.upgrade, false) - group.set_allows_action(defines.input_action.deconstruct, false) - group.set_allows_action(defines.input_action.open_gui, false) - group.set_allows_action(defines.input_action.fast_entity_transfer, false) - group.set_allows_action(defines.input_action.fast_entity_split, false) -end - -function Public.try_create_permissions_groups() - if not game.permissions.get_group('lobby') then - local group = game.permissions.create_group('lobby') - set_restricted_permissions(group) - - group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) - group.set_allows_action(defines.input_action.grab_blueprint_record, false) - group.set_allows_action(defines.input_action.import_blueprint_string, false) - group.set_allows_action(defines.input_action.import_blueprint, false) - end - - if not game.permissions.get_group('crowsnest') then - local group = game.permissions.create_group('crowsnest') - set_restricted_permissions(group) - group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players - end - - if not game.permissions.get_group('crowsnest_privileged') then - local group = game.permissions.create_group('crowsnest_privileged') - set_restricted_permissions(group) - group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players - - group.set_allows_action(defines.input_action.open_gui, true) - group.set_allows_action(defines.input_action.fast_entity_transfer, true) - group.set_allows_action(defines.input_action.fast_entity_split, true) - end - - if not game.permissions.get_group('cabin') then - local group = game.permissions.create_group('cabin') - group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players - set_restricted_permissions(group) - - group.set_allows_action(defines.input_action.open_gui, true) -- We want you to open the market, but there is other code to prevent you from opening certain chests - end - - if not game.permissions.get_group('cabin_privileged') then - local group = game.permissions.create_group('cabin_privileged') - group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players - set_restricted_permissions(group) - - group.set_allows_action(defines.input_action.open_gui, true) -- We want you to open the market, but there is other code to prevent you from opening certain chests - end - - if not game.permissions.get_group('plebs') then - local group = game.permissions.create_group('plebs') - set_normal_permissions(group) - end - - if not game.permissions.get_group('not_trusted') then - local group = game.permissions.create_group('not_trusted') - set_normal_permissions(group) - - -- not_trusted.set_allows_action(defines.input_action.cancel_craft, false) - -- not_trusted.set_allows_action(defines.input_action.drop_item, false) - group.set_allows_action(defines.input_action.disconnect_rolling_stock, false) - group.set_allows_action(defines.input_action.connect_rolling_stock, false) - group.set_allows_action(defines.input_action.open_train_gui, false) - group.set_allows_action(defines.input_action.open_train_station_gui, false) - group.set_allows_action(defines.input_action.open_trains_gui, false) - group.set_allows_action(defines.input_action.change_train_stop_station, false) - group.set_allows_action(defines.input_action.change_train_wait_condition, false) - group.set_allows_action(defines.input_action.change_train_wait_condition_data, false) - group.set_allows_action(defines.input_action.drag_train_schedule, false) - group.set_allows_action(defines.input_action.drag_train_wait_condition, false) - group.set_allows_action(defines.input_action.go_to_train_station, false) - group.set_allows_action(defines.input_action.remove_train_station, false) - group.set_allows_action(defines.input_action.set_trains_limit, false) - group.set_allows_action(defines.input_action.set_train_stopped, false) - end - - local blueprint_disabled_groups = { - 'crowsnest_bps_disabled', - 'crowsnest_privileged_bps_disabled', - 'cabin_bps_disabled', - 'cabin_privileged_bps_disabled', - 'plebs_bps_disabled', - 'not_trusted_bps_disabled' - } - - for _, group_name in ipairs(blueprint_disabled_groups) do - if not game.permissions.get_group(group_name) then - local group = game.permissions.create_group(group_name) - local base_group_name = group_name:gsub('_bps_disabled', '') - local base_group = game.permissions.get_group(base_group_name) - - for _, action in pairs(defines.input_action) do - group.set_allows_action(action, base_group.allows_action(action)) - end - - group.set_allows_action(defines.input_action.open_blueprint_library_gui, false) - group.set_allows_action(defines.input_action.grab_blueprint_record, false) - group.set_allows_action(defines.input_action.import_blueprint_string, false) - group.set_allows_action(defines.input_action.import_blueprint, false) - end - end -end - -function Public.add_player_to_permission_group(player, group_override) - Public.try_create_permissions_groups() - - -- local jailed = Jailed.get_jailed_table() - -- local enable_permission_group_disconnect = WPT.get('disconnect_wagon') - - local gulag = game.permissions.get_group('gulag') - local tbl = gulag and gulag.players - for i = 1, #tbl do - if tbl[i].index == player.index then - return - end - end - - -- if player.admin then - -- return - -- end - - -- if jailed[player.name] then - -- return - -- end - - local group = game.permissions.get_group(group_override) - - group.add_player(player) -end - -function Public.update_privileges(player) - Public.try_create_permissions_groups() - - if not Common.validate_player_and_character(player) then - return - end - - local memory = Memory.get_crew_memory() - local bps_disabled_suffix = memory.run_has_blueprints_disabled and '_bps_disabled' or '' - - if string.sub(player.surface.name, 9, 17) == 'Crowsnest' then - if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then - return Public.add_player_to_permission_group(player, 'crowsnest_privileged' .. bps_disabled_suffix) - else - return Public.add_player_to_permission_group(player, 'crowsnest' .. bps_disabled_suffix) - end - elseif string.sub(player.surface.name, 9, 13) == 'Cabin' then - if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then - return Public.add_player_to_permission_group(player, 'cabin_privileged' .. bps_disabled_suffix) - else - return Public.add_player_to_permission_group(player, 'cabin' .. bps_disabled_suffix) - end - elseif player.surface.name == CoreData.lobby_surface_name then - return Public.add_player_to_permission_group(player, 'lobby') - else - local session = Session.get_session_table() - local AG = Antigrief.get() - - local playtime = player.online_time - if session and session[player.name] then - playtime = player.online_time + session[player.name] - end - - if AG and AG.enabled and not player.admin and playtime < 5184000 then -- 24 hours - Public.add_player_to_permission_group(player, 'not_trusted' .. bps_disabled_suffix) - else - Public.add_player_to_permission_group(player, 'plebs' .. bps_disabled_suffix) - end - end -end - return Public From dc0d15a85773f724684e17634ff5880a7269438e Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 16 Sep 2024 14:29:28 +0100 Subject: [PATCH 40/50] Update coredata.lua --- maps/pirates/coredata.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 9dfd5203..e00eb5aa 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -7,7 +7,7 @@ local _inspect = require 'utils.inspect'.inspect local Public = {} Public.scenario_id_name = 'pirates' -Public.version_string = '1.6.3' --major.minor.patch versioning, to match factorio mod portal +Public.version_string = '1.6.4' --major.minor.patch versioning, to match factorio mod portal Public.rocket_silo_death_causes_loss = false From 585ee0d546c469495800561bc97d51376295483f Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Tue, 17 Sep 2024 15:08:07 +0100 Subject: [PATCH 41/50] tad less dark in hold --- maps/pirates/roles/roles.lua | 4 ++-- maps/pirates/surfaces/hold.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index b298020a..b235c87d 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -1,7 +1,7 @@ -- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates. -local Session = require 'utils.datastore.session_data' -local Antigrief = require 'utils.antigrief' +-- local Session = require 'utils.datastore.session_data' +-- local Antigrief = require 'utils.antigrief' -- local Balance = require 'maps.pirates.balance' local _inspect = require 'utils.inspect'.inspect local Memory = require 'maps.pirates.memory' diff --git a/maps/pirates/surfaces/hold.lua b/maps/pirates/surfaces/hold.lua index 0538e565..238aa6ba 100644 --- a/maps/pirates/surfaces/hold.lua +++ b/maps/pirates/surfaces/hold.lua @@ -128,7 +128,7 @@ function Public.create_hold_surface(nth) local surface = game.create_surface(holdname, map_gen_settings) surface.freeze_daytime = true - surface.daytime = 0.3 + surface.daytime = 0.25 surface.show_clouds = false surface.solar_power_multiplier = 0 From 0ce32bac22845f73181da2a968d801c18f27e794 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Wed, 18 Sep 2024 18:07:18 +0100 Subject: [PATCH 42/50] fix permissionlevels import --- maps/pirates/commands.lua | 6 +++--- maps/pirates/gui/crew.lua | 9 +++++---- maps/pirates/gui/gui.lua | 11 +++++------ maps/pirates/permissions.lua | 19 +++++++++++++++++++ maps/pirates/roles/roles.lua | 18 ------------------ maps/pirates/shop/shop.lua | 6 +++--- 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/maps/pirates/commands.lua b/maps/pirates/commands.lua index 52fb293f..24c02e94 100644 --- a/maps/pirates/commands.lua +++ b/maps/pirates/commands.lua @@ -29,7 +29,7 @@ local simplex_noise = require 'utils.simplex_noise'.d2 local Token = require 'utils.token' local Task = require 'utils.task' local Highscore = require 'maps.pirates.highscore' - +local Permissions = require 'maps.pirates.permissions' local Classes = require 'maps.pirates.roles.classes' local Gui = require 'maps.pirates.gui.gui' -- local Session = require 'utils.datastore.session_data' @@ -73,7 +73,7 @@ local function check_captain(cmd) if player ~= nil then p = player.print if not Common.validate_player(player) then return end - if not (Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN) then + if not (Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN) then p({ 'pirates.cmd_error_not_captain' }, Color.fail) return false end @@ -91,7 +91,7 @@ local function check_captain_or_admin(cmd) if player ~= nil then p = player.print if not Common.validate_player(player) then return end - if not (player.admin or Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN) then + if not (player.admin or Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN) then p({ 'pirates.cmd_error_not_captain' }, Color.fail) return false end diff --git a/maps/pirates/gui/crew.lua b/maps/pirates/gui/crew.lua index 39ff08aa..b74742af 100644 --- a/maps/pirates/gui/crew.lua +++ b/maps/pirates/gui/crew.lua @@ -13,6 +13,7 @@ local Surfaces = require 'maps.pirates.surfaces.surfaces' local SurfacesCommon = require 'maps.pirates.surfaces.common' local Hold = require 'maps.pirates.surfaces.hold' -- local Cabin = require 'maps.pirates.surfaces.cabin' +local Permissions = require 'maps.pirates.permissions' local window_name = 'crew' @@ -596,7 +597,7 @@ function Public.click(event) if eventname == 'capn_summon_crew' then --double check: - if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + if Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN then Crew.summon_crew() end return @@ -604,7 +605,7 @@ function Public.click(event) if eventname == 'capn_requisition' then --double check: - if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + if Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN then Roles.captain_tax(memory.playerindex_captain) end return @@ -622,7 +623,7 @@ function Public.click(event) if eventname == 'capn_disband_crew' then --double check: - if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + if Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN then if not memory.disband_are_you_sure_ticks then memory.disband_are_you_sure_ticks = {} end @@ -633,7 +634,7 @@ function Public.click(event) if eventname == 'capn_disband_are_you_sure' then --double check: - if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + if Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN then local force = memory.force if force and force.valid then local message = { 'pirates.crew_disbanded', player.name, memory.name, Utils.time_longform((memory.real_age or 0) / 60) } diff --git a/maps/pirates/gui/gui.lua b/maps/pirates/gui/gui.lua index 76dfb54c..df15c92f 100644 --- a/maps/pirates/gui/gui.lua +++ b/maps/pirates/gui/gui.lua @@ -22,12 +22,11 @@ local Cabin = require 'maps.pirates.surfaces.cabin' local Crowsnest = require 'maps.pirates.surfaces.crowsnest' local Progression = require 'maps.pirates.progression' local Surfaces = require 'maps.pirates.surfaces.surfaces' -local Roles = require 'maps.pirates.roles.roles' - +-- local Roles = require 'maps.pirates.roles.roles' +local Permissions = require 'maps.pirates.permissions' local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum' local Kraken = require 'maps.pirates.surfaces.sea.kraken' local GuiWelcome = require 'maps.pirates.gui.welcome' - local ComfyGui = require 'utils.gui' ComfyGui.set_disabled_tab('Scoreboard', true) ComfyGui.set_disabled_tab('Groups', true) @@ -1186,7 +1185,7 @@ local function on_gui_click(event) if event.element.name and event.element.name == 'etaframe_piratebutton' then if (memory.boat.state == Boats.enum_state.DOCKED or memory.boat.state == Boats.enum_state.LANDED) then - if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + if Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN then if (not memory.undock_shortcut_are_you_sure_data) then memory.undock_shortcut_are_you_sure_data = {} end if memory.undock_shortcut_are_you_sure_data[player.index] and memory.undock_shortcut_are_you_sure_data[player.index] > game.tick - 60 * 4 then if memory.boat.state == Boats.enum_state.DOCKED then @@ -1199,13 +1198,13 @@ local function on_gui_click(event) end end elseif memory.boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL then - if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + if Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN then local destination_index = memory.mapbeingloadeddestination_index Progression.progress_to_destination(destination_index) end elseif memory.boat.state == Boats.enum_state.ATSEA_VICTORIOUS then - if Roles.player_privilege_level(player) >= Roles.privilege_levels.CAPTAIN then + if Permissions.player_privilege_level(player) >= Permissions.privilege_levels.CAPTAIN then memory.boat.state = Boats.enum_state.ATSEA_SAILING local force = memory.force diff --git a/maps/pirates/permissions.lua b/maps/pirates/permissions.lua index 73f4032e..dd436bbe 100644 --- a/maps/pirates/permissions.lua +++ b/maps/pirates/permissions.lua @@ -10,6 +10,25 @@ local CoreData = require 'maps.pirates.coredata' local Public = {} +local privilege_levels = { + NORMAL = 1, + OFFICER = 2, + CAPTAIN = 3 +} +Public.privilege_levels = privilege_levels + +function Public.player_privilege_level(player) + local memory = Memory.get_crew_memory() + + if Common.is_id_valid(memory.id) and Common.is_captain(player) then + return Public.privilege_levels.CAPTAIN + elseif Common.is_officer(player.index) then + return Public.privilege_levels.OFFICER + else + return Public.privilege_levels.NORMAL + end +end + local function set_normal_permissions(group) if not _DEBUG then group.set_allows_action(defines.input_action.edit_permission_group, false) diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index b235c87d..3929cad7 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -14,12 +14,6 @@ local Classes = require 'maps.pirates.roles.classes' local Permissions = require 'maps.pirates.permissions' local Public = {} -local privilege_levels = { - NORMAL = 1, - OFFICER = 2, - CAPTAIN = 3 -} -Public.privilege_levels = privilege_levels --== Roles — General ==-- @@ -155,18 +149,6 @@ function Public.get_class_print_string(class, add_is_class_obstainable) return nil end -function Public.player_privilege_level(player) - local memory = Memory.get_crew_memory() - - if Common.is_id_valid(memory.id) and Common.is_captain(player) then - return Public.privilege_levels.CAPTAIN - elseif Common.is_officer(player.index) then - return Public.privilege_levels.OFFICER - else - return Public.privilege_levels.NORMAL - end -end - function Public.make_captain(player) local global_memory = Memory.get_global_memory() local memory = Memory.get_crew_memory() diff --git a/maps/pirates/shop/shop.lua b/maps/pirates/shop/shop.lua index b591a3ac..e12cb44f 100644 --- a/maps/pirates/shop/shop.lua +++ b/maps/pirates/shop/shop.lua @@ -10,14 +10,14 @@ local Crew = require 'maps.pirates.crew' local Balance = require 'maps.pirates.balance' local Common = require 'maps.pirates.common' -- local Utils = require 'maps.pirates.utils_local' -local Roles = require 'maps.pirates.roles.roles' +-- local Roles = require 'maps.pirates.roles.roles' local Math = require 'maps.pirates.math' local _inspect = require 'utils.inspect'.inspect local SurfacesCommon = require 'maps.pirates.surfaces.common' local Upgrades = require 'maps.pirates.shop.boat_upgrades' local Cabin = require 'maps.pirates.surfaces.cabin' -- local Upgrades = require 'maps.pirates.shop.boat_upgrades' - +local Permissions = require 'maps.pirates.permissions' local Public = {} Public.Covered = require 'maps.pirates.shop.covered' Public.Merchants = require 'maps.pirates.shop.merchants' @@ -91,7 +91,7 @@ local function purchaseData(market, player, offer_index) local in_captains_cabin = type and type == SurfacesCommon.enum.CABIN local dock_upgrades_market = destination.dynamic_data.dock_captains_market and (destination.dynamic_data.dock_captains_market == market) - local permission_level_fail = (in_captains_cabin and Roles.player_privilege_level(player) < Roles.privilege_levels.OFFICER) or (dock_upgrades_market and Roles.player_privilege_level(player) < Roles.privilege_levels.OFFICER) + local permission_level_fail = (in_captains_cabin and Permissions.player_privilege_level(player) < Permissions.privilege_levels.OFFICER) or (dock_upgrades_market and Permissions.player_privilege_level(player) < Permissions.privilege_levels.OFFICER) if in_captains_cabin then decay_type = 'static' From 9335e938da720839d9d0107877ba1f64a1a97e44 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 23 Sep 2024 14:08:39 +0100 Subject: [PATCH 43/50] lock amount hours --- maps/pirates/common.lua | 2 +- maps/pirates/coredata.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index 2898a50d..d19bb2b9 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -27,7 +27,7 @@ Public.minimum_run_capacity_to_enforce_space_for = 22 -- auto-disbanding when there are no players left in the crew: -- Public.autodisband_hours = nil -Public.autodisband_hours = 24 * 5 -- should not be zero (as this messes with saving and loading a game, which boots the player for a moment.) Also note that the server may run very slowly when no-one is on it. +Public.autodisband_hours = 24 * 2 -- should not be zero (as this messes with saving and loading a game, which boots the player for a moment.) Also note that the server may run very slowly when no-one is on it. Public.boat_steps_at_a_time = 1 diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index e00eb5aa..d01c03ec 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -17,8 +17,8 @@ Public.total_max_biters = 2200 Public.lobby_surface_name = '000-000-Lobby' -Public.private_run_lock_amount_hr = 24 -- how many hours need to pass, when crew is empty or inactive, until private run becomes public -Public.protected_run_lock_amount_hr = 24 -- how many hours need to pass, when crew is empty or inactive, until captain protection expires +Public.private_run_lock_amount_hr = 48 -- how many hours need to pass, when crew is empty or inactive, until private run becomes public +Public.protected_run_lock_amount_hr = 48 -- how many hours need to pass, when crew is empty or inactive, until captain protection expires Public.colors = { coal = { r = 0.5, g = 0.5, b = 0.5 }, From 33cda319017d40d69829b0810dac37b188114f81 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 23 Sep 2024 14:08:47 +0100 Subject: [PATCH 44/50] reenable prod modules --- maps/pirates/api_on_tick.lua | 39 +++++++++++++++++------------------- maps/pirates/common.lua | 6 +++--- maps/pirates/crew.lua | 5 +++-- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index d1c2cc55..64baa6be 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -80,20 +80,20 @@ function Public.prevent_unbarreling_off_ship(tickinterval) end end -local function remove_productivity_modules(surface, machines) - for _, machine in ipairs(machines) do - if machine and machine.valid then - local modules = machine.get_module_inventory() - if modules and modules.valid then - local productivity_modules = modules.get_contents()['productivity-module'] - if productivity_modules and productivity_modules > 0 then - modules.remove { name = 'productivity-module', count = productivity_modules } - surface.spill_item_stack(machine.position, { name = 'productivity-module', count = productivity_modules }, true, nil, true) - end - end - end - end -end +-- local function remove_productivity_modules(surface, machines) +-- for _, machine in ipairs(machines) do +-- if machine and machine.valid then +-- local modules = machine.get_module_inventory() +-- if modules and modules.valid then +-- local productivity_modules = modules.get_contents()['productivity-module'] +-- if productivity_modules and productivity_modules > 0 then +-- modules.remove { name = 'productivity-module', count = productivity_modules } +-- surface.spill_item_stack(machine.position, { name = 'productivity-module', count = productivity_modules }, true, nil, true) +-- end +-- end +-- end +-- end +-- end function Public.apply_restrictions_to_machines(tickinterval) local memory = Memory.get_crew_memory() @@ -165,10 +165,10 @@ function Public.apply_restrictions_to_machines(tickinterval) type = { 'assembling-machine', 'furnace', 'lab' }, force = memory.force_name } - local drills = surface.find_entities_filtered { - type = { 'mining-drill' }, - force = memory.force_name - } + -- local drills = surface.find_entities_filtered { + -- type = { 'mining-drill' }, + -- force = memory.force_name + -- } local power_machines = surface.find_entities_filtered { type = { 'generator', 'solar-panel', 'boiler', 'reactor' }, force = memory.force_name @@ -184,9 +184,6 @@ function Public.apply_restrictions_to_machines(tickinterval) machine.active = not memory.crafters_disabled end end - - remove_productivity_modules(surface, crafters) - remove_productivity_modules(surface, drills) end end diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index d19bb2b9..5bebea2c 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -1696,9 +1696,9 @@ function Public.get_item_blacklist(tier) -- blacklist['cannon-shell'] = true -- blacklist['explosive-cannon-shell'] = true -- blacklist['speed-module-3'] = true - blacklist['productivity-module'] = true - blacklist['productivity-module-2'] = true - blacklist['productivity-module-3'] = true + -- blacklist['productivity-module'] = true + -- blacklist['productivity-module-2'] = true + -- blacklist['productivity-module-3'] = true -- blacklist['effectivity-module-3'] = true -- blacklist['space-science-pack'] = true -- blacklist['rocket-control-unit'] = true diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index 41b9e52d..65114413 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -1057,8 +1057,9 @@ function Public.reset_crew_and_enemy_force(id) crew_force.technologies['gate'].enabled = true -- crew_force.technologies['productivity-module'].enabled = false - crew_force.technologies['productivity-module-2'].enabled = false - crew_force.technologies['productivity-module-3'].enabled = false + -- crew_force.technologies['productivity-module-2'].enabled = false + -- crew_force.technologies['productivity-module-3'].enabled = false + -- crew_force.technologies['speed-module'].enabled = true -- crew_force.technologies['speed-module-2'].enabled = false -- crew_force.technologies['speed-module-3'].enabled = false From 945dcc7b27d06a9efed882f489166d29d2821da9 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 23 Sep 2024 14:09:46 +0100 Subject: [PATCH 45/50] autodisband_hours to 24 * 4 --- locale/en/pirates.cfg | 2 +- maps/pirates/common.lua | 2 +- maps/pirates/coredata.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 253af2fc..e708c497 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -19,7 +19,7 @@ softmod_info_1_1=v1.6.3 highlights softmod_info_1_2=• Gameplay further slowed down for small crews.\n• Optional setting for new crews to disable blueprints.\n• Fixed a bug causing large waves.\n• Grace period of 2 minutes on each island before attacks. softmod_info_2_1=v1.6.0 highlights -softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Productivity modules are removed from the game until a later feature is released.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market +softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market softmod_info_credits_1=Credits softmod_info_credits_2=Designed/developed by thesixthroc. Updates from Piratux. Comfy codebase and help from Gerkiz, Hanakocz and Mew @ Comfy Industries (https://getcomfy.eu). Island structure blueprints contributed by Mattisso.\n\nCome chat with us: https://getcomfy.eu/discord\n\n"Those white gloves. I'll never forget them 'till the day I die." - Dr. John diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index 5bebea2c..c5539fae 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -27,7 +27,7 @@ Public.minimum_run_capacity_to_enforce_space_for = 22 -- auto-disbanding when there are no players left in the crew: -- Public.autodisband_hours = nil -Public.autodisband_hours = 24 * 2 -- should not be zero (as this messes with saving and loading a game, which boots the player for a moment.) Also note that the server may run very slowly when no-one is on it. +Public.autodisband_hours = 24 * 4 -- should not be zero (as this messes with saving and loading a game, which boots the player for a moment.) Also note that the server may run very slowly when no-one is on it. Public.boat_steps_at_a_time = 1 diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index d01c03ec..9b176a5a 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -7,7 +7,7 @@ local _inspect = require 'utils.inspect'.inspect local Public = {} Public.scenario_id_name = 'pirates' -Public.version_string = '1.6.4' --major.minor.patch versioning, to match factorio mod portal +Public.version_string = '1.6.5' --major.minor.patch versioning, to match factorio mod portal Public.rocket_silo_death_causes_loss = false From aae52ee55e1e978d3e2e72b8824a728527636fc2 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 23 Sep 2024 14:23:58 +0100 Subject: [PATCH 46/50] chat code cleanup --- locale/en/pirates.cfg | 6 ++---- maps/pirates/api_events.lua | 13 ++++++------- maps/pirates/gui/info.lua | 14 +++----------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index e708c497..01bcc33c 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -15,8 +15,8 @@ softmod_info_new_players_2=Mine coal and other resources and bring them to the s softmod_info_tips_1=Features of the game that are hard to work out alone softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password -softmod_info_1_1=v1.6.3 highlights -softmod_info_1_2=• Gameplay further slowed down for small crews.\n• Optional setting for new crews to disable blueprints.\n• Fixed a bug causing large waves.\n• Grace period of 2 minutes on each island before attacks. +softmod_info_1_1=v1.6.1–1.6.5 highlights +softmod_info_1_2=• Gameplay further slowed down for small crews.\n• Optional setting for new crews to disable blueprints.\n• Fixed a bug causing large waves.\n• Grace period of 2 minutes on each island before attacks.\n• Machines now deactivate after several minutes spent waiting at sea. softmod_info_2_1=v1.6.0 highlights softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market @@ -29,8 +29,6 @@ thesixthroc_support_toast=Support Pirate Ship at ko-fi.com/thesixthroc softmod_info_body_promote=by thesixthroc softmod_info_body_promote_old2=patreon.com/thesixthroc -softmod_info_body_clicky=Click to dismiss. - separator_1=, diff --git a/maps/pirates/api_events.lua b/maps/pirates/api_events.lua index 65dd4c18..6fc8f75a 100644 --- a/maps/pirates/api_events.lua +++ b/maps/pirates/api_events.lua @@ -2092,10 +2092,7 @@ local function event_on_console_chat(event) local global_memory = Memory.get_global_memory() local player = game.players[event.player_index] - local tag = player.tag - if not tag then - tag = '' - end + local tag = player.tag or '' local color = player.chat_color -- if global.tournament_mode then @@ -2116,11 +2113,13 @@ local function event_on_console_chat(event) end else -- NOTE: For some reason memory.name(or player.name?) can be nil so need this check. It was observed it happened after crew died and resetted, then I said something in lobby before launching new run. That's the only recorded occurence so far. - if memory.name then + if memory.name and player.name then game.forces.player.print(player.name .. tag .. ' [' .. memory.name .. ']: ' .. event.message, color) - else - game.forces.player.print(player.name .. tag .. event.message, color) + elseif player.name then + game.forces.player.print(player.name .. tag .. ': ' .. event.message, color) log('Error (non-critical): memory.name is nil') + else + log('Error (non-critical): player.name is nil') end end end diff --git a/maps/pirates/gui/info.lua b/maps/pirates/gui/info.lua index a74a012d..f26e3e6b 100644 --- a/maps/pirates/gui/info.lua +++ b/maps/pirates/gui/info.lua @@ -173,13 +173,6 @@ function Public.flow_add_info_tab(flow, tab_name) flow3.style.horizontally_stretchable = true flow3.style.horizontal_align = 'center' - flow4 = flow3.add { type = "label", caption = { "pirates.softmod_info_body_clicky" } } - flow4.style.font = 'default-small' - flow4.style.font_color = GuiCommon.friendly_font_color - flow4.style.single_line = false - flow4.style.bottom_margin = 4 - flow4.style.top_margin = 3 - flow.add_tab(tab, contents) return ret @@ -222,16 +215,15 @@ function Public.full_update(player) local flow = player.gui.screen[window_name .. '_piratewindow'] local flow2 = flow - -- warning, if you make these too small, it loses 'Click to dismiss.' -- This is really really dumb, to have to change these manually. But sadly we couldn't get the window to look like it does and also be expandable. if flow2.selected_tab_index == 1 then flow2.style.height = 400 elseif flow2.selected_tab_index == 2 then - flow2.style.height = 550 + flow2.style.height = 500 elseif flow2.selected_tab_index == 3 then - flow2.style.height = 680 + flow2.style.height = 500 elseif flow2.selected_tab_index == 4 then - flow2.style.height = 340 + flow2.style.height = 350 end end From 52d9a6d969f0f18724a7ed91a74621ac8973efb2 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Mon, 23 Sep 2024 14:24:04 +0100 Subject: [PATCH 47/50] turn coal liq off --- maps/pirates/crew.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index 65114413..a11cb5b6 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -975,7 +975,7 @@ function Public.reset_crew_and_enemy_force(id) -- Trying out having this be researched by default, in order to make coal (the resource needed to power the ship) interchangeable with oil, thereby making coal more precious: - crew_force.technologies['coal-liquefaction'].researched = true + -- crew_force.technologies['coal-liquefaction'].researched = true -- crew_force.technologies['toolbelt'].enabled = false --trying this. we don't actually want players to carry too many things manually, and in fact in a resource-tight scenario that's problematic From 706a91047116de2b04bb3c34a1ac146ed17ef1fb Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Tue, 24 Sep 2024 13:00:35 +0100 Subject: [PATCH 48/50] fix offering weapon upgrades multiple times --- .../surfaces/islands/cave/cave_source.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/maps/pirates/surfaces/islands/cave/cave_source.lua b/maps/pirates/surfaces/islands/cave/cave_source.lua index 9a27f6aa..52297eb6 100644 --- a/maps/pirates/surfaces/islands/cave/cave_source.lua +++ b/maps/pirates/surfaces/islands/cave/cave_source.lua @@ -28,13 +28,17 @@ local function spawn_market(args, is_main) if is_main then offers = ShopCovered.market_generate_coin_offers(6) - offers[#offers + 1] = { - price = Balance.weapon_damage_upgrade_price(), - offer = { - type = "nothing", - effect_description = { 'pirates.market_description_purchase_attack_upgrade', Balance.weapon_damage_upgrade_percentage() } + if not destination_data.dynamic_data.offered_weapon_damage_upgrade then + offers[#offers + 1] = { + price = Balance.weapon_damage_upgrade_price(), + offer = { + type = "nothing", + effect_description = { 'pirates.market_description_purchase_attack_upgrade', Balance.weapon_damage_upgrade_percentage() } + } } - } + + destination_data.dynamic_data.offered_weapon_damage_upgrade = true + end if destination_data.static_params.class_for_sale then offers[#offers + 1] = { price = { { 'coin', Balance.class_cost(true) } }, offer = { type = "nothing", effect_description = { 'pirates.market_description_purchase_class', Classes.display_form(destination_data.static_params.class_for_sale) } } } From ccacb9980b961695123c91d8afca3529ad9568b1 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Tue, 24 Sep 2024 13:10:07 +0100 Subject: [PATCH 49/50] No longer expire private/protected status --- locale/en/pirates.cfg | 14 +++++++------- maps/pirates/api_on_tick.lua | 37 ------------------------------------ maps/pirates/coredata.lua | 3 --- maps/pirates/crew.lua | 2 -- maps/pirates/gui/runs.lua | 18 +++++++----------- maps/pirates/main.lua | 2 -- maps/pirates/roles/roles.lua | 2 +- 7 files changed, 15 insertions(+), 63 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 01bcc33c..0e955e49 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -16,10 +16,10 @@ softmod_info_tips_1=Features of the game that are hard to work out alone softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password softmod_info_1_1=v1.6.1–1.6.5 highlights -softmod_info_1_2=• Gameplay further slowed down for small crews.\n• Optional setting for new crews to disable blueprints.\n• Fixed a bug causing large waves.\n• Grace period of 2 minutes on each island before attacks.\n• Machines now deactivate after several minutes spent waiting at sea. +softmod_info_1_2=• Optional setting for new crews to disable blueprints.\n• Each island now has a grace period of 2 minutes before attacks.\n• Machines now deactivate after several minutes spent waiting at sea.\n• Private crews and captain-protected crews no longer revert to public crews when inactive. Runs now autodisband after 96 hours of inactivity.\n• Further slowing of gameplay for small crews. softmod_info_2_1=v1.6.0 highlights -softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Island surfaces are now always deleted after the boat leaves, fixing issues with marooned players.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Spectators can now change surfaces.\n• Crew proposal endorsements system removed.\n• Balance tweaks:\n - Most maps now have some unkillable spawners\n - Mining productivity increases naturally with leagues traveled\n - Biter nighttime damage bonus nerfed\n - Tweaks to radioactive islands\n - Kovarex enrichment no longer researched at start of game\n - Land mines only purchasable at docks, and drop your speed when placed\n - Flamers nerf slightly increased\n - 5% weapon and turret damage upgrade available at each island market +softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Players now die rather than being temporarily marooned if they miss the boat.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Balance tweaks:\n - Most maps now have some unkillable spawners.\n - Mining productivity increases naturally with leagues traveled.\n - Biter nighttime damage bonus nerfed.\n - Tweaks to radioactive islands.\n - Kovarex enrichment no longer researched at start of game.\n - Land mines only purchasable at docks, and drop your speed when placed.\n - Flamers nerf slightly increased.\n - 5% weapon and turret damage upgrade available at each island market. softmod_info_credits_1=Credits softmod_info_credits_2=Designed/developed by thesixthroc. Updates from Piratux. Comfy codebase and help from Gerkiz, Hanakocz and Mew @ Comfy Industries (https://getcomfy.eu). Island structure blueprints contributed by Mattisso.\n\nCome chat with us: https://getcomfy.eu/discord\n\n"Those white gloves. I'll never forget them 'till the day I die." - Dr. John @@ -77,7 +77,7 @@ parrot_cave_tip_1=That island looks suspiciously dark... I'm scared! Squawk! parrot_captain_first_time_in_cabin_hint=Squawk! Captains and officers can buy rail signals to steer the ship! parrot_cliff_explosive_tip=Cliff explosives? These look so powerful, they could blow away those annoying chests in the hold. Squawk! parrot_buried_treasure_tip=Squawk! If X marks the spot - use an item to dig! -parrot_captain_left_protected_run=The captain has disconnected. Since this crew is captain-protected, the captain role will not be redistributed for __1__ hours. Squawk! +parrot_captain_left_protected_run=The captain has disconnected. Since this crew is captain-protected, the captain role will not be redistributed. Squawk! parrot_player_joins_protected_run_with_no_captain=Hello there! Since this crew is captain-protected, you will have to wait for captain to return in order to control the ship. parrot_create_new_crew_tip=You can always create or join another crew. To do this, press the red flag on top, click 'Quit Crew', then press 'Crews'. parrot_crafters_disabled=Our machines have paused whilst we're waiting at sea. @@ -533,9 +533,9 @@ gui_runs_proposal_maker_propose=Propose gui_runs_proposal_maker_no_limit=No limit gui_runs_proposal_maker_blueprints_disabled=Blueprints disabled gui_runs_proposal_maker_protected=Captain-protected -gui_runs_proposal_maker_protected_tooltip=Captain-protected crew. If the captain leaves or becomes afk, and there are no officers, the captain role stays vacant.\nIf the crew is empty or inactive for __1__ hours, it becomes unprotected. +gui_runs_proposal_maker_protected_tooltip=Captain-protected crew. If the captain leaves or becomes afk, and there are no officers, the captain role stays vacant. gui_runs_proposal_maker_private=Private -gui_runs_proposal_maker_private_tooltip=Private crew. Once the crew has launched, players must enter the password in order to join.\nIf the crew is empty or inactive for __1__ hours, the password is removed. +gui_runs_proposal_maker_private_tooltip=Private crew. Once the crew has launched, players must enter the password in order to join. gui_runs_proposal_maker_password=Password gui_runs_proposal_maker_confirm_password=Confirm Password gui_runs_proposal_maker_error_protected_run_limit=All protected crew slots are occupied. Wait until protected crew slots free up to create your own. @@ -545,8 +545,8 @@ gui_runs_proposal_maker_error_two_private_runs=You can't create more than one pr gui_runs_proposal_maker_error_three_runs=You can't create more than two crews. gui_runs_proposal_maker_error_private_run_password_no_match=Passwords do not match. gui_runs_proposal_maker_error_private_run_password_empty=Passwords can't be empty. -gui_join_protected_run_info=This crew is protected.\nThis means when captain leaves the game, other members won't get the captain role (unless there are officers).\nCaptain protection expires in __1__:__2__:__3__ -gui_join_private_run_info=This crew is private.\nPlease enter a password to join the crew.\nThis crew will become public in __1__:__2__:__3__ +gui_join_protected_run_info=This crew is protected.\nThis means when captain leaves the game, other members won't get the captain role (unless there are officers) +gui_join_private_run_info=This crew is private.\nEnter the password to join the crew. gui_join_private_run_error_wrong_password=The password you've entered is incorrect. cmd_notify_set_private_run_password=The password for __1__ has been set to __2__ diff --git a/maps/pirates/api_on_tick.lua b/maps/pirates/api_on_tick.lua index 64baa6be..d18593db 100644 --- a/maps/pirates/api_on_tick.lua +++ b/maps/pirates/api_on_tick.lua @@ -1710,43 +1710,6 @@ function Public.revealed_buried_treasure_distance_check() end end -function Public.update_protected_run_lock_timer(tickinterval) - local memory = Memory.get_crew_memory() - if memory.run_is_protected then - if not Roles.captain_exists() then - if memory.protected_run_lock_timer > 0 then - memory.protected_run_lock_timer = memory.protected_run_lock_timer - tickinterval - - if memory.protected_run_lock_timer <= 0 then - Common.notify_game({ 'pirates.protected_run_lock_expired', memory.name }) - memory.run_is_protected = false - Roles.assign_captain_based_on_priorities() - end - end - else - memory.protected_run_lock_timer = 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr - end - end -end - -function Public.update_private_run_lock_timer(tickinterval) - local memory = Memory.get_crew_memory() - if memory.run_is_private then - if Common.activecrewcount() <= 0 then - if memory.private_run_lock_timer > 0 then - memory.private_run_lock_timer = memory.private_run_lock_timer - tickinterval - - if memory.private_run_lock_timer <= 0 then - Common.notify_game({ 'pirates.private_run_lock_expired', memory.name }) - memory.run_is_private = false - end - end - else - memory.private_run_lock_timer = 60 * 60 * 60 * CoreData.private_run_lock_amount_hr - end - end -end - function Public.update_pet_biter_lifetime(tickinterval) local memory = Memory.get_crew_memory() if memory.pet_biters then diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 9b176a5a..a9bd689e 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -17,9 +17,6 @@ Public.total_max_biters = 2200 Public.lobby_surface_name = '000-000-Lobby' -Public.private_run_lock_amount_hr = 48 -- how many hours need to pass, when crew is empty or inactive, until private run becomes public -Public.protected_run_lock_amount_hr = 48 -- how many hours need to pass, when crew is empty or inactive, until captain protection expires - Public.colors = { coal = { r = 0.5, g = 0.5, b = 0.5 }, wood = { r = 204, g = 158, b = 67 }, diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index a11cb5b6..4577e703 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -754,10 +754,8 @@ function Public.initialise_crew(accepted_proposal, player_position) -- memory.mode = CoreData.mode_options[accepted_proposal.mode_option].value memory.run_has_blueprints_disabled = accepted_proposal.run_has_blueprints_disabled memory.run_is_protected = accepted_proposal.run_is_protected - memory.protected_run_lock_timer = 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr memory.run_is_private = accepted_proposal.run_is_private memory.private_run_password = accepted_proposal.private_run_password - memory.private_run_lock_timer = 60 * 60 * 60 * CoreData.private_run_lock_amount_hr memory.destinationsvisited_indices = {} memory.stored_fuel = Balance.starting_fuel diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index cb39fc43..c996a841 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -209,7 +209,7 @@ function Public.toggle_window(player) flow3 = flow2.add({ name = 'join_protected_crew_info', type = 'label', - caption = { 'pirates.gui_join_protected_run_info', 0, 0, 0 }, + caption = { 'pirates.gui_join_protected_run_info' }, visible = false, }) flow3.style.single_line = false @@ -217,7 +217,7 @@ function Public.toggle_window(player) flow3 = flow2.add({ name = 'join_private_crew_info', type = 'label', - caption = { 'pirates.gui_join_private_run_info', 0, 0, 0 }, + caption = { 'pirates.gui_join_private_run_info' }, visible = false, }) flow3.style.single_line = false @@ -359,7 +359,7 @@ function Public.toggle_window(player) type = 'checkbox', caption = { 'pirates.gui_runs_proposal_maker_protected' }, state = false, - tooltip = { 'pirates.gui_runs_proposal_maker_protected_tooltip', CoreData.protected_run_lock_amount_hr } + tooltip = { 'pirates.gui_runs_proposal_maker_protected_tooltip' } }) flow5.add({ @@ -367,7 +367,7 @@ function Public.toggle_window(player) type = 'checkbox', caption = { 'pirates.gui_runs_proposal_maker_private' }, state = false, - tooltip = { 'pirates.gui_runs_proposal_maker_private_tooltip', CoreData.private_run_lock_amount_hr } + tooltip = { 'pirates.gui_runs_proposal_maker_private_tooltip' } }) flow6 = flow5.add({ @@ -525,20 +525,16 @@ function Public.full_update(player) end ongoing_runs.body.leaving_prompt.visible = playercrew_status.leaving - ongoing_runs.body.join_protected_crew_info.visible = selected_crew and selected_crew.run_is_protected and selected_crew.protected_run_lock_timer < 60 * 60 * 60 * CoreData.protected_run_lock_amount_hr + ongoing_runs.body.join_protected_crew_info.visible = selected_crew and selected_crew.run_is_protected ongoing_runs.body.join_private_crew_info.visible = selected_crew and selected_crew.run_is_private ongoing_runs.body.password.visible = selected_crew and selected_crew.run_is_private if selected_crew then if ongoing_runs.body.join_protected_crew_info.visible then - local lock_timer = selected_crew.protected_run_lock_timer - local hrs, min, sec = Math.floor((lock_timer / (60 * 60 * 60)) % 60), Math.floor((lock_timer / (60 * 60)) % 60), Math.floor((lock_timer / 60) % 60) - ongoing_runs.body.join_protected_crew_info.caption = { 'pirates.gui_join_protected_run_info', hrs, min, sec } + ongoing_runs.body.join_protected_crew_info.caption = { 'pirates.gui_join_protected_run_info' } end if ongoing_runs.body.join_private_crew_info.visible then - local lock_timer = selected_crew.private_run_lock_timer - local hrs, min, sec = Math.floor((lock_timer / (60 * 60 * 60)) % 60), Math.floor((lock_timer / (60 * 60)) % 60), Math.floor((lock_timer / 60) % 60) - ongoing_runs.body.join_private_crew_info.caption = { 'pirates.gui_join_private_run_info', hrs, min, sec } + ongoing_runs.body.join_private_crew_info.caption = { 'pirates.gui_join_private_run_info' } end end end diff --git a/maps/pirates/main.lua b/maps/pirates/main.lua index 96def92c..5de51631 100644 --- a/maps/pirates/main.lua +++ b/maps/pirates/main.lua @@ -240,8 +240,6 @@ local function crew_tick() if tick % 3600 == 0 then PiratesApiOnTick.prune_offline_characters_list(3600) - PiratesApiOnTick.update_protected_run_lock_timer(3600) - PiratesApiOnTick.update_private_run_lock_timer(3600) end end end diff --git a/maps/pirates/roles/roles.lua b/maps/pirates/roles/roles.lua index 3929cad7..97a99e7a 100644 --- a/maps/pirates/roles/roles.lua +++ b/maps/pirates/roles/roles.lua @@ -220,7 +220,7 @@ function Public.player_left_so_redestribute_roles(player) local officers = Common.crew_get_non_afk_officers() if memory.run_is_protected and #officers == 0 then if memory.crewplayerindices and #memory.crewplayerindices > 0 then - Common.parrot_speak(memory.force, { 'pirates.parrot_captain_left_protected_run', Common.protected_run_lock_amount_hr }) + Common.parrot_speak(memory.force, { 'pirates.parrot_captain_left_protected_run' }) Common.parrot_speak(memory.force, { 'pirates.parrot_create_new_crew_tip' }) end elseif memory.run_is_protected then From 292579b10165acc5f5a37fd3c3bf353c045d4177 Mon Sep 17 00:00:00 2001 From: danielmartin0 Date: Tue, 24 Sep 2024 13:13:29 +0100 Subject: [PATCH 50/50] only disband inactive crews on the public server --- locale/en/pirates.cfg | 2 +- maps/pirates/crew.lua | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/locale/en/pirates.cfg b/locale/en/pirates.cfg index 0e955e49..1d6092ff 100644 --- a/locale/en/pirates.cfg +++ b/locale/en/pirates.cfg @@ -13,7 +13,7 @@ softmod_info_new_players_1=For New Players softmod_info_new_players_2=Mine coal and other resources and bring them to the ship to keep things going, or try asking the captain for more specific tasks. softmod_info_tips_1=Features of the game that are hard to work out alone -softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Productivity modules can't be used in machines.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password +softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password softmod_info_1_1=v1.6.1–1.6.5 highlights softmod_info_1_2=• Optional setting for new crews to disable blueprints.\n• Each island now has a grace period of 2 minutes before attacks.\n• Machines now deactivate after several minutes spent waiting at sea.\n• Private crews and captain-protected crews no longer revert to public crews when inactive. Runs now autodisband after 96 hours of inactivity.\n• Further slowing of gameplay for small crews. diff --git a/maps/pirates/crew.lua b/maps/pirates/crew.lua index 4577e703..04c08a33 100644 --- a/maps/pirates/crew.lua +++ b/maps/pirates/crew.lua @@ -279,7 +279,9 @@ function Public.join_spectators(player, crewid) end if #Common.crew_get_crew_members() == 0 then - if Common.autodisband_hours then + local exists_disband_tick = memory.crew_disband_tick and memory.crew_disband_tick > game.tick + + if Common.autodisband_hours and not exists_disband_tick and Server.get_current_time() then memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60 end end @@ -312,7 +314,9 @@ function Public.leave_spectators(player, quiet) memory.spectatorplayerindices = Utils.ordered_table_with_values_removed(memory.spectatorplayerindices, player.index) if #Common.crew_get_crew_members() == 0 then - if Common.autodisband_hours then + local exists_disband_tick = memory.crew_disband_tick and memory.crew_disband_tick > game.tick + + if Common.autodisband_hours and not exists_disband_tick and Server.get_current_time() then memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60 end end @@ -492,7 +496,7 @@ function Public.leave_crew(player, to_lobby, quiet) if #Common.crew_get_crew_members() == 0 then local exists_disband_tick = memory.crew_disband_tick and memory.crew_disband_tick > game.tick - if Common.autodisband_hours and not exists_disband_tick then + if Common.autodisband_hours and not exists_disband_tick and Server.get_current_time() then memory.crew_disband_tick = game.tick + Common.autodisband_hours * 60 * 60 * 60 end