SMUnlimited / AMAI

Advanced Melee Artificial Intelligence Mod For Warcraft 3
Other
192 stars 31 forks source link

The retreat control seems to lack some judgment #305

Closed jzy-chitong56 closed 2 months ago

jzy-chitong56 commented 2 months ago

This avoids the distance of the main hero's position, but does not determine the distance between the main army's position and the starting point

Meanwhile, in hero micro operation missions, emergency TP is code controlled. Can emergency TP also be opened for SetGroupsFlee,Simultaneously close isfleeing

if not desperation_assault and ((CaptainRetreating() and isfleeing) or town_threatened) then     //((major_hero == null or not UnitAlive(major_hero)) and ver_heroes) or  then  //attack_running and
    call Trace("===Retreat control ended===")
    set break_attack = attack_running
    set retreat_controlled = false
    call SetGroupsFlee(true)
    if major_hero != null and UnitAlive(major_hero) and DistanceBetweenPoints_kd(home_location, GetUnitLoc(major_hero)) < 1250 then
      set isfleeing = false     // home so no need to be retreating. Also prevents bug in the captainretreating condition
    endif
    return
endif

new

  if not desperation_assault and ((CaptainRetreating() and isfleeing) or town_threatened or CaptainIsHome()) then     //((major_hero == null or not UnitAlive(major_hero)) and ver_heroes) or  then  //attack_running and
    call Trace("===Retreat control ended===")
    set break_attack = attack_running
    set retreat_controlled = false
    call SetGroupsFlee(true)
    if CaptainIsHome() or (major_hero != null and UnitAlive(major_hero) and DistanceBetweenPoints_kd(home_location, GetUnitLoc(major_hero)) < 1250) or (main_army >= 0 and army_loc[main_army] != null and DistanceBetweenPoints(home_location, army_loc[main_army]) < 1250) then
      set isfleeing = false     // home so no need to be retreating. Also prevents bug in the captainretreating condition
      call SetGroupsFlee(false)
    endif
    return
  endif