Add script functions to set mission timers and limits.
parent
c261aca433
commit
0dae5eaee0
|
@ -2,12 +2,12 @@
|
|||
script "cam1a.slo"
|
||||
run
|
||||
{
|
||||
|
||||
/* General Values */
|
||||
player int 0
|
||||
enemy1 int 7 //barbarians (base1)
|
||||
enemy2 int 6 //barbarians (base2)
|
||||
startPower int 1300 //initial power level
|
||||
//commandCentre STRUCTURE 926
|
||||
|
||||
/* Starting Tech */
|
||||
viperBody BODY "Body1REC"
|
||||
|
@ -20,16 +20,12 @@ numTech int 3
|
|||
tech[0] RESEARCHSTAT "R-Vehicle-Body01"
|
||||
tech[1] RESEARCHSTAT "R-Sys-Spade1Mk1"
|
||||
tech[2] RESEARCHSTAT "R-Vehicle-Prop-Wheels"
|
||||
//tech[3] RESEARCHSTAT "CAM1RESEARCH" //"R-Wpn-MG1Mk1"
|
||||
|
||||
|
||||
|
||||
/* Set Structure Limits */
|
||||
powerGen STRUCTURESTAT "A0PowerGenerator"
|
||||
oilDerrick STRUCTURESTAT "A0ResourceExtractor"
|
||||
research STRUCTURESTAT "A0ResearchFacility"
|
||||
factory STRUCTURESTAT "A0LightFactory"
|
||||
//powerModuleHack STRUCTURESTAT "A0PowMod1"
|
||||
command STRUCTURESTAT "A0CommandCentre"
|
||||
numPow INT 5 //Limit on number of Power Generator Buildings
|
||||
numExt INT 200 //Limit on number of resource Extractors
|
||||
|
@ -45,7 +41,6 @@ MissionBrief2 INTMESSAGE "MB1A_MSG"
|
|||
obj1Msg INTMESSAGE "C1A_OBJ1"
|
||||
incomingSnd SOUND "pcv456.ogg"
|
||||
endMsg INTMESSAGE "END"
|
||||
//winMsg INTMESSAGE "WIN"
|
||||
|
||||
/* Proximity: Artifacts */
|
||||
crate FEATURESTAT "Crate"
|
||||
|
@ -54,28 +49,23 @@ art1X int 5184
|
|||
art1Y int 2112
|
||||
art1Get STRUCTURE 8 //get this from base1 factory
|
||||
art1Snd2 SOUND "pcv352.ogg"
|
||||
//art1Msg INTMESSAGE "C1A_ART1"
|
||||
art1Comp RESEARCHSTAT "R-Wpn-Flamer01Mk1"
|
||||
|
||||
art2X int 2496
|
||||
art2Y int 4032
|
||||
art2Get STRUCTURE 1256 //get this from base2 southern factory
|
||||
art2Snd2 SOUND "pcv352.ogg"
|
||||
//art2Msg INTMESSAGE "C1A_ART2"
|
||||
art2Comp RESEARCHSTAT "R-Sys-Engineering01"
|
||||
|
||||
art3X int 1856
|
||||
art3Y int 1600
|
||||
art3Get STRUCTURE 20 //get this from base2 factory
|
||||
art3Snd2 SOUND "pcv352.ogg"
|
||||
//art3Msg INTMESSAGE "C1A_ART3"
|
||||
art3Comp RESEARCHSTAT "R-Defense-Tower01" //guntowerMG now
|
||||
|
||||
art4X int 3776 //4416
|
||||
art4Y int 4544 //5312
|
||||
//art4Get STRUCTURE 3414 //not req'd, placed in script
|
||||
art4Snd2 SOUND "pcv352.ogg"
|
||||
//art4Msg INTMESSAGE "C1A_ART4"
|
||||
art4Comp RESEARCHSTAT "R-Wpn-MG-Damage01"
|
||||
|
||||
//Player Bonus Research Topics given on completion of mission
|
||||
|
@ -107,7 +97,6 @@ enm22 STRUCTURE 1256 //base2=factory2
|
|||
enm22ID STRUCTUREID 1256
|
||||
enm22Msg INTMESSAGE "C1A_BASE3"
|
||||
enm22Snd1 SOUND "pcv374.ogg"
|
||||
//enm22Snd2 SOUND "pcv391.ogg"
|
||||
|
||||
/* Win or lose */
|
||||
lostSnd SOUND "pcv470.ogg" //mission failed
|
||||
|
@ -121,5 +110,4 @@ buggy TEMPLATE "BarbarianBuggy"
|
|||
bloke TEMPLATE "BaBaPeople"
|
||||
jeep TEMPLATE "BabaJeep"
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -151,7 +151,6 @@ event startEvnt(CALL_GAMEINIT)
|
|||
// take over the selectedPlayer's units to avoid id number clashes on later levels
|
||||
takeOverDroidsInArea(0,0, 0,0, mapWidth * 128, mapHeight * 128);
|
||||
|
||||
//centreView(commandCentre);
|
||||
centreViewPos(1728, 6720); //centre near transport
|
||||
// set zoom Level 64x64
|
||||
setRadarZoom(1);
|
||||
|
@ -388,7 +387,6 @@ event lostYetEvnt(winLoseTrig)
|
|||
setEventTrigger(lostYetEvnt, inactive);
|
||||
setEventTrigger(timeUp, inactive);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
|
||||
#include "console.h"
|
||||
#include "map.h"
|
||||
#include "mission.h"
|
||||
#include "group.h"
|
||||
#include "transporter.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Utility functions -- not called directly from scripts
|
||||
|
@ -306,6 +308,82 @@ static QScriptValue js_orderDroidLoc(QScriptContext *context, QScriptEngine *)
|
|||
return QScriptValue();
|
||||
}
|
||||
|
||||
static QScriptValue js_setMissionTime(QScriptContext *context, QScriptEngine *)
|
||||
{
|
||||
int value = context->argument(0).toInt32() * 100;
|
||||
mission.time = value;
|
||||
setMissionCountDown();
|
||||
if (mission.time >= 0)
|
||||
{
|
||||
mission.startTime = gameTime;
|
||||
addMissionTimerInterface();
|
||||
}
|
||||
else
|
||||
{
|
||||
intRemoveMissionTimer();
|
||||
mission.cheatTime = 0;
|
||||
}
|
||||
return QScriptValue();
|
||||
}
|
||||
|
||||
static QScriptValue js_setReinforcementTime(QScriptContext *context, QScriptEngine *)
|
||||
{
|
||||
int value = context->argument(0).toInt32() * 100;
|
||||
ASSERT_OR_RETURN(QScriptValue(), value == LZ_COMPROMISED_TIME || value < 60 * 60 * GAME_TICKS_PER_SEC,
|
||||
"The transport timer cannot be set to more than 1 hour!");
|
||||
mission.ETA = value;
|
||||
if (missionCanReEnforce())
|
||||
{
|
||||
addTransporterTimerInterface();
|
||||
}
|
||||
if (value < 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 != NULL; psDroid = psDroid->psNext)
|
||||
{
|
||||
if (psDroid->droidType == DROID_TRANSPORTER)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if not found a transporter, can remove the launch button
|
||||
if (psDroid == NULL)
|
||||
{
|
||||
intRemoveTransporterLaunch();
|
||||
}
|
||||
}
|
||||
return QScriptValue();
|
||||
}
|
||||
|
||||
static QScriptValue js_setStructureLimits(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
QString building = context->argument(0).toString();
|
||||
int limit = context->argument(1).toInt32();
|
||||
int player;
|
||||
int structInc = getStructStatFromName(building.toUtf8().constData());
|
||||
if (context->argumentCount() > 2)
|
||||
{
|
||||
player = context->argument(2).toInt32();
|
||||
}
|
||||
else
|
||||
{
|
||||
player = engine->globalObject().property("me").toInt32();
|
||||
}
|
||||
ASSERT_OR_RETURN(QScriptValue(), player < MAX_PLAYERS && player >= 0, "Invalid player number");
|
||||
ASSERT_OR_RETURN(QScriptValue(), limit < LOTS_OF && limit >= 0, "Invalid limit");
|
||||
ASSERT_OR_RETURN(QScriptValue(), structInc < numStructureStats && structInc >= 0, "Invalid structure");
|
||||
|
||||
STRUCTURE_LIMITS *psStructLimits = asStructLimits[player];
|
||||
psStructLimits[structInc].limit = limit;
|
||||
psStructLimits[structInc].globalLimit = limit;
|
||||
|
||||
return QScriptValue();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Register functions with scripting system
|
||||
|
||||
|
@ -326,6 +404,9 @@ bool registerFunctions(QScriptEngine *engine)
|
|||
engine->globalObject().setProperty("groupAddDroid", engine->newFunction(js_groupAddDroid));
|
||||
engine->globalObject().setProperty("groupSize", engine->newFunction(js_groupSize));
|
||||
engine->globalObject().setProperty("orderDroidLoc", engine->newFunction(js_orderDroidLoc));
|
||||
engine->globalObject().setProperty("setMissionTime", engine->newFunction(js_setMissionTime));
|
||||
engine->globalObject().setProperty("setReinforcementTime", engine->newFunction(js_setReinforcementTime));
|
||||
engine->globalObject().setProperty("setStructureLimits", engine->newFunction(js_setStructureLimits));
|
||||
|
||||
// Set some useful constants
|
||||
engine->globalObject().setProperty("DORDER_ATTACK", DORDER_ATTACK, QScriptValue::ReadOnly | QScriptValue::Undeletable);
|
||||
|
|
|
@ -4758,18 +4758,10 @@ bool scrSetReinforcementTime(void)
|
|||
time = -1;
|
||||
}
|
||||
|
||||
//not interseted in this check any more - AB 28/01/99
|
||||
//quick check of the value - don't check if time has not been set
|
||||
/*if (mission.time > 0 && time != LZ_COMPROMISED_TIME && time > mission.time)
|
||||
{
|
||||
DBMB(("scrSetReinforcementTime: reinforcement time greater than mission time!"));
|
||||
}*/
|
||||
//store the value
|
||||
mission.ETA = time;
|
||||
|
||||
//if offworld or campaign change mission, then add the timer
|
||||
//if (mission.type == LDS_MKEEP || mission.type == LDS_MCLEAR ||
|
||||
// mission.type == LDS_CAMCHANGE)
|
||||
if (missionCanReEnforce())
|
||||
{
|
||||
addTransporterTimerInterface();
|
||||
|
|
Loading…
Reference in New Issue