function GetDistance takes unit u1, unit u2 returns real
// This is a simple function which returns distance between 2 units
// You can even call it from GUI if you copy it into your map's custom script
local real x1 = GetUnitX(u1)
local real y1 = GetUnitY(u1)
local real x2 = GetUnitX(u2)
local real y2 = GetUnitY(u2)
local real r = SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
return r
endfunction
function Call takes nothing returns nothing
// Here is the example of JASS call
// It can be a trigger action
local unit u1 = <SomeUnit1>
local unit u2 = <SomeUnit2>
local real distance
// ...
set distance = GetDistance(u1, u2)
// Function below writes distance to the screen
call BJDebugMsg(R2S(distance))
// Removing Pointer Leaks
set u1 = null
set u2 = null
endfunction