# Get Building Count In Town

Grammar — Returns the number of buildings of type unit in town for player player using mask countMask|TechTreeCountType
FlagsNative | Function

Returns the number of buildings of the specified type in the specified town for a player.

# Arguments

  • int — Player
  • int — Town
  • string [ gamelink::Unit ] — Unit
  • int [ preset::TechTreeCountType ] — Count Mask

Returns — int

native int AIGetBuildingCountInTown(
	int player,
	int town,
	string aliasUnitType,
	int countMask,
);

Category: AI Advanced / Towns / Functions

# Examples

# mods/core.sc2mod

MeleeLowAI.galaxy

// L477
AIGetBuildingCountInTown(player, town, c_TB_CommandCenter_Alias, c_techCountCompleteOnly)
// L481
AIGetBuildingCountInTown(player, town, c_TB_MissileTurret, c_techCountCompleteOnly)
// L485
AIGetBuildingCountInTown(player, town, c_TB_Bunker, c_techCountCompleteOnly)
// L620
AIGetBuildingCountInTown(player, town, c_ZB_Hatchery_Alias, c_techCountCompleteOnly)
// L626
AIGetBuildingCountInTown(player, town, c_ZB_SporeCrawler, c_techCountCompleteOnly)
// L630
AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly)
// L761
AIGetBuildingCountInTown(player, town, c_PB_Nexus, c_techCountCompleteOnly)
// L766
AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly)
// L772
AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountCompleteOnly)

# mods/liberty.sc2mod

ProtossChIn.galaxy

// L2085
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/liberty.sc2mod

ProtossHdVH.galaxy

// L2084
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/liberty.sc2mod

ProtossHigh.galaxy

// L1007
AIGetBuildingCountInTown(player, mainTown, c_PB_Pylon, c_techCountCompleteOnly)
// L1015
AIGetBuildingCountInTown(player, mainTown, c_PB_PhotonCannon, c_techCountInProgressOrBetter)
// L1071
AIGetBuildingCountInTown(player, town, c_PB_Nexus, c_techCountInProgressOrBetter)
// L1076
AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly)
// L1083
AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountInProgressOrBetter)

# mods/liberty.sc2mod

ProtossVyHd.galaxy

// L2115
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/liberty.sc2mod

TerranHigh.galaxy

// L1098
AIGetBuildingCountInTown(player, mainTown, c_TB_MissileTurret, c_techCountCompleteOnly)
// L1113
AIGetBuildingCountInTown(player, mainTown, c_TB_CommandCenter, c_techCountCompleteOnly)
// L1152
AIGetBuildingCountInTown(player, town, c_TB_CommandCenter, c_techCountCompleteOnly)

# mods/liberty.sc2mod

ZergHigh.galaxy

// L1027
AIGetBuildingCountInTown(player, mainTown, c_ZB_Hatchery_Alias, c_techCountCompleteOnly)
// L1041
AIGetBuildingCountInTown(player, mainTown, c_ZB_SpineCrawler, c_techCountCompleteOnly)
// L1048
AIGetBuildingCountInTown(player, mainTown, c_ZB_SporeCrawler, c_techCountCompleteOnly)
// L1082
AIGetBuildingCountInTown(player, town, c_ZB_Hatchery_Alias, c_techCountCompleteOnly)
// L1105
AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly)

# mods/swarm.sc2mod

ProtossChIn.galaxy

// L2085
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/swarm.sc2mod

ProtossHdVH.galaxy

// L2084
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/swarm.sc2mod

ProtossHigh.galaxy

// L1002
AIGetBuildingCountInTown(player, mainTown, c_PB_Pylon, c_techCountCompleteOnly)
// L1010
AIGetBuildingCountInTown(player, mainTown, c_PB_PhotonCannon, c_techCountInProgressOrBetter)
// L1066
AIGetBuildingCountInTown(player, town, c_PB_Nexus, c_techCountInProgressOrBetter)
// L1071
AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly)
// L1078
AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountInProgressOrBetter)

# mods/swarm.sc2mod

ProtossVyHd.galaxy

// L2115
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/swarm.sc2mod

TerranHigh.galaxy

// L1089
AIGetBuildingCountInTown(player, mainTown, c_TB_MissileTurret, c_techCountCompleteOnly)
// L1104
AIGetBuildingCountInTown(player, mainTown, c_TB_CommandCenter, c_techCountCompleteOnly)
// L1143
AIGetBuildingCountInTown(player, town, c_TB_CommandCenter, c_techCountCompleteOnly)

# mods/swarm.sc2mod

ZergHigh.galaxy

// L1045
AIGetBuildingCountInTown(player, mainTown, c_ZB_Hatchery_Alias, c_techCountCompleteOnly)
// L1059
AIGetBuildingCountInTown(player, mainTown, c_ZB_SpineCrawler, c_techCountCompleteOnly)
// L1066
AIGetBuildingCountInTown(player, mainTown, c_ZB_SporeCrawler, c_techCountCompleteOnly)
// L1100
AIGetBuildingCountInTown(player, town, c_ZB_Hatchery_Alias, c_techCountCompleteOnly)
// L1123
AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly)

# mods/void.sc2mod

ProtossChIn.galaxy

// L2611
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/void.sc2mod

ProtossHdVH.galaxy

// L2613
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/void.sc2mod

ProtossHigh.galaxy

// L1039
AIGetBuildingCountInTown(player, mainTown, c_PB_Pylon, c_techCountCompleteOnly)
// L1047
AIGetBuildingCountInTown(player, mainTown, c_PB_PhotonCannon, c_techCountInProgressOrBetter)
// L1103
AIGetBuildingCountInTown(player, town, c_PB_Nexus, c_techCountInProgressOrBetter)
// L1108
AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly)
// L1115
AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountInProgressOrBetter)

# mods/void.sc2mod

ProtossVyHd.galaxy

// L2644
AIGetBuildingCountInTown(player, c_townMain, c_PB_Pylon, c_techCountQueuedOrBetter)

# mods/void.sc2mod

TerranHigh.galaxy

// L1103
AIGetBuildingCountInTown(player, mainTown, c_TB_MissileTurret, c_techCountCompleteOnly)
// L1118
AIGetBuildingCountInTown(player, mainTown, c_TB_CommandCenter, c_techCountCompleteOnly)
// L1157
AIGetBuildingCountInTown(player, town, c_TB_CommandCenter, c_techCountCompleteOnly)

# mods/void.sc2mod

ZergHigh.galaxy

// L1055
AIGetBuildingCountInTown(player, mainTown, c_ZB_Hatchery_Alias, c_techCountCompleteOnly)
// L1069
AIGetBuildingCountInTown(player, mainTown, c_ZB_SpineCrawler, c_techCountCompleteOnly)
// L1076
AIGetBuildingCountInTown(player, mainTown, c_ZB_SporeCrawler, c_techCountCompleteOnly)
// L1110
AIGetBuildingCountInTown(player, town, c_ZB_Hatchery_Alias, c_techCountCompleteOnly)
// L1133
AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly)

# mods/warcoop/warmeleeai.sc2mod

Common_ai.galaxy

// L29
AIGetBuildingCountInTown(player, townid, unitid,mask)