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

253 lines
7.3 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 STRUCTURE silo[3]; //Missile silo object
public TEXTSTRING failed_msg, captured_msg;
public WEAPON lasSat;
public STRUCTURESTAT testStat;
public SOUND capturedSnd, warnSatSnd, failedSnd;
private int uplinkX[3], uplinkY[3], tempX, tempY, temp;
private int lasX1, lasX2, lasY1, lasY2, yMax, switch1, switch2, chance;
//private STRUCTURE target;
private BASEOBJ target;
private BOOL flag;
private int numTargets, targets[13], res;
private int count, uplinkPlayer;
private RESEARCHSTAT researchDone;
trigger captureTrig((droidInRange(player, uplinkX[0], uplinkY[0], 300) and ((silo[0] != NULLOBJECT) or (silo[1] != NULLOBJECT) or (silo[2] != NULLOBJECT))), 13); //3 tiles range
trigger nexusGoTrig(wait, 3000); //wait 5 mins after warning
trigger captureDeadTrig(((silo[0] == NULLOBJECT) and (silo[1] == NULLOBJECT) and (silo[2] == NULLOBJECT)), 17);
trigger fireLasSatTrig(wait, 50); //every 5 seconds
trigger fireLasSatTrig2(wait, 100); //every 10 seconds (1 hour on 3A)
trigger fireLasSatTrig3(wait, 150); //every 15 seconds
trigger fireLasSatTrig4(wait, 200); //every 20 seconds
trigger moveSatTrig(every, 50); //every 5 seconds //from N of 3B to N of 3A (10mins on 3B)
trigger moveSatTrig2(every, 250); //every 25 seconds //from N of 3A to N of 3C (50 mins on 3A)
trigger moveSatTrig3(every, 250); //every 25 seconds //from N of 3C to N of 3D (Not actually used!!)
event captureEvnt;
event fireLasSat;
event start(CALL_GAMEINIT)
{
if (silo[0] != NULLOBJECT)
{
uplinkX[0] = silo[0].x;
uplinkY[0] = silo[0].y;
uplinkX[1] = silo[1].x;
uplinkY[1] = silo[1].y;
uplinkX[2] = silo[2].x;
uplinkY[2] = silo[2].y;
uplinkPlayer = silo[0].player;
createAlliance(player, uplinkPlayer); //ally player with uplink
createAlliance(enemy, uplinkPlayer); //ally Enemy with uplink
}
lasX1 = 64; //set LasSat area limits (change later)
lasY1 = 64; //3B only (get to 3AB later)
lasX2 = 8000;
lasY2 = 128; //8000;
chance = 50; //starting chance to hit %age
yMax = 16384; //24576; //allow 3A-B
switch1 = 8192; //when switches speed for covering 3A
switch2 = 16384; //when switches speed for covering 3C
//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 clearMessage(inactive)
{
flushConsoleMessages();
setEventTrigger(clearMessage, inactive);
}
//need to check this again later (with different structure IDs, since player number has changed!!!)
event captureDeadEvnt(captureDeadTrig)
{
//don't allow win
setEventTrigger(captureEvnt, inactive);
//need to play audio if possible
addConsoleText(failed_msg, player);
playSound(failedSnd, player);
pause(20);
extraFailFlag = TRUE;
setEventTrigger(captureDeadEvnt, inactive);
}
event captureEvnt(captureTrig)
{
//check that no enemy defences/units nearby
if ((numDroidsInArea(enemy, uplinkX[0] - capRange, uplinkY[0] - capRange, uplinkX[0] + capRange,
uplinkY[0] + capRange) == 0) and (numStructsByTypeInArea(enemy, REF_DEFENSE, uplinkX[0] - capRange, uplinkY[0] - capRange, uplinkX[0] + capRange, uplinkY[0] + capRange) == 0))
{
setEventTrigger(captureDeadEvnt, inactive);
//convert structure to player ownership now script function exists
//takeOverStructsInArea(uplinkPlayer, player, uplinkX[0] - 1280, uplinkY[0] - 1280, uplinkX[0] + 1280, uplinkY[0] + 1280);
//new way to take over structures whilst keeping ID same
count = 0;
while (count < 3)
{
if (silo[count] != NULLOBJECT)
{
takeOverSingleStructure(silo[count], player);
}
count = count + 1;
}
//need to play Audio if possible?
playSound(capturedSnd, player);
showConsoleText(captured_msg, player);
pause(20);
extraVictoryFlag = TRUE;
setEventTrigger(captureEvnt, inactive);
}
}
event fireLasSat(fireLasSatTrig) //every 5 seconds
{
//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); //4 tiles either side
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) //every 10 seconds
{
if (lasY2 < yMax)
{
lasY2 = lasY2 + 128; //add another tile to limit, so creeps to North of 3A in 10 mins
//lasY1 = lasY1 + 64; //add another 1/2 tile to limit, so stops targetting north so much
//slow down for covering 3A
if (lasY2 > switch1)
{
setEventTrigger(moveSat, moveSatTrig2);
switch1 = 100000;
}
//slow down for covering 3C
if (lasY2 > switch2)
{
setEventTrigger(moveSat, moveSatTrig3);
switch2 = 100000;
}
}
}
/* not needed
event incChance(every, 10)
{
if (chance < 50)
{
chance = chance + 1; //increment chance up to maximum (50%)
}
else
{
setEventTrigger(incChance, inactive);
}
}
*/