UnitGroupFilter
unitgroup UnitGroupFilter(string type, int player, unitgroup g, unitfilter f, int max)
Filter 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
- unitgroup g
Original unit group
- 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
unitgroup UnitGroupAllUnits() { return UnitGroup(null, -1, null, null, 0); } string type = "Pylon"; int player = 2; unitgroup g = UnitGroupAllUnits(); unitfilter filter = UnitFilterStr("Ground;Cloaked"); int max = 10; g = UnitGroupFilter(type, player, g, filter, max); // Select all units matching the following criterias // * Unit is a Pylon // * Unit belongs to player 2 // * Unit is Ground and not Cloaked // * Only the first 10 units
- Example #2: Empty Group
// Create an empty group unitgroup UnitGroupEmpty() { return UnitGroupFilter(null, -1, null, null, 0); }
- Example #3: Filter by Type
unitgroup UnitGroupFilterType(unitgroup g, string type) { return UnitGroupFilter(type, -1, g, null, 0); }