Results 1 to 6 of 6

Thread: Finding correct object with color

  1. #1
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Finding correct object with color

    I had a problem with finding the altar in my script. I have tried many colors but it changes too often, if tolerance is put higher, it will find the similar colors of the surroundings.
    How can I find the color until the correct object is found?



    There are 3 objects found with similar colors. The small stone and boots of lightness, and the altar that I want to find. How can I find the color until the object is found, or the uptext is there?

    Here's the part that finds altar and clicks it.

    Simba Code:
    Procedure ClickAltar6;
    var
      a,t: Integer;
      TPA  : TPointArray;
      ATPA : T2DPointArray;
      MP   : TPoint;
      tmpCTS : Integer;
      Box  : TBox;
    begin
      if(not(LoggedIn))then Exit;
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.84, 0.28);

    //Find the color on mainscreen except your character, I know its crappy
      if not FindColorsTolerance(TPA, 6906726, 0, 0, 231, 338, 2) then
      begin
        writeln('Trying to find area2');
        if not FindColorsTolerance(TPA, 6906726, 0, 198, 515, 337, 2) then
        begin
          writeln('Trying to find area3');
          if not FindColorsTolerance(TPA, 6906726, 274, 0, 515, 337, 2) then
          begin
            writeln('Trying to find area4');
            if not FindColorsTolerance(TPA, 6906726, 0, 0, 515, 141, 2) then
            begin
              writeln('Cant find altar again omggggg');
              writeln('Terminating Script');
              TerminateScript;
            end else
            begin
              writeln('Found in area4');
            end;
          end else
          begin
            writeln('Found in area3');
          end;
        end else
        begin
          writeln('Found in area2');
        end;
      end else
      begin
        writeln('Found in area1');
      end;
      SortTPAFrom(TPA, Point(MSCX, MSCY));
      ATPA := TPAtoATPAEx(TPA, 15, 15);

      for a := 0 to High(ATPA) do
      begin
        MP := MiddleTPA(ATPA[a]);
        Box := IntToBox((MP.X - 20), (MP.Y - 20), (MP.X + 20), (MP.Y + 20));
        {$IFDEF SMART}
        SMART_DrawBoxEx(True, Box, clYellow);
        {$ENDIF}
        MMouse(MP.X, MP.Y, 4, 4);
        if WaitUptext('raft', 2000) then
        begin
          ClickMouse2(mouse_Left);
          writeln('Crafting Runes');
          MarkTime(t)
          repeat
            wait(500);
          until WaitInvMaxCount(8, 2000) or (TimeFromMark(t) > 4000);
          writeln('Crafted runes');
        end else
        begin
          writeln('Y NO ALTAR?!?!');
          TerminateScript;
        end;
        {$IFDEF SMART}
        SMART_ClearCanvas;
        {$ENDIF}
        Break;
      end;

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

  2. #2
    Join Date
    Mar 2012
    Posts
    426
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

    Default

    Simba Code:
    Procedure CraftARune;
    Begin
      If (FindObj(x,y,'ltar',11318452,0) or FindObj(x,y,'ltar',9081233,0)) Then
        Begin
          Mouse(x,y,5,5,true);
        End Else
        Begin
          WalkToAltar;
          CraftARune;
        End;
      Wait(RandomRange(1250,1750));
      IfRandoms;
    End;

    That is the function I use to search for the altar in my Astrals script. It searches for the lightest colored "rock" around the base of the altar and the darkest colored "rock" around the base. I don't believe it has failed me unless colors have changed!

  3. #3
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    if (CountColor(.........) < 50) then
    Continue;


    Put that in your loop. OR you can sortatpafromsize(ATPA, 50, False); Which will sort from closest to you and largest first. Loop through the ATPA and mouse over it for the uptext.. If WaitUptextMulti(['altar', 'tar', 'stral'], 600) then...

  4. #4
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    If you can make sure to stand next to the altar you can make a smaller box where you want to be searching for
    Simba Code:
    MSCX - 100, MSCY - 100, MSCX + 100, MSCY + 100

    Nearly no-one seems to be using FindColoredArea but it works fairly well and is a lot easier to make than making TPA loops. If you know how to make those I highly suggest you to make TPA loops, though. But this code should work. Just edit the 499 and 500 numbers to whatever works well.
    Simba Code:
    procedure Test;
    begin
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(9.01, 9.00);
      if CountColorTolerance(6972776, MSX1, MSY1, MSX2, MSY2, 2) > 499 then
        begin
          if FindColoredAreaTolerance(X, Y, 6972776, MSCX - 100, MSCY - 100, MSCX + 100, MSCY + 100, 500, 2) then
            begin
              MMouse(X, Y, 2, 2);
            end;
        end else
        begin
          WriteLn('We have counted less than 100 colors of our desired color');
          //Failsafe here
        end;
    end;

    Script source code available here: Github

  5. #5
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    You can use SortATPAFromMidPoint(aTPA, Point(SORTFROMTHISPOINT))


    ~Home

  6. #6
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks guys. SortATPAFromSize works great for me!

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
  •