74 lines
2.2 KiB
Plaintext
74 lines
2.2 KiB
Plaintext
|
//SLO file for capturing NASDA central Uplink structure when player is near
|
||
|
//updates victory and fail conditions
|
||
|
|
||
|
//cam2DX.SLO
|
||
|
|
||
|
/* ******************** */
|
||
|
/* Declared Variables */
|
||
|
/* ******************** */
|
||
|
|
||
|
public int player, enemy, uplinkPlayer, capRange;
|
||
|
public STRUCTURE uplink;
|
||
|
public TEXTSTRING failed_msg, captured_msg;
|
||
|
public SOUND goodSnd, badSnd;
|
||
|
private int uplinkX, uplinkY;
|
||
|
|
||
|
trigger captureTrig((droidInRange(player, uplinkX, uplinkY, 300) and (uplink != NULLOBJECT)), 13); //3 tiles range
|
||
|
trigger captureDeadTrig((uplink == NULLOBJECT), 17);
|
||
|
trigger clearMessageTrig(wait, 100); //10 second delay
|
||
|
|
||
|
event captureEvnt;
|
||
|
|
||
|
event start(CALL_GAMEINIT)
|
||
|
{
|
||
|
//set up alliances first so don't kill each other!
|
||
|
createAlliance(player, uplinkPlayer);
|
||
|
createAlliance(enemy, uplinkPlayer);
|
||
|
|
||
|
if (uplink != NULLOBJECT)
|
||
|
{
|
||
|
uplinkX = uplink.x;
|
||
|
uplinkY = uplink.y;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
event captureDeadEvnt(captureDeadTrig)
|
||
|
{
|
||
|
/* PROBLEM WITH THIS KICKING IN EVEN WHEN STRUCTURE CAPTURED */
|
||
|
/* MAY JUST REQUIRE REORDER OF TURNING EVENTS INACTIVE BEFORE DOING ACTIONS */
|
||
|
//need to play audio if possible
|
||
|
addConsoleText(failed_msg, player);
|
||
|
playSound(badSnd, player); //Objective destroyed
|
||
|
extraFailFlag = TRUE;
|
||
|
//don't allow win
|
||
|
setEventTrigger(captureDeadEvnt, inactive);
|
||
|
setEventTrigger(captureEvnt, inactive);
|
||
|
}
|
||
|
|
||
|
event clearMessage(inactive)
|
||
|
{
|
||
|
flushConsoleMessages();
|
||
|
setEventTrigger(clearMessage, inactive);
|
||
|
}
|
||
|
|
||
|
event captureEvnt(captureTrig)
|
||
|
{
|
||
|
//check taht no enemy defences/units nearby
|
||
|
if ((numDroidsInArea(enemy, uplinkX - capRange, uplinkY - capRange, uplinkX + capRange, uplinkY + capRange) == 0)
|
||
|
and (numStructsByTypeInArea(enemy, REF_DEFENSE, uplinkX - capRange, uplinkY - capRange, uplinkX + capRange, uplinkY + capRange) == 0))
|
||
|
{
|
||
|
//convert structure to player ownership now script function exists
|
||
|
takeOverStructsInArea(uplinkPlayer, player, uplinkX - 128, uplinkY - 128, uplinkX + 128, uplinkY + 128);
|
||
|
//need to play Audio if possible
|
||
|
showConsoleText(captured_msg, player);
|
||
|
playSound(goodSnd, player); //Objective captured
|
||
|
extraVictoryFlag = TRUE;
|
||
|
//don't allow lose
|
||
|
setEventTrigger(captureEvnt, inactive);
|
||
|
setEventTrigger(captureDeadEvnt, inactive);
|
||
|
setEventTrigger(clearMessage, clearMessageTrig);
|
||
|
}
|
||
|
}
|
||
|
|