AIFindUnits
unitgroup AIFindUnits(int player, string unitType, point p, fixed range, int inMaxCount);
Returns a unitgroup containing all the units of a type owned by the player within range of the given point, up to the max number specified.
Parameters
- int player
The owner of the units. Use player 0 for neutral units such as c_NU_Minerals
- string unitType
A string designating the type of unit to search for. Can be units or buildings. Aliases do not work with this function. Supplying a null string will return all units owned by player in the specified area.
- point p
The center of the circle shaped area to be searched.
- fixed range
The radius of the circle shaped area to be searched.
- int inMaxCount
An integer specifying the max number of units to return. c_noMaxCount specifies no maximum.
Return value
unitgroup - A unitgroup containing the units found.
Examples
- Example: Count Larva
int CountLarvaAtThisHatchery(int player, unit myHatchery) { point hatcheryLoc=UnitGetPosition(myHatchery); int numLarva=AIFindUnits(player, c_ZU_Larva, hatcheryLoc, 3.5); return numLarva; }
Notes
- There is no perfect range for grabbing all of the Larva from this Hatchery and none of the Larva from an adjacent Hatchery if both Hatcheries have a large number of larva squirming around. 3.6 is also a good value to use.
- 2 comments
- 2 comments
- Reply
- #2
Astazha Mar 25, 2010 at 04:39 UTC - 0 likesI believe so, yes.
- Reply
- #1
vjeux Mar 24, 2010 at 15:16 UTC - 0 likesIs this the same thing as this?