All pastes #439907 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-14 16:53 UTC
rendered paste body
{ ---------------------------------------------------------------------------- ]
[   .________                           _______.__   .__.__  .__               ]
[   \_____   \______  _  __ ___________/   ____/  | _|__|  | |  |   ______     ]
[    |    ___/  _ \ \/ \/ // __ \_  __ \____  \|  |/ /  |  | |  |  /  ___/     ]
[    |   |  (  <_> )     /\  ___/|  | \/       \    <|  |  |_|  |__\___  \     ]
[    |___|   \____/ \/\_/  \___ \|__| /______  /__|_ \__|____/____/____  /     ]
[                              \/            \/     \/                 \/      ]
[                                               By Starblaster100              ]
[ ---------------------------------------------------------------------------- ]
[                          >>   DESCRIPTION   <<                               ]
[ ---------------------------------------------------------------------------- ]
[  This Script is Designed to Power Auto a Specific Skill on a Specific Char   ]
[  until  a  Certain Number of Loads have been Power Autoed.  This will then   ]
[  Switch Character and Power Auto the next Players Specific Skill. This will  ]
[  Keep Repeating until all Players are Inactive, or the script is Terminated  ]                                                                ]
[ ---------------------------------------------------------------------------- ]
[                        >>   SUPPORTED SKILLS   <<                            ]
[ ---------------------------------------------------------------------------- ]
[    o  Mining       - Must have a Pick and be near Minable Rocks              ]
[    o  Woodcutting  - Must have an Axe and be near Cuttable Trees             ]
[    o  Fishing      - Must have Fishing Equipment and be near a Fish Spot     ]
[    o  Bone Burying - Must be near Bones, or a Bank if Withdrawing from Bank  ]
[    o  Fletching    - Must be in a Bank, and have a Knife if Cutting any Logs ]
[                      Place All Fletching Items in First Few Bank Slots       ]
[ ---------------------------------------------------------------------------- ]
[                       >>   SETUP INSTRUCTIONS   <<                           ]
[ ---------------------------------------------------------------------------- ]
[    o  For each Individual Player, Equip the  *Specific Equipment* needed to  ]
[       Power the Specific Skill Selected                                      ]
[    o  *Place* Each Individual Player in the *Specific Spots* where they are  ]
[       going to work                                                          ]
[    o  Run the Script and Fill in the Setup                                   ]
[    o  Do not Change Anything in the Script Itself. Hit the Run Button Now!   ]
[ ---------------------------------------------------------------------------- ]
[                         Script by Starblaster100                             ]
[       Please Post Progress Reports, Bugs and Suggestions in my Thread!       ]
[ ---------------------------------------------------------------------------- }

program PowerSkills_By_Starblaster100;
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/Mining.scar}
{.include SRL/SRL/Skill/Woodcutting.scar}
{.include SRL/SRL/Skill/Fishing.scar}
{.include SRL/SRL/Extended/xMapWalk.scar}

Const
  VerNumber = '2.3';      //Version number.  No need to Change
  DebugNumber = 1;        //How to Display Progress. To See all Debug, Set as 2, Otherwise 1 is Recommended.
  PrintReport = 1;        //How Often in minutes to Print the Progress Report. 1-5 Recommended.
  AntiBanRandomness = 5;  //The Bigger the Number, the less Chance of Antiban Procedures Occuring.  5 Recomended.

Var
  TitleLabel, UsernameLabel, PasswordLabel, LampSkillLabel, ColorsLabel, TripsLabel, MiningSecsLabel : TLabel;
  LeftButton, RightButton, StartButton, CreatePlayerButton, DeletePlayerButton, DonateButton : TButton;
  String1ComboBox, String2ComboBox, String3ComboBox, LampSkillComboBox, FletchComboBox : TComboBox;
  UsernameEdit, PasswordEdit, ColorsEdit, LoadsEdit, MiningSecsEdit : TEdit;
  DTMBones, DTMBigBones, Report2, BrokenAxeMask, DTMLog: Integer;
  IsActive, ColorCheckBox, BankCheckBox, GemsCheckBox: TCheckBox;
  DTMFletching: Array[1..4] of Integer;
  DTMFishing: Array[1..7] of Integer;
  DTMMining: Array[1..2] of Integer;
  SkipItems: Array[1..21] of String;
  PowerMainSkillsFileName: String;
  FletchString: Array of String;
  StartScript: Boolean;
  frmDesign : TForm;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure StarDebug(S: String; How: Integer);                           ]
[  >>  How to Display the Debug. For my use Really, you can Change if You Want ]
[ ---------------------------------------------------------------------------- }

Procedure StarDebug(S: String; How: Integer);
Begin
  Case How of
    1: Status(s);
    2: Writeln(s);
    3: Players[CurrentPlayer].loc := S;
    4: Begin
         Status(S);
         Players[CurrentPlayer].loc := S;
       end;
    else Exit;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure Intro;                                                        ]
[  >>  Script name, Version and Author                                         ]
[ ---------------------------------------------------------------------------- }

Procedure Intro;
Begin
  ClearDebug;
  Status('Script Created by Starblaster100');
  Writeln(' .________                           _______.__   .__.__  .__           ');
  Writeln(' \_____   \______  _  __ ___________/   ____/  | _|__|  | |  |   ______ ');
  Writeln('  |    ___/  _ \ \/ \/ // __ \_  __ \____  \|  |/ /  |  | |  |  /  ___/ ');
  Writeln('  |   |  (  <_> )     /\  ___/|  | \/       \    <|  |  |_|  |__\___  \ ');
  Writeln('  |___|   \____/ \/\_/  \___ \|__| /______  /__|_ \__|____/____/____  / ');
  Writeln('                            \/            \/     \/                 \/  ');
  Writeln('             Ver '+VerNumber+'                     By Starblaster100    ');
  ReportVars[0] := ReportVars[0] + 1;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure WriteNews;                                                    ]
[  >>  Downloads the Latest News from the Server                               ]
[ ---------------------------------------------------------------------------- }

Procedure WriteNews;
Var
  Timer, i, x, y, Temp, HowMany: integer;
  News : Array of String;
  New, TheNews : String;
Begin
  ChangeReportWidth(390);
  ClearDebug;
  ClearReport;
  Status('Downloading Latest News...');
  Writeln('Please Wait whilst the Latest PowerSkills News is Downloaded...');
  Wait(1);
  TheNews := Getpage('http://starblaster.freehostia.com/PowerSkillsNews.txt');
  AddToReport(' >> Latest PowerSkills News:');
  AddToReport(Chr(32));

  For Temp := 1 to Length(TheNews) do
    If(Copy(TheNews, Temp, 1) = ',') then
      HowMany := HowMany + 1;
  x := 0;
  y := 1;
  SetArrayLength(News, HowMany+1);
  For i := 1 to HowMany do
  Begin
    MarkTime(Timer);
    repeat
      x := x + 1;
      new := copy(TheNews, x, x+1);
    until(copy(new, 1, 1) = ',')or(TimeFromMark(Timer) >= 2000);
    news[i]:= copy(TheNews, y, (x-y));
    y := x + 1;
    Wait(1);
  end;
  For i := 1 to HowMany do
    AddToReport(' :: '+news[i]);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure SendPSStats(Skill: String);                                   ]
[  >>  Updates the Stats to the SRL Server                                     ]
[ ---------------------------------------------------------------------------- }

Procedure SendPSStats(Skill: String);
Begin
  StarDebug('Sending Stats', DebugNumber);
  Case Lowercase(Skill) of
    'mining'      : begin
                      If (EquipPick) then
                        ReportVars[4] := ReportVars[4] + 28
                      else
                        ReportVars[4] := ReportVars[4] + 27;
                    end;
    'woodcutting' : begin
                      If (EquipAxe) then
                        ReportVars[5] := ReportVars[5] + 28
                      else
                        ReportVars[5] := ReportVars[5] + 27;
                    end;
    'fishing'     : ReportVars[6] := ReportVars[6] + 27;
    'bone burying': ReportVars[7] := ReportVars[7] + 28;
    'fletching'   : case (Lowercase(Players[CurrentPlayer].String2)) of
                      'logs --> (u) shortbow'         : ReportVars[8] := ReportVars[8] + 27;
                      'logs --> (u) longbow'          : ReportVars[8] := ReportVars[8] + 27;
                      '(u) shortbow --> (s) shortbow' : ReportVars[8] := ReportVars[8] + 14;
                      '(u) longBow --> (s) longbow'   : ReportVars[8] := ReportVars[8] + 14;
                      'logs --> (s) shortbow'         : ReportVars[8] := ReportVars[8] + 13;
                      'logs --> (s) longbow'          : ReportVars[8] := ReportVars[8] + 13;
                    end;
    else Writeln('Unsupported Skill, Stats could not be Sent');
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Function ExpPerItem(Skill, ItemName: string): Extended;                 ]
[  >>  Loads the Exp for Each Skill and Each Item in the Specific Skill        ]
[ ---------------------------------------------------------------------------- }

Function ExpPerItem: Extended;
begin
  Case LowerCase(Players[CurrentPlayer].String1) of
    'woodcutting' : Begin
                      case LowerCase(Players[CurrentPlayer].String2) of
                        'tree'    : Result := 25;
                        'oak'     : Result := 37.5;
                        'willow'  : Result := 62.5;
                        'maple'   : Result := 100;
                        'mahogany': Result := 125;
                        'yew'     : Result := 175;
                        'magic'   : Result := 250;
                        else Begin Writeln('Unsupported WC Item'); Result := 0; end;
                      end;
                    end;
    'mining'      : Begin
                      case LowerCase(Players[CurrentPlayer].String2) of
                        'tin'    : Result := 17.5;
                        'copper' : Result := 17.5;
                        'iron'   : Result := 35;
                        'coal'   : Result := 50;
                        'mith'   : Result := 80;
                        'gold'   : Result := 65;
                        'silver' : Result := 40;
                        'addy'   : Result := 95;
                        'rune'   : Result := 125;
                        else Begin Writeln('Unsupported Mining Item'); Result := 0; end;
                      end;
                    end;
    'fishing'     : Begin
                      case LowerCase(Players[CurrentPlayer].String2) of
                        'net'     : Result := 25;
                        'cage'    : Result := 90;
                        'harpoon' : Result := 90;
                        else Begin Writeln('Unsupported Fishing Item'); Result := 0; end;
                      end;
                    end;
    'bone burying': Begin
                      case LowerCase(Players[CurrentPlayer].String2) of
                        'bones'     : Result := 4.5;
                        'big bones' : Result := 15;
                        else Begin Writeln('Unsupported Bone Burying Item'); Result := 0; end;
                      end;
                    end;
    'fletching'   : begin
                      case Lowercase(Players[CurrentPlayer].String2) of
                        'logs --> (u) shortbow',
                        '(u) shortbow --> (s) shortbow' : begin
                                                            case Lowercase(FletchString[CurrentPlayer]) of
                                                              'normal' : Result := 5;
                                                              'oak'    : Result := 16.5;
                                                              'willow' : Result := 33.3;
                                                              'maple'  : Result := 50;
                                                              'yew'    : Result := 66.5;
                                                              'magic'  : Result := 83.3;
                                                              else Writeln('Fletching Log Type not Recognised!');
                                                            end;
                                                          end;
                        'logs --> (u) longbow',
                        '(u) longbow --> (s) longbow'   : begin
                                                            case Lowercase(FletchString[CurrentPlayer]) of
                                                              'normal' : Result := 10;
                                                              'oak'    : Result := 25;
                                                              'willow' : Result := 41.5;
                                                              'maple'  : Result := 58.3;
                                                              'yew'    : Result := 75;
                                                              'magic'  : Result := 91.5;
                                                              else Writeln('Fletching Log Type not Recognised!');
                                                            end;
                                                          end;
                        'logs --> (s) shortbow'         : begin
                                                            case Lowercase(FletchString[CurrentPlayer]) of
                                                              'normal' : Result := 10;
                                                              'oak'    : Result := 33;
                                                              'willow' : Result := 66.6;
                                                              'maple'  : Result := 100;
                                                              'yew'    : Result := 133;
                                                              'magic'  : Result := 166.6;
                                                              else Writeln('Fletching Log Type not Recognised!');
                                                            end;
                                                          end;
                        'logs --> (s) longbow'          : begin
                                                            case Lowercase(FletchString[CurrentPlayer]) of
                                                              'normal' : Result := 20;
                                                              'oak'    : Result := 50;
                                                              'willow' : Result := 83;
                                                              'maple'  : Result := 116.6;
                                                              'yew'    : Result := 150;
                                                              'magic'  : Result := 183;
                                                              else Writeln('Fletching Log Type not Recognised!');
                                                            end;
                                                          end;
                        else Writeln('Unknown Fletching Type!');
                      end;
                    end;
    else Begin Writeln('Unsupported Skill'); Result := 0; end;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure ProgressReport;                                               ]
[  >>  Prints The Progress Report every "PrintReport" Minutes                  ]
[ ---------------------------------------------------------------------------- }

Procedure ProgressReport(ForceProgress: Boolean);
Var
  i, TempLoads: Integer;
  TempExp: Extended;
Begin
  If (GetSystemTime - Report2 >= PrintReport * 60000) or (ForceProgress) then
  Begin
    StarDebug('Progress Report', DebugNumber);
    For i := 0 to (HowManyPlayers-1) do
      TempLoads := TempLoads + Players[i].Banked;
    For i := 0 to (HowManyPlayers-1) do
      TempExp := TempExp + (ExpPerItem * Players[i].Banked * 28);
    Writeln('<---------------------------------------------->');
    Writeln('¦     PowerSkills Ver '+VerNumber+' By Starblaster100    ¦');
    Writeln('<---------------------------------------------->');
    Writeln('  Total Running Time    : ' +TimeRunning);
    Writeln('  Total Loads Done      : ' +IntToStr(TempLoads));
    Writeln('  Total Exp Gained      : ' +FloatToStr(TempExp));
    Writeln('<---------------------------------------------->');
    Writeln('  Current Player No.    : ' +IntToStr(CurrentPlayer+1)+ '/' +IntToStr(HowManyPlayers));
    Writeln('  Current Player Name   : ' +Players[CurrentPlayer].Name);
    Writeln('  Player Power Skilling : ' +Players[CurrentPlayer].String1);
    Writeln('  Player Running Time   : ' +IntToStr(Players[CurrentPlayer].Worked)+ ' Minutes');
    Writeln('  Current Player Loads  : ' +IntToStr(Players[CurrentPlayer].Banked));
    If (LoggedIn) then
    begin
      Case Lowercase(Players[CurrentPlayer].String1) of
        'woodcutting' : Writeln('  WC Levels Gained      : ' +IntToStr(GetSkillLevel('woodcutting')-Players[CurrentPlayer].Level[20]));
        'mining'      : Writeln('  Mining Levels Gained  : ' +IntToStr(GetSkillLevel('mining')-Players[CurrentPlayer].Level[15]));
        'fishing'     : Writeln('  Fishing Levels Gained : ' +IntToStr(GetSkillLevel('fishing')-Players[CurrentPlayer].Level[17]));
        'bone burying': Writeln('  Prayer Levels Gained  : ' +IntToStr(GetSkillLevel('prayer')-Players[CurrentPlayer].Level[5]));
        'fletching'   : Writeln('  Fletch Levels Gained  : ' +IntToStr(GetSkillLevel('fletching')-Players[CurrentPlayer].Level[13]));
      end;
    end;
    Writeln('  Exp Approx Gained     : ' +FloatToStr(ExpPerItem * Players[CurrentPlayer].Banked * 28));
    Writeln('  Player Worked for     : '+IntToStr(Players[CurrentPlayer].Worked)+' Minutes');
    Writeln('  Player Currently      : '+Players[CurrentPlayer].loc);
    Writeln('<---------------------------------------------->');
    For i := 0 to HowManyPlayers-1 do
      Writeln('  ' +IntToStr(i)+ ' : '+Players[i].Name+' = '+BoolToStr(Players[i].Active)+
        ', Skill: '+ Players[CurrentPlayer].String1 +', '+IntToStr(Players[i].Worked)+
        ' Minutes, Loads: '+IntToStr(Players[i].Banked)+', Curently: '+Players[i].Loc);
    Writeln('<---------------------------------------------->');
    SRLRandomsReport;
    Report2 := GetSystemTime;
    GameTab(4);
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  procedure Color32ToRGB(Color: Integer; var R, G, B: Integer);           ]
[  >>  Converts a Color into RGB - Thanks to Lorax                             ]
[ ---------------------------------------------------------------------------- }

procedure Color32ToRGB(Color: Integer; var R, G, B: Integer);
begin
  B := (Color and $00ff0000) shr 16;
  G := (Color and $0000ff00) shr 8;
  R := (Color and $000000ff);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  function Randoms(Skill: String): Boolean;                               ]
[  >>  Finds and Solves Randoms, Courtesy of SRL                               ]
[ ---------------------------------------------------------------------------- }

function Randoms(Skill: String): Boolean;
var
  TX, TY, i: Integer;
begin
  for i := 1 to 17 do
  begin
    case I of
      1: CloseWindow;
      2: if FindTalk then
           Result := True;
      3: if FindDead then
           Result := True;
      4: if FindMod then
           Result := True;
      5: if FindMime then
           Result := True;
      6: if FindMaze then
           Result := True;
      7: if FindQuiz then
           Result := True;
      8: if FindDemon then
           Result := True;
      9: if FindScapeRune then
           Result := True;
      10: if FindTalk then
            Result := True;
      11: if FindLamp(Players[CurrentPlayer].Skill) then
            Result := True;
      12: if (FindNewBox) then
          begin
            Result := True;
            if (UseBoxSolver) then
              SolveBox
            else
              GambleNewBox;
          end;
      13: if FindTrade then
            Result := True;
      14: if NoGameTab then
          begin
            Result := True;
            Players[CurrentPlayer].loc := 'No GameTab';
            Logout;
            Exit;
          end;
      15: if (FindFight) then
          begin
            result := true;
            RunAwayDirection(Players[CurrentPlayer].String3);
            Wait(5000 + Random(2500));
            RunBack;
          end;
      16: If(FindNpcChatText('ongr'))then
          begin
            ClickToContinue;
            Result := True;
            ReportVars[1] := ReportVars[1] + 1;
          end;
      17: ProgressReport(False);
    end;
    Wait(1);
  end;
  case Lowercase(Skill) of
    ''           : Wait(1);
    'woodcutting': Begin
                     For i := 0 to 1 do
                     Begin
                       Case i of
                         0: If (InChat('do not') or InChat('have axe')) then
                            begin
                              if ( EquipAxe ) then
                                GameTab ( 2 )
                              else
                                GameTab ( 4 );
                              Wait(400 + Random(200));
                              if FindBitmapMaskTolerance ( BrokenAxeMask, TX, TY, MIX1, MIY1, MIX2, MIY2, 10, 2 ) then
                              Begin
                                Result := True;
                                Logout;
                                Players[CurrentPlayer].Loc := 'Broken Axe';
                                Players[CurrentPlayer].Active := False;
                                Exit;
                              end;
                              If not(FindHead) then
                              begin
                                Result := True;
                                Logout;
                                Players[CurrentPlayer].Loc := 'Lost Axe Head';
                                Players[CurrentPlayer].Active := False;
                                Exit;
                              end;
                            end;
                         1: FindBirdsNest;
                       end;
                       Wait(1);
                     end;
                   end;
    'mining'  : Begin
                  For i := 0 to 1 do
                  Begin
                    Case i of
                      0: if not (FindPick) then
                         begin
                           Result := True;
                           Logout;
                           Players[CurrentPlayer].Loc := 'Lost Mining Equipment';
                         end;
                      1: Begin
                           GetMousePos(x, y);
                           If (x < MMX2) and (y < MMY2) and (x > MMX1) and (y > MMY1+21)then
                             GasCheck(x, y-20);
                         end;
                    end;
                    Wait(1);
                  end;
                end;
    'fishing' : Begin
                  For i := 0 to 2 do
                  Begin
                    Case i of
                    {  0: if not (FindFishingEquipment) then    //Doesn't Work!
                         begin
                           Result := True;
                           Logout;
                           Players[CurrentPlayer].Loc := 'Lost Fishing Equipment';
                         end;               }
                      1: HandleWhirlPool;
                      2: If (FindPlant) then
                           Result := True;
                    end;
                    Wait(1);
                  end;
                end;
    else Writeln('Randoms are Incorrect Star! Recode the Script!');
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure DoAntiBan;                                                    ]
[  >>  Does some Random AntiBan Procedures                                     ]
[ ---------------------------------------------------------------------------- }

Procedure DoAntiBan(Extras: Boolean);
Begin
  If not(LoggedIn) then Exit;
  If (Extras) then
  Begin
    Case Random(20) of
      0: RandomRClickEvery(2 + Random(8));
      1: HoverSkill('random', false);
      2: RotateEvery(20 + Random(10));
      3: LeaveScreenEvery(5 + Random(5));
      4: PickUpMouse;
      5: BoredEvery(9 + Random(24));
      6: Begin
           GameTab(1 + Random(12));
           Wait(1500 + Random(500));
           GameTab(4);
         end;
      7: SleepAndMoveMouse(1000 + Random(1000));
      8: MMouse(Random(MSX2), Random(MSY2), 0, 0);
    end;
  end else
  begin
    Case Random(10) of
      0 : IdleTime(1000 + Random(350), 500, 1.0);
      1 : IdleTime(1000 + Random(350), 1000, 1.0);
      2 : IdleTime(1000 + Random(350), 750, 0.5);
      3 : SleepAndMoveMouse(2500 + Random(2500));
      4 : SleepAndMoveMouse(1500 + Random(1500));
      5 : SleepAndMoveMouse(500 + Random(500));
    end;
  end;
  FindTalk;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  procedure LoadNullWords;                                                ]
[  >>  Loads Words which cannot be your Nickname - by Mad Cow                  ]
[ ---------------------------------------------------------------------------- }

procedure LoadNullWords;
begin
  SkipItems[1] := 'the';
  SkipItems[2] := 'but';
  SkipItems[3] := 'yes';
  SkipItems[4] := 'lol';
  SkipItems[5] := 'brb';
  SkipItems[6] := 'gtg';
  SkipItems[7] := 'cya';
  SkipItems[8] := 'how';
  SkipItems[9] := 'hey';
  SkipItems[10] := 'wat';
  SkipItems[11] := 'umm';
  SkipItems[12] := 'him';
  SkipItems[13] := 'she';
  SkipItems[14] := 'man';
  SkipItems[15] := 'wow';
  SkipItems[16] := 'god';
  SkipItems[17] := 'nub';
  SkipItems[18] := 'nop';
  SkipItems[19] := 'did';
  SkipItems[20] := 'you';
  SkipItems[21] := 'ing';
end;

{ ---------------------------------------------------------------------------- ]
[  >>  function CreateNick(Username : String) : String;                        ]
[  >>  Creates your Nickname from your Username - by Mad Cow                   ]
[ ---------------------------------------------------------------------------- }

function CreateNick(Username : String) : String;
var
  UserLength, NickStart, INick, A : Integer;
  Nicks, Temp : String;
  BadNick : Boolean;
begin
  UserLength := Length(Username);
  INick := 0;
  LoadNullWords;
  repeat
    BadNick := False;
    NickStart := 2 + INick;
    Nicks := Nicks + Copy(Username, NickStart, 3);
    for A := 1 to 3 do
    begin
      Temp := Copy(Nicks, A, 1);
      if(Temp = ' ') or (Temp = '_')then
      begin
        INick := INick + 1;
        Nicks := '';
        BadNick := True;
      end;
    end;
    for A := 1 to 21 do
    begin
      if(Nicks = SkipItems[A]) then
      begin
        INick := INick + 1;
        Nicks := '';
        BadNick := True;
      end;
    end;
  until((not(BadNick)) or (NickStart >= 15))
  Result := Nicks;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure GenerateNickNames;                                            ]
[  >>  Saves Nicknames, and Sets Default Locations, by Mad Cow Edited by Star  ]
[ ---------------------------------------------------------------------------- }

Procedure GenerateNickNames;
Begin
  Writeln('');
  Writeln('Creating Nicknames:');
  Status('Creating Nicknames');
  For X := 0 to HowManyPlayers - 1 do
  begin
    if(Players[X].Nick = '') then
    begin
      Players[X].Nick := CreateNick(Players[X].Name);
      WriteLn('  Players[' + IntToStr(X) + '].Nick := ' + Players[X].Nick + ';');
      Wait(1);
    end;
  end;
  Writeln('');
  Status('Setting Players Current Location:');
  For X := 0 to HowManyPlayers - 1 do
    Players[X].Loc := 'Not Yet Started Autoing';
  Status('If you see this Message for Longer than 3 Seconds, Stop the Script and Restart Straight Away!');
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Function UpdateCoords(Var ax, ay: Integer; TheColor: Integer): Boolean; ]
[  >>  Updates Color Coords When you are Moving after a Click                  ]
[  >>  Huge Thanks to Sumillion and Lorax for the Function - modified by Star  ]
[ ---------------------------------------------------------------------------- }

Function UpdateCoords(Var cx, cy: Integer; ax, ay, TheColor, Tol: Integer): Boolean;
var
  //ax, ay,
  Counter: Integer;
Begin
  StarDebug('Updating Color Coords ...', DebugNumber);
  //GetMousePos(ax, ay);
  If (ax < 20) then ax := 20; If (ay < 20) then ay := 20;
  While (FlagPresent) and (FindColorSpiralTolerance(cx, cy, TheColor, ax-20, ay-20, ax+20, ay+20, Tol)) do
  begin
    ax := cx; ay := cy;
    Wait(15);
  end;
  If (ax < 10) then ax := 10; If (ay < 10) then ay := 10;
  While (FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol)) and (Counter < 60) do
  begin
    ax := cx; ay := cy;
    Counter := Counter + 1;
    Wait(15);
  end;
  Result := FindColorSpiralTolerance(cx, cy, TheColor, ax-10, ay-10, ax+10, ay+10, Tol);
  if (not Result) then
    StarDebug('We lost the Color while Updating it', DebugNumber)
  else
    StarDebug('Updated Color Coords', Debugnumber);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Mining                                                          ]
[  >>  Procedure AutoRockColor;                                                ]
[  >>  Automatically gets the Rock Color.  If this Fails, Set it Yourself      ]
[ ---------------------------------------------------------------------------- }

Procedure AutoRockColor;
var
  OreTol, i : integer;
begin
  StarDebug('Picking Ore Colors', DebugNumber);
  If not(Loggedin) then Exit;
  If (Players[CurrentPlayer].Integer1 > 0) then Exit;

  Case Lowercase(Players[CurrentPlayer].String2) of
    'copper'  : Begin Players[CurrentPlayer].Integer1 := 3824768;  OreTol := 35; end;
    'tin'     : Begin Players[CurrentPlayer].Integer1 := 7829375;  OreTol := 35; end;
    'iron'    : Begin Players[CurrentPlayer].Integer1 := 2305870;  OreTol := 25; end;
    'coal'    : Begin Players[CurrentPlayer].Integer1 := 2834753;  OreTol := 13; end;
    'mith'    : Begin Players[CurrentPlayer].Integer1 := 7359564;  OreTol := 20; end;
    'gold'    : Begin Players[CurrentPlayer].Integer1 := 1881051;  OreTol := 20; end;
    'silver'  : Begin Players[CurrentPlayer].Integer1 := 12434885; OreTol := 20; end;
    'addy'    : Begin Players[CurrentPlayer].Integer1 := 6322272;  OreTol := 20; end;
    'rune'    : Begin Players[CurrentPlayer].Integer1 := 0;        OreTol := 20; end;
  end;

  Repeat
    If(FindOreColors(Players[CurrentPlayer].Integer1, 5, OreTol))then Break;
    If(Not(Loggedin))then Break;
    i := i + 1;
    KeyDown(VK_LEFT);
    Wait(100 + random(100));
    KeyUp(VK_LEFT);
    If(i > 49) then
    Begin
      Writeln('Could not find Ore Color --> Switching player.')
      Logout;
    end;
  Until(i > 49)
  MakeCompass('N');
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Mining                                                          ]
[  >>  Procedure ChangeGasPixels(Var Gasx,GasY:Integer);                       ]
[  >>  Changes the Gas Color so that it can be Found if Present                ]
[ ---------------------------------------------------------------------------- }

Procedure ChangeGasPixels(Var Gasx, GasY: Integer); //Courtesy of Wizzup? Thanks dude!
Var
   TempX, TempY: Integer;
Begin
  Wait(100);
  StarDebug('Changing Gas Pixels', DebugNumber);
  If FlagPresent Then
  Begin
    FFlag(0);
    If FindColorSpiralTolerance(x, y, OreColor, MSX1, MSY1, MSX2, MSY2, 4) Then
    Begin
      x := TempX;
      y := TempY;
      If CheckOre(x, y, OreColor, 4) > 2 Then
      Begin
        If Distance(MSCX, MSCY, TempX, Tempy) < 40 Then
        Begin
          GasX := x;
          GasY := y;
        end;
      end;
    end;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Mining                                                          ]
[  >>  Function GasFound(CheckForGas: Boolean; cx, cy: Integer): Boolean;      ]
[  >>  Checks for and Handles Gas.  Will also just move if Needed              ]
[ ---------------------------------------------------------------------------- }

Function CheckGas(S: String; CheckForGas: Boolean; cx, cy: Integer): Boolean;
Var
  Mark, c: Integer;
Begin
  If (CheckForGas) then
  begin
    If GasCheck(cx, cy-20) or FindGas(cx, cy-20)then
    Begin
      Repeat
        c := c + 1;
        Result := True;
        Mouse(648, 83, 2, 2, True);
        Wait(400 + Random(400));
      until(c >= 2)
      MarkTime(Mark);
    end;
  end else
  Begin
    Repeat
      c := c + 1;
      Result := True;
      Mouse(648, 83, 2, 2, True);
      Wait(400 + Random(400));
    until(c >= 2)
    MarkTime(Mark);
  end;
  If (Result) then
  Begin
    Case Lowercase(S) of
      'gas' : ReportVars[2] := ReportVars[2] + 1;
      'ent' : ReportVars[3] := ReportVars[3] + 1;
    end;
    While (TimeFromMark(Mark) < 15000) do
    begin
      StarDebug(Capitalize(S) + ' Found!', 4);
      SleepAndMoveMouse(1000);
      Randoms('');
    end;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Mining                                                          ]
[  >>  Procedure MineRock(SecondsToWait: Integer);                             ]
[  >>  Starts Mining a Rock and Waits for it to be Mined                       ]
[ ---------------------------------------------------------------------------- }

Procedure MineRock(SecondsToWait: Integer);
Var
  Current, Mark, cx, cy: Integer;
Begin
  If not(Loggedin) then Exit;
  StarDebug('Mining Ore', DebugNumber);

  If (OreColor1 > 0) and (OreColor2 > 0) and (OreColor3 > 0)then
  begin
    Case Random(3) of
      0: Players[CurrentPlayer].Integer1 := OreColor1;
      1: Players[CurrentPlayer].Integer1 := OreColor2;
      2: Players[CurrentPlayer].Integer1 := OreColor3;
    end;
  end;

  While not(FindColorSpiralTolerance(x, y, Players[CurrentPlayer].Integer1, MSX1, MSY1, MSX2, MSY2, 5)) do
  Begin
    If not(LoggedIn) then Exit;
    Randoms('mining');
    Wait(100);
  end;

  Current := InvCount;

  If (FindObj(cx, cy, 'Mine', Players[CurrentPlayer].Integer1, 5))then
  begin
    If not(CheckGas('Gas', True, cx, cy))then
    begin
      If not(Random(10) = 7) then
        Mouse(cx, cy, 0, 0, True)
      else
      Begin
        Mouse(cx, cy, 0, 0, False);
        Wait(100 + Random(100));
        ChooseOption(x, y, 'Mine');
      end;
      ChangeGasPixels(cx, cy);
      GetMousePos(x, y);
      If(x < MSX1) or (x > MSX2) or (y < MSY1) or (y > MSY2) then
        MMouse(Random(MSCX), Random(MSCY), 0, 0);
      MarkTime(Mark);
      Repeat
        Status('Waiting for "You Swing your Pick..."');
        If Randoms('mining') then  Exit;
        If (GetColor(103, 421) = 0) and (GetColor(195, 426) = 0)then Break;
        If (InChat('You swing')) then Break;
        If (InChat('There is')) then Break;
      Until(TimeFromMark(Mark) >= 1500)

      MarkTime(Mark);
      Repeat
        Status('Waiting for "You Managed to Mine..."');
        If Randoms('Mining')then Exit;
        If CheckGas('Gas', True, cx, cy) then Exit;
        If (GetColor(77, 421) = 0) and (GetColor(131, 422) = 0) and (GetColor(146, 421) = 0)then Break;
        If (InChat('There is')) then Break;
        If (InChat('You man')) then Break;
        Wait(10);
      Until(TimeFromMark(Mark) > SecondsToWait * 1000) or
      (InventoryCount >= 28) or (not(GetColor(109, 430) = 0) and (not(GetColor(195, 426) = 0)))

      If (TimeFromMark(Mark) > SecondsToWait * 1000) then
        If(Random(AntiBanRandomness) = 0) then
          DoAntiBan(True);
      If(InvCount > Current)then
        StarDebug('Mined an Ore!', 4);
    end;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Woodcutting                                                     ]
[  >>  Procedure AutoTreeColor(TreeTypeColor : String);                        ]
[  >>  Automatically gets the Tree Color.  If this Fails, Set it Yourself      ]
[ ---------------------------------------------------------------------------- }

Procedure AutoTreeColor(TreeTypeColor : String);
Var
  C, TempTreeColor : Integer;
Begin
  If not(Loggedin) then Exit;
  Case Lowercase(TreeTypeColor)of
    'tree','' : TempTreeColor := 3504232;
    'oak'     : TempTreeColor := 3106904;
    'willow'  : TempTreeColor := 4417632;
    'maple'   : TempTreeColor := 32928;
    'mahogany': TempTreeColor := 3697506;
    'yew'     : TempTreeColor := 3371104;
    'magic'   : TempTreeColor := 14678264;
  End;
  If(Players[CurrentPlayer].Integer1 > 0)Then
    Exit;
  StarDebug('Getting Tree Color', DebugNumber);
  For C := 0 to 30 do
  Begin
    If(Findobj(x, y, 'Chop down '+Capitalize(TreeTypeColor), TempTreeColor, C))Then
    Begin
      GetMousePos(x, y);
      Players[CurrentPlayer].Integer1 := Getcolor(x, y);
      Writeln('Tree Color Successfully Found: '+IntToStr(Players[CurrentPlayer].Integer1)+' at: ('+IntToStr(x)+', '+IntToStr(y)+') with Tolerance: '+IntToStr(c));
      Break;
    end;
  end;
  If(Players[CurrentPlayer].Integer1 = 0)Then
  Begin
    Writeln('Tree Color not Found');
    Writeln('Player is Inactive!');
    Players[CurrentPlayer].Active := False;
    Players[CurrentPlayer].Loc := 'Tree AutoColor Failed!';
    Logout;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Woodcutting                                                     ]
[  >>  Function StarFindEnt(TreeName: String): Boolean;                        ]
[  >>  Returns True if an Ent is Found                                         ]
[ ---------------------------------------------------------------------------- }

Function StarFindEnt(TreeName: String): Boolean;
Var
  H, S, L: Extended;
  R, G, B: Integer;
  cx, cy, ax, ay, i: Integer;
  Temp: Array[0..5] of Integer;
Begin
  if (IsTextInAreaEx(7, 7, 180, 25, cx, cy, TreeName, 100, UpChars, True,
    True, 0, 2, -1)) then
  Begin
    For i := 0 to 5 do
    Begin
      ax := cx + i;
      ay := cy + 3;
      Temp[i] := GetColor(ax, ay);
      //Writeln(IntToStr(Temp[i])+' '+IntToStr(ax)+' '+IntToStr(ay));
    end;
    For i := 0 to 5 do
    Begin
      ColorToHSL(Temp[i], H, S, L);
      Color32ToRGB(Temp[i], R, G, B);
      If ((H >= 10) and (H <= 20) and
         (S >= 80) and (S <= 100) and
         (L >= 35) and (L <= 55)) then
      Begin
        Result := True;
        Exit;
      end else
      If ((R > 190) and (R < 225) and
         (G > 190) and (G < 225) and
         (B >= 0) and (B < 25)) then
      Begin
        Result := True;
        Exit;
      end
    end;
    if(FindColorTolerance(cx, cy, 122333, 60, 1, 123, 15, 10))then
      Result := True;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Woodcutting                                                     ]
[  >>  Function StartChopping(Click: Boolean): Boolean;                        ]
[  >>  Starts Cutting the Tree, Returning a Boolean                            ]
[ ---------------------------------------------------------------------------- }

Function StartChopping(var cx, cy, TreeColor: Integer; Click: Boolean): Boolean;
Begin
  If not(LoggedIn)then Exit;
  StarDebug('Finding '+Players[CurrentPlayer].String2, 4);
  Randoms('');

  While not(FindColorSpiralTolerance(cx, cy, Players[CurrentPlayer].Integer1, MSX1, MSY1, MSX2, MSY2, 5)) do
  Begin
    If not(Loggedin) then Exit;
    Randoms('woodcutting');
    Wait(100);
  end;

  Repeat
    If not(LoggedIn) then Exit;
    If(FindObj(cx, cy, Capitalize(Players[CurrentPlayer].String2), Players[CurrentPlayer].Integer1, 2))and
      not (StarFindEnt(Capitalize(Players[CurrentPlayer].String2))) then
    Begin
      GetMousePos(x, y);
      TreeColor := GetColor(x, y);
      If (Click) then
      begin
        If (Random(5) = 0) then
        Begin
          Mouse(x, y, 0, 0, False);
          Wait(100 + Random(100));
          ChooseOption(x, y, 'Chop');
        end else
          Mouse(x, y, 0, 0, True);
      end  else
        MMouse(x, y, 0, 0);
      Result := True;
    end;
  until(Result = True)
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Woodcutting                                                     ]
[  >>  Procedure WaitWhilstChopping;                                           ]
[  >>  Waits Whilst the tree is Being Cut, Searching for Randoms               ]
[ ---------------------------------------------------------------------------- }

Procedure Chopping;
Var
  cx, cy, Counter, CountUntil, Current, Mark, TreeColor: Integer;
begin
  If StartChopping(cx, cy, TreeColor, True) then
  begin
    If UpdateCoords(x, y, cx, cy, TreeColor, 10)then
      MMouse(cx, cy, 0, 0)
    else
    Begin
      Flag;
      Wait(400 + Random(200));
      StartChopping(x, y, TreeColor, False)
    end;

    Current := InvCount;
    MarkTime(Mark);
    CountUntil := 64 + Random(20);
    Counter := 0;

    repeat
      If not(LoggedIn) then Exit;
      Counter := Counter + 1;
      Status('Chopping ' +Capitalize(Players[CurrentPlayer].String2)+ ': '+intToStr(Counter)+'/'+IntToStr(CountUntil));
      Players[CurrentPlayer].Loc := 'Chopping '+Capitalize(Players[CurrentPlayer].String2);

      If Randoms('woodcutting')then Exit;
      If (StarFindEnt(Capitalize(Players[CurrentPlayer].String2)))then
      begin
        EntsAvoided := EntsAvoided + 1;
        Writeln('Ent Number '+IntToStr(EntsAvoided)+' Found');
        If ScreenShots then
          TakeScreen('Ent Avioded', EntsAvoided);
        CheckGas('Ent', False, cx, cy);
        Exit;
      end;
      Wait(10);
      If (TimeFromMark(Mark) >= 20*1000) and (Current = InvCount) then
        Break;
      If (Current < InvCount) then
      begin
        Current := InvCount;
        MarkTime(Mark);
      end;
    until not(IsUpText(Capitalize(Players[CurrentPlayer].String2))) or (Counter >= CountUntil) or (InventoryCount >= 28)

    If (Counter >= CountUntil) then
      If (Random(AntiBanRandomness) = 0) then
        DoAntiBan(True);
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Fishing                                                         ]
[  >>  function FindFish(var cx, cy: Integer) : Boolean;                       ]
[  >>  Finds a Fishing Spot Depending on the Type Chosen                       ]
[ ---------------------------------------------------------------------------- }

function FindFish(var cx, cy: Integer) : Boolean;
var
  a, c, i, x1, y1, x2, y2, ix, iy: Integer;
begin
  If not(Loggedin) then Exit;
  StarDebug('Finding Fish', 4);
  if(FindMSColorTol(x, y, 15515800, 25))then
  begin
    x1:= 245;
    y1:= 165;
    x2:= 277;
    y2:= 185;
    repeat
      a:=a+1;
      if(a=1)then
        c:= c + 1;
      if(a=3)then
        c:= c + 1;
      for i:=1 to c do
      begin
        if(a=1)then
        begin
          x1:= x1 + 30;
          x2:= x2 + 30;
        end else
        if(a=2)then
        begin
          y1:= y1 - 20;
          y2:= y2 - 20;
        end else
        if(a=3)then
        begin
          x1:= x1 - 30;
          x2:= x2 - 30;
        end else
        if(a=4)then
        begin
          y1:= y1 + 20;
          y2:= y2 + 20;
        end;
        if(x1=485)and(x2=517)then
          x2:= x2 - 2;
        if(y1=325)and(y2=345)then
          y2:= y2 - 7;
        if(x2>515)then
          Break;
        if(FindColorTolerance(ix, iy, 15515800, x1, y1, x2, y2, 30))then
        begin
          MMouse(ix, iy, 3, 3)
          Wait(100 + random(100))
          if((Option2('Cage'))and(Players[CurrentPlayer].String2 = 'Cage')) or
          ((Option2('Net')) and (Players[CurrentPlayer].String2 = 'Net'))then
          begin
            Mouse(ix, iy, 0, 0, True);
            wait(100 + random(100));
            Result := True;
            cx := ix; cy := iy;
            Exit;
          end else
          if ((Option2('Cage')) and (Players[CurrentPlayer].String2 = 'Harpoon'))then
          begin
            Result := True;
            cx := ix; cy := iy;
            Mouse(ix, iy, 0, 0, False);
            wait(100 + random(100));
            ChooseOption(x, y, 'Harpoon');
            Wait(100 + Random(50));
            Exit;
          end;
        end;
      end;
      if(a  = 4)then  a:= 0;
    until(x2>515) or (Result = True)
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Fishing                                                         ]
[  >>  Function FishSpotPresent(cx, cy: Integer): Boolean;                     ]
[  >>  Checks if a Fishing Spot is Still Present                               ]
[ ---------------------------------------------------------------------------- }

Function FishSpotPresent(cx, cy: Integer): Boolean;
Var
  i : integer;
Begin
  If not(Loggedin) then Exit;
  For i := 1 to 10 do
  Begin
    Wait(10);
    If (cx < 10) then cx := 10; If (cy < 10) then cy := 10;
    If(FindColorSpiralTolerance(x, y, 15515800, cx-10, cy-10, cx+10, cy+10, 30))then
      Result := True;
    If(Result = True)then
      Break;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Fishing                                                         ]
[  >>  Procedure DoFishing;                                                    ]
[  >>  Waits Whilst Fishing Occurs                                             ]
[ ---------------------------------------------------------------------------- }

Procedure DoFishing;
Var
  q, e, ax, ay, cx, cy, Mark, Current : integer;
  i : Extended;
Begin
  If not(Loggedin) then Exit;
  Current := InvCount;
  If (FindFish(ax, ay)) then
  begin
    UpdateCoords(cx, cy, ax, ay, 15515800, 30)
    e := 70 + Random(30)
    StarDebug('Fishing', 4);
    MarkTime(Mark);
    Repeat
      i := i + 1;
      Status('Fishing: ' +FloatToStr(I)+ '/' +IntToStr(E));
      If Randoms('fishing')then Exit;
      If (Random(6) = 0) then
        For q := 1 to 4 do
        Begin
          i := i + 0.25;
          If (Random(AntiBanRandomness) = 0) then DoAntiBan(False);
        end;
      Wait(50);
      If (TimeFromMark(Mark) >= 22*1000) and (Current = InvCount) then
        Break;
      If (Current < InvCount) then
      begin
        Current := InvCount;
        MarkTime(Mark);
      end;
      Wait(50);
    Until( I >= E ) or (InventoryFull) or not(FishSpotPresent(cx, cy))
  end else StarDebug('Fish Not Found', DebugNumber);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Function StarOpenBank(LookForColor: integer): Boolean;                  ]
[  >>  Opens the Bank, Looking for a Specific Color                            ]
[ ---------------------------------------------------------------------------- }

Function StarOpenBank(LookForColor: Integer): Boolean;
var
  c: Integer;
begin
  If not(Loggedin)then Exit;
  if(FindObjMultiText(x, y, 'Use B', 'Bank', 'booth', LookForColor, 12))then
  begin
    Mouse(x, y, 1, 1, false);
    if(ChooseOption(x, y, 'quickly')) or (ChooseOption(x, y, 'Bank Banker'))then
    begin
      Flag;
      repeat
        Wait(100);
        c := c + 1
      until(BankScreen) or (c >= 50) or (PinScreen)
      If (BankScreen) then
      begin
        If not(Getcolor(475, 75) = 5531254)then
          Mouse(475, 77, 0, 0, true);
        Result := True
        Exit;
      end else
      If (PinScreen) then
      begin
        CloseBank;
        Logout;
        Players[CurrentPlayer].Loc := 'Pin Screen Detected!';
        Players[CurrentPlayer].Active := False;
        Exit;
      end else
      If (C >= 50) then
      begin
        CloseBank;
        Logout;
        Players[CurrentPlayer].Loc := 'Timed out when Opening Bank';
        Players[CurrentPlayer].Active := False;
        Exit;
      end;
    end;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Prayer                                                          ]
[  >>  Function GrabBones(Bank: Boolean): Boolean;                             ]
[  >>  Waits for Bones to Appear and Picks up Bones off of the Floor OR        ]
[      Opens the banks and Withdraws any Bones found in the First Few Slots    ]
[ ---------------------------------------------------------------------------- }

Function GrabBones(Bank: Boolean): Boolean;
var
  Searchfor2, Dx, Dy, Current, Mark: Integer;            //1 = Text
  SearchFor1: String;                                    //2 = Bitmap
begin
  If not(LoggedIn) then Exit;
  If InventoryFull then Exit;
  Current := InvCount;
  StarDebug('Grabbing Bones', 4);

  If((Players[CurrentPlayer].Integer1) = 0) then
    Players[CurrentPlayer].Integer1 := 13355985;

  Case Lowercase(Players[CurrentPlayer].String2) of
    'bones'     : SearchFor2 := DTMBones;
    'big bones' : SearchFor2 := DTMBigBones;
    else Begin Writeln('Something Wrong with SearchFor2'); Exit; end;
  end;

  If not(Bank) then
  Begin
    while not(FindColorSpiralTolerance(dx, dy, Players[CurrentPlayer].Integer1, MSX1+20, MSY1+20, MSX2-20, MSY2-20, 20))do
    begin
      Randoms('');
      Wait(10);
    end;
    If(FindObj(dx, dy, 'Take', Players[CurrentPlayer].Integer1, 20))then
    begin
      Mouse(dx, dy, 0, 0, False);
      Wait(100 + Random(100));
      Case Lowercase(Players[CurrentPlayer].String2) of
        'bones'     : SearchFor1 := 'Bones';
        'big bones' : SearchFor1 := 'Big bones';
        else Begin Writeln('Something Wrong with SearchFor1'); SearchFor1 := 'ones'; end;
      end;
      If (FindText(dx, dy, 'ke '+SearchFor1, UpChars, MSX1, MSY1, MSX2, MSY2))then
      begin
        Mouse(dx + 5 + Random(5), dy + 2 + Random(1), 0, 0, True);
        Flag;
        MarkTime(mark);
        while (Current = InvCount) do
        begin
          Wait(200 + Random(100));
          If(TimeFromMark(Mark) > 3000) then Break;
        end;
        Wait(100 + Random(100));
      end else
      Begin
        MMouse(Random(MSCX), Random(MSCY), 0, 0);
        If (Random(AntibanRandomness) = 0) then DoAntiBan(True);
      end;
    end else
    begin
      Wait(200 + Random(200));
      If (Random(AntibanRandomness) = 0) then DoAntiBan(True);
    end;
  end else
  begin
    If (StarOpenBank(7113112)) then
    begin
      Wait(100);
      If(FindDTM(SearchFor2, dx, dy, MSX1, MSY1, MSCX, MSCY))then
      begin
        Mouse(dx, dy, 2, 2, False);
        Wait(100 + Random(100));
        If (FindText(dx, dy, 'draw Al', UpChars, MSX1, MSY1, MSX2, MSY2))then
        begin
          Mouse(dx + 5 + Random(5), dy + 2 + Random(1), 0, 0, True);
          while (InvCount = 0) do
          begin
            Wait(200 + Random(100));
            If(TimeFromMark(Mark) > 3000) then Break;
          end;
          Wait(100 + Random(100));
          CloseBank;
          Result := True;
        end else
        begin
          CloseBank;
          Logout;
          Players[CurrentPlayer].Loc := 'No Bones in bank!';
          Players[CurrentPlayer].Active := False;
        end;
      end else
      begin
        CloseBank;
        Logout;
        Players[CurrentPlayer].Loc := 'No Bones in bank!';
        Players[CurrentPlayer].Active := False;
      end;
    end;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Prayer                                                          ]
[  >>  Procedure BuryBones(BoneType: String);                                  ]
[  >>  Buries the Specified Type of Bones                                      ]
[ ---------------------------------------------------------------------------- }

Procedure BuryBones(BoneType: String);
Var
  i, SearchFor, Current, cx, cy: Integer;
  Coords: TPoint;
Begin
  If not(LoggedIn) then Exit;
  StarDebug('Burying Bones', 4);
  Case Lowercase(BoneType) of
    'bones'     : SearchFor := DTMBones;
    'big bones' : SearchFor := DTMBigBones;
    else Begin Writeln('Something Wrong with SearchFor'); Exit; end;
  end;

  For i := 1 to 28 do
  begin
    FindTalk;
    If (ExistsItem(i)) then
    begin
      Current := InvCount;
      Coords := ItemCoords(i);
      If(FindDTM(SearchFor, cx, cy, Coords.x-30, Coords.y-20, Coords.x+30, Coords.y+30))then
      Begin
        Mouse(Coords.x, Coords.y+5, 3, 3, True);
        While(InvCount = Current) do
          Wait(100);
        Wait(550 + Random(150));
      end else
        MMouse(MSCX, MSCY, MSCY, MSCY);
    end
    Wait(1);
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure Drop2;                                                        ]
[  >>  Drops All Items in the Inventory, Leaving out some Specific Ones        ]
[ ---------------------------------------------------------------------------- }

Procedure Drop(DTM: Integer);
Var
  cx, cy, Current, i: integer;
  Coords: TPoint;
Begin
  If not(LoggedIn) then Exit;
  GameTab(4);
  For i := 1 to 28 do
  begin
    Writeln('Checking If Item Exists');
    If (ExistsItem(i)) then
    begin
      Current := InvCount;
      Coords := ItemCoords(i);
      Writeln('Finding DTM');
      If(FindDTM(DTM, cx, cy, Coords.x-30, Coords.y-20, Coords.x+30, Coords.y+30))then
      Begin
        Mouse(Coords.x, Coords.y+5, 3, 3, False);
        Wait(50 + Random(50));
        Writeln('Finding Drop Text');
        If(FindText(cx, cy, 'Drop', UpChars, MIX1, MIY1, MIX2, MIY2))then
        Begin
          Mouse(cx + 10 + Random(10), cy + 4, 5, 1, True);
          Wait(200);
          While(InvCount = Current) do
            Wait(100);
          Wait(250 + Random(100));
        end else
          ClickText('Cancel', MIX1, MIY1, MIX2, MIY2);
      end;
    end;
    Wait(1);
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Fletching                                                       ]
[  >>  Function GrabForFletching: Boolean;                                     ]
[  >>  Opens Bank and Grabs Material needed for Fletching the Specific Item    ]
[ ---------------------------------------------------------------------------- }

Function GrabForFletching: Boolean;
Var
  LookFor: Array of Integer;
  cx, cy, i, Amount, Current: Integer;
  Error: Boolean;
begin
  If not(LoggedIn) then Exit;
  StarDebug('Grabbing Items for Fletching', 4);

  case Lowercase(Players[CurrentPlayer].String2) of
    'logs --> (u) shortbow'        : begin
                                       SetArrayLength(LookFor, 1);
                                       LookFor[0]:= DTMLog;
                                       Amount := 27;
                                     end;
    'logs --> (u) longbow'         : begin
                                       SetArrayLength(LookFor, 1);
                                       LookFor[0]:= DTMLog;
                                       Amount := 27;
                                     end;
    '(u) shortbow --> (s) shortbow': begin
                                       SetArrayLength(LookFor, 2);
                                       LookFor[0]:= DTMFletching[3];
                                       LookFor[1]:= DTMFletching[1];
                                       Amount := 14;
                                     end;
    '(u) longbow --> (s) longbow'  : begin
                                       SetArrayLength(LookFor, 2);
                                       LookFor[0]:= DTMFletching[4];
                                       LookFor[1]:= DTMFletching[1];
                                       Amount := 14;
                                     end;
    'logs --> (s) shortbow'        : begin
                                       SetArrayLength(LookFor, 2);
                                       LookFor[0]:= DTMLog;
                                       LookFor[1]:= DTMFletching[1];
                                       Amount := 13;
                                     end;
    'logs --> (s) longbow'         : begin
                                       SetArrayLength(LookFor, 2);
                                       LookFor[0]:= DTMLog;
                                       LookFor[1]:= DTMFletching[1];
                                       Amount := 13;
                                     end;
    else begin Writeln('Error in GrabForFletching!'); TerminateScript; end;
  end;
  If (StarOpenBank(7113112)) then
  begin
    Wait(200 + Random(200));
    If (Copy(Lowercase(Players[CurrentPlayer].String2), 1, 3) = '(u)') then
      Deposit(1, 28, 2)
    else
      Deposit(2, 28, 2);
    For i := 0 to GetArrayLength(LookFor)-1 do
    begin
      Current := InvCount;
      Wait(500 + Random(250));
      If (FindDTM(LookFor[i], cx, cy, MSX1, MSY1, MSX2, MSY2))then
      begin
        Mouse(cx, cy, 5, 5, False);
        Wait(100 + Random(50));
        If (Amount >= 27) then
        begin
          If (FindText(cx, cy, 'draw Al', UpChars, MSX1, MSY1, MSX2, MSY2))then
          begin
            Mouse(cx + 5 + Random(5), cy + 2 + Random(1), 0, 0, True)
            While (Current = InvCount) do
              Wait(150);
            Wait(200 + Random(100));
            Result := true;
          end else
            Error := True;
        end else
        If (FindText(cx, cy, 'draw X', UpChars, MSX1, MSY1, MSX2, MSY2))then
        begin
          Mouse(cx + 5 + Random(5), cy + 2 + Random(1), 0, 0, True);
          While (GetColor(214, 434) = 0) and (GetColor(439, 434) = 0) and (LoggedIn)do
            Wait(100);
          Wait(200 + Random(100));
          TypeSend(IntToStr(Amount));
          While (Current = InvCount) and (Loggedin) do
            Wait(150);
          Wait(200 + Random(100));
          Result := True;
        end else
          Error := True;
      end else
      begin
        Error := True;
        StarDebug('DTM LookFor[' +IntToStr(i)+ '] was not Found!', DebugNumber);
      end;
      If (Error = True) then
      begin
        Players[CurrentPlayer].Loc := 'Could not Withdraw Items!';
        Players[CurrentPlayer].Active := False;
        CloseBank;
        Logout;
        Exit;
      end;
    end;
    CloseBank;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Part of Fletching                                                       ]
[  >>  Procedure Fletch;                                                       ]
[  >>  Fletches the Specific Item into the Desired Item                        ]
[ ---------------------------------------------------------------------------- }

Procedure Fletch;
var
  cx, cy, dx, dy, Number, Current, Mark: Integer;
  Error: Boolean;
  LookForText: String;
begin
  If not(LoggedIn) then Exit;
  StarDebug('Fletching Items', 4);
  GameTab(4);
  Wait(200 + Random(100));
  //Cut Logs
  If (Copy(Lowercase(Players[CurrentPlayer].String2), 1, 2) = 'lo') then
  begin
    If (FindDTM(DTMFletching[2], cx, cy, MIX1, MIY1, MIX2, MIY2))then
    begin
      Mouse(cx, cy, 5, 5, True);
      Wait(200 + Random(100));
    end else
      Error := True;
    If (FindDTM(DTMLog, cx, cy, MIX1, MIY1, MIX2, MIY2)) and not(Error) then
    begin
      Mouse(cx, cy, 5, 5, True);
      Wait(200 + Random(100));
    end else
      Error := True;
    While (GetColor(214, 434) = 0) and (GetColor(439, 434) = 0) and (loggedIn) and not(Error) do
      Wait(100);
    Wait(200 + Random(100));
    case Lowercase(Players[CurrentPlayer].String2) of
      'logs --> (u) shortbow', 'logs --> (s) shortbow' : LookForText := 'hort';
      'logs --> (u) longbow', 'logs --> (s) longbow'  : LookForText := 'ong';
      else begin Writeln('Error in Fletch 1'); Exit; end;
    end;
    If (FindNPCChatText(LookForText)) and not(Error) then
    begin
      Mouse(x, y-30, 8, 8, False);
      Wait(100 + Random(50));
      If (FindText(cx, cy, 'ake X', UpChars, MCX1, MCY1, MCX2, MCY2))then
      begin
        Mouse(cx + 5 + Random(5), cy + 2 + Random(1), 0, 0, True);
        While not(GetColor(256, 410) = 8388608) and (LoggedIn) do
          Wait(100);
        Wait(200 + Random(100));
        TypeSend(IntToStr(28 + Random(1000)));
        MarkTime(Mark);
        repeat
          If not(LoggedIn) then Exit;
          Wait(10);
          If (Random(AntibanRandomness) = 0) then DoAntiBan(False);
          If (Randoms('')) then Exit;
        until (InChat('ave run')) or not (FindDTM(DTMLog, cx, cy, MIX1, MIY1, MIX2, MIY2)) or (TimeFromMark(Mark) > 60*1000)
      end else
      begin
        Mouse(MSCX, MSCY, MSCX, MSCY, False);
        MMouse(MSCX, MSCY, MSCX, MSCY);
        Error := True;
      end;
    end else
      Error := True;
    If (Error) then
    begin
      Players[CurrentPlayer].loc := 'Could not Fletch 1!';
      Players[CurrentPlayer].active := False;
      Logout;
      Exit;
    end;
  end;
  // Unstrung to Strung.
  If (Pos('(s)', Lowercase(Players[CurrentPlayer].String2)) > 0) then
  begin
    case Lowercase(Players[CurrentPlayer].String2) of
      '(u) shortbow --> (s) shortbow', 'logs --> (s) shortbow': Number := 3;
      '(u) longbow --> (s) longbow', 'logs --> (s) longbow': Number := 4;
      else begin Writeln('Error in Fletch 2!'); Exit; end;
    end;
    Repeat
      Current := 0;
      Current := InvCount;
      If (FindDTM(DTMFletching[1], cx, cy, MIX1, MIY1, MIX2, MIY2))then
      begin
        Mouse(cx, cy, 5, 5, True);
        Wait(200 + Random(100));
      end else
        Error := True;
      If (FindDTM(DTMFletching[Number], dx, dy, MIX1, MIY1, MIX2, MIY2)) and not(Error) then
      begin
        Mouse(dx, dy, 5, 5, True);
        Wait(200 + Random(100));
      end else
        Error := True;
      MarkTime(Mark);
      While (Current = InvCount) and not(Error) and (TimeFromMark(Mark) < 20*1000) do
        Wait(100);
      Wait(100 + Random(100));
    until (Error)
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Procedure LoadDTMs;                                                     ]
[  >>  Loads all DTMs needed into the Memory                                   ]
[ ---------------------------------------------------------------------------- }

Procedure LoadDTMsandBitmaps;
Begin
  DTMFletching[1] := DTMFromString('78DA637CC5C0C0E0C780029ACA23181E02694' +  //String
                   '620FE0F048CF7808C080634C0884402E9B740228A809AEF402294' +
                   '809ABB40C29B809A2F986EC650F394B07B0036370EED');
  DTMFletching[2] := DTMFromString('78DA63F460626078C28002CAF272181E02694' +  //Knife
                   '620FE0F048C7640359F18D000231209A441E6DC27A0C61FA8E61A' +
                   '01353E40358F08A87103AA798D5F0D00E5B80D52');
  DTMFletching[3] := DTMFromString('78DA639CC7C4C0F08C01057495E6313C04D28' +  //Shortbow
                   'C40FC1F08189702D53C6640038C4824909E0954F38A809AA94035' +
                   'AF09A8E903AA794740CD74A09A1704D42C04AA794A40CD02C2FE0' +
                   '200F0A71285');
  DTMFletching[4] := DTMFromString('78DA63EC636060F0644001735A6A191E02694' +  //Longbow
                   '620FE0F048CD3808C080634C088440269909A60026A2601091F02' +
                   '6A40EEF126A0662A900824A0A607D35F186A66008970FC6A00FFA' +
                   'D0DA1');
  DTMMining[1] := DTMFromString('78DA639CC4C4C060CBC8800CBC7415191E026' +     //Ores
                '990E87F20606C04AA7144550391859140BA17A8C680809A794035' +
                'A604D4CC01AA7121A0A607A8C69B809A36A01A73026AA603D518E' +
                '257030091BF0C02');
  DTMMining[2] := DTMFromString('78DA632C66626078C6800278AB84181E02694' +     //Gems
                '620FE0F048C19986A20B2301248E703D57C20A0A61AA8E61D0135' +
                '5540350F08A82902AAB98D5F0D00E0910DAA');
  DTMLog := DTMFromString('78DA638C676060F0634001EEA69C0C0F81342' +           //Logs
          '310FF0702C64420239C010D302291403A0C48441050E30F248208' +
          'A8C905128104D464821C49404D3A9008C5AF06005AEA0A55');
  DTMBones := DTMFromString('78DA639CC3C4C0F09401059C3E7298E104906' +         //Normal Bones
            '604E2FF40C0381DA8E635031A60442281F402A09A6704D42C06AA' +
            'B94F40CD244CF760A8590154F304BF1A0094DB1042');
  DTMBigBones := DTMFromString('78DA637467626098CEC8800C76AD5FCF70024' +      //Big Bones
               '88344FF0301630050CD02543510591809A4ED806A661350130C54' +
               '3393801A3722CCF103AA998C5F0D00A32B0C55');
  BrokenAxeMask   := BitmapFromString(9, 10, 'z78DA7373230D1890' +            //Broken Axe Mask
              '05C8D34BAA2EE2D5E3F21131FEC56FCBE091A53C34007F307225');
  DTMFishing[1] := DTMFromString('78DA632C65626078C28002762608333C04D28' +    //Lobster
                 'C40FC1F081853806A5E30A0014624124883CCF944404D3550CD33' +
                 '026A6A816AAE1350530254731FBF1A0050520E3B');
  DTMFishing[2] := DTMFromString('78DA632C666260606564400687269D667808A' +    //SwordFish
                 '441A2FF81803119A84614550D44164602E93CA09AFF0CF8D55402' +
                 'D5701030A78A098987434D2661730014E20AE8');
  DTMFishing[3] := DTMFromString('78DA639CCDC4C0F08201051CDCB19DE121906' +    //Tuna
                 '604E2FF40C03819A8E609031A60442281743F50CD07026A6611A1' +
                 '6629A67B30D42C03AAB98D5F0D008B78103C');
  DTMFishing[4] := DTMFromString('78DA63DCC1C0C0D0CA8002525272181E02694' +    //Anchovies
                 '620FE0F048CEB808C260634C0884402E93D4062220135A780440B' +
                 '0135078144157E350025E10C63');
  DTMFishing[5] := DTMFromString('78DA638C65606068634001E5172B191E02694' +    //Sardine
                 '620FE0F048CE1404607031A604422817402906827A0260E483412' +
                 '50930624EAF1AB0100BC150B1A');
  DTMFishing[6] := DTMFromString('78DA63EC666060686740014776EF667808A41' +    //herring
                 '981F83F1030B600197D0C6880118904D29D40A291809AE940A292' +
                 '809A2940A215BF1A0068080C7D');
  DTMFishing[7] := DTMFromString('78DA637CCDC0C0D0CE8002B6AF59C3F010483' +    //Trout, pike, Salmon
                 '302F17F20607C0464F433A001462412487F0112CD04D43C0112AD' +
                 '04D47C001275F8D5000017520E2C');
end;

{ ---------------------------------------------------------------------------- ]
[  >>  The Form Procedures                                                     ]
[  >>  The Following is a Huge list of Form Procedures to Allow the Form to    ]
[      Work.  They are all Based off of Yakmans Player Manager from SRL        ]
[ ---------------------------------------------------------------------------- }

Procedure SafeInitForm;
var
  v: TVariantArray;
begin
  setarraylength(V, 0);
  ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
  frmDesign.ShowModal;
end;

procedure SafeShowFormModal;
var
  v: TVariantArray;
begin
  setarraylength(V, 0);
  ThreadSafeCall('ShowFormModal', v);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Saves Current Options Selected for Switching Players                    ]
[ ---------------------------------------------------------------------------- }

Procedure SavePlayersInForm(No: Integer);
Begin
  Players[no].Name := UsernameEdit.Text;
  Players[no].Pass := PasswordEdit.Text;
  Players[no].Skill := LampSkillComboBox.Text;
  Players[no].String1 := String1Combobox.Text;
  Players[no].String2 := String2Combobox.Text;
  Players[no].String3 := String3Combobox.Text;
  Players[no].Active := IsActive.Checked;
  Players[no].Boolean1 := ColorCheckBox.Checked;
  Players[no].Boolean2 := BankCheckBox.Checked;
  Players[no].Boolean3 := GemsCheckBox.Checked;
  Players[no].Integer1 := StrToIntDef(ColorsEdit.Text, 0);
  Players[no].Integer2 := StrToIntDef(LoadsEdit.Text, 0);
  Players[no].Integer3 := StrToIntDef(MiningSecsEdit.Text, 0);
  FletchString[no] := FletchComboBox.Text;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Loads Current Options Selected for Switching Players                    ]
[ ---------------------------------------------------------------------------- }

Procedure LoadPlayersInForm(no: Integer);
Begin
  try
    UsernameEdit.text := Players[no].Name;
    PasswordEdit.Text := Players[no].Pass;
    LampSkillComboBox.Text := Players[no].Skill;
    String1Combobox.Text := Players[no].String1;
    String2Combobox.Text := Players[no].String2;
    String3Combobox.Text := Players[no].String3;
    IsActive.Checked := Players[no].Active;
    ColorCheckBox.Checked := Players[no].Boolean1;
    BankCheckBox.Checked := Players[no].Boolean2;
    GemsCheckBox.Checked := Players[no].Boolean3;
    ColorsEdit.Text := IntToStr(Players[no].Integer1);
    LoadsEdit.Text := IntToStr(Players[no].Integer2);
    MiningSecsEdit.Text := IntToStr(Players[no].Integer3);
    FletchComboBox.Text := FletchString[no];
  except
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Saves Current Options To File                                           ]
[ ---------------------------------------------------------------------------- }

procedure SaveUs2;
var
  f, CharsFile: Integer;
begin
  If (PowerMainSkillsFileName = '') then PowerMainSkillsFileName := 'PowerSkills'
    CharsFile := RewriteFile(ScriptPath + PowerMainSkillsFileName + '.dat', False)
  For f := 0 to GetArrayLength(players) - 1 do
  begin
    WriteFileString(CharsFile, 'name' +IntToStr(f)+ '=' +players[f].name+ Chr(13))
    WriteFileString(CharsFile, 'pass' +IntToStr(f)+ '=' +players[f].pass+ Chr(13))
    WriteFileString(CharsFile, 'skill' +IntToStr(f)+ '=' +players[f].skill+ Chr(13))
    WriteFileString(CharsFile, 'string1' +IntToStr(f)+ '=' +players[f].string1+ Chr(13))
    WriteFileString(CharsFile, 'string2' +IntToStr(f)+ '=' +players[f].string2 + Chr(13))
    WriteFileString(CharsFile, 'string3' +IntToStr(f)+ '=' +players[f].string3 + Chr(13))
    WriteFileString(CharsFile, 'integer1' +IntToStr(f)+ '=' +IntToStr(players[f].Integer1) + Chr(13))
    WriteFileString(CharsFile, 'integer2' +IntToStr(f)+ '=' +IntToStr(players[f].Integer2) + Chr(13))
    WriteFileString(CharsFile, 'integer3' +IntToStr(f)+ '=' +IntToStr(players[f].Integer3) + Chr(13))
    WriteFileString(CharsFile, 'active' +IntToStr(f)+ '=' +BoolToStr(players[f].Active) + Chr(13))
    WriteFileString(CharsFile, 'boolean1' +IntToStr(f)+ '=' +BoolToStr(players[f].Boolean1) + Chr(13))
    WriteFileString(CharsFile, 'boolean2' +IntToStr(f)+ '=' +BoolToStr(players[f].Boolean2) + Chr(13))
    WriteFileString(CharsFile, 'boolean3' +IntToStr(f)+ '=' +BoolToStr(players[f].Boolean3) + Chr(13))
    WriteFileString(CharsFile, 'fletchstring' +IntToStr(f)+ '=' +fletchstring[f] + Chr(13))
    //Writeln('Saved Player: '+IntToStr(f));
  end;
  CloseFile(charsfile)
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Loads Current Options from File                                         ]
[ ---------------------------------------------------------------------------- }

procedure LoadUs2;
var
  f, CharsFile, Temp: Integer;
begin
  if (PowerMainSkillsFileName = '') then PowerMainSkillsFileName := 'PowerSkills';
  CharsFile := OpenFile(ScriptPath + PowerMainSkillsFileName + '.dat', False)
  if (CharsFile < 0) then
  begin
    SaveUs2;
    CharsFile := OpenFile(AppPath + filename + '.dat', False)
    if (CharsFile < 0) then
    begin
      WriteLn('Error Loading Chars');
      Exit;
    end
  end
  ReadFileString(CharsFile, CharsFileString, FileSize(CharsFile))
  CloseFile(CharsFile)
  Temp := CountPlayers;
  If (Temp <= 0) then Temp:= 1;
  SetArrayLength(players, Temp);
  SetArrayLength(fletchstring, Temp);
  HowManyPlayers := GetArrayLength(players)
  for f := 0 to HowManyPlayers - 1 do
  begin
    players[f].Name := GetFileData(f, 'name')
    players[f].Pass := GetFileData(f, 'pass')
    players[f].Skill := GetFileData(f, 'skill')
    players[f].String1 := GetFileData(f, 'string1')
    players[f].String2 := GetFileData(f, 'string2')
    players[f].String3 := GetFileData(f, 'string3')
    players[f].Integer1 := StrToIntDef(GetFileData(f, 'integer1'), 0)
    players[f].Integer2 := StrToIntDef(GetFileData(f, 'integer2'), 0)
    players[f].Integer3 := StrToIntDef(GetFileData(f, 'integer3'), 0)
    players[f].Active := StrToBool(GetFileData(f, 'active'))
    players[f].Boolean1 := StrToBool(GetFileData(f, 'boolean1'))
    players[f].Boolean2 := StrToBool(GetFileData(f, 'boolean2'))
    players[f].Boolean3 := StrToBool(GetFileData(f, 'boolean3'))
    fletchstring[f] := GetFileData(f, 'fletchstring')
    //Writeln('Loading Player: '+IntToStr(f));
  end
  CloseFile(CharsFile);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Changes Options Depending on Skill Chosen                               ]
[ ---------------------------------------------------------------------------- }

Procedure String1Change(Sender: TObject);
Begin
  Case Lowercase(String1ComboBox.Text) of
    'woodcutting': Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Tree');
                     String2ComboBox.Items.Add('Oak');
                     String2ComboBox.Items.Add('Willow');
                     String2ComboBox.Items.Add('Maple');
                     String2ComboBox.Items.Add('Yew');
                     String2ComboBox.Items.Add('Magic');
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    'mining':      Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Tin');
                     String2ComboBox.Items.Add('Copper');
                     String2ComboBox.Items.Add('Iron');
                     String2ComboBox.Items.Add('Coal');
                     String2ComboBox.Items.Add('Mith');
                     String2ComboBox.Items.Add('Gold');
                     String2ComboBox.Items.Add('Silver');
                     String2ComboBox.Items.Add('Addy');
                     String2ComboBox.Items.Add('Rune');
                     MiningSecsLabel.Visible := True
                     MiningSecsEdit.Visible := True;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := True;
                   end;
    'bone burying':Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Bones');
                     String2ComboBox.Items.Add('Big bones');
                     MiningSecsLabel.Visible := False;
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := True;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    'fishing' :    Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Net');
                     String2ComboBox.Items.Add('Cage');
                     String2ComboBox.Items.Add('Harpoon');
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    'fletching':   Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Logs --> (U) Shortbow');
                     String2ComboBox.Items.Add('Logs --> (U) Longbow');
                     String2ComboBox.Items.Add('(U) Shortbow --> (S) Shortbow');
                     String2ComboBox.Items.Add('(U) Longbow --> (S) Longbow');
                     String2ComboBox.Items.Add('Logs --> (S) Shortbow');
                     String2ComboBox.Items.Add('Logs --> (S) Longbow');
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := True;
                     GemsCheckBox.Visible := False;
                   end;
    ''           : Begin
                     String2ComboBox.Clear;
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    Else String2ComboBox.Clear;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Changes Options Depending on Skill Chosen Again                         ]
[ ---------------------------------------------------------------------------- }

Procedure String1Change2;
Begin
  Case Lowercase(Players[CurrentPlayer].String1) of
    'woodcutting': Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Tree');
                     String2ComboBox.Items.Add('Oak');
                     String2ComboBox.Items.Add('Willow');
                     String2ComboBox.Items.Add('Maple');
                     String2ComboBox.Items.Add('Yew');
                     String2ComboBox.Items.Add('Magic');
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    'mining':      Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Tin');
                     String2ComboBox.Items.Add('Copper');
                     String2ComboBox.Items.Add('Iron');
                     String2ComboBox.Items.Add('Coal');
                     String2ComboBox.Items.Add('Mith');
                     String2ComboBox.Items.Add('Gold');
                     String2ComboBox.Items.Add('Silver');
                     String2ComboBox.Items.Add('Addy');
                     String2ComboBox.Items.Add('Rune');
                     MiningSecsLabel.Visible := True
                     MiningSecsEdit.Visible := True;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := True;
                   end;
    'bone burying':Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Bones');
                     String2ComboBox.Items.Add('Big bones');
                     MiningSecsLabel.Visible := False;
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := True;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    'fishing' :    Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Net');
                     String2ComboBox.Items.Add('Cage');
                     String2ComboBox.Items.Add('Harpoon');
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    'fletching':   Begin
                     String2ComboBox.Clear;
                     String2ComboBox.Items.Add('Logs --> (U) Shortbow');
                     String2ComboBox.Items.Add('Logs --> (U) Longbow');
                     String2ComboBox.Items.Add('(U) Shortbow --> (S) Shortbow');
                     String2ComboBox.Items.Add('(U) Longbow --> (S) Longbow');
                     String2ComboBox.Items.Add('Logs --> (S) Shortbow');
                     String2ComboBox.Items.Add('Logs --> (S) Longbow');
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := True;
                     GemsCheckBox.Visible := False;
                   end;
    ''           : Begin
                     String2ComboBox.Clear;
                     MiningSecsLabel.Visible := False
                     MiningSecsEdit.Visible := False;
                     BankCheckBox.Visible := False;
                     FletchComboBox.Visible := False;
                     GemsCheckBox.Visible := False;
                   end;
    Else String2ComboBox.Clear;
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Adds a New User to The Player Array                                     ]
[ ---------------------------------------------------------------------------- }

Procedure CreateNewUser(sender: Tobject);
begin
  SavePlayersInForm(CurrentPlayer);
  SetArrayLength(Players, GetArrayLength(Players) + 1)
  SetArrayLength(FletchString, GetArrayLength(Players) + 1)
  CurrentPlayer := GetArrayLength(Players) - 1;
  UsernameLabel.Caption := IntToStr(CurrentPlayer) +'. Username';
  PasswordLabel.Caption := IntToStr(CurrentPlayer) +'. Password';
  LampSkillLabel.Caption := IntToStr(CurrentPlayer) +'. Lamp Skill';
  TripsLabel.Caption := IntToStr(CurrentPlayer) +'. Loads';
  LoadPlayersInForm(CurrentPlayer);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Deletes a Player from the Player Array                                  ]
[ ---------------------------------------------------------------------------- }

Procedure DeleteAPlayer(sender: tobject);
Begin
  repeat
    if (GetArrayLength(players) = 1) then break
    SetArrayLength(players, GetArrayLength(players) - 1)
    SetArrayLength(FletchString, GetArrayLength(players) - 1)
    CurrentPlayer := GetArrayLength(Players) - 1;
    UsernameLabel.Caption := IntToStr(CurrentPlayer) +'. Username';
    PasswordLabel.Caption := IntToStr(CurrentPlayer) +'. Password';
    LampSkillLabel.Caption := IntToStr(CurrentPlayer) +'. Lamp Skill';
    TripsLabel.Caption := IntToStr(CurrentPlayer) +'. Loads';
    LoadPlayersInForm(CurrentPlayer);
  until (True)
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Goes to Next Player in the Player Array                                 ]
[ ---------------------------------------------------------------------------- }

Procedure PressNextButton(sender: TObject);
begin
  try
    players[currentplayer + 1].name := players[currentplayer + 1].name
  except
    Exit;
  end
  SavePlayersInForm(CurrentPlayer);
  CurrentPlayer := CurrentPlayer + 1;
  UsernameLabel.Caption := IntToStr(CurrentPlayer) +'. Username';
  PasswordLabel.Caption := IntToStr(CurrentPlayer) +'. Password';
  LampSkillLabel.Caption := IntToStr(CurrentPlayer) +'. Lamp Skill';
  TripsLabel.Caption := IntToStr(CurrentPlayer) +'. Loads';
  String1Change2;
  LoadPlayersInForm(CurrentPlayer);
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Goes to Previous Player in the Player Array                             ]
[ ---------------------------------------------------------------------------- }

Procedure PressBackButton(sender: tobject);
begin
  if (Currentplayer <> 0) then
  begin
    SavePlayersInForm(CurrentPlayer);
    CurrentPlayer := CurrentPlayer - 1;
    UsernameLabel.Caption := IntToStr(CurrentPlayer) +'. Username';
    PasswordLabel.Caption := IntToStr(CurrentPlayer) +'. Password';
    LampSkillLabel.Caption := IntToStr(CurrentPlayer) +'. Lamp Skill';
    TripsLabel.Caption := IntToStr(CurrentPlayer) +'. Loads';
    String1Change2;
    LoadPlayersInForm(CurrentPlayer);
  end
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Saves Options when the Form closes                                      ]
[ ---------------------------------------------------------------------------- }

procedure FormClose2(sender: TObject; var CanClose: Boolean);
begin
  SavePlayersInForm(CurrentPlayer);
  SaveUs2;
  HowManyPlayers := GetArrayLength(players)
  CanClose := True
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Makes Labels Visible or Invisible Depending on the Options Chosen       ]
[ ---------------------------------------------------------------------------- }

procedure ChangeLabels(sender: TObject);
begin
  If (ColorCheckBox.Checked) then
  Begin
    ColorsLabel.Visible := True;
    ColorsEdit.Visible := True;
  end else
  Begin
    ColorsLabel.Visible := False;
    ColorsEdit.Visible := False;
    Players[CurrentPlayer].Integer1 := 0;
    ColorsEdit.Text := '0';
  end;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Closes the Form and Starts the Script                                   ]
[ ---------------------------------------------------------------------------- }

Procedure StartClicked(Sender: TObject);
var
  v: TVariantArray;
begin
  SetArrayLength ( V, 0);
  frmDesign.ModalResult:= mrOk;
  StartScript := True;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Opens the Donations Page.  DOnation are always Appreciated!             ]
[ ---------------------------------------------------------------------------- }

Procedure DonateClicked(Sender: TObject);
begin
  OpenWebPage('https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=starblaster100%40gmail'+
              '%2ecom&item_name=Starblaster100s%20SCAR%20Scripts&no_shipping=1&no_note=1&tax=0&'+
              'currency_code=GBP&lc=GB&bn=PP%2dDonationsBF&charset=UTF%2d8');
  For x := 0 to 7 do
    Writeln(' -->  Thank You!  <-- ');
end;

{ ---------------------------------------------------------------------------- ]
[  >>  Displays the Main Form for the First Time                               ]
[ ---------------------------------------------------------------------------- }

Procedure InitForm;
Begin
LoadUs2;

frmDesign := CreateForm;
frmDesign.Position := poDesktopCenter;
frmDesign.Width := 313;
frmDesign.Height := 285;
frmDesign.Caption := 'PowerSkills by Starblaster100';
frmDesign.Color := clInactiveCaption;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
frmDesign.OnCloseQuery := @FormClose2;

TitleLabel := TLabel.Create(frmDesign);
TitleLabel.Parent := frmDesign;
TitleLabel.Left := 28;
TitleLabel.Top := 10;
TitleLabel.Width := 277;
TitleLabel.Height := 20;
TitleLabel.Caption := 'PowerSkills by Starblaster100';
TitleLabel.Font.Color := clWindowText;
TitleLabel.Font.Height := -17;
TitleLabel.Font.Name := 'MS Sans Serif';
TitleLabel.Font.Style := [fsBold, fsUnderline];
TitleLabel.ParentFont := False;

CreatePlayerButton := TButton.Create(frmDesign);
CreatePlayerButton.Parent := frmDesign;
CreatePlayerButton.Left := 60;
CreatePlayerButton.Top := 35;
CreatePlayerButton.Width := 83;
CreatePlayerButton.Height := 29;
CreatePlayerButton.Hint := 'Click to Create a New Player';
CreatePlayerButton.Caption := 'Create Player';
CreatePlayerButton.ParentShowHint := False;
CreatePlayerButton.ShowHint := True;
CreatePlayerButton.TabOrder := 13;
CreatePlayerButton.OnClick := @CreateNewUser;

DeletePlayerButton := TButton.Create(frmDesign);
DeletePlayerButton.Parent := frmDesign;
DeletePlayerButton.Left := 150;
DeletePlayerButton.Top := 35;
DeletePlayerButton.Width := 83;
DeletePlayerButton.Height := 29;
DeletePlayerButton.Hint := 'Click to Delete the Current Player';
DeletePlayerButton.Caption := 'Delete Player';
DeletePlayerButton.ParentShowHint := False;
DeletePlayerButton.ShowHint := True;
DeletePlayerButton.TabOrder := 13;
DeletePlayerButton.OnClick := @DeleteAPlayer;

LeftButton := TButton.Create(frmDesign);
LeftButton.Parent := frmDesign;
LeftButton.Left := 15;
LeftButton.Top := 35;
LeftButton.Width := 38;
LeftButton.Height := 29;
LeftButton.Hint := 'Click to go to the Previous Player';
LeftButton.Caption := '<---';
LeftButton.ParentShowHint := False;
LeftButton.ShowHint := True;
LeftButton.TabOrder := 13;
LeftButton.OnClick := @PressBackButton;

RightButton := TButton.Create(frmDesign);
RightButton.Parent := frmDesign;
RightButton.Left := 239;
RightButton.Top := 35;
RightButton.Width := 38;
RightButton.Height := 29;
RightButton.Hint := 'Click to go to the Next Player';
RightButton.Caption := '--->';
RightButton.ParentShowHint := False;
RightButton.ShowHint := True;
RightButton.TabOrder := 14;
RightButton.OnClick := @PressNextButton;

UsernameLabel := TLabel.Create(frmDesign);
UsernameLabel.Parent := frmDesign;
UsernameLabel.Left := 16;
UsernameLabel.Top := 73;
UsernameLabel.Width := 63;
UsernameLabel.Height := 16;
UsernameLabel.Font.Color := clWindowText;
UsernameLabel.Font.Height := -15;
UsernameLabel.Font.Name := 'MS Sans Serif';
UsernameLabel.Font.Style := [];
UsernameLabel.ParentFont := False;
UsernameLabel.Caption := '0. Username';

PasswordLabel := TLabel.Create(frmDesign);
PasswordLabel.Parent := frmDesign;
PasswordLabel.Left := 16;
PasswordLabel.Top := 96;
PasswordLabel.Width := 60;
PasswordLabel.Height := 16;
PasswordLabel.Font.Color := clWindowText;
PasswordLabel.Font.Height := -15;
PasswordLabel.Font.Name := 'MS Sans Serif';
PasswordLabel.Font.Style := [];
PasswordLabel.ParentFont := False;
PasswordLabel.Caption := '0. Password';

LampSkillLabel := TLabel.Create(frmDesign);
LampSkillLabel.Parent := frmDesign;
LampSkillLabel.Left := 16;
LampSkillLabel.Top := 120;
LampSkillLabel.Width := 62;
LampSkillLabel.Height := 16;
LampSkillLabel.Font.Color := clWindowText;
LampSkillLabel.Font.Height := -15;
LampSkillLabel.Font.Name := 'MS Sans Serif';
LampSkillLabel.Font.Style := [];
LampSkillLabel.ParentFont := False;
LampSkillLabel.Caption := '0. Lamp Skill';

TripsLabel := TLabel.Create(frmDesign);
TripsLabel.Parent := frmDesign;
TripsLabel.Left := 16;
TripsLabel.Top := 144;
TripsLabel.Width := 62;
TripsLabel.Height := 16;
TripsLabel.Font.Color := clWindowText;
TripsLabel.Font.Height := -15;
TripsLabel.Font.Name := 'MS Sans Serif';
TripsLabel.Font.Style := [];
TripsLabel.ParentFont := False;
TripsLabel.Caption := '0. Loads';

UsernameEdit := TEdit.Create(frmDesign);
UsernameEdit.Parent := frmDesign;
UsernameEdit.Left := 100;
UsernameEdit.Top := 71;
UsernameEdit.Width := 121;
UsernameEdit.Height := 21;
UsernameEdit.Hint := 'Type in your Username here';
UsernameEdit.ParentShowHint := False;
UsernameEdit.ShowHint := True;
UsernameEdit.TabOrder := 8;
UsernameEdit.Text := Players[0].Name;

PasswordEdit := TEdit.Create(frmDesign);
PasswordEdit.Parent := frmDesign;
PasswordEdit.Left := 100;
PasswordEdit.Top := 94;
PasswordEdit.Width := 121;
PasswordEdit.Height := 21;
PasswordEdit.Hint := 'Type in your Password here';
PasswordEdit.ParentShowHint := False;
PasswordEdit.PasswordChar := '*';
PasswordEdit.ShowHint := True;
PasswordEdit.TabOrder := 9;
PasswordEdit.Text := Players[0].Pass;

LampSkillComboBox := TComboBox.Create(frmDesign);
LampSkillComboBox.Parent := frmDesign;
LampSkillComboBox.Left := 100;
LampSkillComboBox.Top := 117;
LampSkillComboBox.Width := 121;
LampSkillComboBox.Height := 21;
LampSkillComboBox.Hint := 'Type in the Skill you want to use a Lamp on if Found';
LampSkillComboBox.ItemHeight := 13;
LampSkillComboBox.ParentShowHint := False;
LampSkillComboBox.ShowHint := True;
LampSkillComboBox.TabOrder := 10;
LampSkillComboBox.Text := Players[0].Skill;
LampSkillComboBox.Items.Add('Strength');
LampSkillComboBox.Items.Add('Attack');
LampSkillComboBox.Items.Add('Ranged');
LampSkillComboBox.Items.Add('Magic');
LampSkillComboBox.Items.Add('Defence');
LampSkillComboBox.Items.Add('Hitpoints');
LampSkillComboBox.Items.Add('Prayer');
LampSkillComboBox.Items.Add('Agility');
LampSkillComboBox.Items.Add('Herblore');
LampSkillComboBox.Items.Add('Thieving');
LampSkillComboBox.Items.Add('Crafting');
LampSkillComboBox.Items.Add('Runecrafting');
LampSkillComboBox.Items.Add('Slayer');
LampSkillComboBox.Items.Add('Farming');
LampSkillComboBox.Items.Add('Mining');
LampSkillComboBox.Items.Add('Smithing');
LampSkillComboBox.Items.Add('Fishing');
LampSkillComboBox.Items.Add('Cooking');
LampSkillComboBox.Items.Add('Firemaking');
LampSkillComboBox.Items.Add('Woodcutting');
LampSkillComboBox.Items.Add('Fletching');
LampSkillComboBox.Items.Add('Construction');
LampSkillComboBox.Items.Add('Hunting');

LoadsEdit := TEdit.Create(frmDesign);
LoadsEdit.Parent := frmDesign;
LoadsEdit.Left := 100;
LoadsEdit.Top := 140;
LoadsEdit.Width := 121;
LoadsEdit.Height := 21;
LoadsEdit.Hint := 'Type in how many Loads to PowerSkill before Switching Char.';
LoadsEdit.ParentShowHint := False;
LoadsEdit.ShowHint := True;
LoadsEdit.TabOrder := 10;
LoadsEdit.Text := IntToStr(Players[0].Integer2);

IsActive := TCheckBox.Create(frmDesign);
IsActive.Parent := frmDesign;
IsActive.Left := 225;
IsActive.Top := 71;
IsActive.Width := 53;
IsActive.Height := 20;
IsActive.Caption := 'Active?';
IsActive.ParentShowHint := False;
IsActive.ShowHint := True;
IsActive.Hint := 'Should this Player be Active?';
IsActive.Checked := Players[0].Active;

ColorCheckBox := TCheckBox.Create(frmDesign);
ColorCheckBox.Parent := frmDesign;
ColorCheckBox.Left := 225;
ColorCheckBox.Top := 94;
ColorCheckBox.Width := 53;
ColorCheckBox.Height := 20;
ColorCheckBox.Caption := 'Colors?';
ColorCheckBox.ParentShowHint := False;
ColorCheckBox.ShowHint := True;
ColorCheckBox.Hint := 'Do you want to pick Your Own Colors?';
ColorCheckBox.Checked := Players[0].Boolean1;
ColorCheckBox.OnClick := @ChangeLabels;

String1ComboBox := TComboBox.Create(frmDesign);
String1ComboBox.Parent := frmDesign;
String1ComboBox.Left := 10;
String1ComboBox.Top := 165;
String1ComboBox.Width := 80;
String1ComboBox.Height := 21;
String1ComboBox.Hint := 'Select the Skill to Power Auto';
String1ComboBox.ItemHeight := 13;
String1ComboBox.ParentShowHint := False;
String1ComboBox.ShowHint := True;
String1ComboBox.TabOrder := 11;
String1ComboBox.Text := Players[0].String1;
String1ComboBox.Items.Add('Woodcutting');
String1ComboBox.Items.Add('Mining');
String1ComboBox.Items.Add('Fishing');
String1ComboBox.Items.Add('Bone Burying');
String1ComboBox.Items.Add('Fletching');
String1ComboBox.OnChange := @String1Change;

String2ComboBox := TComboBox.Create(frmDesign);
String2ComboBox.Parent := frmDesign;
String2ComboBox.Left := 95;
String2ComboBox.Top := 165;
String2ComboBox.Width := 120;
String2ComboBox.Height := 21;
String2ComboBox.Hint := 'Select the Specific thing to Power Auto';
String2ComboBox.ItemHeight := 13;
String2ComboBox.ParentShowHint := False;
String2ComboBox.ShowHint := True;
String2ComboBox.TabOrder := 12;
String2ComboBox.Text := Players[0].String2;
String2ComboBox.OnDropDown := @String1Change;

String3ComboBox := TComboBox.Create(frmDesign);
String3ComboBox.Parent := frmDesign;
String3ComboBox.Left := 220;
String3ComboBox.Top := 165;
String3ComboBox.Width := 70;
String3ComboBox.Height := 21;
String3ComboBox.Hint := 'Select the Direction to Run in if we are Attacked';
String3ComboBox.ItemHeight := 13;
String3ComboBox.ParentShowHint := False;
String3ComboBox.ShowHint := True;
String3ComboBox.TabOrder := 12;
String3ComboBox.Items.Add('N');
String3ComboBox.Items.Add('E');
String3ComboBox.Items.Add('S');
String3ComboBox.Items.Add('W');
String3ComboBox.Text := Players[0].String3;

GemsCheckBox := TCheckBox.Create(frmDesign);
GemsCheckBox.Parent := frmDesign;
GemsCheckBox.Left := 225;
GemsCheckBox.Top := 117;
GemsCheckBox.Width := 78;
GemsCheckBox.Height := 20;
GemsCheckBox.Caption := 'Save Gems?';
GemsCheckBox.ParentShowHint := False;
GemsCheckBox.ShowHint := True;
GemsCheckBox.Hint := 'Do you want to save the Gems you Mine?';
GemsCheckBox.Checked := Players[0].Boolean3;
If (String1ComboBox.Text = 'Mining') then
  GemsCheckBox.Visible := True
else
  GemsCheckBox.Visible := False;

FletchComboBox := TComboBox.Create(frmDesign);
FletchComboBox.Parent := frmDesign;
FletchComboBox.Left := 182;
FletchComboBox.Top := 193;
FletchComboBox.Width := 100;
FletchComboBox.Height := 21;
FletchComboBox.Hint := 'Select What Type of Log the Item is';
FletchComboBox.ItemHeight := 13;
FletchComboBox.ParentShowHint := False;
FletchComboBox.ShowHint := True;
FletchComboBox.TabOrder := 12;
FletchComboBox.Items.Add('Normal');
FletchComboBox.Items.Add('Oak');
FletchComboBox.Items.Add('Willow');
FletchComboBox.Items.Add('Maple');
FletchComboBox.Items.Add('Yew');
FletchComboBox.Items.Add('Magic');
FletchComboBox.Text := FletchString[0];
If (String1ComboBox.Text = 'Fletching') then
  FletchComboBox.Visible := True
else
  FletchComboBox.Visible := False;

ColorsLabel := TLabel.Create(frmDesign);
ColorsLabel.Parent := frmDesign;
ColorsLabel.Left := 10;
ColorsLabel.Top := 194;
ColorsLabel.Width := 80;
ColorsLabel.Height := 12;
ColorsLabel.Font.Color := clWindowText;
ColorsLabel.Font.Height := -12;
ColorsLabel.Font.Name := 'MS Sans Serif';
ColorsLabel.Font.Style := [];
ColorsLabel.ParentFont := False;
ColorsLabel.Caption := 'Picked Color:';
If (ColorCheckBox.Checked) then
  ColorsLabel.Visible := True
else
  ColorsLabel.Visible := False;

ColorsEdit := TEdit.Create(frmDesign);
ColorsEdit.Parent := frmDesign;
ColorsEdit.Left := 77;
ColorsEdit.Top := 191;
ColorsEdit.Width := 80;
ColorsEdit.Height := 21;
ColorsEdit.Hint := 'Put in the Color of the Item you are Autoing.  Leave as 0 for AutoPick';
ColorsEdit.ParentShowHint := False;
ColorsEdit.ShowHint := True;
ColorsEdit.TabOrder := 8;
ColorsEdit.Text := IntToStr(Players[0].Integer1);
If (ColorCheckBox.Checked) then
  ColorsEdit.Visible := True
else
  ColorsEdit.Visible := False;

MiningSecsLabel := TLabel.Create(frmDesign);
MiningSecsLabel.Parent := frmDesign;
MiningSecsLabel.Left := 162;
MiningSecsLabel.Top := 194;
MiningSecsLabel.Width := 80;
MiningSecsLabel.Height := 12;
MiningSecsLabel.Font.Color := clWindowText;
MiningSecsLabel.Font.Height := -12;
MiningSecsLabel.Font.Name := 'MS Sans Serif';
MiningSecsLabel.Font.Style := [];
MiningSecsLabel.ParentFont := False;
MiningSecsLabel.Caption := 'Seconds:';
If (String1ComboBox.Text = 'Mining') then
  MiningSecsLabel.Visible := True
else
  MiningSecsLabel.Visible := False;

MiningSecsEdit := TEdit.Create(frmDesign);
MiningSecsEdit.Parent := frmDesign;
MiningSecsEdit.Left := 210;
MiningSecsEdit.Top := 191;
MiningSecsEdit.Width := 80;
MiningSecsEdit.Height := 21;
MiningSecsEdit.Hint := 'Number of Seconds you are willing to Wait for a rock to Mine before Clicking Again';
MiningSecsEdit.ParentShowHint := False;
MiningSecsEdit.ShowHint := True;
MiningSecsEdit.TabOrder := 8;
MiningSecsEdit.Text := IntToStr(Players[0].Integer3);
If (String1ComboBox.Text = 'Mining') then
  MiningSecsEdit.Visible := True
else
  MiningSecsEdit.Visible := False;

BankCheckBox := TCheckBox.Create(frmDesign);
BankCheckBox.Parent := frmDesign;
BankCheckBox.Left := 164;
BankCheckBox.Top := 192;
BankCheckBox.Width := 125;
BankCheckBox.Height := 20;
BankCheckBox.Caption := 'Withdraw From Bank?';
BankCheckBox.ParentShowHint := False;
BankCheckBox.ShowHint := True;
BankCheckBox.Hint := 'Click to Withdraw Bones from Bank and Bury. Otherwise it will pick up from Floor';
BankCheckBox.Checked := Players[0].Boolean2;
If (String1ComboBox.Text = 'Bone Burying') then
  BankCheckBox.Visible := True
else
  BankCheckBox.Visible := False;

StartButton := TButton.Create(frmDesign);
StartButton.Parent := frmDesign;
StartButton.Left := 60;
StartButton.Top := 220;
StartButton.Width := 75;
StartButton.Height := 25;
StartButton.Hint := 'Click to Start the Script';
StartButton.Caption := 'Start Script';
StartButton.ParentShowHint := False;
StartButton.ShowHint := True;
StartButton.TabOrder := 15;
StartButton.OnClick := @StartClicked;

DonateButton := TButton.Create(frmDesign);
DonateButton.Parent := frmDesign;
DonateButton.Left := 150;
DonateButton.Top := 220;
DonateButton.Width := 75;
DonateButton.Height := 25;
DonateButton.Hint := 'Donations are always Appreciated!';
DonateButton.Caption := 'Donate!';
DonateButton.ParentShowHint := False;
DonateButton.ShowHint := True;
DonateButton.TabOrder := 15;
DonateButton.OnClick := @DonateClicked;
end;

{ ---------------------------------------------------------------------------- ]
[  >>  The Main Loop                                                           ]
[  >>  Pretty Self Explanitory ;-)                                             ]
[ ---------------------------------------------------------------------------- }

Begin
  SetupSRL;
  SetupSRLMining;
  SetupSRLFishing;
  NewLine := '';
  ScriptID := '67';
  WriteNews;
  Intro;

  try
    SafeInitForm;
    SafeShowFormModal;
  finally
    FreeForm(frmDesign);
  except
    Writeln('Error in InitForm!');
  end;

  If not(StartScript) then TerminateScript;
  BenMouse := False;
  ActivateClient;
  Wait(200 + Random(300));
  GenerateNickNames;
  LoadDTMsandBitmaps;

  Repeat
    NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
    If not(Loggedin)then LoginPlayer;
    GetAllLevels;
    Report2 := GetSystemTime;
    Status('Preparing Character');
    Case Lowercase(Players[CurrentPlayer].String1) of
      'woodcutting' : Begin
                        FindAxeHeadColor;
                        AutoTreeColor(Players[CurrentPlayer].String2);
                      end;
      'mining'      : Begin
                        FindPickHeadColor;
                        AutoRockColor;
                      end;
      'fishing'     : FindFishingEquipmentColor;
      'bone burying': Wait(1);
      'fletching'   : If (Copy(Lowercase(Players[CurrentPlayer].String2), 1, 2) = 'lo') then
                      Begin
                        GameTab(4);
                        If not(FindDTM(DTMFletching[2], x, y, MIX1, MIY1, MIX2, MIY2))then
                        Begin
                          Players[CurrentPlayer].Loc := 'No Knife Found!';
                          Players[CurrentPlayer].Active := False;
                          Logout;
                        end;
                      end;
      else Begin Writeln('Error in Main Loop 1!'); TerminateScript; end;
    end;
    Repeat
      Repeat
        If not(LoggedIn) then Break;
        Case Lowercase(Players[CurrentPlayer].String1) of
          'woodcutting' : Chopping;
          'mining'      : MineRock(Players[CurrentPlayer].Integer3);
          'fishing'     : DoFishing;
          'bone burying': If (GrabBones(Players[CurrentPlayer].Boolean2)) then Break;
          'fletching'   : If GrabForFletching then Break;
          else Begin Writeln('Error in Main Loop 2!'); TerminateScript; end;
        end;
        Wait(100);
      Until(InventoryCount >= 28) or not (LoggedIn)
      Case Lowercase(Players[CurrentPlayer].String1) of
        'woodcutting' : Drop(DTMLog);
        'mining'      : If (Players[CurrentPlayer].Boolean3 = False) then
                        begin
                          Drop(DTMMining[1]);   //For some reason the "for do" loop doesn't work here :(
                          Drop(DTMMining[2]);
                        end else
                          Drop(DTMMining[1]);
        'fishing'     : begin
                          Drop(DTMFishing[1]);
                          Drop(DTMFishing[2]);
                          Drop(DTMFishing[3]);
                          Drop(DTMFishing[4]);
                          Drop(DTMFishing[5]);
                          Drop(DTMFishing[6]);
                          Drop(DTMFishing[7]);
                        end;
        'bone burying': BuryBones(Players[CurrentPlayer].String2);
        'fletching'   : Fletch;
        else Begin Writeln('Error in Main Loop 3!'); TerminateScript; end;
      end;

      Players[CurrentPlayer].Extended1 := Players[CurrentPlayer].Extended1 + 1;
      Players[CurrentPlayer].Banked := Players[CurrentPlayer].Banked + 1;
      SendPSStats(Players[CurrentPlayer].String1);

    until(Players[CurrentPlayer].Extended1 >= Players[CurrentPlayer].Integer2)or not(LoggedIn)

    ProgressReport(True);
    SRLRandomsReport;
    Players[CurrentPlayer].Extended1 := 0;
    FreeBitmap(NickNameBMP);

    If(LoggedIn)then
      NextPlayer(True)
    else
      NextPlayer(False)

  Until(False)
end.