Results 1 to 10 of 10

Thread: FindColorSprial3

  1. #1
    Join Date
    Jun 2007
    Location
    #SRL
    Posts
    200
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default FindColorSprial3

    well i was trying to make my ServantPlanker, and I encountered the problem of trying to find a color that has the uptext of the name of the servant, but if i tried to use FindColorSprial in a repeat loop it would never find a color that is to the left of the previous color that was found, so i made this, but it has to have the "CMouse" in it for the click.

    SCAR Code:
    {*******************************************************************************
    procedure CMouse(Left: Boolean);
    By: Mutant Squirrle modded by Tootoot222
    Description: Clicks mouse at current position.
    Notes: Mutant Squirrle made this, and i just took out the "mouse" procedure
    *******************************************************************************}


    procedure CMouse(Left:Boolean);
    var
    a,b,c: Integer;
    begin
      Wait(60 + Random(30));
      GetMousePos(b, c);
      HoldMouse(b + 1, c, left);
      repeat
        Wait(20 + Random(30));
        a := a + 1;
      until (a > 4);
      GetMousePos(b, c);
      ReleaseMouse(b, c, left);
      Wait(100 + Random(100));
    end;

    {*******************************************************************************
    function FindColorSprial3(var x,y: Integer; Color,Sx,Sy,Ex,Ey,Tol,Rx,Ry: Integer; Click,Left,UsePhrase: Boolean; Phrase: String; IFrom: Integer):Boolean;
    By: Tootoot222
    Description: Stores the x,y coords for Color in Sx,Sy,Ex,Ey and if usePhrase = true then it checks the uptext to see if it matches Phrase, and if Click = true then it click at that point.
    Use: Use like: FindColorSprial3(x,y,255,0,0,500,500,5,2,2,True,True,True,'Walk here',1);
    *******************************************************************************}

    Function FindColorSprial3(var x,y: Integer; Color,Sx,Sy,Ex,Ey,Tol,Rx,Ry: Integer; Click,Left,UsePhrase: Boolean; Phrase: String; IFrom: Integer):Boolean;
    var
    z,t,q,w,i,TimesLooked,TimesFound: Integer;
    begin
      z:= Sx;
      t:= Sy;
      if(FindColorTolerance(q,w,Color,Sx,Sy,Ex,Ey,Tol)) then
      begin
        Writeln('Color is in the area spesified');
        Z:= Q;
        T:= W;
      end else
      begin
        Writeln('Color is NOT in the area spesified');
        GetApplication.BringToFront;
        Result:= False;
        Exit;
      end;
      repeat
        repeat
          Writeln('Looked for color '+IntToStr(TimesLooked)+' times, and found the color '+IntToStr(TimesFound)+'Times');
          Writeln('Serching for color '+IntToStr(Color)+' At '+IntToStr(z)+','+IntToStr(t));
          TimesLooked:= TimesLooked+1;
          if(FindColorTolerance(q,w,Color,z,t,z,t,Tol)) then
          begin
            TimesFound:= TimesFound+1;
            Writeln('found color at '+IntToStr(z)+','+IntToStr(t));
            MMouse(q,w,Rx,Ry);
            i:= 0;
            repeat
              Wait(165+Random(47));
              i:= i+1;
            until(i>=4);
            if(UsePhrase) then
            begin
              Writeln('UpText = '+Lowercase(Copy(GetUpText,IFrom,Length(phrase))));
              if(Lowercase(Copy(GetUpText,IFrom,Length(phrase)))=LowerCase(Phrase)) then
              begin
                Result:= True;
                x:= q;
                y:= w;
                if(Click) then
                begin
                  CMouse(Left);
                end;
                Exit;
              end;
            end else
            begin
              Result:= True;
              x:= q;
              y:= w;
              if(Click) then
              begin
                CMouse(Left);
              end;
              Exit;
            end;
          end else
          begin
            if(FindColorTolerance(q,w,Color,z+1,t,Ex,t,Tol)) then
            begin
              z:= q;
            end else
            begin
              if(FindColorTolerance(q,w,Color,Sx,t+1,Ex,Ey,Tol)) then
              begin
                z:= q;
                t:= w;
              end else
              begin
                Writeln('Color is NOT within the area of '+IntToStr(z)+','+IntToStr(t)+' to '+IntToStr(Ex)+','+IntToStr(Ey));
                Result:= False;
                Exit;
              end;
            end;
          end;
          z:= z+2;
        until(z>= EX);
        t:= t+6;
        z:= Sx;
      until(Y>= Ey+1);
    end;
    Quote Originally Posted by IRC
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 43
    <Wizzup> shit
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 3
    <Wizzup> 1
    <Wizzup> offblast

  2. #2
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Wouldn't that lag quite a lot? Have you tried use FindObj?

  3. #3
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    and if you want to still do the same as FindColorSpiral... Why not use FindColorSpiral? Gj though

  4. #4
    Join Date
    Jun 2007
    Location
    #SRL
    Posts
    200
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    @ZephyrsFury, no, it doesn't lag at all
    @n3ss3s, FindColorSprial wouldn't find a color that is to the left of the color found last, so i the color i wanted is at 200,200 and there is another color at 300,100, it would find the 300,100 one first then return false for finding the other color
    Quote Originally Posted by IRC
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 43
    <Wizzup> shit
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 3
    <Wizzup> 1
    <Wizzup> offblast

  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Gj, still don't get it why you don't use findobject

    even he is better in that stuff then me
    ~Hermen

  6. #6
    Join Date
    Jun 2007
    Location
    #SRL
    Posts
    200
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    how does FindObject work?
    Quote Originally Posted by IRC
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 43
    <Wizzup> shit
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 3
    <Wizzup> 1
    <Wizzup> offblast

  7. #7
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by tootoot222 View Post
    how does FindObject work?
    It uses FindColorsSpiralTolerance, which finds every matching color on the screen and returns it as an array of TPoints of the positions of each one (x and y). Then it moves the mouse to each of these points, one at a time, and checks for the uptext.

    FindColorsSpiralTolerance is great. It speeds up this kind of searching a whole lot, since it does one big search and collects all the points at the same time. There is quite a bit of computational overhead involved in doing sequential FindColor searches like you're doing here.


  8. #8
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    @Tara:

    Everything you say in the internet, can, and will be used against you in some amusing way:

    SCAR Code:
    function FindObj(var cx, cy: Integer; Text: string; color, tolerance: Integer): Boolean;
    var
      a, c, i, x1, y1, x2, y2: Integer;
    begin
      x1 := 245;
      y1 := 165;
      x2 := 277;
      y2 := 185;
      repeat
        if (not (Loggedin)) then
          Break;
        a := a + 1;
        if (a = 1) or (a = 3) then
          c := c + 1;
        for i := 1 to c do
        begin
          if (a = 1) then
          begin
            x1 := x1 + 30;
            x2 := x2 + 30;
          end else
          if (a = 2) then
          begin
            y1 := y1 - 20;
            y2 := y2 - 20;
          end else
          if (a = 3) then
          begin
            x1 := x1 - 30;
            x2 := x2 - 30;
          end else
          if (a = 4) then
          begin
            y1 := y1 + 20;
            y2 := y2 + 20;
          end;
          if (x1 = 485) and (x2 = 517) then
            x2 := x2 - 2;
          if (y1 = 325) and (y2 = 345) then
            y2 := y2 - 7;
          if (x2 > 515) then
            Break;
          if (FindColorTolerance(cx, cy, color, x1, y1, x2, y2, tolerance)) then
          begin
            MMouse(cx, cy, 0, 0)
            Wait(50+Random(50));
            if (IsUpText(Text)) then
            begin
              Result := True;
              Break;
            end;
          end;
        end;
        if (a = 4) then
          a := 0;
      until (x2 > 515) or (Result = True);
    end;

    No FindColorsSpiralTolerance, though should be =/

  9. #9
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    LOL, must be another one of the variants, then. FindObjEx is the closest, I guess, but it has all those annoying variables to fill out.

    I think the old one got removed. There used to be a FindObj2 and FindObj3 at one time, one of which must have used FindColorsSpiralTolerance, since that's where I learned it from.


  10. #10
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    I think the old one got removed. There used to be a FindObj2 and FindObj3 at one time, one of which must have used FindColorsSpiralTolerance, since that's where I learned it from.
    Sure... *keeps nodding while the people from hospital wrap tara in the white shirt that ties your arms*

    Any chance of FindObj changing to FindColors?

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
  •