AMAI
AMAI copied to clipboard
ChooseAnEnemyTarget
if attacking_strategy == 1 or attacking_strategy == 3 then elseif attacking_strategy == 2 then
attacking_strategy Never no 1 2 3 ?
and on 24 player map , attacking_strategy will be equal to 5 , but AI have Alien , FFA maybe should be work on no Alien ?
function ChooseAnEnemyTarget takes nothing returns unit
local player target_enemy = null
local group g = CreateGroup()
local location enemy_base = null
//~~call DisplayTimedTextToPlayer(Player(0),0,0,15,"261")
if attacking_strategy == 1 or attacking_strategy == 3 then
set target_enemy = GetWeakestEnemy()
//call Trace("Chooing Weakest Enemy")
elseif attacking_strategy == 2 then
set target_enemy = GetStrongestEnemy()
//call Trace("Choosing Strongest Enemy")
elseif attacking_strategy == 5 then
set target_enemy = GetFFAEnemy()
//call Trace("Choosing FFA Enemy")
else
set target_enemy = GetWeakAndNearEnemy()
//call Trace("Choosing weakest closest Enemy")
endif
call GroupEnumUnitsOfPlayer(g, target_enemy, null)
set enemy_base = GetPlayerStartLocationLoc(target_enemy)
set g = SelectUnittype(g, UNIT_TYPE_TOWNHALL, true)
set g = SelectByLocation(g, enemy_base, 1000, false)
set g = SelectByAlive(g, true)
set returns_unit_target[3] = FirstOfGroup(g)
if returns_unit_target[3] == null then
set returns_unit_target[3] = GetBuilding(target_enemy)
endif
call DestroyGroup(g)
set g = null
call RemoveLocation(enemy_base)
set enemy_base = null
set target_enemy = null
return returns_unit_target[3]
endfunction
Attacking strategy is always 4 from globalSettings, except if it detects no teams then it uses 5.