Page 1 of 1

Counting Units that are still Alive

Posted: Sun Aug 10, 2014 12:48 pm
by jcb989
Hello,

Can anyone suggest the structure of a function I could use to count (a) total units left alive on each side, and (b) total number of units alive of a certain type?

Thanks,

Re: Counting Units that are still Alive

Posted: Mon Aug 11, 2014 3:55 pm
by pipfromslitherine
The basic format would be:

Code: Select all

	for(i=0;i<GetUnitCount(side);i++)
	{
		unit = GetUnitID(side, i) ;
		if( GetUnitDead(unit) == 1)
		{
		// dead
		}
		else
		{
		// alive
		}
	}
Use IsUnitType to tell if a given unit is of a specific type.

Cheers

Pip

Re: Counting Units that are still Alive

Posted: Mon Aug 11, 2014 10:21 pm
by jcb989
Thanks Pip! I will put this to work!