# Set StockEx
Grammar — Set stock for player player at town town to make count units of type unitType using build flags buildFlags|buildFlags and stock flags stockFlags|StockFlags
Flags —Native
|Action
Set stock for a player to make units of the specified unit type. (More advanced than Set Stock)
# Arguments
int
— Playerint
— Townint
— Countstring
<gamelink::Unit> — Unit Typeint
— Build Flagsint
— Stock Flags
Returns — void
native void AISetStockEx(
int player,
int town,
int count,
string aliasType,
int buildFlags,
int stockFlags,
);
# Related
Category: AI Advanced / Construction / Actions
- Build —
void
— AIBuild - Train —
void
— AITrain - Research —
void
— AIResearch - Make Always —
void
— AIMakeAlways - Make Once —
void
— AIMakeOnce - Clear Build Queue —
void
— AIClearBuildQueue - Clear Train Queue —
void
— AIClearTrainQueue - Clear Research Queue —
void
— AIClearResearchQueue - Clear Stock —
void
— AIClearStock - Enable Stock —
void
— AIEnableStock - Set StockEx —
void
— AISetStockEx - Set Stock —
void
— AISetStock - Set StockOpt —
void
— AISetStockOpt - Set StockUnitNext —
void
— AISetStockUnitNext - Set StockTown —
bool
— AISetStockTown - Set StockExpand —
bool
— AISetStockExpand - Set StockAlias —
void
— AISetStockAlias - Set StockFree —
void
— AISetStockFree - Default Economy —
void
— AIDefaultEconomy - Default Expansion —
void
— AIDefaultExpansion
# Examples
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:412
}
AISetStockEx(player, c_townMain, want, what, c_makeDefault, c_stockDefense);
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:482
if (AIGetBuildingCountInTown(player, town, c_TB_MissileTurret, c_techCountCompleteOnly) < 2) {
AISetStockEx(player, town, 2, c_TB_MissileTurret, c_makeResourceDefense | c_nearDropoff, 0);
continue;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:486
}
if (AIGetBuildingCountInTown(player, town, c_TB_Bunker, c_techCountCompleteOnly) < 1) {
AISetStockEx(player, town, 1, c_TB_Bunker, c_makeResourceDefense | c_nearDropoff, 0);
continue;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:627
if (AIGetBuildingCountInTown(player, town, c_ZB_SporeCrawler, c_techCountCompleteOnly) < 2) {
AISetStockEx(player, town, 2, c_ZB_SporeCrawler, c_makeResourceDefense | c_nearDropoff, 0);
continue;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:631
}
if (AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly) < 2) {
AISetStockEx(player, town, 2, c_ZB_SpineCrawler, c_makeResourceDefense | c_nearDropoff, 0);
continue;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:767
// make 2 pylons in each town
if (AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly) < 2) {
AISetStockEx(player, town, 1, c_PB_Pylon, c_makeExpanPower, 0);
AISetStockEx(player, town, 2, c_PB_Pylon, c_makeResourceDefense | c_nearDropoff, 0);
continue;
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:768
if (AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly) < 2) {
AISetStockEx(player, town, 1, c_PB_Pylon, c_makeExpanPower, 0);
AISetStockEx(player, town, 2, c_PB_Pylon, c_makeResourceDefense | c_nearDropoff, 0);
continue;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:773
if (AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountCompleteOnly) < 2) {
AISetStockEx(player, town, 2, c_PB_PhotonCannon, c_makeResourceDefense | c_nearDropoff, 0);
continue;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1010
pylonCount = AITechCount(player, c_PB_Pylon, c_techCountCompleteOnly) + 1;
if (pylonInTown == 0) {
AISetStockEx(player, mainTown, pylonCount, c_PB_Pylon, c_makeExpanPower, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1018
cannonCount = AITechCount(player, c_PB_PhotonCannon, c_techCountCompleteOnly) + 1;
if (cannonInTown == 0) {
AISetStockEx(player, mainTown, cannonCount, c_PB_PhotonCannon, c_makeDefense, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1024
// once first cannon is going, make a backup pylon
if (pylonInTown == 1) {
AISetStockEx(player, mainTown, pylonCount, c_PB_Pylon, c_makeExpanPower, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1037
// once the second pylon is done, make 2 more cannons
if (cannonInTown < amount) {
AISetStockEx(player, mainTown, cannonCount, c_PB_PhotonCannon, c_makeDefense, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1078
power = AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly);
if (power == 0) {
AISetStockEx(player, town, 1, c_PB_Pylon, c_makeExpanPower, 0);
continue;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1085
defense = AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountInProgressOrBetter);
if (defense == 0) {
AISetStockEx(player, town, 1, c_PB_PhotonCannon, c_makeDefense, 0);
continue;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1091
// once first cannon is going, make a backup pylon
if (power == 1) {
AISetStockEx(player, town, 2, c_PB_Pylon, c_makeExpanPower, 0);
continue;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1104
// once the second pylon is done, make 2 more cannons
if (defense < amount) {
AISetStockEx(player, town, amount, c_PB_PhotonCannon, c_makeDefense, 0);
continue;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1101
if (turretInTown < amount) {
turretCount = AITechCount(player, c_TB_MissileTurret, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, turretCount, c_TB_MissileTurret, c_makeResourceDefense, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1116
if (commandInTown > 0) {
orbitalCount = AITechCount(player, c_TB_OrbitalCommand, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, orbitalCount, c_TB_OrbitalCommand, c_makeDefault, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1154
if (AIGetBuildingCountInTown(player, town, c_TB_CommandCenter, c_techCountCompleteOnly) > 0) {
if (orbitalTotal < 3) {
AISetStockEx(player, town, 1, c_TB_OrbitalCommand, c_makeDefault, 0);
orbitalIncomplete = orbitalIncomplete + 1;
orbitalTotal = orbitalTotal + 1;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1163
if (planetaryIncomplete == 0) {
if (minLeftInTown > 1000) {
AISetStockEx(player, town, 1, c_TB_PlanetaryFortress, c_makeDefault, 0);
continue;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1179
}
AISetStockEx(player, town, amount, c_TB_MissileTurret, c_makeResourceDefense | c_nearDropoff, 0);
//AISetStockEx(player, town, 1, c_TB_Bunker, c_makeDefense, 0);
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1044
if (spineCrawlerInTown < amount) {
spineCrawlerCount = AITechCount(player, c_ZB_SpineCrawler, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, spineCrawlerCount, c_ZB_SpineCrawler, c_makeDefense, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1051
if (sporeCrawlerInTown < amount + 1) {
sporeCrawlerCount = AITechCount(player, c_ZB_SporeCrawler, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, sporeCrawlerCount, c_ZB_SporeCrawler, c_makeResourceDefense, 0);
return;
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1102
}
AISetStockEx(player, town, amount, c_ZB_SpineCrawler, c_makeDefense, 0);
// After making 2 spine crawler, create 2 spore crawlers in each non-main town
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1106
// After making 2 spine crawler, create 2 spore crawlers in each non-main town
if (AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly) >= 2) {
AISetStockEx(player, town, amount, c_ZB_SporeCrawler, c_makeResourceDefense, 0);
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:418
}
AISetStockEx(player, c_townMain, want, what, c_makeDefault, c_stockDefense);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1005
pylonCount = AITechCount(player, c_PB_Pylon, c_techCountCompleteOnly) + 1;
if (pylonInTown == 0) {
AISetStockEx(player, mainTown, pylonCount, c_PB_Pylon, c_makeExpanPower, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1013
cannonCount = AITechCount(player, c_PB_PhotonCannon, c_techCountCompleteOnly) + 1;
if (cannonInTown == 0) {
AISetStockEx(player, mainTown, cannonCount, c_PB_PhotonCannon, c_makeDefense, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1019
// once first cannon is going, make a backup pylon
if (pylonInTown == 1) {
AISetStockEx(player, mainTown, pylonCount, c_PB_Pylon, c_makeExpanPower, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1032
// once the second pylon is done, make 2 more cannons
if (cannonInTown < amount) {
AISetStockEx(player, mainTown, cannonCount, c_PB_PhotonCannon, c_makeDefense, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1073
power = AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly);
if (power == 0) {
AISetStockEx(player, town, 1, c_PB_Pylon, c_makeExpanPower, 0);
continue;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1080
defense = AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountInProgressOrBetter);
if (defense == 0) {
AISetStockEx(player, town, 1, c_PB_PhotonCannon, c_makeDefense, 0);
continue;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1086
// once first cannon is going, make a backup pylon
if (power == 1) {
AISetStockEx(player, town, 2, c_PB_Pylon, c_makeExpanPower, 0);
continue;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1099
// once the second pylon is done, make 2 more cannons
if (defense < amount) {
AISetStockEx(player, town, amount, c_PB_PhotonCannon, c_makeDefense, 0);
continue;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1092
if (turretInTown < amount) {
turretCount = AITechCount(player, c_TB_MissileTurret, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, turretCount, c_TB_MissileTurret, c_makeResourceDefense, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1107
if (commandInTown > 0) {
orbitalCount = AITechCount(player, c_TB_OrbitalCommand, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, orbitalCount, c_TB_OrbitalCommand, c_makeDefault, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1145
if (AIGetBuildingCountInTown(player, town, c_TB_CommandCenter, c_techCountCompleteOnly) > 0) {
if (orbitalTotal < 3) {
AISetStockEx(player, town, 1, c_TB_OrbitalCommand, c_makeDefault, 0);
orbitalIncomplete = orbitalIncomplete + 1;
orbitalTotal = orbitalTotal + 1;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1154
if (planetaryIncomplete == 0) {
if (minLeftInTown > 1000) {
AISetStockEx(player, town, 1, c_TB_PlanetaryFortress, c_makeDefault, 0);
continue;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1170
}
AISetStockEx(player, town, amount, c_TB_MissileTurret, c_makeResourceDefense | c_nearDropoff, 0);
//AISetStockEx(player, town, 1, c_TB_Bunker, c_makeDefense, 0);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1062
if (spineCrawlerInTown < amount) {
spineCrawlerCount = AITechCount(player, c_ZB_SpineCrawler, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, spineCrawlerCount, c_ZB_SpineCrawler, c_makeDefense, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1069
if (sporeCrawlerInTown < amount + 1) {
sporeCrawlerCount = AITechCount(player, c_ZB_SporeCrawler, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, sporeCrawlerCount, c_ZB_SporeCrawler, c_makeResourceDefense, 0);
return;
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1120
}
AISetStockEx(player, town, amount, c_ZB_SpineCrawler, c_makeDefense, 0);
// After making 2 spine crawler, create 2 spore crawlers in each non-main town
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1124
// After making 2 spine crawler, create 2 spore crawlers in each non-main town
if (AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly) >= 2) {
AISetStockEx(player, town, amount, c_ZB_SporeCrawler, c_makeResourceDefense, 0);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1042
pylonCount = AITechCount(player, c_PB_Pylon, c_techCountCompleteOnly) + 1;
if (pylonInTown == 0) {
AISetStockEx(player, mainTown, pylonCount, c_PB_Pylon, c_makeExpanPower, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1050
cannonCount = AITechCount(player, c_PB_PhotonCannon, c_techCountCompleteOnly) + 1;
if (cannonInTown == 0) {
AISetStockEx(player, mainTown, cannonCount, c_PB_PhotonCannon, c_makeDefense, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1056
// once first cannon is going, make a backup pylon
if (pylonInTown == 1) {
AISetStockEx(player, mainTown, pylonCount, c_PB_Pylon, c_makeExpanPower, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1069
// once the second pylon is done, make 2 more cannons
if (cannonInTown < amount) {
AISetStockEx(player, mainTown, cannonCount, c_PB_PhotonCannon, c_makeDefense, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1110
power = AIGetBuildingCountInTown(player, town, c_PB_Pylon, c_techCountCompleteOnly);
if (power == 0) {
AISetStockEx(player, town, 1, c_PB_Pylon, c_makeExpanPower, 0);
continue;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1117
defense = AIGetBuildingCountInTown(player, town, c_PB_PhotonCannon, c_techCountInProgressOrBetter);
if (defense == 0) {
AISetStockEx(player, town, 1, c_PB_PhotonCannon, c_makeDefense, 0);
continue;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1123
// once first cannon is going, make a backup pylon
if (power == 1) {
AISetStockEx(player, town, 2, c_PB_Pylon, c_makeExpanPower, 0);
continue;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:1136
// once the second pylon is done, make 2 more cannons
if (defense < amount) {
AISetStockEx(player, town, amount, c_PB_PhotonCannon, c_makeDefense, 0);
continue;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1106
if (turretInTown < amount) {
turretCount = AITechCount(player, c_TB_MissileTurret, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, turretCount, c_TB_MissileTurret, c_makeResourceDefense, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1121
if (commandInTown > 0) {
orbitalCount = AITechCount(player, c_TB_OrbitalCommand, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, orbitalCount, c_TB_OrbitalCommand, c_makeDefault, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1159
if (AIGetBuildingCountInTown(player, town, c_TB_CommandCenter, c_techCountCompleteOnly) > 0) {
if (orbitalTotal < 3) {
AISetStockEx(player, town, 1, c_TB_OrbitalCommand, c_makeDefault, 0);
orbitalIncomplete = orbitalIncomplete + 1;
orbitalTotal = orbitalTotal + 1;
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1168
if (planetaryIncomplete == 0) {
if (minLeftInTown > 1000) {
AISetStockEx(player, town, 1, c_TB_PlanetaryFortress, c_makeDefault, 0);
continue;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:1184
}
AISetStockEx(player, town, amount, c_TB_MissileTurret, c_makeResourceDefense | c_nearDropoff, 0);
//AISetStockEx(player, town, 1, c_TB_Bunker, c_makeDefense, 0);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1072
if (spineCrawlerInTown < amount) {
spineCrawlerCount = AITechCount(player, c_ZB_SpineCrawler, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, spineCrawlerCount, c_ZB_SpineCrawler, c_makeDefense, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1079
if (sporeCrawlerInTown < amount + 1) {
sporeCrawlerCount = AITechCount(player, c_ZB_SporeCrawler, c_techCountCompleteOnly) + 1;
AISetStockEx(player, mainTown, sporeCrawlerCount, c_ZB_SporeCrawler, c_makeResourceDefense, 0);
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1130
}
AISetStockEx(player, town, amount, c_ZB_SpineCrawler, c_makeDefense, 0);
// After making 2 spine crawler, create 2 spore crawlers in each non-main town
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:1134
// After making 2 spine crawler, create 2 spore crawlers in each non-main town
if (AIGetBuildingCountInTown(player, town, c_ZB_SpineCrawler, c_techCountCompleteOnly) >= 2) {
AISetStockEx(player, town, amount, c_ZB_SporeCrawler, c_makeResourceDefense, 0);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/Orc/Orc.galaxy:42
//call SecondaryTown ( townid, 1, unitid )
//TriggerDebugOutput(1, StringToText("rebuildtown"), true);
AISetStockEx(player, townid, 1, unitid, c_makeDefault, c_stockNormal);
}
}