Skip to content

Commit

Permalink
Mtn v3 - minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed May 30, 2024
1 parent 3db00ee commit fd2b5ef
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
8 changes: 4 additions & 4 deletions maps/mountain_fortress_v3/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,23 +348,23 @@ commands.add_command(
return
end
if not Collapse.has_collapse_started() then
Collapse.start_now(true)
Collapse.start_now(true, false)
Discord.send_notification_raw(scenario_name, player.name .. ' has enabled collapse.')
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled collapse!', {r = 0.98, g = 0.66, b = 0.22})
log(player.name .. ', has enabled collapse!')
else
Collapse.start_now(false)
Collapse.start_now(false, true)
Discord.send_notification_raw(scenario_name, player.name .. ' has disabled collapse.')
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled collapse!', {r = 0.98, g = 0.66, b = 0.22})
log(player.name .. ', has disabled collapse!')
end
else
if not Collapse.has_collapse_started() then
Collapse.start_now(true)
Collapse.start_now(true, false)
Discord.send_notification_raw(scenario_name, 'Server has enabled collapse.')
log('Collapse has started.')
else
Collapse.start_now(false)
Collapse.start_now(false, true)
Discord.send_notification_raw(scenario_name, 'Server has disabled collapse.')
log('Collapse has stopped.')
end
Expand Down
9 changes: 6 additions & 3 deletions maps/mountain_fortress_v3/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ end
local pause_waves_custom_callback_token =
Task.register(
function(status)
Collapse.start_now(status)
local status_str = status and 'has stopped!' or 'is active once again!'
Alert.alert_all_players(30, 'Collapse ' .. status_str, nil, 'achievement/tech-maniac', 0.6)
local wave_number = WD.get_wave()
if wave_number >= 200 then
Collapse.start_now(status)
local status_str = status and 'has stopped!' or 'is active once again!'
Alert.alert_all_players(30, 'Collapse ' .. status_str, nil, 'achievement/tech-maniac', 0.6)
end
end
)

Expand Down
17 changes: 16 additions & 1 deletion modules/collapse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,15 @@ function Public.get_speed()
return this.speed
end

function Public.start_now(state)
--- Set the collapse to start or not, accepts a second argument to disable the collapse completely.
---@param state boolean
---@param disabled boolean
---@return boolean
function Public.start_now(state, disabled)
this.start_now = state or false

this.disabled = disabled or false

return this.start_now
end

Expand All @@ -454,6 +460,10 @@ function Public.reverse_start_now(state)
end

function Public.has_collapse_started()
if this.disabled then
return true
end

return this.start_now
end

Expand Down Expand Up @@ -499,6 +509,7 @@ local function on_init()
this.tiles = nil
this.reverse_tiles = nil
this.speed = 1
this.disabled = false
this.reverse_start_now = false
this.amount = 8
this.start_now = false
Expand All @@ -510,6 +521,10 @@ local function on_tick()
return
end

if this.disabled then
return
end

progress()
progress_reverse()
end
Expand Down
3 changes: 2 additions & 1 deletion modules/wave_defense/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ function Public.update_gui(player)
gui.wave_number.caption = wave_number
if wave_number == 0 then
gui.label.caption = {'wave_defense.gui_1'}
gui.label.tooltip = 'Next pause will occur in: ' .. floor((Public.get('next_pause_interval') - game.tick) / 60 / 60) + 1 .. ' minute(s)'
gui.wave_number.caption = floor((next_wave - game.tick) / 60) + 1 .. 's'
end
gui.label.tooltip = 'Next pause will occur in: ' .. floor((Public.get('next_pause_interval') - game.tick) / 60 / 60) + 1 .. ' minute(s)'
gui.wave_number.tooltip = 'Next pause will occur in: ' .. floor((Public.get('next_pause_interval') - game.tick) / 60 / 60) + 1 .. ' minute(s)'
local interval = next_wave - last_wave
local value = 1 - (next_wave - game.tick) / interval
if value < 0 then
Expand Down

0 comments on commit fd2b5ef

Please sign in to comment.