Results 1 to 5 of 5

Thread: Need some help :)

  1. #1
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Smile 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.

  2. #2
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    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?

  3. #3
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by J_Pizzle View Post
    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

  4. #4
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    Simba Code:
    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.

  5. #5
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Smile

    Quote Originally Posted by J_Pizzle View Post
    Simba Code:
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •