Results 1 to 5 of 5

Thread: TPA object finding

  1. #1
    Join Date
    May 2012
    Posts
    102
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TPA object finding

    So today I set myself the task of learning about TPA's and what you can do with them and after hours of reading and tweaking (Massive thanks to Naum for his A low down on WizzyPlugin and TPA's) I have produced a function!
    For all who are interested this locates lobster fishing spots on the dock on karamja.
    Simba Code:
    program TPATest;
    {$i SRL/SRL.simba}
    {$i SRL/srl/misc/debug.simba}

    var
      x, y: Integer;

    function FindSpot: Boolean;
    var
      TPA: TPointArray;
      ATPA: Array of TPointArray;
      tmpCTS, i: Integer;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.30, 0.66);

      if FindColorsSpiralTolerance(MSCX, MSCY, TPA, 11379612, MSX1, MSY1, MSX2, MSY2, 7) then
        begin
          SortTPAFrom(TPA, Point(MSCX, MSCY));
          ATPA := TPAToATPAEx(TPA, 25, 25);
          //ATPA := SplitTPAEx(TPA, 15, 15);
          SortATPASize(ATPA, True);

          For i := 0 To High(ATPA) Do
            begin
              MiddleTPAEx(ATPA[i], x, y);
              MMouse(x, y, 5, 5);
              if WaitUpTextMulti(['Cage', 'ge Fi'], 250) then
                begin
                  Result := True;
                  GetMousePos(x, y);
                  Break;
                end;
            end;
        end;

      //DebugATPA(ATPA,'');
      //DebugATPABounds(ATPA);
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    end;

    begin
      SetUpSRL;
      ActivateClient;
      if FindSpot then
        writeln('spot found at: ' + IntToStr(x) + '.' + IntToStr(y));
    end.
    My problem is that im not entirely sure if i've missed something or put something in the wrong place or if it is working as intended as it doesnt always sorts by closest point properly but other than that it seems to work!
    Other suggestions how this can be improved are welcome!

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

    Default

    Simba Code:
    SortATPASize(ATPA, True);

    to

    Simba Code:
    SortATPAFromMidPoint(aTPA, Point(MSCX, MSCY));



    ~Home

  3. #3
    Join Date
    May 2012
    Posts
    102
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Home View Post
    Simba Code:
    SortATPASize(ATPA, True);

    to

    Simba Code:
    SortATPAFromMidPoint(aTPA, Point(MSCX, MSCY));



    ~Home

    Much better thanks, but does that make the
    Simba Code:
    SortTPAFrom(TPA, Point(MSCX, MSCY));
    completely pointless or is it still neccessary?

  4. #4
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Wreck View Post
    but does that make the
    Simba Code:
    SortTPAFrom(TPA, Point(MSCX, MSCY));
    completely pointless or is it still neccessary?
    It was useless from the start :P

    Simba Code:
    if FindColorsSpiralTolerance(MSCX, MSCY, TPA, 11379612, MSX1, MSY1, MSX2, MSY2, 7) then
    begin
      SortTPAFrom(TPA, Point(MSCX, MSCY));

    FindColorsSpiralTolerance does exactly what SortTPAFrom does; you're sorting the TPA from (MSCX, MSCY) twice.

  5. #5
    Join Date
    May 2012
    Posts
    102
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Runaway View Post
    It was useless from the start :P

    Simba Code:
    if FindColorsSpiralTolerance(MSCX, MSCY, TPA, 11379612, MSX1, MSY1, MSX2, MSY2, 7) then
    begin
      SortTPAFrom(TPA, Point(MSCX, MSCY));

    FindColorsSpiralTolerance does exactly what SortTPAFrom does; you're sorting the TPA from (MSCX, MSCY) twice.
    I used FindColorsSpiralTolerance instead of FindColorsTolerance for that exact reason and it never dawned on me that they did the same thing ! Thanks.

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
  •