Results 1 to 8 of 8

Thread: A few problems...

  1. #1
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Wink A few problems...

    Okay, so I think I'm getting closer... but here's the problem:

    It finds the trees and starts chopping, and writes in "The tree has been cut down." (which is more then what it did last time ). However, it doesn't continue chopping? << I seem to have fixed this problem, and it works most of the time, but sometimes it clicks another tree while I'm still chopping, or does "spazzic" motions across the screen to every color it finds.

    And, Nava2 tried to explain it to me, but I didn't really understand what he was saying. In my progress report, the part where I want it to say how many logs/loads it's done for each player doesn't work. It says the total logs and total loads like I want it, but for each player, it just says 0. It would be this part that doesn't work: << Still haven't fixed this.

    SCAR Code:
    + PadR(IntToStr(Players[i].Integers[9]), 11)
    + PadR(IntToStr(Players[i].Integers[10]), 11) + '|');

    One more thing. I don't know for sure if the multiplayer is right. If someone could just check it over that'd be great. << Still not sure, it seems to be working pretty well.

    Also, if you notice something else wrong in the script please tell me. Or even if there's a shorter way of saying it. I want my script to run as smooth as possible.

    SCAR Code:
    program PowerChopper;
      {.Include SRL\SRL\Misc\SMART.SCAR}
      {.include SRL\SRL.scar}
      //{.include SRL\SRL\Misc\Debug.scar}

    var
      HatchetDTM : Array of Integer;
      x, y, c, NumOfLogs, TotalProggies : Integer;
      TreeColor : TIntegerArray;
      TreePoint : TPoint;
     
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Active := True;
      Players[0].Pin := '';
      Players[0].Strings[0] := 'willow';//Which tree to cut?
      Players[0].Integers[0] := 27;//How many logs to cut?
      Players[0].BoxRewards := ['Xp', 'mote', 'ostume'];
     
     {Players[1].Name := '';
      Players[1].Pass := '';
      Players[1].Nick := '';
      Players[1].Active := True;
      Players[1].Pin := '';
      Players[1].Strings[0] := '';//Which tree to cut?
      Players[1].Integers[0] := 000;//How many logs to cut?
      Players[1].BoxRewards := ['Xp', 'mote', 'ostume'];}

    end;

    procedure S_FindRandoms;
    begin
      LampSkill := 'woodcutting';
      FindNormalRandoms;
    end;

    procedure S_MyAntiBan;
    begin
      case Random(70) of
        0: RandomMovement;
        1: BoredHuman;
        2: HoverSkill('random', false);
        3: RandomRClick;
        4: begin
             case Random(2) of
               0: begin
                    KeyDown(VK_RIGHT);
                    Wait(50 + Random(1300));
                    KeyUp(VK_RIGHT);
                    Wait(60 + Random(2000));
                    KeyDown(VK_LEFT);
                    Wait(70 + Random(1100));
                    KeyUp(VK_LEFT);
                  end;
               1: begin
                    KeyDown(VK_LEFT);
                    Wait(50 + Random(1300));
                    KeyUp(VK_LEFT);
                    Wait(60 + Random(2000));
                    KeyDown(VK_RIGHT);
                    Wait(70 + Random(1100));
                    KeyUp(VK_RIGHT);
                  end;
              end;
           end;
        5: begin
             KeyDown(VK_LEFT);
             Wait(100 + Random(1200));
             KeyUp(VK_LEFT);
           end;
        6: begin
             KeyDown(VK_RIGHT);
             Wait(150 + Random(1100));
             KeyUp(VK_RIGHT);
           end;
        7..69:
      end;
    end;


    procedure S_HatchetDTMs;
    begin
     SetArrayLength(HatchetDTM, 7);//[0]:= Bronze, [6]:= Rune
       HatchetDTM[0] := DTMFromString('78DA630C646260D8C4C8800C7CAC9519F8813' +
           '44C94D113A86617AA1A982C5C8D1B50CD36026ABC816AD6125013' +
           '0C54B38E809A504C3763A80921EC1E00949107EF');
       HatchetDTM[1] := DTMFromString('78DA630C626260D8C4C8800C02BDBD19F8813' +
           '448F43F1030BA03D5EC47550391859140DA0DA8662B01355E4035' +
           '6B09A80906AA5947404D2850CD06026A42806AB6E157030033F30' +
           'C28');
       HatchetDTM[2] := DTMFromString('78DA630C626260D8C8C8800CCAF3F318F8813' +
           '448F43F10307A02D5EC40550391859140DA0DA8660B01355E4035' +
           '6B09A80904AA5947404D28A69BB1AAD98A5F0D0090050C8D');
       HatchetDTM[3] := DTMFromString('78DA63F4676260D8C0C8800C44454418F8813' +
           '448F43F1030BA03D5EC43550391859140DA05A8661701351E4035' +
           'EB09A80900AA5947404D28A69BB1AAD98A5F0D0095870B78');
       HatchetDTM[4] := DTMFromString('78DA630C646260D8C8C8800C1C1CE319F8813' +
           '44C94D10DA8E600AA1A982C5C8D2B50CD0E026A3C806A36105013' +
           '0054B38E809A504C3763A80901AAD9865F0D00C5940824');
       HatchetDTM[5] := DTMFromString('78DA63EC64626038C0C8800C9C829D18F8813' +
           '44C94B101A8E614AA1A982C8A9A7D04D4F402D5EC2742CD21026A' +
           '6A816AAEE05703006FA208C7');
       HatchetDTM[6] := DTMFromString('78DA630C606260D8C8C8800C5CA2531944803' +
           '44C94D11DA8662FAA1A982C5C8D1B50CD56026ABC806AD6125013' +
           '0C54B38E809A504C3763A80901AAD9865F0D00E749084A');
    end;

    procedure Cut_FindHatchet;
    var
      b: Boolean;
      i: Integer;
    begin
      GameTab(4);
      for i:= 0 to 6 do
        if(FindDTM(HatchetDTM[i], x, y, MIX1, MIY1, MIX2, MIY2))then
        begin
          b:= True;
          Break;
        end;
        if(b = True)then
          Writeln('Found hatchet.')
        else
        begin
          Writeln('Didn''t find hatchet, logging out.');
          Wait(80 + Random(100));
          LogOut;
          Players[CurrentPlayer].Active := False;
          Exit;
        end;
      FreeDTM(HatchetDTM[i]);
    end;

    procedure Cut_TreeColors;
    begin
      SetArrayLength(TreeColor, 4);
          TreeColor := [6266770, 1199164, 7774605, 1718835];
      case LowerCase(Players[CurrentPlayer].Strings[0]) of
        'tree': c := 0;
        'oak': c := 1;
        'willow': c := 2;
        'yew': c := 3;
      else
        begin
          Players[CurrentPlayer].Active := False;
          Writeln('No tree specified, logging out.');
          Wait(80 + Random(100));
          Logout;
          Exit;
        end;
      end;
    end;

    function Cut_TreeCutDown: Boolean;
    var
      TrCols : TPointArray;
    begin
      FindColorsTolerance(TrCols, TreeColor[c], TreePoint.x - 25, TreePoint.y - 25, TreePoint.x + 25, TreePoint.y + 25, 15);
      if(Length(TrCols) < 10)then
      begin
        Writeln('Tree has been cut down.');
        Result := True;
      end;
    end;

    procedure Cut_ChopTrees;
    var
      fx, fy, k : Integer;//fx, fy : Temp. coords.
      s, e : String;
      TPA : TPointArray;
      T2D : T2DPointArray;
    begin
      ColorToleranceSpeed(2);
      repeat
        FindColorsSpiralTolerance(fx, fy, TPA, TreeColor[c], MSX1, MSY1, MSX2, MSY2, 15);//Stores the color's x, y coords as TPoints.
        T2D := SplitTPAEx(TPA, 6, 6);//Splits TPA into boxes.
        //DebugATPA(T2D, '');
        if Length(T2D) = 0 then Exit;
        SortATPAFromFirstPoint(T2D, Point(MSCX, MSCY));

        for k := 0 to High(T2D) do
        begin
          //Writeln('Length:' + IntToStr(Length(T2D[k])));
          if(Length(T2D[k]) < 50)then Continue;
          MiddleTPAEx(T2D[k], fx, fy);//Stores coords of the middle TPointArray to x, y.
          Wait(30 + Random(20));
          MMouse(fx, fy, 4, 4);
          s := RS_GetUpText;
          e := Players[CurrentPlayer].Strings[0];
          if((Pos('hop', s) > 0) and (Pos(Copy(e, 2, Length(e)), s) > 0))then
          begin
            GetMousePos(x, y);
            Wait(80 + Random(100));
            Mouse(x, y, 4, 4, True);
            TreePoint := IntToPoint(x, y);
            repeat
              S_MyAntiBan;
              Wait(80 + Random(5000));
            until(Cut_TreeCutDown);
          //until(not(IsUpText('hop')) or (InvFull));
          end;
        end;
      until(InvFull or not(LoggedIn));
      ColorToleranceSpeed(1);
    end;

    procedure Cut_DropLogs;
    var a : Integer;
    begin
      if(InvFull)then
      begin
        Wait(80 + Random(100));
        for a := 2 to 28 do
          DropItem(a);
        NumOfLogs := NumOfLogs + 27;
        if(NumOfLogs >= Players[CurrentPlayer].Integers[0])then
        begin
          Players[CurrentPlayer].Active := False;
          Writeln('Cut desired number of logs, logging out.');
          Wait(80 + Random(100));
          Logout;
          Exit;
        end;
      end;
      S_FindRandoms;
    end;

    {****************************
     Function Prg_PlayerActivity;
     By: Drags111
     ****************************}


    function F_PlayerActive(I : Integer): String;
    begin
      if Players[i].Active then Result := 'T' else Result := 'F';
    end;

    procedure F_ProgReport;
    var
      i : Integer;
    begin
      Inc(TotalProggies);
      Writeln(' _______________________________________________');
      Writeln(PadR('|            Coh3n''s Power Chopper', 48) + '|');
      Writeln('|_________________First Script__________________|');
      Writeln('|                                               |');
      Writeln(PadR('|  Time run: ' + TimeRunning, 48) + '|');
      Writeln(PadR('|  Loads: ' + IntToStr(NumOfLogs / 27), 48) + '|');
      Writeln(PadR('|  Logs: ' + IntToStr(NumOfLogs), 48) + '|');
      Writeln('|_______________________________________________|');
      Writeln('|________________Player''s Stats_________________|');
      Writeln('|      ____      ___      _____      ____       |');
      Writeln('|      Nick      T/F      Loads      Logs       |');
      Writeln('|      ¯¯¯¯      ¯¯¯      ¯¯¯¯¯      ¯¯¯¯       |');
      for i := 0 to High(Players)do
        Writeln('|      ' + PadR(Players[i].Nick, 10) + PadR(F_PlayerActive(i), 9)
                          + PadR(IntToStr(Players[i].Integers[9]), 11)
                          + PadR(IntToStr(Players[i].Integers[10]), 11) + '|');
      Writeln('|_______________________________________________|');
    end;

    procedure F_Setup;
    begin
      SMARTSetupEx(152, False, True, False);
      Wait(5000);
      SetTargetDC(SmartGetDC);
      SetupSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
      SetAngle(True);
      S_HatchetDTMs;
      Cut_FindHatchet;
    end;


    begin
      F_Setup;
      repeat
        repeat
          if(ExistsItem(1))then
          begin
            Cut_TreeColors;
            repeat
              Cut_ChopTrees;
              S_FindRandoms;
            until(InvFull);
            Cut_DropLogs;
            F_ProgReport;
          end;
        until(NumOfLogs >= Players[CurrentPlayer].Integers[0])or(not LoggedIn);
        NextPlayer(False);
      until False;
      TerminateScript;
    end.

    Thanks everyone!
    Last edited by Coh3n; 06-08-2009 at 10:40 PM.

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Elaborate on what the progress report does wrong please .

  3. #3
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Your New Main Loop:
    SCAR Code:
    begin
      F_Setup;
      repeat
        repeat
          if(ExistsItem(1))then
          begin
            Cut_TreeColors;
            repeat
              Cut_ChopTrees;
              S_FindRandoms;
            until(InvFull);
            Cut_DropLogs;
            NumOfLogs := NumOfLogs + 27; // Take this out of the other proc/func it was in.
            F_ProgReport;
          end;
        until(NumOfLogs >= Players[CurrentPlayer].Integers[0])or(not LoggedIn);
        NextPlayer(False);
      until False;
    end.
    Last edited by NCDS; 06-08-2009 at 09:38 AM.

  4. #4
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    WELL first of all:
    SCAR Code:
    until(TreeChopedDown = True)
    can be
    [scar]until(TreeChopedDown);
    it just looks alot nicer :]

    Oh i see what your doing, alot like what i was doing with my yew chopper, only your doing it wrong XD ok so first of all:

    SCAR Code:
    FindColorsTolerance(TrCols, TreeColor[c], x - 20, y - 20, x + 20, y + 20, 12);

    will surch for the colors within a box 20 pixles around the point (x, y) but.. you dont realy say where that point is. so pretty much the point is either (0, 0) or what ever the last values for x and y were.

    Im guessing you want to surch for the Trees colors within a 20 pixle box around the area you clicked on the tree? well what you want to do then is make a TPoint of the point you clicked on so you can use it later, something like this:

    SCAR Code:
    tree cutting function thing...
    blah blah blah
    Mouse(x, y, 2, 2, 0);//Right after your click on the tree
    TreePoint := IntToPoint(x, y);//Then have a TPoint

    so later when you have your function that checks if your tree is still there you can do this:

    SCAR Code:
    function Cut_TreeCutDown: Boolean;
    var
      TrCols : TPointArray;
      c : Integer;
    begin
      FindColorsTolerance(TrCols, TreeColor[c], TreePoint.x - 20, TreePoint.y - 20, TreePoint.x + 20, TreePoint.y + 20, 12);
      if(Length(TrCols) = 0)then Exit;
      if(Length(TrCols) < 10)then
      begin
        Writeln('Tree has been cut down.');
        Result := True;
      end;
    end;
    Lance. Da. Pants.

  5. #5
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function Cut_TreeCutDown(x, y : integer) : Boolean;
    var
      TrCols : TPointArray;
      c : Integer;
    begin
      FindColorsTolerance(TrCols, TreeColor[c], x - 20, y - 20, x + 20, y + 20, 12);
      if(Length(TrCols) = 0)then Exit;
      if(Length(TrCols) < 10)then
      begin
        Writeln('Tree has been cut down.');
        Result := True;
      end;
    end;
    That way you can pass the variable through with it being a local variable. In the procedure where you chop or whatever you just do
    SCAR Code:
    until(Cut_TreeCutDown(x, y));
    Or something like that.

    Actually, you can do that with the colors and stuff...

  6. #6
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    Elaborate on what the progress report does wrong please .
    Okay, I tried.

    Quote Originally Posted by NCDS View Post
    Your New Main Loop:
    SCAR Code:
    NumOfLogs := NumOfLogs + 27; // Take this out of the other proc/func it was in.
    But if I took that out of the original function, it wouldn't do this

    SCAR Code:
    NumOfLogs := NumOfLogs + 27;
        if(NumOfLogs >= Players[CurrentPlayer].Integers[0])then
        begin
          Players[CurrentPlayer].Active := False;
          Writeln('Cut desired number of logs, logging out.');
          Wait(80 + Random(100));
          Logout;
          Exit;
        end;

    am I right?

    Quote Originally Posted by lancerawks View Post
    WELL first of all:
    SCAR Code:
    until(TreeChopedDown = True)
    can be
    SCAR Code:
    until(TreeChopedDown);
    it just looks alot nicer :]
    Thanks.

    Quote Originally Posted by lancerawks View Post
    Im guessing you want to surch for the Trees colors within a 20 pixle box around the area you clicked on the tree?
    Yes! I knew I needed something like that because what I was doing wasn't really making any sense. Lol. Thanks.

    Quote Originally Posted by Da 0wner View Post
    Actually, you can do that with the colors and stuff...
    Huh? Lol.



    ^I updated the first post.
    Last edited by Coh3n; 06-08-2009 at 10:48 PM.

  7. #7
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    For your progress report problem it would be because you do not increment it since you said it is always zero.

  8. #8
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    For your progress report problem it would be because you do not increment it since you said it is always zero.
    Hmm, okay thanks.

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
  •