I never actually knew that it was there and stumbled across it while digging in the common.j for a way to check the race of a unit.
(whatever const means in this context)
Now, judging by it beeing a native funcion and not beeing affected by the incredible overhead that jass (or for that matter, any interpreted scripting language) comes with, its probably faster than manually calculating the distance and comparing it.
On the other hand, when comparing manually, you don't need to use the sqrt if you compare with a constant value, and sqrt's are certainly one of the slower operations.
As for this, does anybody know how those functions are doing and if it's worth using them for constant distances?
JASS:
constant native IsUnitInRange takes unit whichUnit, unit otherUnit, real distance returns boolean
constant native IsUnitInRangeXY takes unit whichUnit, real x, real y, real distance returns boolean
constant native IsUnitInRangeLoc takes unit whichUnit, location whichLocation, real distance returns boolean
(whatever const means in this context)
Now, judging by it beeing a native funcion and not beeing affected by the incredible overhead that jass (or for that matter, any interpreted scripting language) comes with, its probably faster than manually calculating the distance and comparing it.
On the other hand, when comparing manually, you don't need to use the sqrt if you compare with a constant value, and sqrt's are certainly one of the slower operations.
As for this, does anybody know how those functions are doing and if it's worth using them for constant distances?