From 72e7e69640ff1c6b75dbf8f7305dd8452786d9fc Mon Sep 17 00:00:00 2001 From: Dylan <28832631+DARwins1@users.noreply.github.com> Date: Mon, 16 Oct 2023 00:32:34 -0700 Subject: [PATCH] Utilize the transport timer on Beta End --- .../campaign/libcampaign_includes/events.js | 19 ++++++++++ src/mission.cpp | 10 ++++-- src/order.cpp | 5 +-- src/transporter.cpp | 5 +-- src/wzapi.cpp | 35 +++++++++---------- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/data/base/script/campaign/libcampaign_includes/events.js b/data/base/script/campaign/libcampaign_includes/events.js index c3be570b351..cf10e1686ee 100644 --- a/data/base/script/campaign/libcampaign_includes/events.js +++ b/data/base/script/campaign/libcampaign_includes/events.js @@ -236,6 +236,11 @@ function cam_eventTransporterExit(transport) setReinforcementTime(__camVictoryData.reinforcements); } } + // Show how long until the transporter comes back on Beta End. + if (__camWinLossCallback === CAM_VICTORY_TIMEOUT) + { + setReinforcementTime(__camVictoryData.reinforcements); + } } if (transport.player !== CAM_HUMAN_PLAYER || @@ -257,6 +262,13 @@ function cam_eventTransporterLanded(transport) { __camLandTransporter(transport.player, camMakePos(transport)); } + else + { + // Make the transporter timer on Beta End disappear, since the transporter has arrived. + if (__camWinLossCallback === CAM_VICTORY_TIMEOUT) { + setReinforcementTime(-1); + } + } } function cam_eventMissionTimeout() @@ -357,6 +369,13 @@ function cam_eventGameLoaded() } } + if (__camWinLossCallback === CAM_VICTORY_TIMEOUT + && enumDroid(CAM_HUMAN_PLAYER, DROID_SUPERTRANSPORTER).length === 0) + { + // If the transport is gone on Beta End, put a timer up to show when it'll be back + setReinforcementTime(__camVictoryData.reinforcements); + } + //Subscribe to eventGroupSeen again. camSetEnemyBases(); diff --git a/src/mission.cpp b/src/mission.cpp index f2f6893fa1d..3116056b001 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -543,8 +543,8 @@ void addTransporterTimerInterface() { bAddInterface = true; - //check timer is not already on the screen - if (!widgGetFromID(psWScreen, IDTRANTIMER_BUTTON)) + // Check that neither the timer nor the launch button are on screen + if (!widgGetFromID(psWScreen, IDTRANTIMER_BUTTON) && !widgGetFromID(psWScreen, IDTRANS_LAUNCH)) { intAddTransporterTimer(); } @@ -3140,7 +3140,11 @@ void resetMissionWidgets() { if (auto transporter = find_transporter()) { - intAddTransporterLaunch(transporter); + // Show launch button if the transporter has not already been launched + if (!transporterFlying(transporter)) + { + intAddTransporterLaunch(transporter); + } } } diff --git a/src/order.cpp b/src/order.cpp index a5168d247da..eed6487982d 100644 --- a/src/order.cpp +++ b/src/order.cpp @@ -484,11 +484,11 @@ void orderUpdateDroid(DROID *psDroid) } else { - //the script can call startMission for this callback for offworld missions - triggerEvent(TRIGGER_TRANSPORTER_EXIT, psDroid); /* clear order */ psDroid->order = DroidOrder(DORDER_NONE); } + //the script can call startMission for this callback for offworld missions (if we want to change level) + triggerEvent(TRIGGER_TRANSPORTER_EXIT, psDroid); psDroid->sMove.speed = 0; // Prevent radical movement vector when adjusting from home to away map exit and entry coordinates. } @@ -525,6 +525,7 @@ void orderUpdateDroid(DROID *psDroid) missionDroidsRemaining(selectedPlayer)) { resetTransporter(); + triggerEvent(TRIGGER_TRANSPORTER_LANDED, psDroid); } else { diff --git a/src/transporter.cpp b/src/transporter.cpp index 615dc2d08aa..e483d0ea00b 100644 --- a/src/transporter.cpp +++ b/src/transporter.cpp @@ -336,8 +336,9 @@ bool intAddTransporterLaunch(DROID *psDroid) //set up the static transporter psCurrTransporter = psDroid; - //check the button is not already up - if (widgGetFromID(psWScreen, IDTRANS_LAUNCH) != nullptr) + // Check that neither the launch button nor the transport timer are currently up + if (widgGetFromID(psWScreen, IDTRANS_LAUNCH) != nullptr + || widgGetFromID(psWScreen, IDTRANTIMER_BUTTON) != nullptr) { return true; } diff --git a/src/wzapi.cpp b/src/wzapi.cpp index f96cc456f6b..e5c460bdedd 100644 --- a/src/wzapi.cpp +++ b/src/wzapi.cpp @@ -2491,30 +2491,29 @@ wzapi::no_return_value wzapi::setReinforcementTime(WZAPI_PARAMS(int _time)) "The transport timer cannot be set to more than 1 hour!"); SCRIPT_ASSERT({}, context, selectedPlayer < MAX_PLAYERS, "Invalid selectedPlayer for current client: %" PRIu32 "", selectedPlayer); mission.ETA = time; - if (missionCanReEnforce()) - { - addTransporterTimerInterface(); - } + if (time < 0) { - DROID *psDroid; - intRemoveTransporterTimer(); - /* Only remove the launch if haven't got a transporter droid since the scripts set the - * time to -1 at the between stage if there are not going to be reinforcements on the submap */ - for (psDroid = apsDroidLists[selectedPlayer]; psDroid != nullptr; psDroid = psDroid->psNext) - { - if (isTransporter(psDroid)) - { - break; - } - } - // if not found a transporter, can remove the launch button - if (psDroid == nullptr) + } + DROID* psDroid; + + /* Search for a transport that is idle; if we can't find any, remove the launch button + * since there's no transport to launch */ + for (psDroid = apsDroidLists[selectedPlayer]; psDroid != nullptr; psDroid = psDroid->psNext) + { + if (isTransporter(psDroid) && !transporterFlying(psDroid)) { - intRemoveTransporterLaunch(); + break; } } + // Didn't find an idle transporter, we can remove the launch button + if (psDroid == nullptr) + { + intRemoveTransporterLaunch(); + } + resetMissionWidgets(); + addTransporterTimerInterface(); return {}; }