Jump to content
Sign in to follow this  
smacker909

script to make you clear dead from battlefield

Recommended Posts

Ok, first try, so be easy on me. I know there's lots wrong, but I'm learning. I wanted to make something to force me to clear my dead buddies from the battle field. I have a hospital tent setup in a base camp in the middle of Zargabad.. so I have to drag / carry my fallen squadmates back to the hospital tent. If any thinks it's useful and wants to improve, or just suggestions.. I know I'm doing lots wrong.. :D

// Get initial squad count
_initSquadSize = ({alive _x} count units player);

// Starting cleared count starts at zero
_clrCnt = 0;

// Size of your crew
_sqdMates = _initSquadSize - 1;
hint format ["You have %1 Squad mates.. bring 'em back dead or alive!",_sqdMates];
sleep 3;

// Position of static Hospital tent
_hospitalPosX = position myHospital select 0;
_hospitalPosY = position myHospital select 1;

// array of my units //  has to be a better way
_sqdArray = [myUnit1, myUnit2, myUnit3];


while {(count _sqdArray > 0)} do {

  // Count of current living squadmates
  _aliveCnt = ({alive _x} count units player);

  // Dead count
  _deadCnt = (_initSquadSize - _aliveCnt);

  // for each member in _sqdArray
  {
  if (!alive _x) then {  

           // Check to see if this dead guy is in tent / cleared
           _xPos = getPos _x select 0;
           _yPos = getPos _x select 1;

           _xDiff = _hospitalPosX - _xPos;
           _yDiff = _hospitalPosY - _yPos;

    // Couldn't figure out better way
           if (((_xDiff > -3) && (_xDiff < 3)) && ((_yDiff > -3) && (_yDiff < 3))) then {

		  _clrCnt = _clrCnt + 1;	
                         _unClr = (_deadCnt - _clrCnt);	
                         hint format ["%1 is has been cleared from the battlefield.. \n there are %2 left to clear",_x,_unClr];	
		  // removing dead / cleared unit from array
                         _sqdArray = _sqdArray - [_x];							
		  sleep 2;						

		} else {			          

                         hintSilent format ["%1 is dead... don't leave him behind!",_x];						
                         sleep 2;
                   }
           }
  }
  forEach _sqdArray;
  if (count _sqdArray == 0) then {hint "All squadmates are dead and cleared from the battlefield"};
  sleep 3;
};

Edited by smacker909

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  

×