# Wave Unit Count
Grammar — Get the number of units in wave w
Flags —Native
|Function
Returns the number of units in a wave.
# Arguments
wave
— Wave
Returns — int
native int AIWaveUnitCount(wave w);
# Related
Category: AI Advanced / Waves / Functions
- Create Wave Info —
waveinfo
— AIWaveInfoCreate - Create Wave Info From Wave —
waveinfo
— AIWaveInfo - Create Wave —
wave
— AIWaveCreate - Wave Unit Count —
int
— AIWaveUnitCount - Wave State —
int
— AIWaveState - Wave Target Unit —
wavetarget
— AIWaveTargetUnit - Wave Target UnitGroup —
wavetarget
— AIWaveTargetUnitGroup - Wave Target Unit Point —
wavetarget
— AIWaveTargetUnitPoint - Wave Target Point —
wavetarget
— AIWaveTargetPoint - Wave Target Player —
wavetarget
— AIWaveTargetPlayer - Wave Target Melee —
wavetarget
— AIWaveTargetMelee - Wave Target Melee Harass —
wavetarget
— AIWaveTargetMeleeHarass - Wave Target Merge —
wavetarget
— AIWaveTargetMerge - Wave Target Patrol —
wavetarget
— AIWaveTargetPatrol - Wave Target Escort —
wavetarget
— AIWaveTargetEscort - Wave Target Escort No Leash —
wavetarget
— AIWaveTargetEscortNL - Wave Target Gather Offense —
wavetarget
— AIWaveTargetGatherO - Wave Target Gather Defense —
wavetarget
— AIWaveTargetGatherD - Wave Target Harass Retreat —
wavetarget
— AIWaveHarassRetreat - Wave Target Region —
wavetarget
— AIWaveTargetRegion - Wave Get Target —
wavetarget
— AIWaveGetTarget - Is Wave In Combat —
bool
— AIWaveIsInCombat - Wave Time In Combat —
int
— AIWaveGetTimeInCombat - Wave Time Since Combat —
int
— AIWaveGetTimeSinceCombat - Wave Time Since Ordered —
int
— AIWaveGetTimeSinceOrdered - Wave Eval —
int
— AIWaveEval - Wave Eval Ratio —
int
— AIWaveEvalRatio - Eval Ratio —
int
— AIEvalRatio - Wave Get —
wave
— AIWaveGet - Wave Type —
int
— AIWaveType - Get Best Attack Target Point —
point
— AIGetBestTarget - Wave To String —
string
— AIWaveToString - Wave To Text —
text
— AIWaveToText
# Examples
campaigns/swarm.sc2campaign — base.sc2maps/maps/campaign/voidprologue/voidprologue01.sc2map/MapScript.galaxy:4226
TriggerExecute(gt_Kerrigan07Wave, true, true);
Wait(gv_waveCooldownTime, c_timeGame);
while (!((AIWaveUnitCount(gv_currentWave) < 15))) {
Wait(1.0, c_timeGame);
}
campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/voidprologue/voidprologue01.sc2map — MapScript.galaxy:4226
TriggerExecute(gt_Kerrigan07Wave, true, true);
Wait(gv_waveCooldownTime, c_timeGame);
while (!((AIWaveUnitCount(gv_currentWave) < 15))) {
Wait(1.0, c_timeGame);
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:322
// first offer it to the attack wave if that wave has some units in it
if (AIWaveUnitCount(attackWave) >= 4) {
if (AIWaveDetectorCount(attackWave) == 0) {
AIWaveAddUnitPriority(attackWave, u, c_prioWavePeon);
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:343
// let the attack wave claim a second one
if (AIWaveUnitCount(attackWave) >= 4) {
if (AIWaveDetectorCount(attackWave) < 2) {
AIWaveAddUnitPriority(attackWave, u, c_prioWavePeon);
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeHighAI.galaxy:165
if (AIGetCoopFlag(player, c_coopWaveAttacker)) {
if (AIWaveUnitCount(AIWaveGet(player, c_waveAttack)) > 0) {
return;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeHighAI.galaxy:168
return;
}
if (AIWaveUnitCount(AIWaveGet(player, c_waveMain)) < 8) {
return;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:120
}
if (sendAttack) {
waveCount = AIWaveUnitCount(AIWaveGet(player, c_waveMain)) + AIWaveUnitCount(AIWaveGet(player, c_waveAttack));
desiredArmyCount = AIGetStockArmyCount(player);
if (waveCount < desiredArmyCount/2) {
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:120
}
if (sendAttack) {
waveCount = AIWaveUnitCount(AIWaveGet(player, c_waveMain)) + AIWaveUnitCount(AIWaveGet(player, c_waveAttack));
desiredArmyCount = AIGetStockArmyCount(player);
if (waveCount < desiredArmyCount/2) {
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:168
activateNextWave = false; // wait for the AI to activate
}
if (AIWaveUnitCount(AIWaveGet(player, c_waveAttack)) > 0) {
activateNextWave = false;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeLowAI.galaxy:171
activateNextWave = false;
}
else if (AIWaveUnitCount(AIWaveGet(player, c_waveMain)) < 8) {
activateNextWave = false;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:58
player,
"wave=" + name +
", units=" + IntToString(AIWaveUnitCount(w)) +
", state=" + WaveStateName(AIWaveState(w)) +
", ratio=" + IntToString(AIWaveEvalRatio(w, c_evalRange)) +
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:155
void AIWaveMain (int player, wave w) {
unit obstruction = null;
int count = AIWaveUnitCount(w);
int state = AIWaveState(w);
int attackState = AIState(player, e_attackState);
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:226
if (!AIGetFlag(player, e_flagsDiversion)) {
if (AIWaveUnitCount(w) != 0) {
if (type == c_waveDivert1) {
AIWaveMerge(player, c_waveDivert1, c_waveAttack);
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:349
// See if the clear obstruction wave is already full
waveClob = AIWaveGet(player, c_waveClearObs);
countClob = AIWaveUnitCount(waveClob);
if (countClob >= 4) {
return false;
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:356
// If the attack wave is getting weak, keep units available for it instead
waveAtck = AIWaveGet(player, c_waveAttack);
countAtck = AIWaveUnitCount(waveAtck);
evalAtck = AIWaveEvalRatio(waveAtck, c_evalRange);
if (countAtck > 0 && evalAtck < 90) {
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:401
waveAttack = AIWaveGet(player, c_waveAttack);
if (AIWaveUnitCount(waveAttack) == 0) {
return false;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:426
waveAttack = AIWaveGet(player, c_waveAttack);
if (AIWaveUnitCount(waveAttack) == 0) {
return c_nullPoint;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:758
else if (state == e_attackState_Idle) {
count = AIWaveUnitCount(w) + AIWaveUnitCount(AIWaveGet(player, c_waveMain));
if ((AIWaveGetTimeSinceRetreat(w) > 120) && (AIGetUserInt(player, c_delayNextAttack) < AIGetTime())) {
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:758
else if (state == e_attackState_Idle) {
count = AIWaveUnitCount(w) + AIWaveUnitCount(AIWaveGet(player, c_waveMain));
if ((AIWaveGetTimeSinceRetreat(w) > 120) && (AIGetUserInt(player, c_delayNextAttack) < AIGetTime())) {
mods/core.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:806
}
if (AIWaveUnitCount(w) < 1) {
return;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:13147
lv_playerWavesIter = 0;
for ( ; ( (auto7A411C1C_ai >= 0 && lv_playerWavesIter <= auto7A411C1C_ae) || (auto7A411C1C_ai < 0 && lv_playerWavesIter >= auto7A411C1C_ae) ) ; lv_playerWavesIter += auto7A411C1C_ai ) {
if ((AIWaveUnitCount(libCOMI_gv_cM_CoopAIPlayer_AttackWaves[lv_playerIter][lv_playerWavesIter]) > 0)) {
autoADEF27AE_g = AIWaveGetUnits(libCOMI_gv_cM_CoopAIPlayer_AttackWaves[lv_playerIter][lv_playerWavesIter]);
autoADEF27AE_u = UnitGroupCount(autoADEF27AE_g, c_unitCountAll);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:322
// first offer it to the attack wave if that wave has some units in it
if (AIWaveUnitCount(attackWave) >= 4) {
if (AIWaveDetectorCount(attackWave) == 0) {
AIWaveAddUnitPriority(attackWave, u, c_prioWavePeon);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/MeleeAI.galaxy:343
// let the attack wave claim a second one
if (AIWaveUnitCount(attackWave) >= 4) {
if (AIWaveDetectorCount(attackWave) < 2) {
AIWaveAddUnitPriority(attackWave, u, c_prioWavePeon);
mods/void.sc2mod — base.sc2data/TriggerLibs/MeleeHighAI.galaxy:165
if (AIGetCoopFlag(player, c_coopWaveAttacker)) {
if (AIWaveUnitCount(AIWaveGet(player, c_waveAttack)) > 0) {
return;
}
mods/void.sc2mod — base.sc2data/TriggerLibs/MeleeHighAI.galaxy:168
return;
}
if (AIWaveUnitCount(AIWaveGet(player, c_waveMain)) < 8) {
return;
}
mods/warcoop/warcoopdata.sc2mod — base.sc2data/TriggerLibs/WarCoopData.galaxy:2941
// Implementation
if ((AIWaveUnitCount(lp_wave) == 0)) {
return true;
}
mods/warcoop/warcoopdata.sc2mod — base.sc2data/TriggerLibs/WarCoopData.galaxy:2948
lv_ping = PingLastCreated();
PingSetScale(lv_ping, lp_scale);
while ((AIWaveUnitCount(lp_wave) > 0)) {
PingSetPosition(lv_ping, UnitGroupCenterOfGroup(AIWaveGetUnits(lp_wave)));
Wait(1.0, c_timeGame);
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:188
player,
"wave=" + name +
", units=" + IntToString(AIWaveUnitCount(w)) +
", state=" + WaveStateName(AIWaveState(w)) +
", ratio=" + IntToString(AIWaveEvalRatio(w, c_evalRange)) +
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:251
void AIWaveMain (int player, wave w) {
unit obstruction = null;
int count = AIWaveUnitCount(w);
int state = AIWaveState(w);
int attackState = AIState(player, e_attackState);
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:315
if (!AIGetFlag(player, e_flagsDiversion)) {
if (AIWaveUnitCount(w) != 0) {
if (type == c_waveDivert1) {
AIWaveMerge(player, c_waveDivert1, c_waveAttack);
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:432
// See if the clear obstruction wave is already full
waveClob = AIWaveGet(player, c_waveClearObs);
countClob = AIWaveUnitCount(waveClob);
if (countClob >= 4) {
return false;
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:439
// If the attack wave is getting weak, keep units available for it instead
waveAtck = AIWaveGet(player, c_waveAttack);
countAtck = AIWaveUnitCount(waveAtck);
evalAtck = AIWaveEvalRatio(waveAtck, c_evalRange);
if (countAtck > 0 && evalAtck < 90) {
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:491
waveAttack = AIWaveGet(player, c_waveAttack);
if (AIWaveUnitCount(waveAttack) == 0) {
return false;
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:516
waveAttack = AIWaveGet(player, c_waveAttack);
if (AIWaveUnitCount(waveAttack) == 0) {
return c_nullPoint;
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:851
else if (state == e_attackState_Idle) {
count = AIWaveUnitCount(w) + AIWaveUnitCount(AIWaveGet(player, c_waveMain));
if ((AIWaveGetTimeSinceRetreat(w) > 2) && (AIGetUserInt(player, c_delayNextAttack) < AIGetTime())) {
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:851
else if (state == e_attackState_Idle) {
count = AIWaveUnitCount(w) + AIWaveUnitCount(AIWaveGet(player, c_waveMain));
if ((AIWaveGetTimeSinceRetreat(w) > 2) && (AIGetUserInt(player, c_delayNextAttack) < AIGetTime())) {
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeWaveAI.galaxy:902
}
if (AIWaveUnitCount(w) < 1) {
return;
}