# Wave State

Grammar — Get the state of wave waveRef
FlagsNative | Function

Returns the state of a wave.

# Arguments

  • wave — Wave

Returns — int

native int AIWaveState(wave w);

Category: AI Advanced / Waves / Functions

# Examples

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:59

        "wave="         + name                                          +
        ", units="      + IntToString(AIWaveUnitCount(w))               +
        ", state="      + WaveStateName(AIWaveState(w))                 +
        ", ratio="      + IntToString(AIWaveEvalRatio(w, c_evalRange))  +
        ", combat="     + IntToString(AIWaveGetTimeInCombat(w))         +

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:83


    if (eval < neededEval) {
        if (AIWaveState(w) != c_waveStateRetreat) {
DebugAIPlayerWave(player, "self defend1 set wave = retreat to gather defense");
            AIWaveSetType(w, c_waveStateRetreat, AIWaveTargetGatherD(player, c_townMain));

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:88

        }
    }
    else if (AIWaveState(w) != c_waveStateDefend) {
        if (eval > neededEval+10) {
            if (AIWaveGetTimeSinceOrdered(w) >= 20) {

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:106


    if (eval < neededEval) {
        if (AIWaveState(w) != c_waveStateRetreat) {
DebugAIPlayerWave(player, "ally defend1 set wave = retreat to gather defense");
            AIWaveSetType(w, c_waveStateRetreat, AIWaveTargetGatherD(player, c_townMain));

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:111

        }
    }
    else if (AIWaveState(w) != c_waveStateDefend) {
        if (eval > neededEval+10) {
            if (AIWaveGetTimeSinceOrdered(w) >= 5) {

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:136

        AIDefendAllyWithWave(player, w);
    }
    else if (AIWaveState(w) != c_waveStateIdle) {
DebugAIPlayerWave(player, "defend3 set defend = idle at gather defense");
        AIWaveSetType(w, c_waveStateIdle, AIWaveTargetGatherMelee(player));

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:156

    unit obstruction = null;
    int count = AIWaveUnitCount(w);
    int state = AIWaveState(w);
    int attackState = AIState(player, e_attackState);

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:199

    string leaderType;
    
    state = AIWaveState(w);

    if (type == c_waveDivert2) {

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:269

    int state;
    
    state = AIWaveState(w);
    if (state != c_waveStateGuardHome) {
DebugAIPlayerWave(player, "home set divert = idle at gather defense");

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:284

    unit oldTarget = null;
    int obsLife;
    int state = AIWaveState(w);

    // If we're supposed to be obeying the player, merge back into the main wave

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:615


    curWave = AIUnitGetWave(aiUnit);
    if (curWave == null || AIWaveState(curWave) != c_waveStateRetreat) {
        return null;
    }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1500


    curWave = AIUnitGetWave(aiUnit);
    if (curWave == null || AIWaveState(curWave) != c_waveStateRetreat) {
        return null;
    }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:506


    curWave = AIUnitGetWave(aiUnit);
    if (curWave == null || AIWaveState(curWave) != c_waveStateRetreat) {
        return null;
    }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:594


    curWave = AIUnitGetWave(aiUnit);
    if (curWave == null || AIWaveState(curWave) != c_waveStateRetreat) {
        return null;
    }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1501


    curWave = AIUnitGetWave(aiUnit);
    if (curWave == null || AIWaveState(curWave) != c_waveStateRetreat) {
        return null;
    }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:486


    curWave = AIUnitGetWave(aiUnit);
    if (curWave == null || AIWaveState(curWave) != c_waveStateRetreat) {
        return null;
    }

mods/warcoop/warclassicsystem.sc2modbase.sc2data/TriggerLibs/Tactical/TacticalAIWar3.galaxy:84

	w=AIUnitGetWave(aiUnit);
	if(w==null){return null;}
	if(AIWaveState(w)==c_waveStateRetreat){return null;}//For Fun
	goal=AIWaveGoal(w);
	if(goal==null){return null;}

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:189

        "wave="         + name                                          +
        ", units="      + IntToString(AIWaveUnitCount(w))               +
        ", state="      + WaveStateName(AIWaveState(w))                 +
        ", ratio="      + IntToString(AIWaveEvalRatio(w, c_evalRange))  +
        ", combat="     + IntToString(AIWaveGetTimeInCombat(w))         +

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:213


    if (eval < neededEval) {
        if (AIWaveState(w) != c_waveStateRetreat) {
DebugAIPlayerWave(player, "defend1 set wave = retreat to gather defense");
            AIWaveSetType(w, c_waveStateRetreat, AIWaveTargetGatherD(player, c_townMain));

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:218

        }
    }
    else if (AIWaveState(w) != c_waveStateDefend) {
        if (eval > neededEval+10) {
            if (AIWaveGetTimeSinceOrdered(w) >= 20) {

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:240

        AIDefendWithWave(player, w);
    }
    else if (AIWaveState(w) != c_waveStateIdle) {
DebugAIPlayerWave(player, "defend3 set defend = idle at gather defense");
        AIWaveSetType(w, c_waveStateIdle, AIWaveTargetGatherD(player, c_townMain));

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:252

    unit obstruction = null;
    int count = AIWaveUnitCount(w);
    int state = AIWaveState(w);
    int attackState = AIState(player, e_attackState);

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:292

    string leaderType;
    
    state = AIWaveState(w);

    if (type == c_waveDivert2) {

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:358

    int state;
    
    state = AIWaveState(w);
    if (state != c_waveStateGuardHome) {
DebugAIPlayerWave(player, "home set divert = idle at gather defense");

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:373

    unit oldTarget = null;
    int obsLife;
    int state = AIWaveState(w);

    // If we're supposed to be obeying the player, merge back into the main wave

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:495

    }

    if (AIWaveState(waveAttack) != c_waveStateAttack) {
        return false;
    }

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:520

    }

    if (AIWaveState(waveAttack) != c_waveStateAttack) {
        return c_nullPoint;
    }

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/Orc/Orc.galaxy:428

//--------------------------------------------------------------------------------------------------
bool CaptainRetreating(int player){
    return AIWaveState(AIWaveGet(player,c_waveMain))==c_waveStateRetreat;
}
void setup_forceOrc (int player){