# Remove Unit From All Waves

Grammar — Remove unit from all waves
FlagsNative | Action

Removes a unit from any waves it is in.

# Arguments

  • unit — Unit

Returns — void

native void AIRemoveUnitFromAnyWaves(unit u);

Category: AI / MiscCampaign / Actions

# Examples

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/thorner03.sc2map/MapScript.galaxy:1409

    }

    AIRemoveUnitFromAnyWaves(UnitFromId(2));
    AISetUnitScriptControlled(UnitFromId(2), false);
    AIAttackWaveSetGatherPoint(gv_p02_TYCHUS, UnitGetPosition(UnitFromId(2)));

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/thorner03.sc2map/MapScript.galaxy:1675

    TriggerExecute(gt_P04AttackWaves, true, false);
    Wait(10.0, c_timeGame);
    AIRemoveUnitFromAnyWaves(UnitFromId(2));
    AISetUnitScriptControlled(UnitFromId(2), false);
    AIAttackWaveSetGatherPoint(gv_p02_TYCHUS, UnitGetPosition(UnitFromId(2)));

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/ttosh02.sc2map/MapScript.galaxy:2692

            auto9A060CE7_var = UnitGroupUnitFromEnd(auto9A060CE7_g, auto9A060CE7_u);
            if (auto9A060CE7_var == null) { break; }
            AIRemoveUnitFromAnyWaves(auto9A060CE7_var);
        }
    }

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/ttosh02.sc2map/MapScript.galaxy:2748

        auto16B0C7AE_var = UnitGroupUnitFromEnd(auto16B0C7AE_g, auto16B0C7AE_u);
        if (auto16B0C7AE_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto16B0C7AE_var);
        if ((libNtve_gf_DifficultyValueInt(0, 0, 0, 1) == 1) && (UnitGetType(auto16B0C7AE_var) != "Observer")) {
            AISetUnitSuicide(auto16B0C7AE_var, true);

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/ttosh02.sc2map/MapScript.galaxy:2819

        auto8E33FE20_var = UnitGroupUnitFromEnd(auto8E33FE20_g, auto8E33FE20_u);
        if (auto8E33FE20_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto8E33FE20_var);
    }
    if ((gv_protossScore == 3)) {

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tvalerian02b.sc2map/MapScript.galaxy:1313


    TriggerEnable(TriggerGetCurrent(), false);
    AIRemoveUnitFromAnyWaves(gv_leviathan);
    UnitIssueOrder(gv_leviathan, Order(AbilityCommand("stop", 0)), c_orderQueueReplace);
    autoD38025F2_n = libNtve_gf_DifficultyValueInt(3, 4, 4, 5);

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tvalerian03.sc2map/MapScript.galaxy:2683


    lv_leviathanHomePoint = UnitGetPosition(gv_leviathan);
    AIRemoveUnitFromAnyWaves(gv_leviathan);
    UnitIssueOrder(EventUnit(), Order(AbilityCommand("move", 2)), c_orderQueueReplace);
    while (true) {

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tvalerian03.sc2map/MapScript.galaxy:3415

        if ((UnitGetPropertyFixed(gv_kerrigan, c_unitPropLife, c_unitPropCurrent) <= 150.0)) {
            PingSetVisible(gv_kerriganPing, false);
            AIRemoveUnitFromAnyWaves(gv_kerrigan);
            AISetUnitScriptControlled(gv_kerrigan, true);
            UnitBehaviorRemove(gv_kerrigan, "Stunned", 1);

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tvalerian03.sc2map/MapScript.galaxy:3431

                auto1DD65D10_var = UnitGroupUnitFromEnd(auto1DD65D10_g, auto1DD65D10_u);
                if (auto1DD65D10_var == null) { break; }
                AIRemoveUnitFromAnyWaves(auto1DD65D10_var);
                UnitIssueOrder(auto1DD65D10_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(gv_artifact)), c_orderQueueReplace);
            }

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul04.sc2map/MapScript.galaxy:3206

        auto2349CB4A_var = UnitGroupUnitFromEnd(auto2349CB4A_g, auto2349CB4A_u);
        if (auto2349CB4A_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto2349CB4A_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, auto2349CB4A_var);
    }

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul04.sc2map/MapScript.galaxy:3214

        autoD69B4807_var = UnitGroupUnitFromEnd(autoD69B4807_g, autoD69B4807_u);
        if (autoD69B4807_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoD69B4807_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, autoD69B4807_var);
    }

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul04.sc2map/MapScript.galaxy:3222

        auto1A6B2BE7_var = UnitGroupUnitFromEnd(auto1A6B2BE7_g, auto1A6B2BE7_u);
        if (auto1A6B2BE7_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto1A6B2BE7_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, auto1A6B2BE7_var);
    }

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul04.sc2map/MapScript.galaxy:3230

        autoDE45E3C3_var = UnitGroupUnitFromEnd(autoDE45E3C3_g, autoDE45E3C3_u);
        if (autoDE45E3C3_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoDE45E3C3_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, autoDE45E3C3_var);
    }

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul04.sc2map/MapScript.galaxy:3238

        autoFCFC6CC1_var = UnitGroupUnitFromEnd(autoFCFC6CC1_g, autoFCFC6CC1_u);
        if (autoFCFC6CC1_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoFCFC6CC1_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, autoFCFC6CC1_var);
    }

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/thorner03.sc2mapMapScript.galaxy:1409

    }

    AIRemoveUnitFromAnyWaves(UnitFromId(2));
    AISetUnitScriptControlled(UnitFromId(2), false);
    AIAttackWaveSetGatherPoint(gv_p02_TYCHUS, UnitGetPosition(UnitFromId(2)));

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/thorner03.sc2mapMapScript.galaxy:1675

    TriggerExecute(gt_P04AttackWaves, true, false);
    Wait(10.0, c_timeGame);
    AIRemoveUnitFromAnyWaves(UnitFromId(2));
    AISetUnitScriptControlled(UnitFromId(2), false);
    AIAttackWaveSetGatherPoint(gv_p02_TYCHUS, UnitGetPosition(UnitFromId(2)));

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/ttosh02.sc2mapMapScript.galaxy:2692

            auto9A060CE7_var = UnitGroupUnitFromEnd(auto9A060CE7_g, auto9A060CE7_u);
            if (auto9A060CE7_var == null) { break; }
            AIRemoveUnitFromAnyWaves(auto9A060CE7_var);
        }
    }

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/ttosh02.sc2mapMapScript.galaxy:2748

        auto16B0C7AE_var = UnitGroupUnitFromEnd(auto16B0C7AE_g, auto16B0C7AE_u);
        if (auto16B0C7AE_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto16B0C7AE_var);
        if ((libNtve_gf_DifficultyValueInt(0, 0, 0, 1) == 1) && (UnitGetType(auto16B0C7AE_var) != "Observer")) {
            AISetUnitSuicide(auto16B0C7AE_var, true);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/ttosh02.sc2mapMapScript.galaxy:2819

        auto8E33FE20_var = UnitGroupUnitFromEnd(auto8E33FE20_g, auto8E33FE20_u);
        if (auto8E33FE20_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto8E33FE20_var);
    }
    if ((gv_protossScore == 3)) {

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tvalerian02b.sc2mapMapScript.galaxy:1313


    TriggerEnable(TriggerGetCurrent(), false);
    AIRemoveUnitFromAnyWaves(gv_leviathan);
    UnitIssueOrder(gv_leviathan, Order(AbilityCommand("stop", 0)), c_orderQueueReplace);
    autoD38025F2_n = libNtve_gf_DifficultyValueInt(3, 4, 4, 5);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tvalerian03.sc2mapMapScript.galaxy:2683


    lv_leviathanHomePoint = UnitGetPosition(gv_leviathan);
    AIRemoveUnitFromAnyWaves(gv_leviathan);
    UnitIssueOrder(EventUnit(), Order(AbilityCommand("move", 2)), c_orderQueueReplace);
    while (true) {

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tvalerian03.sc2mapMapScript.galaxy:3415

        if ((UnitGetPropertyFixed(gv_kerrigan, c_unitPropLife, c_unitPropCurrent) <= 150.0)) {
            PingSetVisible(gv_kerriganPing, false);
            AIRemoveUnitFromAnyWaves(gv_kerrigan);
            AISetUnitScriptControlled(gv_kerrigan, true);
            UnitBehaviorRemove(gv_kerrigan, "Stunned", 1);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tvalerian03.sc2mapMapScript.galaxy:3431

                auto1DD65D10_var = UnitGroupUnitFromEnd(auto1DD65D10_g, auto1DD65D10_u);
                if (auto1DD65D10_var == null) { break; }
                AIRemoveUnitFromAnyWaves(auto1DD65D10_var);
                UnitIssueOrder(auto1DD65D10_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(gv_artifact)), c_orderQueueReplace);
            }

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul04.sc2mapMapScript.galaxy:3206

        auto2349CB4A_var = UnitGroupUnitFromEnd(auto2349CB4A_g, auto2349CB4A_u);
        if (auto2349CB4A_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto2349CB4A_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, auto2349CB4A_var);
    }

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul04.sc2mapMapScript.galaxy:3214

        autoD69B4807_var = UnitGroupUnitFromEnd(autoD69B4807_g, autoD69B4807_u);
        if (autoD69B4807_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoD69B4807_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, autoD69B4807_var);
    }

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul04.sc2mapMapScript.galaxy:3222

        auto1A6B2BE7_var = UnitGroupUnitFromEnd(auto1A6B2BE7_g, auto1A6B2BE7_u);
        if (auto1A6B2BE7_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto1A6B2BE7_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, auto1A6B2BE7_var);
    }

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul04.sc2mapMapScript.galaxy:3230

        autoDE45E3C3_var = UnitGroupUnitFromEnd(autoDE45E3C3_g, autoDE45E3C3_u);
        if (autoDE45E3C3_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoDE45E3C3_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, autoDE45E3C3_var);
    }

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul04.sc2mapMapScript.galaxy:3238

        autoFCFC6CC1_var = UnitGroupUnitFromEnd(autoFCFC6CC1_g, autoFCFC6CC1_u);
        if (autoFCFC6CC1_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoFCFC6CC1_var);
        UnitGroupRemove(gv_gGWavesUnitGroup, autoFCFC6CC1_var);
    }

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/voidprologue/voidprologue01.sc2map/MapScript.galaxy:3834

        autoAEBA1236_var = UnitGroupUnitFromEnd(autoAEBA1236_g, autoAEBA1236_u);
        if (autoAEBA1236_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoAEBA1236_var);
        libNtve_gf_ShareVisionofUnit(autoAEBA1236_var, false, gv_pLAYER_01_USER);
        if ((libNtve_gf_UnitInRegion(autoAEBA1236_var, RegionFromId(4)) == true)) {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/voidprologue/voidprologue01.sc2map/MapScript.galaxy:4084

        auto9765FBD7_var = UnitGroupUnitFromEnd(auto9765FBD7_g, auto9765FBD7_u);
        if (auto9765FBD7_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto9765FBD7_var);
        libNtve_gf_ShareVisionofUnit(auto9765FBD7_var, false, gv_pLAYER_01_USER);
        if ((libNtve_gf_UnitInRegion(auto9765FBD7_var, RegionFromId(5)) == true)) {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/voidprologue/voidprologue01.sc2mapMapScript.galaxy:3834

        autoAEBA1236_var = UnitGroupUnitFromEnd(autoAEBA1236_g, autoAEBA1236_u);
        if (autoAEBA1236_var == null) { break; }
        AIRemoveUnitFromAnyWaves(autoAEBA1236_var);
        libNtve_gf_ShareVisionofUnit(autoAEBA1236_var, false, gv_pLAYER_01_USER);
        if ((libNtve_gf_UnitInRegion(autoAEBA1236_var, RegionFromId(4)) == true)) {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/voidprologue/voidprologue01.sc2mapMapScript.galaxy:4084

        auto9765FBD7_var = UnitGroupUnitFromEnd(auto9765FBD7_g, auto9765FBD7_u);
        if (auto9765FBD7_var == null) { break; }
        AIRemoveUnitFromAnyWaves(auto9765FBD7_var);
        libNtve_gf_ShareVisionofUnit(auto9765FBD7_var, false, gv_pLAYER_01_USER);
        if ((libNtve_gf_UnitInRegion(auto9765FBD7_var, RegionFromId(5)) == true)) {

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/ptaldarim01.sc2map/MapScript.galaxy:3284

        if (auto4DF29060_var == null) { break; }
        AISetUnitScriptControlled(auto4DF29060_var, false);
        AIRemoveUnitFromAnyWaves(auto4DF29060_var);
        if ((UnitGetOwner(auto4DF29060_var) != gv_pLAYER_01_USER)) {
            AISetUnitSuicide(auto4DF29060_var, true);

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/ptaldarim01.sc2map/MapScript.galaxy:3443

        if (auto0F3CEB9A_var == null) { break; }
        AISetUnitScriptControlled(auto0F3CEB9A_var, false);
        AIRemoveUnitFromAnyWaves(auto0F3CEB9A_var);
        if ((UnitGetOwner(auto0F3CEB9A_var) != gv_pLAYER_01_USER)) {
            AISetUnitSuicide(auto0F3CEB9A_var, true);

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/ptaldarim01.sc2mapMapScript.galaxy:3284

        if (auto4DF29060_var == null) { break; }
        AISetUnitScriptControlled(auto4DF29060_var, false);
        AIRemoveUnitFromAnyWaves(auto4DF29060_var);
        if ((UnitGetOwner(auto4DF29060_var) != gv_pLAYER_01_USER)) {
            AISetUnitSuicide(auto4DF29060_var, true);

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/ptaldarim01.sc2mapMapScript.galaxy:3443

        if (auto0F3CEB9A_var == null) { break; }
        AISetUnitScriptControlled(auto0F3CEB9A_var, false);
        AIRemoveUnitFromAnyWaves(auto0F3CEB9A_var);
        if ((UnitGetOwner(auto0F3CEB9A_var) != gv_pLAYER_01_USER)) {
            AISetUnitSuicide(auto0F3CEB9A_var, true);

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignMissionLib.galaxy:6078

    UnitIssueOrder(EventUnit(), Order(AbilityCommand("stop", 0)), c_orderQueueReplace);
    AISetUnitScriptControlled(EventUnit(), false);
    AIRemoveUnitFromAnyWaves(EventUnit());
    AISetUnitSuicide(EventUnit(), true);
    return true;

mods/novastoryassets.sc2modbase.sc2maps/maps/campaign/nova/nova03.sc2map/MapScript.galaxy:1271

    // Automatic Variable Declarations
    // Implementation
    AIRemoveUnitFromAnyWaves(lp_overseerUnit);
    while ((libNCMI_gf_GameIsOver() == false) && (gv_currentStage == 1) && (UnitIsAlive(lp_overseerUnit) == true)) {
        if ((DistanceBetweenPoints(UnitGetPosition(lp_overseerUnit), lp_targetPoint) <= 1)) {

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

        if (autoC02902CA_var == null) { break; }
        if ((AIUnitGetWave(autoC02902CA_var) != null)) {
            AIRemoveUnitFromAnyWaves(autoC02902CA_var);
        }

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

    // Automatic Variable Declarations
    // Implementation
    AIRemoveUnitFromAnyWaves(lp_infestedUnit);
    Wait(RandomFixed(2.0, 5.0), c_timeGame);
    while ((UnitIsAlive(lp_infestedUnit) == true) && ((UnitGetType(lp_infestedUnit) == "InfestedCivilian") || (UnitGetType(lp_infestedUnit) == "InfestedExploder") || (UnitGetType(lp_infestedUnit) == "InfestedTerranCampaign") || (UnitGetType(lp_infestedUnit) == "InfestedAbomination"))) {

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

    // Automatic Variable Declarations
    // Implementation
    AIRemoveUnitFromAnyWaves(lp_infestedUnit);
    Wait(RandomFixed(2.0, 5.0), c_timeAI);
    while ((UnitIsAlive(lp_infestedUnit) == true) && ((UnitGetType(lp_infestedUnit) == "InfestedCivilian") || (UnitGetType(lp_infestedUnit) == "InfestedExploder") || (UnitGetType(lp_infestedUnit) == "InfestedTerranCampaign") || (UnitGetType(lp_infestedUnit) == "InfestedAbomination") || (UnitGetType(lp_infestedUnit) == "NovaInfestedBanshee"))) {

mods/novastoryassets.sc2mod/base.sc2maps/maps/campaign/nova/nova03.sc2mapMapScript.galaxy:1271

    // Automatic Variable Declarations
    // Implementation
    AIRemoveUnitFromAnyWaves(lp_overseerUnit);
    while ((libNCMI_gf_GameIsOver() == false) && (gv_currentStage == 1) && (UnitIsAlive(lp_overseerUnit) == true)) {
        if ((DistanceBetweenPoints(UnitGetPosition(lp_overseerUnit), lp_targetPoint) <= 1)) {

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

        if (autoC02902CA_var == null) { break; }
        if ((AIUnitGetWave(autoC02902CA_var) != null)) {
            AIRemoveUnitFromAnyWaves(autoC02902CA_var);
        }

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

    // Automatic Variable Declarations
    // Implementation
    AIRemoveUnitFromAnyWaves(lp_infestedUnit);
    Wait(RandomFixed(2.0, 5.0), c_timeGame);
    while ((UnitIsAlive(lp_infestedUnit) == true) && ((UnitGetType(lp_infestedUnit) == "InfestedCivilian") || (UnitGetType(lp_infestedUnit) == "InfestedExploder") || (UnitGetType(lp_infestedUnit) == "InfestedTerranCampaign") || (UnitGetType(lp_infestedUnit) == "InfestedAbomination"))) {

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

    // Automatic Variable Declarations
    // Implementation
    AIRemoveUnitFromAnyWaves(lp_infestedUnit);
    Wait(RandomFixed(2.0, 5.0), c_timeAI);
    while ((UnitIsAlive(lp_infestedUnit) == true) && ((UnitGetType(lp_infestedUnit) == "InfestedCivilian") || (UnitGetType(lp_infestedUnit) == "InfestedExploder") || (UnitGetType(lp_infestedUnit) == "InfestedTerranCampaign") || (UnitGetType(lp_infestedUnit) == "InfestedAbomination") || (UnitGetType(lp_infestedUnit) == "NovaInfestedBanshee"))) {