SC2Mapster.com Wiki

UnitGroup

unitgroup UnitGroup (string type,
		      int player,
		      region r,
		      unitfilter f,
		      int max);

Create a unit group.

Parameters

string type
  • null: No restriction on the unit type
  • type: Only get units of that type (returned by UnitGetType).
int player
  • -1 (c_playerAny): No restriction on the player
  • n: Only units owned by player n
region r
  • null: No restriction on the region. All the map is being taken in account
  • region: Only get units from that region
unitfilter f
  • null: No restriction on the unit filter.
  • filter: Only get units that match the filter
int max
  • 0: No maximum
  • n: Maximum number of units in the group.

Examples

Example #1: Sample Usage
int player = 2;
unitfilter filter = UnitFilterStr("Ground;Cloaked");
region reg = RegionCircle(Point(50, 50), 30);
string type = "Pylon";
int max = 10;

unitgroup g = UnitGroup(type, player, reg, filter, max);
// Select all units matching the following criterias
// * Unit is a Pylon
// * Unit belongs to player 2
// * Unit is Ground and not Cloaked
// * Unit is in the region centered at (50, 50) of radius 30
// * Only the first 10 units
Example #2: All Units
// Select all the units of the map
unitgroup UnitGroupAllUnits() {
  return UnitGroup(null, -1, null, null, 0);
}
Example #3: Empty Group
// Create an empty group
unitgroup UnitGroupEmpty() {
  return UnitGroup(null, -1, RegionCircle(null, 0), null, 0);
}
Example #4: Order
// Cast the order for all the units of the group
void UnitGroupOrder(unitgroup g, order ord) {
  int count = UnitGroupCount(g, 0);
  unit u;
  int i = 1;
  while (i <= count) {
    u = UnitGroupUnit(g, i);
    AICast(u, ord, c_noMarker, true);
    i += 1;
  }
}

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

Facts

Date created
Mar 13, 2010
Last updated
Mar 22, 2010

Authors