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.
- 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
- Source
- Blizzard.j
- wc3modding.com
- GetUnitStatePercent