Results 1 to 16 of 16

Thread: Function FindTreeColor: Integer;

  1. #1
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default Function FindTreeColor: Integer;

    SCAR Code:
    Function FindTreeColor: Integer;
    var
      TPA: TPointArray;
      i, TestColor, GC, R, G, B, AL: Integer;
    begin
      GC := 1528609;
      FindColorsSpiralTolerance(mmcx, mmcy, TPA, GC, mmx1, mmy1, mmx2, mmy2, 70);
      If Length(TPA) < 1 then
      begin
        writeln('Couldn''t find tree color!');
        Result := -1;
        exit;
      end;
      FilterPointsPie(TPA, 0, 360, 0, 72, MMCX, MMCY);
      AL := GetArrayLength(TPA);
      For i := 0 to AL - 1 do
      begin
        If RS_OnMiniMap(TPA[i].x, TPA[i].y) then
        begin
          TestColor := GetColor(TPA[i].x, TPA[i].y);
          ColorToRGB(TestColor, R, G, B);
          if InRange(R - B, 4, 50) then
            if InRange(R - G, -65, -30) then
              if InRange(G - B, 50, 82) then
                if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
                  if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
                    if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
                    begin
                      writeln('Tree colour = '+ Inttostr(TestColor));
                      Result := TestColor;
                      exit;
                    end;
        end;
      end;
      writeln('Couldn''t find tree color!');
      Result := -1;
    end;



    Even in a place where the ground is very similar to the tree, it finds it
    Last edited by noidea; 08-08-2009 at 12:51 PM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  2. #2
    Join Date
    Dec 2008
    Posts
    209
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I had noidea you could do stuff like this, nice

    I'm semi-working on a power cutter atm, I'll sure to be adding it to it

    I'll tell you how it goes on the irc

    ~ Craig`

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    lol, i get some credit for sort of giving you the idea last night, right?

    and good job haha
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    lol, i get some credit for sort of giving you the idea last night, right?

    and good job haha
    I wrote it a few days ago silly. I'm trying to re-write my old VWM
    <3
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

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

    Default

    Good job!
    ~Hermen

  6. #6
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Add in AutoColor.scar nowz!!
    Really helpful, since its good for location checks like.

    RW
    RW
    if (not(findcolor(x, y, Findtreecolor, mmx1,mmy1,mmx2,mmy2))) or whatever the params lol
    then exit;

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

    Default

    Quote Originally Posted by Smarter Child View Post
    Add in AutoColor.scar nowz!!
    Really helpful, since its good for location checks like.

    RW
    RW
    if (not(findcolor(x, y, Findtreecolor, mmx1,mmy1,mmx2,mmy2))) or whatever the params lol
    then exit;
    That wouldn't be smart, because like whole Runescape's MM exists out of tree's when you are walking.
    ~Hermen

  8. #8
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    This is especially useful for DDTMs.
    Thanks, noidea - committed it.

    Though, I took the liberty to edit it a tiny bit, hope you don't mind.

  9. #9
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by EvilChicken! View Post
    This is especially useful for DDTMs.
    Thanks, noidea - committed it.

    Though, I took the liberty to edit it a tiny bit, hope you don't mind.
    /me cheers
    thanks EC! my first function added <3

    I don't mind you editting it.

    Edit: Lol, with the edits, its so short

    Edit2: Oops. I hadnt realised I left in the DebugTPA(). It was the raw colour that the FindColorsSpiralTolerance gave out
    To the the pic I used, I just made another tpa using the FindTreeColor.
    Last edited by noidea; 08-08-2009 at 12:52 PM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  10. #10
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Sorry for the double post but this is urgant.

    The one commited to SRL isn't find the tree colour.
    ANd the one I posted Is.

    Not putting you down EC

    Edit: your function isnt working. The FindMMColor...
    I changed it
    SCAR Code:
    function FindMMColorsSpiralTolerance(var Points: TPointArray; Color, Tol: Integer): Boolean;
    begin
      Result := False;
      if (not LoggedIn) then exit;
      FindColorsSpiralTolerance(MMCX, MMCY, Points, Color, MMX1, MMY1, MMX2, MMY2, Tol);
      result := length(points) > 0;
      if Result then
        FilterPointsPie(Points, 0.0, 360.0, 0.0, 76.0, MMCX, MMCY);
    end;
    It works
    And that bug is affecting ALL the other autocolors :<
    Last edited by noidea; 08-08-2009 at 02:49 PM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  11. #11
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Sorry for the triple post but this is an epic updated one.

    SCAR Code:
    Function FindTreeColor: Integer;
    var
      TPA, TestTPA: TPointArray;
      ATPA: T2DPointArray;
      H, S, L: Extended;
      i, TestColor, R, G, B, AL, BlackListCol: Integer;
    begin
      Result := -1;
      BlackListCol := -1;
      if FindMMColorsSpiralTolerance(TPA, 1528609, 70) then
      begin
        AL := high(TPA);
        For i := 0 to AL do
        begin
          TestColor := GetColor(TPA[i].x, TPA[i].y);
          if TestColor <> BlackListCol then
          begin
            ColorToRGB(TestColor, R, G, B);
            ColorToHSL(TestColor, H, S, L);
            if InRange(R - B, 4, 50) then
              if InRange(R - G, -65, -30) then
                if InRange(G - B, 50, 87) then
                  if L < 28 then
                    if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
                      if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
                        if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
                        begin
                          FindColorsSpiralTolerance(mmcx, mmcy, TestTPA, TestColor, mmx1, mmy1, mmx2, mmy2, 0);
                          if Length(TestTPA) > 0 then
                          begin
                            ATPA := TPAtoATPAEx(TestTPA, 11, 10);
                            SortATPAFrom(ATPA, Point(mmcx, mmcy));
                            if not InRange(Length(ATPA[0]), 21, 28) then
                              if Length(ATPA[0]) < 30 then
                              begin
                                srl_Warn('FindTreeColor', 'TreeColor = ' + IntToStr(TestColor), warn_Debug);
                                Result := TestColor;
                                exit;
                              end else
                              begin
                                ColorToHSL(TestColor, H, S, L);
                                if L > 24 then
                                  BlackListCol := TestColor;
                              end;
                          end;
                        end;
          end;
        end;
      end;
      srl_Warn('FindTreeColor', 'Could''t find TreeColor', warn_Debug);
      Result := -1;
    end;
    - EvilChicken Style


    SCAR Code:
    Function FindTreeColor: Integer;
    var
      TPA, TestTPA: TPointArray;
      ATPA: T2DPointArray;
      H, S, L: Extended;
      i, TestColor, GC, R, G, B, AL, BlackListCol: Integer;
    begin
      GC := 1528609;
      BlackListCol := -1;
      FindColorsSpiralTolerance(mmcx, mmcy, TPA, GC, mmx1, mmy1, mmx2, mmy2, 70);
      If Length(TPA) < 1 then
      begin
        writeln('Couldn''t find tree color!');
        Result := -1;
        exit;
      end;
      FilterPointsPie(TPA, 0, 360, 0, 72, MMCX, MMCY);
      //DebugTPA(TPA, '');
      AL := GetArrayLength(TPA);
      For i := 0 to AL - 1 do
      begin
        If RS_OnMiniMap(TPA[i].x, TPA[i].y) then
        begin
          TestColor := GetColor(TPA[i].x, TPA[i].y);
          if TestColor <> BlackListCol then
          begin
            ColorToRGB(TestColor, R, G, B);
            ColorToHSL(TestColor, H, S, L);
            if InRange(R - B, 4, 50) then
              if InRange(R - G, -65, -30) then
                if InRange(G - B, 50, 87) then
                  if L < 28 then
                    if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
                      if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
                        if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
                        begin
                          FindColorsSpiralTolerance(mmcx, mmcy, TestTPA, TestColor, mmx1, mmy1, mmx2, mmy2, 0);
                          if Length(TestTPA) > 0 then
                          begin
                            ATPA := TPAtoATPAEx(TestTPA, 11, 10);
                            SortATPAFrom(ATPA, Point(mmcx, mmcy));
                            if not InRange(Length(ATPA[0]), 21, 28) then
                              if Length(ATPA[0]) < 30 then
                              begin
                                writeln('Tree colour = '+ Inttostr(TestColor));
                                Result := TestColor;
                                exit;
                              end else
                              begin
                                ColorToHSL(TestColor, H, S, L);
                                if L > 24 then
                                  BlackListCol := TestColor;
                              end;
                          end;
                        end;
          end;
        end;
      end;
      writeln('Couldn''t find tree color!');
      Result := -1;
    end;
    - Original

    The other one would often find the Bushes on the MM (I only found that after I posted). This one skips the bushes ect...

    All in all this is about 100x better.

    btw: I stayed up ALL night coding, and testing this - It better work. Wizzup can tell you that I was on the irc all night ranting and raging
    Last edited by noidea; 08-08-2009 at 08:19 PM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  12. #12
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Ow, nice, looks a lot better.

    First of all, it needs to be a global variable for the color to be permanently stored in there.
    Second, don't you think that an array of colors would be better?
    Third, I'll add it with the array if you can tell me with 100% certainty that it won't add useful colors in that blacklist array.

  13. #13
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    You should replace GetArrayLength with High(). In a freak case that if nothing is found, then it won't do:

    For I := 0 to -1 Do.

    Good work though

    Edit: You may want to set Result := -1; at the beginning.

  14. #14
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by EvilChicken! View Post
    Ow, nice, looks a lot better.

    First of all, it needs to be a global variable for the color to be permanently stored in there.
    Second, don't you think that an array of colors would be better?
    Third, I'll add it with the array if you can tell me with 100% certainty that it won't add useful colors in that blacklist array.
    So should I let it find that bush colour? (The tree that sort of looks like a palm tree on the MM)
    Or just all the colour on the tree?
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  15. #15
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Did some testing, seems to work really well. Nevermind the talk about making the blacklist array global, by the way.
    Here's the version I committed.

    SCAR Code:
    function FindTreeColor: Integer;
    var
      TPA, TestTPA: TPointArray;
      ATPA: T2DPointArray;
      H, S, L: Extended;
      Hi, i, TestColor, R, G, B: Integer;
      TreeColorsBlackList: TIntegerArray;

     
    begin
      if FindMMColorsSpiralTolerance(TPA, 1528609, 70) then
      begin
        Hi := High(TPA);
        For I := 0 to Hi do
        begin
          TestColor := GetColor(TPA[i].x, TPA[i].y);
          if not InIntArray(TreeColorsBlackList, TestColor) then
          begin
            ColorToRGB(TestColor, R, G, B);
            ColorToHSL(TestColor, H, S, L);
            if InRange(R - B, 4, 50) then
              if InRange(R - G, -65, -30) then
                if InRange(G - B, 50, 87) then
                  if (L < 28) then
                    if (GetColor(TPA[i].x - 1, TPA[i].y) = TestColor) then
                      if (GetColor(TPA[i].x, TPA[i].y + 1) = TestColor) then
                        if (GetColor(TPA[i].x, TPA[i].y - 1) = TestColor) then
                          if FindMMColorsSpiralTolerance(testTPA, TestColor, 0) then
                          begin
                            ATPA := TPAtoATPAEx(TestTPA, 11, 10);
                            if (not InRange(Length(ATPA[0]), 21, 28)) then
                              if (Length(ATPA[0]) < 30) then
                              begin
                                srl_Warn('FindTreeColor', 'TreeColor = ' + IntToStr(TestColor), warn_Debug);
                                Result := TestColor;
                                Exit;
                              end else
                                if (L > 24) then
                                begin
                                  Hi := High(TreeColorsBlackList);
                                  SetLength(TreeColorsBlackList, Hi + 2);
                                  TreeColorsBlackList[Hi + 1] := TestColor;
                                end;
                          end;
          end;
        end;
      end;
      srl_Warn('FindTreeColor', 'Could''t find TreeColor', warn_Debug);
      Result := -1;
    end;
    Last edited by EvilChicken!; 08-09-2009 at 07:21 AM.

  16. #16
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    SCAR Code:
    Function FindTreeColor: Integer;
    var
      TPA, TestTPA: TPointArray;
      ATPA: T2DPointArray;
      H, S, L: Extended;
      i, TestColor, GC, R, G, B, AL: Integer;
      BlackListCol: TIntegerArray;
    begin
      result := -1;
      if FindMMColorsSpiralTolerance(TPA, 1528609, 70) then
      begin
        AL := high(TPA);
        For i := 0 to AL do
        begin
          TestColor := GetColor(TPA[i].x, TPA[i].y);
          if not InIntArray(BlackListCol, TestColor) then
          begin
            ColorToRGB(TestColor, R, G, B);
            ColorToHSL(TestColor, H, S, L);
            if InRange(R - B, -10, 50) then
              if InRange(R - G, -75, -30) then
                if InRange(G - B, 50, 88) then
                  if L < 31.5 then
                    if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
                      if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
                        if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
                        begin
                          FindColorsSpiralTolerance(mmcx, mmcy, TestTPA, TestColor, mmx1, mmy1, mmx2, mmy2, 0);
                          if Length(TestTPA) > 0 then
                          begin
                            ATPA := TPAtoATPAEx(TestTPA, 11, 10);
                            SortATPAFrom(ATPA, Point(mmcx, mmcy));
                            if not InRange(Length(ATPA[0]), 21, 28) then
                              if Length(ATPA[0]) < 30 then
                                if not InRange(Length(ATPA[0]), 8, 10) then
                              begin
                                writeln('Tree colour = '+ Inttostr(TestColor));
                                Result := TestColor;
                                exit;
                              end else
                              begin
                                ColorToHSL(TestColor, H, S, L);
                                if L > 24 then
                                begin
                                  SetArrayLength(BlackListCol, Length(BLackListCol) + 1);
                                  BlackListCol[High(BlackListCol)] := TestColor;
                                end;
                              end;
                          end;
                        end;
          end;
        end;
      end;
      writeln('Couldn''t find tree color!');
      Result := -1;
    end;

    Lol I just sent you this in PM and its like identical to yours
    The one you upped needs to change some of the ranges though.

    Edit: Lol I cant believe the similarity Its almost like word for word
    Last edited by noidea; 08-09-2009 at 08:35 AM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

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
  •