• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Picking the unit the most closely matching a condition?

Status
Not open for further replies.
Level 4
Joined
Feb 2, 2009
Messages
71
JASS:
function GetBestUnit takes group g returns unit
     local unit bestUnit = FirstOfGroup(g) //Doing this to have a unit to compare with.
     local unit u = null
     loop
          set u = FirstOfGroup(g)
          exitwhen u == null
          if SomeValueOf(u) > SomeValueOf(bestUnit) then
               set u = bestUnit
          endif
          call GroupRemoveUnit(g, u)
     endloop
     
     set u = null
     return bestUnit
endfunction
 
Status
Not open for further replies.
Top