# Get Best Attack Target Point

Grammar — Get the best target point to attack for player player, optionally considering only enemies enemies, for a wave leaving gather point gatherPoint|GatherPoint, using search flags flags
FlagsNative | Function

Get the best target point to attack for a player, optionally considering only the specified enemies.

# Arguments

  • int — Player
  • playergroup — Enemies
  • point — Gather Point
  • int<preset::AIBestTargetFlags> — Flags

Returns — point

native point AIGetBestTarget(
	int player,
	playergroup enemies,
	point gatherPoint,
	int flags,
);

Category: AI Advanced / Waves / Functions

# Examples

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/Orc/Orc.galaxy:457

    //Too many army, go suicide 
    if(c_food_used[player]>90){
        p=AIGetBestTarget (player, enemies, UnitGroupCenterOfGroup(ug), c_btDefaultPrefersPath);
        AIAttackWaveSetTargetPoint(player,p);
        AIAttackWaveSetGatherPoint(player, p);

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/Orc/Orc.galaxy:477

        if(PlayerGroupCount(weakEnemies)>1){
            //Attack weak enemies
            p=AIGetBestTarget (player, weakEnemies, UnitGroupCenterOfGroup(ug), c_btDefaultPrefersPath);
            AIAttackWaveSetTargetPoint(player,p);
            AIAttackWaveSetGatherPoint(player, p);

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/Orc/Orc.galaxy:505

    unitgroup ug=UnitGroup(null, player, RegionEntireMap(), UnitFilter(0, 0, (1 << c_targetFilterAlly) | (1 << c_targetFilterNeutral) | (1 << c_targetFilterEnemy) | (1 << c_targetFilterWorker) | (1 << c_targetFilterMissile) | (1 << c_targetFilterPreventDefeat), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0); 
    playergroup enemies=PlayerGroupAlliance(c_playerGroupEnemy, player);
    point po=AIGetBestTarget (player, enemies, UnitGroupCenterOfGroup(ug), c_btDefaultPrefersPath);
     if(c_hero1_done[player]+c_hero2_done[player]==0){return;}
    if(c_food_used[player]>90){