2020-05-17 12:23:55 +02:00
local Color = require ' utils.color_presets '
2022-10-25 23:29:40 +02:00
local Public = require ' maps.mountain_fortress_v3.table '
2020-05-17 12:23:55 +02:00
local Task = require ' utils.task '
2020-06-25 17:59:16 +02:00
local Server = require ' utils.server '
2021-11-11 01:57:58 +01:00
local Collapse = require ' modules.collapse '
2021-02-01 00:00:29 +01:00
local WD = require ' modules.wave_defense.table '
2024-01-03 00:15:53 +01:00
local Discord = require ' utils.discord_handler '
2020-05-17 12:23:55 +02:00
local mapkeeper = ' [color=blue]Mapkeeper:[/color] '
2024-01-03 00:15:53 +01:00
local scenario_name = ' Mtn Fortress '
2020-05-17 12:23:55 +02:00
commands.add_command (
2020-10-19 20:21:27 +02:00
' scenario ' ,
2020-06-07 23:25:01 +02:00
' Usable only for admins - controls the scenario! ' ,
function ( cmd )
2020-05-17 12:23:55 +02:00
local p
local player = game.player
2020-06-07 23:25:01 +02:00
if not player or not player.valid then
p = log
else
p = player.print
if not player.admin then
return
2020-05-17 12:23:55 +02:00
end
end
2022-10-25 23:29:40 +02:00
local this = Public.get ( )
2020-05-23 21:18:18 +02:00
local param = cmd.parameter
2020-05-17 12:23:55 +02:00
2020-06-25 17:59:16 +02:00
if param == ' restart ' or param == ' shutdown ' or param == ' reset ' or param == ' restartnow ' then
2020-06-07 23:25:01 +02:00
goto continue
else
2020-06-25 17:59:16 +02:00
p ( ' [ERROR] Arguments are: \n restart \n shutdown \n reset \n restartnow ' )
2020-06-07 23:25:01 +02:00
return
end
2020-05-23 21:18:18 +02:00
2020-06-07 23:25:01 +02:00
:: continue ::
2020-05-23 21:18:18 +02:00
2020-06-07 23:25:01 +02:00
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
2020-12-28 10:48:25 +01:00
p ( ' [WARNING] This command will disable the soft-reset feature, run this command again if you really want to do this! ' )
2020-06-07 23:25:01 +02:00
return
end
2020-05-23 21:18:18 +02:00
2020-06-07 23:25:01 +02:00
if param == ' restart ' then
if this.restart then
this.reset_are_you_sure = nil
this.restart = false
this.soft_reset = true
p ( ' [SUCCESS] Soft-reset is enabled. ' )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' has enabled soft-reset! ' )
2020-06-07 23:25:01 +02:00
return
2020-05-17 12:23:55 +02:00
else
2020-06-07 23:25:01 +02:00
this.reset_are_you_sure = nil
this.restart = true
this.soft_reset = false
if this.shutdown then
this.shutdown = false
2020-05-23 21:18:18 +02:00
end
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' has disabled soft-reset! Restart will happen from scenario. ' )
2020-07-25 22:22:21 +02:00
p ( ' [WARNING] Soft-reset is disabled! Server will restart from scenario to load new changes. ' )
2020-06-07 23:25:01 +02:00
return
end
2020-06-25 17:59:16 +02:00
elseif param == ' restartnow ' then
this.reset_are_you_sure = nil
Server.start_scenario ( ' Mountain_Fortress_v3 ' )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' restarted the scenario. ' )
2020-06-25 17:59:16 +02:00
return
2020-06-07 23:25:01 +02:00
elseif param == ' shutdown ' then
if this.shutdown then
this.reset_are_you_sure = nil
this.shutdown = false
this.soft_reset = true
p ( ' [SUCCESS] Soft-reset is enabled. ' )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' has enabled soft-reset. Server will NOT shutdown! ' )
2020-06-07 23:25:01 +02:00
return
else
this.reset_are_you_sure = nil
this.shutdown = true
this.soft_reset = false
if this.restart then
this.restart = false
2020-05-23 21:18:18 +02:00
end
2020-07-25 22:22:21 +02:00
p ( ' [WARNING] Soft-reset is disabled! Server will shutdown. Most likely because of updates. ' )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' has disabled soft-reset. Server will shutdown! ' )
2020-06-07 23:25:01 +02:00
return
2020-05-17 12:23:55 +02:00
end
2020-06-07 23:25:01 +02:00
elseif param == ' reset ' then
this.reset_are_you_sure = nil
if player and player.valid then
game.print ( mapkeeper .. ' ' .. player.name .. ' , has reset the game! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' has reset the game! ' )
2020-06-07 23:25:01 +02:00
else
game.print ( mapkeeper .. ' server, has reset the game! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , ' Server has reset the game! ' )
2020-06-07 23:25:01 +02:00
end
2022-10-25 23:29:40 +02:00
Public.reset_map ( )
2020-06-07 23:25:01 +02:00
p ( ' [WARNING] Game has been reset! ' )
return
2020-05-23 21:18:18 +02:00
end
end
)
commands.add_command (
' set_queue_speed ' ,
' Usable only for admins - sets the queue speed of this map! ' ,
function ( cmd )
local player = game.player
local param = tonumber ( cmd.parameter )
2020-05-17 12:23:55 +02:00
2021-08-21 12:46:10 +02:00
if player and player.valid then
if not player.admin then
2023-01-17 10:52:32 +01:00
player.print ( " [ERROR] You're not admin! " , Color.fail )
2021-08-21 12:46:10 +02:00
return
end
if not param then
return
2020-05-23 21:18:18 +02:00
end
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' set the queue speed to: ' .. param )
2023-01-17 10:52:32 +01:00
player.print ( ' Queue speed set to: ' .. param )
2021-08-21 12:46:10 +02:00
Task.set_queue_speed ( param )
else
2023-01-17 10:52:32 +01:00
log ( ' Queue speed set to: ' .. param )
2021-08-21 12:46:10 +02:00
Task.set_queue_speed ( param )
2020-05-17 12:23:55 +02:00
end
end
)
2024-01-03 00:15:53 +01:00
commands.add_command (
' complete_quests ' ,
' Usable only for admins - sets the queue speed of this map! ' ,
function ( )
local player = game.player
if player and player.valid then
if not player.admin then
player.print ( " [ERROR] You're not admin! " , Color.fail )
return
end
local this = Public.get ( )
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
player.print ( ' [WARNING] This command will break the current run and complete all quests, run this command again if you really want to do this! ' , Color.warning )
return
end
this.reset_are_you_sure = nil
Discord.send_notification_raw ( scenario_name , player.name .. ' completed all the quest via command. ' )
Public.stateful . set_stateful ( ' objectives_completed_count ' , 5 )
game.print ( mapkeeper .. player.name .. ' , has forced completed all quests! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
else
local this = Public.get ( )
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
log ( ' [WARNING] This command will break the current run and complete all quests, run this command again if you really want to do this! ' )
return
end
this.reset_are_you_sure = nil
log ( ' Quests completed. ' )
Discord.send_notification_raw ( scenario_name , ' Server completed all the quest via command ' )
Public.stateful . set_stateful ( ' objectives_completed_count ' , 5 )
end
end
)
2021-02-01 00:00:29 +01:00
commands.add_command (
' disable_biters ' ,
2022-04-05 20:02:13 +02:00
' Usable only for admins - disables wave defense! ' ,
2021-03-24 20:14:55 +01:00
function ( )
2021-02-01 00:00:29 +01:00
local player = game.player
2023-01-17 10:52:32 +01:00
if not player or not player.valid then
2021-02-01 00:00:29 +01:00
return
end
if not player.admin then
player.print ( " [ERROR] You're not admin! " , Color.fail )
return
end
2022-10-25 23:29:40 +02:00
local this = Public.get ( )
2021-02-01 00:00:29 +01:00
local tbl = WD.get ( )
if not this.disable_biters_are_you_sure then
this.disable_biters_are_you_sure = true
player.print ( ' [WARNING] This command will disable the wave_defense in-game, run this command again if you really want to do this! ' , Color.warning )
return
end
if not tbl.game_lost then
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' disabled the wave defense module. ' )
2021-02-01 00:00:29 +01:00
game.print ( mapkeeper .. ' ' .. player.name .. ' , has disabled the wave_defense module! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
tbl.game_lost = true
else
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' enabled the wave defense module. ' )
2021-02-01 00:00:29 +01:00
game.print ( mapkeeper .. ' ' .. player.name .. ' , has enabled the wave_defense module! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
tbl.game_lost = false
end
this.disable_biters_are_you_sure = nil
end
)
2022-07-10 21:53:18 +02:00
commands.add_command (
' toggle_orbital_strikes ' ,
' Usable only for admins - toggles orbital strikes! ' ,
function ( )
local player = game.player
2023-01-17 10:52:32 +01:00
if not player or not player.valid then
2022-07-10 21:53:18 +02:00
return
end
if not player.admin then
player.print ( " [ERROR] You're not admin! " , Color.fail )
return
end
2022-10-25 23:29:40 +02:00
local this = Public.get ( )
2022-07-10 21:53:18 +02:00
if not this.orbital_strikes_are_you_sure then
this.orbital_strikes_are_you_sure = true
player.print ( ' [WARNING] This command will disable the orbital_strikes in-game, run this command again if you really want to do this! ' , Color.warning )
return
end
if this.orbital_strikes . enabled then
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' disabled the orbital strike module. ' )
2022-07-10 21:53:18 +02:00
game.print ( mapkeeper .. ' ' .. player.name .. ' , has disabled the orbital_strikes module! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
this.orbital_strikes . enabled = false
else
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' enabled the orbital strike module. ' )
2022-07-10 21:53:18 +02:00
game.print ( mapkeeper .. ' ' .. player.name .. ' , has enabled the orbital_strikes module! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
this.orbital_strikes . enabled = true
end
this.orbital_strikes_are_you_sure = nil
end
)
2023-08-12 00:29:17 +02:00
commands.add_command (
' toggle_end_game ' ,
' Usable only for admins - initiates the final battle! ' ,
function ( )
local player = game.player
if not player or not player.valid then
return
end
if not player.admin then
player.print ( " [ERROR] You're not admin! " , Color.fail )
return
end
local this = Public.get ( )
if not this.final_battle_are_you_sure then
this.final_battle_are_you_sure = true
player.print ( ' [WARNING] This command will trigger the final battle, ONLY run this command again if you really want to do this! ' , Color.warning )
return
end
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' toggled the end game. ' )
2023-08-12 00:29:17 +02:00
Public.stateful . set_stateful ( ' final_battle ' , true )
Public.set ( ' final_battle ' , true )
game.print ( mapkeeper .. ' ' .. player.name .. ' , has triggered the final battle sequence! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
this.final_battle_are_you_sure = nil
end
)
2020-05-23 21:18:18 +02:00
commands.add_command (
' get_queue_speed ' ,
' Usable only for admins - gets the queue speed of this map! ' ,
function ( )
local p
local player = game.player
2021-08-21 12:46:10 +02:00
if player and player.valid then
p = player.print
if not player.admin then
p ( " [ERROR] You're not admin! " , Color.fail )
return
2020-05-17 12:23:55 +02:00
end
2021-08-21 12:46:10 +02:00
p ( Task.get_queue_speed ( ) )
else
p = log
p ( Task.get_queue_speed ( ) )
2020-05-17 12:23:55 +02:00
end
2020-05-23 21:18:18 +02:00
end
)
2021-11-11 01:57:58 +01:00
2023-01-17 10:52:32 +01:00
commands.add_command (
2023-08-10 14:28:32 +02:00
' disable_collapse ' ,
2023-01-17 10:52:32 +01:00
' Toggles the collapse feature ' ,
function ( )
local player = game.player
2021-11-11 01:57:58 +01:00
2023-01-17 10:52:32 +01:00
if player and player.valid then
if not player.admin then
player.print ( " [ERROR] You're not admin! " , Color.fail )
2021-11-11 01:57:58 +01:00
return
end
2023-08-10 14:28:32 +02:00
if Collapse.get_disable_state ( ) then
Collapse.disable_collapse ( false )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' has enabled collapse. ' )
2023-08-10 14:28:32 +02:00
game.print ( mapkeeper .. ' ' .. player.name .. ' , has enabled collapse! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
log ( player.name .. ' , has enabled collapse! ' )
2023-01-17 10:52:32 +01:00
else
2023-08-10 14:28:32 +02:00
Collapse.disable_collapse ( true )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , player.name .. ' has disabled collapse. ' )
2023-08-10 14:28:32 +02:00
game.print ( mapkeeper .. ' ' .. player.name .. ' , has disabled collapse! ' , { r = 0.98 , g = 0.66 , b = 0.22 } )
log ( player.name .. ' , has disabled collapse! ' )
2023-01-17 10:52:32 +01:00
end
else
2023-08-10 14:28:32 +02:00
if Collapse.get_disable_state ( ) then
Collapse.disable_collapse ( false )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , ' Server has enabled collapse. ' )
2023-01-17 10:52:32 +01:00
log ( ' Collapse has started. ' )
else
2023-08-10 14:28:32 +02:00
Collapse.disable_collapse ( true )
2024-01-03 00:15:53 +01:00
Discord.send_notification_raw ( scenario_name , ' Server has disabled collapse. ' )
2023-01-17 10:52:32 +01:00
log ( ' Collapse has stopped. ' )
2021-11-11 01:57:58 +01:00
end
end
2023-01-17 10:52:32 +01:00
end
)
2022-10-25 23:29:40 +02:00
return Public