Results 1 to 2 of 2

Thread: TPA Finder Function

  1. #1
    Join Date
    Jan 2012
    Posts
    190
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default TPA Finder Function

    Im Trying To Find This






    Sorta Like This







    Using The Red As Points And The Green As The Distance Inbetween The Points
    Not DTM
    But A Similar Method With Tolerance



    It needs To Adjust Due to RS Always Adjusting Theirs
    Which Is Why I Say I Need To Use A TPA Finder Function

  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Try my dual-color searching function:
    Simba Code:
    Function FindObjEx_F(ColorA, ColorB, Tol, Bounds, sX, sY: Integer; UpText: TStringArray; Var X, Y: Integer; Debug: Boolean): Boolean;
      var
        B: TBox;
        TPA: TPointArray;
        L,i,CTS: Integer;
        ATPA,ATPA2: T2DPointArray;
      begin
        CTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        FindColorsSpiralTolerance(sX, sY, TPA, ColorA, MSX1, MSY1, MSX2, MSY2, Tol)
        ColorToleranceSpeed(CTS);
        if Length(TPA) < 1 then
          Exit;
        ATPA := TPAtoATPAEx(TPA, Bounds, Bounds);
        L := High(ATPA);
        SetArrayLength(ATPA2, L+1);
        for i := 0 to L do
        begin
          B := GetTPABounds(ATPA[i]);
          with B do
          begin
            FindColorsSpiralTolerance(sX, sY, ATPA2[i], ColorB, B.X1, B.Y1, B.X2, B.Y2, Tol)
            if Length(ATPA2[i]) > 0 then
            begin
              MiddleTPAEx(ATPA2[i], X, Y);
              HumanMMouse(X, Y, 5, 5);
              if WaitUpTextMulti(UpText, 800) then
              begin
                Result := True;
                if DeBug then
                  SMART_DrawBox(IntToBox(X-Bounds, Y-Bounds, X+Bounds, Y+Bounds));
                GetMousePos(X, Y);
                Exit;
              end;
            end;
          end;
        end;
      end;

    Searches for ColorA first, and for everywhere that it's found it splits those into boxes, the size of these boxes are defined by the Bounds value you input into the function. Then, it searches inside of each of those boxes for ColorB. If it finds a box in which both colors are found, it'll get the middle point (this will probably exactly where the two colors merge) and move the mouse to that position, at which it'll check for the UpText (any one of the uptexts in the array).

    For example:
    Simba Code:
    //Tolerance of 15 for both colors, box size of 20x20, start the search at the mainscreen center X & Y, color debuggin is false
      if FindObjEx_F(RockColor_Ore, RockColor_Base, 15, 20, MSCX, MSCY, ['Mine', 'Rocks'], X, Y, False) then
      begin
        Writeln('Found a rock at point('+IntToStr(X)+', '+IntToStr(X));
      end;

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


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
  •