Results 1 to 5 of 5

Thread: Need Help With Ladder Function

  1. #1
    Join Date
    Jan 2012
    Posts
    713
    Mentioned
    3 Post(s)
    Quoted
    9 Post(s)

    Default Need Help With Ladder Function

    So this is my last step I need to finish and I couldn't seen to find anything|tuts on this and its taking me about a week now so I'm going to ask for help. Im using the ACA tool to find the ladders colors and i need the function to actually climb down it.

    Simba Code:
    [CODE]function TrapDoorColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.20, 0.35);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 6186359, MSX1, MSY1, MSX2, MSY2, 24);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

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

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

        if (X >= 2.76) and (X <= 36.79) and (Y >= 2.82) and (Y <= 37.91) and (Z >= 2.39) and (Z <= 40.51) then
        begin
          Result := arC[i];
          Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

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

      if (i = arL + 1) then
        Writeln('AutoColor failed in finding the color.');
    end;   [/CODE]

    ^ ACA autocolor function code for finding the color

  2. #2
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    I'm not sure how much scripting knowledge you have so I will just give you the simplest way to use what you have. Keep in mind that function returns a color. This would be the simplest way to use it:

    Simba Code:
    Procedure ClickLadder;
    Begin
      x := MSCX;
      y := MSCY;
      if FindObjCustom(x, y, ['down', 'adder'], [TrapDoorColor], 5) then
        Mouse(x, y, 0, 0, true);
    end;
    Last edited by Nebula; 04-04-2012 at 09:26 PM.

  3. #3
    Join Date
    Feb 2012
    Posts
    168
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by GOOGLE View Post
    So this is my last step I need to finish and I couldn't seen to find anything|tuts on this and its taking me about a week now so I'm going to ask for help. Im using the ACA tool to find the ladders colors and i need the function to actually climb down it.

    Simba Code:
    [CODE]function TrapDoorColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.20, 0.35);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 6186359, MSX1, MSY1, MSX2, MSY2, 24);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

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

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

        if (X >= 2.76) and (X <= 36.79) and (Y >= 2.82) and (Y <= 37.91) and (Z >= 2.39) and (Z <= 40.51) then
        begin
          Result := arC[i];
          Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

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

      if (i = arL + 1) then
        Writeln('AutoColor failed in finding the color.');
    end;   [/CODE]

    ^ ACA autocolor function code for finding the color
    This is how I'd do it:
    Simba Code:
    procedure FindLadder;
    var
      I, N, x, y: Integer;
      TPA: TPointArray;
      ATPA: Array of TPointArray;
    begin
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.20, 0.35);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, 6186359, MSX1, MSY1, MSX2, MSY2, 24); //Note here: Try to pick better colors, tolerance of 24 is quite high and you'll get a bunch of false positives
      ATPA := (SplitTPAEx(TPA, 10, 10));
      SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
      N := High(ATPA);
      for I := 0 to N do
      begin
        MiddleTPAEx(ATPA[I], x, y);
        Mouse(x, y, 2, 2, 3);
        if IsUptext('adde') then
        begin
          Mouse(x, y, 2, 2, 1);
          break;
        end;
      end;
    end;

    I might have made a syntax error or two, wrote this directly into the forum post, but that's the general idea.

  4. #4
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Pretty sure ACA has a find obj function as-well, you could just use that

  5. #5
    Join Date
    May 2008
    Location
    ;)
    Posts
    576
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    That ACA function returns the best color to use to find the object. So, you could use what nebula suggested:

    Simba Code:
    Procedure ClickLadder;
    Begin
      x := MSCX;
      y := MSCY;
      if FindObjCustom(x, y, ['down', 'adder'], [TrapDoorColor], 5) then
        Mouse(x, y, 0, 0, true);
    end;

    or a custom object finder to your liking, or you could use ACA's built in object finding function.

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
  •