SMUnlimited / AMAI

Advanced Melee Artificial Intelligence Mod For Warcraft 3
Other
206 stars 34 forks source link

exp creep unit group same problem occurs in UnitAliveInGroup #296

Open jzy-chitong56 opened 5 months ago

jzy-chitong56 commented 5 months ago

check UnitAliveInGroup code

when one unit is die , but the unit variable no set null then next loop , if the unit variable set null , perhaps it will block the harass job, while the units behind u may still survive, but they cannot Recycle Position

solution still requires a hash table storage unit -- I don't write

temp fix
function UnitAliveInGroup takes group rg returns boolean
  local unit u = null
  local group g = null
  set g = CopyGroup(rg, g)
  loop
    set u = FirstOfGroup(g)
    exitwhen u == null
    if not UnitAlive(u) then
      call GroupRemoveUnit(rg, u)
      call GroupRemoveUnit(unit_harassing, u)
    endif
    call GroupRemoveUnit(g, u)
  endloop
  call DestroyGroup(g)
  set g = null
  if FirstOfGroup(rg) == null then
    call DestroyGroup(rg)
    return false
  endif
  return true
endfunction

and when if town_threatened and (not state_attacking or hero_harass) then , should need RecycleHarrassPosition

jzy-chitong56 commented 4 months ago

windwalk_group have same bug when unit die , the variable set null , ResetWindWalkerGuardPosition maybe cannot remove the unit from windwalk_group when use windwalk_group , then will have bug