Cheat engine is your friend.
This code will calculate the distance of an enemy or more, relative to your player coordinates and store it into a variable.
It is useful for teleportation methods, for example you want to teleport to your nearest ally or on top of an enemy.
Maybe there's an object on the ground and you want to make a teleport skill so the player can collect objects tha are in a certain range.
There's more that you can do with this!
Code:
fld [PlayerX]
fsub [OtherEntityX]
fmul ST(0)
fstp [distanceX] //dx^2
fld [PlayerY]
fsub [OtherEntityY]
fmul ST(0)
fstp [distanceY] //dy^2
fld [PlayerZ]
fsub [OtherEntityZ]
fmul ST(0)
fstp [distanceZ] //dz^2
fld [distanceX]
fadd [distanceY]
fadd [distanceZ]
fsqrt
fstp [distanceTotal]// sqrt(dx^2 + dz^2 + dy^2) = distance
[distanceTotal] Contains the distance of that player/entity.