Results 1 to 8 of 8

Thread: Getting a major pain in the .... error

  1. #1
    Join Date
    Nov 2008
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Getting a major pain in the .... error

    Hello, for some reason it keeps giving me the same error every time and every script. The error is:
    [Runtime Error] : Out Of Range in line 27 in script C:\Program Files\SCAR 3.15\Scripts\EssMiner.Scar

    Generally the line is usually Players[0].Name := ' ';

    It's really starting to make me mad. If you could, could you help me, please?
    Thanks Skyfire999.

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Read this topic and see if it helps. It should explain how to fix your error.
    :-)

  3. #3
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    ... don't tell me you kept all of the things player[0].name... omg didn't even think of it when i was trying to help you earlier... you have to change that for each character...
    ex.
    player[0].name
    rest of stuff...

    player[1].name
    rest of stuff...

    and so on...

  4. #4
    Join Date
    Nov 2008
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It really doesn't help me much, but i did exactly what it said to do and it keeps giving me the same error.

  5. #5
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Post the script you're using in SCAR tags, then.
    :-)

  6. #6
    Join Date
    Nov 2008
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    okay, i got it to stop getting the error by using // to Players[0].Name := ' ';
    By the way im using SRL Essence Miner V2 by Wizzup?
    SCAR Code:
    http://www.villavu.com/forum/showthread.php?t=34175
    now it's saying i don't have any players, so now it keeps saying the same thing over. When i run Narcle's Fast fighter it work perfectly fine. I'm kind of new to scar and don't no much about scar.

  7. #7
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Make sure you have NumberOfPlayers set correctly.

  8. #8
    Join Date
    Nov 2008
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I think I do, but I'll post the script:

    SCAR Code:
    Program Essminer;
    {.Include SRL/SRL/Misc/SMART.Scar}
    {.Include SRL/SRL.Scar}
    {.Include SRL/SRL/Skill/Mining.Scar}

    Var
      Report, tAbyss, Abyss, ArrowColor, LadderColor, Ess: Integer;
      V: String;

    Const
      Loads = 10; //How many loads until progressreport and player switching
      UseSMART = True; //If not using smart. remove the smart include, then go SETUPSMART
      SMARTWorld = 136;
     
      DeBugInfo = False;

    Procedure DeclarePlayers;
    Begin

           SRLID := '';
           SRLPassword := '';

      CurrentPlayer := 0;
      HowManyPlayers  := 1;
      NumberOfPlayers( HowManyPlayers );

      Players[0].Name  := '';
      Players[0].Pass  := '';
      Players[0].Nick  := '';
      Players[0].Active:= True;

      Writeln( IntToStr ( HowManyPlayers ) + ' Player[s]' );
    End;

    Procedure WriteIt(S: String);
    Begin
      If(DeBugInfo)Then
        Writeln(S);
    End;

    Function SRLNetReport: Boolean;
    Begin
      If(Report = 0)Then
        Report := GetSystemTime;
      If(GetSystemTime - Report >= 305000)Then
      Begin
        Writeln('Sent SRL Stats.');
        SRLRandomsReport;
        Result := True;
        Report := GetSystemTime;
      End;
    End;
     
    Procedure SetupSMART;
    Begin
      //If u dont use SMART comment the line below
      SmartSetup('World'+IntToStr(SMARTWorld), True, True, False);
      SetTargetDC(SmartGetDC);
      If Not (LoggedIn) Then
        While Not (SmartGetColor(360, 172) = 13158) Do
          Wait(100);
    End;

    Function FindColorSymbol(Var X, Y: Integer; S: String): Boolean;
    Var
      Col: Integer;
    Begin
      Case lowercase(S) of
       'arrow': Col := ArrowColor;
      End;
      If( Col = 0 )Then
      Begin
        Col := GetSymbolColor(X, Y, S);
        If(Col > 0)Then
          Writeln(S + ' Color is ' + IntToStr(Col));
      End;
      X := MMCX;
      Y := MMCY;
      If(Col <> 0)Then
        If(FindColorSpiral(X, Y, Col, MMX1, MMY1, MMX2, MMY2))Then
          Result := True;
      Case lowercase(S) of
       'arrow': ArrowColor := Col;
      End;
    End;

    Function n_FindPick: Boolean;
    Var
      C, cts, Ex, Ey, bmp_PickAxe, X, Y: Integer;
    Begin
      If(Not NoPick)Then
        If(Not EquipPick)Then
        Begin
          If(GetCurrentTab <> 4)Then
          Begin
            GameTab(4);
            Wait(500);
          End;
          bmp_PickAxe := BitmapFromString(30, 14, 'z78DA3330A03E70C3010C' +
             '0625C0EF36FAB8DC8D2C407F37D32E36A96B267D521DB56C19A8D' +
             'C41B9FBDDA80406732C0F8F544A7C0C0E6CBA25AF641BD8B211BF' +
             'AB28C94DB47039ADC307D3FDB42B2107674D34185A1400863DFCA' +
             '8');
          NoPick := Not FindBitmapMaskTolerance(bmp_PickAxe, X, Y, MIX1, MIY1, MIX2, MIY2, 10, 10);
          FreeBitmap(bmp_PickAxe);
        End Else
          If(ClickContinue(False, False))Then
            NoPick := FindNPCChatText('Pickaxe', Nothing);
           
      Result := Not NoPick;
     
      If(NoPick)Then
      Begin
        Writeln('Lost Pick');
       
        If(InvFull)Then
          DropItem(2);
         
        If(InvCount = 27)Then
          DropItem(3);

        If(EquipPick)Then
          TakeOff(5);

        GameTab(4);
       
        if FindBitmapMaskTolerance(BrokenPick, X, Y, MIX1, MIY1, MIX2, MIY2, 10, 10) then
        begin   // Broken Pickaxe Handler
          NoPick := True;
          case Random(5) of
           0: TypeSend('arg');
           1: TypeSend('aarg');
           2: TypeSend('arghh');
           3: TypeSend('dam');
           4: TypeSend('sjee.');
          end;
          Result := False;
          Exit;
        end;
       
        GameTab(4);
        if FindBitmapMaskTolerance(PickAxeHandle, X, Y, MIX1, MIY1, MIX2, MIY2, 10, 10) then
        Begin
          cts := GetColorToleranceSpeed;
          repeat
            if not (LoggedIn) then Exit;
            x := Random(510) + 5;
            y := Random(330) + 5;
            ColorToleranceSpeed(2);
            if (FindColorSpiralTolerance(x, y, hc1, MSx1, MSy1, MSx2, MSy2, 10)) or
               (FindColorSpiralTolerance(x, y, hc2, MSx1, MSy1, MSx2, MSy2, 10)) or
               (FindColorSpiralTolerance(x, y, hc3, MSx1, MSy1, MSx2, MSy2, 10)) or
               (FindColorSpiralTolerance(x, y, hc4, MSx1, MSy1, MSx2, MSy2, 10)) or
               (FindColorSpiralTolerance(x, y, hc5, MSx1, MSy1, MSx2, MSy2, 10)) then
               begin
                 MMouse(x, y, 2, 2);
                 if IsUpTextMultiCustom(['Take', 'pick', 'head']) then
                 begin
                   GetMousePos(x, y);
                   Mouse(x, y, 0, 0, True);
                 end;
                 FFlag(0);
                 Wait(1000 + Random(100));
               end;
            c := c + 1;
            GameTab(4);
          until ((FindBitmapMaskTolerance(PickAxeHead, x, y, MIx1, MIy1, MIx2, MIy2, 10, 10))or (c >= 10));
          ColorToleranceSpeed(cts);
        End;
       
        Gametab(4);
        if FindBitmapMaskTolerance(PickAxeHead, X, Y, MIx1, MIy1, MIx2, MIy2, 10, 10)And
           FindBitmapMaskTolerance(PickAxeHandle, ex, ey, MIx1, MIy1, MIx2, MIy2, 10, 10) then
           begin
             Mouse(X, Y, 0, 0, True);
             Wait(1000 + Random(100));
             Mouse(ex + 5, ey + 11, 2, 2, True);
             PickAxeAttached := PickAxeAttached + 1;
             WriteLn('Attached Head & Handle');
             bmp_PickAxe := BitmapFromString(30, 14, 'z78DA3330A03E70C3010C' +
             '0625C0EF36FAB8DC8D2C407F37D32E36A96B267D521DB56C19A8D' +
             'C41B9FBDDA80406732C0F8F544A7C0C0E6CBA25AF641BD8B211BF' +
             'AB28C94DB47039ADC307D3FDB42B2107674D34185A1400863DFCA' +
             '8');
             NoPick := Not FindBitmapMaskTolerance(bmp_PickAxe, X, Y, MIX1, MIY1, MIX2, MIY2, 10, 10);
             FreeBitmap(bmp_PickAxe);
             Result := Not NoPick;
             if EquipPick then
             begin
               Wait(3000);
               if FindColor(X, Y, hc1, MIx1, MIy1, MIx2, MIy2) then
                 Mouse(X, Y, 5, 5, True);
             end;
           end;
      End;
    End;

    Function GetPaintBitmap(Color, sX, sY: Integer; Text: TStringArray; Dist: Integer): Integer;
    Var
       TPA: TPointArray;
       H, Q, B: Integer;
    Begin
      Result := BitmapFromString(sX, sY, '');
      For B := 0 To High(Text) Do
      Begin
        TPA := LoadTextTPA(Text[b], UpChars, H);
        Color := Random(16777215);
        For Q := 0 To High(TPA) Do
          FastSetPixel(Result, TPA[q].x, TPA[q].y + B * Dist, Color);
      End;
    End;

    Procedure ClearSMARTCanvas;
    Var
      BMP: Integer;
      SMARTCanvas, Canvas: TCanvas;
    Begin
      BMP := BitmapFromString(765, 503, '')
      SMARTCanvas := GetBitmapCanvas(BMP);
      Canvas := GetBitmapCanvas(BMP);
      SMARTCanvas.handle := SmartGetDebugDC;
      CopyCanvas(Canvas, SMARTCanvas, 0, 0, 765, 503, -1000, -1000, 1000, 1000);
      FreeBitmap(BMP);
    End;

    Procedure ProgressReportCanvas(X, Y: Integer);
    Var
      SCanvas, Canvas: TCanvas;
      BMP, Sec: Integer;
      Text: TStringArray;
    Begin
      If(Not UseSMART)Then Exit;
      Sec := GetTimeRunning div 1000+1;
      ClearSMARTCanvas;
      BMP := BitmapFromString(765, 503, '');
      SCanvas := GetBitmapCanvas(BMP);
      SCanvas.handle := SmartGetDebugDC;
      Text := [
           'Worked : ' + TimeRunning,
           'Mined  : ' + IntToStr( Ess )+ ' Ess',
           'Gained : ' + IntToStr( Ess * 5 )+ ' Exp',
           'Banked : ' + IntToStr( Banks )+ ' Loads',
           'Solved : ' + IntToStr( Abyss )+' Abyss Randoms',
           'Ess per hour : ' + IntToStr(Round(3600*Ess/Sec)),
           'Exp per hour : ' + IntToStr(Round(3600*(Ess * 5)/Sec)),
           'Banks per hour : ' + IntToStr(Round(3600*Banks/Sec))];
      Canvas := GetBitmapCanvas(GetPaintBitmap(255, 765, 503, Text, 25));
      CopyCanvas(Canvas, SCanvas, 0, 0, 765, 503, X, Y, X + 765, Y + 503);
      FreeBitmap(BMP);
    End;

    Function ScanMiniMap(iFrom, iTo, Distance: Integer): Integer;
    Var
       I: Integer;
    Begin
      For I := iFrom To ITo Do
        If GetColor(Round(Distance * Sin(I * Pi / 180)) + 626, Round(-Distance * Cos(I * Pi / 180)) + 84) = 65536 Then
          Inc(Result);
    End;

    Function InAbyss: Boolean;
    Var
      X, Y: Integer;
    Begin
      Result := InRange(CountColorTolerance(0, MMX1, MMY1, MMX2, MMY2, 1),
                        108372, 108495)And(ScanMinimap(0, 359, 50) = 360)And
                        (Not FindColor(X, Y, 195836, MMX1, MMY1, MMX2, MMY2));
    End;

    Function SolveAbyss: Boolean;
    Var
      T, Tol, II, I, X, Y: Integer;
      Cols: TIntegerArray;
      Box: TBox;
    Begin
      //If(FindNormalRandoms)Then Exit;
      If(Not InAbyss)Then Exit;
      Writeln('In Abyss!');
      Cols := [6753318, 11844301, 6209303, 3157315, 3027300];
      Tol := 30;
      T := GetSystemTime;
      While(InAbyss)And(LoggedIn)Do
      Begin
        If( GetSystemTime - T > 30000)Then Break;
        Wait(50);
        I := Random(4);
        Case I Of
         0: Box := PointToBox(Point(239, 95), Point(273, 128));
         1: Box := PointToBox(Point(278, 134), Point(310, 192));
         2: Box := PointToBox(Point(246, 175), Point(283, 210));
         3: Box := PointToBox(Point(194, 141), Point(231, 182));
         Else Continue;
        End;
        X := MSCX;
        Y := MSCY;
        If(FindColorSpiralTolerance(X, Y, Cols[II], Box.X1, Box.Y1, Box.X2, Box.Y2, Tol))Then
        Begin
          MMouse(X, Y, 0, 0);
          Wait(30+Random(40));
          If(IsUpText('per'))Then
          Begin
            GetMousepos(X, Y);
            Mouse(X, Y, 0, 0,True);
            Wait(500+Random(400));
          End Else II := II + 1;
        End Else II := II + 1;
        If(II = 5)Then
        Begin
          Tol := Tol + 5;
          II := 0;
        End;
        Status(IntTostr(II)+ ' - ' +IntToStr(Tol));
      End;
      Result := Not InAbyss;
      If(Result)Then
      Begin
        Inc(tAbyss);
        Inc(Abyss);
        Writeln('Solved Abyss in ' +IntToStr(GetSystemTime - T)+' Msec');
      End;
      If(ClickContinue(False, False))Then
        While(ClickContinue(True, True))Do
          Wait(100);
    End;

    Function FindRandoms(Pickcheck: Boolean): Boolean;
    Var
      I: Integer;
    Begin
      For I:= 0 To 5 Do
      Begin
        If(Not Pickcheck)Then
          If(I = 1)Then Continue;
        Case I Of
         0: Result := SolveAbyss;
         1: Result := n_FindPick;
         2: Result := CloseBank;
         3: Result := CloseWindow;
         4: Result := FindNormalRandoms;
         5: Result := ClickContinue(False, False);
        End;
        If(Result)Then
          Break;
      End;
      If(Result)Then
        While(ClickContinue(True, True))Do
          Wait(100);
    End;

    Function UnderGround: Boolean;
    Var
      P: Integer;
    Begin
      P := PercentBlackMM;
      Result := P > 45; //possible bugs :(
      //If(Not Result)Then
      //  WriteIt('Percent: '+IntToStr(P));
    End;

    function FindLadderColorex:integer;
    var
      GC, ColorCount, a, i, j, n, l, TestColor, Red, Green, Blue : integer;
    var
      ColorArray : array of integer;
    var
      P : array of Tpoint;
    begin
      Result := FindLadderColor;
      If(Result > 0)Then
        Exit;

      GC := 3906;
      Flag;
      FindColorsSpiralTolerance(MMCX, MMY2, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
      l:=GetArrayLength(P);
      SetArrayLength(ColorArray,32);
      l:=GetArrayLength(P);
      for a:= 0 to l-1 do
      begin
        if rs_OnMinimap(P[a].x,P[a].y) then
        begin
          TestColor := GetColor(P[a].x,P[a].y);
          if SimilarColors(TestColor,GC,60) then
          begin
            ColorToRGB(TestColor, Red, Green, Blue);
            if InRange(Red, 55, 115) then
              if InRange(Green, 5, 70) then
                if InRange(Red - Blue, 55, 105) then
                  if InRange(Red - Green, 25, 65) then
                    if InRange(Green - Blue, 5, 60) then
                      if Blue <= 30 then
                      begin
                        n:=0;
                        for i:= 0 to 3 do
                        begin
                          for j:= 0 to 7 do
                          begin
                            ColorArray[n]:=GetColor(P[a].x+i,P[a].y-3+j);
                            n:=n+1;
                          end;
                        end;
                        ColorCount:=0;
                        for n:= 0 to 31 do
                        begin
                          if ColorArray[n]=TestColor then ColorCount:=ColorCount+1;
                        end;
                        if ColorCount<17 then if ColorCount>12 then
                        begin
                          Result := TestColor;
                          WriteLn('Ladder color = ' + IntToStr(TestColor)
                          +
                          ' at ' + IntToStr(P[a].x) + ',' + IntToStr(P[a].y));
                          Exit;
                        end;
                      end;
          end;
        end;
      end;
      WriteLn('Could not find Ladder Color!');
      Result := 0;
    end;

    Procedure Run;
    Var
      ColorSign: String;
    Begin
      If(GetMMLevels('run', ColorSign) > 30)Then
        SetRun(True);
    End;

    Function FindMagicSymbol(Var X, Y: Integer): Boolean;
    Var
      TPA, aTPA: T2DPointArray;
      I, CTS: Integer;
    Begin
      SetArrayLength(TPA, 2);

      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);

      SetColorSpeed2Modifiers(0.2, 2.52); //Light Red - Red
      FindColorsTolerance(TPA[0], 1717188, MMX1, MMY1, MMX2, MMY2, 10);

      SetColorSpeed2Modifiers(1.37, 2.91); //Orange - Yellow
      FindColorsTolerance(TPA[1], 1022963, MMX1, MMY1, MMX2, MMY2, 5);

      aTPA := TPAToaTPAEx(CombineTPA(TPA[0], TPA[1]), 25, 25);
      //DeBugaTPA(aTPA, '');

      SortATPASize(aTPA, True);
      //SortATPAFrom(aTPA, Point(X, Y)); //This will sort it in a Uber way :)

      For I:= 0 To High(aTPA) Do
      Begin
        MiddleTPAEx(aTPA[I], X, Y);
        SetColorSpeed2Modifiers(1.37, 2.91); //Orange-Yellow
        If(CountColorTolerance(1022963, X - 15, Y - 15, X + 15, Y + 15, 3) > 5)Then
        Begin
          WriteIt('Yellow '+IntToStr( CountColorTolerance(1022963, X - 15, Y - 15, X + 15, Y + 15, 3) ));
          SetColorSpeed2Modifiers(0.2, 2.52); //Light Red - Red
          If(CountColorTolerance(1717188, X - 10, Y - 10, X + 10, Y + 10, 10) > 5)Then
          Begin
            WriteIt('Red '+IntToStr( CountColorTolerance(1717188, X - 10, Y - 10, X + 10, Y + 10, 10) ));
            If(RS_OnMinimap(X, Y))Then
            Begin
              Result := True;
              //MoveMouse(X, Y);
              Break;
            End;
          End;
        End;
      End;
      If(Result)Then
        Writeln('Found MagicSymbol')
      Else
      Begin
        Writeln('Didnt Find MagicSymbol');
        FFlag(0);
      End;
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorTOleranceSpeed(CTS);
    End;

    Procedure WalkToAubury;
    Var
      X, Y: Integer;
      TPA: TPointArray;
    Begin
      If(Not LoggedIn)Then Exit;
      If(UnderGround)Then Exit;

      //FindColorSymbol(X, Y, 'magic shop');
      If(LadderColor = 0)Then
        LadderColor := FindLadderColorex;
      X := MMCX - 20;
      Y := MMY2;
      If(FindColorSpiral(X, Y, LadderColor, MMX1, MMCY, MMCX, MMY2))Then
      Begin
        MFNF(X + 50 + Random(10), Y - 25 + Random(5), -1, -2);
        Run;
        FFlag(10);
      End;
      X := MMCX;
      Y := MMY2;
      If(FindColorSpiral(X, Y, LadderColor, MMX1, MMCY, MMX2, MMY2))Then
      Begin
        X := X - 50;
        Y := Y - 10;
        If(FindColorSpiral(X, Y, 195836, X - 35, Y - 35, X + 35, Y + 35))Then
        Begin
          SetArrayLength(TPA, 2);
          TPA[0] := Point(X, Y);
          //If(FindColorSymbol(X, Y, 'magic shop'))THen
          If(FindMagicSymbol(X, Y))Then
          Begin
            TPA[1] := Point(X, Y);
            MiddleTPAEx(TPA, X, Y);
          End Else
          Begin
            X := TPA[0].X;
            Y := TPA[0].Y;
          End;
          MFNF(X, Y, 1, -1);
        End Else MFNF(X, Y, 1, -1);
        FFlag(10);
      End Else
        If(FindMagicSymbol(X, Y))Then
        Begin
          MFNF(X, Y, 1, -1);
          FFlag(10);
        End;
      FTWait(2);
    End;

    Function FindPortal: Boolean;
    var
      CTS, I, X, Y: Integer;
      TPA: TPointArray;
      aTPA: T2DPointArray;
    Begin
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.70, 2.14);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, 10276529, MSX1, MSY1, MSX2, MSY2, 14);
      SetColorSpeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(CTS);

      aTPA := TPAtoATPAEx(TPA, 35, 35);
      SortATPASize(aTPA, True);

      For I:= 0 To High(aTPA) Do
      Begin
        If(High(aTPA[I]) < 150)Then Continue;
        MiddleTPAEx(aTPA[I], X, Y);
        Mouse(X, Y, 0, 0, False);
        Wait(150+Random(150));
        Result := ChooseOption('Use');
        If(Result)Then
        Begin
          WriteIt('T - Port: '+IntToStr(High(aTPA[I])));
          FFlag(0);
          Break;
        End Else WriteIt('F - Port: '+IntToStr(High(aTPA[I])));
      End;
    End;

    Function AuburyWait(Down: Boolean): Boolean;
    Var
      T: Integer;
    Begin
      T := GetSystemTime;
      Repeat
        FTWait(1);
        If(Down)Then
          Result := UnderGround
        Else
          Result := Not UnderGround;
        FindRandoms(False);
        If(GetSystemTime - T > 8000)Then Exit;
      Until(LoggedIn)And(Result);
      If(InAbyss)Then
      Begin
        //Writeln('In Abyss random');
        //TerminateScript;      //EPIC!
        SolveAbyss;
      End;
    End;

    Function FindAubury: Boolean;
    Var
      Color, Tolerance: TIntegerArray;
      Sat, Hue: TExtendedArray;
      CTS, X, Y, T, I: Integer;
      TPA, P: TPointArray;
      aTPA: T2DPointArray;
    Begin
      Result := UnderGround;
      If(Result)Then Exit;

      T := GetSystemTime;

      Color :=  [6321538, 1358063, 9541276]; //Color
      Hue := [0.14, 0.18, 0.40]; //Hue
      Sat := [0.48, 0.91, 0.10]; //Sat
      Tolerance := [9, 11, 23]; //Lum

      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);

      For I:= 0 To High(Color) Do
      Begin
        SetColorspeed2Modifiers(Hue[I], Sat[I]);
        FindColorsTolerance(TPA, Color[I], MSX1, MSY1, MSX2, MSY2, Tolerance[I]);
        P := CombineTPA(TPA, P);
      End;

      aTPA := TPAToATPAEx(P, 25, 25);
      SortATPAFrom(aTPA, Point(MSCX, MSCY));
      //SortATPASize(aTPA, True);

      SetColorspeed2Modifiers(0.18, 0.91);
      For I:= 0 To High(aTPA) Do
      Begin
        If(getSystemTime - T > 2500)Then Break;
        MiddleTPAEx(aTPA[I], X, Y);
        If(PointInBox(Point(X, Y), IntToBox(4, 4, 113, 25)))Then
          Continue;
        If(CountColorTolerance(1358063, X - 35, Y - 35, X + 35, Y + 35, 11) < 15)Then
          Continue;
        MMouse(X, Y, 0, 0);
        Wait(150+Random(150));
        If(IsUpTextMultiCustom(['bury', 'k-to', 'ubu']))Then
        Begin
          WriteIt('Took ' + IntTostr(getSystemTime-t)+' - Gold Points ' +inttostr(CountColorTolerance(1358063, X - 35, Y - 35, X + 35, Y + 35, 11)));
          GetmousePos(X, Y);
          Mouse(X, Y, 0, 0, False);
          Wait(50+Random(20));
          If(ChooseOption('eleport'))Then
          Begin
            FFlag(0);
            Wait(400+Random(200));
            Result := AuburyWait(True);
            Break;
          End;
        End;
      End;
      ColorToleranceSpeed(CTS);
      SetColorspeed2Modifiers(0.2, 0.2);
    End;

    Procedure TeleAubury;
    Var
      X, Y, W: Integer;
      TPA: TPointArray;
    Begin
      If(Not LoggedIn)Then Exit;
      If(UnderGround)Then Exit;
     
      Repeat
        Inc(W);
        FTWait(1);
        If(FindAubury)Then
          Break
        Else
          If(W Mod 4 = 0)Then
            If(FindMagicSymbol(X, Y))THen
            Begin
              SetArrayLength(TPA, 2);
              TPA[0] := Point(X, Y);
              If(FindColorSpiral(X, Y, 195836, X - 35, Y - 35, X + 35, Y + 35))Then
              Begin
                TPA[1] := Point(X, Y);
                MiddleTPAEx(TPA, X, Y);
              End Else
              Begin
                X := TPA[0].X;
                Y := TPA[0].Y;
              End;
              Mouse(X, Y, 5, 5, True);
              FFlag(10);
            End Else
            Begin
              If(W > 30)Then
              Begin
                Writeln('Couldnt find aubury!');
                Logout;
                Exit;
              End;
              X := MMCX;
              Y := MMCY;
              If(FindColorSpiral(X, Y, 195836, X - 35, Y - 35, X + 35, Y + 35))Then
              Begin
                Mouse(X, Y, 5, 5, True);
                FFlag(10);
              End;
            End;
        FindRandoms(False);
      Until(Not LoggedIn)Or(UnderGround);
    End;

    Procedure ExitMine;
    Var
      W, X, Y, T: Integer;
    Begin
      If(Not LoggedIn)Then Exit;
      If(Not UnderGround)Then Exit;
      T := GetSystemTime;
      Repeat

        If(GetSystemTime - T > 20000)Then Exit;
        If(Not Loggedin)Then Exit;

        If(W > 10)Then
        Begin

        End;

        If(FindPortal)Then
        Begin
          if AuburyWait(False) then
            break;
        End
        Else
          If(FindColorSymbol(X, Y, 'arrow'))Then
          Begin
            Inc(W);
            If(W Mod 2 <> 0)Then Continue;
            Mouse(X+Random(20)-Random(20), Y+Random(20)-Random(20), 5, 5, True);
            FFlag(0);
            T := GetSystemTime;
          End Else
            W := 0;
        Inc(W);

        FTWait(2);
      Until(Not LoggedIn)Or(Not UnderGround);
    End;

    Function FindYellowDots(Var X, Y: Integer; AmountOfDots, Tolerance: Integer): Boolean;
    Var
      I: Integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    Begin
      FindColorsTolerance(TPA, 195836, MMX1, MMY1, MMX2, MMY2, 0);
      aTPA := SplitTPA(TPA, 3 + Tolerance);
      For I:= 0 To GetArrayLength( aTPA ) - 1 Do
        If( GetArrayLength(aTPA[I]) / 3 = AmountOfDots )Then
        Begin
          Result := True;
          MiddleTPAEx(aTPA[I], X, Y);
          Break;
        End;
    End;

    Function FindBankers(Var X, Y: Integer): Boolean;
    Var
      DTM: Integer;
      A: Extended;
    Begin
      DTM := DTMFromString('78DA63CC636260886140017FFE30318800694' +
           '620FE0F048C85F8D580006329116A2A09AB0100102C0F82');
      Result := FindDTMRotated(DTM, X, Y, MMX1, MMY1, MMX2, MMY2, -Pi, Pi, 0.1, A);
      FreeDTM( DTM );
    End;

    Procedure WalkToBank;
    Var
      W, X, Y, Rx, Ry: Integer;
    Begin
      If(Not LoggedIn)Then Exit;
      If(UnderGround)Then Exit;

      If(LadderColor = 0)Then
        LadderColor := FindLadderColorex;
      X := MMCX;
      Y := MMCY - 30;
      Rx := MMCx + 30;
      Ry := MMCY;
      If(FindColorSpiral(X, Y, LadderColor, MMX1, MMY1, MMX2, MMY2))And
        (FindColorSpiral(Rx, Ry, LadderColor, MMX1, MMY1, MMX2, MMY2))Then
        Begin
          MFNF(Rx - 5, Y - 10 + Random(5), -2, 2);
          Run;
          FFlag(15);
        End;
      X := MMCX + 25;
      Y := MMY1 + 20;
      If(FindColorSpiral(X, Y, LadderColor, MMX1, MMY1, MMCX + 20, MMCY - 20))Then
        MFNF(X + 20, Y, 1, 3)
      Else
        MFNF(MMCX - Random(10) + Random(20), MMY1 + 20 - Random(10) + Random(10), 0, 3);
      FFlag(15);
      FTWait(2);
      Repeat
        Inc(W);
        If(FindYellowDots(X, Y, 6, 1))Then
          MFNF(X, Y - 5, 0, -1)
        Else
        If(FindBankers(X, Y))Then
          MFNF(X, Y - 5, 0, -1);
        FFlag(0);
        If(FindYellowDots(X, Y, 6, 1))Then
          If(Distance(X, Y, MMCX, MMCY) < 20)Then
            Break;
        FTWait(2);
      Until(Not LoggedIn)Or(W > 5);
    End;

    Procedure LevelForPick(Pick: String; Var Attack, Mining: Integer);
    Begin
      Case LowerCase(Pick) Of
        'bronze', 'iron':
        Begin
           Attack := 1;
           Mining := 1;
        End;
        'steel':
        Begin
           Attack := 5;
           Mining := 6;
        End;
        'mith','mithril':
        Begin
           Attack := 20;
           Mining := 21;
        End;
        'addy','adamant','adamantite':
        Begin
           Attack := 30;
           Mining := 31;
        End;
        'rune', 'runite':
        Begin
           Attack := 40;
           Mining := 41;
        End;
        Else Writeln('ERROR!!! No Such Pick As '+Pick+' > Procedure LevelForPick(Pick: String; Var Attack, Mining: Integer); <');
      End;
    End;

    Procedure EquipIfPossible;
    Var
      I, bmp_PickAxe, X, Y, bmp_Pick, Attack, Mining, {CTS,} Att, myMin: Integer;
      Pickaxe: String;
      B: Boolean;
    Begin
     Try
      If(GetCurrentTab <> 5)Then
      Begin
        GameTab(5);
        Wait(500);
      End;
      bmp_PickAxe := BitmapFromString(30, 14, 'z78DA3330A03E70C3010C' +
           '0625C0EF36FAB8DC8D2C407F37D32E36A96B267D521DB56C19A8D' +
           'C41B9FBDDA80406732C0F8F544A7C0C0E6CBA25AF641BD8B211BF' +
           'AB28C94DB47039ADC307D3FDB42B2107674D34185A1400863DFCA' +
           '8');
      B := FindBitmapMaskTolerance(bmp_PickAxe, X, Y, MIX1, MIY1, MIX2, MIY2, 10, 10);
      FreeBitmap(bmp_PickAxe);
      If(B)Then
      Begin
        Writeln('Pick is equipped');
        EquipPick := True;
        NoPick := False;
        Exit;
      End;

      If(Players[CurrentPlayer].Level[1] = 0)Then
        Players[CurrentPlayer].Level[1] := GetSkillInfo('attack', True);

      If(Players[CurrentPlayer].Level[15] = 0)Then
        Players[CurrentPlayer].Level[15]:= GetSkillInfo('mining', True);

      Att := Players[CurrentPlayer].Level[1];
      myMin := Players[CurrentPlayer].Level[15];

      If(GetCurrentTab <> 4)Then
      Begin
        GameTab(4);
        Wait(500);
      End;

      //CTS := GetColorToleranceSpeed;
      //ColorToleranceSpeed(2);
      For I:= 66 DownTo 61 Do
      Begin
        bmp_Pick := srl_GetBitmap(I);
        If(FindBitmapTolerancein(bmp_Pick, X, Y, MIX1, MIY1, MIX2, MIY2, 20))Then
          Break;
      End;
      FreeBitmap(bmp_Pick);
      srl_FreeBitmaps;
      Case I Of
       66: Pickaxe := 'rune';
       65: Pickaxe := 'addy';
       64: Pickaxe := 'mith';
       63: Pickaxe := 'steel';
       62: Pickaxe := 'iron';
       61: Pickaxe := 'bronze';
       Else
       Begin
         NoPick := True;
         Writeln('No Pick!');
         Exit;
       End;
      End;
      //ColorToleranceSpeed(CTS);
      LevelForPick( PickAxe, Attack, Mining);

      If( Att >= Attack)And(myMin >= Mining)Then
      Begin
        Writeln('Equipping ' + PickAxe+ ' pickaxe');
        Mouse(X, Y, 8, 8, True);
        FTWait(2);
        NoPick := False;
        EquipPick := True;
      End Else
      Begin
        NoPick := False;
        EquipPick := False;
        Writeln('Cant equip ' + PickAxe+ ' pickaxe');
      End;
     Except End;
    End;

    Function CountItemColorTol(Color, Tol: Integer): Integer;
    Var
      Dx, Dy, I: Integer;
      ItemTp: TPoint;
    Begin
      GameTab(4);
      For I:= 1 To 28 Do
      Begin
        ItemTP:= ItemCoords(I);
        If(FindColorTolerance(Dx,Dy,Color,ItemTP.X-10,ItemTP.Y-10,ItemTP.X+10,ItemTP.Y+10, Tol))Then
          Inc(Result);
      End;
    End;

    Procedure BankInfo;
    Var
      tEss: Integer;
    Begin
      tEss := CountItemColorTol(5658461, 5); //CountEss;

      Writeln('Mined = ' + IntToStr(tEss)+' Rune ess');

      Ess := Ess + tEss;
      Inc(Banks);

      Players[CurrentPlayer].Integers[0] := Players[CurrentPlayer].Integers[0] + tEss;
      Inc(Players[CurrentPlayer].Banked);

      Disguise('Mined: '+IntToStr(Ess)+' ['+IntToStr(Players[CurrentPlayer].Banked Mod Loads)+'/'+IntToStr(Loads)+']');

      ProgressReportCanvas(27, 27);
     
      ReportVars[0] := ReportVars[0] + tEss;
      ReportVars[1] := ReportVars[0] * 5;
      ReportVars[2] := ReportVars[2] + tAbyss;
      tAbyss := 0;
     
      //SRLNetReport;;
    End;

    Function OpenVEBBank: Boolean;
    Var
      T, C, CTS, I, X, Y: Integer;
      TPA: TPointArray;
      aTPA: T2DPointArray;
    Begin
     
      CTS := GetColorToleranceSpeed;

      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.05, 1.36);
      FindColorsSpiralTolerance(MSCX, MSCY + 20, TPA, 2315621, MSX1, MSY1, MSX2, MSY2, 9);
      SetColorspeed2Modifiers(0.2, 0.2);
      ColorToleranceSpeed(CTS);
     
      aTPA := TPAtoATPAEx(TPA, 30, 30);
      T := GetSystemTime;
      For I:= 0 To High(aTPA) Do
      Begin
        If(GetSystemTime - T > 2500)Then Break;
        if (not LoggedIn) or BankScreen or PinScreen then
          Break;
        MiddleTPAEx(aTPA[I], X, Y);
        MMouse(X, Y, 3, 3);
        Wait(75 + Random(75));
        if IsUpText('ooth') Then
        begin
          GetMousePos(x, y);
          Mouse(x, y, 0, 0, False);
          Wait(70 + Random(75));
          if ChooseOption('uickly') then
          begin
            FFLag(0);
            MarkTime(c);
            repeat
              Wait(100);
            until (BankScreen) or (PinScreen) or (TimeFromMark(c) > 3000);
          end;
        end;
      end;
      If(PinScreen)Then
        if (Length(Players) > 0) then
          if (Players[CurrentPlayer].Pin <> '') then
            InPin(Players[CurrentPlayer].Pin);
      Result := (BankScreen) or (PinScreen);
    End;

    Procedure Bank;
    Var
      Att, Mining, bmp_Pick, I, {CTS,} W, X, Y: Integer;
      PickAxe: String;
      B: Boolean;
    Begin
      If(Not LoggedIn)Then Exit;
      FindNormalRandoms;
      If(UnderGround)Then Exit;
      FindNormalRandoms;

      If(NoPick)Then
      Begin
        If(Players[CurrentPlayer].Level[1] = 0)Then
          Players[CurrentPlayer].Level[1] := GetSkillInfo('attack', True);

        If(Players[CurrentPlayer].Level[15] = 0)Then
          Players[CurrentPlayer].Level[15]:= GetSkillInfo('mining', True);
      End;
     
      If(FlagPresent)Then
      Begin
        Flag;
        Wait(1500+Random(1000));
      End;

      I := InvCount;

      If(Not NoPick)Then
        If(EquipPick)Then
        Begin
          If(I = 0)Then
            Exit;
        End Else
          If(I = 1)Then
            Exit;
      Writeln('Banking');
     
      I := 0;
      BankInfo;
     
      Repeat
        OpenVEBBank
        Wait(100);
        Inc( W );
      Until(BankScreen) Or ( W >= 10 ) Or (PinScreen);

      If(PinScreen)Then
        if (Length(Players) > 0) then
          if (Players[CurrentPlayer].Pin <> '') then
            InPin(Players[CurrentPlayer].Pin);

      If(BankScreen)Then
      Begin

        If(NoPick)Then
        Begin
          Deposit(1, 28, True);
          FixBank;
            //This piece of code will get a new pickaxe...
          //CTS := GetColorToleranceSpeed;
          //ColorToleranceSpeed(2);
          For I:= 66 DownTo 61 Do
          Begin
            Case I Of
              66: Pickaxe := 'rune';
              65: Pickaxe := 'addy';
              64: Pickaxe := 'mith';
              63: Pickaxe := 'steel';
              62: Pickaxe := 'iron';
              61: Pickaxe := 'bronze';
              Else Writeln('No Pick!');
            End;
            LevelForPick( PickAxe, Att, Mining );
            If(Players[CurrentPlayer].Level[15] >= Mining)Then
            Begin
              Try
               bmp_Pick := srl_GetBitmap(I);
               B := FindBitmapTolerancein(bmp_Pick, X, Y, MSX1, MSY1, MSX2, MSY2, 20);
               FreeBitmap(bmp_Pick);
              Except End;
            End;
            If(B)Then
              Break;
          End;

          Case I Of
            66: Pickaxe := 'rune';
            65: Pickaxe := 'addy';
            64: Pickaxe := 'mith';
            63: Pickaxe := 'steel';
            62: Pickaxe := 'iron';
            61: Pickaxe := 'bronze';
          End;

          If(PickAxe = '')Then
          Begin
            Writeln('No More pickaxes!');
            CloseBank;
            NoPick := True;
            Logout;
            Exit;
          End Else
          Begin
            Writeln('Taking out ' + PickAxe + ' Pickaxe');
            Mouse(X, Y, 8, 8, True);
            NoPick := False;
            Wait(300+Random(200));
          End;
          CloseBank;
          Wait(300+Random(400));
          EquipIfPossible;
          FindPickHeadColor;
          Exit;
        End;

        If(EquipPick)Then
          Deposit(1, 28, True)
        Else Deposit(2, 28, True);

        If(Players[CurrentPlayer].Banked Mod Loads = 0)Then
          CloseBank;
      End;
      FindNormalRandoms;
    End;

    Procedure InitPlayer;
    Var
      I: Integer;
    Begin

      MakeCompass('n');
      SetAngle(True);
     
      SolveAbyss;
      FindRandoms(False);
      Retaliate(False);

      EquipIfPossible;
      FindPickHeadColor;
      If(NoPick)Then
        Bank;
      If(NoPick)Then
        Exit;
       
      If(EquipPick)Then
        I := 0
      Else I := 1;
     
      If(InvCount > I)Then
        Bank;
       
      //Might want to change this dunno...
      SetChat('On',1);
      SetChat('Off',2);
      SetChat('Off',3);
      SetChat('Off',4);
      SetChat('Off', 5);

      SetRun(True);
    End;

    Procedure Updater;
    Var
      Version: String;
      aFile: Integer;
      S: String;
    Begin
     Try
      S := GetPage('http://www.freewebs.com/jk2fakefiles/EssMiner/EssMiner.txt');
      Version := Between('sion ', ' Link1', S);
      If(StrToFloat(Version) = StrToFloat(V))Then
      Begin
        Writeln('Latest version');
        Exit;
      End Else
      If(StrToFloat(Version) > StrToFloat(V))Then
      Begin
        S := GetPage('http://www.freewebs.com/jk2fakefiles/EssMiner/EssMiner.scar');
        aFile := RewriteFile(ScriptPath + 'EssMiner.Scar', False);
        if (aFile < 0) then
        Begin
          Writeln('');
          Writeln('Error while updating...');
          Writeln('Download manually from');
          Writeln('http://www.freewebs.com/jk2fakefiles/EssMiner/EssMiner.scar');
          Writeln('');
          Repeat
            Wait(1000);
          Until false
        End;
        Writeln('');
        Writeln('Updated to latest version!');
        WriteFileString(aFile, S);
        Writeln('Saved to '+ScriptPath + 'EssMiner.Scar');
        S := GetPage('http://www.freewebs.com/jk2fakefiles/EssMiner/change.txt');
        Writeln(Trim(Between('v'+Version, 'v'+V, S)));
        Writeln('');
        Writeln('Terminate the script and scar will ask u to load the new version');
        Writeln('');
        Repeat
          Wait(1000);
        Until false
      End Else
        Writeln('Thank you for beta testing');
     Except
       Writeln('Error in update.');
     End;
    End;

    Procedure DeleteCache;
    Var
      I, II, T, aFile: Integer;
      FilePath: String;
      FileNames: TStringArray;
    Begin
     Try
      T := GetSystemTime;
      FilePath := 'C:\RSCache\';
      FileNames := ['jagex_runescape_preferences.dat', 'random.dat', 'main_file_cache.dat0',
      'main_file_cache.dat2', 'main_file_cache.idx'];
      For I:= 0 To High(FileNames) Do
      Begin
        If(I = 1)Then //Changes directory when I = 1
          FilePath := FilePath + '.jagex_cache_32\';
        If(I = 2)Then //Changes directory when I = 2
          FilePath := FilePath + 'RuneScape\';
        If(I = 4)Then
        Begin //Deletes Main_File_Cache.idx 0..26 and 255
          For II:= 0 To 26 Do
          Begin
            aFile := RewriteFile(FilePath + FileNames[I] + IntToStr(II), False);
            WriteFileString(aFile, '');
            CloseFile(aFile);
          End;
          aFile := RewriteFile(FilePath + FileNames[I] + IntToStr(255), False);
          WriteFileString(aFile, '');
          CloseFile(aFile);
          Continue;
        End;
        aFile := RewriteFile(FilePath + FileNames[I], False);
        WriteFileString(aFile, '');
        CloseFile(aFile);
      End;
     Except
       WriteIt('Error - '+IntToStr(I));
       WriteIt('Error - '+IntToStr(II));
     Finally
       Writeln('Deleted Cache in ' +IntToStr(GetSystemTime - T)+' Msec');
     End;
    End;

    Procedure SetupScript;
    Var
      C, I: Integer;
    Begin
      //DeleteCache;
      V := '1.6';
      Updater;
      If(UseSMART)Then
        SetupSMART;
      SetupSRL;
      SetupMining;
      ScriptID := '959';
      ReportVars[3] := 1;
      DeclarePlayers;
      Disguise('Mined: '+IntToStr(Ess)+' ['+IntToStr(Players[CurrentPlayer].Banked Mod Loads)+'/'+IntToStr(Loads)+']');
      For C := 0 To HowManyPlayers - 1 Do
        For I := 0 To 99 Do
          Players[C].Integers[I] := 0;
      ActivateClient;
      Wait(300);
      LoginPlayer;
      SetAudio(0, 0, 0, Mono);
      InitPlayer;
    End;

    Function ActivePlayers: Integer;
    Var
      i: Integer;
    Begin
      For I := 0 To HowManyPlayers -1 Do
        If(Players[I].Active)Then
          Result := Result + 1;
    End;

    Procedure ProgressReport;
    Var
      I, Sec: Integer;
    Begin
      Sec := GetTimeRunning div 1000+1;

      Writeln('<------------------------------------------------------------------------------>');
      Writeln('                               JuKKa''s Essminer                                ');
      Writeln('<------------------------------------------------------------------------------>');
      Writeln('  Worked : ' + TimeRunning );
      Writeln('  Mined  : ' + IntToStr( Ess )+ ' Ess');
      Writeln('  Gained : ' + IntToStr( Ess * 5 )+ ' Exp');
      Writeln('  Banked : ' + IntToStr( Banks )+ ' Loads');
      Writeln('  Solved : ' + IntToStr( Abyss )+' Abyss Randoms');
      Writeln('<------------------------------------------------------------------------------>');
      Writeln('  Ess per hour : ' + IntToStr(Round(3600*Ess/Sec)));
      Writeln('  Exp per hour : ' + IntToStr(Round(3600*(Ess * 5)/Sec)));
      Writeln('  Banks per hour : ' + IntToStr(Round(3600*Banks/Sec)));
      Writeln('<------------------------------------------------------------------------------>');
      Writeln('  #      -      Status      -      Mined      -      Gained      -      Banks');
      For I:= 0 To HowManyPlayers - 1 Do
        Writeln(Padr('  '+IntToStr(I), 13)+
                     '   '+Padr(BoolToStr(Players[I].Active), 18) +
                     ' ' + Padr(IntToStr(Players[I].Integers[0]), 17) +
                     ' ' + Padr(IntToStr(Players[I].Integers[0] * 5), 18) +
                     ' ' + IntToStr(Players[I].Banked));
      Writeln('<------------------------------------------------------------------------------>');
      SRLNetReport;
    End;

    procedure ScriptTerminate;
    Begin
      If(UseSmart)Then
      Begin
        //SmartSetDebug(True);
        //ProgressReportCanvas(27, 27);
      End;
      Disguise('Script finished!');            //Possible name change\\
      SRLNetReport; //Returns a boolean =)
      //Could make it a loop until it successfully send srl stats
      //But would be rather bitchy :)
      ProgressReport;
      Writeln('Thank you for using Jukka''s Essminer! Please post proggies!');
    End;

    Function FindEssenceMMDist: Integer;
    Var
      CTS, X, Y: Integer;
      TPA: TPointArray;
      aTPA: T2DPointArray;
    Begin
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      FindColorsSpiralTolerance(MMCX, MMCY, TPA, 8092805, MMX1, MMY1, MMX2, MMY2, 12);
      ColorToleranceSpeed(CTS);
      aTPA := TPAtoATPAEx(TPA, 50, 50);
      SortATPASize(aTPA, True);
      Try
       MiddleTPAEx(aTPA[0], X, Y);
       WriteIt('Ess Dist: '+ IntToStr( Distance(MMCX, MMCY, X, Y) ));
       Result := Distance(MMCX, MMCY, X, Y);
      Except
       Result := 100000000000000000000;
      End;       //Lol... i couldnt come up with a better idea...
    End;

    Function ClickEssence: Boolean;

    Var
      CTS, I, X, Y: Integer;
      TPA: TPointArray;
      aTPA: T2DPointArray;
    Begin
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      FindColorsSpiralTolerance(MMCX, MMCY, TPA, 8092805, MMX1, MMY1, MMX2, MMY2, 12);
      ColorToleranceSpeed(CTS);
      aTPA := TPAtoATPAEx(TPA, 50, 50);
      SortATPASize(aTPA, True);
      For I:= 0 To High(aTPA) Do
      Begin
        MiddleTPAEx(aTPA[I], X, Y);
        MFNF(X, Y, 3, 3);
        Result := FlagPresent;
        FFlag(15);
        Break;
      End;
    End;

    Function GetCentreDirection: Boolean;
    Var
      T, L, CTS, I, X, Y: Integer;
      Ar: TIntegerArray;
      TPA: TPointArray;
      aTPA: T2DPointArray;
      B: TBox;
    Begin //MMX1, MMY1, MMX2, MMY2
      //If(FindEssenceMMDist < 100)Then Exit;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);
      FindColorsSpiralTolerance(MMCX, MMCY, TPA, 16777215, MMX1, MMY1, MMX2, MMY2, 300);
      ColorToleranceSpeed(CTS);
      {For I:= High(TPA) DownTo 0 Do
      Begin
        If(InCircle(TPA[I].X, TPA[I].Y, MMCX, MMCY, 45))Then Continue;
        If(Not InCircle(TPA[I].X, TPA[I].Y, MMCX, MMCY, 55))Then Continue;
        SetArrayLength(tTPA, GetArrayLength(tTPA) + 1);
        tTPA[ High(tTPA) ] := TPA[I];
      End;}

      FilterPointsPie(TPA, 0, 360, 45, 55, MMCX, MMCY);
      //DeBugMM(TPA);
      aTPA := TPAToaTPA(TPA, 35);
      //DeBugaTPA(aTPA, '');
      SortATPASize(aTPA, False);
      SetArrayLength(Ar, GetArrayLength(aTPA));
      For I:= 0 To High(aTPA)Do
      Begin
        B := GetTPABounds(aTPA[I]);
        Ar[I] := CountColor(65536, B.X1, B.Y1, B.X2, B.Y2);
        WriteIt(IntToStr(I)+' - '+IntToStr(AR[I]));
      End;
      T := GetSystemTime;
      Repeat
        If(GetSystemTime - T > 100)Then Exit;
        L := AMin(AR);
        For I:= 0 To High(Ar)Do
          If(Ar[I] = L)Then
            Break;
        If(L < 0)Then
        Begin
          Ar[I] := 1000;
          Continue;
        End Else Break;
      Until False
      MiddleTPAEx(aTPA[I], X, Y);
      WriteIt(IntToStr(I));
      MFNF(X, Y, 3, 3);
      Result := FlagPresent;
      FFlag(10);
    End;

    Function NavigateCenter: Boolean;

    Var
       Points, W: Integer;
    Begin
      Points := ScanMiniMap(0, 359, 70);
      WriteIt('Black Points = '+IntToStr(Points));
      Case Points Of
        0..50: WriteIt('Not Underground');
        51..269:
        Begin
          WriteIt('Middle');

          If(FindEssenceMMDist > 150)Then
            Repeat
              FTWait(2);
              Inc(W);
              GetCentreDirection;
            Until(FindEssenceMMDist < 150)Or(W > 3);

          W := 0;

          Repeat

            If(Not ClickEssence)Then
            Begin
              Inc(W);
              GetCentreDirection;
            End;

            If(W > 10)Then
            Begin

              If(Not Result)Then
              Begin
                Writeln('Lost at essence');
                Logout;
                Exit;
              End;
            End;

            Result := FindEssenceMMDist < 30;
          Until(Result);
        End;
        270..355:
        Begin
          Result := FindEssenceMMDist < 30;

          If(Not Result)Then
            If(Not ClickEssence)Then
            Begin
              Writeln('Fix at Navigatecenter...');
              TerminateScript;
            End;

          If(Result)Then
          Begin
            WriteIt('Ess Stone');
            Exit;
          End;
        End;
        360: Result := SolveAbyss;
      End;
    End;

    Function FindEssStone(Var X, Y: Integer): Boolean;
    Var
      T, CTS, I: Integer;
      TPA, TPA1, TPA2: TPointArray;
      aTPA: T2DPointArray;
    Begin
      T := GetSystemTime;

      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.16, 0.21);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA1, 8816530, MSX1, MSY1, MSX2, MSY2, 9);
      SetColorSpeed2Modifiers(0.11, 0.14);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA2, 8158345, MSX1, MSY1, MSX2, MSY2, 18);
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      TPA := CombineTPA(TPA1, TPA2);
      WriteIt('length: '+IntToStr(High(TPA)));
      //ClearDoubleTPA(TPA); //Clear Double TPA IS SLOW!!!
      //WriteIt('length: '+IntToStr(High(TPA)));
      aTPA := TPAtoATPAEx(TPA, 50, 50);
      SortATPASize(aTPA, True);

      WriteIt(intToStr(GetSystemTime-T));

      For I:= 0 To High(aTPA) Do
      Begin
        MiddleTPAEx(aTPA[I], X, Y);
        MMouse(X, Y, 0, 0);
        Wait(100+Random(100));
        If(IsUpTextMultiCustom(['ine', 'Rune', 'Ess']))Then
        Begin
          GetMousePos(X, Y);
          WriteIt('T Length: '+IntToStr(High(aTPA[I])));
          Result := True;
          Break;
        End Else WriteIt('F Length: '+IntToStr(High(aTPA[I])));
      End;
    End;

    Function HackEss(Var X, Y: Integer): Boolean;
    Begin
      Result := FindEssStone(X, Y);
    End;

    Procedure AntiBan;
    Begin
      Case Random(20) of
        0: If Random(15) = 5 Then MMouse(MSX1, MSY1, MSX2, MSY2);
        1: If Random(25) = 5 Then RandomRClick;
        2: If Random(10) = 5 Then HoverSkill('mining', False);
        3, 4, 5: Wait(100 + Random(1000));
        6: If Random(10) = 5 Then Begin GameTab(1 + Random(14)); Wait(500 + Random(500)); GameTab(4); End;
        17: If Random(15) = 5 Then HoverSkill('random', False);
      End;
    End;

    Procedure MineEss;
    Var
      I, W, tInv, X, Y, T: Integer;
    Begin
      If(Not LoggedIn)Then Exit;
      If(Not UnderGround)Then Exit;
      If(NavigateCenter)Then
      Begin
        FTWait(1);

        If(HackEss(X, Y))Then
        Begin
          Mouse(X, Y, 0, 0, True);
          FFlag(0);
          T := GetSystemTime;
        End;

        tInv := InvCount;
        I := GetSystemTime;
        While(InvCount < 28)And(LoggedIn)And(UnderGround)And(Not NoPick)Do
        Begin
          FTWait(1);
          If( InvCount > tInv)Then
          Begin
            tInv := InvCount;
            T := GetSystemTime;
          End;
          Status(IntToStr(tInv)+'/28');
          n_FindPick;
          FindRandoms(True);
          If(GetSystemTime - T > 5000)Then
            If(HackEss(X, Y))Then
            Begin
              If(InvCount = 28)Then Exit;
              Mouse(X, Y, 0, 0, True);
              FFlag(0);
              Wait(300+Random(300));
              n_FindPick;
              FindRandoms(True);
              T := GetSystemTime;
            End Else
            Begin
              ClickEssence;
              Inc(W);
            End;
          If(W > 4)Then Exit;
          FTWait(1);
          If(FindFight)Then
          Begin
            Writeln('Found Fight trying to run away to portal');
            Exit;
          End Else AntiBan;
          FTWait(1);
          If(GetSystemTime - I > 7000+Random(7000))Then
          Begin
            GameTab(1 + Random(14));
            I := GetSystemTime;
          End;
        End;

      End;
    End;

    Begin
      SetupScript;
      Repeat
        Repeat
          WalkToAubury;
          TeleAubury;
          MineEss;
          ExitMine;
          WalkToBank;
          Bank;
        Until(Not LoggedIn)Or(NoPick)Or(Players[CurrentPlayer].Banked Mod Loads = 0);

        If(LoggedIn)And(Not NoPick)Then
        Begin
          //True
          Status('True');
          ProgressReport;
          If(ActivePlayers > 1)Then
          Begin //If one player and only one active it wont logout and login back in...
            NextPlayer(True);
            InitPlayer;
          End;
        End Else
        Begin
          //False
          Status('False');
          Players[CurrentPlayer].Active := False;
          Logout;
          If(ActivePlayers > 0)Then
          Begin //If no players active it will skip this and jump to the end of the loop.
            ProgressReport; //where it will then quit and call: "ScriptTerminate;"
            NextPlayer(False);
            InitPlayer;
          End;
        End;

      Until(Not LoggedIn)And(ActivePlayers = 0);
    End.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pain Olympics?
    By ctown in forum Music, Movies and TV
    Replies: 33
    Last Post: 06-17-2009, 09:45 PM
  2. need major help plz!!!
    By king tut in forum OSR Help
    Replies: 9
    Last Post: 09-09-2007, 04:39 AM
  3. The Pain is Over
    By timtag1190 in forum Blogs and Writing
    Replies: 11
    Last Post: 08-07-2007, 11:58 AM
  4. ~BaDaa's Pain In The Arse Flooder~
    By badaa in forum First Scripts
    Replies: 11
    Last Post: 07-13-2007, 10:23 PM
  5. Cut The Pain
    By timtag1190 in forum Blogs and Writing
    Replies: 0
    Last Post: 12-29-2006, 05:23 AM

Posting Permissions

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