warzone2100/data/script/text/cam3a-d2x.slo

273 lines
7.5 KiB
Plaintext

//SLO file for LasSat firing
//on cam3A-D
//Nexus DOESN'T hold back for 5 mins yet! (need to communicate between scripts)
//a hack for this would be placing a unit for player X in region and using this as a trigger in the generic script
//no countdown sequence yet either!
//also doesn't check for Nexus destroying the missile silo as a mission fail (ID changes when taken over)
//will need to check player has a certain type of structure
//cam3A_DX.SLO
/* ******************** */
/* Declared Variables */
/* ******************** */
public int player, enemy, capRange;
public TEXTSTRING failed_msg;
public WEAPON lasSat;
private STRUCTURE silo[3]; //Missile silo object
public STRUCTURESTAT testStat, siloStat;
public INTMESSAGE brief, brief2, resMsg[4];
public SOUND failedSnd, warnSatSnd;
private int uplinkX[3], uplinkY[3], tempX, tempY, temp;
private int lasX1, lasX2, lasY1, lasY2, yMax, chance, timeLimit;
//private STRUCTURE target;
private BASEOBJ target;
private BOOL flag;
private int numTargets, targets[13], res;
//player research topics for missile codes
public RESEARCHSTAT playerRes[4];
private int count, uplinkPlayer;
private RESEARCHSTAT researchDone;
private GROUP grpGroup[1];
private DROID droid;
private STRUCTURE testStruc,structure;
trigger clearMessageTrig(wait, 100); //10 second delay
trigger nexusGoTrig(wait, 2950); //wait 5 mins (- 5secs) after warning
trigger captureDeadTrig(((silo[0] == NULLOBJECT) and (silo[1] == NULLOBJECT) and (silo[2] == NULLOBJECT)), 17);
trigger resDoneTrig(CALL_RESEARCHCOMPLETED, ref researchDone, ref structure, -1); //use playerRes[res] to check against what's been completed //trigger for research completed
trigger missileLaunchTrig(wait, 20); //play launch sequence
trigger fireLasSatTrig(wait, 100); //every 10 seconds
trigger fireLasSatTrig2(wait, 150); //every 15 seconds
trigger fireLasSatTrig3(wait, 200); //every 20 seconds
trigger fireLasSatTrig4(wait, 250); //every 25 seconds
trigger moveSatTrig(every, 318); //every 31.8 seconds (1hr 8min to cover 3AD)
event fireLasSat;
event resDone;
event missileLaunch;
event start(CALL_GAMEINIT)
{
//don't let player see 3B anymore
setScrollMinY(126);
//setScrollParams(0, 64, 58, 256);
//need to give player research for NEXUS intruder program
res = 0; //keeps track of research to test done
enableResearch(playerRes[res], player);
lasX1 = 64; //set LasSat area limits (change later)
lasY1 = 16000; //3A and B
lasX2 = 8000;
lasY2 = 16384;
chance = 50; //starting chance to hit %age
//allow LasSats to hit gamma base
yMax = 32576; //allow 3AD!! //24576;
//setup target types
numTargets = 13;
//use wall more than anything else so picks more often
targets[0] = ST_HQ; //ST_WALL
targets[1] = ST_FACTORY;
targets[2] = ST_POWER_GEN;
targets[3] = ST_RESOURCE_EXTRACTOR;
targets[4] = ST_WALL;
targets[5] = ST_RESEARCH;
targets[6] = ST_REPAIR_FACILITY;
targets[7] = ST_COMMAND_CONTROL;
targets[8] = ST_CYBORG_FACTORY;
targets[9] = ST_VTOL_FACTORY; //ST_WALL
targets[10] = ST_REARM_PAD;
targets[11] = ST_SENSOR;
targets[12] = ST_DEF_ALL;
}
event nukeEm(wait, 5)
{
//need to nuke all player structures in 3AB
count = 0;
while (count < 20)
{
killStructsInArea(player, count, 0, 0, 8128, 16384, FALSE, FALSE);
count = count + 1;
}
//need to nuke all player units in 3AB
killDroidsInArea(0,0,8128, 16384, player);
}
//to check if player no longer has the silos
event captureDeadEvnt(inactive)
{
//don't allow win
setEventTrigger(resDone, inactive);
setEventTrigger(missileLaunch, inactive);
//need to play audio if possible
addConsoleText(failed_msg, player);
playSound(failedSnd, player);
pause(20);
extraFailFlag = TRUE;
setEventTrigger(captureDeadEvnt, inactive);
}
event allowLose(wait, 20)
{
//need to find missile silos belonging to Player
//they need to be of a type not used by anything else
initEnumStruct(FALSE, siloStat, player, player);
testStruc = enumStruct();
count = 0;
while ((testStruc != NULLOBJECT) and (count < 3))
{
silo[count] = testStruc; //found silo!!!
//playSound(failedSnd, player);
count = count + 1;
testStruc = enumStruct();
}
setEventTrigger(captureDeadEvnt, captureDeadTrig);
}
event clearMessage(inactive)
{
flushConsoleMessages();
setEventTrigger(clearMessage, inactive);
}
event nexusGo(nexusGoTrig) //wait 5mins
{
//start Nexus forces attacking when time is up
//give player warning
addMessage(brief2, MISS_MSG, 0, true);
//set timelimit
setMissionTime(timeLimit);
//Start Las Sat firing
//setEventTrigger(fireLasSat, fireLasSatTrig);
}
event missileLaunch(inactive)
{
//either done here or as part of win sequence?
//may want countdown here...
extraVictoryFlag = TRUE; //only when player done all research
//addMessage(winMsg, MISS_MSG, 0, true);
setEventTrigger(fireLasSat, inactive);
}
event resDone(resDoneTrig)
{
//play research done messages (4 in all)
//check that the research completed is the one we are interested in
if (researchDone == playerRes[res])
{
if (res < 3)
{
addMessage(resMsg[res], MISS_MSG, 0, true);
res = res + 1;
//enable the next research topic
enableResearch(playerRes[res], player);
}
else if (res >= 3)
{
addMessage(resMsg[res], MISS_MSG, 0, true);
setEventTrigger(missileLaunch, missileLaunchTrig);
setEventTrigger(resDone, inactive);
}
}
}
event fireLasSat(fireLasSatTrig)
{
//find a target in area
resetStructTargets();
setStructTarPref(targets[random(numTargets)]); //pick random target type preference
//setStructTarPref(targets[4]); //pick walls to check
target = structTargetInArea(player, -1, lasX1, lasY1, lasX2, lasY2);
//if no structures to hit go for Droids
if (target == NULLOBJECT)
{
resetDroidTargets();
target = droidTargetInArea(player, -1, lasX1, lasY1, lasX2, lasY2);
}
if (target != NULLOBJECT)
{
if (random(100) < chance)
{
tempX = target.x; //store for audio message later
tempY = target.y;
//hit target
fireWeaponAtObj(lasSat, target);
}
else
{
//try to just miss target
//use pickStructLocation
tempX = target.x - 512 + random(1024); //slight randomisation for better effect
tempY = target.y - 512 + random(1024);
flag = pickStructLocation(testStat, ref tempX, ref tempY,player);
if (flag)
{
tempX = tempX - 64 + random(128); //randomise result a bit more
tempY = tempY - 64 + random(128);
fireWeaponAtLoc(lasSat, tempX, tempY);
}
//if can't miss, then hit close by anyway!
else
{
//pick random coords (hopefully miss!)
tempX = target.x - 512 + random(1024); //slight randomisation for better effect
tempY = target.y - 512 + random(1024);
fireWeaponAtLoc(lasSat, tempX, tempY);
}
}
}
else
{
//pick random coords (hopefully miss!)
tempX = lasX1 + random(lasX2 - lasX1);
tempY = lasY1 + random(lasY2 - lasY1);
fireWeaponAtLoc(lasSat, tempX, tempY);
}
//warn player that lassat has fired!
if (random(100) < 50)
{
playSoundPos(warnSatSnd, selectedPlayer, tempX, tempY, 0); //warn player!!
}
//set random time for next firing
temp = random(4);
if (temp == 0)
{
setEventTrigger(fireLasSat, fireLasSatTrig);
}
else if (temp == 1)
{
setEventTrigger(fireLasSat, fireLasSatTrig2);
}
else if (temp == 2)
{
setEventTrigger(fireLasSat, fireLasSatTrig3);
}
else
{
setEventTrigger(fireLasSat, fireLasSatTrig4);
}
}
event moveSat(moveSatTrig)
{
if (lasY2 < yMax)
{
lasY2 = lasY2 + 128; //add another tile to limit, so creeps into 3A in 10 mins
//lasY1 = lasY1 + 64; //add another 1/2 tile to limit, so stops targetting north so much
}
}