# Wave Merge

Grammar — Merges the wave with index waveFrom|FromIndex into the wave with index waveInto|IntoIndex for player player
FlagsNative | Action

Merges two waves together. Waves are specified using a player’s wave indexes.

# Arguments

  • int — Player
  • int — Wave From
  • int — Wave Into

Returns — void

native void AIWaveMerge(
	int player,
	int waveFrom,
	int waveInto,
);

Category: AI Advanced / Waves / Actions

# Examples

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeHighAI.galaxy:173

    }

    AIWaveMerge(player, c_waveMain, c_waveAttack);    
}

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeLowAI.galaxy:129


    if (sendAttack) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Attack);
    }

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeLowAI.galaxy:176


        if (activateNextWave) {
            AIWaveMerge(player, c_waveMain, c_waveAttack);
        }
    }

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

void AIWaveDefend (int player, wave w) {
    if (PlayerBeaconIsSet(player, c_beaconArmy)) {
        AIWaveMerge(player, c_waveDefend, c_waveAttack);
        return;
    }

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

        if (AIWaveGetTimeSinceOrdered(w) >= 30) {
            DebugAIPlayerWave(player, "defend4 merge defend back into attack");
            AIWaveMerge(player, c_waveDefend, c_waveAttack);
            return;
        }

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


    if (count >= 5 && PlayerBeaconIsSet(player, c_beaconArmy)) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        return;
    }

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

    if (count >= 6 && AIGetFlag(player, e_flagsTimeout)) {
        if (attackState != e_attackState_DropAttack && attackState != e_attackState_DropRetreat) {
            AIWaveMerge(player, c_waveMain, c_waveAttack);
            return;
        }

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

        if (AIWaveUnitCount(w) != 0) {
            if (type == c_waveDivert1) {
                AIWaveMerge(player, c_waveDivert1, c_waveAttack);
            }
            else if(type == c_waveDivert2) {

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

            }
            else if(type == c_waveDivert2) {
                AIWaveMerge(player, c_waveDivert2, c_waveAttack);
            }
        }

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

    // If we're supposed to be obeying the player, merge back into the main wave
    if (PlayerBeaconIsSet(player, c_beaconArmy)) {
        AIWaveMerge(player, c_waveClearObs, c_waveAttack);
        return;
    }

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

    if (obstruction == null) {
DebugAIPlayerWave(player, "clearobs1 merge clear obstruction -> main");
        AIWaveMerge(player, c_waveClearObs, c_waveMain);
        return;
    }

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

    AISetAttackState(player, e_attackState_DropAttack);
DebugAIPlayerWave(player, "attack1drop merge main -> attack; set attack = drop attack");
    AIWaveMerge(player, c_waveMain, c_waveAttack);
    AIWaveSetType(w, c_waveStateDropAttack, AIWaveTargetMeleeDrop(player, AILastDropLocation(), AILastDropGoal()));
    return true;

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

            if (AIState(player, e_attackState) == e_attackState_Attack) {
                DebugAIPlayerWave(player, "attack1 merge main -> attack; set attack = attack vs. melee target");
                AIWaveMerge(player, c_waveMain, c_waveAttack);
                AIWaveSetType(w, c_waveStateAttack, AIWaveTargetMelee(player));
            }

mods/liberty.sc2modbase.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:812

    // turn on attacking if it's not already on, but delay the next attack 5-7 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/liberty.sc2modbase.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:844

    // turn on attacking if it's not already on, but delay the next attack 5-7 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/liberty.sc2modbase.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:801

    // turn on attacking if it's not already on, but delay the next attack 5-7 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/swarm.sc2modbase.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:812

    // turn on attacking if it's not already on, but delay the next attack 5-7 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/swarm.sc2modbase.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:844

    // turn on attacking if it's not already on, but delay the next attack 5-7 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/swarm.sc2modbase.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:811

    // turn on attacking if it's not already on, but delay the next attack 5-7 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/void.sc2modbase.sc2data/TriggerLibs/MeleeHighAI.galaxy:173

    }

    AIWaveMerge(player, c_waveMain, c_waveAttack);    
}

mods/void.sc2modbase.sc2data/TriggerLibs/Protoss/ProtossHigh.galaxy:845

    // turn on attacking if it's not already on, but delay the next attack 4-6 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/void.sc2modbase.sc2data/TriggerLibs/Terran/TerranHigh.galaxy:847

    // turn on attacking if it's not already on, but delay the next attack 4-6 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

mods/void.sc2modbase.sc2data/TriggerLibs/Zerg/ZergHigh.galaxy:829

    // turn on attacking if it's not already on, but delay the next attack 4-6 minutes
    if (AIState(player, e_attackState) == e_attackState_Wait) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        AISetAttackState(player, e_attackState_Idle);

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

void AIWaveDefend (int player, wave w) {
    if (PlayerBeaconIsSet(player, c_beaconArmy)) {
        AIWaveMerge(player, c_waveDefend, c_waveAttack);
        return;
    }

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


    if (count >= 5 && PlayerBeaconIsSet(player, c_beaconArmy)) {
        AIWaveMerge(player, c_waveMain, c_waveAttack);
        return;
    }

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

    if (count >= 6 && AIGetFlag(player, e_flagsTimeout)) {
        if (attackState != e_attackState_DropAttack && attackState != e_attackState_DropRetreat) {
            AIWaveMerge(player, c_waveMain, c_waveAttack);
            return;
        }

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

        if (AIWaveUnitCount(w) != 0) {
            if (type == c_waveDivert1) {
                AIWaveMerge(player, c_waveDivert1, c_waveAttack);
            }
            else if(type == c_waveDivert2) {

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

            }
            else if(type == c_waveDivert2) {
                AIWaveMerge(player, c_waveDivert2, c_waveAttack);
            }
        }

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

    // If we're supposed to be obeying the player, merge back into the main wave
    if (PlayerBeaconIsSet(player, c_beaconArmy)) {
        AIWaveMerge(player, c_waveClearObs, c_waveAttack);
        return;
    }

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

    if (obstruction == null) {
DebugAIPlayerWave(player, "clearobs1 merge clear obstruction -> main");
        AIWaveMerge(player, c_waveClearObs, c_waveMain);
        return;
    }

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

    AISetAttackState(player, e_attackState_DropAttack);
DebugAIPlayerWave(player, "attack1drop merge main -> attack; set attack = drop attack");
    AIWaveMerge(player, c_waveMain, c_waveAttack);
    AIWaveSetType(w, c_waveStateDropAttack, AIWaveTargetMeleeDrop(player, AILastDropLocation(), AILastDropGoal()));
    return true;

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

            if (AIState(player, e_attackState) == e_attackState_Attack) {
                DebugAIPlayerWave(player, "attack1 merge main -> attack; set attack = attack vs. melee target");
                AIWaveMerge(player, c_waveMain, c_waveAttack);
				wt=AIWaveTargetMeleeWar3(player);
				if(wt){

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

        else if (AIWaveState(w) != c_waveStateRetreat) {
DebugAIPlayerWave(player, "attack2 merge main -> attack; set attack = retreat to gather offense");
            AIWaveMerge(player, c_waveMain, c_waveAttack);
            AIWaveSetType(w, c_waveStateRetreat, AIWaveTargetGatherO(player, c_townMain));
        }