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!
Create a unit group, pick all units inside the radius (matching conditions).
loop through units
if health of GetEnumUnit() > r
then
set u = GetEnumUnit()
set r = healt of GetEnumUnit()
else
loop
set First = FirstOfGroup(Hate)
if ((GetWidgetLife(First)) >= hp) then
set HpHigh = First
set hp = (GetWidgetLife(First))
call GroupRemoveUnit(Hate, First)
elseif ((GetWidgetLife(First)) < hp) then
call GroupRemoveUnit(Hate, First)
endif
exitwhen (First == null)
endloop
the code will work, but for some performance just make
JASS:
loop
set First = FirstOfGroup(Hate)
exitwhen First == null
if GetUnitState(First, UNIT_STATE_LIFE) >= hp then
set HpHigh = First
set hp = (GetWidgetLife(First))
endif
call GroupRemoveUnit(Hate, First)
endloop
this way you exit the loop directly if there is no unit and you also don't need to check if the unit has less hp than the one that was picked because ithat's the thing you don't need. and whether the if returns true or false: in both cases you remove the unit of the group, so you can just do that after the if.
you also may have recognized that i used GetUnitState(). i never tested GetWidgetLife(), so i used sth. i know.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.