SC2Mapster.com Wiki

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.

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

  • 2 comments
  • Avatar of Astazha Astazha Mar 25, 2010 at 04:39 UTC - 0 likes

    I believe so, yes.

  • Avatar of vjeux vjeux Mar 24, 2010 at 15:16 UTC - 0 likes

    Is this the same thing as this?

    unitgroup AIFindUnits(int player, string type, point p, fixed r, int max) {
      return UnitGroup(type, player, RegionCircle(p, r), null, max);
    }
    
  • 2 comments

Table of contents

  1. 1 Notes

Facts

Date created
Mar 15, 2010
Last updated
Mar 25, 2010