GetUnitStatePercent
- Parameters
-
whichUnit unit
whichState unitstate
whichMaxState unitstate
- comment
-
Returns the current unit state in percent. Unit states representing current value and max value must be provided in that order.
In case of failure returns 0.
Example: a unit with 30/60 HP will return 50.0, meaning the unit is at 50% HP.
- patch
-
1.07
- Source
- Blizzard.j (suggest an edit or discuss on Github)
- return type
-
real
- Source code
-
function GetUnitStatePercent takes unit whichUnit, unitstate whichState, unitstate whichMaxState returns real local real value = GetUnitState(whichUnit, whichState) local real maxValue = GetUnitState(whichUnit, whichMaxState) // Return 0 for null units. if (whichUnit == null) or (maxValue == 0) then return 0.0 endif return value / maxValue * 100.0 endfunction