SC2Mapster.com Wiki

UnitGroupCount

int UnitGroupCount (unitgroup g, int mode);

Number of units in the unit group.

Parameters

unitgroup g

The group containing the units to be counted.

int mode
  • 0 (c_unitCountAll): All the units
  • 1 (c_unitCountAlive): Alive units
  • 2 (c_unitCountDead): Dead units

Return value

int - The number of units in unitgroup aGroup.

Examples

Example: Sample Usage
int player = // Fill ...;
unitgroup overlords;
int numOverlords;
unit overlord;
int i;

// Get all the overlords in the player base
overlords = AIFindUnits(player,
                        c_ZU_Overlord,
                        PlayerStartLocation(player),
                        15,
                        c_noMaxCount);

// Get the number of overlords
numOverlords = UnitGroupCount(overlords, c_unitCountAll);

// Do operation on them
i = 1;
while (i <= numOverlords) {
  overlord = UnitGroupUnit(overlords, i);
  // Do something with the overlord
  i += 1;
}

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Mar 14, 2010
Last updated
Mar 18, 2010

Authors