Results 1 to 10 of 10

Thread: Trouble scrolling through atpa

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Trouble scrolling through atpa

    So I am using this function to gather colors on the minimap and test their distance between each other, and if they are a certain distance between each other then it will click there but it does not seem to be working:

    Simba Code:
    {$I SRL/SRL.Simba}
    {$I SRL/SRL/Misc/Debug.simba}
    Procedure WalkPoint;
    Var
      Point_1, Point_2, Spot_Click: TPointArray;
      Point_1_ATPA, Point_2_ATPA, Spot_ATPA: T2DPointArray;
      I, J, K, Dist_Get_1, Dist_Get_2, Moves:Integer;
    Begin
      FindColorsTolerance(Point_1, 2442088, 547, 33, 710, 193, 25);
      FindColorsTolerance(Point_2, 404792, 547, 33, 710, 193, 25);
      FindColorsTolerance(Spot_Click, 5658204, 547, 33, 710, 193, 25);
      SplitTPAWrap(Point_1, 7, Point_1_ATPA);
      SplitTPAWrap(Point_2, 7, Point_2_ATPA);
      SplitTPAWrap(Spot_Click, 7, Spot_ATPA);
      DebugATPABounds(Point_1_ATPA);
      DebugATPABounds(Point_2_ATPA);
      DebugATPABounds(Spot_ATPA);
      SetLength(Point_1, 15);
      SetLength(Point_2, 15);
      for I:= 0 To High(Point_1) Do
        for J:= 0 To High(Point_2) Do
         //for K:= 0 To High(Spot_Click) Do
          begin
           Moves := 0;
            Repeat
              if (Length(Spot_Click) = 0) or
              (Length(Point_1) = 0) or
              (Length(Point_2) = 0)then
             Begin
                Writeln('No colors were found');
                Exit;
             End;
              If Moves >= 15 Then
              Begin
                Writeln('Moves > 15 stopping')
                Exit;
              End;
              Moves := Moves +1
              Dist_Get_1 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_1[0].x,Point_1[0].y);
              Dist_Get_2 := Distance(Spot_Click[0].x, Spot_Click[0].y,Point_2[0].x,Point_2[0].y);
              If (Dist_Get_1 <= 39) and (Dist_Get_2 <= 39)  and
              (Dist_Get_1 >= 2) and (Dist_Get_2 >= 2) Then
             Begin
                Writeln('colors were found');
                mmouse(Spot_Click[0].x,Spot_Click[0].y,1,1)
                ClickMouse2(Mouse_Left)
               // While (SS_FFlag) Do
                Wait(50)
                Exit;
             End;
          Until Moves > 15
        End;
    End;
    begin
      MouseSpeed := 15;
      WalkPoint;
    end.

    Anybody know what I'm doing wrong?

  2. #2
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    I'm trying to walk to the spot inbetween the archery story and armour shop as a test and the Debug is splitting the whole minimap for some reason


  3. #3
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    My revision from what I understand via your short description + code.
    (Note: be sure to read the comments in the code to understand what I'm trying to do)

    Simba Code:
    {$include_once srl/srl.simba}

    function WalkToPointOnMM(): Boolean;
    var
      i, j, k, D1, D2: Integer;
      GatherColors: TIntegerArray;
      Gather: array [0..2] of TPointArray; // 0 = Pt1, 1 = Pt2, 2 = Spot Click
      GatherATPA: array [0..2] of T2DPointArray;
    begin
      Result := False;
      GatherColors := [228, 15331301, 6912900]; // Colors

      // Find color, filter color, split color
      for i := 0 to high(Gather) do
      begin
        FindColorsTolerance(Gather[i], GatherColors[i], MMX1, MMY1, MMX2, MMY2, 25);
        FilterPointsPie(Gather[i], 0, 360, 0, 72, MMCx, MMCy);
        SplitTPAWrap(Gather[i], 15, GatherATPA[i]);
      end;

      // So we have 2 ATPA's...
      for i := 0 to high(GatherATPA) do
        // Now we have 'x' TPA's in each ATPA, from the original split TPA's...
        for j := 0 to high(GatherATPA[i]) do
          // Then in each TPA we test distances now between points...
          for k := 0 to high(GatherATPA[i][j]) do
          begin
            (* Note the Index values, 2, 1, and 0.
             * These reference the order of the colors specified in GatherColors.
             * Thus making it relevant to use the indexed values as shown below,
             *  because it matches the pattern/description you wish to search for.
             *)

            D1 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
                           GatherATPA[0][j][k].x, GatherATPA[0][j][k].y);
            D2 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
                           GatherATPA[1][j][k].y, GatherATPA[1][j][k].y);
            if ((D1 <= 25) and (D1 >= 0)) and ((D2 <= 20) and (D2 >= 0)) then
            begin
              Result := True;
              MMouse(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y, 1, 1);
              ClickMouse2(Mouse_Right);
              Exit;
            end;
          end;
    end;

    begin
      SetupSRL;
      WalkToPointOnMM();
    end.

  4. #4
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    My revision from what I understand via your short description + code.
    (Note: be sure to read the comments in the code to understand what I'm trying to do)

    Simba Code:
    {$include_once srl/srl.simba}

    function WalkToPointOnMM(): Boolean;
    var
      i, j, k, D1, D2: Integer;
      GatherColors: TIntegerArray;
      Gather: array [0..2] of TPointArray; // 0 = Pt1, 1 = Pt2, 2 = Spot Click
      GatherATPA: array [0..2] of T2DPointArray;
    begin
      Result := False;
      GatherColors := [228, 15331301, 6912900]; // Colors

      // Find color, filter color, split color
      for i := 0 to high(Gather) do
      begin
        FindColorsTolerance(Gather[i], GatherColors[i], MMX1, MMY1, MMX2, MMY2, 25);
        FilterPointsPie(Gather[i], 0, 360, 0, 72, MMCx, MMCy);
        SplitTPAWrap(Gather[i], 15, GatherATPA[i]);
      end;

      // So we have 2 ATPA's...
      for i := 0 to high(GatherATPA) do
        // Now we have 'x' TPA's in each ATPA, from the original split TPA's...
        for j := 0 to high(GatherATPA[i]) do
          // Then in each TPA we test distances now between points...
          for k := 0 to high(GatherATPA[i][j]) do
          begin
            (* Note the Index values, 2, 1, and 0.
             * These reference the order of the colors specified in GatherColors.
             * Thus making it relevant to use the indexed values as shown below,
             *  because it matches the pattern/description you wish to search for.
             *)

            D1 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
                           GatherATPA[0][j][k].x, GatherATPA[0][j][k].y);
            D2 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
                           GatherATPA[1][j][k].y, GatherATPA[1][j][k].y);
            if ((D1 <= 25) and (D1 >= 0)) and ((D2 <= 20) and (D2 >= 0)) then
            begin
              Result := True;
              MMouse(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y, 1, 1);
              ClickMouse2(Mouse_Right);
              Exit;
            end;
          end;
    end;

    begin
      SetupSRL;
      WalkToPointOnMM();
    end.
    I'm getting a range check error at line 36, I don't know why I added failsafe incase it can't find color:

    Simba Code:
    if (Length(GatherATPA) = 0) Then
          Exit;

    Simba Code:
    {$include srl/srl.simba}

    function WalkToPointOnMM(): Boolean;
    var
      i, j, k, D1, D2: Integer;
      GatherColors: TIntegerArray;
      Gather: array [0..2] of TPointArray; // 0 = Pt1, 1 = Pt2, 2 = Spot Click
      GatherATPA: array [0..2] of T2DPointArray;
    begin
      Result := False;
      GatherColors := [11363426, 5658204, 5658204]; // Colors

      // Find color, filter color, split color
      for i := 0 to high(Gather) do
      begin
        FindColorsTolerance(Gather[i], GatherColors[i], 547, 33, 710, 193, 25);
        FilterPointsPie(Gather[i], 0, 360, 0, 72, 635, 113);
        SplitTPAWrap(Gather[i], 15, GatherATPA[i]);
      end;

      // So we have 2 ATPA's...
      for i := 0 to high(GatherATPA) do
        // Now we have 'x' TPA's in each ATPA, from the original split TPA's...
        for j := 0 to high(GatherATPA[i]) do
          // Then in each TPA we test distances now between points...
          for k := 0 to high(GatherATPA[i][j]) do
          begin
          if (Length(GatherATPA) = 0) Then
          Exit;
            (* Not
            e the Index values, 2, 1, and 0.
             * These reference the order of the colors specified in GatherColors.
             * Thus making it relevant to use the indexed values as shown below,
             *  because it matches the pattern/description you wish to search for.
             *)

            D1 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
                           GatherATPA[0][j][k].x, GatherATPA[0][j][k].y);
            D2 := Distance(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y,
                           GatherATPA[1][j][k].y, GatherATPA[1][j][k].y);
            if ((D1 <= 25) and (D1 >= 0)) and ((D2 <= 20) and (D2 >= 0)) then
            begin
              Result := True;
              MMouse(GatherATPA[2][j][k].x, GatherATPA[2][j][k].y, 1, 1);
              ClickMouse2(Mouse_Right);
              Exit;
            end;
          end;
    end;

    begin
      SetupSRL;
      WalkToPointOnMM();
    end.

    EDIT:

    I also tried to change the 75 at thhis line assuming it was looking for he colors 75 pixels from the middle of the minimap:

    Simba Code:
    FilterPointsPie(Gather[i], 0, 360, 0, 75, 635, 113);

    But still the same result

  5. #5
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Yes, I suppose adding a failsafe that checks for length of Gather[i] after the filterpoints pie is greater than 0, then proceed, else, exit.

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Yes, I suppose adding a failsafe that checks for length of Gather[i] after the filterpoints pie is greater than 0, then proceed, else, exit.
    I don't think it's working I used common colors and high max distance

    Simba Code:
    if ((D1 <= 30) and (D1 >= 0)) and ((D2 <= 50) and (D2 >= 0)) then

    And all of the same color

  7. #7
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Did you try also lowering your Split distance from 15 to something lower?

  8. #8
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Did you try also lowering your Split distance from 15 to something lower?
    I went all the way down to 5 still no result

  9. #9
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by RJJ95 View Post
    I'm trying to walk to the spot inbetween the archery story and armour shop as a test and the Debug is splitting the whole minimap for some reason

    Just saw this post;
    If you're trying to walk between those two buildings, would not RadialWalk suffice to walk the path that is also indeed inbetween both?

  10. #10
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Just saw this post;
    If you're trying to walk between those two buildings, would not RadialWalk suffice to walk the path that is also indeed inbetween both?
    Because I want to use this method for other things I am just testing it in a area that would be difficult for rotated DTM's

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
  •