Page 5 of 6 FirstFirst ... 3456 LastLast
Results 101 to 125 of 126

Thread: Ivy Chopper Ultra !

  1. #101
    Join Date
    Feb 2012
    Posts
    21
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    no point
    Last edited by blindout; 09-25-2014 at 06:59 PM.

  2. #102
    Join Date
    Aug 2014
    Location
    Michigan, USA
    Posts
    138
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Why does this chopper switch the ivys I chop while still chopping the first one? looks super bot like if you ask me.
    It redirected me to the next ivy after like 10 seconds....?
    HELP?!

    EDIT:
    Changed line 90
    "FindOwnIvy := True; // Tries to find an unoccupied ivy if set to 'true'"
    to
    "FindOwnIvy := False; // Tries to find an unoccupied ivy if set to 'true'"

    Works now. (:


    ALSO:

    Does not loot at all.
    HELP?
    Last edited by xSorrels; 09-19-2014 at 02:33 AM.

  3. #103
    Join Date
    Sep 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I am getting this error now whenever I try and run the program, "Exception in Script: Duplicate declaration "getXP" at line 787, column 35", I had it running for almost a week then this happens last night! Any help?

  4. #104
    Join Date
    Jul 2014
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    Quote Originally Posted by capnfox View Post
    I am getting this error now whenever I try and run the program, "Exception in Script: Duplicate declaration "getXP" at line 787, column 35", I had it running for almost a week then this happens last night! Any help?
    Same.

  5. #105
    Join Date
    Aug 2014
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    ^^^ please help

  6. #106
    Join Date
    Sep 2014
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Also getting the duplicate declaration error

  7. #107
    Join Date
    Oct 2013
    Posts
    56
    Mentioned
    0 Post(s)
    Quoted
    28 Post(s)

    Default

    To all wondering about that duplication error, just delete that part of the script for the time being until it is fixed, all it means is that xp wont be counted if im right. Works perfectly fine without it

  8. #108
    Join Date
    Jul 2014
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default

    /-------------------------------------------------------------\
    |-------------------------------------------------------------|
    | Press Play's |
    | Ivy Chopper Ultra |
    | Version 1.10 |
    |-------------------------------------------------------------|
    | TOTALS : |
    | Time Running : 12 hr 11 min 30 sec |
    | Exp Gained : 788690 |
    | Nests Gotten : 4 |
    | |
    | PLAYER 0 : |
    | Time Running : 11 hr 21 min 37 sec |
    | Exp Gained : 788690 |
    | Exp / Hour : 69424 |
    | |
    | |
    |-------------------------------------------------------------|
    \-------------------------------------------------------------/
    99's Achieved using Simba
    - 99 Divination thanks to AIO Divination script by Solaire
    - 99 Woodcutting thanks to IvyChopperUltra and Draynor Chop N' Bank by Press Play and Coh3n

  9. #109
    Join Date
    Sep 2014
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just got 70 to 99 woodcutting off this script from north fally wall. Works amazing.

  10. #110
    Join Date
    Jul 2014
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default

    /-------------------------------------------------------------\
    |-------------------------------------------------------------|
    | Press Play's |
    | Ivy Chopper Ultra |
    | Version 1.10 |
    |-------------------------------------------------------------|
    | TOTALS : |
    | Time Running : 2 hr 17 min 20 sec |
    | Exp Gained : 175395 |
    | Nests Gotten : 2 |
    | |
    | PLAYER 0 : |
    | Time Running : 2 hr 17 min 18 sec |
    | Exp Gained : 175395 |
    | Exp / Hour : 76639 |
    | |
    | |
    |-------------------------------------------------------------|
    \-------------------------------------------------------------/
    99's Achieved using Simba
    - 99 Divination thanks to AIO Divination script by Solaire
    - 99 Woodcutting thanks to IvyChopperUltra and Draynor Chop N' Bank by Press Play and Coh3n

  11. #111
    Join Date
    Jul 2014
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default

    Why does the bot now rotate the angle of the camera to far so it no longer looks at the ivy?

    EDIT: Nvm it was my fault I messed up a value
    99's Achieved using Simba
    - 99 Divination thanks to AIO Divination script by Solaire
    - 99 Woodcutting thanks to IvyChopperUltra and Draynor Chop N' Bank by Press Play and Coh3n

  12. #112
    Join Date
    Jul 2014
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default

    Thanks alot for this script, got 99 WC this morning
    99's Achieved using Simba
    - 99 Divination thanks to AIO Divination script by Solaire
    - 99 Woodcutting thanks to IvyChopperUltra and Draynor Chop N' Bank by Press Play and Coh3n

  13. #113
    Join Date
    Aug 2013
    Posts
    159
    Mentioned
    4 Post(s)
    Quoted
    90 Post(s)

    Default

    Fantastic script, got me from 73-80(40k off 81) and I plan on using it to 99 but I'm not going to suicide it anymore than I already have.

    Progress Report Details: I had a little bit of bonus exp at the start but I ran it so long that the average should be accurate. Also, it was double exp when I did this and a rune hatchet.(Gave about 960ish exp with double exp and bonus exp per ivy)

    /-------------------------------------------------------------\
    |-------------------------------------------------------------|
    | Press Play's |
    | Ivy Chopper Ultra |
    | Version 1.10 |
    |-------------------------------------------------------------|
    | TOTALS : |
    | Time Running : 9 hr 34 min 18 sec |
    | Exp Gained : 1103449 |
    | Nests Gotten : 5 |
    | |
    | PLAYER 0 : |
    | Time Running : 9 hr 38 sec |
    | Exp Gained : 1103449 |
    | Exp / Hour : 122458 |
    | |
    | |
    |-------------------------------------------------------------|
    \-------------------------------------------------------------/

    Edit: Another Progressive Report: 81-85 with a dragon hatchet plus I went about 20 minutes over after leveling up.

    /-------------------------------------------------------------\
    |-------------------------------------------------------------|
    | Press Play's |
    | Ivy Chopper Ultra |
    | Version 1.10 |
    |-------------------------------------------------------------|
    | TOTALS : |
    | Time Running : 7 hr 50 min 18 sec |
    | Exp Gained : 1050035 |
    | Nests Gotten : 5 |
    | |
    | PLAYER 0 : |
    | Time Running : 7 hr 21 min 33 sec |
    | Exp Gained : 1050035 |
    | Exp / Hour : 142681 |
    | |
    | |
    |-------------------------------------------------------------|
    \-------------------------------------------------------------/

  14. #114
    Join Date
    Aug 2012
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hi,

    Was using this script for a while until I encountered the following error which kills off the script:

    Error: No default value for parameter 3 found at line 1105
    Compiling failed.

    Anyone encountered the same issue as me?

  15. #115
    Join Date
    Apr 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Hello!

    I think I'm doing something wrong...just not sure what
    I keep getting this error...


    Error: No default value for parameter 3 found at line 1105
    Compiling failed.


    I set up the password and username as instructed. Re installed simba, etc and still same error.

  16. #116
    Join Date
    Nov 2014
    Posts
    50
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    This script is fantastic however i have never had to babysit so much in my life. If or whenever i have to come back from a break or log in, the camera adjust part just spins around and around for about 15 seconds then ends up not looking at the ivy whatsoever. If i do not fix the camera angle from there, it simply will not work.

    Btw Thank you very very much, i got 99 with the script from i think 78.
    Last edited by taylar; 11-18-2014 at 05:45 AM.

  17. #117
    Join Date
    Dec 2014
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I am very new to this stuff, and it can't figure out my loginName on line 105? I put it in correctly, help?

  18. #118
    Join Date
    Dec 2014
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    changed it to smart8 now i get this "Error: Unknown declaration "smartSetupDrawing" at line 860" but if i keep without the 8 it says No default value for parameter 3 found at line 1105.... Haven't been able to get 1 ivy chopper working ):

  19. #119
    Join Date
    Aug 2013
    Posts
    159
    Mentioned
    4 Post(s)
    Quoted
    90 Post(s)

    Default

    I changed a few lines to get it to run, it appears a bit outdated.

    Progress Report:
    /-------------------------------------------------------------\
    |-------------------------------------------------------------|
    |                        Press Play's                         |
    |                      Ivy Chopper Ultra                      |
    |                        Version 1.10                         |
    |-------------------------------------------------------------|
    |     TOTALS :                                                |
    |       Time Running  : 8 hr 53 min 9 sec                     |
    |       Exp Gained    : 614552                                |
    |       Nests Gotten  : 8                                     |
    |                                                             |
    |     PLAYER 0 :                                              |
    |       Time Running  : 8 hr 21 min 8 sec                     |
    |       Exp Gained    : 614552                                |
    |       Exp / Hour    : 73579                                 |
    |                                                             |
    |                                                             |
    |-------------------------------------------------------------|
    \-------------------------------------------------------------/


    Edit: Here is the script, this should work for any of you that our having the "Error: No default value for parameter 3 found at line 1105
    Compiling failed." problem.

    Simba Code:
    program IvyChopperUltra;
    {$DEFINE SMART}
    {$I SRL-6/SRL.Simba}

    {$DEFINE DEBUG}
    {$DEFINE PAINT}
    {$DEFINE SCREENSHOT}
    {$DEFINE SCREENSHOT_NEST}

    {



                      8888888b.
                      888   Y88b
                      888    888
                      888   d88P 888d888 .d88b.  .d8888b  .d8888b
                      8888888P"  888P"  d8P  Y8b 88K      88K
                      888        888    88888888 "Y8888b. "Y8888b.
                      888        888    Y8b.          X88      X88
                      888        888     "Y8888   88888P'  88888P'



                            8888888b.  888
                            888   Y88b 888
                            888    888 888
                            888   d88P 888  8888b.  888  888
                            8888888P"  888     "88b 888  888
                            888        888 .d888888 888  888
                            888        888 888  888 Y88b 888
                            888        888 "Y888888  "Y88888
                                                         888
                                                    Y8b d88P
                                                     "Y88P"



    +------------------------------------------------------------------------------+


              _   _      _         __    _     ___   ___   ___   ____  ___
             | | \ \  / \ \_/     / /`  | |_| / / \ | |_) | |_) | |_  | |_)
             |_|  \_\/   |_|      \_\_, |_| | \_\_/ |_|   |_|   |_|__ |_| \
                             _     _    _____  ___    __
                            | | | | |    | |  | |_)  / /\
                            \_\_/ |_|__  |_|  |_| \ /_/--\



    +------------------------------------------------------------------------------+
    }


    { ~~ Global Variables ~~ }
    var
      x, y: Integer;
      WhenBreak, HowManyPlayers: Integer;
      FindOwnIvy: Boolean;

    const
    { *** For Players}
      P_WALL_DIR    = 0;
    { *** For Report}
      P_XP          = 1;
      P_NESTS       = 2;
      P_START_XP    = 3;
      P_FIRST_LOGIN = 4;

    { *** For Directions}
      DIR_NORTH = 0;
      DIR_EAST  = 90;
      DIR_SOUTH = 180;
      DIR_WEST  = 270;

    {==============================================================================}
    {  START START   START START     START START       START START    START START  }
    {  START            START       START   START      START      |      START     }
    {  START START      START      START --- START     START START       START     }
    {        START      START     START       START    START  START      START     }
    {  START START      START     START       START    START   START     START     }
    {==============================================================================}

    {------------------------------------------------------------------------------]
    [  VARIBLE SETUP:                                                              ]
    [     See the thread for details.                                              ]
    [------------------------------------------------------------------------------}

    procedure LoadGlobals;
    begin
      WhenBreak     := 240;   // Minutes until break
      FindOwnIvy    := True;  // Tries to find an unoccupied ivy if set to 'true'
    end;

    {------------------------------------------------------------------------------]
    [  DECLARE PLAYERS:                                                            ]
    [     Change accordingly.                                                      ]
    [------------------------------------------------------------------------------}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      setLength(players, HowManyPlayers);
      CurrentPlayer := 0;

      with Players[0] do
      begin
        loginName            :='';           // Username
        password             :='';           // Password
        integers[P_WALL_DIR] := DIR_SOUTH;   // The direction your player faces to chop the ivy
        isMember             := true;
        isActive             := true;
        world                := -1;
      end;
    end;

    {==============================================================================}
    {                STOP STOP   STOP STOP   STOP-STOP    STOP STOP                }
    {                STOP           STOP     STOP STOP    STOP    |                }
    {      =====     STOP STOP      STOP     STOP STOP    STOP STOP     =====      }
    {                     STOP      STOP     STOP STOP    STOP                     }
    {                STOP STOP      STOP     STOP-STOP    STOP                     }
    {==============================================================================}

    const
      ScriptVersion = '1.10';
      ScriptName    = 'Ivy Chopper Ultra';

    { ~~ The following options are not recommended to change
         unless you have a well rounded scripting ability ~~ }


      LaggFactor    = 3;      // [1 = no lagg, 3 = default, 10 = HOLY S**T]
      logoutDelay   = 0;      // Wait before logging out; for debugging
    type
      TotalStatistics = record
        XP, Nests: Integer;
      end;

      TBooleanFunction = function(): boolean;

    var
      TotalTimeInactive: Integer;  // Time
      RoundTime: TTimeMarker;
      Total: TotalStatistics;
      PlayerStartXP: Integer;
      reportString: TStringArray;

    {$IFNDEF CODEINSIGHT}
    //============================================================================//
    // Utility functions:
    //----------------------------------------------------------------------------//
    //============================================================================//
    // procedure debug(w: string);
    //   -Prints debug if DEBUG is defined.
    //============================================================================//
    procedure debug(w: string; lvl: Integer);
    var
      i: Integer;
    begin
      {$IFDEF DEBUG}
        if lvl > 1 then
        begin
          w := '-' + w;
          for i := 1 to lvl-1 do
            w := '  ' + w;
        end;
        writeln(w);
      {$ELSE}
        status(w);
      {$ENDIF}
    end;

    //============================================================================//
    // procedure DebugScreen(reason: String);
    //   -Saves a screenshot to 'reason' if SCREENSHOT is defined.
    //============================================================================//
    procedure DebugScreen(reason: String);
    var
      bmpF, i: Integer;
      TPAName, TPAStats: TPointArray;
    begin
      {$IFDEF SCREENSHOT}
        if not DirectoryExists(ScriptPath + 'Screenshots/') then
          if not CreateDirectory(ScriptPath + 'Screenshots/') then
            Exit;

        bmpF := BitmapFromClient(0, 0, minimap.getBounds().x2+1, chatbox.getBounds().y2+1);
        TPAName := TPAFromBox(IntToBox(chatbox.getChatArea().X1, chatbox.getChatArea().Y2, chatbox.getChatArea().X2, chatbox.getBounds().Y2));
        TPAStats := TPAFromBox(actionbar.getBounds());
        for i := 0 to High(TPAName) do
          FastSetPixel(bmpF, TPAName[i].x, TPAName[i].y, clWhite);
        for i := 0 to High(TPAStats) do
          FastSetPixel(bmpF, TPAStats[i].x, TPAStats[i].y, clWhite);

        SaveBitmap(bmpF, ScriptPath + 'Screenshots/' +reason+ '.png');
        //SaveScreenshot(ScriptPath + 'Screenshots/' +reason+ '.png');
        Debug('Screenshot saved.', 0);
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintClear(area: TBox);
    //   -Clears the 'area' on SMART.
    //============================================================================//
    procedure paintClear(area: TBox);
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.clearArea(area);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintClear(); overload;
    //   -Clears everything on SMART.
    //============================================================================//
    procedure paintClear(); overload;
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.drawClear(0);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintTPA(pts: TPointArray; col: Integer);
    //   -Paints TPA to SMART with colour 'col'
    //============================================================================//
    procedure paintTPA(pts: TPointArray; col: Integer);
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.DrawTPA(pts, col);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintBox(pts: TBox;  col: Integer);
    //   -Paints box to SMART with colour 'col'
    //============================================================================//
    procedure paintBox(pts: TBox;  col: Integer);
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.DrawBox(pts, col);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // function PointToStr(P: TPoint): String;
    //   -Turns a TPoint variable into a String variable in the format: (x, y).
    //============================================================================//
    function PointToStr(P: TPoint): String;
    begin
      Result := ('('+IntToStr(P.x)+', '+IntToStr(P.y)+')');
    end;

    //============================================================================//
    // function overTime(theTime: TTimeMarker; theLimit: LongInt): boolean;
    //   -'theTime' is the TTimeMarker with the stored time.
    //   -'theLimit' is the amount of time which 'theTime'(ms) must exceed to
    //    return true.
    //============================================================================//
    function overTime(theTime: TTimeMarker; theLimit: LongInt): boolean;
    begin
      result := (theTime.getTime() > theLimit);
    end;

    function IsIvyAhead_Mouse: Boolean; forward;
    //============================================================================//
    // procedure doAntiBan();
    //   -Performs generic antiban procedure.
    //============================================================================//
    procedure doAntiBan();
    var
      r: Integer;
    begin;
      if not isLoggedIn() then exit();

      r := Random(65);
      case r of
        0..17: hoverSkill(SKILL_WOODCUTTING);
        18..30: randomCompass(10, 30, true);
        36..39: begin
                  if IsIvyAhead_Mouse then
                  begin
                    GetMousePos(x, y);
                    FastClick(mouse_left);
                  end;
                end;
        31..35: randomRClickItem();
        40..50: boredHuman();
        51..55: mouseMovingObject();
        56..60: randomCameraAngle(MS_ANGLE_HIGH);
        61: pickUpMouse();
        62: smallRandomMouse();
        63: sleepAndMoveMouse(randomRange(1000,2000));
        64: mouseOffClient(OFF_CLIENT_RANDOM);
      end;

      wait(randomRange(250, 1000));
      gameTabs.openTab(TAB_BACKPACK);
      debug('Antiban procedure performed.', 1);
    end;
    {$ENDIF}

    function IsIvyAhead_Mouse: Boolean;
    begin
      MouseBox(IntToBox(247, 155, 271, 172), mouse_move);
      Result := isMouseOverText(['Chop Ivy', 'Ivy', 'hop I']);
    end;

    function IsIvyAhead_Colour: Boolean;
    var
      IvyTPA: TPointArray;
      CMod: TColorSettings;
      Bounds: TBox;
    begin
      Bounds := IntToBox(mainscreen.playerBox.x1+5, mainscreen.playerBox.y1-5, mainscreen.playerBox.x2-5, mainscreen.playerBox.y2-15);
      CMod := ColorSetting(2, 0.31, 1.41);
      FindColorsSpiralTolerance(x, y, IvyTPA, 2049333, Bounds, 8, CMod);
      paintTPA(IvyTPA, clRed);

      Result := (Length(IvyTPA) > 20);
    end;

    function MSCenter: TPoint;
    begin
      result := mainscreen.getCenterPoint();
    end;

    //============================================================================//
    // My own fuction for sorting an ATPA from Runescape's centre of main screen
    //   -Uses bubble sort.
    //============================================================================//
    type
      TDistanceIndex = record
        TPA: TPointArray;
        Point: TPoint;
        Distance: LongInt;
      end;

    procedure SortATPAFromMSCentre(var ATPA: T2DPointArray);
    var
      Temp: Array of TDistanceIndex;
      h, i: Integer;
      f: Boolean;

    begin
      SetLength(Temp, Length(ATPA));
      h := High(ATPA);

      // Set array
      for i := 0 to h do
      begin
        Temp[i].TPA := ATPA[i];
        Temp[i].Point := ATPA[i][0];
        Temp[i].Distance := Distance(Temp[i].Point.x, Temp[i].Point.y, MSCenter.x, MSCenter.y);
      end;

      // Arrange Array
      repeat
        f:= True;
        for i := 1 to h-1 do
        begin
          if Temp[i-1].Distance > Temp[i].Distance then
          begin
            Swap(Temp[i-1], Temp[i]);
            f:= False;
          end;
        end;
      until(f)

      // Reset array
      for i := 0 to h do
        ATPA[i] := Temp[i].TPA;

    end;

    function FindIvy(var x, y: Integer): Boolean;
    label insideLoop;
    var
      i, h, hl, G, a, f: Integer;
      bmpD: LongInt;
      P: TPoint;
      B: TBox;
      IvyTPA, MidIvyPts: TPointArray;
      IvyATPA: T2DPointArray;
      CMod: TColorSettings;
    begin
      if not isLoggedIn then Exit;

      CMod := ColorSetting(2, 0.31, 1.41);
      FindColorsSpiralTolerance(x, y, IvyTPA, 2049333, mainscreen.getBounds(), 8, CMod);
      IvyATPA := SplitTPA(IvyTPA, 8);
      SortATPAFromMSCentre(IvyATPA);

      if ( Length(IvyATPA) = 0 ) then
      begin
        Debug('Ivy not found.', 1);
        Result:= false;
      end else
        Debug('Found ' +IntToStr(Length(IvyATPA))+ ' possible Ivys.', 1);

      h:= High(IvyATPA);
      for i := 0 to h do
      begin
        if Length(IvyATPA[i]) > 10 then
        begin
          {$IFDEF PAINT}
            paintTPA(IvyATPA[i], clRed);
          {$ENDIF}

          B := GetTPABounds(IvyATPA[i]);
          P := MiddleBox(B);
          hl := B.X2 - B.X1;
          Debug('Horizontal pixel length of Ivy is: '+IntToStr(hl), 2);
          G := Floor(hl / 25);
          Debug('Thus, will split into '+IntToStr(G)+' groups.', 2);
          SetLength(MidIvyPts, G);

          {$IFDEF PAINT}
            paintBox(B, clBlue);
          {$ENDIF}
          for a := 0 to High(MidIvyPts) do
          begin
            MidIvyPts[a] := Point(Round((B.X1 + ((hl / (G * 2)) * ((a * 2) + 1)))), P.y);
            Debug('MidIvyPts['+IntToStr(a)+']: '+PointToStr(MidIvyPts[a]), 2);
          end;
          SortTPAFrom(MidIvyPts, MSCenter());
          //DebugWait(2000+Random(500));


          for a := 0 to High(MidIvyPts) do
          begin
            if FindOwnIvy then
            begin
              B := IntToBox(MidIvyPts[a].x - 12, MidIvyPts[a].y + 3, MidIvyPts[a].x + 12, MidIvyPts[a].y + 40);
              {$IFDEF PAINT}
                paintBox(B, clWhite);
              {$ENDIF}

              Debug('AveragePixelShift: '+IntToStr(getPixelShiftAverage(B, 250, 500)), 1);
              if getPixelShiftAverage(B, 250, 500) > 300 then
              continue;
            end;

            Mouse(MidIvyPts[a].x, MidIvyPts[a].y, 3, 3, MOUSE_MOVE);
            Debug('Hovering to find UpText.', 1);
            if (isMouseOverText(['Chop Ivy', 'Ivy', 'hop I'], 200)) then
            begin
              Result:= True;
              GetMousePos(x, y);
              Exit;
            end else
            begin
              f := f + 1;
              Debug('Could not find UpText, right-clicking.', 1);
              fastClick(MOUSE_RIGHT);
              Wait(200 + Random(100));
              if chooseOption.optionsExist(['Chop Ivy', 'Ivy', 'hop I']) then
              begin
                Result := True;
                Exit;
              end;
              Result := false;
              if chooseOption.isOpen() then
                chooseOption.close();
              if f < 3 then
                a := a - 1
              else
                f := 0;
            end;
          end;
        end else
          Debug('Skipped TPA(' +IntToStr(i)+ ') ; Length(=' +IntToStr(Length(IvyATPA[i]))+ ') too small.', 1);
      end;
    end;

    function ClickIvy: Boolean;
    begin
      Result := True;
      if FindIvy(x, y) then
      begin
        if not chooseOption.optionsExist(['Chop Ivy', 'Ivy', 'hop I']) then
          Mouse(x, y, 0, 0, mouse_right);

        if not chooseOption.select(['Chop Ivy', 'Ivy', 'hop I']) then
          Result := False;
      end else
        Result := False;
    end;

    function ChopIvy: Boolean;
    var
      i: Integer;
      b: Boolean;
      t: TTimeMarker;
      ivyInfront: TBox;
    begin
      b := False;
      ivyInfront := IntToBox(mainscreen.playerBox.x1+5, mainscreen.playerBox.y1-5, mainscreen.playerBox.x2-5, mainscreen.playerBox.y2-15);
      paintBox(ivyInfront, clWhite);
      t.reset();
      t.start();
      claimTicket();
      ExitTreasure();
      repeat
        if IsIvyAhead_Colour then
        begin
          MouseBox(ivyInfront, MOUSE_MOVE);
          if (isMouseOverText(['Chop Ivy', 'p Ivy', 'hop I'], 200)) then
          begin
            FastClick(MOUSE_LEFT);
            Result := True;
            Break;
          end;
        end;

        if ClickIvy then
        begin
          Result := True;
          Break;
        end else
          if FindOwnIvy then
          begin
            b := True;
            FindOwnIvy := False;
          end else
            if b then
              FindOwnIvy := True;
      until(t.getTime() > 60*1000)
      if Result then
        Debug('Clicked Ivy.', 1);
      if (b) and (not FindOwnIvy) then
        FindOwnIvy := True;
    end;

    (*
    TRSChatbox._getTextColorArray
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function TRSChatbox._getTextColorArray(): TStringArray;

    Returns an array of the text color of each line.

    .. note::

        - by Press Play
        - Last Updated: 14 July 2014 by Press Play

    Example:

    .. code-block:: pascal

        c := chatbox._getTextColorArray();
        for i:=high(c) downto 0 do
          writeln('Line '+toStr(i)+': '+toStr(c[i]));
    *)

    function TRSChatbox._getTextColorArray(): TIntegerArray;
    var
      i, j: Integer;
      tmpTPA: TPointArray;
      cols: TIntegerArray;
      b: TBox;
    begin
      setLength(result, length(self.lineBoxes));
      // clRed    : Unlocking new music, bird nest drop, news
      // clYellow : (OLD) Used when a demon appears somewhere
      // 16776960 : Cyan - GE buy/sell process completed
      // 30446    : Orange - Daily Challenge (assignment + completion)
      // 33023    : Orange - Treasure Hunter Key
      cols := [clRed, clYellow, 16776960, 30446, 33023];
      for i:=0 to High(self.lineBoxes) do
      begin
        b := self.lineBoxes[i];
        b.edit(0, +3, 0, -3);
        result[i] := -1;

        if FindColors(tmpTPA, clWhite, b) then
          if FindColorsTolerance(tmpTPA, 15966584, b, 3) then
            Result[i] := 15441012   // Player chat (needs tolerance)
          else
            Result[i] := clWhite;   // Examine, player names etc.

        if result[i] <> -1 then
          continue();

        for j:=0 to high(cols) do
          if FindColors(tmpTPA, cols[j], b) then
          begin
            Result[i] := cols[j];
            break();
          end;

      end;
    end;

    var
      AChatCol: TIntegerArray;
      RedCount: Integer;

    function GetNestNotification: Boolean;
    var
      i, j, rch: Integer;
      a: TIntegerArray;
    begin
      a := chatbox._getTextColorArray();
      for i := high(a) downto 0 do
        if a[i] <> AChatCol[i] then
        begin
          Debug('GetNestNotification: Chat changed.', 1);
          AChatCol := chatbox._getTextColorArray();
          rch := 0;
          for j := 0 to 7 do
            if AChatCol[j] = clRed then
              Inc(rch);

          if rch = 0 then
            Exit;

          if (rch > RedCount)
          or ((rch = RedCount) and (AChatCol[0] = clRed)) then
          begin
            Debug('A nest just dropped onto the ground.', 1);
            {$IFDEF SCREENSHOT_NEST}
            DebugScreen('Bird''s_Nest_'+TheDate(date_day)+'_'+MsToTime(GetTimeRunning, Time_Abbrev));
            {$ENDIF}
            RedCount := rch;
            Result := True;
          end;

          if rch <> RedCount then
            RedCount := rch;
        end;
    end;

    function FindNest(var x, y: Integer): Boolean;
    var
      CTS, i, h,bmpD: Integer;
      P: TPoint;
      NestTPA: TPointArray;
      NestATPA: T2DPointArray;
      CMod: TColorSettings;
      Bounds: TBox;
    begin
      Cmod := ColorSetting(2, 0.15, 1.65);
      Bounds := IntToBox(mainscreen.playerPoint.x-50, mainscreen.playerPoint.y-50, mainscreen.playerPoint.x+50, mainscreen.playerPoint.y+50);
      paintBox(bounds, clPurple);
      FindColorsSpiralTolerance(x, y, NestTPA, 3558742, Bounds, 6, CMod);

      NestATPA := SplitTPA(NestTPA, 5);
      SortATPAFromMSCentre(NestATPA);

      if ( Length(NestATPA) = 0 ) then
        Result:= false
      else
        Debug('Found ' +IntToStr(Length(NestATPA))+ ' possible nests.', 1);

      h:= High(NestATPA);

      for i := 0 to h do
      begin
        if Length(NestATPA[i]) > 5 then
        begin
          {$IFDEF PAINT}
            paintTPA(nestATPA[i], clRed);
            paintBox(Bounds, clWhite);
          {$ENDIF}

          P := MiddleBox(GetTPABounds(NestATPA[i]));
          Mouse(P.x-1, P.y-1, 2, 2, Mouse_Move);
          if isMouseOverText(['Take Bir', 'e Bird'], 200) then
          begin
            Result:= True;
            GetMousePos(x, y);
            Break;
          end else
          begin
            GetMousePos(x, y);
            Mouse(x, y, 0, 0, mouse_right);
            Wait(200 + Random(100));
            if chooseOption.optionsExist(['Take Bir', 'e Bird']) then
            begin
              Result := True;
              Break;
            end;
            Result:= false;
            if chooseOption.isOpen() then
              chooseOption.close();
          end;
        end else
          Debug('Skipped TPA(' +IntToStr(i)+ ') ; Length(=' +IntToStr(Length(NestATPA[i]))+ ') too small.', 1);
      end;
    end;

    function GetNest: Boolean;
    var
      i: Integer;
      t: TTimeMarker;
    begin
      Debug('Attepting to find nest.', 1);
      t.reset();
      t.start();
      i := tabBackpack.count();
      repeat
        if FindNest(x, y) then
        begin
          if chooseOption.optionsExist(['Take Bir', 'e Bird']) then
            chooseOption.select(['Take Bir', 'e Bird'])
          else
            Mouse(x, y, 0, 0, mouse_left);
          while minimap.isPlayerMoving() do
            Wait(500+Random(100));
        end;
        if tabBackpack.count() > i then
        begin
          Debug('Picked up nest.', 2);
          Result := True;
          Exit;
        end;
      until(t.getTime() > 35*1000);
      Debug('Failed to pick up nest.', 1);
      {$IFDEF SCREENSHOT_NEST}
        DebugScreen('Bird''s_Nest_'+TheDate(date_day)+'_'+MsToTime(GetTimeRunning, Time_Abbrev)+'_FAILED');
      {$ENDIF}
    end;

    procedure SetupPlayer; forward;
    function WaitWhileChop: Boolean;
    var
      ivyTime: TTimeMarker;
    begin
      minimap.waitFlag();
      ivyTime.reset();
      ivyTime.start();
      repeat
        Wait(1000 + Random(500));
        Status('Waiting: '+MsToTime(ivyTime.getTime(), Time_Abbrev)+', AveragePixelShift: '+IntToStr(getPixelShiftAverage(mainscreen.playerBox, 500, 1000)));

        minimap.setAngle(players[currentPlayer].integers[P_WALL_DIR]);

        if GetNestNotification then
          if GetNest then
          begin
            Inc(Players[CurrentPlayer].Integers[P_NESTS]);
            ChopIvy;
          end;

        if Random(120) = 0 then
          DoAntiBan;

        {$IFDEF SMART}
        if ivyTime.getTime() > 5000 then
          paintClear();
        {$ENDIF}

        if ivyTime.getTime() > 4*60*1000 then
        begin
          DoAntiBan;
          ivyTime.reset();
          ivyTime.start();
        end;

        if not isLoggedIn then
        begin
          SetupPlayer;
          ChopIvy;
        end;
        //Debug(, 1);
      until((not IsIvyAhead_Colour) or (getPixelShiftAverage(mainscreen.playerBox, 500, 1000) < 300));
      Result := True;
    end;

    // Credits to Ashaman
    function TRSChatBox.getXP: Integer;
    var
      b: TBox;
      s: String;
      tpa : TPointArray;
      atpa : T2DPointArray;
      i,cts,p: Integer;
    begin
      b := self.getBounds();
      b.edit(+(b.x2-b.x1)-140, +10, -5, -94);

      findColorsTolerance(tpa, 14013909, b, 4,colorSetting(2, 0.00, 0.00));

      if length(tpa) < 2 then
      begin
        writeln('chatBox.getXP(): No XP found');
        Exit;
      end;

      atpa := tpa.cluster(5);

      b:= atpa.getbounds;
      b.edit(-2,-2,+2,+3);

      s:=Replace(tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);

      P := Pos('x', S);
      if P > 0 then
        Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
      else
        Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

      debug('chatBox.getXP(): XP found: ' + tostr(result), 0);
    end;











    //============================================================================//
    // procedure setupScript();
    //   -Everything initialised; all systems go.
    //============================================================================//
    procedure setupScript();
    var
      i: Integer;
    begin
      clearDebug();
      disguise(ScriptName+ ' has been started!');
      writeln(ScriptName+' is loading.');

      loadGlobals();
      declarePlayers();
      disableSRLDebug := true;
      disableSRLLog   := true;
      debug('Setting up SRL.', 0);
      setupSRL();
      for i := 0 to howManyPlayers - 1 do
      begin
        players[i].findMod := true;
        players[i].worked.name := 'Player '+toStr(i);
        players[i].worked.start();
        players[i].worked.pause();
        players[i].booleans[P_FIRST_LOGIN] := false;
      end;

      {$IFDEF PAINT}
        smartSetupDrawing();
      {$ENDIF}

      whenBreak:= ((1000*60)*Whenbreak);
      addOnTerminate('ProgressReport');
    end;

    //============================================================================//
    // Report functions:
    //----------------------------------------------------------------------------//
    procedure CalculateTotals;
    var
      i: Integer;
    begin
      Total.XP := 0;
      Players[CurrentPlayer].Integers[P_XP] := chatBox.getXP() - Players[CurrentPlayer].Integers[P_START_XP];
      for i:=0 to HowManyPlayers-1 do
        Total.XP := Total.XP + Players[i].Integers[P_XP];

      Total.Nests := 0;
      for i:=0 to HowManyPlayers-1 do
        Total.Nests := Total.Nests + Players[i].Integers[P_NESTS];
    end;

    procedure clearReportString;
    begin
      setLength(reportString, 1);
      reportString[0] := '';
    end;

    procedure addToReportString(s: String);
    begin
      reportString[high(reportString)] := s;
      setLength(reportString, length(reportString) + 1);
    end;

    procedure progressReport();
    var
      i: Integer;
    begin
      calculateTotals();

      {$IFNDEF DEBUG}
        clearDebug();
      {$ENDIF}

      ClearReportString;
      AddToReportString('/-------------------------------------------------------------\');
      AddToReportString('|-------------------------------------------------------------|');
      AddToReportString(PadR('|                        Press Play''s', 62) + '|');
      AddToReportString(PadR('|                      ' +ScriptName, 62) + '|');
      AddToReportString(PadR('|                        Version ' + ScriptVersion, 62) + '|');
      AddToReportString('|-------------------------------------------------------------|');
      AddToReportString(PadR('|     TOTALS : ', 62) + '|');
      AddToReportString(PadR('|       Time Running  : ' +MsToTime(getTimeRunning(), TIME_ABBREV), 62) + '|');
      AddToReportString(PadR('|       Exp Gained    : ' +IntToStr(Round(total.XP)), 62) + '|');
      AddToReportString(PadR('|       Nests Gotten  : ' +IntToStr(Total.Nests), 62) + '|');
      AddToReportString(PadR('|     ', 62) + '|');
      for i:=0 to HowManyPlayers-1 do
      begin
        AddToReportString(PadR('|     PLAYER ' +IntToStr(i)+ ' : ', 62) + '|');
        AddToReportString(PadR('|       Time Running  : ' +MsToTime(players[i].worked.getTime(), TIME_ABBREV), 62) + '|');
        AddToReportString(PadR('|       Exp Gained    : ' +IntToStr(Round(Players[i].Integers[P_XP])), 62) + '|');
        if not ((players[i].worked.getTime()/60000) = 0) then
          AddToReportString(PadR('|       Exp / Hour    : ' +IntToStr(Round(Players[i].Integers[P_XP]*60/(players[i].worked.getTime()/60000))), 62) + '|');

        if not (players[i].location = '') then
          AddToReportString(PadR('|       False Reason  : ' +players[i].location, 62) + '|');
        AddToReportString(PadR('|     ', 62) + '|');
      end;
      AddToReportString(PadR('|     ', 62) + '|');
      AddToReportString('|-------------------------------------------------------------|');
      AddToReportString('\-------------------------------------------------------------/');
      for i := 0 to High(ReportString) do
          Writeln(ReportString[i]);
    end;

    //============================================================================//
    // procedure setupPlayer();
    //   -Logs in the players and sets it up - ready to go!
    //============================================================================//
    procedure setupPlayer();
    var
      i: Integer;
      a: TIntegerArray;
    begin
      players[currentPlayer].login();
      writeln('Player ' +IntToStr(CurrentPlayer)+ ' logged in.');
      paintClear();
      wait(randomRange(100, 150));
      minimap.clickCompass();
      wait(randomRange(200, 500));
      minimap.setAngle(players[currentPlayer].integers[P_WALL_DIR]);
      wait(randomRange(200, 500));
      mainscreen.setAngle(MS_ANGLE_HIGH);
      exitTreasure();
      wait(randomRange(500, 1000));

      a := chatbox._getTextColorArray();
      setLength(AChatCol, length(a));
      for i := high(a) downto 0 do
        AChatCol[i] := a[i];
      if not Players[CurrentPlayer].Booleans[P_FIRST_LOGIN] then
        Players[CurrentPlayer].Integers[P_START_XP] := chatBox.getXP();
      Players[CurrentPlayer].Booleans[P_FIRST_LOGIN] := True;
      RedCount := 0;

      roundTime.reset();
      roundTime.start();
    end;

    {$IFNDEF CODEINSIGHT}
    //============================================================================//
    // procedure takeBreak();
    //   -Takes a break based on the amount of time played by the current player.
    //============================================================================//
    procedure takeBreak();
    var
      Breaktime, Timeleft, i, e: Integer;
    begin
      if isLoggedIn() then
        players[currentPlayer].logout;

      if players[currentPlayer].worked.getTime() > (2*60*60*1000) then
      begin
        Breaktime:= randomRange(20*60*1000, 35*60*1000);
      end else
        Breaktime:= randomRange(Round(Players[CurrentPlayer].worked.getTime() / 8), Round(Players[CurrentPlayer].worked.getTime() / 4));

      Writeln('Taking a break for ' + mstotime(breaktime, Time_Abbrev) );
      Writeln('');

      i := getSystemTime();
      repeat
        wait(10000);
        e:= GetSystemTime;
        timeleft:= breaktime - (e - i);
        Disguise('We have ' + mstotime(timeleft, Time_Abbrev) + ' to go');
      until( (e - i) >= breaktime );

      Disguise('Finished break.');
    end;

    //============================================================================//
    // procedure logoutProcess();
    //   -Performs logout on current player, sets activeness and takes break.
    //============================================================================//
    procedure logoutProcess();
    begin
      Debug('Loging out.', 1);

      if bankScreen.isOpen() then
        bankScreen.close();

      if (not (lowercase(players[currentPlayer].location) = '')) or (not isLoggedIn()) then
      begin
        debugScreen(capitalize(players[currentPlayer].location)+'_'+msToTime(getTimeRunning(), TIME_ABBREV));
        players[currentPlayer].isActive := false;
      end;

      wait(logoutDelay + random(1000));
      players[currentPlayer].logout();

      progressReport();

      if not( lowercase(players[currentPlayer].location) = '') then
        players[currentPlayer].isActive := false;

      if not (players.getActive() = 0) then
      begin
        takeBreak();
      end else
        exit();

      players.next(players[currentPlayer].isActive);
    end;

    //============================================================================//
    // function tryStep(f: TBooleanFunction, errorMsg: String): boolean;
    //   -Trys a routine 5 times before exiting and return false.
    //   -Sets 'errorMsg' as player.location.
    //============================================================================//
    function tryStep(name: String; f: TBooleanFunction; errorMsg: String): boolean;
    var
      i: Integer;
    begin
      debug('Attempting to excecute ' +name+ '.', 1);
      for i := 1 to 5 do
      begin
        if f() then
        begin
          result := true;
          break();
        end;
        if not isLoggedIn() then
          if not players[currentPlayer].login() then break();
        debug('Failed to excecute ' +name+ ' ' +intToStr(i)+ ' time(s).', 2);
      end;

      if not result then
        players[currentPlayer].location := errorMsg;
    end;

    //============================================================================//
    // procedure takeAFKBreak();
    //   -Waits a random amount of time, pretending to be AFK.
    //============================================================================//
    procedure takeAFKBreak();
    begin
      case random(25) of
        10: begin
              debug('Taking AFK break.', 1);
              wait(randomRange(10000, 45000));
            end;
      end;
    end;

    //============================================================================//
    // function mainLoopSucessful(): boolean;
    //   -Performs one iteration of the main loop for a single player.
    //============================================================================//
    function mainLoopSucessful(): boolean;
    begin
      if not tryStep('chopIvy()', @chopIvy, 'Could not chop Ivy') then
        exit();

      if not tryStep('waitWhileChop()', @waitWhileChop, 'Timed out while chopping') then
        exit();

      takeAFKBreak();

      progressReport();

      result:= True;
    end;

    //============================================================================//
    // function playerActive(): boolean;
    //   -Overwrites player.location if SRL has overwritten it; returns true
    //    if the current player is deemed to be active.
    //============================================================================//
    function playerActive(): boolean;
    var
      arr: TVariantArray;
    begin
      {arr := __getLoginResponse(players[currentPlayer].location, 0);

      if length(arr) > 0 then
        if (arr[__RES_ACTION] = 'true')
        or (arr[__RES_ACTION] = 'update') then
          players[currentPlayer].location := '';

      if (players[currentPlayer].location = '') then
        result := true;}

      if not isLoggedIn() then
      begin
        result := false;
        exit;
      end;

      result := true;
    end;
    {$ENDIF}




    {------------------------------------------------------------------------------]
    [  MAIN LOOP:                                                                  ]
    [     Where all the routines are combined into a working script!               ]
    [------------------------------------------------------------------------------}

    BEGIN
      setupScript();

      repeat
        setupPlayer();

        repeat

          if not playerActive() then
            break();

          if not mainLoopSucessful() then
            break();

        until( roundTime.getTime() >= (whenBreak + randomRange(-(1000*60*3), (1000*60*3)) ) );

        logoutProcess();

      until( players.getActive() = 0 );
      debug('All players are inactive.', 1);
      debug('Script is finished.', 1);

      if isLoggedIn() then
        players[currentPlayer].logout();

      terminateScript();
    END.

  20. #120
    Join Date
    Feb 2007
    Posts
    64
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Trollcrank View Post
    I changed a few lines to get it to run, it appears a bit outdated.

    Progress Report:
    /-------------------------------------------------------------\
    |-------------------------------------------------------------|
    |                        Press Play's                         |
    |                      Ivy Chopper Ultra                      |
    |                        Version 1.10                         |
    |-------------------------------------------------------------|
    |     TOTALS :                                                |
    |       Time Running  : 8 hr 53 min 9 sec                     |
    |       Exp Gained    : 614552                                |
    |       Nests Gotten  : 8                                     |
    |                                                             |
    |     PLAYER 0 :                                              |
    |       Time Running  : 8 hr 21 min 8 sec                     |
    |       Exp Gained    : 614552                                |
    |       Exp / Hour    : 73579                                 |
    |                                                             |
    |                                                             |
    |-------------------------------------------------------------|
    \-------------------------------------------------------------/


    Edit: Here is the script, this should work for any of you that our having the "Error: No default value for parameter 3 found at line 1105
    Compiling failed." problem.

    Simba Code:
    program IvyChopperUltra;
    {$DEFINE SMART}
    {$I SRL-6/SRL.Simba}

    {$DEFINE DEBUG}
    {$DEFINE PAINT}
    {$DEFINE SCREENSHOT}
    {$DEFINE SCREENSHOT_NEST}

    {



                      8888888b.
                      888   Y88b
                      888    888
                      888   d88P 888d888 .d88b.  .d8888b  .d8888b
                      8888888P"  888P"  d8P  Y8b 88K      88K
                      888        888    88888888 "Y8888b. "Y8888b.
                      888        888    Y8b.          X88      X88
                      888        888     "Y8888   88888P'  88888P'



                            8888888b.  888
                            888   Y88b 888
                            888    888 888
                            888   d88P 888  8888b.  888  888
                            8888888P"  888     "88b 888  888
                            888        888 .d888888 888  888
                            888        888 888  888 Y88b 888
                            888        888 "Y888888  "Y88888
                                                         888
                                                    Y8b d88P
                                                     "Y88P"



    +------------------------------------------------------------------------------+


              _   _      _         __    _     ___   ___   ___   ____  ___
             | | \ \  / \ \_/     / /`  | |_| / / \ | |_) | |_) | |_  | |_)
             |_|  \_\/   |_|      \_\_, |_| | \_\_/ |_|   |_|   |_|__ |_| \
                             _     _    _____  ___    __
                            | | | | |    | |  | |_)  / /\
                            \_\_/ |_|__  |_|  |_| \ /_/--\



    +------------------------------------------------------------------------------+
    }


    { ~~ Global Variables ~~ }
    var
      x, y: Integer;
      WhenBreak, HowManyPlayers: Integer;
      FindOwnIvy: Boolean;

    const
    { *** For Players}
      P_WALL_DIR    = 0;
    { *** For Report}
      P_XP          = 1;
      P_NESTS       = 2;
      P_START_XP    = 3;
      P_FIRST_LOGIN = 4;

    { *** For Directions}
      DIR_NORTH = 0;
      DIR_EAST  = 90;
      DIR_SOUTH = 180;
      DIR_WEST  = 270;

    {==============================================================================}
    {  START START   START START     START START       START START    START START  }
    {  START            START       START   START      START      |      START     }
    {  START START      START      START --- START     START START       START     }
    {        START      START     START       START    START  START      START     }
    {  START START      START     START       START    START   START     START     }
    {==============================================================================}

    {------------------------------------------------------------------------------]
    [  VARIBLE SETUP:                                                              ]
    [     See the thread for details.                                              ]
    [------------------------------------------------------------------------------}

    procedure LoadGlobals;
    begin
      WhenBreak     := 240;   // Minutes until break
      FindOwnIvy    := True;  // Tries to find an unoccupied ivy if set to 'true'
    end;

    {------------------------------------------------------------------------------]
    [  DECLARE PLAYERS:                                                            ]
    [     Change accordingly.                                                      ]
    [------------------------------------------------------------------------------}

    procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      setLength(players, HowManyPlayers);
      CurrentPlayer := 0;

      with Players[0] do
      begin
        loginName            :='';           // Username
        password             :='';           // Password
        integers[P_WALL_DIR] := DIR_SOUTH;   // The direction your player faces to chop the ivy
        isMember             := true;
        isActive             := true;
        world                := -1;
      end;
    end;

    {==============================================================================}
    {                STOP STOP   STOP STOP   STOP-STOP    STOP STOP                }
    {                STOP           STOP     STOP STOP    STOP    |                }
    {      =====     STOP STOP      STOP     STOP STOP    STOP STOP     =====      }
    {                     STOP      STOP     STOP STOP    STOP                     }
    {                STOP STOP      STOP     STOP-STOP    STOP                     }
    {==============================================================================}

    const
      ScriptVersion = '1.10';
      ScriptName    = 'Ivy Chopper Ultra';

    { ~~ The following options are not recommended to change
         unless you have a well rounded scripting ability ~~ }


      LaggFactor    = 3;      // [1 = no lagg, 3 = default, 10 = HOLY S**T]
      logoutDelay   = 0;      // Wait before logging out; for debugging
    type
      TotalStatistics = record
        XP, Nests: Integer;
      end;

      TBooleanFunction = function(): boolean;

    var
      TotalTimeInactive: Integer;  // Time
      RoundTime: TTimeMarker;
      Total: TotalStatistics;
      PlayerStartXP: Integer;
      reportString: TStringArray;

    {$IFNDEF CODEINSIGHT}
    //============================================================================//
    // Utility functions:
    //----------------------------------------------------------------------------//
    //============================================================================//
    // procedure debug(w: string);
    //   -Prints debug if DEBUG is defined.
    //============================================================================//
    procedure debug(w: string; lvl: Integer);
    var
      i: Integer;
    begin
      {$IFDEF DEBUG}
        if lvl > 1 then
        begin
          w := '-' + w;
          for i := 1 to lvl-1 do
            w := '  ' + w;
        end;
        writeln(w);
      {$ELSE}
        status(w);
      {$ENDIF}
    end;

    //============================================================================//
    // procedure DebugScreen(reason: String);
    //   -Saves a screenshot to 'reason' if SCREENSHOT is defined.
    //============================================================================//
    procedure DebugScreen(reason: String);
    var
      bmpF, i: Integer;
      TPAName, TPAStats: TPointArray;
    begin
      {$IFDEF SCREENSHOT}
        if not DirectoryExists(ScriptPath + 'Screenshots/') then
          if not CreateDirectory(ScriptPath + 'Screenshots/') then
            Exit;

        bmpF := BitmapFromClient(0, 0, minimap.getBounds().x2+1, chatbox.getBounds().y2+1);
        TPAName := TPAFromBox(IntToBox(chatbox.getChatArea().X1, chatbox.getChatArea().Y2, chatbox.getChatArea().X2, chatbox.getBounds().Y2));
        TPAStats := TPAFromBox(actionbar.getBounds());
        for i := 0 to High(TPAName) do
          FastSetPixel(bmpF, TPAName[i].x, TPAName[i].y, clWhite);
        for i := 0 to High(TPAStats) do
          FastSetPixel(bmpF, TPAStats[i].x, TPAStats[i].y, clWhite);

        SaveBitmap(bmpF, ScriptPath + 'Screenshots/' +reason+ '.png');
        //SaveScreenshot(ScriptPath + 'Screenshots/' +reason+ '.png');
        Debug('Screenshot saved.', 0);
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintClear(area: TBox);
    //   -Clears the 'area' on SMART.
    //============================================================================//
    procedure paintClear(area: TBox);
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.clearArea(area);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintClear(); overload;
    //   -Clears everything on SMART.
    //============================================================================//
    procedure paintClear(); overload;
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.drawClear(0);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintTPA(pts: TPointArray; col: Integer);
    //   -Paints TPA to SMART with colour 'col'
    //============================================================================//
    procedure paintTPA(pts: TPointArray; col: Integer);
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.DrawTPA(pts, col);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // procedure paintBox(pts: TBox;  col: Integer);
    //   -Paints box to SMART with colour 'col'
    //============================================================================//
    procedure paintBox(pts: TBox;  col: Integer);
    begin
      {$IFDEF PAINT}
        {$IFDEF SMART}
          {$IFDEF DEBUG}
            smartImage.DrawBox(pts, col);
          {$ENDIF}
        {$ENDIF}
      {$ENDIF}
    end;

    //============================================================================//
    // function PointToStr(P: TPoint): String;
    //   -Turns a TPoint variable into a String variable in the format: (x, y).
    //============================================================================//
    function PointToStr(P: TPoint): String;
    begin
      Result := ('('+IntToStr(P.x)+', '+IntToStr(P.y)+')');
    end;

    //============================================================================//
    // function overTime(theTime: TTimeMarker; theLimit: LongInt): boolean;
    //   -'theTime' is the TTimeMarker with the stored time.
    //   -'theLimit' is the amount of time which 'theTime'(ms) must exceed to
    //    return true.
    //============================================================================//
    function overTime(theTime: TTimeMarker; theLimit: LongInt): boolean;
    begin
      result := (theTime.getTime() > theLimit);
    end;

    function IsIvyAhead_Mouse: Boolean; forward;
    //============================================================================//
    // procedure doAntiBan();
    //   -Performs generic antiban procedure.
    //============================================================================//
    procedure doAntiBan();
    var
      r: Integer;
    begin;
      if not isLoggedIn() then exit();

      r := Random(65);
      case r of
        0..17: hoverSkill(SKILL_WOODCUTTING);
        18..30: randomCompass(10, 30, true);
        36..39: begin
                  if IsIvyAhead_Mouse then
                  begin
                    GetMousePos(x, y);
                    FastClick(mouse_left);
                  end;
                end;
        31..35: randomRClickItem();
        40..50: boredHuman();
        51..55: mouseMovingObject();
        56..60: randomCameraAngle(MS_ANGLE_HIGH);
        61: pickUpMouse();
        62: smallRandomMouse();
        63: sleepAndMoveMouse(randomRange(1000,2000));
        64: mouseOffClient(OFF_CLIENT_RANDOM);
      end;

      wait(randomRange(250, 1000));
      gameTabs.openTab(TAB_BACKPACK);
      debug('Antiban procedure performed.', 1);
    end;
    {$ENDIF}

    function IsIvyAhead_Mouse: Boolean;
    begin
      MouseBox(IntToBox(247, 155, 271, 172), mouse_move);
      Result := isMouseOverText(['Chop Ivy', 'Ivy', 'hop I']);
    end;

    function IsIvyAhead_Colour: Boolean;
    var
      IvyTPA: TPointArray;
      CMod: TColorSettings;
      Bounds: TBox;
    begin
      Bounds := IntToBox(mainscreen.playerBox.x1+5, mainscreen.playerBox.y1-5, mainscreen.playerBox.x2-5, mainscreen.playerBox.y2-15);
      CMod := ColorSetting(2, 0.31, 1.41);
      FindColorsSpiralTolerance(x, y, IvyTPA, 2049333, Bounds, 8, CMod);
      paintTPA(IvyTPA, clRed);

      Result := (Length(IvyTPA) > 20);
    end;

    function MSCenter: TPoint;
    begin
      result := mainscreen.getCenterPoint();
    end;

    //============================================================================//
    // My own fuction for sorting an ATPA from Runescape's centre of main screen
    //   -Uses bubble sort.
    //============================================================================//
    type
      TDistanceIndex = record
        TPA: TPointArray;
        Point: TPoint;
        Distance: LongInt;
      end;

    procedure SortATPAFromMSCentre(var ATPA: T2DPointArray);
    var
      Temp: Array of TDistanceIndex;
      h, i: Integer;
      f: Boolean;

    begin
      SetLength(Temp, Length(ATPA));
      h := High(ATPA);

      // Set array
      for i := 0 to h do
      begin
        Temp[i].TPA := ATPA[i];
        Temp[i].Point := ATPA[i][0];
        Temp[i].Distance := Distance(Temp[i].Point.x, Temp[i].Point.y, MSCenter.x, MSCenter.y);
      end;

      // Arrange Array
      repeat
        f:= True;
        for i := 1 to h-1 do
        begin
          if Temp[i-1].Distance > Temp[i].Distance then
          begin
            Swap(Temp[i-1], Temp[i]);
            f:= False;
          end;
        end;
      until(f)

      // Reset array
      for i := 0 to h do
        ATPA[i] := Temp[i].TPA;

    end;

    function FindIvy(var x, y: Integer): Boolean;
    label insideLoop;
    var
      i, h, hl, G, a, f: Integer;
      bmpD: LongInt;
      P: TPoint;
      B: TBox;
      IvyTPA, MidIvyPts: TPointArray;
      IvyATPA: T2DPointArray;
      CMod: TColorSettings;
    begin
      if not isLoggedIn then Exit;

      CMod := ColorSetting(2, 0.31, 1.41);
      FindColorsSpiralTolerance(x, y, IvyTPA, 2049333, mainscreen.getBounds(), 8, CMod);
      IvyATPA := SplitTPA(IvyTPA, 8);
      SortATPAFromMSCentre(IvyATPA);

      if ( Length(IvyATPA) = 0 ) then
      begin
        Debug('Ivy not found.', 1);
        Result:= false;
      end else
        Debug('Found ' +IntToStr(Length(IvyATPA))+ ' possible Ivys.', 1);

      h:= High(IvyATPA);
      for i := 0 to h do
      begin
        if Length(IvyATPA[i]) > 10 then
        begin
          {$IFDEF PAINT}
            paintTPA(IvyATPA[i], clRed);
          {$ENDIF}

          B := GetTPABounds(IvyATPA[i]);
          P := MiddleBox(B);
          hl := B.X2 - B.X1;
          Debug('Horizontal pixel length of Ivy is: '+IntToStr(hl), 2);
          G := Floor(hl / 25);
          Debug('Thus, will split into '+IntToStr(G)+' groups.', 2);
          SetLength(MidIvyPts, G);

          {$IFDEF PAINT}
            paintBox(B, clBlue);
          {$ENDIF}
          for a := 0 to High(MidIvyPts) do
          begin
            MidIvyPts[a] := Point(Round((B.X1 + ((hl / (G * 2)) * ((a * 2) + 1)))), P.y);
            Debug('MidIvyPts['+IntToStr(a)+']: '+PointToStr(MidIvyPts[a]), 2);
          end;
          SortTPAFrom(MidIvyPts, MSCenter());
          //DebugWait(2000+Random(500));


          for a := 0 to High(MidIvyPts) do
          begin
            if FindOwnIvy then
            begin
              B := IntToBox(MidIvyPts[a].x - 12, MidIvyPts[a].y + 3, MidIvyPts[a].x + 12, MidIvyPts[a].y + 40);
              {$IFDEF PAINT}
                paintBox(B, clWhite);
              {$ENDIF}

              Debug('AveragePixelShift: '+IntToStr(getPixelShiftAverage(B, 250, 500)), 1);
              if getPixelShiftAverage(B, 250, 500) > 300 then
              continue;
            end;

            Mouse(MidIvyPts[a].x, MidIvyPts[a].y, 3, 3, MOUSE_MOVE);
            Debug('Hovering to find UpText.', 1);
            if (isMouseOverText(['Chop Ivy', 'Ivy', 'hop I'], 200)) then
            begin
              Result:= True;
              GetMousePos(x, y);
              Exit;
            end else
            begin
              f := f + 1;
              Debug('Could not find UpText, right-clicking.', 1);
              fastClick(MOUSE_RIGHT);
              Wait(200 + Random(100));
              if chooseOption.optionsExist(['Chop Ivy', 'Ivy', 'hop I']) then
              begin
                Result := True;
                Exit;
              end;
              Result := false;
              if chooseOption.isOpen() then
                chooseOption.close();
              if f < 3 then
                a := a - 1
              else
                f := 0;
            end;
          end;
        end else
          Debug('Skipped TPA(' +IntToStr(i)+ ') ; Length(=' +IntToStr(Length(IvyATPA[i]))+ ') too small.', 1);
      end;
    end;

    function ClickIvy: Boolean;
    begin
      Result := True;
      if FindIvy(x, y) then
      begin
        if not chooseOption.optionsExist(['Chop Ivy', 'Ivy', 'hop I']) then
          Mouse(x, y, 0, 0, mouse_right);

        if not chooseOption.select(['Chop Ivy', 'Ivy', 'hop I']) then
          Result := False;
      end else
        Result := False;
    end;

    function ChopIvy: Boolean;
    var
      i: Integer;
      b: Boolean;
      t: TTimeMarker;
      ivyInfront: TBox;
    begin
      b := False;
      ivyInfront := IntToBox(mainscreen.playerBox.x1+5, mainscreen.playerBox.y1-5, mainscreen.playerBox.x2-5, mainscreen.playerBox.y2-15);
      paintBox(ivyInfront, clWhite);
      t.reset();
      t.start();
      claimTicket();
      ExitTreasure();
      repeat
        if IsIvyAhead_Colour then
        begin
          MouseBox(ivyInfront, MOUSE_MOVE);
          if (isMouseOverText(['Chop Ivy', 'p Ivy', 'hop I'], 200)) then
          begin
            FastClick(MOUSE_LEFT);
            Result := True;
            Break;
          end;
        end;

        if ClickIvy then
        begin
          Result := True;
          Break;
        end else
          if FindOwnIvy then
          begin
            b := True;
            FindOwnIvy := False;
          end else
            if b then
              FindOwnIvy := True;
      until(t.getTime() > 60*1000)
      if Result then
        Debug('Clicked Ivy.', 1);
      if (b) and (not FindOwnIvy) then
        FindOwnIvy := True;
    end;

    (*
    TRSChatbox._getTextColorArray
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function TRSChatbox._getTextColorArray(): TStringArray;

    Returns an array of the text color of each line.

    .. note::

        - by Press Play
        - Last Updated: 14 July 2014 by Press Play

    Example:

    .. code-block:: pascal

        c := chatbox._getTextColorArray();
        for i:=high(c) downto 0 do
          writeln('Line '+toStr(i)+': '+toStr(c[i]));
    *)

    function TRSChatbox._getTextColorArray(): TIntegerArray;
    var
      i, j: Integer;
      tmpTPA: TPointArray;
      cols: TIntegerArray;
      b: TBox;
    begin
      setLength(result, length(self.lineBoxes));
      // clRed    : Unlocking new music, bird nest drop, news
      // clYellow : (OLD) Used when a demon appears somewhere
      // 16776960 : Cyan - GE buy/sell process completed
      // 30446    : Orange - Daily Challenge (assignment + completion)
      // 33023    : Orange - Treasure Hunter Key
      cols := [clRed, clYellow, 16776960, 30446, 33023];
      for i:=0 to High(self.lineBoxes) do
      begin
        b := self.lineBoxes[i];
        b.edit(0, +3, 0, -3);
        result[i] := -1;

        if FindColors(tmpTPA, clWhite, b) then
          if FindColorsTolerance(tmpTPA, 15966584, b, 3) then
            Result[i] := 15441012   // Player chat (needs tolerance)
          else
            Result[i] := clWhite;   // Examine, player names etc.

        if result[i] <> -1 then
          continue();

        for j:=0 to high(cols) do
          if FindColors(tmpTPA, cols[j], b) then
          begin
            Result[i] := cols[j];
            break();
          end;

      end;
    end;

    var
      AChatCol: TIntegerArray;
      RedCount: Integer;

    function GetNestNotification: Boolean;
    var
      i, j, rch: Integer;
      a: TIntegerArray;
    begin
      a := chatbox._getTextColorArray();
      for i := high(a) downto 0 do
        if a[i] <> AChatCol[i] then
        begin
          Debug('GetNestNotification: Chat changed.', 1);
          AChatCol := chatbox._getTextColorArray();
          rch := 0;
          for j := 0 to 7 do
            if AChatCol[j] = clRed then
              Inc(rch);

          if rch = 0 then
            Exit;

          if (rch > RedCount)
          or ((rch = RedCount) and (AChatCol[0] = clRed)) then
          begin
            Debug('A nest just dropped onto the ground.', 1);
            {$IFDEF SCREENSHOT_NEST}
            DebugScreen('Bird''s_Nest_'+TheDate(date_day)+'_'+MsToTime(GetTimeRunning, Time_Abbrev));
            {$ENDIF}
            RedCount := rch;
            Result := True;
          end;

          if rch <> RedCount then
            RedCount := rch;
        end;
    end;

    function FindNest(var x, y: Integer): Boolean;
    var
      CTS, i, h,bmpD: Integer;
      P: TPoint;
      NestTPA: TPointArray;
      NestATPA: T2DPointArray;
      CMod: TColorSettings;
      Bounds: TBox;
    begin
      Cmod := ColorSetting(2, 0.15, 1.65);
      Bounds := IntToBox(mainscreen.playerPoint.x-50, mainscreen.playerPoint.y-50, mainscreen.playerPoint.x+50, mainscreen.playerPoint.y+50);
      paintBox(bounds, clPurple);
      FindColorsSpiralTolerance(x, y, NestTPA, 3558742, Bounds, 6, CMod);

      NestATPA := SplitTPA(NestTPA, 5);
      SortATPAFromMSCentre(NestATPA);

      if ( Length(NestATPA) = 0 ) then
        Result:= false
      else
        Debug('Found ' +IntToStr(Length(NestATPA))+ ' possible nests.', 1);

      h:= High(NestATPA);

      for i := 0 to h do
      begin
        if Length(NestATPA[i]) > 5 then
        begin
          {$IFDEF PAINT}
            paintTPA(nestATPA[i], clRed);
            paintBox(Bounds, clWhite);
          {$ENDIF}

          P := MiddleBox(GetTPABounds(NestATPA[i]));
          Mouse(P.x-1, P.y-1, 2, 2, Mouse_Move);
          if isMouseOverText(['Take Bir', 'e Bird'], 200) then
          begin
            Result:= True;
            GetMousePos(x, y);
            Break;
          end else
          begin
            GetMousePos(x, y);
            Mouse(x, y, 0, 0, mouse_right);
            Wait(200 + Random(100));
            if chooseOption.optionsExist(['Take Bir', 'e Bird']) then
            begin
              Result := True;
              Break;
            end;
            Result:= false;
            if chooseOption.isOpen() then
              chooseOption.close();
          end;
        end else
          Debug('Skipped TPA(' +IntToStr(i)+ ') ; Length(=' +IntToStr(Length(NestATPA[i]))+ ') too small.', 1);
      end;
    end;

    function GetNest: Boolean;
    var
      i: Integer;
      t: TTimeMarker;
    begin
      Debug('Attepting to find nest.', 1);
      t.reset();
      t.start();
      i := tabBackpack.count();
      repeat
        if FindNest(x, y) then
        begin
          if chooseOption.optionsExist(['Take Bir', 'e Bird']) then
            chooseOption.select(['Take Bir', 'e Bird'])
          else
            Mouse(x, y, 0, 0, mouse_left);
          while minimap.isPlayerMoving() do
            Wait(500+Random(100));
        end;
        if tabBackpack.count() > i then
        begin
          Debug('Picked up nest.', 2);
          Result := True;
          Exit;
        end;
      until(t.getTime() > 35*1000);
      Debug('Failed to pick up nest.', 1);
      {$IFDEF SCREENSHOT_NEST}
        DebugScreen('Bird''s_Nest_'+TheDate(date_day)+'_'+MsToTime(GetTimeRunning, Time_Abbrev)+'_FAILED');
      {$ENDIF}
    end;

    procedure SetupPlayer; forward;
    function WaitWhileChop: Boolean;
    var
      ivyTime: TTimeMarker;
    begin
      minimap.waitFlag();
      ivyTime.reset();
      ivyTime.start();
      repeat
        Wait(1000 + Random(500));
        Status('Waiting: '+MsToTime(ivyTime.getTime(), Time_Abbrev)+', AveragePixelShift: '+IntToStr(getPixelShiftAverage(mainscreen.playerBox, 500, 1000)));

        minimap.setAngle(players[currentPlayer].integers[P_WALL_DIR]);

        if GetNestNotification then
          if GetNest then
          begin
            Inc(Players[CurrentPlayer].Integers[P_NESTS]);
            ChopIvy;
          end;

        if Random(120) = 0 then
          DoAntiBan;

        {$IFDEF SMART}
        if ivyTime.getTime() > 5000 then
          paintClear();
        {$ENDIF}

        if ivyTime.getTime() > 4*60*1000 then
        begin
          DoAntiBan;
          ivyTime.reset();
          ivyTime.start();
        end;

        if not isLoggedIn then
        begin
          SetupPlayer;
          ChopIvy;
        end;
        //Debug(, 1);
      until((not IsIvyAhead_Colour) or (getPixelShiftAverage(mainscreen.playerBox, 500, 1000) < 300));
      Result := True;
    end;

    // Credits to Ashaman
    function TRSChatBox.getXP: Integer;
    var
      b: TBox;
      s: String;
      tpa : TPointArray;
      atpa : T2DPointArray;
      i,cts,p: Integer;
    begin
      b := self.getBounds();
      b.edit(+(b.x2-b.x1)-140, +10, -5, -94);

      findColorsTolerance(tpa, 14013909, b, 4,colorSetting(2, 0.00, 0.00));

      if length(tpa) < 2 then
      begin
        writeln('chatBox.getXP(): No XP found');
        Exit;
      end;

      atpa := tpa.cluster(5);

      b:= atpa.getbounds;
      b.edit(-2,-2,+2,+3);

      s:=Replace(tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);

      P := Pos('x', S);
      if P > 0 then
        Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
      else
        Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

      debug('chatBox.getXP(): XP found: ' + tostr(result), 0);
    end;











    //============================================================================//
    // procedure setupScript();
    //   -Everything initialised; all systems go.
    //============================================================================//
    procedure setupScript();
    var
      i: Integer;
    begin
      clearDebug();
      disguise(ScriptName+ ' has been started!');
      writeln(ScriptName+' is loading.');

      loadGlobals();
      declarePlayers();
      disableSRLDebug := true;
      disableSRLLog   := true;
      debug('Setting up SRL.', 0);
      setupSRL();
      for i := 0 to howManyPlayers - 1 do
      begin
        players[i].findMod := true;
        players[i].worked.name := 'Player '+toStr(i);
        players[i].worked.start();
        players[i].worked.pause();
        players[i].booleans[P_FIRST_LOGIN] := false;
      end;

      {$IFDEF PAINT}
        smartSetupDrawing();
      {$ENDIF}

      whenBreak:= ((1000*60)*Whenbreak);
      addOnTerminate('ProgressReport');
    end;

    //============================================================================//
    // Report functions:
    //----------------------------------------------------------------------------//
    procedure CalculateTotals;
    var
      i: Integer;
    begin
      Total.XP := 0;
      Players[CurrentPlayer].Integers[P_XP] := chatBox.getXP() - Players[CurrentPlayer].Integers[P_START_XP];
      for i:=0 to HowManyPlayers-1 do
        Total.XP := Total.XP + Players[i].Integers[P_XP];

      Total.Nests := 0;
      for i:=0 to HowManyPlayers-1 do
        Total.Nests := Total.Nests + Players[i].Integers[P_NESTS];
    end;

    procedure clearReportString;
    begin
      setLength(reportString, 1);
      reportString[0] := '';
    end;

    procedure addToReportString(s: String);
    begin
      reportString[high(reportString)] := s;
      setLength(reportString, length(reportString) + 1);
    end;

    procedure progressReport();
    var
      i: Integer;
    begin
      calculateTotals();

      {$IFNDEF DEBUG}
        clearDebug();
      {$ENDIF}

      ClearReportString;
      AddToReportString('/-------------------------------------------------------------\');
      AddToReportString('|-------------------------------------------------------------|');
      AddToReportString(PadR('|                        Press Play''s', 62) + '|');
      AddToReportString(PadR('|                      ' +ScriptName, 62) + '|');
      AddToReportString(PadR('|                        Version ' + ScriptVersion, 62) + '|');
      AddToReportString('|-------------------------------------------------------------|');
      AddToReportString(PadR('|     TOTALS : ', 62) + '|');
      AddToReportString(PadR('|       Time Running  : ' +MsToTime(getTimeRunning(), TIME_ABBREV), 62) + '|');
      AddToReportString(PadR('|       Exp Gained    : ' +IntToStr(Round(total.XP)), 62) + '|');
      AddToReportString(PadR('|       Nests Gotten  : ' +IntToStr(Total.Nests), 62) + '|');
      AddToReportString(PadR('|     ', 62) + '|');
      for i:=0 to HowManyPlayers-1 do
      begin
        AddToReportString(PadR('|     PLAYER ' +IntToStr(i)+ ' : ', 62) + '|');
        AddToReportString(PadR('|       Time Running  : ' +MsToTime(players[i].worked.getTime(), TIME_ABBREV), 62) + '|');
        AddToReportString(PadR('|       Exp Gained    : ' +IntToStr(Round(Players[i].Integers[P_XP])), 62) + '|');
        if not ((players[i].worked.getTime()/60000) = 0) then
          AddToReportString(PadR('|       Exp / Hour    : ' +IntToStr(Round(Players[i].Integers[P_XP]*60/(players[i].worked.getTime()/60000))), 62) + '|');

        if not (players[i].location = '') then
          AddToReportString(PadR('|       False Reason  : ' +players[i].location, 62) + '|');
        AddToReportString(PadR('|     ', 62) + '|');
      end;
      AddToReportString(PadR('|     ', 62) + '|');
      AddToReportString('|-------------------------------------------------------------|');
      AddToReportString('\-------------------------------------------------------------/');
      for i := 0 to High(ReportString) do
          Writeln(ReportString[i]);
    end;

    //============================================================================//
    // procedure setupPlayer();
    //   -Logs in the players and sets it up - ready to go!
    //============================================================================//
    procedure setupPlayer();
    var
      i: Integer;
      a: TIntegerArray;
    begin
      players[currentPlayer].login();
      writeln('Player ' +IntToStr(CurrentPlayer)+ ' logged in.');
      paintClear();
      wait(randomRange(100, 150));
      minimap.clickCompass();
      wait(randomRange(200, 500));
      minimap.setAngle(players[currentPlayer].integers[P_WALL_DIR]);
      wait(randomRange(200, 500));
      mainscreen.setAngle(MS_ANGLE_HIGH);
      exitTreasure();
      wait(randomRange(500, 1000));

      a := chatbox._getTextColorArray();
      setLength(AChatCol, length(a));
      for i := high(a) downto 0 do
        AChatCol[i] := a[i];
      if not Players[CurrentPlayer].Booleans[P_FIRST_LOGIN] then
        Players[CurrentPlayer].Integers[P_START_XP] := chatBox.getXP();
      Players[CurrentPlayer].Booleans[P_FIRST_LOGIN] := True;
      RedCount := 0;

      roundTime.reset();
      roundTime.start();
    end;

    {$IFNDEF CODEINSIGHT}
    //============================================================================//
    // procedure takeBreak();
    //   -Takes a break based on the amount of time played by the current player.
    //============================================================================//
    procedure takeBreak();
    var
      Breaktime, Timeleft, i, e: Integer;
    begin
      if isLoggedIn() then
        players[currentPlayer].logout;

      if players[currentPlayer].worked.getTime() > (2*60*60*1000) then
      begin
        Breaktime:= randomRange(20*60*1000, 35*60*1000);
      end else
        Breaktime:= randomRange(Round(Players[CurrentPlayer].worked.getTime() / 8), Round(Players[CurrentPlayer].worked.getTime() / 4));

      Writeln('Taking a break for ' + mstotime(breaktime, Time_Abbrev) );
      Writeln('');

      i := getSystemTime();
      repeat
        wait(10000);
        e:= GetSystemTime;
        timeleft:= breaktime - (e - i);
        Disguise('We have ' + mstotime(timeleft, Time_Abbrev) + ' to go');
      until( (e - i) >= breaktime );

      Disguise('Finished break.');
    end;

    //============================================================================//
    // procedure logoutProcess();
    //   -Performs logout on current player, sets activeness and takes break.
    //============================================================================//
    procedure logoutProcess();
    begin
      Debug('Loging out.', 1);

      if bankScreen.isOpen() then
        bankScreen.close();

      if (not (lowercase(players[currentPlayer].location) = '')) or (not isLoggedIn()) then
      begin
        debugScreen(capitalize(players[currentPlayer].location)+'_'+msToTime(getTimeRunning(), TIME_ABBREV));
        players[currentPlayer].isActive := false;
      end;

      wait(logoutDelay + random(1000));
      players[currentPlayer].logout();

      progressReport();

      if not( lowercase(players[currentPlayer].location) = '') then
        players[currentPlayer].isActive := false;

      if not (players.getActive() = 0) then
      begin
        takeBreak();
      end else
        exit();

      players.next(players[currentPlayer].isActive);
    end;

    //============================================================================//
    // function tryStep(f: TBooleanFunction, errorMsg: String): boolean;
    //   -Trys a routine 5 times before exiting and return false.
    //   -Sets 'errorMsg' as player.location.
    //============================================================================//
    function tryStep(name: String; f: TBooleanFunction; errorMsg: String): boolean;
    var
      i: Integer;
    begin
      debug('Attempting to excecute ' +name+ '.', 1);
      for i := 1 to 5 do
      begin
        if f() then
        begin
          result := true;
          break();
        end;
        if not isLoggedIn() then
          if not players[currentPlayer].login() then break();
        debug('Failed to excecute ' +name+ ' ' +intToStr(i)+ ' time(s).', 2);
      end;

      if not result then
        players[currentPlayer].location := errorMsg;
    end;

    //============================================================================//
    // procedure takeAFKBreak();
    //   -Waits a random amount of time, pretending to be AFK.
    //============================================================================//
    procedure takeAFKBreak();
    begin
      case random(25) of
        10: begin
              debug('Taking AFK break.', 1);
              wait(randomRange(10000, 45000));
            end;
      end;
    end;

    //============================================================================//
    // function mainLoopSucessful(): boolean;
    //   -Performs one iteration of the main loop for a single player.
    //============================================================================//
    function mainLoopSucessful(): boolean;
    begin
      if not tryStep('chopIvy()', @chopIvy, 'Could not chop Ivy') then
        exit();

      if not tryStep('waitWhileChop()', @waitWhileChop, 'Timed out while chopping') then
        exit();

      takeAFKBreak();

      progressReport();

      result:= True;
    end;

    //============================================================================//
    // function playerActive(): boolean;
    //   -Overwrites player.location if SRL has overwritten it; returns true
    //    if the current player is deemed to be active.
    //============================================================================//
    function playerActive(): boolean;
    var
      arr: TVariantArray;
    begin
      {arr := __getLoginResponse(players[currentPlayer].location, 0);

      if length(arr) > 0 then
        if (arr[__RES_ACTION] = 'true')
        or (arr[__RES_ACTION] = 'update') then
          players[currentPlayer].location := '';

      if (players[currentPlayer].location = '') then
        result := true;}

      if not isLoggedIn() then
      begin
        result := false;
        exit;
      end;

      result := true;
    end;
    {$ENDIF}




    {------------------------------------------------------------------------------]
    [  MAIN LOOP:                                                                  ]
    [     Where all the routines are combined into a working script!               ]
    [------------------------------------------------------------------------------}

    BEGIN
      setupScript();

      repeat
        setupPlayer();

        repeat

          if not playerActive() then
            break();

          if not mainLoopSucessful() then
            break();

        until( roundTime.getTime() >= (whenBreak + randomRange(-(1000*60*3), (1000*60*3)) ) );

        logoutProcess();

      until( players.getActive() = 0 );
      debug('All players are inactive.', 1);
      debug('Script is finished.', 1);

      if isLoggedIn() then
        players[currentPlayer].logout();

      terminateScript();
    END.
    Commenting out works too I spose, (does it have any problems with your commented out code? i.e. Doesn't run past a certain time? or something - I haven't bothered to look at it enough to work out what the call actually does.

    All I did was an an extra parameter in at the end.

    Code:
      arr := __getLoginResponse(players[currentPlayer].location, 0);
    becomes
    Code:
    arr := __getLoginResponse(players[currentPlayer].location, 0, 0);

  21. #121
    Join Date
    Feb 2007
    Posts
    38
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by PheteyGee View Post
    Commenting out works too I spose, (does it have any problems with your commented out code? i.e. Doesn't run past a certain time? or something - I haven't bothered to look at it enough to work out what the call actually does.

    All I did was an an extra parameter in at the end.

    Code:
      arr := __getLoginResponse(players[currentPlayer].location, 0);
    becomes
    Code:
    arr := __getLoginResponse(players[currentPlayer].location, 0, 0);
    Adding an extra parameter didn't solve the issue at line 1105. Commenting out will allow you to run it, I will post again later with the results of my test run.

  22. #122
    Join Date
    Jun 2013
    Posts
    7
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Error: Unknown declaration "__getLoginResponse" at line 1105
    Compiling failed.

  23. #123
    Join Date
    Oct 2014
    Posts
    34
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by darkfire23 View Post
    Adding an extra parameter didn't solve the issue at line 1105. Commenting out will allow you to run it, I will post again later with the results of my test run.
    i commented it out along with 1108 and 1009, seems like its working well.

  24. #124
    Join Date
    Oct 2014
    Posts
    34
    Mentioned
    0 Post(s)
    Quoted
    10 Post(s)

    Default

    got it to run for 3 hours varrock south-looking near years.

  25. #125
    Join Date
    Apr 2014
    Posts
    96
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default

    Error: Unknown declaration "__getLoginResponse" at line 1105
    Compiling failed.

    having a little trouble. Please help

Page 5 of 6 FirstFirst ... 3456 LastLast

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
  •