Results 1 to 11 of 11

Thread: CutTree function

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

    Default CutTree function

    Hi, I have managed making a rather good Find & CutTree function.
    I made this thread to show you the function, duh!, but also to thank my good friend, Clay (pwnaz0r), to help and explain me TPAtoATPA and MiddleTPA, thanks buddy!!

    I'm making a PowerCutter, that I will release when it's ready (I just started on it). I still have some problem (not with this function).
    I want to make a functino that will return true if the tree is gone.
    Since trees are positioned in grass (or at least nearby) I can't make a function that will look for the color in a box around the spot we've found the tree, because it can be grass..

    Any suggestions? Plz post!

    However, here is the function:

    SCAR Code:
    program new;
    {.include srl/srl.scar}


    function CutTree(var x, y, color: integer): boolean;
    var
      TreeColor: integer;
      i: integer;
      tPoints: TPointArray;
      stPoints: TPointArrayArray;
    begin
      x:= MSCX;
      y:= MSCY;
      FindColorsSpiralTolerance(x, y, tPoints, 2047287, MSX1, MSY1, MSX2, MSY2, 10);
      stPoints:= TPAtoATPAEx(tPoints, 100, 30);
      for i:= 0 to GetArrayLength(stPoints) - 1 do
        tPoints[i]:= MiddleTPA(stPoints[i])
      for i:= 0 to GetArrayLength(tPoints) do
      begin
        MMouse(tPoints[i].x, tPoints[i].y, 2, 2);
        if IsUpTextMulti('Chop', 'own', 'ree') then
        begin
          result:= true;
          GetMousePos(x, y);
          Color:= GetColor(x, y);
          if random(10) < 7 then
          begin
            Mouse(x, y, 0, 0, True)
            Wait(200+random(100));
          end else
          begin
            Mouse(x, y, 0, 0, False);
            ChooseOption('Chop');
            Wait(200+random(100));
          end;
        exit;
        end;
      end;
    end;


    procedure Test;
    var
      Mark: longint;
      x, y, UpdatedTreeColor: integer;
    begin
      MarkTime(Mark);
      if CutTree(x, y, UpdatedTreeColor) then
      begin
        Writeln(inttostr(TimeFromMark(Mark))+'ms.');
        Writeln('Tree Found at '+inttostr(x)+'x, '+inttostr(y)+'y.');
        Writeln('Updated TreeColor: '+inttostr(UpdatedTreeColor));
      end else
      begin
        Writeln('Tree not found!');
      end;
    end;


    begin
    setupsrl;
    Test;
    end.

    Oh, a last note, it finds it aprox 800-1200 ms (including, w 200ms wait, uptextmulti finding, etc..)

    -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]

  2. #2
    Join Date
    Jan 2007
    Location
    USA
    Posts
    1,782
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thats about the time it should take for a player to click on the tree i guess.

    Join the fastest growing merchanting clan on the the net!

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Seems like you know the wizzuplugin a bit already

    About the tree gone part, just try using a color to detect if its gone or not... hehe.
    Administrator's Warning:


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

    Default

    Quote Originally Posted by Sumilion View Post
    Seems like you know the wizzuplugin a bit already

    About the tree gone part, just try using a color to detect if its gone or not... hehe.
    Yes I did, thanks to pwnaz0r (and actually a lil bit Markus too).

    Btw, color of what?? some unique color, because they are simular to the grass color..

    -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
    Jan 2007
    Location
    USA
    Posts
    1,782
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function FollowColor(var x, y: integer; Color: integer; acc: extended): boolean;
    var
      ColorMark, tries, found: integer;
    begin
      if not LoggedIn then exit; tries:= 0; found:= 0;
      MarkTime(ColorMark);
      while FlagPresent do
      begin
        if (TimeFromMark(ColorMark) >= 20000)then exit;
        if not LoggedIn then exit;
        Inc(tries);
        if FindColorSpiral(x, y, Color, x - 25, y - 25, x + 25, y + 25) then Inc(Found);
      end;
      result:= Acc <= (Found div Tries);
    end;

    Join the fastest growing merchanting clan on the the net!

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

    Default

    Quote Originally Posted by pwnaz0r View Post
    SCAR Code:
    function FollowColor(var x, y: integer; Color: integer; acc: extended): boolean;
    var
      ColorMark, tries, found: integer;
    begin
      if not LoggedIn then exit; tries:= 0; found:= 0;
      MarkTime(ColorMark);
      while FlagPresent do
      begin
        if (TimeFromMark(ColorMark) >= 20000)then exit;
        if not LoggedIn then exit;
        Inc(tries);
        if FindColorSpiral(x, y, Color, x - 25, y - 25, x + 25, y + 25) then Inc(Found);
      end;
      result:= Acc <= (Found div Tries);
    end;
    Wowah, thanks!! As color input I can use the color I gained using GetColor in my CutTree function

    Thanks!

    -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]

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Hmm, personally I use 3631459 with a tol of 20. But really I just picked any color that seemed quite general in the tree..
    Administrator's Warning:


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

    Default

    Quote Originally Posted by Sumilion View Post
    Hmm, personally I use 3631459 with a tol of 20. But really I just picked any color that seemed quite general in the tree..
    Ok, thanks for the information, I will try
    I'm trying pwnaz0r's function atm.
    [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]

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

    Default

    you hover the spot again and check for uptext

    but nice, clay. can you explain me tah same
    ~Hermen

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

    Default

    Good job!

    By the way do you and hermpie speak same language?

    Because I noticed that you two are about (no offense to anyone) scripters, though hermpie hasnt used wizzyplugin or FindColorsTolerance yet, so I think if atleast not to be able to do good team work, he could learn something from you

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

    Default

    Quote Originally Posted by n3ss3s View Post
    Good job!

    By the way do you and hermpie speak same language?

    Because I noticed that you two are about (no offense to anyone) scripters, though hermpie hasnt used wizzyplugin or FindColorsTolerance yet, so I think if atleast not to be able to do good team work, he could learn something from you
    Yes we do speak the same language
    And yes, I think he can learn something from m e, but.. I'm not really good in teaching people stuff.
    However thanks for your reply and, yes, I'm on my way to learn m ore things, use them and make scripts again.
    I have gain some knowledge scripting since I'm here (already for a year (h) ) and I want to test the things I know and make scripts again

    -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]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help with a function.
    By Floor66 in forum OSR Help
    Replies: 15
    Last Post: 04-15-2008, 02:03 PM
  2. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  3. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  4. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •