Skip to content

Commit

Permalink
Improve upon gameOverMessage function.
Browse files Browse the repository at this point in the history
No longer plays the mission end or win video in multiplayer. Now it can
play the game outro from within it.
  • Loading branch information
KJeff01 committed Nov 29, 2017
1 parent 04f2ffe commit 652dde1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
10 changes: 4 additions & 6 deletions data/base/script/campaign/cam3-4.js
Expand Up @@ -91,11 +91,10 @@ function enableAllFactories()

function enableReinforcements()
{
camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, undefined, {
camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, "GAMMA_OUT", {
area: "RTLZ",
reinforcements: 60, // 1 min
annihilate: true,
victoryVideo: "MB3_4_OUTRO"
annihilate: true
});
}

Expand Down Expand Up @@ -124,11 +123,10 @@ function eventStartLevel()
var tpos = getObject("transportEntryExit");
var lz = getObject("landingZone");

camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, undefined, {
camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, "GAMMA_OUT", {
area: "RTLZ",
reinforcements: -1,
annihilate: true,
victoryVideo: "MB3_4_OUTRO"
annihilate: true
});

centreView(startpos.x, startpos.y);
Expand Down
5 changes: 5 additions & 0 deletions data/base/script/campaign/libcampaign.js
Expand Up @@ -2475,6 +2475,11 @@ function __camGameWon()
if (camDef(__camNextLevel))
{
camTrace(__camNextLevel);
if (__camNextLevel === "GAMMA_OUT")
{
gameOverMessage(true, true);
return;
}
camNextLevel(__camNextLevel);
}
else
Expand Down
31 changes: 23 additions & 8 deletions src/qtscriptfuncs.cpp
Expand Up @@ -69,6 +69,7 @@
#include "warcam.h"
#include "projectile.h"
#include "component.h"
#include "seqdisp.h"

#define FAKE_REF_LASSAT 999
#define ALL_PLAYERS -1
Expand Down Expand Up @@ -2810,17 +2811,23 @@ static QScriptValue js_playSound(QScriptContext *context, QScriptEngine *engine)
return QScriptValue();
}

//-- \subsection{gameOverMessage(won)}
//-- \subsection{gameOverMessage(won, showOutro)}
//-- End game in victory or defeat.
static QScriptValue js_gameOverMessage(QScriptContext *context, QScriptEngine *engine)
{
int player = engine->globalObject().property("me").toInt32();
const MESSAGE_TYPE msgType = MSG_MISSION; // always
bool gameWon = context->argument(0).toBool();
bool showOutro = false;
if (context->argumentCount() > 1)
{
showOutro = context->argument(1).toBool();
}
VIEWDATA *psViewData;
if (gameWon)
{
psViewData = getViewData("WIN");
//Quick hack to stop assert when trying to play outro in campaign.
psViewData = !bMultiPlayer && showOutro ? getViewData("END") : getViewData("WIN");
addConsoleMessage(_("YOU ARE VICTORIOUS!"), DEFAULT_JUSTIFY, SYSTEM_MESSAGE);
}
else
Expand All @@ -2830,15 +2837,23 @@ static QScriptValue js_gameOverMessage(QScriptContext *context, QScriptEngine *e
}
ASSERT(psViewData, "Viewdata not found");
MESSAGE *psMessage = addMessage(msgType, false, player);
if (psMessage)
if (!bMultiPlayer && psMessage)
{
//set the data
psMessage->pViewData = psViewData;
displayImmediateMessage(psMessage);
stopReticuleButtonFlash(IDRET_INTEL_MAP);

//we need to set this here so the VIDEO_QUIT callback is not called
setScriptWinLoseVideo(gameWon ? PLAY_WIN : PLAY_LOSE);
seq_ClearSeqList();
if (gameWon && showOutro)
{
seq_AddSeqToList("outro.ogg", nullptr, "outro.txa", false);
seq_StartNextFullScreenVideo();
}
else
{
//set the data
psMessage->pViewData = psViewData;
displayImmediateMessage(psMessage);
stopReticuleButtonFlash(IDRET_INTEL_MAP);
}
}
jsDebugMessageUpdate();
displayGameOver(gameWon);
Expand Down

0 comments on commit 652dde1

Please sign in to comment.