# 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.sc2campaignbase.sc2maps/maps/campaign/tzeratul03.sc2map/MapScript.galaxy:2513

    }

    lv_point = AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(32), 9.0, 40.0, 30.0);
    if ((RegionContainsPoint(RegionCircle(lv_point, 10.0), CameraGetTarget(gv_p01_USER)) == true) && (gv_gameOver == false)) {
        CameraShakeStart(gv_p01_USER, c_cameraPositionTarget, c_cameraDirectionZ, 0.07, 2.0, 100.0, 3.0);

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul03.sc2map/MapScript.galaxy:2561

    }

    lv_point = AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(24), 9.0, 40.0, 30.0);
    if ((RegionContainsPoint(RegionCircle(lv_point, 10.0), CameraGetTarget(gv_p01_USER)) == true) && (gv_gameOver == false)) {
        CameraShakeStart(gv_p01_USER, c_cameraPositionTarget, c_cameraDirectionZ, 0.07, 2.0, 100.0, 3.0);

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul03.sc2map/MapScript.galaxy:2609

    }

    lv_point = AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(40), 9.0, 40.0, 30.0);
    if ((RegionContainsPoint(RegionCircle(lv_point, 10.0), CameraGetTarget(gv_p01_USER)) == true) && (gv_gameOver == false)) {
        CameraShakeStart(gv_p01_USER, c_cameraPositionTarget, c_cameraDirectionZ, 0.07, 2.0, 100.0, 3.0);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul03.sc2mapMapScript.galaxy:2513

    }

    lv_point = AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(32), 9.0, 40.0, 30.0);
    if ((RegionContainsPoint(RegionCircle(lv_point, 10.0), CameraGetTarget(gv_p01_USER)) == true) && (gv_gameOver == false)) {
        CameraShakeStart(gv_p01_USER, c_cameraPositionTarget, c_cameraDirectionZ, 0.07, 2.0, 100.0, 3.0);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul03.sc2mapMapScript.galaxy:2561

    }

    lv_point = AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(24), 9.0, 40.0, 30.0);
    if ((RegionContainsPoint(RegionCircle(lv_point, 10.0), CameraGetTarget(gv_p01_USER)) == true) && (gv_gameOver == false)) {
        CameraShakeStart(gv_p01_USER, c_cameraPositionTarget, c_cameraDirectionZ, 0.07, 2.0, 100.0, 3.0);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul03.sc2mapMapScript.galaxy:2609

    }

    lv_point = AIRandomSpawnPoint(gv_p02_ZERG_LOW_GROUND_AI, RegionFromId(40), 9.0, 40.0, 30.0);
    if ((RegionContainsPoint(RegionCircle(lv_point, 10.0), CameraGetTarget(gv_p01_USER)) == true) && (gv_gameOver == false)) {
        CameraShakeStart(gv_p01_USER, c_cameraPositionTarget, c_cameraDirectionZ, 0.07, 2.0, 100.0, 3.0);