Results 1 to 14 of 14

Thread: Finding the farthest away symbol?

  1. #1
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Finding the farthest away symbol?

    There can be 2+ of the same symbols on the map and sometimes im located at either of them, but when i use FindSymbol 90% of the time it will click the symbol that i am standing on, so how can i make it that it would find the symbol that is most farthest away from me (middle of minimap).

    EDIT:
    SCAR Code:
    program UltramateFisherbot;
    {.Include SRL/SRL.Scar}
    {______________________________________________________________________________}
    (* Credits and thanks to: SRL Developers, Dr D. Dervish.
    {______________________________________________________________________________}
    (*             Presented and coded by Ultra from [url]www.villavu.com[/url]              *)

    (*           This script catches and drops different fish anywhere,           *)
    (*              and levels up your character's fishing level.                 *)
    {______________________________________________________________________________}
    (* -At the moment can catch shrimps, anchovies, trout, salmon, tuna, lobster, *)
    (*  and swordfish.                                                            *)
    (* -Includes great and human-like anti-ban performace.                        *)
    (* -Finds and solves all available random events effectively.                 *)
    (* -Keeps watch on experience increase.                                       *)
    (* -Effective human-like dropping.                                            *)
    (* -Supports multi-player.                                                    *)
    (* -Detailed and organized progress report.                                   *)
    {______________________________________________________________________________}
    (* Please note that some features of this script such as experience watching  *)
    (* may not work because of flaws in the SRL repostery. Thank you.             *)
    (* Always remember to help me out by posting progress reports, bugs, errors   *)
    (* or other problems that you might encounter.                                *)
    {______________________________________________________________________________}

    {___________________________________SETUP______________________________________}
    const
    CheckExpEvery = 50;   //Try to check your character's exp. every how many seconds?
    RegularHuman = True;  //Should the script perform regular human actions?
    MSpeed = 'normal';    //SEE BELOW.
                          //The speed at which the cursor will move.
                          //Increases performance but raises ban factor the faster
                          //it is. 'random during auto' is suited the best, it
                          //switches mouse speeds everynow and then.
                          //'lazy','normal','fast','very fast','random during auto'.
    FishForMin = 31;      //Minimum amount of seconds to fish for at a fishing spot.
    FishForMax = 51;      //Maximum amount of seconds to fish for at a fishing spot.
    SpotTol = 10;         //Increase this if the script if can't find fishing spot.
                     
    procedure DeclarePlayers;
    begin
     Disguise('Loading players...');//You don't need to touch this.
     HowManyPlayers := 1;//How many players are going to auto in total?
     CurrentPlayer := 0;//Which player goes first? Best to leave this as it is.
     NumberOfPlayers(HowManyPlayers);

      Players[0].Name :='';//Username.
      Players[0].Pass :='';//Password.
      Players[0].Nick :='';//Nickname. Example: If your username is 'Ultrapwns' put this to 'ltra'.
      Players[0].Active := True;//Is this player going to auto?
      Players[0].Integers[0] := 2;//See below.
     
                                  //////////////////////////////
                                  //Number\\Tool////////////////
                                  //1     \\Net               //
                                  //2     \\Fly fishing rod   //
                                  //3     \\Harpoon           //
                                  //4     \\Lobster cage      //
                                  //////////////////////////////

    end;
    {_______________________________END OF SETUP___________________________________}

    {______________________________________________________________________________}
    const
    Script_Version = '1.1';//You do not need to touch this.
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    var
    X, Y : Integer;                                          //Coord. Integers.
    Catches, ExpEarned : Integer;                            //Amount Integers.
    WasExp, CurrentExp, ExpMark, AN : Integer;               //Sub-amount integers.
    Shrimp_Alike, Fish_Alike, Tuna : Integer;                //DTMs.
    Lobster, Swordfish : Integer;                            //DTMs.
    DropTheInv : Boolean;                                    //Booleans.
    FishSymbols, FarthestSymbol : TPointArray;               //TPAs.

    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure LoadAllDTMs;
    begin
     Disguise('Loading dtms...');
      Shrimp_Alike := DTMFromString('78DA63DCC9C4C0309591011984D8E831FC07D' +
           '220D1FF40C0B803A86621AA1A06062630091365DC0FE4CF27A066' +
           '33903F9D809A8340FE24026A4E60BA1943CD06207F0E7E35002FC' +
           'F0F34');
      Fish_Alike := DTMFromString('78DA639CC2C4C0A0C7C8800C26F7F630FC07D' +
           '220D1FF40C0D80B546381AA868181094CC24419E701F9DA04D44C' +
           '06F23509A8E900F2CD08A85908E4CBE3570300252C0B5A');
      Tuna := DTMFromString('78DA63DCC9C4C0B08B9101194CEEED61F80FA' +
           '441A2FF8180712B50CD5154350C0C4C601226CAB80EC8DF4F40CD' +
           '51207F370135FB80FC8304D480DCBC91809A0340FE26FC6A00869' +
           'F110C');
      Lobster := DTMFromString('78DA637CCEC4C0B083910119249ACB32FC07D' +
           '220D1FF40C0F81AA8E628AA1A060626300913657C0AE4EF25A0E6' +
           '1690BF8D809A0F40FE6A026ADE1161D775207F177E3500509C113' +
           '8');
      Swordfish := DTMFromString('78DA63E4636660D8CCC8800C66E52C66F80FA' +
           '441A2FF81809101A8E628AA1A060626300913651406AA594F408D' +
           '0C50CD4E026AB8806A361250C30F54B30ABF1A001CF40B64');
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure FreeAllDTMs;
    begin
    Disguise('Freeing dtms...');
     FreeDTM(Shrimp_Alike);
     FreeDTM(Fish_Alike);
     FreeDTM(Tuna);
     FreeDTM(Lobster);
     FreeDTM(Swordfish);
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    function TheInvIsFull : Boolean;
    var
    This, That : Integer;
    begin
     case Players[CurrentPlayer].Integers[0] of
     1: This := Shrimp_Alike;
     2: This := Fish_Alike;
     3: begin
        This := Tuna;
        That := Swordfish;
        end;
     4: This := Lobster;
     end;
      if not Players[CurrentPlayer].Integers[0]=3 then
       Result := FindDTM(This, X, Y, InvBox(28).X1, InvBox(28).Y1, InvBox(28).X2, InvBox(28).Y2);
      if not Players[CurrentPlayer].Integers[0]=3 then
      Result := FindDTM(This, X, Y, InvBox(28).X1, InvBox(28).Y1, InvBox(28).X2, InvBox(28).Y2)or
      FindDTM(That, X, Y, InvBox(28).X1, InvBox(28).Y1, InvBox(28).X2, InvBox(28).Y2);
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure MoveCompassRandom;
    var
    W : Integer;
    begin
     case RandomRange(1, 6) of
     1: MakeCompass('e');
     2: MakeCompass('s');
     3: MakeCompass('w');
     4: MakeCompass('n');
     5: begin
        W := RandomRange(700, 2000);
        KeyDown(VK_Down);
        Wait(W);
        KeyUp(VK_Down);
        Wait(Random(300));
        KeyDown(VK_Up);
        Wait(W+Random(500));
        KeyUp(VK_Up);
        Wait(Random(150));
        end;
     end;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure PreHandleExp;
    begin
    Disguise('Pre handling experience...');
     WasExp := GetXP('fishing');
     MarkTime(ExpMark);
     AN := (CheckExpEvery*1000)+Random(CheckExpEvery*1000);
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure HandleExp;
    begin
    Disguise('Exp. Check in ' + IntToStr(Round((AN-TimeFromMark(ExpMark))/1000)) + ' secs.');
     if (TimeFromMark(ExpMark)>AN)and(LoggedIn)then
     begin
     CurrentExp := GetXP('fishing');
     Disguise('Current exp is ' + IntToStr(CurrentExp) + '...');
     ExpEarned := CurrentExp-WasExp;
     MarkTime(ExpMark);
     AN := (CheckExpEvery*1000)+Random(CheckExpEvery*1000);
    end;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure MousingWhileFishing;
    begin
     if RandomRange(1, 3)=2 then MMouse(MIX1, MIY1, MIX2, MIY2)
     else MMouse(MIX2, MIY2, MIX1, MIY1);
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure AntiBan_RegularHuman;
    var
    MT, RT : Integer;
    begin
    Disguise('Performing anti-ban...');
    MT := 0;
    RT := RandomRange(2000, 15000);
     case RandomRange(1, 100) of
     1..11: MoveCompassRandom;
     12..14: HoverSkill('random', False);
     15..19:
     begin
       MarkTime(MT);
       while TimeFromMark(MT)<RT do
       begin
        FindNormalRandoms;
        Wait(200);
       end;
       PickUpMouse;
     end;
     20..24: RandomMovement;
     25..26: BoredHuman;
     27..29: ExamineInv;
     30..34: LevelUp;
     35..70: Wait(RandomRange(100, 5000));
     71..100: Wait(1);
      end;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure DeclareMSpeed;
    var
    Error : Boolean;
    begin
    Disguise('Changing mouse speed...');
    Error := True;
     case MSpeed of
     'lazy': begin MouseSpeed := 10; Error:=False; end;
     'normal': begin MouseSpeed := 15; Error:=False; end;
     'fast': begin MouseSpeed := 20; Error:=False; end;
     'very fast': begin MouseSpeed := 25; Error:=False; end;
     'random during auto': begin Error:=False;
      case RandomRange(1, 9) of
      1..5: Wait(1);
      6: MouseSpeed := 10;
      7: MouseSpeed := 15;
      8: MouseSpeed := 20;
      9: MouseSpeed := 25;
      end;
     end;
     end;
     Disguise('Mouse speed set to ' + IntToStr(MouseSpeed) + '...');
       if Error then begin TerminateScript;
       WriteLn('MSpeed const was declared improperly!'); end;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    function NoActivePlayers : Boolean;
    var
    I : Integer;
    begin
      for I := 0 to (HowManyPlayers - 1) do
       if Players[I].Active then
         Exit;
      Result := True;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    function SpotNick : String;
    begin
    Disguise('Informing of information...');
     case Players[CurrentPlayer].Integers[0] of
     1: Result := 'et';
     2: Result := 'ure';
     3: Result := 'age';
     4: Result := 'age';
     end;
    if not Players[CurrentPlayer].Integers[0]=1 then
    if not Players[CurrentPlayer].Integers[0]=2 then
    if not Players[CurrentPlayer].Integers[0]=3 then
    if not Players[CurrentPlayer].Integers[0]=4 then
     begin
     FreeAllDTMs;
     TerminateScript;
     end;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    function FindFishingSpot : Boolean;
    var
     TPA : TPointArray;
     P : TPoint;
     I, FA : Integer;
     begin
     FA := 0;
     Disguise('Looking for fishing spots...');
     FindColorsSpiralTolerance(MSCX, MSCY, TPA, 11643558, MSX1, MSY1, MSX2, MSY2, SpotTol);
     if Length(TPA)=0 then Exit;
      for I := 0 to High(TPA) do
      begin
       P := TPA[i];
       {MMouse(P.X, P.Y, 0, 0);
       Wait(200+random(100));
       if IsUpText('rrow') then}

       MMouse(P.X, P.Y, 0, 0);
       Wait(200+random(100));
       if IsUpText(SpotNick) then
        begin
        Mouse(P.X, P.Y, 0, 0, False);
        Wait(150+Random(76));
        if Players[CurrentPlayer].Integers[0]=3 then
        begin
        Wait(500+random(500));
        if ChooseOption('arpoo') then
        begin
        FFlag(1);
        Result := True;
        Exit;
        end;
        end else
        begin
        Wait(500+random(500));
        if ChooseOption(SpotNick) then
        begin
        FFlag(1);
        Result := True;
        Exit;
        end;
        end;
        I := I + 5;
        end;
       end;
      Result := False;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure Fishing;
    var
    Start : Integer;
    Finish : Integer;
    begin
    DropTheInv := False;
    if Players[CurrentPlayer].Active=True then
     begin
     Disguise('Fishing...');
     Finish := RandomRange(FishForMin*1000, FishForMax*1000);
     MarkTime(Start);
     while(LoggedIn)and(TimeFromMark(Start)<Finish)do
      begin
      Wait(RandomRange(900, 2000));
      FindNormalRandoms;
      if TheInvIsFull or InvFull then begin DropTheInv:=True; Disguise('Inventory full...'); Exit; end;
      if RandomRange(1, 10)=9 then MoveCompassRandom;
      if RandomRange(1, 8)=7 then MousingWhileFishing;
      end;
     Disguise('Switching spots...');
    end;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    function DropByDTM(TheDTM, RandomnessX, RandomnessY : Integer) : Boolean;
    var
    DTMCoords : TPointArray;
    I : Integer;
    begin
    DTMCoords := ItemCoordinates('inv', 'dtm', TheDTM, []);
    if High(DTMCoords)<1 then begin Result:=False; Exit; end;
    I := 0;
     while(I<=High(DTMCoords))do
     begin
      Mouse(DTMCoords[I].X, DTMCoords[I].Y, RandomnessX, RandomnessY, False);
      Wait(100+random(100));
      if ChooseOption('rop') then Catches := Catches + 1;
      Wait(20+random(20));
      if RandomRange(1, 10)=9 then MMouse(DTMCoords[I].X, DTMCoords[I].Y, 20, 20);
      I := I + 1;
     end;
     Result := True;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure ClearInventory;
    var
    DropThis : Integer;
    DropThisAswell : Integer;
    begin
    if DropTheInv then
     begin
     Disguise('Dropping fish...');
     GameTab(tab_inv);
     
     case Players[CurrentPlayer].Integers[0] of
     1: DropThis := Shrimp_Alike;
     2: DropThis := Fish_Alike;
     3: begin
        DropThis := Tuna;
        DropThisAswell := Swordfish;
        end;
     4: DropThis := Lobster;
     end;
     
     DropByDTM(DropThis, 10, 10);
     if Players[CurrentPlayer].Integers[0]=3 then
     DropByDTM(DropThisAswell, 10, 10);
     DropTheInv := False;

     end;
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    procedure Report;
    begin
     ClearDebug;
     Disguise('Updating progress report...');
     WriteLn('><>><>><>UltramateFisherbot><>><>><>');
     WriteLn('><>><>><>><>Version: ' + Script_Version + '><>><>><>><>');
     WriteLn(PadR('> Ran: ' + TimeRunning, 35) + '<');
     WriteLn(PadR('> Current Player: ' + Players[CurrentPlayer].Name, 35) + '<');
     WriteLn(PadR('> Total Catches: ' + IntToStr(Catches), 35) + '<');
     WriteLn(PadR('> Total Catches P/H: ' + IntToStr(Round((Catches * 3600.0) / (GetTimeRunning / 1000.0))), 35) + '<');
     WriteLn(PadR('> Exp.: ' + IntToStr(ExpEarned), 35) + '<');
     WriteLn(PadR('> Exp. P/H: ' + IntToStr(Round((ExpEarned * 3600.0) / (GetTimeRunning / 1000.0))), 35) + '<');
     WriteLn('><>><>><>><>><>><>><>><>><>><>><>><>');
    end;
    {______________________________________________________________________________}

    {______________________________________________________________________________}
    begin
     SetUpSRL;
     LoadAllDTMs;
     Wait(5000);
     DeclarePlayers;
     DeclareMSpeed;
     if not LoggedIn then LogInPlayer;
      begin
      repeat
      PreHandleExp;
       repeat
       if Players[CurrentPlayer].Active=True then
       if not LoggedIn then LogInPlayer;
       HandleExp;
       ClearInventory;
     FindNormalRandoms;
     Report;
     if FindFishingSpot then Fishing else
     begin
      Wait(2000+random(1000));
      if FindFishingSpot then Fishing else
       begin
        Wait(2000+random(1000));
         if FindFishingSpot then Fishing else
          begin
          SymbolAccuracy := 0.4;
          MakeCompass('n');
          if FindSymbols(FishSymbols, 'fish') then
          begin
          SortTPAFrom(FishSymbols, Point(MMCX, MMCY));
          FarthestSymbol := FishSymbols[High(FishSymbols)];
          Mouse(FarthestSymbol.X, FarthestSymbol.Y, 3, 3, True);
          FFlag(0);
          Wait(RandomRange(1000, 2000));
          end else
          Players[CurrentPlayer].Active := False;
          if FindFishingSpot then Fishing else
          begin
          MakeCompass('s');
          if FindSymbols(FishSymbols, 'fish') then
          begin
          SortTPAFrom(FishSymbols, Point(MMCX, MMCY));
          FarthestSymbol := FishSymbols[High(FishSymbols)];
          Mouse(FarthestSymbol.X, FarthestSymbol.Y, 3, 3, True);
          FFlag(0);
          Wait(RandomRange(1000, 2000));
          end else
          Players[CurrentPlayer].Active := False;
          if FindFishingSpot then Fishing else Players[CurrentPlayer].Active := False;
          end;
          end;
         end;
        end;
      HandleExp;
      Report;
      ClearInventory;
      Report;
      DeclareMSpeed;
      if RegularHuman then AntiBan_RegularHuman;
      until(Players[CurrentPlayer].Active=False);
      NextPlayer(False);
     until(NoActivePlayers);
     FreeAllDTMs;
     end;
    end.
    {______________________________________________________________________________}
    I get an error:
    Line 463: [Error] (21523:49): Type mismatch in script C:\Documents and Settings\Ultra\Desktop\New scar\Scripts\Scripts\Public Scripts\UltramateFisherbot.scar
    Woot woot.

  2. #2
    Join Date
    Nov 2009
    Location
    Seattle, WA
    Posts
    589
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Ugh, RadialWalkTolerance xD?
    Don't Troll, Don't Fight, Just keep the Respect
    Status : Offline

    Feel free to re-make my scripts ;D
    Community Member

  3. #3
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    FindSymbols(TPA, 'Symbol');
    Mouse(TPA[High(TPA)].x, ...)'

  4. #4
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SortTPAFrom(MMcx, MMcy)
    InvertTPA(TPA)

    is what I did for my powerfisher (although I used a tpa for walking)

  5. #5
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    You guys are making this harder that it looks...
    Simple use FindSymbols to find all the occurrences of that particular Symbol on the map, then use the Distance() function to determine which one is the farthest away.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  6. #6
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    You guys are making this harder that it looks...
    Simple use FindSymbols to find all the occurrences of that particular Symbol on the map, then use the Distance() function to determine which one is the farthest away.
    SCAR Code:
    FindSymbols('', tpa);
    SortTPAFrom(tpa, Point(MMCX, MMCY));
    farthestSymbol := TPA[high(tpa)];

    Thats a lot easier than using a loop

    You wrote the loop for us!
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  7. #7
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    You guys are making this harder that it looks...
    Simple use FindSymbols to find all the occurrences of that particular Symbol on the map, then use the Distance() function to determine which one is the farthest away.
    Ah that's what i use to do a lot!

    fast and simple

  8. #8
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I used Nava2's example thingy but i got an error.
    Woot woot.

  9. #9
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Just use Distance();

    or High(array);

    or InvertTPA.

    Honestly, all three of those things can be done with the most basic of knowledge.

    Just look through the include.

  10. #10
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Just use Distance();

    or High(array);

    or InvertTPA.

    Honestly, all three of those things can be done with the most basic of knowledge.

    Just look through the include.
    How would i use distance? Sry im not too pro at tpas :\ and i came back to scripting a couple of months ago..
    Woot woot.

  11. #11
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    FindColorsSpiralTolerance(GetUniqueSymbolColor('fish'), etc, etc, etc);

    for i := high(tpa) downto 0 do
      if findsymbol(x, y, 'fish', tpa[i].x - 10, tpa[i].y - 10, tpa[i].x + 10, tpa[i].y + 10) then
      begin
        result := true;
        writeln('there it is!');
      end;

  12. #12
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Ultra View Post
    How would i use distance? Sry im not too pro at tpas :\ and i came back to scripting a couple of months ago..
    FindSymbols(tpa, '');
    SortTPAFrom(tpa, Point(MMCX, MMCY));
    Mouse(TPA[high(tpa)].x, ect...);

  13. #13
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Ultra View Post
    How would i use distance? Sry im not too pro at tpas :\ and i came back to scripting a couple of months ago..
    Well, the params for the function are:
    SCAR Code:
    Distance(x1, y1, x2, y2: Integer): Integer;
    So, "x1, y1" represents the first point, and "x2, y2" represents the second point.

    The function itself return's the Distance, measured in single pixels, between the two point's.

    Therefor, would be used like this:
    SCAR Code:
    if Distance(x1, y1, x2, y2) > TheDistanceYouWant then etc..

    Simple, right?

    Let me know if your still confused.

  14. #14
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Sorting by distance
    SCAR Code:
    Var
      MaxDistance, I, D, N: Integer;

    MaxDistance := -1;
    For I := 0 To High(TPA) Do
    Begin
      D := Distance(TPA[I].X, TPA[I].Y, MMCX, MMCY)
      If (D > MaxDistance) Then
      Begin
        MaxDistance :=  D;
        N := I;
      End;
    End;

    WriteLn('Furthest point in TPA is TPA['+IntToStr(N)+']');
    If this helps at all It's faster than SortTPA.

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
  •