Results 1 to 3 of 3

Thread: ACA Help

  1. #1
    Join Date
    Mar 2013
    Posts
    222
    Mentioned
    3 Post(s)
    Quoted
    143 Post(s)

    Default ACA Help

    Hey guys I was wondering if you guys could help me decipher the code from the ACA program.

    This is the code from my kyatt program.

    Code:
    function FindClimb: Boolean;
    var
      arP: TPointArray;
      ararP: T2DPointArray;
      tmpCTS, i, arL: Integer;
      Colors : Array of Integer;
      P: TPoint;
    begin
    
      Cycle := 0;
    
      Repeat
    
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);
    
      Case Cycle of
        0: begin
        if not(FindColorsTolerance(arP, 855310, MSX1, MSY1, MSX2, MSY2-75, 1)) then
        begin
          Debugger('Failed to find the color, no object found. 0');
            ColorToleranceSpeed(tmpCTS);
            SetColorSpeed2Modifiers(0.2, 0.2);
        end;
        end;
    
        1: begin
        if not(FindColorsTolerance(arP, 789517, MSX1, MSY1, MSX2, MSY2-75, 1)) then
        begin
          Debugger('Failed to find the color, no object found. 1');
          ColorToleranceSpeed(tmpCTS);
          SetColorSpeed2Modifiers(0.2, 0.2);
          end;
        end;
    
        2: begin
        if not(FindColorsTolerance(arP, 855309, MSX1, MSY1, MSX2, MSY2-75, 1)) then
        begin
          Debugger('Failed to find the color, no object found. 2');
          ColorToleranceSpeed(tmpCTS);
          SetColorSpeed2Modifiers(0.2, 0.2);
          Exit;
          end;
        end;
    
    
    
      end;
    
      SortTPAFrom(arP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 20) then Continue;
        P := MiddleTPA(ararP[i]);
        HumanMMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('Climb')) then
        begin;
          Result := True;
          Exit;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Debugger('FindClimb could not find object. Cycle: ' + IntToStr(Cycle));
      end;
    
      Cycle := Cycle + 1;
    
      Until ( Cycle = 3 )
    
      Result := False;
    
    end;
    As you can see, I used 'cycle' to cycle through the various possible colors instead of putting them into an array. If you guys have any suggestions any improvements to this or if its fine as it is to achieve that function.

    My main confusion is the
    Code:
    SortTPAFrom(arP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 20) then Continue;
        P := MiddleTPA(ararP[i]);
        HumanMMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('Climb')) then
        begin;
          Result := True;
          Exit;
        end;
      end;
    I can select the 'max length' in the ACA function maker and I can see it translates to [if (Length(ararP[i]) < 20) then Continue;]
    Is this a way to ignore the random single pixels that might have matching colors from the findcolortolerance or is it something completely different?

    Thanks!

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    If the object contains multiple colors, you may want to add up all the points in which the colors are found, rather than just searching for a single color at a time and handling them 1 by 1.
    Eg.
    Simba Code:
    colors:= [855310, 789517, 855309];
    SetLength(ATPA, Length(colors));
    for i:=0 to High(colors) do
      FindColorsTolerance(ATPA[i], colors[i], ...);
    MergeATPAWrap(ATPA, arP);
    //other codes

    You are right about the purpose of length check

  3. #3
    Join Date
    Mar 2013
    Posts
    222
    Mentioned
    3 Post(s)
    Quoted
    143 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    If the object contains multiple colors, you may want to add up all the points in which the colors are found, rather than just searching for a single color at a time and handling them 1 by 1.
    Eg.
    Simba Code:
    colors:= [855310, 789517, 855309];
    SetLength(ATPA, Length(colors));
    for i:=0 to High(colors) do
      FindColorsTolerance(ATPA[i], colors[i], ...);
    MergeATPAWrap(ATPA, arP);
    //other codes

    You are right about the purpose of length check
    Tanks for the help!

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
  •