Results 1 to 11 of 11

Thread: Drill Demon Changes

  1. #1
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Drill Demon Changes

    Changes:

    Horn colours changed, breaking the demon finding function. It's fixed in this release.
    Made a new function called Demon_InRandom.
    Changed "TypeID" from 2 to 1 in AntiRandoms.scar.
    Made the solver try to identify the signs for 5x longer (incase someone's infront of the sign and the solver doesn't notice).
    Made the solver wait while something was blocking the view of the sign.

    SCAR Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               » Drill Demon Solver Routines                 --//
    //-----------------------------------------------------------------//
    // * function Demon_InRandom: Boolean;                          // * by TRiLeZ
    // * function NoSignObstruction: Boolean;                          // * by Sumilion, ZephyrsFury & TRiLeZ
    // * function DemonCenter: Boolean;                                // * by TRiLeZ
    // * procedure IdentifySigns(var JogIndex, StarIndex, SitIndex, PushIndex: Integer);     // * by Sumilion & TRiLeZ
    // * function demon_GetTask: string;                               // * by TRiLeZ & Nielsie95
    // * function PerformTask(TaskIndex: Integer): Boolean;            // * by Sumilion
    // * function GetSigns(var JogIndex, StarIndex, SitIndex, PushIndex: Integer): Boolean;  // * by Sumilion , ZephyrsFury & TRiLez
    // * function SolveDemon: Boolean;                                 // * by Sumilion
    //-----------------------------------------------------------------//

    {*******************************************************************************
    function Demon_InRandom: Boolean;
    by: TRiLeZ
    Description: Checks if you're in the demon random.
    Date: December 15, 2009
    *******************************************************************************}

    function Demon_InRandom: Boolean;
    var
      TempCTS: Integer;
    begin
      TempCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);
      if (CountDots('npc') = 1) then
        if (TabExists(tab_Magic) = false) then
          if (CountColorTolerance(15986930, MMX1, MMY1, MMX2, MMY2, 13) >= 750) then //white fences
            if (not (GetColor(504, 348) = 657930)) then //Arrow in chat box
            Result := True;
      ColorToleranceSpeed(TempCTS);
    end;

    {*******************************************************************************
    function NoSignObstruction: Boolean;
    by: Sumilion & ZephyrsFury, little modifiction by TRiLeZ
    Description: Checks if the signs are fully visible.
    *******************************************************************************}

    function NoSignObstruction: Boolean;
    var
      arP: TPointArray;
      ararP: T2DPointArray;
      arC: TIntegerArray;
      b: TBox;
      i, j, x, y: Integer;
    begin
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.12, 0.16);
      try
        FindColorsSpiralTolerance(MSX1, MSCY, arP, 6257516, MSX1, MSY1, MSX2, MSY2, 10);
        if (Length(arP) = 0) then Exit;

        ararP := SplitTPA(arP, 10);

        if (Length(ararP) <> 4) then Exit;

        for i := 0 to High(ararP) do
        begin
          SetLength(arP, 0);

          b := GetTPABounds(ararP[i]);
          for x := b.x1 - 1 to b.x2 + 1 do
          begin
            SetLength(arP, Length(arP) + 2);
            arP[High(arP) - 1] := Point(x, b.y1 - 1);
            arP[High(arP)] := Point(x, b.y2 + 1);
          end;
          for y := b.y1 - 1 to b.y2 + 1 do
          begin
            SetLength(arP, Length(arP) + 2);
            arP[High(arP) - 1] := Point(b.x1 - 1, y);
            arP[High(arP)] := Point(b.x2 + 1, y);
          end;

          arC := GetColors(arP);

          for j := 0 to High(arC) do
          begin
            SetColorspeed2Modifiers(0.1, 0.58);  // filling
            Result := SimilarColors(3695936, arC[j], 4);
            if not Result then
            begin
              SetColorSpeed2Modifiers(0.06, 0.15); // rims
              Result := SimilarColors(2971495, arC[j], 11);
              if (not(Result)) then Exit;
            end;
          end;

        end;

      finally
        ColorToleranceSpeed(1);
        SetColorspeed2Modifiers(0.2, 0.2);
      end;
    end;

    {*******************************************************************************
    function DemonCenter: Boolean;
    by: TRiLeZ
    Description: Walks to the center of the random.
    *******************************************************************************}


    function DemonCenter: Boolean;
    var
      cts, H, F: Integer;
      arP: TPointarray;
      P: TPoint;
      SarP: T2DPointArray;
    begin
      cts := GetColorToleranceSpeed;
      Mouse(543, 24, 12, 12, true);
      Wait(150 + Random(200));
      SetAngle(True);
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.77, 2.5);
      if not FindColorsTolerance(arP, 3433847, MSX1, MSY1, MSX2, MSY2, 4) then
      begin
        Writeln('DemonCenter - Could not find the board colors.');
        Exit;
      end;

      H := High(arP);
      SarP := TPAtoATPA(arP, 50);
      F := High(SarP);

      if ((arP[0].x < MSCX) and (arP[H].x < MSCX)) or ((arP[0].x > MSCX) and
      (arP[H].x > MSCX)) then
      begin
        if (arP[0].x < MSCX) and (arP[H].x < MSCX) then
        begin
          Writeln('DemonCenter - We are at the edge of the random area, fixing position.');
          Mouse(MiddleTPA(SarP[Round(F/2)]).x, MiddleTPA(SarP[Round(F/2)]).y + 60, 10, 10, False);
          WaitOption('Walk', 400);
          Wait(2000);
          FFlag(0);
          Wait(2000 + Random(250));
        end else
        if (arP[0].x > MSCX) and (arP[H].x > MSCX) then
        begin
          Writeln('DemonCenter - We are at the edge of the random area, fixing position.');
          Mouse(MiddleTPA(SarP[F]).x, MiddleTPA(SarP[F]).y + 60, 10, 10, False);
          WaitOption('Walk', 400);
          Wait(2000);
          FFlag(0);
          Wait(2000 + Random(250));
        end;
        if not FindColorsTolerance(arP, 3433847, MSX1, MSY1, MSX2, MSY2, 4) then
        begin
          Writeln('DemonCenter - Could not find the board colors.');
          Exit;
        end;
      end;

      Result := Length(arP) > 0;
      P := MiddleTPA(arP);
      if (IsUpText('Walk')) then
        Mouse(P.X, P.Y + 50, 0, 0, True)
      else
      begin
        Mouse(P.X, P.Y + 50, 0, 0, False);
        ChooseOption('Walk');
      end;
      Wait(2000);
      FFlag(0);
      Wait(2000 + Random(250));
      ColorToleranceSpeed(cts);
    end;

    {*******************************************************************************
    procedure IdentifySigns(var JogIndex, StarIndex, SitIndex, PushIndex: Integer);
    by: Sumilion, little modification by TRiLeZ
    Description: Gets the actions on the signs.
    *******************************************************************************}


    procedure IdentifySigns(var JogIndex, StarIndex, SitIndex, PushIndex: Integer);
    var
      i, MinLength, MaxWidth: Integer;
      arP: TPointArray;
      ararP: T2DPointArray;
      arColors: TIntegerArray;
      b: TBox;
    begin
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.12, 0.16);
      FindColorsSpiralTolerance(MSX1, MSCY, arP, 6257516, MSX1, MSY1, MSX2, MSY2, 10);

      ararP := TPAtoATPA(arP, 45);
      if (Length(ararP) <> 4) then
        Exit;

      MinLength := 999;
      for i := 0 to High(ararP) do
      begin
        if (Length(ararP[i]) < Minlength) then
        begin
          MinLength := Length(ararP[i]);
          JogIndex := i + 1;
        end;
      end;

      for i := 0 to High(ararP) do
      begin
        if (i = JogIndex - 1) then Continue;

        b := GetTPABounds(ararP[i]);

        if ((b.x2 - b.x1) > MaxWidth) then
        begin
          MaxWidth := b.x2 - b.x1;
          PushIndex := i + 1;
        end;
      end;

      for i := 0 to High(ararP) do
      begin
        if (i = JogIndex - 1) then Continue;
        if (i = PushIndex - 1) then Continue;

        arColors := GetColors(ararP[i]);
        ClearSameIntegers(arColors);

        if (Length(arColors) = 2) then
          StarIndex := i + 1;
        if (Length(arColors) = 1) then
          SitIndex := i + 1;
      end;
    end;

    {*******************************************************************************
    function demon_GetTask: string;
    by: TRiLeZ & Nielsie95
    Description: Reads from Damien what we should do.
    *******************************************************************************}


    function demon_GetTask: string;
    var
      dx, dy, t, cts, q: Integer;
      Tasks: TStringArray;
      DRed, DBlack, TPA: TPointArray;
      Demon: T2DPointArray;
    begin
      if not FindNPCChatText('Sergeant Damien', Nothing) then
      begin
        Writeln('We should talk to Damien.');
        MarkTime(t);
        cts := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        repeat
          SetColorspeed2Modifiers(0.1, 1.35);
          FindColorsTolerance(DRed, 988783, MSX1, MSY1, MSX2, MSY2, 4);
          SetColorspeed2Modifiers(0, 3.71);
          FindColorsTolerance(DBlack, 855309, MSX1, MSY1, MSX2, MSY2, 3);
          if (Length(DRed) > 0) and (Length(DBlack) > 0) then
          begin
            TPA := CombineTPA(DRed, DBlack);
            Demon := SplitTPAEx(TPA, 20, 20);
            SortATPAFrom(Demon, Point(MSCX, MSCY));
            for q := 0 to High(Demon) do
            begin
              MiddleTPAEx(Demon[q], dx, dy);
              MMouse(dx, dy, 2, 2);
              if WaitUpText('Talk', 150) then
              begin
                GetMousePos(dx, dy);
                Mouse(dx, dy, 0, 0, false);
                Break;
              end;
            end;
          end;
          Wait(150 + Random(50));
        until ChooseOption('to Se') or (TimeFromMark(t) > 30000);
        ColorToleranceSpeed(cts);

        if (TimeFromMark(t) > 30000) then
        begin
          Writeln('Can''t find Damien.');
          LogOut
          Exit;
        end;

        MarkTime(t);
        while not FindNPCChatText('Sergeant Damien', Nothing) and
        (TimeFromMark(t) < 30000) do
          Wait(500 + Random(100));

        if (TimeFromMark(t) > 30000) then
        begin
          Writeln('Failed to talk to Damien.');
          LogOut;
          Exit;
        end;
      end;

      T := GetSystemTime;
      while (not(FindNPCChatText('this mat', Nothing))) and
      (ClickContinue(True, True)) and (GetSystemTime - T < 30000) do
        Wait(100);

      Tasks := ['jog', 'star', 'sit', 'push'];
      for t := 0 to 3 do
        if FindNPCChatText(Tasks[t], Nothing) then
        begin
          Result := Capitalize(Tasks[t]);
          Break;
        end;

      if (Result = '') then
      begin
        Writeln('Can''t find what Damien wants us to do.');
        LogOut;
        Exit;
      end;

      ClickContinue(True, True);
      ClickContinue(True, False);
    end;

    {*******************************************************************************
    function PerformTask(TaskIndex: Integer): Boolean;
    by: Sumilion
    Description: Performs the correct workout.
    *******************************************************************************}


    function PerformTask(TaskIndex: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2, t: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.06, 0.15);

      if not(FindColorsTolerance(arP, 2971495, MSX1, MSY1, MSX2, MSY2, 11)) then
      begin
        Writeln('Failed to find the signs, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 6.61) and (X <= 19.45) and (Y >= 7.00) and (Y <= 20.47) and (Z >= 2.28) and (Z <= 6.43) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;

      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
      SetLength(arP, 0);

      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 100) then Continue;
        if (Length(ararP[i]) > 250) then Continue;
        SetLength(arP, Length(arP) + 1);
        arP[High(arP)] := MiddleTPA(ararP[i]);
      end;

      SortTPAFrom(arP, Point(MSX1, MSCY));

      if (Length(arP) <> 4) then
      begin
        Writeln('Wrong Array Length, failed to find the mat.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        LogOut;
        Exit;
      end;

      MMouse(arP[TaskIndex - 1].x, arP[TaskIndex - 1].y + 65, 5, 5);
      Wait(100 + Random(100));
      if (IsUpText('Exercise')) then
      begin;
        Result := True;
        GetMousePos(arP[TaskIndex - 1].x, arP[TaskIndex - 1].y);
        Mouse(arP[TaskIndex - 1].x, arP[TaskIndex - 1].y, 0, 0, True);
        Flag;
        MarkTime(t);
        while not FindNPCChatText('Sergeant Damien', Nothing) and
             (TimeFromMark(t) < 20000) do
          Wait(100 + Random(100));

        if (TimeFromMark(t) > 20000) then
        begin
          Writeln('Task Timeout');
          ColorToleranceSpeed(tmpCTS);
          SetColorSpeed2Modifiers(0.2, 0.2);
          LogOut;
          Exit;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    end;

    {*******************************************************************************
    function GetSigns(var JogIndex, StarIndex, SitIndex, PushIndex: Integer): Boolean;
    by: Sumilion & ZephyrsFury, little modification by TRiLeZ
    Description: Handles the getting of the signs.
    *******************************************************************************}


    function GetSigns(var JogIndex, StarIndex, SitIndex, PushIndex: Integer): Boolean;
    var
      C, I, T: Integer;
    begin
      c := 0;
      if not DemonCenter then
      begin
        Writeln('Failed to find the demon center.');
        LogOut;
        Exit;
      end;
      Mouse(543, 24, 12, 12, true);
      Wait(150 + Random(200));
      SetAngle(False);
      JogIndex := 0;
      StarIndex :=0;
      SitIndex := 0;
      PushIndex := 0;

      while ((JogIndex = 0) or (StarIndex = 0) or (SitIndex = 0) or (PushIndex = 0)) and (c < 250) and Demon_InRandom do
      begin
        JogIndex := 0; StarIndex := 0; SitIndex := 0; PushIndex := 0;
        try
          while (not NoSignObstruction) do
          begin
            Wait(20 + Random(10));
            if (TimeFromMark(t) >= 120000) then Break;
          end;
          IdentifySigns(JogIndex, StarIndex, SitIndex, PushIndex);
        except end;
        if ((JogIndex = 0) or (StarIndex = 0) or (SitIndex = 0) or (PushIndex = 0)) then
        begin
          Inc(c);
          if (c = 20) then
            MakeCompass('N');
          if (c >= 40) then Break;
          if (c mod 3 = 0) then
            if (c < 20) then
            begin
              KeyDown(vk_Right);
              Wait(60 + Random(25));
              KeyUp(vk_Right);
            end else
            begin
              KeyDown(vk_Left);
              Wait(60 + Random(25));
              KeyUp(vk_Left);
            end;
          Wait(150 + Random(150));
        end;
      end;
      Mouse(543, 24, 12, 12, true);
      Wait(150 + Random(200));
      SetAngle(True);
      Result := (JogIndex > 0) and (StarIndex > 0) and (SitIndex > 0) and (PushIndex > 0);

      for i := 0 to 3 do
      begin
        if (JogIndex - 1 = i) then
          Writeln(IntToStr(JogIndex) + ': Jog mat');
        if (StarIndex - 1 = i) then
          Writeln(IntToStr(StarIndex) + ': Star Jump mat');
        if (PushIndex - 1 = i) then
          Writeln(IntToStr(PushIndex) + ': Push-up mat');
        if (SitIndex - 1 = i) then
          Writeln(IntToStr(SitIndex) + ': Sit-up mat');
      end;
    end;

    {*******************************************************************************
    function SolveDemon: Boolean;
    by: Sumilion
    Description: Main solving procedure.
    *******************************************************************************}


    function SolveDemon: Boolean;
    var
      Task: string;
      JogIndex, StarIndex, SitIndex, PushIndex, t: Integer;
    begin
      TakeScreen('Found Demon');
      ClickContinue(True, True);
      SetAngle(true);
      MarkTime(t);
      MakeCompass('N');
      repeat;
        Task := demon_GetTask;
        Writeln(Task);

        if (not(GetSigns(JogIndex, StarIndex, SitIndex, PushIndex))) then
        begin
          WriteLn('Could not identify demon signs.');
          LogOut;
          Exit;
        end;

        case Task of
          'Jog': PerformTask(JogIndex);
          'Star': PerformTask(StarIndex);
          'Sit': PerformTask(SitIndex);
          'Push': PerformTask(PushIndex);
        end;

        Wait(100 + Random(200));

        if FindNPCChatText('Wrong exercise', Nothing) then
          Writeln('Wrong exercise.');

      until FindNPCChatText('actually', Nothing) or (TimeFromMark(t) > 10 * 60 * 1000);

      if (TimeFromMark(t) > 10 * 60 * 1000) then
      begin
        Writeln('We''ve been in the demon random for 10 minutes. It failed.');
        LogOut;
        Exit;
      end;

      Writeln('Demon random solved!');
      Result := True;
      ClickContinue(True, True);
      Wait(10000);
    end;

    SCAR Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               » AntiRandom Routines                         --//
    //-----------------------------------------------------------------//
    // * procedure SRLRandomsReport;                      // * by Starblaster100
    // * function FindBoxOption(var Box: TBox): Boolean;  // * by Nava2
    // * function UseRewardBox: Boolean;                  // * by Nava2
    // * function FindMod: Boolean;                       // * by Stupid3ooo
    // * function FindFight: Boolean;                     // * by Stupid3ooo
    // * function FindLamp(skill: String): Boolean;       // * by pups, Starblaster100 and PriSoner fixed by Lee Lok Hin
    // * function FindDead : boolean;                     // * by Stupid3ooo and Cazax
    // * function Rand_GetRandomType: Integer;            // * by ZephyrsFury
    // * procedure LoadTeleRandoms;                       // * by ZephyrsFury
    // * function SolveTeleportRandoms: Boolean;          // * by ZephyrsFury
    // * function FindNonInventoryRandoms: Boolean;       // * by The SRL Developers Team!... all time sexiness by Mutant
    // * function FindNormalRandoms: Boolean;             // * by The SRL Developers Team!... all time sexiness by Mutant
    //-----------------------------------------------------------------//

    type
      TTeleRandom = record
        Name: string;
        TypeID, RandIndex: Integer;
        TextColors,TextFonts: TIntegerArray;
        IsInRandom, SolveRandom: function: Boolean;
        Texts, Music: TStringArray;
        TextBoxes: TBoxArray;
      end;

    var
      TeleRandoms: array of TTeleRandom;
      SolveSRLRandoms, r_UseRandomTool: Boolean;
      RB_SkipArray: TIntegerArray;
      SoundPath: string;
      CurRandom: Integer;
     
    {*******************************************************************************
    procedure SRLRandomsReport;
    by: Starblaster100
    Description: Displays Randoms Report.
    *******************************************************************************}


    procedure SRLRandomsReport;
    var
      i, CurrentInt: Integer;
      CurrentStr, Name: string;
     
    Begin
      ChangeReportWidth(280);
      ClearReport;
      AddToReport('/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\');
      AddToReport('|     SRL ' + IntToStr(SRLVersionNumber) + ' Randoms Report    |');
      AddToReport('|       [url]www.villavu.com[/url]        |');
      AddToReport('|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|');
      For i := 0 to 44 do
      Begin
        Case i of
          0: begin CurrentInt := SRL_Logs;                     Name := '| SRL Logs          :'; end;
          1: begin CurrentInt := RandSolved[rand_Trade];       Name := '| Trades Made       :'; end;
          2: begin CurrentInt := RandFailed[rand_Trade];       Name := '| Trades Missed     :'; end;
          3: begin CurrentInt := RandSolved[rand_Fight];       Name := '| Fights            :'; end;
          4: begin CurrentInt := RandSolved[rand_Sandwich];    Name := '| Sandwiches Solved :'; end;
          5: begin CurrentInt := RandFailed[rand_Sandwich];    Name := '| Sandwiches Missed :'; end;
          6: begin CurrentInt := RandSolved[rand_Lamp];        Name := '| Lamps Solved      :'; end;
          7: begin CurrentInt := RandFailed[rand_Lamp];        Name := '| Lamps Missed      :'; end;
          8: begin CurrentInt := RandSolved[rand_Frog];        Name := '| Frog Solved       :'; end;
          9: begin CurrentInt := RandFailed[rand_Frog];        Name := '| Frog Missed       :'; end;
          10: begin CurrentInt := RandSolved[rand_Certer];     Name := '| Certers Solved    :'; end;
          11: begin CurrentInt := RandFailed[rand_Certer];     Name := '| Certers Missed    :'; end;
          12: begin CurrentInt := RandSolved[rand_Demon];      Name := '| Demons Solved     :'; end;
          13: begin CurrentInt := RandFailed[rand_Demon];      Name := '| Demons Missed     :'; end;
          14: begin CurrentInt := RandSolved[rand_Mod];        Name := '| Mods Found        :'; end;
          15: begin CurrentInt := RandSolved[rand_Maze];       Name := '| Mazes Solved      :'; end;
          16: begin CurrentInt := RandFailed[rand_Maze];       Name := '| Mazes Missed      :'; end;
          17: begin CurrentInt := RandSolved[rand_Mime];       Name := '| Mimes Solved      :'; end;
          18: begin CurrentInt := RandFailed[rand_Mime];       Name := '| Mimes Missed      :'; end;
          19: begin CurrentInt := RandSolved[rand_Death];      Name := '| Deaths            :'; end;
          20: begin CurrentInt := RandSolved[rand_Quiz];       Name := '| Quizes Solved     :'; end;
          21: begin CurrentInt := RandFailed[rand_Quiz];       Name := '| Quizes Missed     :'; end;
          22: begin CurrentInt := RandSolved[rand_ScapeRune];  Name := '| ScapeRunes Solved :'; end;
          23: begin CurrentInt := RandFailed[rand_ScapeRune];  Name := '| ScapeRunes Missed :'; end;
          24: begin CurrentInt := RandSolved[rand_BirdNest];   Name := '| Birds Nests       :'; end;
          25: begin CurrentInt := RandSolved[rand_Pinball];    Name := '| Pinballs Solved   :'; end;
          26: begin CurrentInt := RandFailed[rand_Pinball];    Name := '| Pinballs Missed   :'; end;
          27: begin CurrentInt := RandSolved[rand_PrisonPete]; Name := '| Petes Solved      :'; end;
          28: begin CurrentInt := RandFailed[rand_PrisonPete]; Name := '| Petes Missed      :'; end;
          29: begin CurrentInt := RandSolved[rand_Forester];   Name := '| Foresters Solved  :'; end;
          30: begin CurrentInt := RandFailed[rand_Forester];   Name := '| Foresters Missed  :'; end;
          31: begin CurrentInt := RandSolved[rand_Leo];        Name := '| Leo''s Solved      :'; end; //Another space due to the ''
          32: begin CurrentInt := RandFailed[rand_Leo];        Name := '| Leo''s Missed      :'; end;
          33: begin CurrentInt := RandSolved[rand_Molly];      Name := '| Molly''s Solved    :'; end;
          34: begin CurrentInt := RandFailed[rand_Molly];      Name := '| Molly''s Missed    :'; end;
          35: begin CurrentInt := RandSolved[rand_Pillory];    Name := '| Pillory''s Solved  :'; end;
          36: begin CurrentInt := RandFailed[rand_Pillory];    Name := '| Pillory''s Missed  :'; end;
          37: begin CurrentInt := RandSolved[rand_CapnArnav];  Name := '| Capn Arnav Solved :'; end;
          38: begin CurrentInt := RandFailed[rand_CapnArnav];  Name := '| Capn Arnav Missed :'; end;
          39: begin CurrentInt := RandSolved[rand_Beekeeper];  Name := '| Beekeepers Solved :'; end;
          40: begin CurrentInt := RandFailed[rand_Beekeeper];  Name := '| Beekeepers Missed :'; end;
          41: begin CurrentInt := RandSolved[rand_Abyss];      Name := '| Abysses Solved    :'; end;
          42: begin CurrentInt := RandFailed[rand_Abyss];      Name := '| Abysses Missed    :'; end;
          43: begin CurrentInt := RandSolved[rand_Mordaut];    Name := '| Mordauts Solved   :'; end;
          44: begin CurrentInt := RandFailed[rand_Mordaut];    Name := '| Mordauts Missed   :'; end;
        end;

        if (CurrentInt < 1) then
          Continue;
        CurrentStr := IntToStr(CurrentInt);
        AddToReport(PadR(Name, 30 - Length(CurrentStr)) + CurrentStr + ' |');
      end;
      AddToReport('\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/');
      SendSRLReport;
    end;

    {*******************************************************************************
    procedure FindBoxOption(var Box: TBox): Boolean;
    By: Nava2
    Description: Finds the text of options, based on the text loaded from the
    player array. Will find text in order of occurance in the array.
    *******************************************************************************}


    function FindBoxOption(var Box: TBox; var RewardInd: Integer): Boolean;
    var
      x, y, H, L, II, i, LL, Col: Integer;
      Text, TPA, xTPA: TPointArray;
      ATPA: T2DPointArray;
      Scroll: Boolean;
      P: TPoint;
     
    begin
      Result := False;
      RewardInd := -1;
      Box := IntToBox(-1, -1, -1, -1);
      if (not LoggedIn) then exit;
      L := High(Players[CurrentPlayer].BoxRewards);
      Scroll := (GetColor(385, 70) = 657930);
      for II := 0 to L + 1 do
      begin
        if (InIntArray(RB_SkipArray, II)) then Continue;
        if (II < L + 1) then
          Text := LoadTextTPA(Players[CurrentPlayer].BoxRewards[II], UpChars, H)
        else
          Text := LoadTextTPA('box', UpChars, H);
         
        FindColorsTolerance(TPA, 2070783, 35, 69, 362, 311, 3);
        ATPA := SplitTPAEx(TPA, 3, 1);
        LL := High(ATPA);
        for i := 0 to LL do
        begin
          Result := FindTextTPAInTPA(H, Text, ATPA[i], xTPA);
          if (Result) then Break;
        end;

        if (not Result) and (Scroll) then
        begin
          X := 377;
          Y := 312 - II mod 2 * 245;
          Col := 657930 + II mod 2 * 658704;
          P := Point(375, 302 - II mod 2 * 224);

          MMouse(X, Y, 0, 0);
          Wait(RandomRange(30, 60));

          HoldMouse(X, y, True);
          while (GetColor(P.X, P.Y) <> Col) and (GetColor(385, 70) = 657930) and (not(Result)) do
          begin
            if (not LoggedIn) then Break;
            FindColorsTolerance(TPA, 2070783, 35, 69, 362, 311, 3);
            Result := FindTextTPAInTPA(H, Text, TPA, xTPA);
            Wait(RandomRange(40, 50));
          end;
          ReleaseMouse(X, Y, True);
        end;

        if (Result) then
        begin
          if (II < L + 1) then
            WriteLn('Found Reward Item: ' + Players[CurrentPlayer].BoxRewards[II])
          else
            WriteLn('Found no prefered reward items, chose default reward: Mystery Box');
          Break;
        end;
      end;
      if (not Result) then exit;
      Box := GetTPABounds(xTPA);
      Rewardind := II;
      //Writeln('Box: ' + IntToStr(Box.x1) + ', ' + IntToStr(Box.y1) + ', ' + IntToStr(Box.x2) + ', ' + IntToStr(Box.y2));
    end;

    {*******************************************************************************
    procedure UseRewardBox: Boolean;
    by: Nava2
    Description: Finds the reward box, and opens it getting the reward.
    *******************************************************************************}


    function UseRewardBox: Boolean;
    var
      I, Time, Height, fx, fy, Index, bDTM: Integer;
      Text, TPA: TPointArray;
      B: TBox;
     
    begin
      Result := False;
      if (not LoggedIn) then exit;
      GameTab(tab_Inv);
      if (not(FindColorTolerance(fX, fY, 5510016, MIX1, MIY1, MIX2, MIY2, 20))) then Exit;
      bDTM := DTMFromString('78DA634C636660F8C8C8800CDA452219E4803' +
           '448F43F1030A600D53C435503918591403A0AA8E6150135C94035' +
           'BF09A82902AAF941841A427681DCFC00BF1A008DCA0E8C');
      for I := 1 to 28 do
      begin
        B := InvBox(I);
        if FindItemEx(fx, fy, 'dtm', bDTM, B, []) then
        begin
          InvMouse(I, 3);
          Wait(RandomRange(100, 150));
          Result := IsUpText('event gift');
          if (Result) then Break;
        end;
      end;
      FreeDTM(bDTM);
      if (not Result) then exit;

      GetMousePos(fx, fy);
      Mouse(fx, fy, 0, 0, True);

      Result := False;
      Text := LoadTextTPA('hoose', UpChars, Height);
      Time := GetTimeRunning + 10000;
      FindColorsTolerance(TPA, 2070783, 185, 34, 327, 50, 3);
      while (not Result and (GetTimeRunning < Time)) do
      begin
        Wait(RandomRange(80, 100));
        FindColorsTolerance(TPA, 2070783, 185, 34, 327, 50, 3);
        if (Length(TPA) > 10) then
          Result := FindTextTPAinTPA(Height, Text, TPA, TPA);
      end;

      if (not Result) then
      begin
        SRL_Warn('OpenRewardBox', 'Could not open Reward Screen', Warn_AllVersions);
        Exit;
      end;
      Wait(Random(100));
      if (not FindBoxOption(B, Index)) then
      begin
        SRL_Warn('UseRewardBox', 'Could not find a usable option.', Warn_AllVersions);
        Exit;
      end;

      Mouse(B.X1, B.Y1, 0, 0, True);
      Time := GetTimeRunning + 2000;
      Result := False;
      while (not Result) and (GetTimeRunning < Time) do
      begin
        FindColorsTolerance(TPA, 1317148, 35, 70, 362, 311, 3);
        Result := Length(TPA) > 50;
        Wait(50 + Random(50));
      end;
      if (not Result) then
      begin
        CloseWindow;
        Exit;
      end;
      MouseBox(413, 171, 469, 200, 1);
      Time := GetSystemTime;
      while (CountColorTolerance(1317148, B.x1 - 10, B.y1 - 10, B.x1 + 10, B.y1 + 10, 3) > 50) and (GetSystemTime - Time < 5000) do
      begin
        if (Pos('thing else', GetChatBoxText(8, clBlack)) > 0) then
        begin
          CloseWindow;
          Wait(500 + Random(500));
          SetLength(RB_SkipArray, Length(RB_SkipArray) + 1);
          RB_SkipArray[High(RB_SkipArray)] := Index;
          Result := UseRewardBox;
          Break;
        end;
        Wait(100 + Random(200));
      end;
      RB_SkipArray := [];
      if (CloseWindow) then
        Result := False;
    end;

    {*******************************************************************************
    function FindMod: Boolean;
    by: Stupid3ooo
    Description: Results True if a mod is found, then it waits 10-20 mins and logs back in
    *******************************************************************************}


    function FindMod: Boolean;
    var
      tX, tY: Integer;
    begin
      if (not UseFindMod) or (not LoggedIn) then exit;
      if (BmpMod = 0) or (BmpAdmin = 0) then
        LoadSRLBitMaps;
      if (FindColorTolerance(tX, tY, 14737632, MCX1, MCY1, MCX1 + 40, MCY2, 15)) or
           (FindColorTolerance(tX, tY, 589815, MCX1, MCY1, MCX1 + 40, MCY2, 15)) then
        if (FindTransparentBitmapTolerance(bmpMod, tX, tY, clBlack, MCX1, MCY1, MCX1 + 40, MCY2, 15)) or
         (FindTransparentBitmapTolerance(bmpAdmin, tx, ty, clBlack, MCX1, MCY1, MCX1 + 40, MCY2, 15)) then
        begin
          Result := True;
          AddToSRLLog('******** FOUND MOD ********');
          WriteLn('******** FOUND MOD ********');
          TakeScreen('Found mod');
          Inc(RandSolved[rand_Mod]);
          SaveToChatLog;
          if (SRL_Procs[srl_OnFindMod] <> nil) then
            SRL_Procs[srl_OnFindMod]();
          if (LogoutOnMod) then
          begin
            Players[CurrentPlayer].Rand := 'Found Mod';
            repeat
              Logout;
              Wait(1500 + Random(500));
            until not (LoggedIn);
            Wait(60000 + Random(60000));
            LoginPlayer;
            Players[CurrentPlayer].Rand := '';
          end;
        end;
    end;

    {*******************************************************************************
    function FindFight: Boolean;
    by: EvilChicken!
    Description: Results true if charachter is in a fight.
    *******************************************************************************}


    function FindFight: Boolean;
    begin
      Result := False;
      if (not LoggedIn) then exit;
      if (CountColor(10496, 200, 130, 280, 180) + CountColor(198716, 200, 130, 280, 180) > 50) then
      begin
        if (CheckHpFirst) and (HpPercent = 100) then exit;

        Result := True;
        AddToSRLLog('******** FOUND FIGHTING RANDOM ********');
        WriteLn('******** FOUND FIGHTING RANDOM ********');
        TakeScreen('Found Fight');
        Inc(RandSolved[rand_Fight]);
      end;
    end;

    {*******************************************************************************
    function FindLamp(skill: String): Boolean;
    by: Pups, Starblaster100 and PriSoner fixed by Lee Lok Hin
    Description: handles Genie. Results True if lamp found and handled.
    skill: Skill to use with lamp eg. 'strength', 'attack', etc.
    *******************************************************************************}


    function FindLamp(skill: string): Boolean;
    var
      LampTime, X, Y, I: Integer;
    begin
      GameTab(tab_Inv);
      if FindColorTolerance(x, y, 1084300, MIX1, MIY1, MIX2, MIY2, 40) then
        if (FindTransparentBitmapTolerance(Lamp, x, y, clBlack, MIX1, MIY1, MIX2, MIY2, 40)) then
        begin
          Result := True;
          Inc(RandSolved[rand_Lamp]);
          TakeScreen('Lamp Random Solved');
          AddToSRLLog('******** SOLVED LAMP RANDOM ********');
          WriteLn('******** SOLVED LAMP RANDOM ********');
          Mouse(X, Y, 4, 4, True);
          Wait(1500 + Random(500));
          MarkTime(LampTime);
          for I := 1 to 4 do
          begin
            case (LowerCase(Skill)) of
              'attack': Mouse(81, 109, 12, 12, True);
              'strength': Mouse(139, 110, 12, 12, True);
              'ranged': Mouse(196, 113, 12, 12, True);
              'magic': Mouse(257, 117, 12, 12, True);
              'defence': Mouse(319, 109, 12, 12, True);
              'crafting', 'craft': Mouse(376, 111, 12, 12, True);
              'hitpoints', 'hp': Mouse(436, 112, 12, 12, True);
              'prayer', 'pray': Mouse(79, 166, 12, 12, True);
              'agility': Mouse(141, 166, 12, 12, True);
              'herblore': Mouse(199, 171, 12, 12, True);
              'thieving', 'thief': Mouse(258, 167, 12, 12, True);
              'fishing', 'fish': Mouse(325, 164, 12, 12, True);
              'runecraft', 'runecrafting': Mouse(375, 167, 12, 12, True);
              'slayer', 'slay': Mouse(436, 173, 12, 12, True);
              'farming', 'farm': Mouse(83, 224, 12, 12, True);
              'mining', 'mine': Mouse(137, 222, 12, 12, True);
              'smithing', 'smith': Mouse(197, 220, 12, 12, True);
              'hunting', 'hunt', 'hunter': Mouse(257, 222, 12, 12, True);
              'cooking', 'cook': Mouse(318, 227, 12, 12, True);
              'firemaking', 'fire': Mouse(378, 226, 12, 12, True);
              'woodcutting', 'wc': Mouse(439, 222, 12, 12, True);
              'fletching', 'fletch': Mouse(199, 275, 12, 12, True);
              'construction': Mouse(255, 277, 12, 12, True);
              'summoning': Mouse(323, 276, 12, 12, True);
            else
              Mouse(438, 113, 12, 12, True);
            end;
            Wait(500 + Random(200) + Random(100));
            if FindColorTolerance(X, Y, 5602449, 41, 75, 470, 302, 30) then Break;
            if (TimeFromMark(LampTime) > 10000) then
            begin
              Result := False;
              Logout;
              Players[CurrentPlayer].Rand := 'Lamp';
              Exit;
            end;
            ClickToContinue;
          end;
          Mouse(416, 281, 7, 1, True);
          Wait(500 + Random(150) + Random(150));
        end;
    end;

    {*******************************************************************************
    function FindDead: Boolean;
    by: Stupid3ooo and Cazax
    Description: Checks for text "Oh dear you are dead".
    Logs out player if Reincarnate = False.
    *******************************************************************************}

    function FindDead: Boolean;
    begin
      Result := False;
      if FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dear', SmallChars, Nothing) then
        if FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dead', SmallChars, Nothing) then
        begin
          Inc(RandSolved[rand_Death]);
          Result := True;
          SaveToChatLog;
          if (SRL_Procs[srl_OnFindDead] <> nil) then
            SRL_Procs[srl_OnFindDead]();
          if (Reincarnate) then exit;
          TakeScreen('Found Dead');
          LogOut;
          Players[CurrentPlayer].Rand := 'Oh Dear You Are in Lumby';
          Players[CurrentPlayer].Active := False;
        end;
    end;

    {*******************************************************************************
    function Rand_GetRandomType: Integer;
    by: ZephyrsFury
    Description: Checks for the existance of various tabs to determine the type of
    random we are in:
      1: 13 or 14-tab randoms
      2: 6-tab randoms.
    *******************************************************************************}


    function Rand_GetRandomType: Integer;
    var
      TabConfig: TIntegerArray;
    begin
      TabConfig := [tab_Stats, tab_Friends];
      for Result := 1 to 2 do
        if (TabExists(TabConfig[Result - 1])) then
          Exit;
    end;

    {*******************************************************************************
    procedure LoadTeleRandoms;
    by: ZephyrsFury
    Description: Loads the teleport random information for each random.
    *******************************************************************************}


    procedure LoadTeleRandoms;
    begin
      SetLength(TeleRandoms, 19);

      with TeleRandoms[0] do    //
      begin
        Name := 'leo the gravedigger';
        Music := ['spooky'];
        TypeID := 1;
        IsInRandom := @InLeoGraveyard;
        Texts := ['Leo'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveLeo;
        RandIndex := rand_Leo;
      end;

      with TeleRandoms[1] do    //
      begin
        Name := 'freaky forester';
        Music := ['pheasant peasant'];
        TypeID := 1;
        IsInRandom := @InForesterRandom;
        Texts := ['orester'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveForester;
        RandIndex := rand_Forester;
      end;

      with TeleRandoms[2] do     //
      begin
        Name := 'maze';
        Music := ['time out'];
        TypeID := 1;
        IsInRandom := @InMaze;
        Texts := ['mplete'];
        TextColors := [15395562];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(131, 28, 194, 52)];
        SolveRandom := @SolveMaze;
        RandIndex := rand_Maze;
      end;

      with TeleRandoms[3] do  //
      begin
        Name := 'prison pete';
        Music := ['in the clink'];
        TypeID := 1;
        IsInRandom := @InPrisonPete;
        Texts := [];
        TextColors := [];
        TextFonts := [];
        TextBoxes := [];
        SolveRandom := nil;
        RandIndex := rand_PrisonPete;
      end;

      with TeleRandoms[4] do  //
      begin
        Name := 'evil bob''s island';
        Music := ['evil bob''s island'];
        TypeID := 1;
        IsInRandom := @InEvilBobsIsland;
        Texts := [];
        TextColors := [0];
        TextFonts := [];
        TextBoxes := [];
        SolveRandom := @SolveEvilBob;
        RandIndex := rand_ScapeRune;
      end;

      with TeleRandoms[5] do     //
      begin
        Name := 'drill demon';
        Music := ['corporal punishment'];
        TypeID := 1;
        IsInRandom := @Demon_InRandom;
        Texts := ['amien', 'amien'];
        TextColors := [128, 0];
        TextFonts := [NPCChars, NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2), IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveDemon;
        RandIndex := rand_Demon;
      end;

      with TeleRandoms[6] do        //Quiz with 6 tabs visibile
      begin
        Name := 'quiz';
        Music := ['the quiz master'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['uiz', 'uiz'];
        TextColors := [128, 0];
        TextFonts := [NPCChars, NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2), IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveQuiz;
        RandIndex := rand_Quiz;
      end;

      with TeleRandoms[7] do        //Quiz with 13 tabs visible
      begin
        Name := 'quiz';
        Music := [];
        TypeID := 1;
        IsInRandom := @InQuizRandom;
        Texts := ['uiz', 'uiz'];
        TextColors := [128, 0];
        TextFonts := [NPCChars, NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2), IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveQuiz;
        RandIndex := rand_Quiz;
      end;

      with TeleRandoms[8] do      //
      begin
        Name := 'surprise exam';
        Music := ['school''s out'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['ordaut'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveMordaut;
        RandIndex := rand_Mordaut;
      end;

      with TeleRandoms[9] do   //
      begin
        Name := 'molly''s evil twin';
        Music := ['head to head'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['olly'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := nil;
        RandIndex := rand_Molly;
      end;

      with TeleRandoms[10] do    //
      begin
        Name := 'pinball';
        Music := ['pinball wizard'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['flashing'];
        TextColors := [8323072];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolvePinball;
        RandIndex := rand_Pinball;
      end;

      with TeleRandoms[11] do    //
      begin
        Name := 'sandwich lady';
        Music := ['snack attack'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['andwich'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveSandwichLady;
        RandIndex := rand_Sandwich;
      end;

      with TeleRandoms[12] do    //
      begin
        Name := 'bee keeper';
        Music := ['horizon'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['keeper'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveBeeKeeper;
        RandIndex := rand_BeeKeeper;
      end;

      with TeleRandoms[13] do    //
      begin
        Name := 'pillory';
        Music := [];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['swinging', 'pillory'];
        TextColors := [128, 0];
        TextFonts := [NPCChars, NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2), IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolvePilloryPuzzle;
        RandIndex := rand_Pillory;
      end;

      with TeleRandoms[14] do  //
      begin
        Name := 'cap''n arnav';
        Music := ['sea shanty', 'sea shanty2'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['rnav'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveArnav;
        RandIndex := rand_CapnArnav;
      end;

      with TeleRandoms[15] do   // Abyss!
      begin
        Name := 'abyssal teleport';
        Music := ['into the abyss'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['appendage'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveAbyss;
        RandIndex := rand_Abyss;
      end;

      with TeleRandoms[16] do   //
      begin
        Name := 'certer';
        Music := ['harmony'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['iles'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveCerter;
        RandIndex := rand_Certer;
      end;

      with TeleRandoms[17] do    //
      begin
        Name := 'mime';
        Music := ['artistry'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['Mime'];
        TextColors := [0];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveMime;
        RandIndex := rand_Mime;
      end;

      with TeleRandoms[18] do   //
      begin
        Name := 'frog';
        Music := ['frogland'];
        TypeID := 2;
        IsInRandom := nil;
        Texts := ['erald'];
        TextColors := [128];
        TextFonts := [NPCChars];
        TextBoxes := [IntToBox(MCX1, MCY1, MCX2, MCY2)];
        SolveRandom := @SolveFrog;
        RandIndex := rand_Frog;
      end;
    end;

    procedure r_RunAlert; forward;
    function r_CheckAction: Boolean; forward;
    procedure r_ResetAll; forward;

    {*******************************************************************************
    function SolveTeleportRandoms: Boolean;
    by: ZephyrsFury
    Description: Handles the solving of Teleport randoms. Returns True if one is
      detected.
    *******************************************************************************}


    function SolveTeleportRandoms: Boolean;
    var
      TypeID, H, HH, I, J: Integer;
      B: TBox;
      RandResult: Boolean;
      Rand_Music: string;
      InitCompAngle: Extended;
    begin
      TypeID := Rand_GetRandomType;
      H := High(TeleRandoms);
      for I := 0 to H do
      begin
        if (TypeID = TeleRandoms[I].TypeID) then
        begin
          if (TeleRandoms[I].IsInRandom <> nil) then
            RandResult := TeleRandoms[I].IsInRandom();
          if (TeleRandoms[I].IsInRandom = nil) or (RandResult) then
          begin
            Status('Possible Random: ' + Capitalize(TeleRandoms[I].Name));
            Result := (Length(TeleRandoms[I].Texts) = 0) and (Length(TeleRandoms[I].Music) = 0);
            if (not Result) and (Length(TeleRandoms[I].Music) > 0) then
            begin
              if (Rand_Music = '') then Rand_Music := Lowercase(GetMusic);
              Result := InStrArr(Rand_Music, TeleRandoms[I].Music, False);
            end;
            if (not Result) and (Length(TeleRandoms[I].Texts) > 0) then
            begin
              HH := High(TeleRandoms[I].Texts)
              for J := 0 to HH do
              begin
                B := TeleRandoms[I].TextBoxes[J];
                Result := (FindTextTPA(TeleRandoms[I].TextColors[J], 0, B.X1, B.Y1, B.X2, B.Y2, TeleRandoms[I].Texts[J], TeleRandoms[I].TextFonts[J], Nothing));
                if (Result) then Break;
              end;
            end;
          end;
        end;
        if (not Result) then Continue;
        InitCompAngle := rs_GetCompassAngleDegrees;
        WriteLn('***** STR: FOUND RANDOM: ''' + Capitalize(TeleRandoms[I].Name) + ''' *****');
        AddToSRLLog('***** STR: FOUND RANDOM: ''' + Capitalize(TeleRandoms[I].Name) + ''' *****');
        TakeScreen('Found ' + Capitalize(TeleRandoms[I].Name) + ' random');
        Players[CurrentPlayer].Rand := Capitalize(TeleRandoms[I].Name);
        if (r_UseRandomTool) then
        begin
          PlaySound(SoundPath);
          CurRandom := I;
          r_RunAlert;
          if (r_CheckAction) then
          begin
            WriteLn('***** STR: ''' + Capitalize(TeleRandoms[i].Name) + ''' RANDOM SOLVED BY HAND! *****');
            AddToSRLLog('***** STR: ''' + Capitalize(TeleRandoms[i].Name) + ''' RANDOM SOLVED BY HAND! *****');
            Players[CurrentPlayer].Rand := '';
            Wait(5000 + Random(2000));
            r_ResetAll;
            Exit;
          end;
          r_ResetAll;
        end;
        ClickNorth(True);

        RandResult := False;
        if (TeleRandoms[I].SolveRandom <> nil) and (SolveSRLRandoms) then
          RandResult := TeleRandoms[I].SolveRandom();
        if (RandResult) then
        begin
          WriteLn('***** STR: ''' + Capitalize(TeleRandoms[I].Name) + ''' RANDOM SOLVED SUCCESSFULLY! *****');
          AddToSRLLog('***** STR: ''' + Capitalize(TeleRandoms[I].Name) + ''' RANDOM SOLVED SUCCESSFULLY! *****');
          Inc(RandSolved[TeleRandoms[I].RandIndex]);
          Players[CurrentPlayer].Rand := '';
          Wait(10000 + Random(2000));
        end else
        begin
          WriteLn('***** STR: ''' + Capitalize(TeleRandoms[I].Name) + ''' RANDOM SOLVING FAILED! *****');
          AddToSRLLog('***** STR: ''' + Capitalize(TeleRandoms[I].Name) + ''' RANDOM SOLVING FAILED! *****');
          Inc(RandFailed[TeleRandoms[I].RandIndex]);
          Players[CurrentPlayer].Active := False;
          LogOut;
          while (LoggedIn) do
            Wait(2000);
        end;
        MakeCompass(InitCompAngle);
        Exit;
      end;
    end;

    {*******************************************************************************
    function FindNonInventoryRandoms: Boolean;
    by: The SRL Developers Team!... all time sexiness by Mutant
    Description: Searches for the common NON-Inventory randoms: Won't switch to GameTab(4)!
    *******************************************************************************}


    function FindNonInventoryRandoms: Boolean;
    var
      I: Byte;
    begin
      for I := 1 to 5 do
      begin
        case I of
          1: Result := SolveTeleportRandoms;
          2: Respond;
          3: Result := FindDead;
          4: Result := RC;
          5: if (SRL_Procs[srl_OnRandomCall] <> nil) then
               SRL_Procs[srl_OnRandomCall]();
        end;
        if (Result) then
        begin
          if (SRL_Procs[srl_OnFindRandom] <> nil) then
            SRL_Procs[srl_OnFindRandom]();
          Break;
        end;
      end;
    end;

    {*******************************************************************************
    function FindNormalRandoms: Boolean;
    by: The SRL Developers Team!... all time sexiness by Mutant
    Description: Calls the 'normal' random checks.
    *******************************************************************************}


    function FindNormalRandoms: Boolean;
    var
      I: Byte;
    begin
      for I := 1 to 8 do
      begin
        case I of
          1: Result := SolveTeleportRandoms;
          2: Respond;
          3: Result := FindDead;
          4: Result := FindLamp(LampSkill);
          5: Result :=  RC;
          6: Result := FindMod;
          7: if (SRL_Procs[srl_OnRandomCall] <> nil) then
               SRL_Procs[srl_OnRandomCall]();
          8: if High(Players[CurrentPlayer].BoxRewards) > -1 then
               Result := UseRewardBox;
        end;
        if (Result) then
        begin
          if (SRL_Procs[srl_OnFindRandom] <> nil) then
            SRL_Procs[srl_OnFindRandom]();
          Break;
        end;
      end;
    end;

    Commit pl0x.
    Last edited by Nava2; 12-16-2009 at 01:28 PM.

  2. #2
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Ehh, function Demon_InRandom: Boolean; gets kinda funky after a while.
    Fence? Arrow in chat box? Are you sure that color will always pick up the fence? Why not search for the color of the mats or something?
    Also: DOH! Why not just check music dude -.-? If Getmusic "Corporal Punishment" Then True? Wouldn't that work?

  3. #3
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Ehh, function Demon_InRandom: Boolean; gets kinda funky after a while.
    Fence? Arrow in chat box? Are you sure that color will always pick up the fence? Why not search for the color of the mats or something?
    Also: DOH! Why not just check music dude -.-? If Getmusic "Corporal Punishment" Then True? Wouldn't that work?
    I re-loaded the client and logged onto different worlds about 6 times to get all of the different fence colours. I don't find the colour of the mats because the they are all green and green is a common ground colour and all of the mats are different colours and have a lot of shading. I chose the arrow in the chat box because it doesn't show when you are in the demon random.

    Also: DOH! SolveTeleportRandoms checks the music.

  4. #4
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Hmm, any reason why calling 'FindNormalRandoms' wasnt checking the music tab for me? And yeah, couldn't just a music search be used for Demon_InRandom?

  5. #5
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Hmm, any reason why calling 'FindNormalRandoms' wasnt checking the music tab for me? And yeah, couldn't just a music search be used for Demon_InRandom?
    The reason why FindNormalRandoms wasn't checking the music tab for you was because the random changed from a type 2 random to a type 1 random (there had to be only 6 tabs for it to be possible to be in the demon random before).

    If Demon_InRandom results true, then SolveTeleportRandoms will check the music (its the way SolveTeleportRandoms works).

  6. #6
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Ohhhh!
    So FIRST it checks X_InRandom and THEN it checks music if the type of random is (1 or 2)? Why not JUST check the music? Or check Music AND X_InRandom, and if any of them result true then move on? So wouldn't just changing the Type from 1 to 2 (or whatever?) fix the problem then?

    Thanks for that explanation.

  7. #7
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Ohhhh!
    So FIRST it checks X_InRandom and THEN it checks music if the type of random is (1 or 2)? Why not JUST check the music? Or check Music AND X_InRandom, and if any of them result true then move on? So wouldn't just changing the Type from 1 to 2 (or whatever?) fix the problem then?

    Thanks for that explanation.
    Ya, when FindNormalRandoms is called, SolveTeleportRandoms is also called which checks to see if the account is in any of the 19 randoms by checking X_InRandom if there is one then by checking the music. Maybe also by checking the chat box.

    If the SolveTeleportRandoms just checked the music, then every time FindNormalRandoms is called...

    Using a function to check if you're in a random is more accurate than just relying on the chat box and game tabs.

  8. #8
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Code:
    kevin@n2-laptop:~/.wine/drive_c/Program Files/SCAR 3.15/Includes/SRL$ svn ci
    Sending        SRL/core/AntiRandoms/AntiRandoms.scar
    Sending        SRL/core/AntiRandoms/Demon.scar
    Transmitting file data ..
    Committed revision 315.
    kevin@n2-laptop:~/.wine/drive_c/Program Files/SCAR 3.15/Includes/SRL$
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  9. #9
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    A tolerance was too low in Demon_InRandom so I had to raise it.

    SCAR Code:
    {*******************************************************************************
    function Demon_InRandom: Boolean;
    by: TRiLeZ
    Description: Checks if you're in the demon random.
    Date: December 15, 2009
    *******************************************************************************}

    function Demon_InRandom: Boolean;
    var
      TempCTS: Integer;
    begin
      TempCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);
      if (CountDots('npc') = 1) then
        if (TabExists(tab_Magic) = false) then
          if (CountColorTolerance(15986930, MMX1, MMY1, MMX2, MMY2, 18) >= 750) then //white fences
            if (not (GetColor(504, 348) = 657930)) then //Arrow in chat box
            Result := True;
      ColorToleranceSpeed(TempCTS);
    end;

    Hopefully the Demon solver won't need anymore changed after this.
    Thanks for committing.

  10. #10
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Just keep updating the first post

    Its a *lot* easier for me to just update the entire file. + Then I know its compiled.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  11. #11
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by TRiLeZ View Post
    A tolerance was too low in Demon_InRandom so I had to raise it.

    SCAR Code:
    {*******************************************************************************
    function Demon_InRandom: Boolean;
    by: TRiLeZ
    Description: Checks if you're in the demon random.
    Date: December 15, 2009
    *******************************************************************************}

    function Demon_InRandom: Boolean;
    var
      TempCTS: Integer;
    begin
      TempCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);
      if (CountDots('npc') = 1) then
        if (TabExists(tab_Magic) = false) then
          if (CountColorTolerance(15986930, MMX1, MMY1, MMX2, MMY2, 18) >= 750) then //white fences
            if (not (GetColor(504, 348) = 657930)) then //Arrow in chat box
            Result := True;
      ColorToleranceSpeed(TempCTS);
    end;

    Hopefully the Demon solver won't need anymore changed after this.
    Thanks for committing.
    This still needs to be committed...

Thread Information

Users Browsing this Thread

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

Posting Permissions

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