Skip to content

Commit

Permalink
qtscript: Add two new functions related to transporter handling in ca…
Browse files Browse the repository at this point in the history
…mpaign,

startTransporterEntry(x, y, player) and setTransporterExit(x,y, player).
  • Loading branch information
perim committed Jan 25, 2013
1 parent 3ed8a41 commit b1b60ba
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/init.cpp
Expand Up @@ -1078,7 +1078,6 @@ bool stageThreeInitialise(void)
DROID *psDroid;

debug(LOG_WZ, "== stageThreeInitalise ==");
bTrackingTransporter = false;

loopMissionState = LMS_NORMAL;

Expand Down
12 changes: 0 additions & 12 deletions src/mission.cpp
Expand Up @@ -127,9 +127,6 @@ MISSION mission;

bool offWorldKeepLists;

// Set by scrFlyInTransporter. True if were currenly tracking the transporter.
bool bTrackingTransporter = false;

/*lists of droids that are held seperate over several missions. There should
only be selectedPlayer's droids but have possibility for MAX_PLAYERS -
also saves writing out list functions to cater for just one player*/
Expand Down Expand Up @@ -637,8 +634,6 @@ void missionFlyTransportersIn(SDWORD iPlayer, bool bTrackTransporter)

ASSERT_OR_RETURN(, iPlayer < MAX_PLAYERS, "Flying nonexistent player %d's transporters in", iPlayer);

bTrackingTransporter = bTrackTransporter;

iLandX = getLandingX(iPlayer);
iLandY = getLandingY(iPlayer);
missionGetTransporterEntry(iPlayer, &iX, &iY);
Expand Down Expand Up @@ -1763,13 +1758,6 @@ void unloadTransporter(DROID *psTransporter, UDWORD x, UDWORD y, bool goingHome)
//unload all the droids from within the current Transporter
if (psTransporter->droidType == DROID_TRANSPORTER || psTransporter->droidType == DROID_SUPERTRANSPORTER)
{
// If the scripts asked for transporter tracking then clear the "tracking a transporter" flag
// since the transporters landed and unloaded now.
if (psTransporter->player == selectedPlayer)
{
bTrackingTransporter = false;
}

// reset the transporter cluster
psTransporter->cluster = 0;
for (psDroid = psTransporter->psGroup->psList; psDroid != NULL && psDroid != psTransporter; psDroid = psNext)
Expand Down
3 changes: 0 additions & 3 deletions src/mission.h
Expand Up @@ -37,9 +37,6 @@
#define MAX_NOGO_AREAS (MAX_PLAYERS + 1)
#define LIMBO_LANDING MAX_PLAYERS

/** Set by scrFlyInTransporter. True if were currenly tracking the transporter. */
extern bool bTrackingTransporter;

extern MISSION mission;
extern bool offWorldKeepLists;
extern DROID *apsLimboDroids[MAX_PLAYERS];
Expand Down
30 changes: 30 additions & 0 deletions src/qtscriptfuncs.cpp
Expand Up @@ -2220,6 +2220,34 @@ static QScriptValue js_getMissionTime(QScriptContext *, QScriptEngine *)
return QScriptValue((mission.time - (gameTime - mission.startTime)) / GAME_TICKS_PER_SEC);
}

//-- \subsection{setTransporterExit(x, y, player)}
//-- Set the exit position for the mission transporter.
static QScriptValue js_setTransporterExit(QScriptContext *context, QScriptEngine *)
{
int x = context->argument(0).toInt32();
int y = context->argument(1).toInt32();
int player = context->argument(2).toInt32();
SCRIPT_ASSERT_PLAYER(context, player);
missionSetTransporterExit(player, x, y);
return QScriptValue();
}

//-- \subsection{startTransporterEntry(x, y, player)}
//-- Set the entry position for the mission transporter, and make it start flying in
//-- reinforcements. If you want the camera to follow it in, use cameraTrack() on it.
//-- The transport needs to be set up with the mission droids, and the first transport
//-- found will be used.
static QScriptValue js_startTransporterEntry(QScriptContext *context, QScriptEngine *)
{
int x = context->argument(0).toInt32();
int y = context->argument(1).toInt32();
int player = context->argument(2).toInt32();
SCRIPT_ASSERT_PLAYER(context, player);
missionSetTransporterEntry(player, x, y);
missionFlyTransportersIn(player, false);
return QScriptValue();
}

//-- \subsection{setReinforcementTime(time)} Set time for reinforcements to arrive. If time is
//-- negative, the reinforcement GUI is removed and the timer stopped. Time is in seconds.
static QScriptValue js_setReinforcementTime(QScriptContext *context, QScriptEngine *)
Expand Down Expand Up @@ -3801,6 +3829,8 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
engine->globalObject().setProperty("donateObject", engine->newFunction(js_donateObject));
engine->globalObject().setProperty("donatePower", engine->newFunction(js_donatePower));
engine->globalObject().setProperty("setNoGoArea", engine->newFunction(js_setNoGoArea));
engine->globalObject().setProperty("startTransporterEntry", engine->newFunction(js_startTransporterEntry));
engine->globalObject().setProperty("setTransporterExit", engine->newFunction(js_setTransporterExit));

// Set some useful constants
engine->globalObject().setProperty("WEATHER_CLEAR", WT_NONE, QScriptValue::ReadOnly | QScriptValue::Undeletable);
Expand Down

0 comments on commit b1b60ba

Please sign in to comment.