Skip to content

Commit

Permalink
Utilize the transport timer on Beta End
Browse files Browse the repository at this point in the history
  • Loading branch information
DARwins1 committed Oct 16, 2023
1 parent 806f503 commit 72e7e69
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 25 deletions.
19 changes: 19 additions & 0 deletions data/base/script/campaign/libcampaign_includes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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()
Expand Down Expand Up @@ -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();

Expand Down
10 changes: 7 additions & 3 deletions src/mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down Expand Up @@ -525,6 +525,7 @@ void orderUpdateDroid(DROID *psDroid)
missionDroidsRemaining(selectedPlayer))
{
resetTransporter();
triggerEvent(TRIGGER_TRANSPORTER_LANDED, psDroid);
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions src/transporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
35 changes: 17 additions & 18 deletions src/wzapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}

Expand Down

0 comments on commit 72e7e69

Please sign in to comment.