# Tactical AI Filter Unit Filter

Grammar — Tactical AI Filter - include only unitFilter in filter
FlagsNative | Action

Sets the specified AI Filter to only include units that match the criteria of the specified target filter. Use this and the other “Tactical AI Filter” actions to set up an AI Filter, which can then be used in a “Tactical AI Filter - Run” function to filter a unit group.

# Arguments

  • aifilter — Filter
  • unitfilter — UnitFilter

Returns — void

native void AISetFilterBits(
	aifilter filter,
	unitfilter uf,
);

Category: AI Advanced / Filters / Actions

# Examples

# campaigns/liberty.sc2campaign

TactCampAI.galaxy

// L439
AISetFilterBits(filter, UnitFilterStr("-;Missile,Self,Stasis,Dead,Hidden,Invulnerable"))
// L559
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_ConsumeDNA, c_fieldFilters)))
// L611
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_GravitonPrison, c_fieldFilters)))
// L661
AISetFilterBits(filter, UnitFilterStr("Structure;Construction,Missile,Self,Stasis,Dead,Hidden,Invulnerable"))

# campaigns/liberty.sc2campaign

MapScript.galaxy

// L466
AISetFilterBits(lv_snipeFilter, libNtve_gf_ConvertTargetFilterStringToUnitFilter(CatalogFieldValueGet(c_gameCatalogAbil, "Snipe", "TargetFilters[" + IntToString(0) + "]", lp_owner)))
// L466
AISetFilterBits(lv_snipeFilter, libNtve_gf_ConvertTargetFilterStringToUnitFilter(CatalogFieldValueGet(c_gameCatalogAbil, "Snipe", "TargetFilters[" + IntToString(0) + "]", lp_owner)))

# campaigns/swarm.sc2campaign

TactCampAI.galaxy

// L439
AISetFilterBits(filter, UnitFilterStr("-;Missile,Self,Stasis,Dead,Hidden,Invulnerable"))
// L559
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_ConsumeDNA, c_fieldFilters)))
// L611
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_GravitonPrison, c_fieldFilters)))
// L661
AISetFilterBits(filter, UnitFilterStr("Structure;Construction,Missile,Self,Stasis,Dead,Hidden,Invulnerable"))

# mods/core.sc2mod

TactProtAI.galaxy

// L811
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_Feedback, c_fieldTargetFiltersAB)))
// L1083
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, chrono, c_fieldTargetFiltersAB)))
// L1565
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_Disintegration, c_fieldTargetFiltersAB)))

# mods/core.sc2mod

TactTerrAI.galaxy

// L49
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_250mmStrikeCannons, c_fieldTargetFiltersAB)))
// L215
AISetFilterBits(filterAI, UnitFilterStr(AIAbilityStr(player, c_AB_Snipe, c_fieldTargetFiltersAB)))
// L275
AISetFilterBits(filterAI, UnitFilterStr(AIAbilityStr(player, c_AB_SteadyTargeting, c_fieldTargetFiltersAB)))
// L460
AISetFilterBits(filter, UnitFilterStr("-;Missile,Self,Stasis,Dead,Hidden,Invulnerable"))
// L1232
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_SeekerMissile, c_fieldTargetFiltersAB)))

# mods/core.sc2mod

TactZergAI.galaxy

// L490
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_NeuralParasite, c_fieldTargetFiltersAB)))
// L596
AISetFilterBits(filter, UnitFilterStr(AIWeaponStr(player, c_WE_InfestedTerran, c_fieldTargetFilters)))
// L966
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_Contaminate, c_fieldTargetFiltersAB)))
// L1039
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_Corruption, c_fieldTargetFiltersAB)))
// L1067
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_LeechResources, c_fieldTargetFiltersAB)))

# mods/starcoop/starcoop.sc2mod

LibCOMU.galaxy

// L1985
AISetFilterBits(lv_enemyNearbyFilter, UnitFilter((1 << c_targetFilterVisible), 0, (1 << c_targetFilterAir) | (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterHallucination - 32)) | (1 << (c_targetFilterInvulnerable - 32))))
// L1991
AISetFilterBits(lv_enemyNearbyFilter, libNtve_gv_visibleFilter)
// L2040
AISetFilterBits(lv_canidatesFilter, UnitFilter((1 << c_targetFilterVisible), 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterHallucination - 32)) | (1 << (c_targetFilterInvulnerable - 32)) | (1 << (c_targetFilterSummoned - 32))))
// L2136
AISetFilterBits(lv_targetFilter2, UnitFilter((1 << c_targetFilterVisible), 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterHallucination - 32)) | (1 << (c_targetFilterInvulnerable - 32))))
// L2187
AISetFilterBits(lv_targetFilter2, UnitFilter((1 << c_targetFilterVisible), 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterHallucination - 32)) | (1 << (c_targetFilterInvulnerable - 32))))
// L2191
AISetFilterBits(lv_targetFilter2, UnitFilter((1 << c_targetFilterVisible), 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterHallucination - 32)) | (1 << (c_targetFilterInvulnerable - 32))))
// L2317
AISetFilterBits(lv_enemyNearbyFilter, UnitFilter((1 << c_targetFilterVisible), 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterHallucination - 32)) | (1 << (c_targetFilterInvulnerable - 32))))
// L4518
AISetFilterBits(lv_enemyNearbyFilter, UnitFilter((1 << c_targetFilterVisible), 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterUncommandable), (1 << (c_targetFilterStasis - 32)) | (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterHallucination - 32)) | (1 << (c_targetFilterInvulnerable - 32))))

# mods/starcoop/starcoop.sc2mod

TactCampAI.galaxy

// L795
AISetFilterBits(filter, UnitFilterStr("-;Missile,Self,Stasis,Dead,Hidden,Invulnerable"))
// L915
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_ConsumeDNA, c_fieldFilters)))
// L990
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_ConsumeDNA, c_fieldTargetFiltersAB)))
// L1052
AISetFilterBits(filter, UnitFilterStr("-;Heroic,Structure,Missile,Stasis,Item,Dead,Hidden,Invulnerable"))
// L1105
AISetFilterBits(filter, UnitFilterStr("-;Construction,Missile,Self,Stasis,Dead,Hidden,Invulnerable"))
// L1385
AISetFilterBits(filter, UnitFilterStr("Structure;Construction,Missile,Self,Stasis,Dead,Hidden,Invulnerable"))
// L1685
AISetFilterBits(filter, UnitFilterStr("Biological;Heroic,Structure,Missile,Stasis,Item,Dead,Hidden,Invulnerable"))

# mods/starcoop/starcoop.sc2mod

TactProtAI.galaxy

// L1044
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_ChronoBoost, c_fieldTargetFiltersAB)))
// L1559
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_Disintegration, c_fieldTargetFiltersAB)))

# mods/starcoop/starcoop.sc2mod

TactTerrAI.galaxy

// L54
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_250mmStrikeCannons, c_fieldTargetFiltersAB)))
// L217
AISetFilterBits(filterAI, UnitFilterStr("Biological,Visible;Heroic,Self,Structure,Destructible,Stasis,Dead,Hidden,Invulnerable"))
// L267
AISetFilterBits(filterAI, UnitFilterStr(AIAbilityStr(player, c_AB_SteadyTargeting, c_fieldTargetFiltersAB)))
// L440
AISetFilterBits(filter, UnitFilterStr("-;Heroic,Missile,Stasis,Item,Dead,Hidden,Invulnerable"))
// L1204
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_SeekerMissile, c_fieldTargetFiltersAB)))

# mods/starcoop/starcoop.sc2mod

TactZergAI.galaxy

// L701
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_NeuralParasite, c_fieldTargetFiltersAB)))
// L807
AISetFilterBits(filter, UnitFilterStr(AIWeaponStr(player, c_WE_InfestedTerran, c_fieldTargetFilters)))
// L1175
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_Contaminate, c_fieldTargetFiltersAB)))
// L1248
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_Corruption, c_fieldTargetFiltersAB)))
// L1276
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_LeechResources, c_fieldTargetFiltersAB)))

# mods/warcoop/warclassicsystem.sc2mod

TacticalAIWar3.galaxy

// L141
AISetFilterBits(filter, UnitFilterStr(AIAbilityStr(player, c_AB_LightningShield, c_fieldTargetFiltersAB)))
// L155
AISetFilterBits(filter, uf)
// L444
AISetFilterBits(filter, UnitFilterStr("Summoned;Player,Ally,Neutral"))

# mods/warcoop/warclassicsystem.sc2mod

WarClassicTactical.galaxy

// L353
AISetFilterBits(lv_enemyNearbyFilter, libNtve_gf_ConvertTargetFilterStringToUnitFilter(CatalogFieldValueGet(c_gameCatalogEffect, (((lp_abil) + "@Search")), "SearchFilters", lp_owner)))
// L554
AISetFilterBits(lv_rangeUnitFilter, libGAwT_gf_AIEffectAbilTargetUnitFilter(lp_owner, lp_aIUnit, lp_abil, lv_level))