Results 1 to 12 of 12

Thread: FindObjCustomEx / FindObjCustomCArray

  1. #1
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default FindObjCustomEx / FindObjCustomCArray

    Well this is the technique that I use for finding fishing spots, and I've also used the same technique for finding Rocks, Trees, ect. So I worked for a bit and Made it as universal as I could. Credits to Boreas for helping with Removing Duplicates from an Array.

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    var
      Ox, Oy: Integer;
      Color, Tolerance, CTS: array [0..1] of Integer;
     
    {
    Name: FindObjCustomEx
    By: Special Ed
    Description: Finds and Object using one Color and returns its Coordinates.
    Vars:
    Ox, Oy - The "Center" of the Object.
    Color, Tolerance, ColorTolSpeed - Self Explanitory.
    MaxHeight, MaxWidth - The Height and Width of the Object, Ex. Fishing Spots are normally 25, 27.
    MaxCount - Max Points it should find using FindColors, Trial and error when finding it.
    MinCount - Minimun Points it should find Using FindColors, Keeps out pieces of Armor, ect.
    MaxTries - Number of Times it should try to find the Obj, Normally I use 3.
    Spiral - Whether or not to Sprial out from Ox, Oy or not.
    }


    function FindObjCustomEx(var Ox, Oy: Integer; Color: Integer; Tolerance, ColorTolSpeed: Byte; MaxHeight, MaxWidth, MinCount, MaxCount, MaxTries: SmallInt; Spiral: Boolean): Boolean;
    var
      Top, Bottom, Right, Left, Tries, CCount, ArrayLength, pFindDups, pBubbleUp: SmallInt;
      i, CTS: Byte;
      NewCol: Boolean;
      Sear, ObjectArea: TBox;
      Cx, Cy: array of Integer;
      CArr, CArr2: array of TPoint;
      BoxMod, tpSwap: TPoint;
    label Start;
    begin
      if(not(LoggedIn))then Exit;
      CTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(ColorTolSpeed);
      Start:
      for i:= 1 to 10 do
      begin
        Sear.x1:= MSCX - Ceil(i * 51.3);
        Sear.y1:= MSCY - Ceil(i * 33.5);
        Sear.x2:= MSCX + Ceil(i * 51.3);
        Sear.y2:= MSCY + Ceil(i * 33.5);
        Ox:= MSCX;
        Oy:= MSCY;
        if(Spiral)then Result:= FindColorSpiralTolerance(Ox, Oy, Color, Sear.x1, Sear.y1, Sear.x2, Sear.y2, Tolerance)else
        Result:= FindColorTolerance(Ox, Oy, Color, Sear.x1, Sear.y1, Sear.x2, Sear.y2, Tolerance);
        if(Result)then
          begin
            BoxMod.x:= MaxWidth div 2;
            BoxMod.y:= MaXHeight div 2;
            ObjectArea.x1:= Ox - BoxMod.x;
            ObjectArea.y1:= Oy - BoxMod.y;
            ObjectArea.x2:= Ox + BoxMod.x;
            ObjectArea.y2:= Oy + BoxMod.y;
            FindColorsTolerance(CArr, Color, ObjectArea.x1, ObjectArea.y1, ObjectArea.x2, ObjectArea.y2, Tolerance);
            SetArrayLength(Cx, Length(CArr));
            SetArrayLength(Cy, Length(CArr));
            for i:= 0 to Length(CArr) - 1 do
            begin
              Cx[i]:= CArr[i].x;
              Cy[i]:= CArr[i].y;
            end;
            BubbleSort(Cx);
            BubbleSort(Cy);
            Left:= Cx[0];
            Right:= Cx[GetArrayLength(CArr) - 1];
            Top:= Cy[0];
            Bottom:= Cy[GetArrayLength(CArr) - 1];
            FindColorsTolerance(CArr2, Color, Left - BoxMod.x, Top - BoxMod.y, Right + BoxMod.x, Bottom + BoxMod.y, Tolerance);
            CArr:= CombineTPA(CArr, CArr2);
            ArrayLength:= GetArrayLength(CArr);
            CArr:= RearrangeTPA(CArr, 0, ArrayLength - 1, True, True);
            for pFindDups:= 0 to ArrayLength - 2 do
            begin
              if(CArr[pFindDups].x = CArr[pFindDups + 1].x) then
              begin
                if(CArr[pFindDups].y = CArr[pFindDups + 1].y)then
                begin
                  for pBubbleUp:= pFindDups to ArrayLength - 2 do
                  begin
                    tpSwap:= CArr[pBubbleUp];
                    CArr[pBubbleUp]:= CArr[pBubbleUp + 1];
                    CArr[pBubbleUp + 1]:= tpSwap;
                  end;
                  ArrayLength:= ArrayLength - 1;
                  SetArrayLength(CArr, ArrayLength);
                end;
              end;
            end;
            CCount:= GetArrayLength(CArr);
            if(CCount < MinCount)or(CCount > MaxCount)then
            begin
              if(Tries = MaxTries)then
                begin
                  Result:= False;
                  NewCol:= False;
                  Exit;
                end;
              Result:= False;
              NewCol:= True;
              Inc(Tries);
              Break;
            end else
            begin
              Result:= True;
              NewCol:= False;
              Break;
            end;
          end;
      end;
      if(Result)then
        begin
          SetArrayLength(Cx, Length(CArr));
          SetArrayLength(Cy, Length(CArr));
          for i:= 0 to Length(CArr) - 1 do
          begin
            Cx[i]:= CArr[i].x;
            Cy[i]:= CArr[i].y;
          end;
          BubbleSort(Cx);
          BubbleSort(Cy);
          Ox:= (Cx[0] + Cx[GetArrayLength(CArr) - 1]) div 2;
          Oy:= (Cy[0] + Cy[GetArrayLength(CArr) - 1]) div 2;
          Result:= True;
        end else Result:= False;
      if(NewCol)then goto Start;
      ColorToleranceSpeed(CTS);
    end;

    {
    Name: FindObjCustomCArray
    By: Special Ed
    Description: Finds and Object using multiple Colors and returns its Coordinates.
    Vars:
    Ox, Oy - The "Center" of the Object.
    Color, Tolerance, ColorTolSpeed - All are arrays of Integer, each corrisponds with itself,
      this provides more accurate finding.
    MaxHeight, MaxWidth - The Height and Width of the Object, Ex. Fishing Spots are normally 25, 27.
    MaxCount - Max Points it should find using FindColors, Trial and error when finding it.
    MinCount - Minimun Points it should find Using FindColors, Keeps out pieces of Armor, ect.
    MaxTries - Number of Times it should try to find the Obj, Normally I use 3.
    Spiral - Whether or not to Sprial out from Ox, Oy or not.
    }


    function FindObjCustomCArray(var Ox, Oy: Integer; Color, Tolerance, ColorTolSpeed: array of Integer; MaxHeight, MaxWidth, MinCount, MaxCount, MaxTries: SmallInt; Spiral: Boolean): Boolean;
    var
      Tries, CCount, ArrayLength, pFindDups, pBubbleUp: SmallInt;
      i, CTS, a: Byte;
      NewCol: Boolean;
      Sear, ObjectArea: TBox;
      Cx, Cy: array of Integer;
      CArr, CArr2: array of TPoint;
      CArrX: array [0..1] of array of TPoint;
      BoxMod, tpSwap: TPoint;
    label Start;
    begin
      if(not(LoggedIn))then Exit;
      CTS:= GetColorToleranceSpeed;
      Start:
      for i:= 1 to 10 do
      begin
        Sear.x1:= MSCX - Ceil(i * 51.3);
        Sear.y1:= MSCY - Ceil(i * 33.5);
        Sear.x2:= MSCX + Ceil(i * 51.3);
        Sear.y2:= MSCY + Ceil(i * 33.5);
        Ox:= MSCX;
        Oy:= MSCY;
        if(Spiral)then
        begin
          for i:= 0 to GetArrayLength(Color) - 1 do
          begin
            ColorToleranceSpeed(ColorTolSpeed[i]);
            if(FindColorSpiralTolerance(Ox, Oy, Color[i], Sear.x1, Sear.y1, Sear.x2, Sear.y2, Tolerance[i]))then
            begin
              Result:= True;
              Break;
            end;
          end;
        end else
        begin
          for i:= 0 to GetArrayLength(Color) - 1 do
          begin
            ColorToleranceSpeed(ColorTolSpeed[i]);
            if(FindColorTolerance(Ox, Oy, Color[i], Sear.x1, Sear.y1, Sear.x2, Sear.y2, Tolerance[i]))then
            begin
              Result:= True;
              Break;
            end;
          end;
        end;
        if(Result)then
          begin
            BoxMod.x:= MaxWidth div 2;
            BoxMod.y:= MaXHeight div 2;
            ObjectArea.x1:= Ox - BoxMod.x;
            ObjectArea.y1:= Oy - BoxMod.y;
            ObjectArea.x2:= Ox + BoxMod.x;
            ObjectArea.y2:= Oy + BoxMod.y;
            for i:= 0 to GetArrayLength(Color) - 1 do
            begin
              ColorToleranceSpeed(ColorTolSpeed[i]);
              FindColorsTolerance(CArrX[a], Color[i], ObjectArea.x1, ObjectArea.y1, ObjectArea.x2, ObjectArea.y2, Tolerance[i]);
              SetArrayLength(CArr, GetArrayLength(CArrX[0]) + GetArrayLength(CArrX[1]));
              for i:= 0 to GetArrayLength(CArrX[0]) - 1 do
              CArr[i]:= CArrX[0][i];
              for i:= GetArrayLength(CArrX[0]) to GetArrayLength(CArrX) - 1 do
              CArr[i]:= CArrX[1][i];
              a:= a + 1;
              if(a = 2)then a:= a xor a;
            end;
            SetArrayLength(Cx, Length(CArr));
            SetArrayLength(Cy, Length(CArr));
            for i:= 0 to Length(CArr) - 1 do
            begin
              Cx[i]:= CArr[i].x;
              Cy[i]:= CArr[i].y;
            end;
            BubbleSort(Cx);
            BubbleSort(Cy);
            ObjectArea.x1:= Cx[0];
            ObjectArea.y1:= Cy[0];
            ObjectArea.x2:= Cx[GetArrayLength(CArr) - 1];
            ObjectArea.y2:= Cy[GetArrayLength(CArr) - 1];
            for i:= 0 to GetArrayLength(Color) - 1 do
            begin
              ColorToleranceSpeed(ColorTolSpeed[i]);
              FindColorsTolerance(CArrX[a], Color[i], ObjectArea.x1, ObjectArea.y1, ObjectArea.x2, ObjectArea.y2, Tolerance[i]);
              SetArrayLength(CArr2, GetArrayLength(CArrX[0]) + GetArrayLength(CArrX[1]));
              for i:= 0 to GetArrayLength(CArrX[0]) - 1 do
              CArr2[i]:= CArrX[0][i];
              for i:= GetArrayLength(CArrX[0]) to GetArrayLength(CArrX) - 1 do
              CArr2[i]:= CArrX[1][i];
              a:= a + 1;
              if(a = 2)then a:= a xor a;
            end;
            CArr:= CombineTPA(CArr, CArr2);
            ArrayLength:= GetArrayLength(CArr);
            CArr:= RearrangeTPA(CArr, 0, ArrayLength - 1, True, True);
            for pFindDups:= 0 to ArrayLength - 2 do
            begin
              if(CArr[pFindDups].x = CArr[pFindDups + 1].x) then
              begin
                if(CArr[pFindDups].y = CArr[pFindDups + 1].y)then
                begin
                  for pBubbleUp:= pFindDups to ArrayLength - 2 do
                  begin
                    tpSwap:= CArr[pBubbleUp];
                    CArr[pBubbleUp]:= CArr[pBubbleUp + 1];
                    CArr[pBubbleUp + 1]:= tpSwap;
                  end;
                  ArrayLength:= ArrayLength - 1;
                  SetArrayLength(CArr, ArrayLength);
                end;
              end;
            end;
            CCount:= GetArrayLength(CArr);
            if(CCount < MinCount)or(CCount > MaxCount)then
            begin
              if(Tries = MaxTries)then
                begin
                  Result:= False;
                  NewCol:= False;
                  Exit;
                end;
              Result:= False;
              NewCol:= True;
              Inc(Tries);
              Break;
            end else
            begin
              Result:= True;
              NewCol:= False;
              Break;
            end;
          end;
      end;
      if(Result)then
        begin
          SetArrayLength(Cx, Length(CArr));
          SetArrayLength(Cy, Length(CArr));
          for i:= 0 to Length(CArr) - 1 do
          begin
            Cx[i]:= CArr[i].x;
            Cy[i]:= CArr[i].y;
          end;
          BubbleSort(Cx);
          BubbleSort(Cy);
          Ox:= (Cx[0] + Cx[GetArrayLength(CArr) - 1]) div 2;
          Oy:= (Cy[0] + Cy[GetArrayLength(CArr) - 1]) div 2;
          Result:= True;
        end else Result:= False;
      if(NewCol)then goto Start;
      ColorToleranceSpeed(CTS);
    end;

    {Should find A Fishing Spot, I know the first one works, but the second is untested}
    begin
    SetupSRL;
    Wait(1000);
    if(FindObjCustomEx(Ox, Oy, 14858393, 33, 0, 22, 22, 3, 60, 5, True))then
    MMouse(Ox, Oy, 0, 0);
    Color[0]:= 14796708;
    Tolerance[0]:= 10;
    CTS[0]:= 0;
    Color[1]:= 15123625;
    Tolerance[1]:= 12;
    CTS[1]:= 1;
    if(FindObjCustomCArray(Ox, Oy, Color, Tolerance, CTS, 22, 22, 3, 60, 3, True))then
    MMouse(Ox, Oy, 0, 0);
    end.
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

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

    Default

    Gotta say that it looks just amazing =)

    Do you know how fast average it is?

  3. #3
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well for the First one, Looking for fishing Spots it gets around... 8 - 30ms depending on how far you are away, for the first one looking for Coal it took 12 - 40ms to find them. The second one I have yet to test but I'm guessing probably double those numbers.
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  4. #4
    Join Date
    Oct 2006
    Posts
    2,297
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    IT looks really nice, great work!
    I wish I had that much experience as you have

    -Tsn.
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

  5. #5
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes, as both of you have said, it "looks" amazing, has anyone even tried it yet?

    EDIT: Bump? 1 Week, 2 replies, not one thing that is helpful? Jeeze... I didn't know it was that bad

    P.S. Or are you just sick of ObjFinders?
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  6. #6
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    I think object finders are ... complete?
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  7. #7
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by R0b0t1 View Post
    I think object finders are ... complete?
    NEVER! You always need more object finder's *twitch**twitch* right n3ss3s?

    Also that was a really, really pointless post, you could of at least made something up like "Yep, tried it and it works, GG nub!" or something, at least that would have made me feel special
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  8. #8
    Join Date
    Aug 2007
    Posts
    1,404
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Yep, tried it and it works, GG nub!

    (Haha :P I haven't tried it. I mostly use colors for object-finding, though, so I won't really use it.)

    -Knives

  9. #9
    Join Date
    Apr 2007
    Location
    Michigan -.-
    Posts
    1,357
    Mentioned
    2 Post(s)
    Quoted
    4 Post(s)

    Default

    looks usefull, im on a mac at school atm, cant exactly test it, but I may be able to during web page design....

    good work
    METAL HEAD FOR LIFE!!!

  10. #10
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by King of Knives View Post
    Yep, tried it and it works, GG nub!

    (Haha :P I haven't tried it. I mostly use colors for object-finding, though, so I won't really use it.)

    -Knives
    Umm... it uses colors... and it is an object finder, I'm confused by your statement. Also I can't believe you copy / pasted my response... XD
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

  11. #11
    Join Date
    Aug 2007
    Posts
    1,404
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry, I though it was a TPointArray... Shows how much I actually pay attention sometimes

    You said you wanted a reply like that :P I'm just here to make you happy.

    -Knives

  12. #12
    Join Date
    Oct 2006
    Location
    C:\Program Files\SCAR 2.03
    Posts
    1,194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by King of Knives View Post
    Sorry, I though it was a TPointArray... Shows how much I actually pay attention sometimes

    You said you wanted a reply like that :P I'm just here to make you happy.

    -Knives
    Well at least someone cares... XD

    Do you at least think you could give it a try for me though. Seeing as how you've spent more time talking to me on the forums than you would have using it on RS?
    [FONT="Garamond"][SIZE="3"]
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
    [/SIZE][/FONT][URL="http://www.villavu.com/forum/forumdisplay.php?f=125"][IMG]http://i40.tinypic.com/r1lzdv.jpg[/IMG][/URL]

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
  •