# 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
Flags —Native
|Function
Get the best target point to attack for a player, optionally considering only the specified enemies.
# Arguments
int
— Playerplayergroup
— Enemiespoint
— Gather Pointint
<preset::AIBestTargetFlags> — Flags
Returns — point
native point AIGetBestTarget(
int player,
playergroup enemies,
point gatherPoint,
int flags,
);
# Related
Category: AI Advanced / Waves / Functions
- Create Wave Info —
waveinfo
— AIWaveInfoCreate - Create Wave Info From Wave —
waveinfo
— AIWaveInfo - Create Wave —
wave
— AIWaveCreate - Wave Unit Count —
int
— AIWaveUnitCount - Wave State —
int
— AIWaveState - Wave Target Unit —
wavetarget
— AIWaveTargetUnit - Wave Target UnitGroup —
wavetarget
— AIWaveTargetUnitGroup - Wave Target Unit Point —
wavetarget
— AIWaveTargetUnitPoint - Wave Target Point —
wavetarget
— AIWaveTargetPoint - Wave Target Player —
wavetarget
— AIWaveTargetPlayer - Wave Target Melee —
wavetarget
— AIWaveTargetMelee - Wave Target Melee Harass —
wavetarget
— AIWaveTargetMeleeHarass - Wave Target Merge —
wavetarget
— AIWaveTargetMerge - Wave Target Patrol —
wavetarget
— AIWaveTargetPatrol - Wave Target Escort —
wavetarget
— AIWaveTargetEscort - Wave Target Escort No Leash —
wavetarget
— AIWaveTargetEscortNL - Wave Target Gather Offense —
wavetarget
— AIWaveTargetGatherO - Wave Target Gather Defense —
wavetarget
— AIWaveTargetGatherD - Wave Target Harass Retreat —
wavetarget
— AIWaveHarassRetreat - Wave Target Region —
wavetarget
— AIWaveTargetRegion - Wave Get Target —
wavetarget
— AIWaveGetTarget - Is Wave In Combat —
bool
— AIWaveIsInCombat - Wave Time In Combat —
int
— AIWaveGetTimeInCombat - Wave Time Since Combat —
int
— AIWaveGetTimeSinceCombat - Wave Time Since Ordered —
int
— AIWaveGetTimeSinceOrdered - Wave Eval —
int
— AIWaveEval - Wave Eval Ratio —
int
— AIWaveEvalRatio - Eval Ratio —
int
— AIEvalRatio - Wave Get —
wave
— AIWaveGet - Wave Type —
int
— AIWaveType - Get Best Attack Target Point —
point
— AIGetBestTarget - Wave To String —
string
— AIWaveToString - Wave To Text —
text
— AIWaveToText
# Examples
mods/warcoop/warmeleeai.sc2mod — base.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.sc2mod — base.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.sc2mod — base.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){