It seems intuitive to assume that but analyse it a bit...
Case 1:
(Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit)))
This converts to...
Code: Select all
return(GetUnitStateSwap(UNIT_STATE_LIFE,GetTriggerUnit())<=GetUnitStateSwap(UNIT_STATE_MAX_LIFE,GetTriggerUnit())*0.1)
Code: Select all
function GetUnitStateSwap takes unitstate whichState, unit whichUnit returns real
return GetUnitState(whichUnit, whichState)
endfunction
Conclusion:
Calls 4 functions in total (Excluding Trigger Unit).
Arithmatic involved: Multiplication by 0.1 or division by 10.
Total comparisons: 1
------------------------------------------------------------------------------------------------
Case 2:
(Percentage life of (Attacked unit)) Less than or equal to 10.00
This converts to
Code: Select all
return(GetUnitLifePercent(GetTriggerUnit())<= 10.)
Code: Select all
function GetUnitLifePercent takes unit whichUnit returns real
return GetUnitStatePercent(whichUnit, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)
endfunction
Code: Select all
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
Conclusion:
Calls 4 functions in total (Excluding Trigger Unit).
Arithmatic involved: Real division, multiplication by 100.
Total comparisons: 3
---------------------------------------------------------
So overall, using [ (Life of (Triggering unit)) Less than or equal to (0.10 x (Max life of (Triggering unit))) ] is more strait forward and and I would imagine faster.
Though ideally you use jass:
Code: Select all
return GetWidgetLife(GetTriggerUnit()) <= GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE)*0.1
Calls 2 functions in total (Excluding Trigger Unit).
Arithmatic involved: Multiplication by 0.1
Total comparisons: 1
Here is a perfect example of the efficiency of jass and why I encourage people to learn it.
On the side, [Triggering Unit] is a faster function call than [Attacking Unit] so it's best to use Triggering Unit when they are interchangeable.