From 2090eef095b66990b187ca07af29870ded6305f7 Mon Sep 17 00:00:00 2001 From: spencershepard Date: Sun, 18 Feb 2024 10:46:55 -0800 Subject: [PATCH] fix mission end sequence --- scripts/RotorOpsServer.lua | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/scripts/RotorOpsServer.lua b/scripts/RotorOpsServer.lua index ff7a994..9a1e646 100644 --- a/scripts/RotorOpsServer.lua +++ b/scripts/RotorOpsServer.lua @@ -1,15 +1,26 @@ RotorOpsServer = {} -RotorOpsServer.version = "0.4" +RotorOpsServer.version = "0.5" trigger.action.outText("ROTOROPS SERVER SCRIPT: "..RotorOpsServer.version, 5) env.info("ROTOROPS SERVER SCRIPT STARTED: "..RotorOpsServer.version) --Mission Ending -RotorOpsServer.time_to_end = 900 +RotorOpsServer.time_to_end = 300 +RotorOpsServer.mission_ending = false +RotorOpsServer.result_text = "WE WON!" -function RotorOpsServer.endMission(secs) +--triggers may still be present in the miz to end the mission (20 minutes) +function RotorOpsServer.endMission(secs, winning_coalition_enum) + if RotorOpsServer.mission_ending then + return + end + env.info("RotorOpsServer: endMission called.") + RotorOpsServer.mission_ending = true if secs then RotorOpsServer.time_to_end = secs end + if winning_coalition_enum == 1 then + RotorOpsServer.result_text = "WE LOST!" + end local function countdown() local minutes = math.floor(RotorOpsServer.time_to_end / 60) @@ -17,10 +28,10 @@ function RotorOpsServer.endMission(secs) if seconds < 10 then seconds = "0" .. seconds end - trigger.action.outText("RTB now. Mission will end in "..minutes..":"..seconds, 2, true) + trigger.action.outText(RotorOpsServer.result_text .. " Standby. Mission will rotate in "..minutes..":"..seconds, 2, true) RotorOpsServer.time_to_end = RotorOpsServer.time_to_end - 1 if RotorOpsServer.time_to_end <= 0 then - trigger.action.setUserFlag('mission_end', 2) + trigger.action.setUserFlag('mission_end', winning_coalition_enum) else timer.scheduleFunction(countdown, {}, timer.getTime() + 1) end @@ -28,6 +39,18 @@ function RotorOpsServer.endMission(secs) countdown() end +function RotorOpsServer.checkGameState() + if RotorOps and RotorOps.game_state then + if RotorOps.game_state == 98 then + RotorOpsServer.endMission(240,1) + elseif RotorOps.game_state == 99 then + RotorOpsServer.endMission(240,2) + end + end + timer.scheduleFunction(RotorOpsServer.checkGameState, {}, timer.getTime() + 4) +end +RotorOpsServer.checkGameState() + --The following code for integrating the server bot spawn credits with PERKS works fine, but it needs to -- be moved to a server script so it's not dependent on this mission script.