1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-17 20:58:13 +02:00

Merge pull request #204 from ComfyFactory/changes

User requested changes
This commit is contained in:
Gerkiz 2022-01-14 22:56:57 +01:00 committed by GitHub
commit 547c6dadd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 255 additions and 42 deletions

View File

@ -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

View File

@ -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},

View File

@ -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

View File

@ -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

View File

@ -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}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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