Calculation formula for Mob Distance in Delphi

03/28/2013 02:33 Afro-Head#1
I got xyz cords like 1234.3245545454 and wonder how to calculate the distance to a Mob from that.

So how do you calculate the ingame distance to mob's in delphi ?


Distance between two points Tutorial: [Only registered and activated users can see links. Click Here To Register...]
03/28/2013 11:04 Sᴡoosh#2
Code:
{$REGION 'Distance stuff'}
function TGrindThread.Distance(P1, P2, Q1, Q2: single): single;
begin
  result := sqrt(Power(P1 - Q1, 2) + Power(P2 - Q2, 2))
end;

function TGrindThread.distanceline(l1, l2: Single): Single;
begin
  result := Abs(l1 - l2);
end;
{$ENDREGION}
Cheers
03/29/2013 00:27 Afro-Head#3
Thanks Swoosh,
i made it the same like you :-)

Quote:
Distance:=Round(Sqrt( power((CHAR_X-MOB_X),2)+ power((CHAR_Y-MOB_Y),2 ) ));
First without power, then see Error on - Numbers.