Skip to content

Commit

Permalink
Utilize the transport timer on Beta End (#3421)
Browse files Browse the repository at this point in the history
  • Loading branch information
DARwins1 authored Oct 18, 2023
1 parent 9423ce1 commit 452e21b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 38 deletions.
20 changes: 20 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,14 @@ 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 +370,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
29 changes: 13 additions & 16 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 @@ -1434,11 +1434,8 @@ void endMission()
abort();
}

if (missionCanReEnforce()) //mission.type == LDS_MCLEAR || mission.type == LDS_MKEEP)
{
intRemoveMissionTimer();
intRemoveTransporterTimer();
}
intRemoveMissionTimer();
intRemoveTransporterTimer();

//at end of mission always do this
intRemoveTransporterLaunch();
Expand Down Expand Up @@ -3087,7 +3084,7 @@ void clearMissionWidgets()
intRemoveMissionTimer();
}

if (missionCanReEnforce())
if (mission.ETA >= 0)
{
intRemoveTransporterTimer();
}
Expand Down Expand Up @@ -3131,17 +3128,17 @@ void resetMissionWidgets()
stopMissionButtonFlash(IDTIMER_FORM);
}

if (missionCanReEnforce())
DROID* transporter = find_transporter();

// Check if not a reinforcement type mission and we have an transporter
if (!missionForReInforcements() && transporter != nullptr && !transporterFlying(transporter))
{
addTransporterTimerInterface();
// Show launch button if the transporter has not already been launched
intAddTransporterLaunch(transporter);
}
//check not a typical reinforcement mission
else if (!missionForReInforcements())
else if (mission.ETA >= 0)
{
if (auto transporter = find_transporter())
{
intAddTransporterLaunch(transporter);
}
addTransporterTimerInterface();
}

}
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 @@ -2526,30 +2526,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 452e21b

Please sign in to comment.