# Random Spawn Point

Grammar — Random point in region between minDistFromEnemies|Min and maxDistFromEnemies|Max distance from enemy units of player player (prefer points within maxDistFromBuildings|MaxDist of an enemy building)
FlagsNative | Function

Returns a random point in the given region. Prefers to stay either close or far from enemies units. Also prefers to be within some max distance of enemy buildings. It will also stay away from previously returned random points in the region.

# Arguments

  • int — Player
  • region — Region
  • fixed — MinDistFromEnemies
  • fixed — MaxDistFromEnemies
  • fixed — MaxDistFromBuildings

Returns — point

native point AIRandomSpawnPoint(
	int player,
	region r,
	fixed minDistFromEnemy,
	fixed maxDistFromEnemy,
	fixed maxDistFromBuilding,
);

Category: AI / MiscCampaign / Functions

# Examples

# campaigns/liberty.sc2campaign

MapScript.galaxy

// L2513
AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(32), 9.0, 40.0, 30.0)
// L2561
AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(24), 9.0, 40.0, 30.0)
// L2609
AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(40), 9.0, 40.0, 30.0)
// L2513
AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(32), 9.0, 40.0, 30.0)
// L2561
AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(24), 9.0, 40.0, 30.0)
// L2609
AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(40), 9.0, 40.0, 30.0)