# Units In Unit Group With Alliance

Grammar — Units in group|Unit Group having alliance alliance with player, with at most count
FlagsNative | Function

Returns a unit group that contains units that have passed the specified ally filters from another unit group.

# Arguments

  • unitgroup — Group
  • int — Player
  • int<preset::UnitAlliance> — Alliance
  • int — Count

Returns — unitgroup

native unitgroup UnitGroupFilterAlliance(
	unitgroup g,
	int player,
	int alliance,
	int maxCount,
);

Category: Unit Group / Useful Unit Groups

# Examples

mods/heroesbrawlmods/arenamodemods/templearena.stormmodbase.stormdata/LibAMCT.galaxy:2212

    lv_currentOrderTarget = OrderGetTargetUnit(lv_currentOrder);
    if ((UnitGetOwner(libAMCT_gv_aRMSkyTemple[lv_templeIndex].lv_temple) != libCore_gv_cOMPUTER_Neutral)) {
        lv_testTargets = UnitGroupFilterAlliance(lv_validTargets, UnitGetOwner(libAMCT_gv_aRMSkyTemple[lv_templeIndex].lv_beacon), c_unitAllianceAlly, 0);
        if ((UnitIsValid(lv_currentOrderTarget) == true) && (UnitGroupHasUnit(lv_testTargets, lv_currentOrderTarget) == true)) {
            lv_bestTarget = lv_currentOrderTarget;

mods/heroesbrawlmods/brawlmapmods/coop/escapefrombraxis.stormmodbase.stormdata/LibPEB1.galaxy:8139

    libNtve_gf_StopTimer(libPEB1_gv_holdoutTimer);
    while (true) {
        lv_zergRemaining = (UnitGroupCount(UnitGroupFilterAlliance(libPEB1_gv_activeZergHeroes, libCore_gv_cOMPUTER_TeamChaos, c_unitAllianceAlly, 0), c_unitCountAlive) + UnitGroupCount(UnitGroupFilterPlayer(libPEB1_gv_activeZergMinions, libCore_gv_cOMPUTER_TeamChaos, 0), c_unitCountAlive));
        if ((lv_zergRemaining == 0)) {
            break;

mods/heroesbrawlmods/brawlmapmods/coop/escapefrombraxis.stormmodbase.stormdata/LibPEB1.galaxy:8729

    libNtve_gf_StopTimer(libPEB1_gv_holdoutTimer);
    while (true) {
        if ((UnitGroupCount(UnitGroupFilterPlayer(libPEB1_gv_activeZergMinions, libCore_gv_cOMPUTER_TeamChaos, 0), c_unitCountAlive) == 0) && (UnitGroupCount(UnitGroupFilterAlliance(libPEB1_gv_activeZergHeroes, libCore_gv_cOMPUTER_TeamChaos, c_unitAllianceAlly, 0), c_unitCountAlive) == 0)) {
            break;
        }

mods/heroesbrawlmods/brawlmapmods/coop/escapefrombraxis.stormmodbase.stormdata/LibPEB1.galaxy:8733

        }
        else {
            libPEB1_gf_SetHoldoutPanelZergRemaining((UnitGroupCount(UnitGroupFilterAlliance(libPEB1_gv_activeZergHeroes, libCore_gv_cOMPUTER_TeamChaos, c_unitAllianceAlly, 0), c_unitCountAlive) + UnitGroupCount(UnitGroupFilterPlayer(libPEB1_gv_activeZergMinions, libCore_gv_cOMPUTER_TeamChaos, 0), c_unitCountAlive)));
            TextExpressionSetToken("Param/Expression/lib_PEB1_8C9C6DCD", "A", IntToText((UnitGroupCount(libPEB1_gv_activeZergHeroes, c_unitCountAlive) + UnitGroupCount(libPEB1_gv_activeZergMinions, c_unitCountAlive))));
            TextTagSetText(lv_countdownTextTag, TextExpressionAssemble("Param/Expression/lib_PEB1_8C9C6DCD"));

mods/heroesbrawlmods/brawlmapmods/coop/escapefrombraxis.stormmodbase.stormdata/LibPEB1.galaxy:10700

    }

    if ((UnitGroupCount(UnitGroupFilterPlayer(libPEB1_gv_activeZergMinions, libCore_gv_cOMPUTER_TeamChaos, 0), c_unitCountAlive) == 0) && (UnitGroupCount(UnitGroupFilterAlliance(libPEB1_gv_activeZergHeroes, libCore_gv_cOMPUTER_TeamChaos, c_unitAllianceAlly, 0), c_unitCountAlive) == 0)) {
        TransmissionSendForPlayerSelect(PlayerGroupAll(), TransmissionSource(), c_invalidPortraitId, "", "Talk", SoundLinkNoIndex(ConversationDataGetSound("AdjutantPVEVO|Line00016", false)), null, null, 0.0, c_transmissionDurationAdd, true, c_maxPlayers, false);
    }

mods/heroesbrawlmods/brawlmapmods/coop/escapefrombraxis.stormmodbase.stormdata/LibPEB1.galaxy:10901

    }

    if ((UnitGroupCount(UnitGroupFilterPlayer(libPEB1_gv_activeZergMinions, libCore_gv_cOMPUTER_TeamChaos, 0), c_unitCountAlive) == 0) && (UnitGroupCount(UnitGroupFilterAlliance(libPEB1_gv_activeZergHeroes, libCore_gv_cOMPUTER_TeamChaos, c_unitAllianceAlly, 0), c_unitCountAlive) == 0)) {
        TransmissionSendForPlayerSelect(PlayerGroupAll(), TransmissionSource(), c_invalidPortraitId, "", "Talk", SoundLinkNoIndex(ConversationDataGetSound("AdjutantPVEVO|Line00016", false)), null, null, 0.0, c_transmissionDurationAdd, true, c_maxPlayers, false);
    }

mods/heroesmapmods/battlegroundmapmods/skytemple.stormmodbase.stormdata/LibMLCP.galaxy:2711

    lv_currentOrderTarget = OrderGetTargetUnit(lv_currentOrder);
    if ((UnitGetOwner(libMLCP_gv_mMSkyTemples[lv_templeIndex].lv_temple) != libCore_gv_cOMPUTER_Neutral)) {
        lv_testTargets = UnitGroupFilterAlliance(lv_validTargets, UnitGetOwner(libMLCP_gv_mMSkyTemples[lv_templeIndex].lv_beacon), c_unitAllianceAlly, 0);
        if ((UnitIsValid(lv_currentOrderTarget) == true) && (UnitGroupHasUnit(lv_testTargets, lv_currentOrderTarget) == true)) {
            lv_bestTarget = lv_currentOrderTarget;

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

    lv_abilityAoE = StringToFixed(CatalogFieldValueGet(c_gameCatalogEffect, "MutatorAmonTychusTossGrenadeDamage", "AreaArray[" + IntToString(0) + "].Radius", c_playerAny));
    lv_score = 1;
    lv_target = AIBestTargetPoint(UnitGroupFilterAlliance(lp_nearByUnits, lp_owner, c_unitAllianceEnemy, 0), 3, lv_abilityDamage, lv_score, lv_abilityAoE, UnitGetPosition(lp_aIUnit), lv_abilityRange, c_unitAttributeNone);
    if ((lv_target != null)) {
        libNtve_gf_AICast(lp_aIUnit, OrderTargetingPoint(AbilityCommand("MutatorAmonTychusTossGrenade", 0), lv_target));

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

    lv_score = 1;
    lv_abilityAoE = 0.5;
    lv_target = AIBestTargetPoint(UnitGroupFilterAlliance(lp_nearByUnits, lp_owner, c_unitAllianceEnemy, 0), 1, lv_abilityDamage, lv_score, lv_abilityAoE, UnitGetPosition(lp_aIUnit), lv_abilityRange, c_unitAttributeNone);
    if ((lv_target != null)) {
        libNtve_gf_AICast(lp_aIUnit, OrderTargetingPoint(AbilityCommand("MutatorAmonRaynorSnipe", 0), lv_target));

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

        lv_score = 3;
        lv_abilityAoE = 5.0;
        lv_target = AIBestTargetPoint(UnitGroupFilterAlliance(lp_nearByUnits, lp_owner, c_unitAllianceEnemy, 0), 2, lv_abilityDamage, lv_score, lv_abilityAoE, UnitGetPosition(lp_aIUnit), lv_abilityRange, c_unitAttributeNone);
        if ((lv_target != null)) {
            libNtve_gf_AICast(lp_aIUnit, OrderTargetingPoint(AbilityCommand("MutatorAmonZagaraMassRoachDrop", 0), lv_target));

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

        lv_abilityAoE = StringToFixed(CatalogFieldValueGet(c_gameCatalogEffect, "MutatorAmonArtanisLightningDashSearch", "AreaArray[" + IntToString(0) + "].Radius", lp_owner));
        lv_score = 2;
        lv_target = AIBestTargetPoint(UnitGroupFilterAlliance(lp_nearByUnits, lp_owner, c_unitAllianceEnemy, 0), 3, lv_abilityDamage, lv_score, lv_abilityAoE, UnitGetPosition(lp_aIUnit), lv_abilityRange, c_unitAttributeNone);
        if ((lv_target != null)) {
            libNtve_gf_AICast(lp_aIUnit, OrderTargetingPoint(AbilityCommand("MutatorAmonArtanisLightningDash", 0), lv_target));

mods/warcoop/warclassicsystem.sc2modbase.sc2data/TriggerLibs/WarClassicTactical.galaxy:437

    }

    if ((UnitGetDamageTakenTime(lp_aIUnit) > 1.0) && (UnitGetPropertyFixed(lp_aIUnit, c_unitPropLifePercent, c_unitPropCurrent) > 50.0) && (UnitGroupCount(UnitGroupFilterAlliance(lp_nearByUnits, lp_owner, c_unitAllianceEnemy, 3), c_unitCountAlive) <= 2)) {
        return ;
    }