Jump to content
Sign in to follow this  
RizlaUK

Setting Correct Timer On Defend Co-op Mission

Recommended Posts

Hi,

 

I'm running an Invade & Annex Server and i'm trying to change a few things. The main things being when the mission turns into a defend and the A.I. counter attack. It's setup in such a way that when the Bluefor have killed most of the Opfor and there is only around 15 Opfor left a 6 minute countdown is activated and what should happen is;

 

a. the timer expires and if Bluefor are in the AO area then it's classed as a succesful defend.

b. the remaining 15 Opfor are elimated before the timer ends, also a successful defend but it ends the timer early.

c. Bluefor are elimated and a new 6 minute timer is activated, if the Bluefor don't re-occupy the area within the 6 minute countdown, it's a failed defend. (This behaviour should happen at any time during the Defend, basically if the Opfor elimate all the human players they need to get back to the AO within 6 mins or it's failed and a new AO will spawn)/*

 

As it stands at the minute, what is happening is;

 

a. we get to the 15 remaining Opfor and the timer kicks in, but when it expires, it doesn't despawn the last few Opfor and activate a successful defend.(we have to still find the last 15, which gets boring)

b. we are elimated by Opfor and the AO stays in defend mode forever, until we get back and kill all the Opfor.

 

I wonder if somebody could help with this please?

 

Regards

 

Rizla

 

Author:

    Jester [AW] & Quiksilver

Last modified:

    16/04/2014 by QS
    
Description:

    When AO is complete, a chance that OPFOR will counterattack.
    
    Create AO detection trigger
    At end of sequence, count WEST.
    if (WEST < 1) exitWith {lost};
    if (WEST > 0) exitWith (held);
    
    Also, APCs spawned with EOS do not engage for whatever reason
_______________________________________________________*/

private ["_pos","_rad","_survivors","_type","_dt"];

sleep 1;

if(random 1 >= 0.35) then {
    
    _defendMessages = [
        "OPFOR Forces incoming! Seek cover immediately and defend the objective area!",
        "The enemy managed to call in reinforcements! Form a perimeter around the objective area!"
    ];
    _targetStartText = format [
        "<t align='center' size='2.2'>Defend Target</t><br/><t size='1.5' align='center' color='#0d4e8f'>%1</t><br/>____________________<br/>We have a problem. The enemy managed to call in reinforcements. They are on the way to take back the last target. You need to defend it at all costs!",
        currentAO
    ];

    [_targetStartText] remoteExec ["AW_fnc_globalHint",0,false];
    ["NewMainDefend", currentAO] remoteExec ["AW_fnc_globalNotification",0,false];

    {_x setMarkerPos (getMarkerPos currentAO);} forEach ["aoCircle_2","aoMarker_2"];
    "aoMarker_2" setMarkerText format["Defend %1",currentAO];

    sleep 180;
    //publicVariable "refreshMarkers";
    publicVariable "currentAO";
    currentAOUp = true;
    radioTowerAlive = false;

    _playersOnlineHint = format [
        "<t size='1.5' align='left' color='#C92626'>Enemy attacking %1!</t><br/><br/>____________________<br/>Get ready boys they're on their way here!", currentAO
    ];

    _defendTimer1 = 480;            // 480
    _defendTimer2 = random 120;        // 120
    
    [_playersOnlineHint] remoteExec ["AW_fnc_globalHint",0,false];

    sleep 30;

    hqSideChat = _defendMessages call BIS_fnc_selectRandom;
    [hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];

    _type = [1,2,3];
    _selectedType = _type select (floor (random (count _type)));
    
    if (_selectedType == 1) then {
        null = [["aoCircle_2"],[5,5],[3,2],[0],[1,0],[0,0,EAST],[0,2,360,FALSE,true]] call Bastion_Spawn;
    };
    if (_selectedType == 2) then {
        null = [["aoCircle_2"],[5,5],[3,2],[0],[2,0],[0,0,EAST],[0,2,360,FALSE,true]] call Bastion_Spawn;
    };
    if (_selectedType == 3) then {
        null = [["aoCircle_2"],[5,5],[3,2],[3],[1,0],[0,0,EAST],[0,2,360,FALSE,true]] call Bastion_Spawn;
    };
        
    hqSideChat = "Thermal images show the bastards are at the perimeter of the AO!";
    [hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];
            
    sleep 30;
            
    hqSideChat = "";
    [hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];
            
    sleep _defendTimer1;
        
    hqSideChat = "";
    [hqSideChat] remoteExec ["AW_fnc_globalSideChat",0,false];
    
    sleep _defendTimer2;
    
        
    //Lets add a check to make sure all OPFOR units are killed.
    _PositionCheck = getMarkerPos currentAO;
    
    //Start a loop to check if units are alive or not
    _AttackContinue = true;
    While {_AttackContinue} do
    {
        _OpforUnitList = [];
        
        {if (side _x IsEqualTo EAST) then {_OpforUnitList pushback _x}; } forEach allUnits;
        
        //If the opfor unit is more than 1000 M. away. Do not consider him apart of the town assault.
        {
            if (_x distance _PositionCheck > 900) then {_OpforUnitList = _OpforUnitList - [_x];};
        } foreach _OpforUnitList;
        
        if (count _OpforUnitList <= 15) then {_AttackContinue = false;};
        
        //Check every 5 seconds
        sleep 5;
    };
    
    
    _targetEndText = format [
        "<t align='center' size='2.2'>Keep It Going!</t><br/><t size='1.5' align='center' color='#0d4e8f'>%1</t><br/>____________________<br/>The Defense is almost over! Keep Going!",
        currentAO
    ];

    [_targetEndText] remoteExec ["AW_fnc_globalHint",0,false];
    
    
    _waitTime = 0;
    _finalPush = true;
    While {_waitTime < 360 and _finalPush} do
    {
    _OpforUnitList = [];

    {if (side _x IsEqualTo EAST) then {_OpforUnitList pushback _x}; } forEach allUnits;

    {
    if (_x distance _PositionCheck > 900) then {_OpforUnitList = _OpforUnitList - [_x];};
    } foreach _OpforUnitList;

    if (count _OpforUnitList == 0) then {_finalPush = false;_waitTime = _waitTime + 5;};

    //Check every 5 seconds
    sleep 5;

};
    
    _targetEndText = format [
        "<t align='center' size='2.2'>Defended Target</t><br/><t size='1.5' align='center' color='#0d4e8f'>%1</t><br/>____________________<br/>That looks like the last of them!",
        currentAO
    ];

    [_targetEndText] remoteExec ["AW_fnc_globalHint",0,false];

    [["aoCircle_2"]] call EOS_deactivate;
    
    //------------------------------------------------- DELETE
    
    deleteVehicle _dt;
    [enemiesArray] spawn QS_fnc_AOdelete;
    if (_chance < PARAMS_RadioTowerMineFieldChance) then {[_unitsArray] spawn QS_fnc_AOdelete;};

   //----------------------------------------------------- MAINTENANCE
    
    _aoClean = [] execVM "scripts\misc\clearItemsAO.sqf";
    waitUntil {
        scriptDone _aoClean
    };
    sleep 20;
};

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×