Announcement

Collapse
No announcement yet.

Defense - End Mission script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Defense - End Mission script

    The problem I have with defense missions is you have to eliminate every last enemy unit. Sometimes they are over 300m out any which way in the trees and the mission just drags on and on. With this script I created two zones to check and if there is no enemy in the inner zone but less than 4 in an outer zone, then the mission is considered a success.

    Code:
    //opforCheck.sqf
    //check that the area is clear of Opfor for win
    // uses two zones so that you don't have to chase down every last OPFOR in a 400m radius
    // the trigger triggerObjZone is 200m round
    // the trigger triggerObjLargeZone is 400m round
    
    if (isServer) then
    	{
    	_run = true;
    
    	while {_run} do
    	{
    		_numEnemy = 0;
    		_numEnemyLargeZone = 0;
    		_numEnemyLeftToAttack = 0;
    		_numEnemy = east countSide list triggerObjZone;
    		_numEnemyLargeZone = east countSide list triggerObjLargeZone;
    		_numEnemyLeftToAttack = _numEnemyLargeZone - _numEnemy;
    	
    		//player groupChat format ["_numEnemy is %1", _numEnemy];
    		sleep 3;
    	
    		if ((_numEnemy < 1) and (_numEnemyLeftToAttack < 4)) then
    		{
    			_x = round (random 30);
    			sleep _x; //randomize the timer before mission ends so it doesn't feel as immediate when you kill the last enemy
    			missionComplete = "completed";
    			publicVariable missionComplete;
    			//player sideChat "cleared";
    			_run = false;
    		};
    	};
    };
    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member
    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

Connect

Collapse

TeamSpeak 3 Server

Collapse

Advertisement

Collapse

Twitter Feed

Collapse

Working...
X