GetUnitStatePercent

Parameters
whichUnit unit
whichState unitstate
whichMaxState unitstate
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