Page 9 of 10 FirstFirst ... 78910 LastLast
Results 201 to 225 of 239

Thread: Randoms Development

  1. #201
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by DannyRS View Post
    @Flight, Had a quick rework of it ^.^

    https://github.com/SRL/SRL-OSR/pull/127
    Why didnt you stick to DTM's? they used to work perfect back when current RS had them.

  2. #202
    Join Date
    Sep 2013
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    20 Post(s)

    Default

    The pinball random needs a little tweaking. I was watching it when it was being solved and when a pinball appears on the furthest end of the room away from the player, sometimes by the time the player gets to it (if hes walking) it goes for another click in the midst of the animation from the first click thus resetting the score back to zero. Also when it got to the exit procedure it had to initiate the backup as the first method didn't get me to the exit. It kept clicking towards the east of the room. (Compass angle was also east at that point if that makes any difference when the random team are trying to debug.

  3. #203
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    @Ashaman88 can you take a look at my random solver for the whirlpool random? it can be found at my barbfisher and i think it works correctly

  4. #204
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    @Ashaman88 can you take a look at my random solver for the whirlpool random? it can be found at my barbfisher and i think it works correctly
    For reference here's yours:
    Simba Code:
    function CheckPool: boolean;
    var
      TPAA: T2DPointArray;
      TPA: TPointArray;
      CTS, I: Integer;
      mp: tpoint;
      box: tbox;
    begin
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      setcolorspeed2modifiers(1.26, 0.29);
      FindColorsSpiralTolerance(mscx, mscy, TPA, 12301240, 70, 38, 500, 327, 16);
      ColorToleranceSpeed(CTS);
      TPAA := TPAToATPAEx(TPA, 15, 15);
      SortATPASize(TPAA, True);
      for I := 0 to High(TPAA) do
        if GetArraylength(TPAA[i]) > 20 then
        begin
          smart_drawboxex(false, false, box, clred);
          MiddleTPAEx(TPAA[i], x, y);
          Mp := MiddleTPA(TPAA[i]);
          box := inttobox(mp.x - 9, mp.y - 9, mp.x + 9, mp.y + 9);
          if pixelshift(box, 500) > 280 then
          begin
            result := true
          end;
        end;
    end;

    Your search bounds are [70, 38, 500, 327], that's most of the full area of the MS... So basically if any visible fishing spot becomes a whirlpool, even if it's not yours, your script will detect it and run away. And you should definitely remove the SMART drawing as not everyone would want boxes drawn on their screen every time a whirlpool is detected.

    You should take a look at this thread for some ideas.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  5. #205
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    For reference here's yours:
    Simba Code:
    function CheckPool: boolean;
    var
      TPAA: T2DPointArray;
      TPA: TPointArray;
      CTS, I: Integer;
      mp: tpoint;
      box: tbox;
    begin
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      setcolorspeed2modifiers(1.26, 0.29);
      FindColorsSpiralTolerance(mscx, mscy, TPA, 12301240, 70, 38, 500, 327, 16);
      ColorToleranceSpeed(CTS);
      TPAA := TPAToATPAEx(TPA, 15, 15);
      SortATPASize(TPAA, True);
      for I := 0 to High(TPAA) do
        if GetArraylength(TPAA[i]) > 20 then
        begin
          smart_drawboxex(false, false, box, clred);
          MiddleTPAEx(TPAA[i], x, y);
          Mp := MiddleTPA(TPAA[i]);
          box := inttobox(mp.x - 9, mp.y - 9, mp.x + 9, mp.y + 9);
          if pixelshift(box, 500) > 280 then
          begin
            result := true
          end;
        end;
    end;

    Your search bounds are [70, 38, 500, 327], that's most of the full area of the MS... So basically if any visible fishing spot becomes a whirlpool, even if it's not yours, your script will detect it and run away. And you should definitely remove the SMART drawing as not everyone would want boxes drawn on their screen every time a whirlpool is detected.

    You should take a look at this thread for some ideas.
    I know but i said he should take a look at it. You can remove the Smart functions. But yes you are right, the location is not right. But atleast it will detect the whirlpools.

  6. #206
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    I know but i said he should take a look at it. You can remove the Smart functions. But yes you are right, the location is not right. But atleast it will detect the whirlpools.
    Whirlpool detecting is more for script side, just make it look for all the fishing spots, sort from closest to player, from the closest to the farthest BEFORE hovering over each spot check the pixel shift, if > a number then it's a whirlpool and move on to the next OR set the length of the ATPA to 2-3 (2-3 fishing spots)

  7. #207
    Join Date
    Aug 2012
    Location
    127.0.0.1
    Posts
    74
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Mordaut random solving, failed for the 2nd time in a row now, debug just cycles through all possible solutions and returns failed to find each time.
    (reset script and didn't code debug in time, sorry)

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

    Default

    Just out of curiosity, what happened to all the solvers Demise and I wrote a year or so ago? I rewrote them to be easily updated, and most of them should have been extremely easy to make work with OSR.

  9. #209
    Join Date
    Nov 2011
    Location
    United States
    Posts
    815
    Mentioned
    6 Post(s)
    Quoted
    284 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Just out of curiosity, what happened to all the solvers Demise and I wrote a year or so ago? I rewrote them to be easily updated, and most of them should have been extremely easy to make work with OSR.
    No idea, but they would be extremely helpful. Like you said it would probably only take me a day or two to fix them... Just starting to get into OSRS with Millenium

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

    Default

    Quote Originally Posted by Itankbots View Post
    No idea, but they would be extremely helpful. Like you said it would probably only take me a day or two to fix them... Just starting to get into OSRS with Millenium
    It was a great system, and if SRL-OSR was based off the latest SRL-5 then it might still use it (the system). It would be a shame if everything was rewritten from scratch.

  11. #211
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Just out of curiosity, what happened to all the solvers Demise and I wrote a year or so ago? I rewrote them to be easily updated, and most of them should have been extremely easy to make work with OSR.
    Did she make solvers for the 3D object random events? Like the Strange Box, Certers, Grave Digger and so on... Personally I'd like to just have the old plugins compiled and used again in anti-randoms. Cynicrus has already converted them to work with Simba, apparently, but there's no compiled version.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


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

    Default

    Quote Originally Posted by Flight View Post
    Did she make solvers for the 3D object random events? Like the Strange Box, Certers, Grave Digger and so on... Personally I'd like to just have the old plugins compiled and used again in anti-randoms. Cynicrus has already converted them to work with Simba, apparently, but there's no compiled version.
    Grave digger was one of maybe two that we didn't solve. Certers worked perfectly as far as I know, and I don't know if the strange box was in RS at the time. I don't remember writing a solver for it. But Mordaut worked really well (probably upwards of 95% of the time), maze was perfect, sandwich lady. Honestly I think the grave digger and prison pete were the only ones that weren't solved.

    I don't really remember what the old plugins were used for, they were written before my time.

    E: These were the only randoms at the time: https://github.com/SRL/SRL-5/tree/ma...re/antirandoms

    E2: Looking SRL-OSR I see you kept the same system (i.e. antirandoms.simba), which it's great! I'm pretty proud of that system and I'm glad you guys stuck with it.
    Last edited by Coh3n; 12-09-2013 at 05:07 PM.

  13. #213
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Grave digger was one of maybe two that we didn't solve. Certers worked perfectly as far as I know, and I don't know if the strange box was in RS at the time. I don't remember writing a solver for it. But Mordaut worked really well (probably upwards of 95% of the time), maze was perfect, sandwich lady. Honestly I think the grave digger and prison pete were the only ones that weren't solved.

    I don't really remember what the old plugins were used for, they were written before my time.

    E: These were the only randoms at the time: https://github.com/SRL/SRL-5/tree/ma...re/antirandoms

    E2: Looking SRL-OSR I see you kept the same system (i.e. antirandoms.simba), which it's great! I'm pretty proud of that system and I'm glad you guys stuck with it.
    To bad most of the random solvers doesnt work for osr.

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

    Default

    Quote Originally Posted by hoodz View Post
    To bad most of the random solvers doesnt work for osr.
    Well obviously. They were written for RS as of last year. Of course they'd need to be updated to work with RS07. My point is a lot of the randoms are really similar and would require only minimal updates to the solvers.

  15. #215
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    It would be nice if there were a sub-forum for OSR random development..
    Most randoms which aren't straight-up talking are failing for me, I wanted to see where some of the randoms usually fail..
    • Certers not detecting odd item out 100% of the time. Client freezes up when scanning.
    • Drill sergeant detects 3-4 signs but then doesn't select one, spams talk-to-sergeant then walk-to-centre a few times before logging out. Edit: Srl just solved a drill demon, first time it's worked in over 10 separate attempts. Sadly wasn't watching because I was writing this
    • Frog random fails by not finishing the speech options while talking to princess at the end of the cave.
    • Sandwich lady fails at finding correct food 90% of the time.
    • Pillory cage won't click on the cage if the compass angle is not north, having problems with lock-detection when facing north, the keys were mostly right although the circle was recognised as a diamond.
    • Strangebox dtm is not recognised, when I set the dtm, solved only 50-60% of the time. The shape recognition was about 80% accurate while the numberscan was disturbingly 40-50% accurate (often changing to wrong numbers, only for the correct shape). The two wrong answers seem to be shown front-on a lot more than the actual answer.
    • Genie completes but can screw up banking scripts when lampskill is not set because the lamp can't be banked. (Set a random default lampskill?)


    I made edits to the pinball random because it wouldn't exit the cave when the compass angle was not north. Simply detected current angle, set to north for the exit routine and set back to previous angle after a successful cave exit. Tested and working fine for me using the Pascal version of OSR:
    Code:
    (*
    Pinball
    =======
    
    Stores all the routines to solve the Pinball random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    This solver uses findGapsTPA to determine which post to click.
    
    *)
    
    //{$DEFINE PB_DEBUG}
    
    const
      PB_SCORE_10 = 180; // the tpa length of when the score is 10
    
    (**
     * Author: Coh3n
     * Description: Detects if a player is in the Pinball random.
     *)
    function PB_Detect(): boolean;
    begin
      // makes sure friends tab exists and magic doesn't
      if ((not tabExists(TAB_MAGIC)) and (tabExists(TAB_FRIENDS))) then
        result := (Trim(GetTextAtExWrap(374, 238, 411, 253, 0, 5, 1,
            65535, 5, 'UpChars07')) = 'Score');
    end;
    
    (**
     * Author: Coh3n
     * Description: Returns the length of a tpa found of the yellow color of the
     * score at the top of the main screen.
     *)
    function PB_GetScore(): integer;
    var
      tpa: TPointArray;
    begin
      // yellow color of the score
      if (findColorsTolerance(tpa, 65535, 373, 239, 434, 258, 30)) then
        result := length(tpa);
    end;
    
    (**
     * Author: SKy Scripter, NCDS, & Coh3n
     * Description: Returns true if a flashing pillar is found.  Sets coordinates
     * to x, y.
     *)
    const
      _PB_FILL_COLOR = 10;
      _PB_MIN_LENGTH = 20;
    
    function PB_ScanPost(var x, y: integer): boolean;
    var
      tpa: TPointArray;
      pillarCols: array of integer;
      ATPA, pillarGaps: T2DPointArray;
      oldTarget, tmpCTS, bmp, i, j, c: integer;
      hue, sat, lum: extended;
      tmpBox: TBox;
    begin
      result := false;
      bmp := -1;
    
      try
        tmpCTS := getColorToleranceSpeed;
        setColorToleranceSpeed(3);
    
        // the green of the spinning pillars
        findColorsTolerance(tpa, 6011467, MSX1, MMY1, MSX2, MSY2, 38);
    
        setColorToleranceSpeed(tmpCTS);
    
        // if colors aren't found, exit
        if (length(tpa) < _PB_MIN_LENGTH) then
          exit;
    
        bmp := createBitmap(MSX2 + 5, MSY2 + 5); // creats a bitmap of the MS
        fastDrawClear(bmp, _PB_FILL_COLOR); // fill it with a distinct color
    
        c := 0;
        pillarCols := getColors(tpa);
    
        // draws a rectangle on the bitmap of the colors that are light enough
        for i := 0 to high(tpa) do
        begin
          colorToHSL(pillarCols[i], hue, sat, lum);
    
          if (lum > 50.0) then
          begin
            tmpBox := intToBox(max(0, tpa[i].x - 1), max(0, tpa[i].y - 1), tpa[i].x + 1, tpa[i].y + 1);
            rectangleBitmap(bmp, tmpBox, clRed);
            inc(c);
          end;
        end;
    
        if (c > _PB_MIN_LENGTH) then
        begin
          floodFillBitmap(bmp, point(5, 5), _PB_FILL_COLOR, clBlack);
    
          oldTarget := getImageTarget();
          setTargetBitmap(bmp);
    
          findColors(tpa, _PB_FILL_COLOR, 0, 0, MSX2 - 5, MSY2 - 5);
    
          setImageTarget(oldTarget); // reset target to RS client
    
          if (length(tpa) > 10) then
          begin
            ATPA := TPAtoATPA(tpa, 60);
            sortATPASize(ATPA, true);
    
            for i := 0 to high(ATPA) do
            begin
              pillarGaps := findGapsTPA(ATPA[i], 10);
    
              for j := 0 to high(pillarGaps) do
                if (length(pillarGaps[j]) > 2) then
                begin
                  middleTPAEx(ATPA[i], x, y);
                  result := true;
                  break;
                end;
    
              if (result) then
                break;
            end;
          end;
        end;
    
        {$IFDEF PB_DEBUG}
        displayDebugImgWindow(MSX2, MSY2);
        drawBitmapDebugImg(bmp);
        {$ENDIF}
    
      finally
        if (bmp <> -1) then
          freeBitmap(bmp);
      end;
    
      if (result) then
        addToSRLLog('PB_ScanPost: Found post');
    end;
    
    (**
     * Author: Coh3n
     * Description: Returns true if player clicks a post and the score changes.
     *)
    function PB_TagPost(): boolean;
    var
      t, x, y, oldScore: integer;
    begin
      if (not loggedIn()) then
        exit;
    
      oldScore := PB_GetScore();
    
      if (PB_ScanPost(x, y)) then
      begin
        Mouse(x, y, 5, 5, mouse_right);
    
        if (WaitOptionMulti(['ag', 'g P'], 618)) then
        begin
          t := (getSystemTime + 6000);
          while (getSystemTime < t) do
          begin
            if (PB_GetScore() <> oldScore) then
            begin
              addToSRLLog('PB_TagPost: Tagged post');
              result := true;
              break;
            end;
    
            wait(300 + random(200));
          end;
        end else
          MMouse(x, y - 25, 8, 8);
      end;
    end;
    
    (**
     * Author: DemiseScythe & Coh3n
     * Description: Uses mainscreen walking to exit the random.
     * Updated: Fixed for 07scape. - DannyRS - 23/03/2013
     *)
    function PB_Exit(): boolean;
    var
      x, y, t, i: integer;
      tpa, tpa_Exit: TPointArray;
      ATPA: T2DPointArray;
      Deg: Extended;
    begin
    
     if (not loggedIn()) then
       exit;
     addToSRLLog('PB_Exit: Exiting cave');
     SetAngle(SRL_ANGLE_HIGH);
     Deg := RS_GetCompassAngleDegrees;
     Wait(100 + random(50));
     MakeCompass('N');
     t := (getSystemTime + 25000);
     repeat
       // the green path color
       if (findColorsTolerance(tpa, 4544055, MSX1, MMCY+10, MSX2, MSY2, 35)) then
       begin
         if (length(tpa) > 0) then
         begin
           MiddleTPAEx(tpa, x, y);
           MMouse(x, y, 5, 5);
           Wait(RandomRange(90,150));
           if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
           begin
             ClickMouse2(mouse_left);
             if (waitTabExists(TAB_MAGIC, 8000)) then
             begin
               result := true;
               break;
             end;
           end;
         end;
       end;
       if (findColorsTolerance(tpa, 5734757, MSX1, MMCY, MSX2, MSY2, 35)) then
         if (length(tpa) > 0) then
         begin
           sortTPAFrom(tpa, point(MSCX, MSY2)); // center of the bottom of the MS
           x := tpa[0].x;
           y := tpa[0].y - 20; // so it's actually on the MS
    
           MMouse(x, y, 5, 5);
    
           // check for the proper uptexts
           if (waitUptextMulti(['Walk', 'alk', 'here', 'ere'], 200)) then
           begin
             ClickMouse2(mouse_left);
           end
           else if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
           begin
             ClickMouse2(mouse_left);
             if (waitTabExists(TAB_MAGIC, 8000)) then
             begin
               result := true;
               break;
             end;
           end;
         end;
       result := tabExists(TAB_MAGIC); // just in case
       wait(2000 + random(300));
     until ((getSystemTime > t) or (result));
     if (result) then
     begin
       Wait(100 + random(500));
       MakeCompass(Deg);
       addToSRLLog('PB_Exit: Clicked exit cave')
     end else
     begin
       addToSRLLog('PB_Exit: Took to long to find exit... Looking for backup');
       t := (getSystemTime + 20000);
       MakeCompass('S');
       repeat
         if (FindColorsTolerance(tpa_Exit, 4677175, MSX1, MSY1, MSX2, MSY2, 23)) then
           ATPA := TPAToATPAEx(tpa_Exit, 70, 5);
         if (length(ATPA) > 0) then
         begin
           SortATPASize(ATPA, True);
           for i := 0 to High(ATPA) do
           begin
             MiddleTPAEx(ATPA[i], x, y);
             MMouse(x, y, 5, 5);
             Wait(RandomRange(90,150));
             if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
             begin
               ClickMouse2(mouse_left);
               if (waitTabExists(TAB_MAGIC, 8000)) then
               begin
                 result := true;
                 break;
               end;
             end;
           end;
         end;
         result := tabExists(TAB_MAGIC);
         wait(2000 + random(300));
       until ((getSystemTime > t) or (result));
       if (result) then
         addToSRLLog('PB_Exit: Clicked exit cave with backup')
       else
         addToSRLLog('PB_Exit: Failed to exit')
     end;
    end;
    
    (**
     * Author: Coh3n & DemiseScythe
     * Description: Solves the Pinball random.
     *)
    function PB_Solve(): boolean;
    var
      t: integer;
    begin
      if (not loggedIn()) then
        exit;
    
      t := (getSystemTime + (15 * 60000)); // maximum 15 minutes
      doConversation('', false);
    
      repeat
        if (PB_GetScore = PB_SCORE_10) then // length of "Score: 10"
        begin
          if (PB_Exit()) then
          begin
            result := true;
            break;
          end;
        end else
          PB_TagPost();
    
        wait(500 + random(200));
      until(result or (getSystemTime > t));
    end;
    Last edited by Krazy_Meerkat; 12-11-2013 at 04:12 PM.

  16. #216
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Grave digger was one of maybe two that we didn't solve. Certers worked perfectly as far as I know, and I don't know if the strange box was in RS at the time. I don't remember writing a solver for it. But Mordaut worked really well (probably upwards of 95% of the time), maze was perfect, sandwich lady. Honestly I think the grave digger and prison pete were the only ones that weren't solved.

    I don't really remember what the old plugins were used for, they were written before my time.

    E: These were the only randoms at the time: https://github.com/SRL/SRL-5/tree/ma...re/antirandoms

    E2: Looking SRL-OSR I see you kept the same system (i.e. antirandoms.simba), which it's great! I'm pretty proud of that system and I'm glad you guys stuck with it.
    From what I remember, we had based it off of both the most recent antirandoms yall came up with and tried combining with the solvers from 2007 SRL. The majority of the randoms that weren't solved were due to a lack of accounts to test with as well as a lack of interest in OSR.

    Quote Originally Posted by Krazy_Meerkat View Post
    It would be nice if there were a sub-forum for OSR random development..
    Most randoms which aren't straight-up talking are failing for me, I wanted to see where some of the randoms usually fail..
    • Certers not detecting odd item out 100% of the time. Client freezes up when scanning.
    • Drill sergeant detects 3-4 signs but then doesn't select one, spams talk-to-sergeant then walk-to-centre a few times before logging out.
    • Freaky forester detects event but does nothing.
    • Frog random fails by not finishing the speech options while talking to princess at the end of the cave.
    • Sandwich lady fails at finding correct food 90% of the time.
    • Pillory cage won't click on the cage if the compass angle is not north, having problems with lock-detection when facing north, the keys were mostly right although the circle was recognised as a diamond.
    • Strangebox dtm is not recognised, when I set the dtm, solved only 50-60% of the time. The shape recognition was about 80% accurate while the numberscan was disturbingly 40-50% accurate (often changing to wrong numbers, only for the correct shape). The two wrong answers seem to be shown front-on a lot more than the actual answer.
    • Genie completes but can screw up banking scripts when lampskill is not set because the lamp can't be banked. (Set a random default lampskill?)


    I made edits to the pinball random because it wouldn't exit the cave when the compass angle was not north. Simply detected current angle, set to north for the exit routine and set back to previous angle after a successful cave exit. Tested and working fine for me:
    Code:
    (*
    Pinball
    =======
    
    Stores all the routines to solve the Pinball random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    This solver uses findGapsTPA to determine which post to click.
    
    *)
    
    //{$DEFINE PB_DEBUG}
    
    const
      PB_SCORE_10 = 180; // the tpa length of when the score is 10
    
    (**
     * Author: Coh3n
     * Description: Detects if a player is in the Pinball random.
     *)
    function PB_Detect(): boolean;
    begin
      // makes sure friends tab exists and magic doesn't
      if ((not tabExists(TAB_MAGIC)) and (tabExists(TAB_FRIENDS))) then
        result := (Trim(GetTextAtExWrap(374, 238, 411, 253, 0, 5, 1,
            65535, 5, 'UpChars07')) = 'Score');
    end;
    
    (**
     * Author: Coh3n
     * Description: Returns the length of a tpa found of the yellow color of the
     * score at the top of the main screen.
     *)
    function PB_GetScore(): integer;
    var
      tpa: TPointArray;
    begin
      // yellow color of the score
      if (findColorsTolerance(tpa, 65535, 373, 239, 434, 258, 30)) then
        result := length(tpa);
    end;
    
    (**
     * Author: SKy Scripter, NCDS, & Coh3n
     * Description: Returns true if a flashing pillar is found.  Sets coordinates
     * to x, y.
     *)
    const
      _PB_FILL_COLOR = 10;
      _PB_MIN_LENGTH = 20;
    
    function PB_ScanPost(var x, y: integer): boolean;
    var
      tpa: TPointArray;
      pillarCols: array of integer;
      ATPA, pillarGaps: T2DPointArray;
      oldTarget, tmpCTS, bmp, i, j, c: integer;
      hue, sat, lum: extended;
      tmpBox: TBox;
    begin
      result := false;
      bmp := -1;
    
      try
        tmpCTS := getColorToleranceSpeed;
        setColorToleranceSpeed(3);
    
        // the green of the spinning pillars
        findColorsTolerance(tpa, 6011467, MSX1, MMY1, MSX2, MSY2, 38);
    
        setColorToleranceSpeed(tmpCTS);
    
        // if colors aren't found, exit
        if (length(tpa) < _PB_MIN_LENGTH) then
          exit;
    
        bmp := createBitmap(MSX2 + 5, MSY2 + 5); // creats a bitmap of the MS
        fastDrawClear(bmp, _PB_FILL_COLOR); // fill it with a distinct color
    
        c := 0;
        pillarCols := getColors(tpa);
    
        // draws a rectangle on the bitmap of the colors that are light enough
        for i := 0 to high(tpa) do
        begin
          colorToHSL(pillarCols[i], hue, sat, lum);
    
          if (lum > 50.0) then
          begin
            tmpBox := intToBox(max(0, tpa[i].x - 1), max(0, tpa[i].y - 1), tpa[i].x + 1, tpa[i].y + 1);
            rectangleBitmap(bmp, tmpBox, clRed);
            inc(c);
          end;
        end;
    
        if (c > _PB_MIN_LENGTH) then
        begin
          floodFillBitmap(bmp, point(5, 5), _PB_FILL_COLOR, clBlack);
    
          oldTarget := getImageTarget();
          setTargetBitmap(bmp);
    
          findColors(tpa, _PB_FILL_COLOR, 0, 0, MSX2 - 5, MSY2 - 5);
    
          setImageTarget(oldTarget); // reset target to RS client
    
          if (length(tpa) > 10) then
          begin
            ATPA := TPAtoATPA(tpa, 60);
            sortATPASize(ATPA, true);
    
            for i := 0 to high(ATPA) do
            begin
              pillarGaps := findGapsTPA(ATPA[i], 10);
    
              for j := 0 to high(pillarGaps) do
                if (length(pillarGaps[j]) > 2) then
                begin
                  middleTPAEx(ATPA[i], x, y);
                  result := true;
                  break;
                end;
    
              if (result) then
                break;
            end;
          end;
        end;
    
        {$IFDEF PB_DEBUG}
        displayDebugImgWindow(MSX2, MSY2);
        drawBitmapDebugImg(bmp);
        {$ENDIF}
    
      finally
        if (bmp <> -1) then
          freeBitmap(bmp);
      end;
    
      if (result) then
        addToSRLLog('PB_ScanPost: Found post');
    end;
    
    (**
     * Author: Coh3n
     * Description: Returns true if player clicks a post and the score changes.
     *)
    function PB_TagPost(): boolean;
    var
      t, x, y, oldScore: integer;
    begin
      if (not loggedIn()) then
        exit;
    
      oldScore := PB_GetScore();
    
      if (PB_ScanPost(x, y)) then
      begin
        Mouse(x, y, 5, 5, mouse_right);
    
        if (WaitOptionMulti(['ag', 'g P'], 618)) then
        begin
          t := (getSystemTime + 6000);
          while (getSystemTime < t) do
          begin
            if (PB_GetScore() <> oldScore) then
            begin
              addToSRLLog('PB_TagPost: Tagged post');
              result := true;
              break;
            end;
    
            wait(300 + random(200));
          end;
        end else
          MMouse(x, y - 25, 8, 8);
      end;
    end;
    
    (**
     * Author: DemiseScythe & Coh3n
     * Description: Uses mainscreen walking to exit the random.
     * Updated: Fixed for 07scape. - DannyRS - 23/03/2013
     *)
    function PB_Exit(): boolean;
    var
      x, y, t, i: integer;
      tpa, tpa_Exit: TPointArray;
      ATPA: T2DPointArray;
      Deg: Extended;
    begin
    
     if (not loggedIn()) then
       exit;
     addToSRLLog('PB_Exit: Exiting cave');
     SetAngle(SRL_ANGLE_HIGH);
     Deg := RS_GetCompassAngleDegrees;
     Wait(100 + random(50));
     MakeCompass('N');
     t := (getSystemTime + 25000);
     repeat
       // the green path color
       if (findColorsTolerance(tpa, 4544055, MSX1, MMCY+10, MSX2, MSY2, 35)) then
       begin
         if (length(tpa) > 0) then
         begin
           MiddleTPAEx(tpa, x, y);
           MMouse(x, y, 5, 5);
           Wait(RandomRange(90,150));
           if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
           begin
             ClickMouse2(mouse_left);
             if (waitTabExists(TAB_MAGIC, 8000)) then
             begin
               result := true;
               break;
             end;
           end;
         end;
       end;
       if (findColorsTolerance(tpa, 5734757, MSX1, MMCY, MSX2, MSY2, 35)) then
         if (length(tpa) > 0) then
         begin
           sortTPAFrom(tpa, point(MSCX, MSY2)); // center of the bottom of the MS
           x := tpa[0].x;
           y := tpa[0].y - 20; // so it's actually on the MS
    
           MMouse(x, y, 5, 5);
    
           // check for the proper uptexts
           if (waitUptextMulti(['Walk', 'alk', 'here', 'ere'], 200)) then
           begin
             ClickMouse2(mouse_left);
           end
           else if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
           begin
             ClickMouse2(mouse_left);
             if (waitTabExists(TAB_MAGIC, 8000)) then
             begin
               result := true;
               break;
             end;
           end;
         end;
       result := tabExists(TAB_MAGIC); // just in case
       wait(2000 + random(300));
     until ((getSystemTime > t) or (result));
     if (result) then
     begin
       Wait(100 + random(500));
       MakeCompass(Deg);
       addToSRLLog('PB_Exit: Clicked exit cave')
     end else
     begin
       addToSRLLog('PB_Exit: Took to long to find exit... Looking for backup');
       t := (getSystemTime + 20000);
       MakeCompass('S');
       repeat
         if (FindColorsTolerance(tpa_Exit, 4677175, MSX1, MSY1, MSX2, MSY2, 23)) then
           ATPA := TPAToATPAEx(tpa_Exit, 70, 5);
         if (length(ATPA) > 0) then
         begin
           SortATPASize(ATPA, True);
           for i := 0 to High(ATPA) do
           begin
             MiddleTPAEx(ATPA[i], x, y);
             MMouse(x, y, 5, 5);
             Wait(RandomRange(90,150));
             if (waitUptextMulti(['Exit', 'xit', 'Cave', 'ave'], 200)) then
             begin
               ClickMouse2(mouse_left);
               if (waitTabExists(TAB_MAGIC, 8000)) then
               begin
                 result := true;
                 break;
               end;
             end;
           end;
         end;
         result := tabExists(TAB_MAGIC);
         wait(2000 + random(300));
       until ((getSystemTime > t) or (result));
       if (result) then
         addToSRLLog('PB_Exit: Clicked exit cave with backup')
       else
         addToSRLLog('PB_Exit: Failed to exit')
     end;
    end;
    
    (**
     * Author: Coh3n & DemiseScythe
     * Description: Solves the Pinball random.
     *)
    function PB_Solve(): boolean;
    var
      t: integer;
    begin
      if (not loggedIn()) then
        exit;
    
      t := (getSystemTime + (15 * 60000)); // maximum 15 minutes
      doConversation('', false);
    
      repeat
        if (PB_GetScore = PB_SCORE_10) then // length of "Score: 10"
        begin
          if (PB_Exit()) then
          begin
            result := true;
            break;
          end;
        end else
          PB_TagPost();
    
        wait(500 + random(200));
      until(result or (getSystemTime > t));
    end;
    That sounds right - if you come up with fixes you should send pull requests for the include. That goes for everyone! Ideally I suppose they could be posted/tested here (or somewhere on forums) first. I know Flight had also done some work on randoms as well that I don't think was pushed to the official OSR (but it should be).

  17. #217
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Edit: I fixed the frog random and a few others..
    Also if there were a subforum for anti-rand development and not just this 1 thread, I'd be all over that. It's too jumbled in here to post updates for each random.. Is it too much to have a thread for each random?
    Last edited by Krazy_Meerkat; 12-14-2013 at 01:05 PM.

  18. #218
    Join Date
    Sep 2012
    Posts
    71
    Mentioned
    2 Post(s)
    Quoted
    26 Post(s)

    Default

    Frog cave Bitmap screenshot if needed
    http://imgur.com/Vs2DHJa

  19. #219
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    I was getting a crazy amount of randoms so I decided to post the ones that I have fixed here..

    Fixed the text options for the frog random.. Credits to Flight for the conversation-handling (adapted from Frog_Solve2). I re-worked the Frog_WalkCenter method because dtm-finding no longer works on the minimap. Added compass handling. Ran it through a few times to make sure everything worked.
    You can make the edits Flight recommends to FindTalk; (which handle frogs before you enter the cave) and they will not clash with the frog solver. Frog_Solve2 method is included and does not use cave-walking (because you will not be in the cave when it gets called).
    frog.simba
    Code:
    (*
    Frog
    ====
    
    Stores all the routines to solve the Frog random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    *)
    
    var
      O_MouseSpeed, FROG_ISLAND_DTM, FROG_ISLAND_DTM_BACKUP, FROG_CROWN_BMP, DTM_Royal_Frog: Integer;
      Deg : Extended;
    
    const
      FROG_YELLOW             = 7986172;
      FROG_RED                = 3097339;
      FROG_GREEN              = 879885;
      FROG_SWAMP              = 8031312;
      FROG_CROWN              = 1095911;
      FROG_CROWN_COLOR_BACKUP = 633312;
    
    //function Frog_Speakto: boolean; forward;
    function Frog_IsTalkingTo: boolean; forward;
    function Frog_FindFrog: boolean; forward;
    
    (*
    DoConversationEx
    ~~~~~~~~~~~~~~
    
    .. code-block:: pascal
    
        function DoConversationEx(resultText: TStringArray; clickresult: boolean): boolean;
    
    Goes through the initial dialog of a random.  Will keep clicking to continue
    until any of the conversation's 'resultText' is found.  Will click to continue when
    any 'resultText' is found if 'clickresult' is set to true.  Set 'resultText' to ['']
    to click continue until conversation is over.
    
    .. note::
    
        Author: Coh3n, Flight
        Last Modified: Jun. 15th, 2013 by Flight
    
    Example:
    
    .. code-block:: pascal
    
        if (DoConversationEx(['thank','nk you'], true)) then
          writeln('Finished conversation');
    *)
    function DoConversationEx(resultText: TStringArray): boolean;
    var
      t,i: integer;
    begin
      while (t < 25) do // max of 25 "click to continue's"
      begin
        if (length(resultText) > 0) then
          for i:=0 to high(resultText) do
            if (findNPCChatText(resultText[i], nothing)) then
            begin
              result := true;
              exit;
            end;
    
        // break if there's no more conversation
        if (not clickContinue(true)) then
          break;
    
        wait(100 + random(200));
        inc(t);
      end;
    end;
    
    (**
     * Author: Justin
     * Description: Detects if we are in the Frog Random. Small chance it would
     * fail to detect due to the frogs being off-screen, checks for Music Track too.
     *)
    function Frog_Detect(): boolean;
    begin
      if not (tabExists(TAB_MAGIC)) then
      begin
        if Length(GetMinimapDots('npc')) >= 4 then
          if PercentBlackMM >= 35 then
            if (GetMusic = 'Frooland') then
            begin
              Result := true;
              exit;
            end;
        if (CountColorTolerance(FROG_GREEN, MSX1, MSY1, MSX2, MSY2, 30) >= 100) then
          if (CountColorTolerance(FROG_RED, MSX1, MSY1, MSX2, MSY2, 30) >= 20) then
            Result := (CountColorTolerance(FROG_YELLOW, MSX1, MSY1, MSX2, MSY2, 30) >= 5);
      end;
    end;
    
    (**
     * Author: Justin
     * Description: Gets our player ready to solve the random.
     *)
    procedure Frog_Setup();
    begin
      if (not LoggedIn()) then
        exit;
      SetAngle(SRL_ANGLE_HIGH);
      MakeCompass('n');
      O_MouseSpeed := MouseSpeed;
      MouseSpeed := 26;
    end;
    
    (**
     * Author: Xtrapsp
     * Description: Loads the DTMs that are used within the random.
     *)
    procedure Frog_Set_DTMS;
    begin
      FROG_ISLAND_DTM := DTMFromString('mrAAAAHic42BgYDjJxsBwA4qvA/EpID4MxLuAeBMQtwDV9ABxNRAXA3EuEBcBcQkQ1wJxaJAdg3lxAk4sB1SDDzMSwDAAAMr5E3M=');
      FROG_ISLAND_DTM_BACKUP := DTMFromString('maQEAAHicE2RgYLjGxMDwGIjvMEHY54H4NBSfg+KrQHwTqu4BED8H4idAfAmqfgbQnIlA3AvFE4B4CgNEfB4QLwLipVA8H8qfDZUHqV8JxIGeNgxmRfFw7ONiARYD4RBvWzAGsf3dLVHUIWNWoDmUYkYqYAwAAGpfKPw=');
      FROG_CROWN_BMP := BitmapFromString(1, 3, 'meJyTOfnD5NxvmaOfARoQBa8=');
      DTM_Royal_Frog := DTMFromString('mbQAAAHicY2VgYLgDxLeB+CYQ34OyeRgZGDgZIbQAEPMD8cpOYYbfZ1QZDs4RYziuKcbw+5wxgxxQLTpmxoLBAAB7VQzf');
    end;
    
    (**
     * Author: Xtrapsp
     * Description: Unloads the DTMs that were used within the random.
     *)
    procedure Frog_Free_DTMS;
    begin
      FreeDTM(FROG_ISLAND_DTM);
      FreeDTM(Frog_ISLAND_DTM_BACKUP);
      FreeBitmap(FROG_CROWN_BMP);
      FreeDTM(DTM_Royal_Frog);
    end;
    
    (**
     * Author: Xtrapsp/Justin
     * Description: Walks our player to the center of the map where the
     * Frog Princess is located. If the DTM fails, will use TPA failsafe.
     *)
    function Frog_WalkCenter: boolean;
    var
      TPA: TPointArray;
      T, TPAX, TPAY, sx, sy: Integer;
    begin
      if (not loggedIn()) then
        exit;
      MakeCompass('N');
      MarkTime(T);
      repeat
      if findcolortolerance(TPAX,TPAY,5861233, MMX1+random(MMX2-MMX1-2), MMY1+random(MMY2-MMY1-2), MMX2, MMY2, 19) then
      if (findcolortolerance(sx,sy,FROG_SWAMP, TPAX - 30, TPAY, TPAX - 15, TPAY, 19) and findcolortolerance(sx,sy,FROG_SWAMP, TPAX + 30, TPAY, TPAX + 45, TPAY, 19)) then
      begin
        Mouse(TPAX, TPAY-4, 4, 2, mouse_Left);
        addToSRLLog('Frog_WalkCenter: Moving to center of cave');
          wait(600 + Random(120));
        FFlag(0);
        result := true;
        addToSRLLog('Frog_WalkCenter[Main]: result: ' + BoolToStr(result));
        break;
      end;
        wait(100+random(50));
      until(timeFromMark(T) > 6000);
      if (not(result = true)) then
      begin
        addToSRLLog('Frog_WalkCenter: Unable to find main DTM, Falling back onto backup');
        if (FindColorsTolerance(TPA, FROG_SWAMP, MMX1, MMY1, MMX2, MMY2, 50)) then
        begin
          MiddleTPAEx(TPA, TPAX, TPAY);
          Mouse(TPAX, TPAY, 8, 8, mouse_Left);
          wait(600 + Random(120));
          FFlag(0);
          result := true;
          addToSRLLog('Frog_WalkCenter[Backup]: result: ' + BoolToStr(result));
        end;
      end;
    end;
    
    (**
     * Author: Xtrapsp/Justin
     * Description: Finds the Frog Princess via DTM with a TPA failsafe.
     * If the DTM fails, it will rotate the camera just incase the Frog Princess
     * is off the screen.
     *)
    function Frog_FindFrog: boolean;
    var
      T, Attempt, tmpCTS, i, fx, fy, arL: integer;
      arP: TPointArray;
      ararP: T2DPointArray;
      P: TPoint;
    begin
      addToSRLLog('Frog_FindFrog: Attempting to find the Frog Princess');
      Marktime(T);
      tmpCTS := GetColorToleranceSpeed;
      repeat
        if FindDTM(DTM_Royal_Frog, fx, fy, MSx1, MSy1, MSx2, MSy2) then
        begin
          MMouse(fx-2, fy-2, 2, 2);
          if WaitUpTextMulti(['Frog','to Fr'], 300) then
          begin
            Writeln('Frog_Solve2: Found royal frog');
            ClickMouse2(mouse_right);
            Wait(randomRange(100,250));
            result := waitOptionMulti(['Talk-to Frog','to Fr','Frog'], 500);
            if result then
            begin
              Writeln('Frog_Solve2: Talking to royal frog...');
              break
            end else
              MouseBox(MCx1, MCy1, MCx2, MCy2, mouse_move);
          end;
        end;
        if not result then
        begin
          if FindBitmapToleranceIn(FROG_CROWN_BMP, fx, fy, MSX1, MSY1, MSX2, MSY2, 40)  then
          begin
            MMouse(fx, fy, 4, 4);
            addToSRLLog('Frog_FindFrog: Checking multi uptext');
            wait(150 + random(100));
            if (IsUpTextMultiCustom(['Frog', 'Talk', 'rog'])) then
            begin
                ClickMouse2(mouse_Right);
                Result := WaitOptionMulti(['Talk-to', 'alk-t', 'Frog', 'rog'], 800);
                addToSRLLog('Frog_FindFrog[Backup]: result: ' + BoolToStr(result));
                wait(600 + Random(120));
                FFlag(0);
                if (result) then
                  addToSRLLog('Frog_FindFrog: Found Frog Princess');
                exit;
            end else
              addToSRLLog('Frog_FindFrog: Could not find uptext');
        end else
          begin
            addToSRLLog('Frog_FindFrog: Could not find Frog Princess. Falling onto backup');
            MakeCompass(rs_GetCompassAngleDegrees + RandomRange(85, 95));
            wait(800+Random(400));
            ColorToleranceSpeed(2);
            SetColorSpeed2Modifiers(0.02, 0.76);
            if (FindColorsTolerance(arP, FROG_CROWN, MSX1, MSY1, MSX2, MSY2, 12)) then
            begin
              addToSRLLog('Frog_FindFrog: Found TPA color, Moving mouse to TPA');
              SortTPAFrom(arP, Point(MSCX, MSCY));
              ararP := SplitTPAEx(arP, 8, 8);
              arL := High(ararP);
              for i := 0 to arL do
              begin
                P := MiddleTPA(ararP[i]);
                MMouse(P.x, P.y, 5, 5);
                addToSRLLog('Frog_FindFrog: Checking multi uptext');
                Wait(100 + Random(100));
                if (IsUpTextMultiCustom(['Frog', 'Talk', 'rog'])) then
                begin
                  ClickMouse2(mouse_Right);
                  Result := WaitOptionMulti(['Talk-to', 'alk-t', 'Frog', 'rog'], 500);
                  addToSRLLog('Frog_FindFrog[Backup]: result: ' + BoolToStr(result));
                  wait(600 + Random(120));
                  FFlag(0);
                  exit;
              end else
                addToSRLLog('Frog_FindFrog: Could not find uptext');
              end;
            end else
             addToSRLLog('Frog_FindFrog[Backup]: Unable to find TPA');
          end;
        end;
        Inc(Attempt);
        addToSRLLog('Frog_FindFrog: Attempt: ' + inttostr(Attempt));
      until ((Attempt > 5) or (Result));
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      exit;
    
    end;
    
    {(**
     * Author: Xtrapsp/Justin
     * Description: Handles talking to the Frog Princeess.
     *)
    function Frog_SpeakTo: boolean;
    var
      T, Attempt: integer;
      TPA: TPointArray;
    begin
      addToSRLLog('Frog_SpeakTo: Attempting to speak to the Frog Princess');
      Marktime(T);
      repeat
        if ClickDTMRotatedIn(FROG_CROWN_DTM, MSX1, MSY1, MSX2, MSY2, - Pi, Pi, Pi / 30, ['rog'], mouse_Left) then
        begin
          addToSRLLog('Frog_SpeakTo: Found Frog Princess, Clicking Frog Princess');
          result := true;
          addToSRLLog('Frog_SpeakTo[Main]: result: ' + BoolToStr(result));
          Wait(3500 + Random(1000));
          exit;
        end
        else
        begin
          addToSRLLog('Frog_SpeakTo: Could not find Frog Princess. Falling onto backup');
          if (FindColorsSpiralTolerance(MSCX, MSCY, TPA, FROG_CROWN_COLOR_BACKUP, MSX1, MSY1, MSX2, MSY2, 25)) then
          begin
            Mouse(TPA[0].X, TPA[0].Y, 2, 2, mouse_Move);
            if IsUpTextMultiCustom(['Frog', 'Talk', 'rog']) then
              ClickMouse2(mouse_Left);
            wait(600 + Random(120));
            FFlag(0);
            Result := true;
            addToSRLLog('Frog_SpeakTo[Backup]: result: ' + BoolToStr(result));
          end;
        end;
        Inc(Attempt);
        MakeCompass(rs_GetCompassAngleDegrees + RandomRange(85, 95));
      until ((Attempt > 20) or (Frog_IsTalkingTo))
      if (Attempt > 20) then
        Frog_WalkCenter;
      exit;
    end;}
    
    (**
     * Author: Xtrapsp/Justin
     * Description: Detects if we are talking to the Frog Princess or just a Frog.
     *)
    function Frog_IsTalkingTo: boolean;
    var
      T, ft, i, Attempt: integer;
      responses: TStringArray;
    begin
      addToSRLLog('Frog_IsTalkingTo: Speaking to the Frog Princess');
      responses := ['very','orry','hange','lrigh','Okay','kay.','I supp','pose so','yeah','Yeah','Sure','ure'];
      MarkTime(ft);
      repeat
        if areTalking then break;
        wait(100+random(50));
      until(timeFromMark(ft) > 6000);
      MarkTime(ft);
      repeat
        if DoConversationEx(responses) then
        begin
          Writeln('Frog_Solve2: Reached response');
          for i:=0 to High(responses) do
            if findTextTPA(0, 5, MCx1, MCy1, MCx2, MCy2, responses[i], CharsNPC07, ClickLeft) then
            begin
              Writeln('Frog_Solve2: Chose correct option');
              ClickToContinue;
              break;
            end;
        end;
      until(timeFromMark(ft) > 15000);
    
      MarkTime(ft);
      repeat
        if (not(Frog_Detect())) then
        begin
          Result := True;
          Writeln('Frog_Solve2: Successfully solved the Frog random!');
          break;
        end;
          Wait(100 + Random(50));
      until(timeFromMark(ft) > 10000);
    
      if not result then
      begin
      repeat
        Result := FindNPCChatText('Hmph. Have you come to apologize for ignoring me?', Nothing);
        if (not(result)) then result:= FindNPCChatText('change', Nothing);
        if (Result or (Attempt > 6)) then
        begin
          addToSRLLog('Frog_IsTalkingTo[backup]: Continuing to chat to Frog Princess');
          Wait(1000 + Random(500));
          DoConversation('', true);
          Wait(1100 + Random(500));
          Mouse(137, 399, 252, 7, True);
          Wait(1100 + Random(500));
          Mouse(153, 449, 130, 5, True);
          Wait(1100 + Random(500));
          Mouse(243, 450, 130, 4, True);
          Wait(2100 + Random(1500));
          exit;
        end
        else
          addToSRLLog('Frog_IsTalkingTo[backup]: Could not continue chat with Frog Princess');
      until ((Attempt > 7) or (TimefromMark(T) > 50000) or Result);
      end;
      if (Attempt > 7) then
      begin
        addToSRLLog('Frog_IsTalkingTo: Attempts are greater than 5');
        Wait(3000 + Random(1000));
        result := false;
      end;
    end;
    
    (**
     * Author: Justin & Flight
     * Modified by: Krazy_Meerkat
     * Description: Handles solving the random event.
     *)
    function Frog_Solve2(): boolean;
    begin
      if (not loggedIn()) then
        exit;
     Deg := RS_GetCompassAngleDegrees;
     Wait(100 + random(50));
      Frog_Setup();
          if Frog_FindFrog then
            result := Frog_IsTalkingTo;
      MouseSpeed := O_MouseSpeed;
      if (not result) then
        addToSRLLog('Frog_Solve2: Frog solver failed or timed out');
      MakeCompass(Deg);
    end;
    
    (**
     * Author: Justin
     * Description: Handles solving the random event.
     *)
    function Frog_Solve(): boolean;
    var
      t: integer;
    begin
      if (not loggedIn()) then
        exit;
     Deg := RS_GetCompassAngleDegrees;
     Wait(100 + random(50));
      t := (getSystemTime + (10 * 60000));
      Frog_Setup();
      repeat
        if Frog_WalkCenter then
          if Frog_FindFrog then
            result := Frog_IsTalkingTo;
      until (result or (getSystemTime > t));
      MouseSpeed := O_MouseSpeed;
      if (not result) then
        addToSRLLog('Frog_Solve: Frog solver failed or timed out');
      MakeCompass(Deg);
    end;
    Fixed the pillory cage random. Object scanning was freezing up and returning low values for the locks, added wait times and minimum value requirements. Fixed compass angle issues. Edit: Improved cage-finding routine.
    pillory.simba
    Code:
    (*
    Pillory
    =======
    
    Stores all the routines to solve the Pillory random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    This solver uses color counting to determine the shape
    of the lock and which key to use.
    
    *)
    
    procedure PL_Message(Message: string);
    begin
      addToSRLLog('[Pillory Random] ' + Message);
    end;
    
    function PL_LockScreen: Boolean;
    begin
      Result := (LoggedIn and (GetColor(497, 34) = 65536));
    end;
    
    function PL_Detect: boolean;
    var
      tpa: TPointArray;
    begin
      if (not TabExists(TAB_OPTIONS)) and (TabExists(TAB_FRIENDS)) then
      begin
        // red doors of the cages
        FindColorsTolerance(tpa, 235, MMCX - 15, MMCY - 15, MMCX + 15, MMCY + 15, 20);
        Result := (inRange(length(tpa), 3, 18));
      end;
    end;
    
    (**
     * Author: DannyRS
     * Last modified 15/03/2013 By DannyRS
     * Description: Opens Cage Interface
     *)
    function PL_ClickCage: Boolean;
    var
      t, x, y: Integer;
    begin
      Result := False;
    
      t := GetSystemTime;
    
      if (not LoggedIn) then Exit;
    
      Result := PL_LockScreen;
    
      if (not Result) then
      begin
        repeat
          x:= MSCX;
          y:= MSCY;
          if (not(IsUpTextMultiCustom(['Unlock','lock','Cage','age']))) then
            if FindColorSpiralTolerance(x, y, 9738912, MSX1, MSY1, MSX2, MSY2, 19) or FindColorSpiralTolerance(x, y, 1118484, MSX1, MSY1, MSX2, MSY2, 19) then
            begin
              MMouse(x,y,4,4);
            end else
              MMouse(243,143,80,65);
    
          Wait(RandomRange(90, 270));
    
          if (IsUpTextMultiCustom(['Unlock','lock','Cage','age'])) then
          begin
            ClickMouse2(mouse_left);
            if (waitFunc(@PL_LockScreen, 50, 5000)) then
            begin
              PL_Message('[PL_ClickCage] Opened Lock Screen');
              Wait(RandomRange(190, 270));
              Result := True;
            end else
              PL_Message('[PL_ClickCage] Failed to open Lock Screen');
          end else
            MMouse(243,143,80,65);
        until (Result) or (GetSystemTime - t > 38000);
      end;
    end;
    
    (**
     * Author: DannyRS
     * Last modified 15/03/2013 By DannyRS
     * Description: Clicks a key 0-2
     *)
    function PL_ClickKey(Slot: Integer): Boolean;
    var
      p: TPoint;
    begin
      Result := False;
    
      if (not PL_LockScreen) then Exit;
    
      p := Point(209 + (Slot*93), 251);
    
      MMouse(RandomRange(p.x - 2, p.x + 2), RandomRange(p.y - 4, p.y + 4), 0, 0);
    
      ClickMouse2(mouse_left);
    
      Result := True;
    end;
    
    (**
     * Author: DannyRS
     * Last modified 9/04/2013 By DannyRS
     * Description: Scans for lock type
     *)
    function PL_GetLock: String;
    var
      CNum,Count,CountTime,WatchTime: Integer;
    begin
      Result := '';
      WatchTime := RandomRange(9000,10000);
      SetColorToleranceSpeed(2);
      SetToleranceSpeed2Modifiers(0.21, 2.01);
      MarkTime(CountTime);
      Count:= 100;
      repeat
        CNum := CountColorTolerance(1057067, 60, 65, 150, 150, 10);
        if (CNum > Count) then
          Count := CNum;
          wait(50 + random(50));
      until (TimeFromMark(CountTime) > WatchTime);
      if (Count > 800) and (Count < 1000) then Result := 'square';
      if (Count > 570) and (Count < 799) then Result := 'triangle';
      if (Count > 400) and (Count < 569) then Result := 'diamond';
      if (Count > 1001) and (Count < 1600) then Result := 'circle';
      PL_Message('[PL_GetLock] Lock Found: ' + Result + ' [' + ToStr(Count) + ']');
    end;
    
    (**
     * Author: DannyRS
     * Last modified 9/04/2013 By DannyRS
     * Description: Scans for key types
     *)
    function PL_GetKeys: TStringArray;
    var
      C1,C2,C3,CNum,Count,WatchTime: Integer;
    begin
      SetLength(Result, 3);
    
      SetColorToleranceSpeed(2);
      SetToleranceSpeed2Modifiers(0.43, 2.81);
    
      MarkTime(WatchTime);
      Result[0] := '';
      Count := 100; CNum := 0;
      repeat
        CNum := CountColorTolerance(1516846, 180, 170, 235, 260, 7);
    
        case CNum of
          286: Result[0] := 'triangle';
          493: Result[0] := 'diamond';
          506: Result[0] := 'circle';
          729: Result[0] := 'square';
        end;
    
        if (CNum > Count) then
          Count := CNum;
        wait(50 + random(50));
    
      until (not (Result[0] = '')) or (TimeFromMark(WatchTime) > 10000);
    
      if (Result[0] = '') then
      begin
        if InRange(Count, 250, 350) then Result[0] := 'triangle';
        if InRange(Count, 400, 500) then Result[0] := 'diamond';
        if InRange(Count, 501, 600) then Result[0] := 'circle';
        if InRange(Count, 670, 1300) then Result[0] := 'square';
      end;
    
      C1 := Count;
    
      MarkTime(WatchTime);
      Result[1] := '';
      Count := 100; CNum := 0;
      repeat
        CNum := CountColorTolerance(1516846, 265, 170, 345, 260, 7);
    
        case CNum of
          286: Result[1] := 'triangle';
          493: Result[1] := 'diamond';
          506: Result[1] := 'circle';
          729: Result[1] := 'square';
        end;
    
        if (CNum > Count) then
          Count := CNum;
        wait(50 + random(50));
    
      until (not (Result[1] = '')) or (TimeFromMark(WatchTime) > 10000);
    
      if (Result[1] = '') then
      begin
        if InRange(Count, 250, 350) then Result[1] := 'triangle';
        if InRange(Count, 400, 500) then Result[1] := 'diamond';
        if InRange(Count, 501, 600) then Result[1] := 'circle';
        if InRange(Count, 670, 1300) then Result[1] := 'square';
      end;
    
      C2 := Count;
    
      MarkTime(WatchTime);
      Result[2] := '';
      Count := 100; CNum := 0;
      repeat
        CNum := CountColorTolerance(1516846, 365, 170, 430, 260, 7);
    
        case CNum of
          286: Result[2] := 'triangle';
          493: Result[2] := 'diamond';
          506: Result[2] := 'circle';
          729: Result[2] := 'square';
        end;
    
        if (CNum > Count) then
          Count := CNum;
        wait(50 + random(50));
    
      until (not (Result[2] = '')) or (TimeFromMark(WatchTime) > 10000);
    
      if (Result[2] = '') then
      begin
        if InRange(Count, 250, 350) then Result[2] := 'triangle';
        if InRange(Count, 400, 500) then Result[2] := 'diamond';
        if InRange(Count, 501, 600) then Result[2] := 'circle';
        if InRange(Count, 670, 1300) then Result[2] := 'square';
      end;
    
      C3 := Count;
    
      PL_Message('[PL_GetKeys] Keys Found: '+
          Result[0]+' ['+IntToStr(C1)+']'+' '+
          Result[1]+' ['+IntToStr(C2)+']'+' '+
          Result[2]+' ['+IntToStr(C3)+']');
    end;
    
    (**
     * Author: DannyRS
     * Last modified 15/03/2013 By DannyRS
     * Description: Solves the Pillory Random Event
     *)
    function PL_Solve: Boolean;
    var
      i, t, keysolves, tmpCTS: Integer;
      tmpHM, tmpSM, Deg: Extended;
      lock: String;
      keys: TStringArray;
    begin
      Result := False;
      keysolves := 0;
    
      tmpCTS := GetColorToleranceSpeed;
      GetToleranceSpeed2Modifiers(tmpHM, tmpSM);
    
      if (not LoggedIn) then Exit;
    
      t := GetSystemTime;
    
     Deg := RS_GetCompassAngleDegrees;
     Wait(100 + random(50));
     MakeCompass('N');
      //if (not PL_ClickCage) then Exit;
    
      repeat
    
        Result := (TabExists(TAB_OPTIONS));
        if (Result) then Break;
    
        // open the lock screen if it's not already open
        if (not PL_LockScreen) then PL_ClickCage;
    
        lock := PL_GetLock;
        keys := PL_GetKeys;
    
        for i := 0 to 2 do
          if (keys[i] = '') then
          begin
             PL_Message('[ERROR] [PL_GetKeys] Failed to get all keys');
             Break;
          end;
    
          if (lock = '') then
          begin
             PL_Message('[ERROR] [PL_GetLock] Failed to get lock type');
             Continue;
          end;
    
          for i := 0 to 2 do
          if (keys[i] = lock) then
          begin
            PL_Message('[PL_Solve] Clicking key : ' + keys[i]);
            if PL_ClickKey(i) then
            begin
              keysolves := keysolves + 1;
              Wait(RandomRange(1500, 2000));
            end;
          end;
    
        Result := ((keysolves > 2) and (not PL_LockScreen)) or
            (TabExists(TAB_OPTIONS));
    
      until (Result) or (GetSystemTime - t > 120000);
    
      if (Result) then MakeCompass(Deg);
    
      SetColorToleranceSpeed(tmpCTS);
      SetToleranceSpeed2Modifiers(tmpHM, tmpSM);
    
      if (not Result) then
      begin
        if (GetSystemTime - t > 120000) then
          PL_Message('[ERROR] Pillory solver timed out');
      end else
        Wait(RandomRange(800, 1200));
    end;
    Fixed the drill demon random. Added 1 new bitmap for each sign, had no problems detecting all 4. Ran it through a few times, changing worlds to test colour difference.
    demon.simba
    Code:
    (*
    Drill Demon
    ===========
    
    Stores all the routines to solve the Drill Demon random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    This solver uses Deformed BMPs to locate the signs
    to solve the Drill Demon (Sergeant Damien) random.
    
    *)
    
    procedure DD_Message(Message: String);
    begin
      addToSRLLog('[DemonDrill Random] ' + Message);
    end;
    
    function DD_Detect(): Boolean;
    begin
      if (not TabExists(TAB_OPTIONS)) and (not TabExists(TAB_EMOTES)) then
        Result := (GetMusic = 'CorPoral Punisbment');
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Moves the player back to the center of the random
     * Note: Inspired by Le Jingle
     *)
    function DD_ResetPosition: Boolean;
    var
      WallTPA: TPointArray;
      WallATPA: T2DPointArray;
      tb: TBox;
      p: TPoint;
      //pa: TPointArray;
    begin
      Result := False;
    
      if (not LoggedIn) then Exit;
    
      SetColorToleranceSpeed(1);
      SetToleranceSpeed2Modifiers(0.02, 0.02);
      FindColorsTolerance(WallTPA, 15593957, 600, 58, 690, 110, 70);
      SplitTPAExWrap(WallTPA, 5, 5, WallATPA);
      SortATPASize(WallATPA, True);
    
      if (Length(WallATPA) < 1) then Exit;
    
      //SMART_DrawBoxEx(True, False, WallATPA[0], clGreen);
    
      tb := GetTPABounds(WallATPA[0]);
      p := MiddleBox(tb);
    
      //Seems white alone is accurate enough to leave this out - Danny
      //pa := GetMiniMapDots('yellow');
      //if (Length(pa) < 1) then Exit;
      //if (not PointInBox(pa[0], tb)) then Exit;
    
      MMouse(p.x, RandomRange(p.y, p.y + 2), 0, 0);
      ClickMouse2(mouse_left);
    
      Wait(RandomRange(300, 400));
      Flag;
      Wait(RandomRange(800, 1200));
    
      Result := True;
    end;
    
    function DD_TalkingToDemon: Boolean;
    begin
      Result := (Trim(GetNPCChatName) = 'SergeantDamien');
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Talks to Sergeant Damien
     *)
    function DD_TalkDemon: Boolean;
    var
      DemonTPA: TPointArray;
      DemonATPA: T2DPointArray;
      x, y, i, Attemps: Integer;
    begin
      Result := False;
    
      if (DD_TalkingToDemon) then
      begin
        Result := True;
        Exit;
      end;
    
      repeat
    
        if (Attemps > 6) then Break;
    
        SetColorToleranceSpeed(2);
        SetToleranceSpeed2Modifiers(0.15, 1.61);
        FindColorsTolerance(DemonTPA, 994406, MSX1, MSY1, MSX2, MSY2, 16);
        SplitTPAExWrap(DemonTPA, 50, 100, DemonATPA);
        SortATPASize(DemonATPA, True);
    
        if (Length(DemonATPA) < 1) then
        begin
          Attemps := Attemps + 1;
          Wait(RandomRange(200, 400));
          Continue;
        end;
    
        for i := 0 to High(DemonATPA) do
        begin
          if (Length(DemonATPA[i]) < 50) then Continue;
          MiddleTPAEx(DemonATPA[i], x, y);
          MMouse(RandomRange(x - 5, x + 5), RandomRange(y - 5, y + 5), 0, 0);
          ClickMouse2(mouse_right);
          Wait(RandomRange(30, 50));
          if (ChooseOptionMulti(['Talk','alk-to'])) then
          begin
            if (WaitFunc(@DD_TalkingToDemon, 50, 25000)) then
            begin
              DD_Message('[DD_TalkDemon] Talked to demon');
              Result := True;
              Exit;
            end else
              DD_Message('[DD_TalkDemon] Failed to Talked to demon');
          end;
        end;
        Attemps := Attemps + 1;
    
      until (Result) or (Attemps > 6);
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Gets the TBoxes of the green signs
     *)
    function DD_GetSigns: TBoxArray;
    var
      ESignsTPA: TPointArray;
      ESignsATPA: T2DPointArray;
      SignsSorted: Boolean;
      i: Integer;
    begin
      SetColorToleranceSpeed(1);
      SetToleranceSpeed2Modifiers(0.02, 0.02);
      FindColorsTolerance(ESignsTPA, 4553552, MSX1, MSY1, MSX2, MSY2, 30);
      SplitTPAExWrap(ESignsTPA, 70, 60, ESignsATPA);
    
      repeat
        SignsSorted := True;
        for i := 0 to High(ESignsATPA) do
        begin
          if (Length(ESignsATPA[i]) < 5) then
          begin
            DeleteValueInATPA(ESignsATPA,i);
            SignsSorted := False;
            Break;
          end;
        end;
      until (SignsSorted);
    
      SetLength(Result, Length(ESignsATPA));
    
      for i := 0 to high(ESignsATPA) do
      begin
        Result[i] := GetTPABounds(ESignsATPA[i]);
      end;
    
      DD_Message('[DD_GetSigns] Number of signs located : ' +
          IntToStr(Length(ESignsATPA)));
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description:
     *  Compares bitmaps to the signs and tries to
     *  return it's position, roughly centered
     *)
    function DD_FindSign(WhichSign: String): TPoint;
    var
      SB: TBoxArray;
      x, y, i, ib, hb: Integer;
      Saccuracy: Extended;
      SBMP: TIntegerArray;
    begin
      Result := Point(-1, -1);
    
      SB := DD_GetSigns;
      if (Length(SB) < 1) then Exit;
    
      SetLength(SBMP, 3);
    
      hb := High(SBMP);
    
      SetColorToleranceSpeed(1);
      SetToleranceSpeed2Modifiers(0.02, 0.02);
    
      case LowerCase(WhichSign) of
        'jog':        begin
                        SBMP[0] := BitmapFromString(14, 15, 'meJxzrw1KnFAOQe5IbAgXDRGvEo' +
                        '6y5zQDEVw7Vlk4wm8UmktooRJNMS4PojkVlxq4p5BDDKsaTBuRVWI' +
                        'qw2UvVmUE44VaiolMEkAEAE9f+0k=');
                        SBMP[1] := BitmapFromString(26, 17, 'meJxzqwl0w0AJfWUQhMYmD2E1jR' +
                        'IDIShrdhMQwa2grmlkGwgxB4IodxVaMFLXNGQDKYwRNM+SHcvIQQf' +
                        'XS57b0CICOQVSYhSmH8k2jSrxOJhNc0PNVhQiKhYdbuQmKgBkSPbW');
                        SBMP[2] := BitmapFromString(29, 10, 'meJxzrQ5wJRrF9ZUSr3gwGItsMh' +
                        'qXbJQ5qxGI4EZRxViImRBjIaZRbizcTGR3UmgsmpnUCltcxlIrVKl' +
                        'rLNxk4tUDAIc3Qs8=');
                      end;
        'starjumps':  begin
                        SBMP[0] := BitmapFromString(16, 16, 'meJxzrw1yx0CJE8ohCFMKK4Krx9' +
                        'SSu7AdiEg1H6su/GogXPwIlyHEqMSlnhhH0kg9hS6nonqsyrBqgcQ' +
                        '7LjOJUY/VXswEhifGkZMfAK38Sfc=');
                        SBMP[1] := BitmapFromString(33, 17, 'meJxzqwl0Ixol9JUBEfHqSUUQ8+' +
                        'lmC4Xm5CxohSNaqMeqkSCilo+objhBu6ge0cPAClrHAi4rqGgLHZI' +
                        'TprHUtQWXsym3Al4Q4XIwsjh5pRa8uMPjWmTzyS4Y4bbgCUZiSngA' +
                        'a5KX0w==');
                        SBMP[2] := BitmapFromString(37, 16, 'meJxzrQ5wJR3F9ZXCERnacaHs+S' +
                        '34raOiXXAbIYjqJhNjKfGIPjbSx5t0C1U6RyI97Ro21tEtNdLHOuR' +
                        'iCtN8qtuIXDBiNZlGHgQiXMbSIgbh1uGJUyKrJAA7N7QN');
                      end;
        'situps':     begin
                        SBMP[0] := BitmapFromString(32, 12, 'meJxzrwl0R0U5C9uAyB1DnCoIYj' +
                        'gdzCfPCoK6KDGfoC5kw0m1ghgtmOYTaQWRWpAVEG8+msm4tGAqI9I' +
                        'KrBoJBiDWsCKIsJqf0F8GRJiuJcN8ZKOQDYeLE4xugobDzYewSUoY' +
                        'xBiObD7QBABMTOo0');
                        SBMP[1] := BitmapFromString(36, 14, 'meJxzqwl0GwQoZ0ErENHNIgrtIl' +
                        'I73C7yrCNeL7JFZNhFkl40u0iyjiSNmBYRbxepepHVUBIaboRSMpr' +
                        'J+O3C6gus2km1i3gE0ZvQV0aMO4lxOR4EtAWCkEXgZqJJUWIX3CKs' +
                        'BqLJEh8pBO1C9g6dEQA0UXaL');
                        SBMP[2] := BitmapFromString(37, 16, 'meJxzrQ5wHRwoe34LENHTLgqtI1' +
                        '473DqybSReL7Jd5FlHkl4060i1kSSNmHaRZB2pepGVkWojmnqCGtE' +
                        'MpyRYiLcOf8ASg4hJMJiyZFsX11cKRMhcuJkQKbgswWRDpF3I1mHa' +
                        'BZElJpUSaRcEkZSDyLCRVPOHEwIAf3vRcQ==');
                      end;
        'pushups':    begin
                        SBMP[0] := BitmapFromString(37, 16, 'meJxzrw1KnFAOQe61QXRAdLZuYF' +
                        'HuwnYIoqddyIjO1tHIakwzaWc1HkNoYSlB7VQMZ+K1ELSUGHMocSF' +
                        'J9sKLFMpjgZ6pmnaJihJ7aWcjWmTRoQrAtAsAxiXG8w==');
                        SBMP[1] := BitmapFromString(39, 16, 'meJxzqwl0qwlM6CuDIDcwlz5oYC' +
                        '2ls73IKGdBKwTR30ZkNCCW0tQBBG2kugOwmkZre/GbQwt7iTeEin6' +
                        'nRAsZboCUCZSEFalpD7ksonpqHFRZntb2okUina1DthEAClrmig==');
                        SBMP[2] := BitmapFromString(43, 16, 'meJxzrQ5wBaO4vlI4coUJ0hMhO2' +
                        'Cg3ICJsue3ANHA2o6MBtZ2OjuGoANo6hhMk+npBjxm0scNBE2jaWg' +
                        'QbwiNkgcZuqiSVuEFICUBOLAZh57phFqOoacb0OJ6AK3GtB0AjuAl' +
                        '9Q==');
                      end;
      end;
    
      for i := 0 to High(SB) do
      begin
        for ib := 0 to hb do
        begin
          if (Result.X > 0) or (Result.Y > 0) then Break;
          if (SB[i].X1 > SB[i].X2) or (SB[i].Y1 > SB[i].Y2) then Continue;
    
          if FindDeformedBitmapToleranceIn(SBMP[ib], x, y, SB[i].X1-2, SB[i].Y1-2,
            SB[i].X2+2, SB[i].Y2+2, 2, 4, False, Saccuracy) then
            begin
              Result := Point(x + 20, y + 7);
              DD_Message('[DD_FindSign] Matching sign found at : ' + ToStr(Result));
              Break;
            end;
        end;
      end;
    
      for ib := 0 to hb do
        FreeBitmap(SBMP[ib]);
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Attemps to solve the Drill Demon random
     *)
    function DD_Solve(): boolean;
    var
      p: TPoint;
      t, tmpCompass, tmpCTS, MMoves, debugColorCount: Integer;
      tmpHM, tmpSM: Extended;
      MatName, LastMatt: String;
    begin
      Result := False;
    
      if (not LoggedIn) then Exit;
    
      t := GetSystemTime;
    
      tmpCTS := GetColorToleranceSpeed;
      GetToleranceSpeed2Modifiers(tmpHM, tmpSM);
      tmpCompass := Round(rs_GetCompassAngleDegrees);
    
      SetAngle(SRL_ANGLE_LOW);
      MakeCompass('N');
    
      repeat
    
        Result := TabExists(TAB_MAGIC);
    
        if (Result) then Break;
    
        if (not DD_TalkDemon) then
        begin
          DD_ResetPosition;
          Continue;
        end;
    
        Wait(RandomRange(1200, 1600));
    
        debugColorCount := CountColor(0, MCX1, MCY1, MCX2, MCY2);
        case debugColorCount of
          687,988,691 : MatName := 'jog';
          707,711     : MatName := 'starjumps';
          569,573     : MatName := 'situps';
          637,938,641 : MatName := 'pushups';
          else
          begin
            ClickToContinue;
            Wait(RandomRange(1200, 1500));
            Continue;
          end;
        end;
        DD_Message('[DD_Solve] Last color count: ' + inttostr(debugColorCount));
        LastMatt := '';
        if (LastMatt = MatName) then
        begin
          MMoves := 0;
    
          DD_Message('[DD_Solve] Already standing on the matt : ' + MatName);
          DD_Message('[DD_Solve] Using matt : ' + MatName + ' again');
    
          repeat
            MMouse(246, 184, 40, 30);
            MMoves := MMoves + 1;
            Wait(RandomRange(90, 340));
            if (IsUpTextMultiCustom(['Use','xercise','mat'])) then
            begin
              ClickMouse2(mouse_right);
              Wait(RandomRange(40, 90));
              if (ChooseOptionMulti(['Use'])) then
              begin
                Wait(RandomRange(1200, 1500));
                if (WaitFunc(@DD_TalkingToDemon, 50, 15000)) then
                begin
                  DD_Message('[DD_Solve] Used matt successfully');
                  LastMatt := MatName;
                  Break;
                end else
                begin
                  DD_Message('[ERROR] Failed to use matt');
                  Break;
                end;
              end;
            end;
          until (MMoves > 10);
    
          Continue;
        end;
    
        DD_Message('[DD_Solve] Walking to center to search for sign');
    
        if (not DD_ResetPosition) then
        begin
          DD_Message('[ERROR] Failed to walk to center');
          Continue;
        end;
    
        DD_Message('[DD_Solve] Searching for sign : ' + MatName);
    
        p := DD_FindSign(MatName);
    
        if (p.x < 0) or (p.y < 0) then
        begin
          DD_Message('[ERROR] Failed to find sign : ' + MatName);
          Continue;
        end;
    
        MMoves := 0;
    
        DD_Message('[DD_Solve] Searching for matt : ' + MatName);
    
        repeat
    
          MMouse(p.x - 10, p.y + 64, 50, 30);
    
        //SMART_DrawBoxEx(True,False,IntToBox(p.x-10,p.y+64,p.x+40,p.y+94),clGreen);
    
          MMoves := MMoves + 1;
          Wait(RandomRange(90, 340));
          if (IsUpTextMultiCustom(['Use','xercise','mat'])) then
          begin
            ClickMouse2(mouse_right);
            Wait(RandomRange(40, 90));
            if (ChooseOptionMulti(['Use'])) then
            begin
              Wait(RandomRange(1200, 1500));
              if (WaitFunc(@DD_TalkingToDemon, 50, 15000)) then
              begin
                DD_Message('[DD_Solve] Used matt successfully');
                LastMatt := MatName;
                Break;
              end else
              begin
                DD_Message('[ERROR] Failed to use matt');
                Break;
              end;
            end;
          end;
        until (MMoves > 10);
    
      Result := TabExists(TAB_MAGIC);
    
      until (Result) or (GetSystemTime - t > 240000);
    
      if (not Result) then
      begin
        if (GetSystemTime - t > 240000) then
          DD_Message('[ERROR] DrillDemon solver timed out');
      end else
        Wait(RandomRange(1200, 1600));
    
      SetAngle(SRL_ANGLE_HIGH);
      MakeCompass(tmpCompass);
    
      SetColorToleranceSpeed(tmpCTS);
      SetToleranceSpeed2Modifiers(tmpHM, tmpSM);
    end;
    Fixed the strange box random. Changed dtm-finding to bmptol-finding for the box item, fast and accurate. Added wait times to the item and number scanning, getting a much higher solve rate, roughly 85% and significantly less extra boxes from in-game time-outs. Call it with SolveBox; because it's not included in the normal random-finding routines.
    box.simba
    Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               ? Box Routines                                --//
    //-----------------------------------------------------------------//
    // * function GambleBox: Boolean;   // * by WT-Fakawi
    // * function GetBoxSide: Integer;  // * by pups/Ashaman88
    // * function GetQuestion(var num: Integer; var shape: string): Integer; // * by pups
    // * function GetNumber: Integer;   // * by Ashaman88
    // * function GetShape: String;     // * by Ashaman88
    // * function OpenBox: Boolean;     // * by Ashaman88
    // * function SolveBox: Boolean;    // * by Ashaman88
    
    //{$I SRL-OSR/SRL/misc/Debug.Simba}
    //{$I SRL-OSR/SRL/misc/SmartGraphics.Simba}
    var
      NumberBounds: TBox;
    
    const
      DebugBox=False;
    
    {*******************************************************************************
    function GambleNewBox: Boolean;
    by: WT-Fakawi  (left this in here just in case we want to guess)
    Description: A random box clicker. Will try to solve the box ONCE, by a random click
                 @ any of the three answers. THIS IS NOT A BOXSOLVER, JUST A BOXCLICKER!
    *******************************************************************************}
    
    function GambleBox: Boolean;
    var
      xb, yb, Choise: Integer;
    begin
      //if FindBitmapToleranceIn(Box, xb, yb, MIX1, MIY1, MIX2, MIY2, 40) then
      begin
        Mouse(xb, yb, 0, 0, True);
        Wait(2000);
        Choise:= Random(3);
        TakeScreen('Gambling box Choise - '+IntToStr(Choise));
        case Choise of
          0: Mouse(145, 295, 4, 4, True);
          1: Mouse(270, 295, 4, 4, True);
          2: Mouse(381, 295, 4, 4, True);
        end;
        IdleTime(4000, 2000, 1.0);
      //  if FindBitmapToleranceIn(Box, xb, yb, MIX1, MIY1, MIX2, MIY2, 40) then
        begin
          WriteLn('Box Missed');
         // NOnewboxes := NOnewboxes + 1;
          Result := False;
          repeat
            Logout;
          until (not (LoggedIn));
          Exit;
        end
        //else
        begin
          WriteLn('Box solved');
        //  newboxes := newboxes + 1;
          Result := True;
        end;
      end;
    end;
    
    {*******************************************************************************
    function OpenBox: Boolean;
    by: Ashaman88
    Description: Opens the box.
    *******************************************************************************}
    
    function OpenBox : Boolean;
    var
      x, y, i : Integer;
      SBMP: TIntegerArray;
    begin
      Result := False;
      SetLength(SBMP, 1);
      GameTab(Tab_Inv);
      Wait(100 + Random(50));
      SBMP[0] := BitmapFromString(22, 15, 'meJxzdHR3BCMbGycgGR2dTBDp6h' +
      'pCtISHxwMRXDsxejG1oyFHmHuwOkZeXhFNb3BwFFZzsBoIR3DZsrJ' +
      'GIMJvAi4E0YtsgpdXILIgENnbu0AQMHwgCKt2PCagISsre/wm+PgG' +
      'D7gJfv5hA25CQGDEgJsATJwDYgJcBAD7lYWZ');
      if FindBitmapToleranceIn(SBMP[0], x, y, MIX1, MIY1, MIX2, MIY2, 40)  then
      begin
        Mouse(x, y, 4, 4, True);
        for i := 0 to 9 do
        begin
          if (GetColor(487, 39) = 13567) and (GetColor(350, 295) = 2304814) then
          begin
            Result := True;
            Break;
          end;
          Wait(500 + Random(50));
        end;
      end;
      FreeBitmap(SBMP[0]);
    end;
    
    type
      NumberRotate = record
        Number, DTM, BMin, BMax, WMin, WMax: integer;
      end;
      NumberRotateArray = array of NumberRotate;
    
    var
      NumberArray: NumberRotateArray;
    
    {*******************************************************************************
    procedure LoadNumbers;
    by: Ashaman88
    Description: Loadsup all the numbers!
    *******************************************************************************}
    
    procedure LoadNumbers;
    begin
      if Length(NumberArray)<>0 then
        Exit;
    
      SetLength(NumberArray,10);
    
      with NumberArray[0] do {Good2}
      begin
        Number := 0;
        DTM  := DTMFromString('mYQMAAHic1c5bCsIwFIThExWr9YJ2F766D99dhptRRFREii0i7jDgBH8xFIX2TQMfpyQzaWZm1nNmiXvPvqQfhP2xjGRAtiudSEJ2iJDPZIoJ/VfP4KSFNudp1N8rdpJcLlIyc/aP9sycmTvZIu6G3hVlpR++C87uuFVyh+juNTb8w3tf22q5aKzJ/d/M9c5f5/5A7fUAGciE0g==');
        BMin := 125;
        BMax := 215;
        WMin := 160;
        WMax := 30;
      end;
    
      with NumberArray[1] do {Good}
      begin
        Number := 1;
        DTM  := DTMFromString('mggAAAHicY2NgYGBigABmIGaBshmBmA+IuaFYCirOAcT1mXEMf//8AWMQG4aNgHLYMBMODAEARdcMkQ==');
        BMin := 85;
        BMax := 130;
        WMin := 0;
        WMax := 100;
      end;
    
      with NumberArray[2] do {Good2}
      begin
        Number := 2;
        DTM  := DTMFromString('mygMAAHic1c5bCoJQFIXh43uWkdnNaAY9NKOG0Dyigkq7XyypqCkK/dESojepF4WP7dlu1z5dY4xjGVOGi6pUrHe/BBsFVVt9R72XouZraEgdnjLTLE/ffElnWzp3VNuqTWW6+t9XbnoOufsMcyywxh4RYhxwwgZLrLBFgCnGmOg90MwOR5xxwfVLLNHHrpt2hMp6ZQ4/3OUhSZL8bDToZ/KPnT3unkdWTmV7nhL4nss=');
        BMin := 0;
        BMax := 1000;
        WMin := 0;
        WMax := 1000;
      end;
    
      with NumberArray[3] do {Good2}
      begin
        Number := 3;
        DTM  := DTMFromString('mHgQAAHic3c/PDsFAEAbwGZTwOH0eF2cnT+EiJaJII0gJ4gn92/KNfomN7MVN2uSXndmd/drGIvIAUZGalmuB5Sllr1Rwzvi1412r73SDK+csowktaEMnwPYb+sm5MNu+QXlmGRHUKeKef29KKSwhgxVsIYc9Wb2BNc8zzs9ozt6yJjCihL3tL77yLfcAZ4/1JziS9TvO++9NmTkm59zfSQa9oGG/+xY6i/EvVaAV8fvzApQlvTI=');
        BMin := 140;
        BMax := 220;
        WMin := 300;
        WMax := 550;
      end;
    
      with NumberArray[4] do {Good2}
      begin
        Number := 4;
        DTM  := DTMFromString('mygMAAHic1c5dCoJAFAXga1ipRVnto4eWUguIVhG0loiIDEn7ISSjvQ11Bs7ALXrxoQcHPgauc49nLCKRJ9KliAJoQxN8aEGDt3vfhxhG0FPcPFa5HWa6HJ/ZdhZyb8Asa6i4rFDtv9A7hw1sYQd7SCClDE5whotyVbMjHLh7gwJKKjj7dqcHPKnkt4z/TtjJ9luzY8rOxhhZLWaVLefTj/sXm/0vE3SvI6+mqp033MCMjw==');
        BMin := 130;
        BMax := 300;
        WMin := 200;
        WMax := 450;
      end;
    
      with NumberArray[5] do {Good2}
      begin
        Number := 5;
        DTM  := DTMFromString('mXQQAAHic3c9dDsFAFAXg26pWikosRWIZ3i3DAhBpCFHx/x8RLJMMzo0jGk9Sb23ypbczp/fOVEXkAZYl4oBHDrlgw1009Mq9a8O35nLgQx4KpGtZcsljLoArfr/Jp58dk2FWc2X2878UqUQBZ+p5tmi5J60XtKZNrNb1OczgAMcY/d4xt4QpTCCCPoTQoZCzNDeiAXS534YmtJjtcU8zQxizp85YcfYJLnAGY0wijXrtL0nn/qKCe6WNlUKJnifIELAH');
        BMin := 230;
        BMax := 300;
        WMin := 340;
        WMax := 900;
      end;
    
      with NumberArray[6] do {Good2B}
      begin
        Number := 6;
        DTM  := DTMFromString('mSAQAAHic3c/bCgFRFAbgtYcijyOXbr2DZ5Gc0yTKYXI+xptw52GUGIxJ/t38w+QOd7Pra7da/9qHlIgklEgM4hT98EDmDEc40QXu4vUMZkR5XGxXcphxAzmHtT9jBO6KqHf+xjNs3n8IvMFm3z/XYa0zS1jBHKYwgQFY0IE2daEPY5gxv+A+Yq/HnJ4dMmtRk1rQABPqUIMyFCAPJaiyZ5I/azJfgSLkYA0b/kG/IZtJy363fdH1t4Lz//r3jiT+FCYqZH5ZT1UtpIA=');
        BMin := 160;
        BMax := 440;
        WMin := 300;
        WMax := 600;
      end;
    
      with NumberArray[7] do {Good2}
      begin
        Number := 7;
        DTM  := DTMFromString('mIgMAAHiczc5hCoJAEAXgtyoZQtfwAN2oI3SD0JCIEiuR8KjiRm/wBUu/8k+48LHsvGFmcwAjwQEJrWWldySQTPWYnGqe10sQ9A6aHbKa9dvMlDaaGe79OGJSSkUXaqiljp7UU0En5Td6KGv1rpVZz1U1y86aa3sOgUKZ7bp/7av3u1m893+x5d+WyC3Ub+cNI6GFkQ==');
        BMin := 140;
        BMax := 220;
        WMin := 200;
        WMax := 550;
      end;
    
      with NumberArray[8] do {Good2}
      begin
        Number := 8;
        DTM  := DTMFromString('mtQMAAHic1c7NCoJAFIbhMyJZVibeR5vuo313EAWVVKRUhEVdttA3+AZuhTYKD2eO52dmbmYDZxZJLEPX5CHnCCOZEBPOEX1BS8i87xvTNyXG1HyfiWPXTDKk5CkS3vGbCdhxULqzJh7lTMzlJg+5c76SV/KSZ6vua6UUuMiJPX7/FvvWPSV7K2LB/5y+jayZ87WPvKWu607y1fLvur5hoXf3jeuhTt8X9gh9aA==');
        BMin := 130;
        BMax := 400;
        WMin := 200;
        WMax := 450;
      end;
    
      with NumberArray[9] do {Good2}
      begin
        Number := 9;
        DTM  := DTMFromString('mdgMAAHic1c7NCgFRGMbxM4U0Jh8TwzVYWstOuQTltoTEyCShIffAzk15Tv5Tp0aysDH16z3zdOZ5p2uMqXjGVKUuAecyAvJQWtLkXJMG096JnDzkns3a0kFER0inz46SFFB0dvvOtDtW5iWWDTMmW2BJtpUdcy8nOctFrkjJj9xNZE3HTKaOOXnWn/CN7T7QlfL+uN9yxsP+R5PRIJe96/mFrLunf/0H3p/4/nkC/OhyWw==');
        BMin := 160;
        BMax := 440;
        WMin := 300;
        WMax := 600;
      end;
    End;
    
    {*******************************************************************************
    procedure FreeNumbers;
    by: Ashaman88
    Description: Frees the number dtms!
    *******************************************************************************}
    
    procedure FreeNumbers;
    var
      I: Integer;
    begin
      for i := 0 to high(NumberArray) do
        FreeDTM(NumberArray[i].DTM);
    end;
    
    {*******************************************************************************
    function GetNumber: Integer;
    by: Ashaman88.
    Description: Gets the number on the side of the box.
    *******************************************************************************}
    
    
    function GetNumber: Integer;
    var
      i, maxScore, maxIndex: integer;
      CTS,X,Y: Integer;
      MidBox: TPoint;
      TPA,TPA1,TPA2,TPAW: TPointArray;
      ATPA: T2DPointArray;
      BrownBox: TBox;
      afound: Extended;
      scores: TintegerArray;
    begin
      LoadNumbers;
      setLength(scores, length(NumberArray));
    
      CTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
    
      SetColorSpeed2Modifiers(0.05, 0.31);
      MidBox:=MiddleBox(IntToBox(NumberBounds.X1+5, NumberBounds.Y1+5, NumberBounds.X2-5, NumberBounds.Y2-5));
      FindColorsSpiralTolerance(MidBox.X, MidBox.Y, TPA, 6187391, NumberBounds.X1, NumberBounds.Y1, NumberBounds.X2, NumberBounds.Y2, 16);
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      ATPA:=FloodFillTPA(TPA);
    
      if Length(ATPA)=0 then
      begin
        Writeln('No brown found');
        Exit;
      end;
    
      if DebugBox then
      begin
       // DebugATPABounds(ATPA);
        Writeln('Length of Brown Shape: '+ToStr(Length(ATPA[0])));
      End;
    
      BrownBox:=GetTPABounds(ATPA[0]);
    
      FindColorsSpiralTolerance(MSCX, MSCY, TPA1, 16579837, BrownBox.X1, BrownBox.Y1, BrownBox.X2, BrownBox.Y2, 5);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA2, 12764106, BrownBox.X1, BrownBox.Y1, BrownBox.X2, BrownBox.Y2, 5);
      TPAW:=CombineTPA(TPA1,TPA2);
    
    
      if DebugBox then
        Writeln('Length of White TPA in Brown: '+ToStr(Length(TPAW)));
    
      // loop through fields, scoring each item
      for i := 0 to high(NumberArray) do
      begin
        if inRange(Length(ATPA[0]), NumberArray[i].Bmin, NumberArray[i].BMax) then
          scores[i] := scores[i] + 1;
    
        if inRange(Length(TPAW), NumberArray[i].Wmin, NumberArray[i].WMax) then
          scores[i] := scores[i] + 1;
    
        if findDTMrotated(NumberArray[i].DTM, x, y, BrownBox.X1-3, BrownBox.Y1-3, BrownBox.X2+3, BrownBox.Y2+3,-Pi,Pi,Pi/30,aFound) then
          scores[i] := scores[i] + 5;
              Wait(15 + Random(10));
      end;
    
      // get the item with the highest score
      maxScore := -1;
      maxIndex := -1;
      for i := 0 to high(scores) do
        if (scores[i] > maxScore) then
        begin
          maxScore := scores[i];
          maxIndex := i;
        end;
    
      if maxindex<>-1 then
      begin
        writeln('NumberScan: '+ToStr(NumberArray[maxIndex].number) + ', with a score of ' + intToStr(scores[maxIndex]));
    
        result := NumberArray[maxIndex].number;
      end;
    
      SetLength(ATPA,0);
      SetLength(TPA,0);
      SetLength(TPA1,0);
      SetLength(TPA2,0);
      SetLength(TPAW,0);
    end;
    
    type
      ShapeRotate = record
        Shape: String;
        SMin, SMax, WMin, WMax, BMin, BMax : integer;
      end;
      ShapeRotateArray = array of ShapeRotate;
    
    var
      ShapeArray: ShapeRotateArray;
    
    {*******************************************************************************
    procedure LoadShapes;
    by: Ashaman88
    Description: Loadsup all the shapes!
    *******************************************************************************}
    
    Procedure LoadShapes;
    begin
      if Length(ShapeArray)<>0 then
        Exit;
    
    
      SetLength(ShapeArray,5);
    
      with ShapeArray[0] do {Good2}
      begin
        Shape := 'Triangle';
        SMin := 10;
        SMax := 13;
        WMin := 4600;
        WMax := 4900;
        BMin := 3200;
        BMax := 4500;
      end;
    
      with ShapeArray[1] do {Good2}
      begin
        Shape := 'Square';
        SMin := 8;
        SMax := 13;
        WMin := 5000;
        WMax := 5800;
        BMin := 100;
        BMax := 2500;
      end;
    
      with ShapeArray[2] do {Good2}
      begin
        Shape := 'Star';
        SMin := 15;
        SMax := 17;
        WMin := 4100;
        WMax := 4400;
        BMin := 7500;
        BMax := 8400;
      end;
    
      with ShapeArray[3] do {Good2}
      begin
        Shape := 'Circle';
        SMin := 17;
        SMax := 20;
        WMin := 7000;
        WMax := 7500;
        BMin := 300;
        BMax := 1300;
      end;
    
      with ShapeArray[4] do {Good}
      begin
        Shape := 'Pentagon';
        SMin := 8;
        SMax := 16;
        WMin := 4400;
        WMax := 4800;
        BMin := 1600;
        BMax := 2400;
      end;
    End;
    
    {*******************************************************************************
    function GetShape: String;
    by: Ashaman88.
    Description: Gets the shape on the side of the box.
    *******************************************************************************}
    
    Function GetShape: String;
    Var
      i, maxScore, maxIndex: integer;
      CTS: Integer;
      TPA,TPA1,TPA2, TPAB: TPointArray;
      ATPA,ATPAB: T2DPointArray;
      WhiteBox: TBox;
      scores: TintegerArray;
    begin
      LoadShapes;
      setLength(scores, length(shapeArray));
    
      Result:='';
      FindColorsSpiralTolerance(MSCX, MSCY, TPA1, 16579837, 172, 45, 352, 225, 5);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA2, 12764106, 172, 45, 352, 225, 5);
      TPA:=CombineTPA(TPA1,TPA2);
    
      ATPA:=FloodFillTPA(TPA);
      SortATPASize(ATPA,True);
      if DebugBox then
        Writeln('Length of Full White ATPA: '+ToStr(Length(ATPA)));
      if Length(ATPA)=0 then
      begin
        Writeln('No white found');
        Exit;
      End;
    
      //if DebugBox then
      //  DebugATPABounds(ATPA);
    
      CTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
    
      WhiteBox:=GetTPABounds(ATPA[0]);
      NumberBounds:=WhiteBox;
    
      SetColorSpeed2Modifiers(0.05, 0.31);
      FindColorsSpiralTolerance(MSCX, MSCY, TPAB, 6187391, WhiteBox.X1, WhiteBox.Y1, WhiteBox.X2, WhiteBox.Y2, 16);
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      SplitTPAWrap(TPAB,10,ATPAB);
      SortATPASize(ATPAB,True);
    
      if DebugBox then
      begin
        Writeln('Length of Shape: '+ToStr(Length(ATPA[0])));
        Writeln('Length of OutterBox: '+ToStr(Length(ATPAB[0])));
      end;
    
      // loop through fields, scoring each item
      for i := 0 to high(ShapeArray) do
      begin
        if inRange(Length(ATPA[0]), ShapeArray[i].Wmin, ShapeArray[i].WMax) then
          scores[i] := scores[i] + 2;
    
        if inRange(Length(ATPAB[0]), ShapeArray[i].Bmin, ShapeArray[i].BMax) then
          scores[i] := scores[i] + 1;
    
        if inRange(Length(ATPA), ShapeArray[i].Smin, ShapeArray[i].SMax) then
          scores[i] := scores[i] + 4;
              Wait(15 + Random(10));
      end;
    
      // get the item with the highest score
      maxScore := -1;
      maxIndex := -1;
      for i := 0 to high(scores) do
        if (scores[i] > maxScore) then
        begin
          maxScore := scores[i];
          maxIndex := i;
        end;
    
      if maxindex<>-1 then
      begin
        writeln('ShapeScan: '+ShapeArray[maxIndex].shape + ', with a score of ' + intToStr(scores[maxIndex]));
    
        result := ShapeArray[maxIndex].shape;
      end;
    
      SetLength(ATPA,0);
      SetLength(TPA,0);
      SetLength(TPA1,0);
      SetLength(TPA2,0);
      SetLength(ATPAB,0);
      SetLength(TPAB,0);
    end;
    
    {*******************************************************************************
    function GetBoxSide: Integer;
    by: pups/Ashaman88
    Description: Gets Box side and freezes client
    *******************************************************************************}
    
    Procedure GetBoxSide;
    var
      X,Y: Integer;
    begin
      repeat
        wait(100);
        if FindColorTolerance(x, y, 16579837, 182, 45, 182, 225, 5) then continue;
        if FindColorTolerance(x, y, 16579837, 342, 45, 342, 225, 5) then continue;
        if FindColorTolerance(x, y, 16579837, 172, 55, 352, 55, 5) then continue;
        if FindColorTolerance(x, y, 16579837, 172, 215, 352, 215, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 182, 45, 182, 225, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 342, 45, 342, 225, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 172, 55, 352, 55, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 172, 215, 352, 215, 5) then continue;
        Break;
      until False;
      Freeze;
    end;
    
    {*******************************************************************************
    function GetQuestion(var num: Integer; var shape: String): Integer;
    by: pups
    Description: Returns number and type.
    *******************************************************************************}
    
    function GetQuestion(var num: Integer; var shape: string): Integer;
    var
      x, y, i: Integer;
      text: string;
    begin
      num := 10;
      shape := '';
      for i := 0 to 14 do
      begin
        case i of
          0: text := '0'; //Zero
          1: text := '1'; //One
          2: text := '2'; //Two
          3: text := '3'; //Three
          4: text := '4'; //Four
          5: text := '5'; //Five
          6: text := '6'; //Six
          7: text := '7'; //Seven
          8: text := '8'; //Eight
          9: text := '9'; //Nine
          10: text := 'Circle'; //Circle
          11: text := 'Triangle'; //Triangle
          12: text := 'Square'; //Square
          13: text := 'Star'; //Star
          14: text := 'Pentagon'; //Pentagon
        end;
        if (FindText(x, y, Text, upchars07, 110, 250, 415, 275)) then
        begin
          Result := i;
          if (i < 10) then
            num := i;
          if (i >= 10) then
            shape := text;
          Exit;
        end;
      end;
    end;
    
    
    {*******************************************************************************
    function SolveBox: Boolean;
    by: Ashaman88
    Description: Solves the Box!
    *******************************************************************************}
    
    function SolveBox: Boolean;
    var
      st2: Integer;
      shapeQ, shape, ans: string;
      numQ, num: Integer;
      x, y: Integer;
    begin
      while OpenBox do
      begin
        WriteLn('Found a box, solving...');
        Wait(1000);
        GetQuestion(numQ, shapeQ);
        if (shapeQ = '') and (numQ = 10) then
          exit;
        WriteLn('Question is:');
        if shapeQ = '' then
          WriteLn('Which shape has number ' + IntToStr(numQ))
        else
          WriteLn('What number is the ' + shapeQ);
        st2 := GetSystemTime;
        repeat
          GetBoxSide;
          Shape:=GetShape;
          Num:=GetNumber;
          UnFreeze;
          if DebugBox then
            Wait(2000) Else
            if (num = numQ) or (shape = shapeQ) then
            begin
              if num = numQ then
                ans := shape
              else
                ans := IntToStr(num);
              WriteLn('Answer is ' + ans);
              if FindText(x, y, ans, upchars07, 116, 286, 183, 311) then
                Mouse(120, 290, 30, 10, True);
              Wait(150 + Random(100));
              if FindText(x, y, ans, upchars07, 235, 286, 302, 311) then
                Mouse(240, 290, 30, 10, True);
              Wait(150 + Random(100));
              if FindText(x, y, ans, upchars07, 350, 286, 417, 311) then
                Mouse(355, 290, 30, 10, True);
              Wait(150 + Random(100));
              //ClickMouse2(mouse_left);
              WriteLn('******** SOLVED BOX RANDOM ********');
              Result := True;
              Break;
            end;
        until GetSystemTime > st2 + 12000;
        Wait(1500 + Random(1000));
      end;
      if Length(NumberArray)>0 then
      begin
        FreeNumbers;
        SetLength(NumberArray,0);
      end;
      if Length(ShapeArray)>0 then
        SetLength(ShapeArray,0);
    end;
    I will probably make a fix for the sandwich lady's object scanning next. I will also attempt the forester soon because I've been getting a lot of them, and there doesn't seem to be a solver atm..
    Last edited by Krazy_Meerkat; 12-18-2013 at 05:58 PM.

  20. #220
    Join Date
    Feb 2012
    Location
    UK
    Posts
    909
    Mentioned
    10 Post(s)
    Quoted
    191 Post(s)

    Default

    Going to try these out with one of hoodz's scripts in pascalscript. It should work right?

    Awesome work though. If only I had a clue what to do to be of any help.
    Solar from RiD.

  21. #221
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    I was getting a crazy amount of randoms so I decided to post the ones that I have fixed here..

    Fixed the text options for the frog random.. It still uses the backup walk, but it manages to get to the middle of the cave.. It solved before I had a chance to improve it.. Will edit this post if I get another one.
    frog.simba
    Code:
    (*
    Frog
    ====
    
    Stores all the routines to solve the Frog random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    *)
    
    var
      O_MouseSpeed, FROG_ISLAND_DTM, FROG_ISLAND_DTM_BACKUP, FROG_CROWN_DTM: Integer;
    
    const
      FROG_YELLOW             = 7986172;
      FROG_RED                = 3097339;
      FROG_GREEN              = 879885;
      FROG_SWAMP              = 8031312;
      FROG_CROWN              = 1095911;
      FROG_CROWN_COLOR_BACKUP = 633312;
    
    //function Frog_Speakto: boolean; forward;
    function Frog_IsTalkingTo: boolean; forward;
    function Frog_FindFrog: boolean; forward;
    
    (**
     * Author: Justin
     * Description: Detects if we are in the Frog Random. Small chance it would
     * fail to detect due to the frogs being off-screen, checks for Music Track too.
     *)
    function Frog_Detect(): boolean;
    begin
      if not (tabExists(TAB_MAGIC)) then
      begin
        if Length(GetMinimapDots('npc')) >= 4 then
          if PercentBlackMM >= 35 then
            if (GetMusic = 'Frooland') then
            begin
              Result := true;
              exit;
            end;
        if (CountColorTolerance(FROG_GREEN, MSX1, MSY1, MSX2, MSY2, 30) >= 100) then
          if (CountColorTolerance(FROG_RED, MSX1, MSY1, MSX2, MSY2, 30) >= 20) then
            Result := (CountColorTolerance(FROG_YELLOW, MSX1, MSY1, MSX2, MSY2, 30) >= 5);
      end;
    end;
    
    (**
     * Author: Justin
     * Description: Gets our player ready to solve the random.
     *)
    procedure Frog_Setup();
    begin
      if (not LoggedIn()) then
        exit;
      SetAngle(SRL_ANGLE_HIGH);
      MakeCompass('n');
      O_MouseSpeed := MouseSpeed;
      MouseSpeed := 26;
    end;
    
    (**
     * Author: Xtrapsp
     * Description: Loads the DTMs that are used within the random.
     *)
    procedure Frog_Set_DTMS;
    begin
      FROG_ISLAND_DTM := DTMFromString('mrAAAAHic42BgYDjJxsBwA4qvA/EpID4MxLuAeBMQtwDV9ABxNRAXA3EuEBcBcQkQ1wJxaJAdg3lxAk4sB1SDDzMSwDAAAMr5E3M=');
      FROG_ISLAND_DTM_BACKUP := DTMFromString('maQEAAHicE2RgYLjGxMDwGIjvMEHY54H4NBSfg+KrQHwTqu4BED8H4idAfAmqfgbQnIlA3AvFE4B4CgNEfB4QLwLipVA8H8qfDZUHqV8JxIGeNgxmRfFw7ONiARYD4RBvWzAGsf3dLVHUIWNWoDmUYkYqYAwAAGpfKPw=');
      FROG_CROWN_DTM := DTMFromString('mggAAAHicY2NgYNBkZGDQAGItINZDwneBcjeB+BoQXwfiWwwQsUI+doZjkjwMG9u4GN5v42O4tICHIZeHlUEEKIcNM+LAEAAAEgENCw==');
    end;
    
    (**
     * Author: Xtrapsp
     * Description: Unloads the DTMs that were used within the random.
     *)
    procedure Frog_Free_DTMS;
    begin
      FreeDTM(FROG_ISLAND_DTM);
      FreeDTM(Frog_ISLAND_DTM_BACKUP);
      FreeDTM(FROG_CROWN_DTM);
    end;
    
    (**
     * Author: Xtrapsp/Justin
     * Description: Walks our player to the center of the map where the
     * Frog Princess is located. If the DTM fails, will use TPA failsafe.
     *)
    function Frog_WalkCenter: boolean;
    var
      TPA: TPointArray;
      T, TPAX, TPAY: Integer;
    begin
      if (not loggedIn()) then
        exit;
      MarkTime(T);
      if ClickDTMRotatedIn(FROG_ISLAND_DTM, MMX1, MMY1, MMX2, MMY2, - Pi, Pi, Pi / 30, [], mouse_Left) then
      begin
        addToSRLLog('Frog_WalkCenter: Moving to center of cave');
        FFlag(0);
        result := true;
        addToSRLLog('Frog_WalkCenter[Main]: result: ' + BoolToStr(result));
      end
      else
      begin
        addToSRLLog('Frog_WalkCenter: Unable to find main DTM, Falling back onto backup');
        if (FindColorsTolerance(TPA, FROG_SWAMP, MMX1, MMY1, MMX2, MMY2, 50)) then
        begin
          MiddleTPAEx(TPA, TPAX, TPAY);
          Mouse(TPAX, TPAY, 8, 8, mouse_Left);
          wait(600 + Random(120));
          FFlag(0);
          result := true;
          addToSRLLog('Frog_WalkCenter[Backup]: result: ' + BoolToStr(result));
        end;
      end;
    end;
    
    (**
     * Author: Xtrapsp/Justin
     * Description: Finds the Frog Princess via DTM with a TPA failsafe.
     * If the DTM fails, it will rotate the camera just incase the Frog Princess
     * is off the screen.
     *)
    function Frog_FindFrog: boolean;
    var
      T, Attempt, tmpCTS, i, arL: integer;
      arP: TPointArray;
      ararP: T2DPointArray;
      P: TPoint;
    begin
      addToSRLLog('Frog_FindFrog: Attempting to find the Frog Princess');
      Marktime(T);
      tmpCTS := GetColorToleranceSpeed;
      repeat
        if ClickDTMRotatedIn(FROG_CROWN_DTM, MSX1, MSY1, MSX2, MSY2, - Pi, Pi, Pi / 30, ['rog'], mouse_Left) then
        begin
          addToSRLLog('Frog_FindFrog: Found Frog Princess');
          result := true;
          addToSRLLog('Frog_FindFrog[Main]: result: ' + BoolToStr(result));
          exit;
        end else
          begin
            addToSRLLog('Frog_FindFrog: Could not find Frog Princess. Falling onto backup');
            MakeCompass(rs_GetCompassAngleDegrees + RandomRange(85, 95));
            wait(800+Random(400));
            ColorToleranceSpeed(2);
            SetColorSpeed2Modifiers(0.02, 0.76);
            if (FindColorsTolerance(arP, FROG_CROWN, MSX1, MSY1, MSX2, MSY2, 12)) then
            begin
              addToSRLLog('Frog_FindFrog: Found TPA color, Moving mouse to TPA');
              SortTPAFrom(arP, Point(MSCX, MSCY));
              ararP := SplitTPAEx(arP, 8, 8);
              arL := High(ararP);
              for i := 0 to arL do
              begin
                P := MiddleTPA(ararP[i]);
                MMouse(P.x, P.y, 5, 5);
                addToSRLLog('Frog_FindFrog: Checking multi uptext');
                Wait(100 + Random(100));
                if (IsUpTextMultiCustom(['Frog', 'Talk', 'rog'])) then
                begin
                  ClickMouse2(mouse_Right);
                  Result := WaitOptionMulti(['Talk-to', 'alk-t', 'Frog', 'rog'], 500);
                  addToSRLLog('Frog_FindFrog[Backup]: result: ' + BoolToStr(result));
                  wait(600 + Random(120));
                  FFlag(0);
                  exit;
              end else
                addToSRLLog('Frog_FindFrog: Could not find uptext');
              end;
            end else
             addToSRLLog('Frog_FindFrog[Backup]: Unable to find TPA');
          end;
        Inc(Attempt);
        addToSRLLog('Frog_FindFrog: Attempt: ' + inttostr(Attempt));
      until ((Attempt > 3) or (Result));
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      exit;
    
    end;
    
    {(**
     * Author: Xtrapsp/Justin
     * Description: Handles talking to the Frog Princeess.
     *)
    function Frog_SpeakTo: boolean;
    var
      T, Attempt: integer;
      TPA: TPointArray;
    begin
      addToSRLLog('Frog_SpeakTo: Attempting to speak to the Frog Princess');
      Marktime(T);
      repeat
        if ClickDTMRotatedIn(FROG_CROWN_DTM, MSX1, MSY1, MSX2, MSY2, - Pi, Pi, Pi / 30, ['rog'], mouse_Left) then
        begin
          addToSRLLog('Frog_SpeakTo: Found Frog Princess, Clicking Frog Princess');
          result := true;
          addToSRLLog('Frog_SpeakTo[Main]: result: ' + BoolToStr(result));
          Wait(3500 + Random(1000));
          exit;
        end
        else
        begin
          addToSRLLog('Frog_SpeakTo: Could not find Frog Princess. Falling onto backup');
          if (FindColorsSpiralTolerance(MSCX, MSCY, TPA, FROG_CROWN_COLOR_BACKUP, MSX1, MSY1, MSX2, MSY2, 25)) then
          begin
            Mouse(TPA[0].X, TPA[0].Y, 2, 2, mouse_Move);
            if IsUpTextMultiCustom(['Frog', 'Talk', 'rog']) then
              ClickMouse2(mouse_Left);
            wait(600 + Random(120));
            FFlag(0);
            Result := true;
            addToSRLLog('Frog_SpeakTo[Backup]: result: ' + BoolToStr(result));
          end;
        end;
        Inc(Attempt);
        MakeCompass(rs_GetCompassAngleDegrees + RandomRange(85, 95));
      until ((Attempt > 20) or (Frog_IsTalkingTo))
      if (Attempt > 20) then
        Frog_WalkCenter;
      exit;
    end;}
    
    (**
     * Author: Xtrapsp/Justin
     * Description: Detects if we are talking to the Frog Princess or just a Frog.
     *)
    function Frog_IsTalkingTo: boolean;
    var
      T, Attempt: integer;
    begin
      addToSRLLog('Frog_IsTalkingTo: Speaking to the Frog Princess');
      repeat
        Result := FindNPCChatText('Hmph. Have you come to apologize for ignoring me?', Nothing);
        if Result then
        begin
          addToSRLLog('Frog_IsTalkingTo: Continuing to chat to Frog Princess');
          Wait(1000 + Random(500));
          DoConversation('', true);
          Wait(1100 + Random(500));
          Mouse(137, 399, 252, 7, True);
          Wait(1100 + Random(500));
          Mouse(153, 449, 130, 5, True);
          Wait(1100 + Random(500));
          Mouse(243, 450, 130, 4, True);
          Wait(2100 + Random(1500));
          Result := true;
          addToSRLLog('Frog_IsTalkingTo: result: ' + BoolToStr(result));
          exit;
        end
        else
          addToSRLLog('Frog_IsTalkingTo: Could not continue chat with Frog Princess');
      until ((Attempt > 5) or (TimefromMark(T) > 50000) or Result);
      if (Attempt > 5) then
      begin
        addToSRLLog('Frog_IsTalkingTo: Attempts are greater than 5');
        Wait(3000 + Random(1000));
        result := false;
      end;
    end;
    
    (**
     * Author: Justin
     * Description: Handles solving the random event.
     *)
    function Frog_Solve(): boolean;
    var
      t: integer;
    begin
      if (not loggedIn()) then
        exit;
      t := (getSystemTime + (10 * 60000));
      Frog_Setup();
      repeat
        if Frog_WalkCenter then
          if Frog_FindFrog then
            result := Frog_IsTalkingTo;
      until (result or (getSystemTime > t));
      MouseSpeed := O_MouseSpeed;
      if (not result) then
        addToSRLLog('Frog_Solve: Frog solver failed or timed out');
    end;
    Fixed the pillory cage random. Object scanning was freezing up and returning low values for the locks, added wait times and minimum value requirements. Fixed compass angle issues.
    pillory.simba
    Code:
    (*
    Pillory
    =======
    
    Stores all the routines to solve the Pillory random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    This solver uses color counting to determine the shape
    of the lock and which key to use.
    
    *)
    
    procedure PL_Message(Message: string);
    begin
      addToSRLLog('[Pillory Random] ' + Message);
    end;
    
    function PL_LockScreen: Boolean;
    begin
      Result := (LoggedIn and (GetColor(497, 34) = 65536));
    end;
    
    function PL_Detect: boolean;
    var
      tpa: TPointArray;
    begin
      if (not TabExists(TAB_OPTIONS)) and (TabExists(TAB_FRIENDS)) then
      begin
        // red doors of the cages
        FindColorsTolerance(tpa, 235, MMCX - 15, MMCY - 15, MMCX + 15, MMCY + 15, 20);
        Result := (inRange(length(tpa), 3, 18));
      end;
    end;
    
    (**
     * Author: DannyRS
     * Last modified 15/03/2013 By DannyRS
     * Description: Opens Cage Interface
     *)
    function PL_ClickCage: Boolean;
    var
      t: Integer;
    begin
      Result := False;
    
      t := GetSystemTime;
    
      if (not LoggedIn) then Exit;
    
      Result := PL_LockScreen;
    
      if (not Result) then
      begin
        repeat
          MMouse(243,143,80,65);
    
          Wait(RandomRange(90, 270));
    
          if (IsUpTextMultiCustom(['Unlock','lock','Cage','age'])) then
          begin
            ClickMouse2(mouse_left);
            if (waitFunc(@PL_LockScreen, 50, 5000)) then
            begin
              PL_Message('[PL_ClickCage] Opened Lock Screen');
              Wait(RandomRange(190, 270));
              Result := True;
            end else
              PL_Message('[PL_ClickCage] Failed to open Lock Screen');
          end;
        until (Result) or (GetSystemTime - t > 30000);
      end;
    end;
    
    (**
     * Author: DannyRS
     * Last modified 15/03/2013 By DannyRS
     * Description: Clicks a key 0-2
     *)
    function PL_ClickKey(Slot: Integer): Boolean;
    var
      p: TPoint;
    begin
      Result := False;
    
      if (not PL_LockScreen) then Exit;
    
      p := Point(209 + (Slot*93), 251);
    
      MMouse(RandomRange(p.x - 2, p.x + 2), RandomRange(p.y - 4, p.y + 4), 0, 0);
    
      ClickMouse2(mouse_left);
    
      Result := True;
    end;
    
    (**
     * Author: DannyRS
     * Last modified 9/04/2013 By DannyRS
     * Description: Scans for lock type
     *)
    function PL_GetLock: String;
    var
      CNum,Count,CountTime,WatchTime: Integer;
    begin
      Result := '';
      WatchTime := RandomRange(9000,10000);
      SetColorToleranceSpeed(2);
      SetToleranceSpeed2Modifiers(0.21, 2.01);
      MarkTime(CountTime);
      Count:= 100;
      repeat
        CNum := CountColorTolerance(1057067, 60, 65, 150, 150, 10);
        if (CNum > Count) then
          Count := CNum;
          wait(50 + random(50));
      until (TimeFromMark(CountTime) > WatchTime);
      if (Count > 800) and (Count < 1000) then Result := 'square';
      if (Count > 570) and (Count < 799) then Result := 'triangle';
      if (Count > 400) and (Count < 569) then Result := 'diamond';
      if (Count > 1001) and (Count < 1600) then Result := 'circle';
      PL_Message('[PL_GetLock] Lock Found: ' + Result + ' [' + ToStr(Count) + ']');
    end;
    
    (**
     * Author: DannyRS
     * Last modified 9/04/2013 By DannyRS
     * Description: Scans for key types
     *)
    function PL_GetKeys: TStringArray;
    var
      C1,C2,C3,CNum,Count,WatchTime: Integer;
    begin
      SetLength(Result, 3);
    
      SetColorToleranceSpeed(2);
      SetToleranceSpeed2Modifiers(0.43, 2.81);
    
      MarkTime(WatchTime);
      Result[0] := '';
      Count := 100; CNum := 0;
      repeat
        CNum := CountColorTolerance(1516846, 180, 170, 235, 260, 7);
    
        case CNum of
          286: Result[0] := 'triangle';
          493: Result[0] := 'diamond';
          506: Result[0] := 'circle';
          729: Result[0] := 'square';
        end;
    
        if (CNum > Count) then
          Count := CNum;
        wait(50 + random(50));
    
      until (not (Result[0] = '')) or (TimeFromMark(WatchTime) > 10000);
    
      if (Result[0] = '') then
      begin
        if InRange(Count, 250, 350) then Result[0] := 'triangle';
        if InRange(Count, 400, 500) then Result[0] := 'diamond';
        if InRange(Count, 501, 600) then Result[0] := 'circle';
        if InRange(Count, 670, 1300) then Result[0] := 'square';
      end;
    
      C1 := Count;
    
      MarkTime(WatchTime);
      Result[1] := '';
      Count := 100; CNum := 0;
      repeat
        CNum := CountColorTolerance(1516846, 265, 170, 345, 260, 7);
    
        case CNum of
          286: Result[1] := 'triangle';
          493: Result[1] := 'diamond';
          506: Result[1] := 'circle';
          729: Result[1] := 'square';
        end;
    
        if (CNum > Count) then
          Count := CNum;
        wait(50 + random(50));
    
      until (not (Result[1] = '')) or (TimeFromMark(WatchTime) > 10000);
    
      if (Result[1] = '') then
      begin
        if InRange(Count, 250, 350) then Result[1] := 'triangle';
        if InRange(Count, 400, 500) then Result[1] := 'diamond';
        if InRange(Count, 501, 600) then Result[1] := 'circle';
        if InRange(Count, 670, 1300) then Result[1] := 'square';
      end;
    
      C2 := Count;
    
      MarkTime(WatchTime);
      Result[2] := '';
      Count := 100; CNum := 0;
      repeat
        CNum := CountColorTolerance(1516846, 365, 170, 430, 260, 7);
    
        case CNum of
          286: Result[2] := 'triangle';
          493: Result[2] := 'diamond';
          506: Result[2] := 'circle';
          729: Result[2] := 'square';
        end;
    
        if (CNum > Count) then
          Count := CNum;
        wait(50 + random(50));
    
      until (not (Result[2] = '')) or (TimeFromMark(WatchTime) > 10000);
    
      if (Result[2] = '') then
      begin
        if InRange(Count, 250, 350) then Result[2] := 'triangle';
        if InRange(Count, 400, 500) then Result[2] := 'diamond';
        if InRange(Count, 501, 600) then Result[2] := 'circle';
        if InRange(Count, 670, 1300) then Result[2] := 'square';
      end;
    
      C3 := Count;
    
      PL_Message('[PL_GetKeys] Keys Found: '+
          Result[0]+' ['+IntToStr(C1)+']'+' '+
          Result[1]+' ['+IntToStr(C2)+']'+' '+
          Result[2]+' ['+IntToStr(C3)+']');
    end;
    
    (**
     * Author: DannyRS
     * Last modified 15/03/2013 By DannyRS
     * Description: Solves the Pillory Random Event
     *)
    function PL_Solve: Boolean;
    var
      i, t, keysolves, tmpCTS: Integer;
      tmpHM, tmpSM, Deg: Extended;
      lock: String;
      keys: TStringArray;
    begin
      Result := False;
      keysolves := 0;
    
      tmpCTS := GetColorToleranceSpeed;
      GetToleranceSpeed2Modifiers(tmpHM, tmpSM);
    
      if (not LoggedIn) then Exit;
    
      t := GetSystemTime;
    
     Deg := RS_GetCompassAngleDegrees;
     Wait(100 + random(50));
     MakeCompass('N');
      //if (not PL_ClickCage) then Exit;
    
      repeat
    
        Result := (TabExists(TAB_OPTIONS));
        if (Result) then Break;
    
        // open the lock screen if it's not already open
        if (not PL_LockScreen) then PL_ClickCage;
    
        lock := PL_GetLock;
        keys := PL_GetKeys;
    
        for i := 0 to 2 do
          if (keys[i] = '') then
          begin
             PL_Message('[ERROR] [PL_GetKeys] Failed to get all keys');
             Break;
          end;
    
          if (lock = '') then
          begin
             PL_Message('[ERROR] [PL_GetLock] Failed to get lock type');
             Continue;
          end;
    
          for i := 0 to 2 do
          if (keys[i] = lock) then
          begin
            PL_Message('[PL_Solve] Clicking key : ' + keys[i]);
            if PL_ClickKey(i) then
            begin
              keysolves := keysolves + 1;
              Wait(RandomRange(1500, 2000));
            end;
          end;
    
        Result := ((keysolves > 2) and (not PL_LockScreen)) or
            (TabExists(TAB_OPTIONS));
    
      until (Result) or (GetSystemTime - t > 120000);
    
      if (Result) then MakeCompass(Deg);
    
      SetColorToleranceSpeed(tmpCTS);
      SetToleranceSpeed2Modifiers(tmpHM, tmpSM);
    
      if (not Result) then
      begin
        if (GetSystemTime - t > 120000) then
          PL_Message('[ERROR] Pillory solver timed out');
      end else
        Wait(RandomRange(800, 1200));
    end;
    Fixed the drill demon random. Added 1 new bitmap for each sign, had no problems detecting all 4. Ran it through a few times, changing worlds to test colour difference.
    demon.simba
    Code:
    (*
    Drill Demon
    ===========
    
    Stores all the routines to solve the Drill Demon random.  None of these routines
    should be used throughout scripts.  They only need to be called in SRL's random
    detection methods.
    
    This solver uses Deformed BMPs to locate the signs
    to solve the Drill Demon (Sergeant Damien) random.
    
    *)
    
    procedure DD_Message(Message: String);
    begin
      addToSRLLog('[DemonDrill Random] ' + Message);
    end;
    
    function DD_Detect(): Boolean;
    begin
      if (not TabExists(TAB_OPTIONS)) and (not TabExists(TAB_EMOTES)) then
        Result := (GetMusic = 'CorPoral Punisbment');
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Moves the player back to the center of the random
     * Note: Inspired by Le Jingle
     *)
    function DD_ResetPosition: Boolean;
    var
      WallTPA: TPointArray;
      WallATPA: T2DPointArray;
      tb: TBox;
      p: TPoint;
      //pa: TPointArray;
    begin
      Result := False;
    
      if (not LoggedIn) then Exit;
    
      SetColorToleranceSpeed(1);
      SetToleranceSpeed2Modifiers(0.02, 0.02);
      FindColorsTolerance(WallTPA, 15593957, 600, 58, 690, 110, 70);
      SplitTPAExWrap(WallTPA, 5, 5, WallATPA);
      SortATPASize(WallATPA, True);
    
      if (Length(WallATPA) < 1) then Exit;
    
      //SMART_DrawBoxEx(True, False, WallATPA[0], clGreen);
    
      tb := GetTPABounds(WallATPA[0]);
      p := MiddleBox(tb);
    
      //Seems white alone is accurate enough to leave this out - Danny
      //pa := GetMiniMapDots('yellow');
      //if (Length(pa) < 1) then Exit;
      //if (not PointInBox(pa[0], tb)) then Exit;
    
      MMouse(p.x, RandomRange(p.y, p.y + 2), 0, 0);
      ClickMouse2(mouse_left);
    
      Wait(RandomRange(300, 400));
      Flag;
      Wait(RandomRange(800, 1200));
    
      Result := True;
    end;
    
    function DD_TalkingToDemon: Boolean;
    begin
      Result := (Trim(GetNPCChatName) = 'SergeantDamien');
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Talks to Sergeant Damien
     *)
    function DD_TalkDemon: Boolean;
    var
      DemonTPA: TPointArray;
      DemonATPA: T2DPointArray;
      x, y, i, Attemps: Integer;
    begin
      Result := False;
    
      if (DD_TalkingToDemon) then
      begin
        Result := True;
        Exit;
      end;
    
      repeat
    
        if (Attemps > 6) then Break;
    
        SetColorToleranceSpeed(2);
        SetToleranceSpeed2Modifiers(0.15, 1.61);
        FindColorsTolerance(DemonTPA, 994406, MSX1, MSY1, MSX2, MSY2, 16);
        SplitTPAExWrap(DemonTPA, 50, 100, DemonATPA);
        SortATPASize(DemonATPA, True);
    
        if (Length(DemonATPA) < 1) then
        begin
          Attemps := Attemps + 1;
          Wait(RandomRange(200, 400));
          Continue;
        end;
    
        for i := 0 to High(DemonATPA) do
        begin
          if (Length(DemonATPA[i]) < 50) then Continue;
          MiddleTPAEx(DemonATPA[i], x, y);
          MMouse(RandomRange(x - 5, x + 5), RandomRange(y - 5, y + 5), 0, 0);
          ClickMouse2(mouse_right);
          Wait(RandomRange(30, 50));
          if (ChooseOptionMulti(['Talk','alk-to'])) then
          begin
            if (WaitFunc(@DD_TalkingToDemon, 50, 25000)) then
            begin
              DD_Message('[DD_TalkDemon] Talked to demon');
              Result := True;
              Exit;
            end else
              DD_Message('[DD_TalkDemon] Failed to Talked to demon');
          end;
        end;
        Attemps := Attemps + 1;
    
      until (Result) or (Attemps > 6);
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Gets the TBoxes of the green signs
     *)
    function DD_GetSigns: TBoxArray;
    var
      ESignsTPA: TPointArray;
      ESignsATPA: T2DPointArray;
      SignsSorted: Boolean;
      i: Integer;
    begin
      SetColorToleranceSpeed(1);
      SetToleranceSpeed2Modifiers(0.02, 0.02);
      FindColorsTolerance(ESignsTPA, 4553552, MSX1, MSY1, MSX2, MSY2, 30);
      SplitTPAExWrap(ESignsTPA, 70, 60, ESignsATPA);
    
      repeat
        SignsSorted := True;
        for i := 0 to High(ESignsATPA) do
        begin
          if (Length(ESignsATPA[i]) < 5) then
          begin
            DeleteValueInATPA(ESignsATPA,i);
            SignsSorted := False;
            Break;
          end;
        end;
      until (SignsSorted);
    
      SetLength(Result, Length(ESignsATPA));
    
      for i := 0 to high(ESignsATPA) do
      begin
        Result[i] := GetTPABounds(ESignsATPA[i]);
      end;
    
      DD_Message('[DD_GetSigns] Number of signs located : ' +
          IntToStr(Length(ESignsATPA)));
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description:
     *  Compares bitmaps to the signs and tries to
     *  return it's position, roughly centered
     *)
    function DD_FindSign(WhichSign: String): TPoint;
    var
      SB: TBoxArray;
      x, y, i, ib, hb: Integer;
      Saccuracy: Extended;
      SBMP: TIntegerArray;
    begin
      Result := Point(-1, -1);
    
      SB := DD_GetSigns;
      if (Length(SB) < 1) then Exit;
    
      SetLength(SBMP, 3);
    
      hb := High(SBMP);
    
      SetColorToleranceSpeed(1);
      SetToleranceSpeed2Modifiers(0.02, 0.02);
    
      case LowerCase(WhichSign) of
        'jog':        begin
                        SBMP[0] := BitmapFromString(14, 15, 'meJxzrw1KnFAOQe5IbAgXDRGvEo' +
                        '6y5zQDEVw7Vlk4wm8UmktooRJNMS4PojkVlxq4p5BDDKsaTBuRVWI' +
                        'qw2UvVmUE44VaiolMEkAEAE9f+0k=');
                        SBMP[1] := BitmapFromString(26, 17, 'meJxzqwl0w0AJfWUQhMYmD2E1jR' +
                        'IDIShrdhMQwa2grmlkGwgxB4IodxVaMFLXNGQDKYwRNM+SHcvIQQf' +
                        'XS57b0CICOQVSYhSmH8k2jSrxOJhNc0PNVhQiKhYdbuQmKgBkSPbW');
                        SBMP[2] := BitmapFromString(29, 10, 'meJxzrQ5wJRrF9ZUSr3gwGItsMh' +
                        'qXbJQ5qxGI4EZRxViImRBjIaZRbizcTGR3UmgsmpnUCltcxlIrVKl' +
                        'rLNxk4tUDAIc3Qs8=');
                      end;
        'starjumps':  begin
                        SBMP[0] := BitmapFromString(16, 16, 'meJxzrw1yx0CJE8ohCFMKK4Krx9' +
                        'SSu7AdiEg1H6su/GogXPwIlyHEqMSlnhhH0kg9hS6nonqsyrBqgcQ' +
                        '7LjOJUY/VXswEhifGkZMfAK38Sfc=');
                        SBMP[1] := BitmapFromString(33, 17, 'meJxzqwl0Ixol9JUBEfHqSUUQ8+' +
                        'lmC4Xm5CxohSNaqMeqkSCilo+objhBu6ge0cPAClrHAi4rqGgLHZI' +
                        'TprHUtQWXsym3Al4Q4XIwsjh5pRa8uMPjWmTzyS4Y4bbgCUZiSngA' +
                        'a5KX0w==');
                        SBMP[2] := BitmapFromString(37, 16, 'meJxzrQ5wJR3F9ZXCERnacaHs+S' +
                        '34raOiXXAbIYjqJhNjKfGIPjbSx5t0C1U6RyI97Ro21tEtNdLHOuR' +
                        'iCtN8qtuIXDBiNZlGHgQiXMbSIgbh1uGJUyKrJAA7N7QN');
                      end;
        'situps':     begin
                        SBMP[0] := BitmapFromString(32, 12, 'meJxzrwl0R0U5C9uAyB1DnCoIYj' +
                        'gdzCfPCoK6KDGfoC5kw0m1ghgtmOYTaQWRWpAVEG8+msm4tGAqI9I' +
                        'KrBoJBiDWsCKIsJqf0F8GRJiuJcN8ZKOQDYeLE4xugobDzYewSUoY' +
                        'xBiObD7QBABMTOo0');
                        SBMP[1] := BitmapFromString(36, 14, 'meJxzqwl0GwQoZ0ErENHNIgrtIl' +
                        'I73C7yrCNeL7JFZNhFkl40u0iyjiSNmBYRbxepepHVUBIaboRSMpr' +
                        'J+O3C6gus2km1i3gE0ZvQV0aMO4lxOR4EtAWCkEXgZqJJUWIX3CKs' +
                        'BqLJEh8pBO1C9g6dEQA0UXaL');
                        SBMP[2] := BitmapFromString(37, 16, 'meJxzrQ5wHRwoe34LENHTLgqtI1' +
                        '473DqybSReL7Jd5FlHkl4060i1kSSNmHaRZB2pepGVkWojmnqCGtE' +
                        'MpyRYiLcOf8ASg4hJMJiyZFsX11cKRMhcuJkQKbgswWRDpF3I1mHa' +
                        'BZElJpUSaRcEkZSDyLCRVPOHEwIAf3vRcQ==');
                      end;
        'pushups':    begin
                        SBMP[0] := BitmapFromString(37, 16, 'meJxzrw1KnFAOQe61QXRAdLZuYF' +
                        'HuwnYIoqddyIjO1tHIakwzaWc1HkNoYSlB7VQMZ+K1ELSUGHMocSF' +
                        'J9sKLFMpjgZ6pmnaJihJ7aWcjWmTRoQrAtAsAxiXG8w==');
                        SBMP[1] := BitmapFromString(39, 16, 'meJxzqwl0qwlM6CuDIDcwlz5oYC' +
                        '2ls73IKGdBKwTR30ZkNCCW0tQBBG2kugOwmkZre/GbQwt7iTeEin6' +
                        'nRAsZboCUCZSEFalpD7ksonpqHFRZntb2okUina1DthEAClrmig==');
                        SBMP[2] := BitmapFromString(43, 16, 'meJxzrQ5wBaO4vlI4coUJ0hMhO2' +
                        'Cg3ICJsue3ANHA2o6MBtZ2OjuGoANo6hhMk+npBjxm0scNBE2jaWg' +
                        'QbwiNkgcZuqiSVuEFICUBOLAZh57phFqOoacb0OJ6AK3GtB0AjuAl' +
                        '9Q==');
                      end;
      end;
    
      for i := 0 to High(SB) do
      begin
        for ib := 0 to hb do
        begin
          if (Result.X > 0) or (Result.Y > 0) then Break;
          if (SB[i].X1 > SB[i].X2) or (SB[i].Y1 > SB[i].Y2) then Continue;
    
          if FindDeformedBitmapToleranceIn(SBMP[ib], x, y, SB[i].X1-2, SB[i].Y1-2,
            SB[i].X2+2, SB[i].Y2+2, 2, 4, False, Saccuracy) then
            begin
              Result := Point(x + 20, y + 7);
              DD_Message('[DD_FindSign] Matching sign found at : ' + ToStr(Result));
              Break;
            end;
        end;
      end;
    
      for ib := 0 to hb do
        FreeBitmap(SBMP[ib]);
    end;
    
    (**
     * Author: DannyRS
     * Last Modified: 17/03/2013 - DannyRS
     * Description: Attemps to solve the Drill Demon random
     *)
    function DD_Solve(): boolean;
    var
      p: TPoint;
      t, tmpCompass, tmpCTS, MMoves, debugColorCount: Integer;
      tmpHM, tmpSM: Extended;
      MatName, LastMatt: String;
    begin
      Result := False;
    
      if (not LoggedIn) then Exit;
    
      t := GetSystemTime;
    
      tmpCTS := GetColorToleranceSpeed;
      GetToleranceSpeed2Modifiers(tmpHM, tmpSM);
      tmpCompass := Round(rs_GetCompassAngleDegrees);
    
      SetAngle(SRL_ANGLE_LOW);
      MakeCompass('N');
    
      repeat
    
        Result := TabExists(TAB_MAGIC);
    
        if (Result) then Break;
    
        if (not DD_TalkDemon) then
        begin
          DD_ResetPosition;
          Continue;
        end;
    
        Wait(RandomRange(1200, 1600));
    
        debugColorCount := CountColor(0, MCX1, MCY1, MCX2, MCY2);
        case debugColorCount of
          687,988,691 : MatName := 'jog';
          707,711     : MatName := 'starjumps';
          569,573     : MatName := 'situps';
          637,938,641 : MatName := 'pushups';
          else
          begin
            ClickToContinue;
            Wait(RandomRange(1200, 1500));
            Continue;
          end;
        end;
        DD_Message('[DD_Solve] Last color count: ' + inttostr(debugColorCount));
        LastMatt := '';
        if (LastMatt = MatName) then
        begin
          MMoves := 0;
    
          DD_Message('[DD_Solve] Already standing on the matt : ' + MatName);
          DD_Message('[DD_Solve] Using matt : ' + MatName + ' again');
    
          repeat
            MMouse(246, 184, 40, 30);
            MMoves := MMoves + 1;
            Wait(RandomRange(90, 340));
            if (IsUpTextMultiCustom(['Use','xercise','mat'])) then
            begin
              ClickMouse2(mouse_right);
              Wait(RandomRange(40, 90));
              if (ChooseOptionMulti(['Use'])) then
              begin
                Wait(RandomRange(1200, 1500));
                if (WaitFunc(@DD_TalkingToDemon, 50, 15000)) then
                begin
                  DD_Message('[DD_Solve] Used matt successfully');
                  LastMatt := MatName;
                  Break;
                end else
                begin
                  DD_Message('[ERROR] Failed to use matt');
                  Break;
                end;
              end;
            end;
          until (MMoves > 10);
    
          Continue;
        end;
    
        DD_Message('[DD_Solve] Walking to center to search for sign');
    
        if (not DD_ResetPosition) then
        begin
          DD_Message('[ERROR] Failed to walk to center');
          Continue;
        end;
    
        DD_Message('[DD_Solve] Searching for sign : ' + MatName);
    
        p := DD_FindSign(MatName);
    
        if (p.x < 0) or (p.y < 0) then
        begin
          DD_Message('[ERROR] Failed to find sign : ' + MatName);
          Continue;
        end;
    
        MMoves := 0;
    
        DD_Message('[DD_Solve] Searching for matt : ' + MatName);
    
        repeat
    
          MMouse(p.x - 10, p.y + 64, 50, 30);
    
        //SMART_DrawBoxEx(True,False,IntToBox(p.x-10,p.y+64,p.x+40,p.y+94),clGreen);
    
          MMoves := MMoves + 1;
          Wait(RandomRange(90, 340));
          if (IsUpTextMultiCustom(['Use','xercise','mat'])) then
          begin
            ClickMouse2(mouse_right);
            Wait(RandomRange(40, 90));
            if (ChooseOptionMulti(['Use'])) then
            begin
              Wait(RandomRange(1200, 1500));
              if (WaitFunc(@DD_TalkingToDemon, 50, 15000)) then
              begin
                DD_Message('[DD_Solve] Used matt successfully');
                LastMatt := MatName;
                Break;
              end else
              begin
                DD_Message('[ERROR] Failed to use matt');
                Break;
              end;
            end;
          end;
        until (MMoves > 10);
    
      Result := TabExists(TAB_MAGIC);
    
      until (Result) or (GetSystemTime - t > 240000);
    
      if (not Result) then
      begin
        if (GetSystemTime - t > 240000) then
          DD_Message('[ERROR] DrillDemon solver timed out');
      end else
        Wait(RandomRange(1200, 1600));
    
      SetAngle(SRL_ANGLE_HIGH);
      MakeCompass(tmpCompass);
    
      SetColorToleranceSpeed(tmpCTS);
      SetToleranceSpeed2Modifiers(tmpHM, tmpSM);
    end;
    Fixed the strange box random. Changed dtm-finding to bmptol-finding for the box item, fast and accurate. Added wait times to the item and number scanning, getting a much higher solve rate, roughly 85% and significantly less extra boxes from in-game time-outs. Call it with SolveBox; because it's not included in the normal random-finding routines.
    box.simba
    Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               ? Box Routines                                --//
    //-----------------------------------------------------------------//
    // * function GambleBox: Boolean;   // * by WT-Fakawi
    // * function GetBoxSide: Integer;  // * by pups/Ashaman88
    // * function GetQuestion(var num: Integer; var shape: string): Integer; // * by pups
    // * function GetNumber: Integer;   // * by Ashaman88
    // * function GetShape: String;     // * by Ashaman88
    // * function OpenBox: Boolean;     // * by Ashaman88
    // * function SolveBox: Boolean;    // * by Ashaman88
    
    //{$I SRL-OSR/SRL/misc/Debug.Simba}
    //{$I SRL-OSR/SRL/misc/SmartGraphics.Simba}
    var
      NumberBounds: TBox;
    
    const
      DebugBox=False;
    
    {*******************************************************************************
    function GambleNewBox: Boolean;
    by: WT-Fakawi  (left this in here just in case we want to guess)
    Description: A random box clicker. Will try to solve the box ONCE, by a random click
                 @ any of the three answers. THIS IS NOT A BOXSOLVER, JUST A BOXCLICKER!
    *******************************************************************************}
    
    function GambleBox: Boolean;
    var
      xb, yb, Choise: Integer;
    begin
      //if FindBitmapToleranceIn(Box, xb, yb, MIX1, MIY1, MIX2, MIY2, 40) then
      begin
        Mouse(xb, yb, 0, 0, True);
        Wait(2000);
        Choise:= Random(3);
        TakeScreen('Gambling box Choise - '+IntToStr(Choise));
        case Choise of
          0: Mouse(145, 295, 4, 4, True);
          1: Mouse(270, 295, 4, 4, True);
          2: Mouse(381, 295, 4, 4, True);
        end;
        IdleTime(4000, 2000, 1.0);
      //  if FindBitmapToleranceIn(Box, xb, yb, MIX1, MIY1, MIX2, MIY2, 40) then
        begin
          WriteLn('Box Missed');
         // NOnewboxes := NOnewboxes + 1;
          Result := False;
          repeat
            Logout;
          until (not (LoggedIn));
          Exit;
        end
        //else
        begin
          WriteLn('Box solved');
        //  newboxes := newboxes + 1;
          Result := True;
        end;
      end;
    end;
    
    {*******************************************************************************
    function OpenBox: Boolean;
    by: Ashaman88
    Description: Opens the box.
    *******************************************************************************}
    
    function OpenBox : Boolean;
    var
      x, y, i : Integer;
      SBMP: TIntegerArray;
    begin
      Result := False;
      SetLength(SBMP, 1);
      GameTab(Tab_Inv);
      Wait(100 + Random(50));
      SBMP[0] := BitmapFromString(22, 15, 'meJxzdHR3BCMbGycgGR2dTBDp6h' +
      'pCtISHxwMRXDsxejG1oyFHmHuwOkZeXhFNb3BwFFZzsBoIR3DZsrJ' +
      'GIMJvAi4E0YtsgpdXILIgENnbu0AQMHwgCKt2PCagISsre/wm+PgG' +
      'D7gJfv5hA25CQGDEgJsATJwDYgJcBAD7lYWZ');
      if FindBitmapToleranceIn(SBMP[0], x, y, MIX1, MIY1, MIX2, MIY2, 40)  then
      begin
        Mouse(x, y, 4, 4, True);
        for i := 0 to 9 do
        begin
          if (GetColor(487, 39) = 13567) and (GetColor(350, 295) = 2304814) then
          begin
            Result := True;
            Break;
          end;
          Wait(500 + Random(50));
        end;
      end;
      FreeBitmap(SBMP[0]);
    end;
    
    type
      NumberRotate = record
        Number, DTM, BMin, BMax, WMin, WMax: integer;
      end;
      NumberRotateArray = array of NumberRotate;
    
    var
      NumberArray: NumberRotateArray;
    
    {*******************************************************************************
    procedure LoadNumbers;
    by: Ashaman88
    Description: Loadsup all the numbers!
    *******************************************************************************}
    
    procedure LoadNumbers;
    begin
      if Length(NumberArray)<>0 then
        Exit;
    
      SetLength(NumberArray,10);
    
      with NumberArray[0] do {Good2}
      begin
        Number := 0;
        DTM  := DTMFromString('mYQMAAHic1c5bCsIwFIThExWr9YJ2F766D99dhptRRFREii0i7jDgBH8xFIX2TQMfpyQzaWZm1nNmiXvPvqQfhP2xjGRAtiudSEJ2iJDPZIoJ/VfP4KSFNudp1N8rdpJcLlIyc/aP9sycmTvZIu6G3hVlpR++C87uuFVyh+juNTb8w3tf22q5aKzJ/d/M9c5f5/5A7fUAGciE0g==');
        BMin := 125;
        BMax := 215;
        WMin := 160;
        WMax := 30;
      end;
    
      with NumberArray[1] do {Good}
      begin
        Number := 1;
        DTM  := DTMFromString('mggAAAHicY2NgYGBigABmIGaBshmBmA+IuaFYCirOAcT1mXEMf//8AWMQG4aNgHLYMBMODAEARdcMkQ==');
        BMin := 85;
        BMax := 130;
        WMin := 0;
        WMax := 100;
      end;
    
      with NumberArray[2] do {Good2}
      begin
        Number := 2;
        DTM  := DTMFromString('mygMAAHic1c5bCoJQFIXh43uWkdnNaAY9NKOG0Dyigkq7XyypqCkK/dESojepF4WP7dlu1z5dY4xjGVOGi6pUrHe/BBsFVVt9R72XouZraEgdnjLTLE/ffElnWzp3VNuqTWW6+t9XbnoOufsMcyywxh4RYhxwwgZLrLBFgCnGmOg90MwOR5xxwfVLLNHHrpt2hMp6ZQ4/3OUhSZL8bDToZ/KPnT3unkdWTmV7nhL4nss=');
        BMin := 0;
        BMax := 1000;
        WMin := 0;
        WMax := 1000;
      end;
    
      with NumberArray[3] do {Good2}
      begin
        Number := 3;
        DTM  := DTMFromString('mHgQAAHic3c/PDsFAEAbwGZTwOH0eF2cnT+EiJaJII0gJ4gn92/KNfomN7MVN2uSXndmd/drGIvIAUZGalmuB5Sllr1Rwzvi1412r73SDK+csowktaEMnwPYb+sm5MNu+QXlmGRHUKeKef29KKSwhgxVsIYc9Wb2BNc8zzs9ozt6yJjCihL3tL77yLfcAZ4/1JziS9TvO++9NmTkm59zfSQa9oGG/+xY6i/EvVaAV8fvzApQlvTI=');
        BMin := 140;
        BMax := 220;
        WMin := 300;
        WMax := 550;
      end;
    
      with NumberArray[4] do {Good2}
      begin
        Number := 4;
        DTM  := DTMFromString('mygMAAHic1c5dCoJAFAXga1ipRVnto4eWUguIVhG0loiIDEn7ISSjvQ11Bs7ALXrxoQcHPgauc49nLCKRJ9KliAJoQxN8aEGDt3vfhxhG0FPcPFa5HWa6HJ/ZdhZyb8Asa6i4rFDtv9A7hw1sYQd7SCClDE5whotyVbMjHLh7gwJKKjj7dqcHPKnkt4z/TtjJ9luzY8rOxhhZLWaVLefTj/sXm/0vE3SvI6+mqp033MCMjw==');
        BMin := 130;
        BMax := 300;
        WMin := 200;
        WMax := 450;
      end;
    
      with NumberArray[5] do {Good2}
      begin
        Number := 5;
        DTM  := DTMFromString('mXQQAAHic3c9dDsFAFAXg26pWikosRWIZ3i3DAhBpCFHx/x8RLJMMzo0jGk9Sb23ypbczp/fOVEXkAZYl4oBHDrlgw1009Mq9a8O35nLgQx4KpGtZcsljLoArfr/Jp58dk2FWc2X2878UqUQBZ+p5tmi5J60XtKZNrNb1OczgAMcY/d4xt4QpTCCCPoTQoZCzNDeiAXS534YmtJjtcU8zQxizp85YcfYJLnAGY0wijXrtL0nn/qKCe6WNlUKJnifIELAH');
        BMin := 230;
        BMax := 300;
        WMin := 340;
        WMax := 900;
      end;
    
      with NumberArray[6] do {Good2B}
      begin
        Number := 6;
        DTM  := DTMFromString('mSAQAAHic3c/bCgFRFAbgtYcijyOXbr2DZ5Gc0yTKYXI+xptw52GUGIxJ/t38w+QOd7Pra7da/9qHlIgklEgM4hT98EDmDEc40QXu4vUMZkR5XGxXcphxAzmHtT9jBO6KqHf+xjNs3n8IvMFm3z/XYa0zS1jBHKYwgQFY0IE2daEPY5gxv+A+Yq/HnJ4dMmtRk1rQABPqUIMyFCAPJaiyZ5I/azJfgSLkYA0b/kG/IZtJy363fdH1t4Lz//r3jiT+FCYqZH5ZT1UtpIA=');
        BMin := 160;
        BMax := 440;
        WMin := 300;
        WMax := 600;
      end;
    
      with NumberArray[7] do {Good2}
      begin
        Number := 7;
        DTM  := DTMFromString('mIgMAAHiczc5hCoJAEAXgtyoZQtfwAN2oI3SD0JCIEiuR8KjiRm/wBUu/8k+48LHsvGFmcwAjwQEJrWWldySQTPWYnGqe10sQ9A6aHbKa9dvMlDaaGe79OGJSSkUXaqiljp7UU0En5Td6KGv1rpVZz1U1y86aa3sOgUKZ7bp/7av3u1m893+x5d+WyC3Ub+cNI6GFkQ==');
        BMin := 140;
        BMax := 220;
        WMin := 200;
        WMax := 550;
      end;
    
      with NumberArray[8] do {Good2}
      begin
        Number := 8;
        DTM  := DTMFromString('mtQMAAHic1c7NCoJAFIbhMyJZVibeR5vuo313EAWVVKRUhEVdttA3+AZuhTYKD2eO52dmbmYDZxZJLEPX5CHnCCOZEBPOEX1BS8i87xvTNyXG1HyfiWPXTDKk5CkS3vGbCdhxULqzJh7lTMzlJg+5c76SV/KSZ6vua6UUuMiJPX7/FvvWPSV7K2LB/5y+jayZ87WPvKWu607y1fLvur5hoXf3jeuhTt8X9gh9aA==');
        BMin := 130;
        BMax := 400;
        WMin := 200;
        WMax := 450;
      end;
    
      with NumberArray[9] do {Good2}
      begin
        Number := 9;
        DTM  := DTMFromString('mdgMAAHic1c7NCgFRGMbxM4U0Jh8TwzVYWstOuQTltoTEyCShIffAzk15Tv5Tp0aysDH16z3zdOZ5p2uMqXjGVKUuAecyAvJQWtLkXJMG096JnDzkns3a0kFER0inz46SFFB0dvvOtDtW5iWWDTMmW2BJtpUdcy8nOctFrkjJj9xNZE3HTKaOOXnWn/CN7T7QlfL+uN9yxsP+R5PRIJe96/mFrLunf/0H3p/4/nkC/OhyWw==');
        BMin := 160;
        BMax := 440;
        WMin := 300;
        WMax := 600;
      end;
    End;
    
    {*******************************************************************************
    procedure FreeNumbers;
    by: Ashaman88
    Description: Frees the number dtms!
    *******************************************************************************}
    
    procedure FreeNumbers;
    var
      I: Integer;
    begin
      for i := 0 to high(NumberArray) do
        FreeDTM(NumberArray[i].DTM);
    end;
    
    {*******************************************************************************
    function GetNumber: Integer;
    by: Ashaman88.
    Description: Gets the number on the side of the box.
    *******************************************************************************}
    
    
    function GetNumber: Integer;
    var
      i, maxScore, maxIndex: integer;
      CTS,X,Y: Integer;
      MidBox: TPoint;
      TPA,TPA1,TPA2,TPAW: TPointArray;
      ATPA: T2DPointArray;
      BrownBox: TBox;
      afound: Extended;
      scores: TintegerArray;
    begin
      LoadNumbers;
      setLength(scores, length(NumberArray));
    
      CTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
    
      SetColorSpeed2Modifiers(0.05, 0.31);
      MidBox:=MiddleBox(IntToBox(NumberBounds.X1+5, NumberBounds.Y1+5, NumberBounds.X2-5, NumberBounds.Y2-5));
      FindColorsSpiralTolerance(MidBox.X, MidBox.Y, TPA, 6187391, NumberBounds.X1, NumberBounds.Y1, NumberBounds.X2, NumberBounds.Y2, 16);
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      ATPA:=FloodFillTPA(TPA);
    
      if Length(ATPA)=0 then
      begin
        Writeln('No brown found');
        Exit;
      end;
    
      if DebugBox then
      begin
       // DebugATPABounds(ATPA);
        Writeln('Length of Brown Shape: '+ToStr(Length(ATPA[0])));
      End;
    
      BrownBox:=GetTPABounds(ATPA[0]);
    
      FindColorsSpiralTolerance(MSCX, MSCY, TPA1, 16579837, BrownBox.X1, BrownBox.Y1, BrownBox.X2, BrownBox.Y2, 5);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA2, 12764106, BrownBox.X1, BrownBox.Y1, BrownBox.X2, BrownBox.Y2, 5);
      TPAW:=CombineTPA(TPA1,TPA2);
    
    
      if DebugBox then
        Writeln('Length of White TPA in Brown: '+ToStr(Length(TPAW)));
    
      // loop through fields, scoring each item
      for i := 0 to high(NumberArray) do
      begin
        if inRange(Length(ATPA[0]), NumberArray[i].Bmin, NumberArray[i].BMax) then
          scores[i] := scores[i] + 1;
    
        if inRange(Length(TPAW), NumberArray[i].Wmin, NumberArray[i].WMax) then
          scores[i] := scores[i] + 1;
    
        if findDTMrotated(NumberArray[i].DTM, x, y, BrownBox.X1-3, BrownBox.Y1-3, BrownBox.X2+3, BrownBox.Y2+3,-Pi,Pi,Pi/30,aFound) then
          scores[i] := scores[i] + 5;
              Wait(15 + Random(10));
      end;
    
      // get the item with the highest score
      maxScore := -1;
      maxIndex := -1;
      for i := 0 to high(scores) do
        if (scores[i] > maxScore) then
        begin
          maxScore := scores[i];
          maxIndex := i;
        end;
    
      if maxindex<>-1 then
      begin
        writeln('NumberScan: '+ToStr(NumberArray[maxIndex].number) + ', with a score of ' + intToStr(scores[maxIndex]));
    
        result := NumberArray[maxIndex].number;
      end;
    
      SetLength(ATPA,0);
      SetLength(TPA,0);
      SetLength(TPA1,0);
      SetLength(TPA2,0);
      SetLength(TPAW,0);
    end;
    
    type
      ShapeRotate = record
        Shape: String;
        SMin, SMax, WMin, WMax, BMin, BMax : integer;
      end;
      ShapeRotateArray = array of ShapeRotate;
    
    var
      ShapeArray: ShapeRotateArray;
    
    {*******************************************************************************
    procedure LoadShapes;
    by: Ashaman88
    Description: Loadsup all the shapes!
    *******************************************************************************}
    
    Procedure LoadShapes;
    begin
      if Length(ShapeArray)<>0 then
        Exit;
    
    
      SetLength(ShapeArray,5);
    
      with ShapeArray[0] do {Good2}
      begin
        Shape := 'Triangle';
        SMin := 10;
        SMax := 13;
        WMin := 4600;
        WMax := 4900;
        BMin := 3200;
        BMax := 4500;
      end;
    
      with ShapeArray[1] do {Good2}
      begin
        Shape := 'Square';
        SMin := 8;
        SMax := 13;
        WMin := 5000;
        WMax := 5800;
        BMin := 100;
        BMax := 2500;
      end;
    
      with ShapeArray[2] do {Good2}
      begin
        Shape := 'Star';
        SMin := 15;
        SMax := 17;
        WMin := 4100;
        WMax := 4400;
        BMin := 7500;
        BMax := 8400;
      end;
    
      with ShapeArray[3] do {Good2}
      begin
        Shape := 'Circle';
        SMin := 17;
        SMax := 20;
        WMin := 7000;
        WMax := 7500;
        BMin := 300;
        BMax := 1300;
      end;
    
      with ShapeArray[4] do {Good}
      begin
        Shape := 'Pentagon';
        SMin := 8;
        SMax := 16;
        WMin := 4400;
        WMax := 4800;
        BMin := 1600;
        BMax := 2400;
      end;
    End;
    
    {*******************************************************************************
    function GetShape: String;
    by: Ashaman88.
    Description: Gets the shape on the side of the box.
    *******************************************************************************}
    
    Function GetShape: String;
    Var
      i, maxScore, maxIndex: integer;
      CTS: Integer;
      TPA,TPA1,TPA2, TPAB: TPointArray;
      ATPA,ATPAB: T2DPointArray;
      WhiteBox: TBox;
      scores: TintegerArray;
    begin
      LoadShapes;
      setLength(scores, length(shapeArray));
    
      Result:='';
      FindColorsSpiralTolerance(MSCX, MSCY, TPA1, 16579837, 172, 45, 352, 225, 5);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA2, 12764106, 172, 45, 352, 225, 5);
      TPA:=CombineTPA(TPA1,TPA2);
    
      ATPA:=FloodFillTPA(TPA);
      SortATPASize(ATPA,True);
      if DebugBox then
        Writeln('Length of Full White ATPA: '+ToStr(Length(ATPA)));
      if Length(ATPA)=0 then
      begin
        Writeln('No white found');
        Exit;
      End;
    
      //if DebugBox then
      //  DebugATPABounds(ATPA);
    
      CTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
    
      WhiteBox:=GetTPABounds(ATPA[0]);
      NumberBounds:=WhiteBox;
    
      SetColorSpeed2Modifiers(0.05, 0.31);
      FindColorsSpiralTolerance(MSCX, MSCY, TPAB, 6187391, WhiteBox.X1, WhiteBox.Y1, WhiteBox.X2, WhiteBox.Y2, 16);
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      SplitTPAWrap(TPAB,10,ATPAB);
      SortATPASize(ATPAB,True);
    
      if DebugBox then
      begin
        Writeln('Length of Shape: '+ToStr(Length(ATPA[0])));
        Writeln('Length of OutterBox: '+ToStr(Length(ATPAB[0])));
      end;
    
      // loop through fields, scoring each item
      for i := 0 to high(ShapeArray) do
      begin
        if inRange(Length(ATPA[0]), ShapeArray[i].Wmin, ShapeArray[i].WMax) then
          scores[i] := scores[i] + 2;
    
        if inRange(Length(ATPAB[0]), ShapeArray[i].Bmin, ShapeArray[i].BMax) then
          scores[i] := scores[i] + 1;
    
        if inRange(Length(ATPA), ShapeArray[i].Smin, ShapeArray[i].SMax) then
          scores[i] := scores[i] + 4;
              Wait(15 + Random(10));
      end;
    
      // get the item with the highest score
      maxScore := -1;
      maxIndex := -1;
      for i := 0 to high(scores) do
        if (scores[i] > maxScore) then
        begin
          maxScore := scores[i];
          maxIndex := i;
        end;
    
      if maxindex<>-1 then
      begin
        writeln('ShapeScan: '+ShapeArray[maxIndex].shape + ', with a score of ' + intToStr(scores[maxIndex]));
    
        result := ShapeArray[maxIndex].shape;
      end;
    
      SetLength(ATPA,0);
      SetLength(TPA,0);
      SetLength(TPA1,0);
      SetLength(TPA2,0);
      SetLength(ATPAB,0);
      SetLength(TPAB,0);
    end;
    
    {*******************************************************************************
    function GetBoxSide: Integer;
    by: pups/Ashaman88
    Description: Gets Box side and freezes client
    *******************************************************************************}
    
    Procedure GetBoxSide;
    var
      X,Y: Integer;
    begin
      repeat
        wait(100);
        if FindColorTolerance(x, y, 16579837, 182, 45, 182, 225, 5) then continue;
        if FindColorTolerance(x, y, 16579837, 342, 45, 342, 225, 5) then continue;
        if FindColorTolerance(x, y, 16579837, 172, 55, 352, 55, 5) then continue;
        if FindColorTolerance(x, y, 16579837, 172, 215, 352, 215, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 182, 45, 182, 225, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 342, 45, 342, 225, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 172, 55, 352, 55, 5) then continue;
        if FindColorTolerance(x, y, 12764106, 172, 215, 352, 215, 5) then continue;
        Break;
      until False;
      Freeze;
    end;
    
    {*******************************************************************************
    function GetQuestion(var num: Integer; var shape: String): Integer;
    by: pups
    Description: Returns number and type.
    *******************************************************************************}
    
    function GetQuestion(var num: Integer; var shape: string): Integer;
    var
      x, y, i: Integer;
      text: string;
    begin
      num := 10;
      shape := '';
      for i := 0 to 14 do
      begin
        case i of
          0: text := '0'; //Zero
          1: text := '1'; //One
          2: text := '2'; //Two
          3: text := '3'; //Three
          4: text := '4'; //Four
          5: text := '5'; //Five
          6: text := '6'; //Six
          7: text := '7'; //Seven
          8: text := '8'; //Eight
          9: text := '9'; //Nine
          10: text := 'Circle'; //Circle
          11: text := 'Triangle'; //Triangle
          12: text := 'Square'; //Square
          13: text := 'Star'; //Star
          14: text := 'Pentagon'; //Pentagon
        end;
        if (FindText(x, y, Text, upchars07, 110, 250, 415, 275)) then
        begin
          Result := i;
          if (i < 10) then
            num := i;
          if (i >= 10) then
            shape := text;
          Exit;
        end;
      end;
    end;
    
    
    {*******************************************************************************
    function SolveBox: Boolean;
    by: Ashaman88
    Description: Solves the Box!
    *******************************************************************************}
    
    function SolveBox: Boolean;
    var
      st2: Integer;
      shapeQ, shape, ans: string;
      numQ, num: Integer;
      x, y: Integer;
    begin
      while OpenBox do
      begin
        WriteLn('Found a box, solving...');
        Wait(1000);
        GetQuestion(numQ, shapeQ);
        if (shapeQ = '') and (numQ = 10) then
          exit;
        WriteLn('Question is:');
        if shapeQ = '' then
          WriteLn('Which shape has number ' + IntToStr(numQ))
        else
          WriteLn('What number is the ' + shapeQ);
        st2 := GetSystemTime;
        repeat
          GetBoxSide;
          Shape:=GetShape;
          Num:=GetNumber;
          UnFreeze;
          if DebugBox then
            Wait(2000) Else
            if (num = numQ) or (shape = shapeQ) then
            begin
              if num = numQ then
                ans := shape
              else
                ans := IntToStr(num);
              WriteLn('Answer is ' + ans);
              if FindText(x, y, ans, upchars07, 116, 286, 183, 311) then
                Mouse(120, 290, 30, 10, True);
              Wait(150 + Random(100));
              if FindText(x, y, ans, upchars07, 235, 286, 302, 311) then
                Mouse(240, 290, 30, 10, True);
              Wait(150 + Random(100));
              if FindText(x, y, ans, upchars07, 350, 286, 417, 311) then
                Mouse(355, 290, 30, 10, True);
              Wait(150 + Random(100));
              //ClickMouse2(mouse_left);
              WriteLn('******** SOLVED BOX RANDOM ********');
              Result := True;
              Break;
            end;
        until GetSystemTime > st2 + 12000;
        Wait(1500 + Random(1000));
      end;
      if Length(NumberArray)>0 then
      begin
        FreeNumbers;
        SetLength(NumberArray,0);
      end;
      if Length(ShapeArray)>0 then
        SetLength(ShapeArray,0);
    end;
    I will probably make a fix for the sandwich lady's object scanning next. I will also attempt the forester soon because I've been getting a lot of them, and there doesn't seem to be a solver atm..
    Awesome job man, if they work send in those pull requests!

  22. #222
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    Awesome job man, if they work send in those pull requests!
    Where do I send these pull requests? A forum search for "osr pull request" sent me back here.. There are a few places to download OSR so I didn't know if I should PM Flight or hoodz or what.. These are for the pascal version of osr (I can do fixes for the lape version if needed).

    All of them work, only the frog random is a quick-fix.. I have a new version which uses some of Flight's frog_solve2 but haven't tested yet, it will still use the quick-fix as a backup.
    I updated my previous post because I fixed the cage-finding routine for the pillory random (it was just using mousebox). Works great now, if you use it, post feedback here.

    I found that there was a forester solver after all, I started working on it but got stuck on the mainscreen tail-finding.. If you fail the forester you get sent to the party room, which isn't an issue for my script which uses hometele, but I'd like the solver to find the pheasant with X number of tails and I'm not up to scratch on my colour routines.. I'll try again when I get another one.
    Last edited by Krazy_Meerkat; 12-15-2013 at 09:14 AM.

  23. #223
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

  24. #224
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    Where do I send these pull requests? A forum search for "osr pull request" sent me back here.. There are a few places to download OSR so I didn't know if I should PM Flight or hoodz or what.. These are for the pascal version of osr (I can do fixes for the lape version if needed).
    I can put them in the include of my tutorial.
    My version is the same as the github version (i think that is what you search) but it has a some extra reflection functions and al_include. The smartparams file works with the latest version of smart too.

  25. #225
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    I can put them in the include of my tutorial.
    My version is the same as the github version (i think that is what you search) but it has a some extra reflection functions and al_include. The smartparams file works with the latest version of smart too.
    It be great if you could include them in your version hoodz, I link to that version because of the neat reflection hooks and your setup tutorial

    Thanks Mayor, the less rands the better imo.. I got 2 more SL's and they solved with the regular solver so I haven't edited that yet.. But I've got a mordaut random atm, so I'm testing a few things..
    Last edited by Krazy_Meerkat; 12-15-2013 at 11:02 AM.

Page 9 of 10 FirstFirst ... 78910 LastLast

Thread Information

Users Browsing this Thread

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

Posting Permissions

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