warzone2100/data/script/text/cam2cx.slo

283 lines
9.4 KiB
Plaintext

//SLO file for making civilians appear and get hearded to LZ for pickup by enemy transports
//Also makes civilians become player controlled when they're near enough and no enemies nearby
//cam2CX.SLO
/* ******************** */
/* Declared Variables */
/* ******************** */
public int player, enemy, scavs;
public int wayX[10], wayY[10];
public TEMPLATE civilian, cyborg;
public int LZX, LZY, LZoneX, LZoneY, LZRange, entryX, entryY, exitX, exitY;
public int numGroups, groupX1[3], groupY1[3], groupX2[3], groupY2[3];
public int groupWayStart[3], groupWayEnd[3], LZX1, LZY1, LZX2, LZY2, trigX1, trigY1, trigX2, trigY2;
private GROUP group[3], civGroup[3], tempGroup, tempGroup2;
private int currentWay[3], count, count2, count3, temp, temp2, totCivs, rescuedCivs, capturedCivs;
private DROID droid;
//transport stuff
public TEMPLATE transporter; //required for enemy transports landing
public SOUND warnSnd, rescueSnd, badSnd;
public TEXTSTRING badMsg;
private DROID transportDroid;
private BOOL transFlag; //is transport on map?
//rescue struff
public int capRange, playerLZX, playerLZY, baseX1, baseX2, baseY1, baseY2;
private int tempX1, tempX2, tempY1, tempY2;
public INTMESSAGE brief, objective;
public SOUND incomingSnd;
public int repNum, repTot, escCivs;
public int timeLimit;
trigger followTrig(wait, 20); //1 seconds behind
trigger landTransTrig((not transFlag) and (numDroidsInArea(scavs, LZX - LZRange, LZY - LZRange, LZX + LZRange, LZY + LZRange) > 0), 33);
trigger transReadyTrig(CALL_TRANSPORTER_OFFMAP, enemy);
trigger startCyborgsTrig(droidInArea(player, trigX1, trigY1, trigX2, trigY2), 41); //only trigger when player near!
trigger moveCyborgsTrig(every, 55);
trigger nowTrig(wait, 1);
//trigger startCyborgsTrig2((numStructsButNotWallsInArea(enemy, baseX1, baseY1, baseX2, baseY2) == 0)
// and (numDroidsInArea(enemy, baseX1, baseY1, baseX2, baseY2) == 0), 83);
trigger startCyborgsTrig2(numStructsButNotWallsInArea(enemy, baseX1, baseY1, baseX2, baseY2) == 0, 83);
event startCyborgs2;
event landTrans;
event start(CALL_GAMEINIT)
{
//set up alliances first so don't kill each other!
createAlliance(player, scavs);
createAlliance(enemy, scavs);
totCivs = 3; //starting number of civilians
//set up cyborg shepherd groups
count = 0;
while (count < numGroups)
{
//get initial civilians into group
groupAddArea(civGroup[count], scavs, groupX1[count], groupY1[count], groupX2[count], groupY2[count]);
groupAddArea(group[count], enemy, groupX1[count], groupY1[count], groupX2[count], groupY2[count]);
currentWay[count] = groupWayStart[count];
//orderGroupLoc(group[count], DORDER_MOVE, wayX[currentWay[count]], wayY[currentWay[count]]);
count = count + 1;
}
//add enemy transport (once!)
//setNoGoArea done in generic (since initialises there! initAllNoGoAreas())
//setNoGoArea((LZX - 1)/128, (LZY - 1)/128, (LZX + 1)/128, (LZY + 1)/128, enemy);
transportDroid = addDroidToMissionList(transporter, enemy);
}
//cyborgs and civilians ordered to waypoints. Waypoints also used for where civilians appear
event moveCyborgs(inactive)
{
count = 0;
while (count < numGroups)
{
//only reorder if >50% idle
if (idleGroup(group[count]) >= group[count].members / 2)
{
if ((currentWay[count] >= groupWayEnd[count] - 1) and (repNum < repTot))
{
//reached entrance to base so order to LZ or back to base
currentWay[count] = groupWayStart[count]; //repeat shepherding
repNum = repNum + 1;
//orderGroupLoc(group[count], DORDER_MOVE, wayX[currentWay[count] + 1], wayY[currentWay[count] + 1]);
orderGroupLoc(group[count], DORDER_MOVE, wayX[currentWay[count]], wayY[currentWay[count]]);
orderGroupLoc(civGroup[count], DORDER_MOVE, LZoneX, LZoneY);
}
else if (currentWay[count] >= groupWayEnd[count] - 1)
{
orderGroupLoc(group[count], DORDER_MOVE, wayX[currentWay[count] + 1], wayY[currentWay[count] + 1]);
orderGroupLoc(civGroup[count], DORDER_MOVE, LZoneX, LZoneY);
}
else
{
//move civilians and flush civilians all done in here now!
//flush building first
count3 = 3; //3 + random(4); //create 3 to 6 civilians
//create max of 8 civilian units at this waypoint position
while (count3 > 0)
{
droid = NULLOBJECT;
droid = addDroid(civilian, wayX[currentWay[count]], wayY[currentWay[count]], scavs);
//if placed order to waypoint and assign to corresponding group
if (droid != NULLOBJECT)
{
groupAddDroid(civGroup[count], droid);
totCivs = totCivs + 1;
}
count3 = count3 - 1;
}
currentWay[count] = currentWay[count] + 1;
//order to next waypoint
if (group[count].members > 0)
{
orderGroupLoc(group[count], DORDER_MOVE, wayX[currentWay[count]], wayY[currentWay[count]]);
orderGroupLoc(civGroup[count], DORDER_MOVE, wayX[currentWay[count] + 1], wayY[currentWay[count] + 1]);
}
else
{
//flee to player's LZ when Cyborg shepherds dead
orderGroupLoc(civGroup[count], DORDER_MOVE, playerLZX, playerLZY);
}
}
}
count = count + 1;
}
}
//set them in motion when player nearby!
event startCyborgs(startCyborgsTrig)
{
setEventTrigger(startCyborgs2, inactive); //disable other start event
playSound(incomingSnd, player);
pause(20);
addMessage(objective, PROX_MSG, player, false); //give blip
addMessage(brief, MISS_MSG, player, true);
//add extra Mission time limit
timeLimit = timeLimit + missionTimeRemaining();
setMissionTime(timeLimit);
count = 0;
while (count < numGroups)
{
orderGroupLoc(group[count], DORDER_MOVE, wayX[currentWay[count]], wayY[currentWay[count]]);
count = count + 1;
}
setEventTrigger(moveCyborgs, moveCyborgsTrig);
setEventTrigger(startCyborgs, inactive);
}
event startCyborgs2(startCyborgsTrig2)
{
//start if player killed N base
setEventTrigger(startCyborgs, nowTrig); //enable other start event
setEventTrigger(startCyborgs2, inactive);
}
/* Transports */
/* transport landed so remove contents and nearby civilians */
event groupTrans(CALL_TRANSPORTER_LANDED, tempGroup, enemy)
{
//vanish contents of transport
initIterateGroup(tempGroup);
count = 0;
while (count < tempGroup.members)
{
droid = iterateGroup(tempGroup);
vanishUnit(droid);
count = count + 1;
}
//now vanish civilians in LZ area
groupAddArea(tempGroup2, scavs, LZX - LZRange, LZY - LZRange, LZX + LZRange, LZY + LZRange);
initIterateGroup(tempGroup2);
count = 0;
while (count < tempGroup2.members)
{
droid = iterateGroup(tempGroup2);
vanishUnit(droid);
capturedCivs = capturedCivs + 1;
count = count + 1;
}
//playSound(warnSnd, player);
pause(10);
}
event landTrans(landTransTrig)
{
if (transportDroid != NULLOBJECT)
{
//playSound(warnSnd, player);
playSoundPos(warnSnd, player, LZX * 128, LZY * 128, 0);
//call enemy transport in when civilians ordered to LZ
transFlag = TRUE;
droid = addDroidToMissionList(cyborg, enemy);
if (droid != NULLOBJECT)
{
addDroidToTransporter(transportDroid, droid);
//call in transport
setTransporterExit(enemy, exitX, exitY);
flyTransporterIn(enemy, entryX, entryY, false);
}
}
}
event nextTrans(transReadyTrig)
{
transFlag = FALSE;
}
//prevent transport if all defenses gone!
event stopTrans(numStructsByTypeInArea(enemy, REF_DEFENSE, LZX1, LZY1, LZX2, LZY2) == 0, 44)
{
setEventTrigger(landTrans, inactive);
setEventTrigger(stopTrans, inactive);
}
event rescueCivs(every, 22)
{
count = 0;
while (count < numGroups)
{
tempX1 = civGroup[count].x - capRange;
tempY1 = civGroup[count].y - capRange;
tempX2 = civGroup[count].x + capRange;
tempY2 = civGroup[count].y + capRange;
//check for player droids but no enemies near group
//if ((numDroidsInArea(player, tempX1, tempY1, tempX2, tempY2) > 0)
// and (numDroidsInArea(enemy, tempX1, tempY1, tempX2, tempY2) == 0))
//check for just player near civilians
if (numDroidsInArea(player, tempX1, tempY1, tempX2, tempY2) > 0)
{
groupAddArea(tempGroup2, scavs, tempX1, tempY1, tempX2, tempY2);
//may want to check how many captured and give audio cue here!
if (tempGroup2.members > 0)
{
playSound(rescueSnd, player); //"Civilian Rescued"
}
rescuedCivs = rescuedCivs + tempGroup2.members; //keep track of number rescued (may die later though!!)
//takeOverDroidsInArea(scavs, player, tempX1, tempY1, tempX2, tempY2); //removed from group as well!
//destroy civilians here
initIterateGroup(tempGroup2);
count2 = 0;
while (count2 < tempGroup2.members)
{
droid = iterateGroup(tempGroup2);
vanishUnit(droid);
count2 = count2 + 1;
}
}
count = count + 1;
}
}
event checkExtra(every, 66) //may want to wait until all the groups dead or at end of waypoints!
{
//Bad way of doing this, since can have neither condition fulfilled, so player doesn't win or lose
//changed so there is no extra victory condition, just extra fail condition
//Number for enemy to transport could be fixed, rather than calculated?
//if (capturedCivs > totCivs/2) //player loses if The Collective transport > 1/2 civilians!
if (capturedCivs > escCivs) //player loses if The Collective transport > 1/2 civilians!
{
playSound(badSnd, player); //"enemy escaping"
addConsoleText(badMsg, player); //text version
extraFailFlag = TRUE;
setEventTrigger(checkExtra, inactive);
}
/*
else if (rescuedCivs > totCivs/2) //player OK if he rescues > 1/2 civilians!
{
extraVictoryFlag = TRUE;
setEventTrigger(checkExtra, inactive);
}
*/
}