Results 1 to 12 of 12

Thread: TPA Help

  1. #1
    Join Date
    Dec 2010
    Posts
    808
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TPA Help

    Which TPA is best?

    Simba Code:
    Function FindTrees(Var X, Y : Integer; W, H, X1, Y1, X2, Y2 : Integer): Boolean;
    Begin
    var
      x, y, i, h : Integer;
      TPA : TPointArray;
      ATPA : T2DPointArray;
    begin
      if not LoggedIn then Exit;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.17, 1.87);
      begin
        FindColorsSpiralTolerance(x, y, TPA, 2904128, MSX1, MSY1, MSX2, MSY2, 6);
        SetColorToleranceSpeed(1);
        ATPA := SplitTPAEx(TPA, 4, 4);
        if (Length(ATPA) = 0) then
          Exit;.
        SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
        h := High(ATPA);
        for i := 0 to h do
        begin;
          MiddleTPAEx(ATPA[i], x, y);
          MMouse(x, y, 3, 3);
          WaitUpText('illo', 250);
          end else
            Exit;
        end;
        Writeln('Found the Willow!');
      end;
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(1);
      Result := Players[CurrentPlayer].Loc := 'found trees';
    End;

    Simba Code:
    program FindObject;
    {.include SRL\SRL.scar}

    var
      x, y: Integer;

    function FindObject(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.17, 1.87);

      if not(FindColorsTolerance(arP, 2904128, MSX1, MSY1, MSX2, MSY2, 6)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 3.31) and (X <= 8.16) and (Y >= 4.21) and (Y <= 10.91) and (Z >= 1.91) and (Z <= 5.93) then
        begin
        for j := 0 to arL2 do
        begin
          if (arUC[i] = arC[j]) then
          begin
            SetLength(arAP, Length(arAP) + 1);
            arAP[High(arAP)] := arP[j];
          end;
        end;
        end;
      end;

      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);

      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('Take')) then
        begin;
          Result := True;
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;

      GetMousePos(fx, fy);
    end;

    begin
      SetupSRL;
      FindObject(x, y);
    end.

    Thankyoooo
    -Boom

  2. #2
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    The first one should do just fine in my opinion, thats what I use.
    There used to be something meaningful here.

  3. #3
    Join Date
    Dec 2010
    Posts
    808
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, thank you.

    -Boom

  4. #4
    Join Date
    Dec 2010
    Posts
    431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    One you made yourself, not using ACA.

  5. #5
    Join Date
    Dec 2010
    Posts
    808
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Train View Post
    One you made yourself, not using ACA.
    First one it is then

    Cheers
    -Boom

  6. #6
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by Dynamite View Post
    Simba Code:
    Function FindTrees(Var X, Y : Integer; W, H, X1, Y1, X2, Y2 : Integer): Boolean;
    Begin
    var
      x, y, i, h : Integer;
      TPA : TPointArray;
      ATPA : T2DPointArray;
    begin
      if not LoggedIn then Exit;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.17, 1.87);
      begin
        FindColorsSpiralTolerance(x, y, TPA, 2904128, MSX1, MSY1, MSX2, MSY2, 6);
        SetColorToleranceSpeed(1);
        ATPA := SplitTPAEx(TPA, 4, 4);
        if (Length(ATPA) = 0) then
          Exit;.
        SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
        h := High(ATPA);
        for i := 0 to h do
        begin;
          MiddleTPAEx(ATPA[i], x, y);
          MMouse(x, y, 3, 3);
          WaitUpText('illo', 250);
          end else
            Exit;
        end;
        Writeln('Found the Willow!');
      end;
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(1);
      Result := Players[CurrentPlayer].Loc := 'found trees';
    End;
    Just a few notes on efficient code:
    Since you have local variables x and y set, they don't need to be in the parameters. Also, the other params are unused, so essentially none of the params are necessary.

    Doing FindColorsSpiralTolerance then SortATPAFromFirstPoint is a waste of resources; I would just use FindColorsTolerance then SortATPAFromFirstPoint.

    if you want this to be used in another function to cut trees, i would do "Result := WaitUptext('illo', 250)", then following that, do an "if Result then Exit;", however i would simply do it all in one function. To do this, do something like... if the uptext is found, then right click (ClickMouse2 ), then Result := WaitOption('whatever option', 600).

    The way you use "Result := Players..." will ALWAYS return true, thus defeating the purpose of having it be a function. what you could do, is at the end, call "if Result then Players[CP].Loc := 'found trees', but what would be better (at least by what it looks like what you're trying to do from other threads) to do would be, in the mainloop do "if CutTrees then Players[CP].Loc := 'cut trees';"

  7. #7
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    Doing FindColorsSpiralTolerance then SortATPAFromFirstPoint is a waste of resources; I would just use FindColorsTolerance then SortATPAFromFirstPoint.
    Actually, it's not a waste of resources. The first point in the FindColorsSpiralTolerance, will be near the middle of the screen, while the other will be near the top left

  8. #8
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Actually, it's not a waste of resources. The first point in the FindColorsSpiralTolerance, will be near the middle of the screen, while the other will be near the top left
    But if you're sorting anyway, wouldn't it just be easier to use FindColorsTolerance? I thought that it was a little faster.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  9. #9
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Actually, it's not a waste of resources. The first point in the FindColorsSpiralTolerance, will be near the middle of the screen, while the other will be near the top left
    Quote Originally Posted by 3Garrett3 View Post
    But if you're sorting anyway, wouldn't it just be easier to use FindColorsTolerance? I thought that it was a little faster.
    This. You sort it twice, waste of resources.

  10. #10
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    But if you're sorting anyway, wouldn't it just be easier to use FindColorsTolerance? I thought that it was a little faster.
    Quote Originally Posted by TomTuff View Post
    This. You sort it twice, waste of resources.
    You guys are correct.. Sorry >_<
    I though SortATPAFromFirstPoint sorted the ATPA from the first point in the ATPA, as the function name suggests...
    I guess it should be renamed SortATPAFromPoint or something like that..

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

    Default

    The sorting may be a lot faster is they are sorted more or less.



    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)

  12. #12
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    The sorting may be a lot faster is they are sorted more or less.
    Good point.

    So use FindColorsSpiralTolerance(mmcx, mmcy

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
  •