Results 1 to 8 of 8

Thread: My first wood cutter / burner

  1. #1
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default My first wood cutter / burner

    It isn't finished yet, and I would like some input on how to finish / improve.

    Code:
    program Kaede666_Cutter;
    {.include SRL/SRL/misc/SMART.scar}
    {.include SRL/SRL.scar}
    {.include SRL/SRL/Skill/WoodCutting.scar}
    var
      x, y, i, TreeWait, LogDTM, TinderDTM: integer;
      TreeTxT: array of string;
      TreeColors: array [0..3] of integer;
    
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Active:= True;
      Players[0].Strings[0] := ''; // normal, oak, willow, maple or yew
    end;
    
    procedure SetupVars;
    begin
      TinderDTM := DTMFromString('78DA63B4626060F8C48002DC6C39C0342394C' +
             'F6809249E33A0014654354E40E22D01358E40E20F01350640E217' +
             '01353A40E23D7E3500C7D1079A');
      LogDTM := DTMFromString('78DA634C656060F8C880025AD3EDC1342394C' +
            'F980B249E33A0014654359140E23701354540E2070135D140E215' +
            '0135D984ED0200C28E0950');
      case lowercase(Players[CurrentPlayer].Strings[0]) of
        'normal' : begin
                     writeln('selected');
                     TreeColors[0] := 462348;
                     TreeColors[1] := 798246;
                     TreeColors[2] := 1125158;
                     TreeColors[3] := 3036236;
                     TreeTxT := ['Tree', 'Tre', 'ree'];
                     TreeWait := 1000;
                     end;
        'oak'    : begin
                     TreeColors[0] := 2584416;
                     TreeColors[1] := 3305828;
                     TreeColors[2] := 4162678;
                     TreeColors[3] := 5544845;
                     TreeTxT := ['Oak', 'Oa', 'ak'];
                     TreeWait := 2000;
                   end;
        'willow' : begin
                     TreeColors[0] := 2181686;
                     TreeColors[1] := 6193521;
                     TreeColors[2] := 3755332;
                     TreeColors[3] := 3234376;
                     TreeTxT := ['Willow', 'Will', 'illo', 'llow'];
                     TreeWait := 3000;
                   end;
        'maple'  : begin
                     TreeColors[0] := 1319487;
                     TreeColors[1] := 725796;
                     TreeColors[2] := 2177124;
                     TreeColors[3] := 1385537;
                     TreeTxT := ['Maple', 'Map', 'apl', 'ple'];
                     TreeWait := 3500;
                   end;
        'yew'    : begin
                     TreeColors[0] := 3241318;
                     TreeColors[1] := 2119755;
                     TreeColors[2] := 2645844;
                     TreeColors[3] := 3240035;
                     TreeTxT := ['Yew', 'Ye', 'ew'];
                     TreeWait := 4500;
                   end;
      end;
    end;
    
    procedure Lightcheck;
    var Z: integer;
    begin
     MarkTime(Z);
     Repeat
           wait(10);
     Until (TimeFromMark(Z) > 3000); //Can't Figure out what the best way to know when it is lit
    end;
    
    procedure Burn;
    var tx, ty, lx, ly : integer;
    begin;       // Thanks to 99_
        if(FindDTM(TinderDTM, tx, ty, MIX1, MIY1, MIX2, MIY2) and
          FindDTM(LogDTM, lx, ly, MIX1, MIY1, MIX2, MIY2))then
            repeat
             Mouse(tx, ty, 2, 2, True);
             Wait(RandomRange(250, 500));
             Mouse(lx, ly, 2, 2, True);
             Wait(RandomRange(1000, 3000));//I've been trying to think of a better way to do this with color.. I'll get back to you on it ;)
            until(not(FindDTM(LogDTM, lx, ly, MIX1, MIY1, MIX2, MIY2)));
    end;        // End of Thanks =P
    
    Procedure Antiban;
    begin
      if not LoggedIn then Exit;
      case Random(22) of
        0:RandomRClick;
        1:HoverSkill('woodcutting',False);
        2:BoredHuman;
        3:RandomMovement;
        4:PickUpMouse;
        6:HoverSkill('firemaking', false);
       end;
    end;
    
    procedure TreeTime;
      var Failed: integer;
    begin
      if (not LoggedIn) then Exit;
      for i := 0 to 3 do
      begin
      if FindObjTPA(x, y, TreeColors[i], 30, 2, 15, 25, 10, TreeTxT) then
        repeat
          FindObjTPA(x, y, TreeColors[i], 30, 2, 15, 25, 10, TreeTxT)
          Wait(100 + Random(300));
          MMouse(x, y, 2, 2);
          begin
            Wait(200 + Random(400));
            case Random(2) of
              0: begin
                   Mouse(x, y, 4, 4, False);
                   Wait(250 + Random(200));
                   ChooseOption('hop');
                 end;
              1: begin
                   Mouse(x, y, 4, 4, True);
                 end;
            end;
            Wait(TreeWait + Random(200));
            FindObjTPA(x, y, TreeColors[i], 30, 2, 15, 25, 10, TreeTxT)
            MMouse(x, y, 2, 2);
            AntiBan;
            if not (LoggedIn) then
              NextPlayer(False);
              LoginPlayer;
          end;
          until Invfull or not FindObjTPA(x, y, TreeColors[i], 30, 2, 15, 25, 10, TreeTxT);
          while (not FindObjTPA(x, y, TreeColors[i], 30, 2, 15, 25, 10, TreeTxT)) do
            repeat
              MakeCompass('N');
              Wait(300 + Random(300));
              if (not FindObjTPA(x, y, TreeColors[i], 30, 2, 15, 25, 10, TreeTxT)) then
                MakeCompass('E');
                Wait(300 + Random(300));
                MakeCompass('S');
                Wait(300 + Random(300));
                MakeCompass('W');
                Wait(300 + Random(300));
                Inc(Failed);
            until FindObjTPA(x, y, TreeColors[i], 30, 2, 15, 25, 10, TreeTxT) or (Failed = 5);
            if (Failed = 5) then
            begin
              WriteLn('Tree Finding Failed :(');
              NextPlayer(False);
            end;
        end;
      end;
    end;
    
    begin
      SetUpSRL;
      SMARTSetUpEX(1, False, True, False);
      SetTargetDC(SMARTGetDC);
      ActivateClient;
      ClearDebug;
      setupvars;
      declareplayers;
      loginplayer;
      Wait(500 + Random(300));
      if(not(loggedin)) then
       repeat
       loginplayer;
       wait(random(600));
       until(loggedin);
      MakeCompass('S');
      SetAngle(True);
       repeat;
        TreeTime;
        case Random(5) of
          2:Antiban;
          end;
       if (invfull) then Burn;
       Wait(100 + Random(300));
      until(false);
    end.
    Last edited by Kaede666; 07-26-2009 at 08:38 AM. Reason: Updated code

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

    Default

    o.o

    this is honestly unbelievable for your first script.. you should use DTMs for lighting btw

    honestly.. if I had a say in anything here I would want you to apply ASAP <3

  3. #3
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I have never really tried using DTM's, how would I go about doing that?

  4. #4
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    when you do "for i := 2 to 28 do" blah blah.. you could do..

    SCAR Code:
    if(FindDTM(TinderDTM, tx, ty, MIX1, MIY1, MIX2, MIY2))then
      if(FindDTM(LogDTM, lx, ly, MIX1, MIY1, MIX2, MIY2))then
        repeat
          Mouse(tx, ty, 2, 2, True);
          Wait(RandomRange(25, 50));
          Mouse(lx, ly, 2, 2, True);
          Wait(RandomRange(1000, 3000));//I've been trying to think of a better way to do this with color.. I'll get back to you on it ;)
        until(not(FindDTM(LogDTM, lx, ly, MIX1, MIY1, MIX2, MIY2)));


  5. #5
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for that, I added it to my script, with proper thanks =p

    I think I've almost got it running!

    Edit: How would I go about finding the DTM's of the items -.-'

  6. #6
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    haha

    have the items in your inventory..

    then go to SCAR..

    Tools > DTM Editor..

    make sure SCAR is below the items in the inventory btw

    then click the center of the item (doesn't have to be exact ) and then make about 5 points on the outside of the item.. and the color should be black, the number of the color should be 63556 or 65536.. one of those.. lol it has the numbers 3 5 and 6 >.>

    then on the right side of the editor (you can check the colors of the points too.. the first one should be whatever.. anything besides 65536.. and the other points should be 65536 if they aren't, delete the points.. as long as there is about 4 points it should be fine) and make the tolerance 255

    sorry if this is confusing :/

    talk to me on MSN if you can..

    panic._@live.com

  7. #7
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Feel free to check out my Chop&Burn, you might find some useful stuff there. To see if the logs are successfully burned, i turn off chats and try to find either "You can't light the logs" or "The fire lights up" (or whatever the texts are). Color based fire finder is bit more complicated, but i think i'll make a function for that. I can post it here then.

    If this really is your first script, then wow. i am amazed.

  8. #8
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'd love to check out your script, but I can't yet. I don't have the permissions to.

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
  •