View Full Version : Need some help :)
Hey guys. Could someone make or tell me how to create function something like this:
So it would sort Objects from so it would return the nearest.
but the thing is that i would like to have it an option to skip some tiles.
So like:
1. Scan all objects
2. Skip the given tile that User gives.
3. Return the nearest. ( Expect that it skipped even if it is nearest one)
~Home :)
Thanks.
JPHamlett
01-18-2011, 09:22 PM
Hmm, I assume this is reflection, so I could try and write a function for you. At the very least I could write the backbone to the function and let you finish it for you.
I need some more information though.
Are we searching by ID, or is it just any object?
Do you want a minimum distance, or just every object currently loaded in Runescape?
Hmm, I assume this is reflection, so I could try and write a function for you. At the very least I could write the backbone to the function and let you finish it for you.
I need some more information though.
Are we searching by ID, or is it just any object?
Do you want a minimum distance, or just every object currently loaded in Runescape?
Id's and there would be max range where to search :)
~Home
JPHamlett
01-18-2011, 09:38 PM
Function GetClosestObject(ID : Integer, ObjType : Integer): TRSObject;
var
ObjArra, SecObjArray : TRSObjectArray;
Obj : TRSObject;
PlayerPos : Tpoint;
I, Dist, LowestDist, ClosestObj: Integer
begin
ObjArray := GetAllObjects(ObjType);
For I := 0 to high(ObjArray) do
If (ObjArray[i].ID = ID) Then
SecObjArray[high(SecObjArray)] := ObjArray[i];
PlayerPos := GetMyPos;
LowestDist := 1000; // Set it high, just because haha.
For I := 0 to high(SecObjArray) Do
Begin
Dist := Distance(PlayerPos.x, PlayerPos.y, SecObjArray[i].Tile.x, SecObjArray[i].Tile.y);
If (Dist < LowestDist) then
Begin
LowestDist := Dist;
ClosestObj := i;
End;
End;
Result := SecObjArray[i];
End;
Here's the backbone to the function, keep in mind I wrote it in about 15 minutes. Also it has never been tested so it may fail miserably.
Function GetClosestObject(ID : Integer, ObjType : Integer): TRSObject;
var
ObjArra, SecObjArray : TRSObjectArray;
Obj : TRSObject;
PlayerPos : Tpoint;
I, Dist, LowestDist, ClosestObj: Integer
begin
ObjArray := GetAllObjects(ObjType);
For I := 0 to high(ObjArray) do
If (ObjArray[i].ID = ID) Then
SecObjArray[high(SecObjArray)] := ObjArray[i];
PlayerPos := GetMyPos;
LowestDist := 1000; // Set it high, just because haha.
For I := 0 to high(SecObjArray) Do
Begin
Dist := Distance(PlayerPos.x, PlayerPos.y, SecObjArray[i].Tile.x, SecObjArray[i].Tile.y);
If (Dist < LowestDist) then
Begin
LowestDist := Dist;
ClosestObj := i;
End;
End;
Result := SecObjArray[i];
End;
Here's the backbone to the function, keep in mind I wrote it in about 15 minutes. Also it has never been tested so it may fail miserably.
Thanks matey!
~Home
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.