# Wave Of Unit

Grammar — Wave of unit
FlagsNative | Function

Returns the wave a unit belongs to.

# Arguments

  • unit — Unit

Returns — wave

native wave AIUnitGetWave(unit u);

Category: AI / MiscCampaign / Functions

# Examples

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/traynor02.sc2map/MapScript.galaxy:3669


    TriggerEnable(TriggerGetCurrent(), false);
    auto14712386_g = AIWaveGetUnits(AIUnitGetWave(EventUnit()));
    auto14712386_u = UnitGroupCount(auto14712386_g, c_unitCountAll);
    for (;; auto14712386_u -= 1) {

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/traynor02.sc2map/MapScript.galaxy:3676

        UnitGroupAdd(lv_newAttackGroup, auto14712386_var);
    }
    AIAttackWaveCancel(AIUnitGetWave(EventUnit()));
    AIAttackWaveSetTargetPoint(gv_pLAYER_02_DOMINION, UnitGetPosition(gv_medicBarracks));
    autoBAB1CE6C_g = lv_newAttackGroup;

campaigns/liberty.sc2campaignbase.sc2maps/maps/challenges/zergcombat.sc2map/MapScript.galaxy:394

    UnitGroupLoopBegin(lp_unitGroup);
    while (!UnitGroupLoopDone()) {
        if (((AIUnitGetWave(UnitGroupLoopCurrent()) == c_nullWave) && (UnitGetOwner(UnitGroupLoopCurrent()) == gv_pLAYER_COMPUTER1))) {
            AIAttackWaveUseUnit(gv_pLAYER_COMPUTER1, UnitGroupLoopCurrent());
            AIAttackWaveSend(gv_pLAYER_COMPUTER1, 0, false);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/traynor02.sc2mapMapScript.galaxy:3669


    TriggerEnable(TriggerGetCurrent(), false);
    auto14712386_g = AIWaveGetUnits(AIUnitGetWave(EventUnit()));
    auto14712386_u = UnitGroupCount(auto14712386_g, c_unitCountAll);
    for (;; auto14712386_u -= 1) {

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/traynor02.sc2mapMapScript.galaxy:3676

        UnitGroupAdd(lv_newAttackGroup, auto14712386_var);
    }
    AIAttackWaveCancel(AIUnitGetWave(EventUnit()));
    AIAttackWaveSetTargetPoint(gv_pLAYER_02_DOMINION, UnitGetPosition(gv_medicBarracks));
    autoBAB1CE6C_g = lv_newAttackGroup;

campaigns/liberty.sc2campaign/base.sc2maps/maps/challenges/zergcombat.sc2mapMapScript.galaxy:394

    UnitGroupLoopBegin(lp_unitGroup);
    while (!UnitGroupLoopDone()) {
        if (((AIUnitGetWave(UnitGroupLoopCurrent()) == c_nullWave) && (UnitGetOwner(UnitGroupLoopCurrent()) == gv_pLAYER_COMPUTER1))) {
            AIAttackWaveUseUnit(gv_pLAYER_COMPUTER1, UnitGroupLoopCurrent());
            AIAttackWaveSend(gv_pLAYER_COMPUTER1, 0, false);

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/zchar01.sc2map/MapScript.galaxy:2631

    }

    AIAttackWaveCancel(AIUnitGetWave(gv_zagara));
    AISetUnitScriptControlled(gv_zagara, false);
    AIRemoveUnitFromAnyWavesAndSetHome(gv_zagara, PointFromId(3));

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zchar01.sc2mapMapScript.galaxy:2631

    }

    AIAttackWaveCancel(AIUnitGetWave(gv_zagara));
    AISetUnitScriptControlled(gv_zagara, false);
    AIRemoveUnitFromAnyWavesAndSetHome(gv_zagara, PointFromId(3));

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/pulnar01.sc2map/MapScript.galaxy:473

        auto2439952A_var = UnitGroupUnitFromEnd(auto2439952A_g, auto2439952A_u);
        if (auto2439952A_var == null) { break; }
        if ((AIUnitGetWave(auto2439952A_var) == null) && (RegionContainsPoint(gv_celestialLocks[lp_index].lv_defenseRegion, UnitGetGoalPosition(auto2439952A_var)) == true)) {
            AIRemoveUnitFromAnyWavesAndSetHome(auto2439952A_var, PlayerStartLocation(UnitGetOwner(auto2439952A_var)));
            UnitIssueOrder(auto2439952A_var, OrderTargetingPoint(null, PlayerStartLocation(UnitGetOwner(auto2439952A_var))), c_orderQueueReplace);

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/pulnar01.sc2map/MapScript.galaxy:2599


            Wait(1.0, c_timeAI);
            if ((lv_attackWave != AIUnitGetWave(UnitGroupUnit(lv_attackWaveUnits, 1)))) {
                break;
            }

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/sc2epilogue01.sc2map/MapScript.galaxy:6289

        autoAA8579C6_var = UnitGroupUnitFromEnd(autoAA8579C6_g, autoAA8579C6_u);
        if (autoAA8579C6_var == null) { break; }
        if ((UnitGetType(autoAA8579C6_var) != "ShadowCloudEpilogue01") && (AIIsNotUsableInWaves(autoAA8579C6_var) == false) && (AIUnitGetWave(autoAA8579C6_var) == null)) {
            UnitGroupAdd(lv_attackGroup, autoAA8579C6_var);
        }

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/sc2epilogue03.sc2map/MapScript.galaxy:2926

                }
                else {
                    if ((RandomInt(1, libLotv_gf_DifficultyValueInt2(8, 8, 9, 10)) == 1) && (AIUnitGetWave(autoE0C2EB0B_var) == null)) {
                        libNtve_gf_AICast(autoE0C2EB0B_var, OrderTargetingPoint(AbilityCommand("attack", 0), RegionRandomPoint(gv_voidChasm[lv_index].lv_spawnRegion)));
                    }

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/sc2epilogue03.sc2map/MapScript.galaxy:4941

        Wait(1.0, c_timeAI);
    }
    auto9C4E0B80_g = AIWaveGetUnits(AIUnitGetWave(UnitGroupUnit(UnitGroup(null, gv_pLAYER_03_ARTANIS, gv_voidChasm[1].lv_spawnSafetyRegion, UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), 1)));
    auto9C4E0B80_u = UnitGroupCount(auto9C4E0B80_g, c_unitCountAll);
    for (;; auto9C4E0B80_u -= 1) {

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pulnar01.sc2mapMapScript.galaxy:473

        auto2439952A_var = UnitGroupUnitFromEnd(auto2439952A_g, auto2439952A_u);
        if (auto2439952A_var == null) { break; }
        if ((AIUnitGetWave(auto2439952A_var) == null) && (RegionContainsPoint(gv_celestialLocks[lp_index].lv_defenseRegion, UnitGetGoalPosition(auto2439952A_var)) == true)) {
            AIRemoveUnitFromAnyWavesAndSetHome(auto2439952A_var, PlayerStartLocation(UnitGetOwner(auto2439952A_var)));
            UnitIssueOrder(auto2439952A_var, OrderTargetingPoint(null, PlayerStartLocation(UnitGetOwner(auto2439952A_var))), c_orderQueueReplace);

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pulnar01.sc2mapMapScript.galaxy:2599


            Wait(1.0, c_timeAI);
            if ((lv_attackWave != AIUnitGetWave(UnitGroupUnit(lv_attackWaveUnits, 1)))) {
                break;
            }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/sc2epilogue01.sc2mapMapScript.galaxy:6289

        autoAA8579C6_var = UnitGroupUnitFromEnd(autoAA8579C6_g, autoAA8579C6_u);
        if (autoAA8579C6_var == null) { break; }
        if ((UnitGetType(autoAA8579C6_var) != "ShadowCloudEpilogue01") && (AIIsNotUsableInWaves(autoAA8579C6_var) == false) && (AIUnitGetWave(autoAA8579C6_var) == null)) {
            UnitGroupAdd(lv_attackGroup, autoAA8579C6_var);
        }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/sc2epilogue03.sc2mapMapScript.galaxy:2926

                }
                else {
                    if ((RandomInt(1, libLotv_gf_DifficultyValueInt2(8, 8, 9, 10)) == 1) && (AIUnitGetWave(autoE0C2EB0B_var) == null)) {
                        libNtve_gf_AICast(autoE0C2EB0B_var, OrderTargetingPoint(AbilityCommand("attack", 0), RegionRandomPoint(gv_voidChasm[lv_index].lv_spawnRegion)));
                    }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/sc2epilogue03.sc2mapMapScript.galaxy:4941

        Wait(1.0, c_timeAI);
    }
    auto9C4E0B80_g = AIWaveGetUnits(AIUnitGetWave(UnitGroupUnit(UnitGroup(null, gv_pLAYER_03_ARTANIS, gv_voidChasm[1].lv_spawnSafetyRegion, UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), 1)));
    auto9C4E0B80_u = UnitGroupCount(auto9C4E0B80_g, c_unitCountAll);
    for (;; auto9C4E0B80_u -= 1) {

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

    }

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

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

    }

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

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

    }

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

mods/novastoryassets.sc2modbase2.sc2maps/maps/campaign/nova/nova05.sc2map/MapScript.galaxy:901

        autoC02902CA_var = UnitGroupUnitFromEnd(autoC02902CA_g, autoC02902CA_u);
        if (autoC02902CA_var == null) { break; }
        if ((AIUnitGetWave(autoC02902CA_var) != null)) {
            AIRemoveUnitFromAnyWaves(autoC02902CA_var);
        }

mods/novastoryassets.sc2mod/base2.sc2maps/maps/campaign/nova/nova05.sc2mapMapScript.galaxy:901

        autoC02902CA_var = UnitGroupUnitFromEnd(autoC02902CA_g, autoC02902CA_u);
        if (autoC02902CA_var == null) { break; }
        if ((AIUnitGetWave(autoC02902CA_var) != null)) {
            AIRemoveUnitFromAnyWaves(autoC02902CA_var);
        }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:2119

        lv_target = AIBestTargetPoint(lv_enemiesNearby, 4, FixedToInt(lv_abilityDamage), lv_score, lv_abilityAoE, UnitGetPosition(lp_aIUnit), lv_abilityRange, c_unitAttributeNone);
        if ((lv_target != null)) {
            lv_wave = AIUnitGetWave(lp_aIUnit);
            UnitIssueOrder(lp_aIUnit, OrderTargetingPoint(AbilityCommand("MutatorAmonNovaNuke", 0), lv_target), c_orderQueueReplace);
            Wait(0.5, c_timeAI);

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1579

	if ((TechTreeUpgradeCount(player, c_ZR_RoachUnderground, c_techCountCompleteOnly) > 0)) {
		
		if (AIPathingCostUnit (aiUnit, AIWaveGoal(AIUnitGetWave(aiUnit)), true) < 0) {
			return;
		}			

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1604

	if (TechTreeUpgradeCount(player, c_ZR_RoachUnderground, c_techCountCompleteOnly) > 0) {
		
		if (AIPathingCostUnit (aiUnit, AIWaveGoal(AIUnitGetWave(aiUnit)), true) < 0) {
			return;
		}			

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

    }

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

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

    }

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

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

    }

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

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

    }
    
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

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

    }
    
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

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

        return;
    }
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

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

    }

    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

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

    unit waveEscortUnit;
    
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

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

    unit waveEscortUnit;
    
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1557

    unit waveEscortUnit;
    
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1602

    aifilter filter;
    
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1637

    unit waveEscortUnit;
    
    unitWave = AIUnitGetWave(aiUnit);
    unitWaveTarget = AIWaveGetTarget(unitWave);
    

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

    }
	//Scroll of Town Portal
	w=AIUnitGetWave(aiUnit);
	if(w==null){return null;}
	if(AIWaveState(w)==c_waveStateRetreat){return null;}//For Fun

mods/warcoop/warcoopdata.sc2modbase.sc2data/TriggerLibs/WarCoopData.galaxy:4015

    // Automatic Variable Declarations
    // Variable Initialization
    lv_attackwave = AIUnitGetWave(EventUnit());

    // Conditions

mods/warcoop/warmeleeai.sc2modbase.sc2data/LibW3AI.galaxy:297

    }

    lv_ug = UnitGroupFilterRegion(AIWaveGetUnits(AIUnitGetWave(lv_c)), RegionCircle(lv_po, 20.0), 0);
    UnitGroupIssueOrder(lv_ug, OrderTargetingPoint(AbilityCommand("Aatk", 0), lv_po), c_orderQueueReplace);
    AISetGroupScriptControlled(lv_ug, false);