ScriptUO
Scripting Resources & Utilities => Stealth Client => Topic started by: playforfun on August 13, 2016, 07:26:31 PM
-
I wasn't sure if there was an API to compare two objects distances from one another, I know you can search an objects range from your self with FindDistance; ...
Either way I came up with my own version so I would like to share it with you guys if you ever find you need to compare the distance between two objects.
Example:
Check if Chest2 is within 2 tiles of Chest1...
Program Example;
Type
TileCord = record
x, y : Integer
end;
Var
TileRange : Array of TileCord;
Function SeekRange(ObjOne, ObjTwo : Cardinal; Range : Integer) : Boolean;
Var
x, y, i : Integer;
begin
Result:= False;
SetLength(TileRange, 0);
for x := (-1 * Range) to Range do
for y := (-1 * Range) to Range do
begin
SetLength(TileRange, Length(TileRange) + 1);
TileRange[High(TileRange)].x := (GetX(ObjOne) + x);
TileRange[High(TileRange)].y := (GetY(ObjOne) + y);
end;
for i := Low(TileRange) to High(TileRange) do
if TileRange[i].x = (GetX(ObjTwo)) then
for i := Low(TileRange) to High(TileRange) do
if TileRange[i].y = (GetY(ObjTwo)) then
Result := True;
end;
//Main Body
begin
if SeekRange(Chest1, Chest2, 2) = True then
// what you want it to do =)
end.