diff --git a/maps/fish_defender_v2/main.lua b/maps/fish_defender_v2/main.lua index bf747607..ebe5c414 100644 --- a/maps/fish_defender_v2/main.lua +++ b/maps/fish_defender_v2/main.lua @@ -1336,40 +1336,42 @@ function Public.reset_game() end Difficulty.reset_difficulty_poll({difficulty_poll_closing_timeout = wave_grace_period}) - local difficulties = { - [1] = { - name = 'Easy', - value = 0.75, - color = {r = 0.00, g = 0.25, b = 0.00}, - print_color = {r = 0.00, g = 0.4, b = 0.00}, - enabled = true - }, - [2] = { - name = 'Normal', - value = 1, - color = {r = 0.00, g = 0.00, b = 0.25}, - print_color = {r = 0.0, g = 0.0, b = 0.5} - }, - [3] = { - name = 'Hard', - value = 1.5, - color = {r = 0.25, g = 0.00, b = 0.00}, - print_color = {r = 0.4, g = 0.0, b = 0.00} - }, - [4] = { - name = 'Nightmare', - value = 3, - color = {r = 0.35, g = 0.00, b = 0.00}, - print_color = {r = 0.6, g = 0.0, b = 0.00} - }, - [5] = { - name = 'Impossible', - value = 5, - color = {r = 0.45, g = 0.00, b = 0.00}, - print_color = {r = 0.8, g = 0.0, b = 0.00} + if game.is_multiplayer() then + local difficulties = { + [1] = { + name = 'Easy', + value = 0.75, + color = {r = 0.00, g = 0.25, b = 0.00}, + print_color = {r = 0.00, g = 0.4, b = 0.00}, + enabled = true + }, + [2] = { + name = 'Normal', + value = 1, + color = {r = 0.00, g = 0.00, b = 0.25}, + print_color = {r = 0.0, g = 0.0, b = 0.5} + }, + [3] = { + name = 'Hard', + value = 1.5, + color = {r = 0.25, g = 0.00, b = 0.00}, + print_color = {r = 0.4, g = 0.0, b = 0.00} + }, + [4] = { + name = 'Nightmare', + value = 3, + color = {r = 0.35, g = 0.00, b = 0.00}, + print_color = {r = 0.6, g = 0.0, b = 0.00} + }, + [5] = { + name = 'Impossible', + value = 5, + color = {r = 0.45, g = 0.00, b = 0.00}, + print_color = {r = 0.8, g = 0.0, b = 0.00} + } } - } - Difficulty.set_difficulties(difficulties) + Difficulty.set_difficulties(difficulties) + end local players = game.connected_players for i = 1, #players do diff --git a/maps/mountain_fortress_v3/basic_markets.lua b/maps/mountain_fortress_v3/basic_markets.lua index 5bfd8371..1107d8aa 100644 --- a/maps/mountain_fortress_v3/basic_markets.lua +++ b/maps/mountain_fortress_v3/basic_markets.lua @@ -52,7 +52,7 @@ market.caspules = { ['defender-capsule'] = {value = 18, rarity = 1}, ['distractor-capsule'] = {value = 68, rarity = 5}, ['destroyer-capsule'] = {value = 74, rarity = 7}, - ['discharge-defense-remote'] = {value = 9216, rarity = 8}, + ['discharge-defense-remote'] = {value = 8222, rarity = 8}, ['artillery-targeting-remote'] = {value = 1024, rarity = 7}, ['raw-fish'] = {value = 6, rarity = 1} } @@ -73,7 +73,7 @@ market.equipment = { ['battery-equipment'] = {value = 160, rarity = 2}, ['battery-mk2-equipment'] = {value = 2000, rarity = 8}, ['personal-laser-defense-equipment'] = {value = 2500, rarity = 7}, - ['discharge-defense-equipment'] = {value = 15000, rarity = 7}, + ['discharge-defense-equipment'] = {value = 8444, rarity = 8}, ['belt-immunity-equipment'] = {value = 200, rarity = 1}, ['exoskeleton-equipment'] = {value = 800, rarity = 3}, ['personal-roboport-equipment'] = {value = 500, rarity = 3}, diff --git a/maps/mountain_fortress_v3/icw/functions.lua b/maps/mountain_fortress_v3/icw/functions.lua index a25b344b..1e2c4311 100644 --- a/maps/mountain_fortress_v3/icw/functions.lua +++ b/maps/mountain_fortress_v3/icw/functions.lua @@ -34,7 +34,8 @@ local reconstruct_all_trains = ) local function get_tile_name() - local main_tile_name = 'tutorial-grid' + -- local main_tile_name = 'tutorial-grid' + local main_tile_name = 'black-refined-concrete' return main_tile_name end diff --git a/maps/mountain_fortress_v3/locomotive/market.lua b/maps/mountain_fortress_v3/locomotive/market.lua index 9a7498bd..37026bad 100644 --- a/maps/mountain_fortress_v3/locomotive/market.lua +++ b/maps/mountain_fortress_v3/locomotive/market.lua @@ -402,7 +402,7 @@ local function get_items() main_market_items['car'] = { stack = 1, value = 'coin', - price = 6000, + price = 4500, tooltip = ({'main_market.car'}), upgrade = false, static = true diff --git a/maps/mountain_fortress_v3/mining.lua b/maps/mountain_fortress_v3/mining.lua index e2ed4485..1ca8f2a7 100644 --- a/maps/mountain_fortress_v3/mining.lua +++ b/maps/mountain_fortress_v3/mining.lua @@ -199,10 +199,10 @@ end local function mining_chances_ores() local data = { - {name = 'iron-ore', chance = 25}, - {name = 'copper-ore', chance = 17}, - {name = 'coal', chance = 15}, - {name = 'stone', chance = 13}, + {name = 'iron-ore', chance = 26}, + {name = 'copper-ore', chance = 21}, + {name = 'coal', chance = 17}, + {name = 'stone', chance = 6}, {name = 'uranium-ore', chance = 2} } diff --git a/modules/rpg/gui.lua b/modules/rpg/gui.lua index 29d8a059..a8f1d422 100644 --- a/modules/rpg/gui.lua +++ b/modules/rpg/gui.lua @@ -445,7 +445,7 @@ function Public.draw_level_text(player) local players = {} for _, p in pairs(game.players) do - if p.index ~= player.index then + if p.index ~= player.index then -- todo maybe remove this so the player also sees their level? players[#players + 1] = p.index end end diff --git a/modules/wave_defense/core.lua b/modules/wave_defense/core.lua index 0c1fb330..830ac66b 100644 --- a/modules/wave_defense/core.lua +++ b/modules/wave_defense/core.lua @@ -9,6 +9,9 @@ Public.buried_enemies = Buried_enemies local Commands = require 'modules.wave_defense.commands' Public.commands = Commands +local Pause_Waves = require 'modules.wave_defense.pause_waves' +Public.pause_waves = Pause_Waves + local Gui = require 'modules.wave_defense.gui' Public.gui = Gui diff --git a/modules/wave_defense/pause_waves.lua b/modules/wave_defense/pause_waves.lua new file mode 100644 index 00000000..9e51beda --- /dev/null +++ b/modules/wave_defense/pause_waves.lua @@ -0,0 +1,204 @@ +local Event = require 'utils.event' +local Gui = require 'utils.gui' +local Public = require 'modules.wave_defense.table' +local Token = require 'utils.token' +local Task = require 'utils.task' +local Server = require 'utils.server' + +local main_frame_name = Gui.uid_name() +local save_button_name = Gui.uid_name() +local discard_button_name = Gui.uid_name() +local random = math.random + +local random_greetings = { + 'Dear defender', + 'Defenders', + 'Dear players', + 'Fellow players' +} + +local random_greetings_size = #random_greetings + +function Public.main_gui(player, text) + local main_frame = player.gui.screen[main_frame_name] + if main_frame and main_frame.valid then + main_frame.destroy() + end + main_frame = + player.gui.screen.add( + { + type = 'frame', + name = main_frame_name, + caption = 'A stretch is needed.', + direction = 'vertical' + } + ) + main_frame.auto_center = true + local main_frame_style = main_frame.style + main_frame_style.width = 500 + + local inside_frame = main_frame.add {type = 'frame', style = 'inside_shallow_frame'} + local inside_frame_style = inside_frame.style + inside_frame_style.padding = 0 + local inside_table = inside_frame.add {type = 'table', column_count = 1} + local inside_table_style = inside_table.style + inside_table_style.vertical_spacing = 0 + + inside_table.add({type = 'line'}) + + local info_main = + inside_table.add( + { + type = 'label', + caption = '[color=yellow]' .. text .. ',[/color]' + } + ) + local info_main_style = info_main.style + info_main_style.font = 'default-large-bold' + info_main_style.padding = 0 + info_main_style.left_padding = 10 + info_main_style.horizontal_align = 'left' + info_main_style.vertical_align = 'bottom' + info_main_style.single_line = false + info_main_style.font_color = {0.55, 0.55, 0.99} + + inside_table.add({type = 'line'}) + + local info_sub = + inside_table.add( + { + type = 'label', + caption = 'We have played for ' .. + Server.format_time(game.ticks_played) .. ' now.\nIf you want to take a quick break,\nplease vote to pause the waves for 5 minutes.' + } + ) + local info_sub_style = info_sub.style + info_sub_style.font = 'default-game' + info_sub_style.padding = 0 + info_sub_style.left_padding = 10 + info_sub_style.horizontal_align = 'left' + info_sub_style.vertical_align = 'bottom' + info_sub_style.single_line = false + + inside_table.add({type = 'line'}) + + local bottom_flow = main_frame.add({type = 'flow', direction = 'horizontal'}) + + local left_flow = bottom_flow.add({type = 'flow'}) + left_flow.style.horizontal_align = 'left' + left_flow.style.horizontally_stretchable = true + + local close_button = left_flow.add({type = 'button', name = discard_button_name, caption = 'I cannot rest!'}) + close_button.style = 'back_button' + + local right_flow = bottom_flow.add({type = 'flow'}) + right_flow.style.horizontal_align = 'right' + + local save_button = right_flow.add({type = 'button', name = save_button_name, caption = 'I need to stretch'}) + save_button.style = 'confirm_button' + + player.opened = main_frame +end + +function Public.display_pause_wave(player, text) + if not player then + return + end + if not text then + return + end + return Public.main_gui(player, text) +end + +local function pause_waves_state(state) + if state then + game.print('[color=blue][Wave Defense][/color] New waves will not spawn for 5 minutes!', {r = 0.98, g = 0.66, b = 0.22}) + Public.set('paused', true) + else + game.print('[color=blue][Wave Defense][/color] Waves will spawn normally again.', {r = 0.98, g = 0.66, b = 0.22}) + Public.set('paused', false) + end +end + +local pause_waves_state_token = Token.register(pause_waves_state) + +Gui.on_click( + save_button_name, + function(event) + local player = event.player + if not player or not player.valid or not player.character then + return + end + + local total_players = #game.connected_players + local pause_waves = Public.get('pause_waves') + if not pause_waves[player.index] then + pause_waves[player.index] = true + pause_waves.index = pause_waves.index + 1 + end + + local divided = total_players / 2 + + if pause_waves.index >= divided then + Public.set('pause_waves', {index = 0}) + local players = game.connected_players + for i = 1, #players do + local p = players[i] + local screen = p.gui.screen + local frame = screen[main_frame_name] + p.surface.play_sound({path = 'utility/new_objective', position = p.position, volume_modifier = 0.75}) + + if frame and frame.valid then + Gui.remove_data_recursively(frame) + frame.destroy() + end + end + pause_waves_state(true) + Task.set_timeout_in_ticks(18000, pause_waves_state_token, false) -- 5 minutes + return + end + + local screen = player.gui.screen + local frame = screen[main_frame_name] + + if frame and frame.valid then + Gui.remove_data_recursively(frame) + frame.destroy() + end + end +) + +Gui.on_click( + discard_button_name, + function(event) + local player = event.player + local screen = player.gui.screen + local frame = screen[main_frame_name] + if not player or not player.valid or not player.character then + return + end + if frame and frame.valid then + Gui.remove_data_recursively(frame) + frame.destroy() + end + end +) + +Event.on_nth_tick( + 216000, -- 1 hour + function() + if game.ticks_played < 100 then + return + end + + local greeting = random_greetings[random(1, random_greetings_size)] + + local players = game.connected_players + for i = 1, #players do + local player = players[i] + Public.display_pause_wave(player, greeting) + end + end +) + +return Public diff --git a/modules/wave_defense/table.lua b/modules/wave_defense/table.lua index f4671f14..64bc2735 100644 --- a/modules/wave_defense/table.lua +++ b/modules/wave_defense/table.lua @@ -88,6 +88,9 @@ function Public.reset_wave_defense() this.worm_raffle = {} this.alert_boss_wave = false this.remove_entities = false + this.pause_waves = { + index = 0 + } this.enable_side_target = false this.enable_threat_log = true this.disable_threat_below_zero = false