Guest User

RuneScapeJJ Molly

a guest
Jan 14th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 34.85 KB | None | 0 0
  1. program JJsMollySolver;
  2. {$DEFINE SMART}
  3. {$i srl/srl.simba}
  4. {$i srl/srl/misc/paintsmart.simba}
  5.  
  6. var
  7.   HookBox, PreviousBox, C, CorrectMolly, FalseMolly: Integer;
  8.   MollyHair: String;
  9.   Debug: Boolean;
  10.  
  11. procedure DeclarePlayers;
  12. begin
  13.   HowManyPlayers := 1;
  14.   NumberOfPlayers(HowManyPlayers);
  15.   CurrentPlayer := 0;
  16.  
  17.   with Players[0] do
  18.     begin
  19.       Name := '';
  20.       Pass := '';
  21.       Pin := '';
  22.       Active := True;
  23.     end;
  24. end;
  25.  
  26. procedure SetupLogin;
  27. begin
  28.   //ClearDebug;
  29.   Smart_Server := 10;
  30.   Smart_Members := False;
  31.   Smart_Signed := True;
  32.   Smart_SuperDetail := False;
  33.   SetupSRL;
  34.   DeclarePlayers;
  35.   LoginPlayer;
  36. end;
  37.  
  38. {*******************************************************************************
  39. procedure TalkToMolly;
  40. by: J J
  41. Description: Talks to Molly at start
  42. *******************************************************************************}
  43. procedure TalkToMolly;
  44. var
  45.   FloorColors, MollyColors: TPointArray;
  46.   SearchBox: TBox;
  47.   MollySplit: T2DPointArray;
  48.   P: TPoint;
  49.  
  50. begin
  51.   SearchBox := IntToBox(60, 215, 125, 265);
  52.   ColorToleranceSpeed(2);
  53.   SetColorSpeed2Modifiers(0.17, 0.54);
  54.   if FindColorsSpiralTolerance(260, 200, FloorColors, 4215386, SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2, 8) then
  55.     begin
  56.       MollyColors := TPAFromBox(SearchBox);
  57.       MollyColors := ClearTPAFromTPA(MollyColors, FloorColors);
  58.       SplitTPAExWrap(MollyColors, 1, 1, MollySplit);
  59.       SortATPASize(MollySplit, True);
  60.       if Length(MollySplit[0]) > 20 then
  61.         begin
  62.           P := MiddleTPA(MollySplit[0]);
  63.           if Debug then
  64.             begin
  65.               SMART_DrawBoxes(False, [Searchbox], clYellow);
  66.               SMART_DrawBoxes(False, [GetTPABounds(MollySplit[0])], clRed);
  67.               SMART_DrawCircle(False, P, 5, False, clAqua);
  68.             end;
  69.           MMouse(P.X, P.Y, RandomRange(-2, 2), RandomRange(-2, 2));
  70.           Wait(50 + Random(100));
  71.           ClickMouse2(1);
  72.         end;
  73.     end;
  74. end;
  75.  
  76. {*******************************************************************************
  77. procedure MollyTalk;
  78. by: J J
  79. Description: Handles the conversations with Molly
  80. *******************************************************************************}
  81. procedure MollyTalk;
  82. begin
  83.   if AreTalking then
  84.     begin
  85.       repeat
  86.         if not(ClickContinue(True, True)) then
  87.           TypeSendEx('1', False);
  88.           Wait(750 + Random(750));
  89.       until not(AreTalking);
  90.     end;
  91. end;
  92.  
  93. {*******************************************************************************
  94. procedure GrabMollyHairColor;
  95. by: J J
  96. Description: Returns molly's hair color by using the hair color while in chat
  97. *******************************************************************************}
  98. procedure GrabMollyHairColor;
  99. var
  100.   HairColor, Tol, i: Integer;
  101.   HairColorExtended, Lowest: Extended;
  102.   HairColors: TIntegerArray;
  103.   Speed2Modifiers, HairDefinedColors: TExtendedArray;
  104.  
  105. begin
  106.   HairColors := GetColors(TPAFromBox(IntToBox(48, 375, 67, 396)));
  107.   HairColor := GetBestColor(HairColors, 2, Tol, Speed2Modifiers);
  108.  
  109.   if Debug then
  110.     begin
  111.       SMART_DrawCircle(False, Point(59, 389), 5, False, clGreen);
  112.       WriteLn('Hair colors: '+ToStr(HairColors)+'');
  113.       WriteLn('Best molly hair color: '+ToStr(HairColor)+'');
  114.       WriteLn('Best tolerance: '+ToStr(Tol)+'');
  115.       WriteLn('Modifiers: '+ToStr(Speed2Modifiers)+'');
  116.     end;
  117.  
  118.   // Dark brown, dark blond, light brown, red, lightblond \\
  119.   HairDefinedColors := [2178123, 3103606, 3954284, 2441835, 2843007];
  120.   HairColorExtended := HairColor;
  121.   Lowest := HairDefinedColors[0]+1;
  122.   for i:=0 to 4 do
  123.     begin
  124.       if Abs(HairColor-HairDefinedColors[i]) < Lowest then
  125.         begin
  126.           Lowest := Abs(HairColor-HairDefinedColors[i]);
  127.           case i of
  128.             0: MollyHair := 'DarkBrown';
  129.             1: MollyHair := 'DarkBlond';
  130.             2: MollyHair := 'LightBrown';
  131.             3: MollyHair := 'Red';
  132.             4: MollyHair := 'LightBlond';
  133.           end;
  134.         end;
  135.     end;
  136.   WriteLn('Molly''s hair color: '+MollyHair+'');
  137. end;
  138.  
  139. {*******************************************************************************
  140. procedure OpenMollyDoor(Where: String);
  141. by: J J
  142. Description: Opens the door in the Molly random event
  143.              Uses the brown colors of the door
  144. *******************************************************************************}
  145. procedure OpenMollyDoor(Where: String);
  146. var
  147.   N: Integer;
  148.   P: TPoint;
  149.   Door: TPointArray;
  150.   DoorSplit: T2DPointArray;
  151.   Searchbox: Array of TBox;
  152.   Hue, Sat: Array of Extended;
  153.   Col, Tol: Array of Integer;
  154.  
  155. begin
  156.   case where of
  157.     'begin': N := 0;
  158.     'end':   N := 1;
  159.   end;
  160.   SearchBox := [IntToBox(380, 80, 480, 180), IntToBox(10, 70, 90, 180)];
  161.   Col := [7115939, 6063508];
  162.   Tol := [5, 11];
  163.   Hue := [0.35, 0.17];
  164.   Sat := [0.77, 0.34];
  165.  
  166.   ColorToleranceSpeed(2);
  167.   SetColorSpeed2Modifiers(Hue[N], Sat[N]);
  168.   if FindColorsSpiralTolerance(MSCX, MSCY, Door, Col[N], SearchBox[N].X1, SearchBox[N].Y1, SearchBox[N].X2, SearchBox[N].Y2, Tol[N]) then
  169.     begin
  170.       WriteLn('Found the door, opening it!');
  171.       SplitTPAExWrap(Door, 3, 3, DoorSplit);
  172.       SortATPASize(DoorSplit, True);
  173.       if Length(DoorSplit[0]) > 10 then
  174.         begin
  175.           P := MiddleTPA(DoorSplit[0]);
  176.           if Debug then
  177.             begin
  178.               SMART_DrawBoxes(False, [GetTPABounds(DoorSplit[0])], clRed);
  179.               SMART_DrawDotsEx(False, Door, clGreen);
  180.               SMART_DrawDotsEx(False, DoorSplit[0], clYellow);
  181.               SMART_DrawCircle(False, P, 2, True, clPurple);
  182.             end;
  183.           MMouse(P.x, P.y, RandomRange(-5, 5), RandomRange(-5, 5));
  184.           Wait(RandomRange(50, 150));
  185.           case Random(7) of
  186.             0..4: ClickMouse2(1);
  187.             5..6: begin
  188.                     ClickMouse2(0);
  189.                     WaitOptionMulti(['pen', 'Open'], 1000);
  190.                   end;
  191.           end;
  192.         end;
  193.     end;
  194. end;
  195.  
  196. {*******************************************************************************
  197. procedure UseControls;
  198. by: J J
  199. Description: Opens the control panel in the Molly random event
  200.              Uses the wooden parts of the control panel
  201. *******************************************************************************}
  202. procedure UseControls;
  203. var
  204.   P: TPoint;
  205.   Controls: TPointArray;
  206.   ControlsSplit: T2DPointArray;
  207.  
  208. begin
  209.   ColorToleranceSpeed(2);
  210.   SetColorSpeed2Modifiers(0.32, 1.67);
  211.   if FindColorsSpiralTolerance(MSCX, MSCY, Controls, 3366960, MSX1, 80, MSX2, 280, 4) then
  212.     begin
  213.       WriteLn('Detected the machine, clicking on it!');
  214.       SplitTPAExWrap(Controls, 2, 2, ControlsSplit);
  215.       SortATPASize(ControlsSplit, True);
  216.       if Length(ControlsSplit[0]) > 2 then
  217.         begin
  218.           P := MiddleTPA(ControlsSplit[0]);
  219.           if Debug then
  220.             begin
  221.               SMART_DrawBoxes(False, [GetTPABounds(ControlsSplit[0])], clRed);
  222.               SMART_DrawDotsEx(False, Controls, clGreen);
  223.               SMART_DrawDotsEx(False, ControlsSplit[0], clYellow);
  224.               SMART_DrawCircle(False, P, 2, True, clPurple);
  225.             end;
  226.           MMouse(P.x, P.y, RandomRange(-5, 5), RandomRange(-5, 5));
  227.           Wait(RandomRange(50, 150));
  228.           case Random(7) of
  229.             0..4: ClickMouse2(1);
  230.             5..6: begin
  231.                     ClickMouse2(0);
  232.                     WaitOptionMulti(['ontrol', 'Use', 'panel'], 1000);
  233.                   end;
  234.           end;
  235.         end;
  236.     end;
  237. end;
  238.  
  239. {*******************************************************************************
  240. function HookPosition: String;
  241. by: J J
  242. Description: Returns the angle of the hook by using the fence to calculate
  243.              the perspective.
  244. *******************************************************************************}
  245. function HookPosition: String;
  246. var
  247.   X, Y, i, NormalDTM, TwoLeftDTM, OneLeftDTM, OneRightDTM, TwoRightDTM: Integer;
  248.   DTMArray: Array of Integer;
  249.  
  250. begin
  251.   NormalDTM := DTMFromString('mlwAAAHicY2dgYGBiZGBQBtKaQHwXyH4IxCuA7AQgfQFInwfiR1B8EYld4qzC0OytyZBoIQfGWbaKDHn2SmA2P1AeF2bCg6EAAOTUDx0=');
  252.   TwoLeftDTM := DTMFromString('mlwAAAHicY2dgYMhlZWA4zMLAcBSIfwKxCRsDgz4QvwGK/wbK3wTiV1DMz8jAIA/EPECcaiXPkGWryJBoIceQbCnPkG6jAGaDxPlBanFgJjwYCgC16Q3z');
  253.   OneLeftDTM := DTMFromString('mlwAAAHicY2dgYKhkZWA4xMLAcASI/wGxPRsDgzUQ/wSK/wHKPwfib0D8EYgZGBkYhIGYFYiTLeUZ0m0UGBIt5FDYqVbyDPxApbgwEx4MBQDPBg4e');
  254.   OneRightDTM := DTMFromString('mlwAAAHicY2dgYOhnZWBwZmNgsAXibhYGhglAzA8UYwXyfwDl7wHxJyBmZmRgEAdiJiB+B+QnWsgxtPtpMcSbyzKkWsmDaZBYsqU8Az9QHhdmwoOhAACpYAwC');
  255.   TwoRightDTM := DTMFromString('mlwAAAHicY2dgYIhhZWBgZ2NgYAHi80D2NBYGhplAfA+IfwPlbwHxSyB+AcS8jAwMCkDMA8SpVvIM6TYKDIkWcmB2lq0inM0PVIsLM+HBUAAAI+IM+Q==');
  256.  
  257.   DTMArray := [NormalDTM, TwoLeftDTM, OneLeftDTM, OneRightDTM, TwoRightDTM];
  258.  
  259.   for i:=0 to 4 do
  260.     begin
  261.       if FindDTM(DTMArray[i], X, Y, MSX1, MSY1, MSX2, MSY2) then
  262.         begin
  263.           case i of
  264.             0: Result := 'Normal';
  265.             1: Result := 'TwoLeft';
  266.             2: Result := 'OneLeft';
  267.             3: Result := 'OneRight';
  268.             4: Result := 'TwoRight';
  269.           end;
  270.           Break;
  271.         end;
  272.     end;
  273.  
  274.   FreeDTMs([NormalDTM, TwoLeftDTM, OneLeftDTM, OneRightDTM, TwoRightDTM]);
  275. end;
  276.  
  277. {*******************************************************************************
  278. function NormalHook: Integer;
  279. by: J J
  280. Description: Finds the position of the hook if it is positioned in a normal
  281.              perspective. It returns an integer which resembles a position
  282.              on this map: http://img841.imageshack.us/img841/4879/tilesystem.png
  283. *******************************************************************************}
  284. function NormalHook: Integer;
  285. var
  286.   i, x, CountedColors, Highest: Integer;
  287.   Row: Array[0..6] of Array[0..9] of TBox;
  288.   X1, Y1, X2, Y2, Multiplier: Array of Integer;
  289.  
  290. begin
  291.   X1 := [66, 83, 97, 109, 120, 129, 137, 144, 150, 156];
  292.   Y1 := [210, 178, 152, 130, 112, 95, 81, 68, 57, 47];
  293.   X2 := [100, 121, 132, 141, 148, 156, 162, 167, 173, 177];
  294.   Y2 := [234, 199, 171, 145, 124, 106, 90, 77, 64, 53];
  295.   Multiplier := [58, 52, 48, 45, 41, 39, 36, 34, 32, 31];
  296.  
  297.   for i:=0 to 6 do
  298.     begin
  299.       for x:=0 to 9 do
  300.         begin
  301.           Row[i][x] := IntToBox(X1[x] + (i * Multiplier[x]), Y1[x], X2[x] + (i * Multiplier[x]), Y2[x]);
  302.           if Debug then
  303.             SMART_DrawBoxes(False, [Row[i][x]], clRed);
  304.           CountedColors := CountColorTolerance(2373117, Row[i][x].X1, Row[i][x].Y1, Row[i][x].X2, Row[i][x].Y2, 5);
  305.           if CountedColors > Highest then
  306.             begin
  307.               Highest := CountedColors;
  308.               Result := (20 + (10 * i) + x);
  309.               WriteLn('Hook box position:  '+IntToStr(((10 * i) + x + 20))+'');
  310.             end;
  311.         end;
  312.     end;
  313. end;
  314.  
  315. {*******************************************************************************
  316. function TwoLeftHook: Integer;
  317. by: J J
  318. Description: Finds the position of the hook if it is positioned in the two left
  319.              perspective. It returns an integer which resembles a position
  320.              on this map: http://img841.imageshack.us/img841/4879/tilesystem.png
  321. *******************************************************************************}
  322. function TwoLeftHook: Integer;
  323. var
  324.   i, CountedColors, Highest: Integer;
  325.   Box: Array[0..9] of TBox;
  326.   X1, Y1, X2, Y2: Array of Integer;
  327.  
  328. begin
  329.   X1 := [76, 105, 128, 147, 164, 178, 191, 203, 213, 222];
  330.   Y1 := [184, 158, 137, 119, 103, 89, 77, 65, 55, 46];
  331.   X2 := [112, 138, 157, 174, 189, 202, 214, 224, 233, 242];
  332.   Y2 := [208, 177, 153, 133, 115, 99, 86, 74, 63, 53];
  333.  
  334.   for i:=0 to 9 do
  335.     begin
  336.       Box[i] := IntToBox(X1[i], Y1[i], X2[i], Y2[i]);
  337.       if Debug then
  338.         SMART_DrawBoxes(False, [Box[i]], clRed);
  339.       CountedColors := CountColorTolerance(2373117, Box[i].X1, Box[i].Y1, Box[i].X2, Box[i].Y2, 5);
  340.       if CountedColors > Highest then
  341.         begin
  342.           Highest := CountedColors;
  343.           Result := i;
  344.           WriteLn('Hook box position: '+IntToStr(i)+'');
  345.         end;
  346.     end;
  347. end;
  348.  
  349. {*******************************************************************************
  350. function OneLeftHook: Integer;
  351. by: J J
  352. Description: Finds the position of the hook if it is positioned in the one left
  353.              perspective. It returns an integer which resembles a position
  354.              on this map: http://img841.imageshack.us/img841/4879/tilesystem.png
  355. *******************************************************************************}
  356. function OneLeftHook: Integer;
  357. var
  358.   i, CountedColors, Highest: Integer;
  359.   Box: Array[0..9] of TBox;
  360.   X1, Y1, X2, Y2: Array of Integer;
  361.  
  362. begin
  363.   X1 := [71, 94, 112, 128, 142, 154, 164, 174, 182, 190];
  364.   Y1 := [196, 167, 143, 123, 106, 90, 77, 65, 54, 45];
  365.   X2 := [108, 128, 144, 157, 168, 180, 188, 197, 203, 210];
  366.   Y2 := [222, 187, 160, 138, 118, 101, 86, 73, 62, 51];
  367.  
  368.   for i:=0 to 9 do
  369.     begin
  370.       Box[i] := IntToBox(X1[i], Y1[i], X2[i], Y2[i]);
  371.       if Debug then
  372.         SMART_DrawBoxes(False, [Box[i]], clRed);
  373.       CountedColors := CountColorTolerance(2373117, Box[i].X1, Box[i].Y1, Box[i].X2, Box[i].Y2, 5);
  374.       if CountedColors > Highest then
  375.         begin
  376.           Highest := CountedColors;
  377.           Result := (10 + i)
  378.           WriteLn('Hook box position: '+IntToStr((10 + i))+'');
  379.         end;
  380.     end;
  381. end;
  382.  
  383. {*******************************************************************************
  384. function TwoRightHook: Integer;
  385. by: J J
  386. Description: Finds the position of the hook if it is positioned in the two right
  387.              perspective. It returns an integer which resembles a position
  388.              on this map: http://img841.imageshack.us/img841/4879/tilesystem.png
  389. *******************************************************************************}
  390. function TwoRightHook: Integer;
  391. var
  392.   i, CountedColors, Highest: Integer;
  393.   Box: Array[0..7] of TBox;
  394.   X1, Y1, X2, Y2: Array of Integer;
  395.  
  396. begin
  397.   X1 := [420, 380, 360, 343, 328, 316, 304, 294];
  398.   Y1 := [182, 158, 137, 119, 103, 89, 77, 66];
  399.   X2 := [445, 413, 390, 371, 354, 339, 327, 315];
  400.   Y2 := [210, 177, 153, 133, 115, 99, 86, 74];
  401.  
  402.   for i:=0 to 7 do
  403.     begin
  404.       Box[i] := IntToBox(X1[i], Y1[i], X2[i], Y2[i]);
  405.       if Debug then
  406.         SMART_DrawBoxes(False, [Box[i]], clRed);
  407.       CountedColors := CountColorTolerance(2373117, Box[i].X1, Box[i].Y1, Box[i].X2, Box[i].Y2, 5);
  408.       if CountedColors > Highest then
  409.         begin
  410.           Highest := CountedColors;
  411.           Result := (100 + i);
  412.           WriteLn('Hook box position: '+IntToStr((100 + i))+'');
  413.         end;
  414.     end;
  415. end;
  416.  
  417. {*******************************************************************************
  418. function OneRightHook: Integer;
  419. by: J J
  420. Description: Finds the position of the hook if it is positioned in the one right
  421.              perspective. It returns an integer which resembles a position
  422.              on this map: http://img841.imageshack.us/img841/4879/tilesystem.png
  423. *******************************************************************************}
  424. function OneRightHook: Integer;
  425. var
  426.   i, CountedColors, Highest: Integer;
  427.   Box: Array[0..7] of TBox;
  428.   X1, Y1, X2, Y2: Array of Integer;
  429.  
  430. begin
  431.   X1 := [422, 389, 373, 360, 349, 338, 329, 321];
  432.   Y1 := [196, 167, 144, 123, 106, 91, 77, 65];
  433.   X2 := [448, 424, 405, 390, 376, 364, 353, 344];
  434.   Y2 := [222, 187, 160, 138, 118, 101, 86, 73];
  435.  
  436.   for i:=0 to 7 do
  437.     begin
  438.       Box[i] := IntToBox(X1[i], Y1[i], X2[i], Y2[i]);
  439.       if Debug then
  440.         SMART_DrawBoxes(False, [Box[i]], clRed);
  441.       CountedColors := CountColorTolerance(2373117, Box[i].X1, Box[i].Y1, Box[i].X2, Box[i].Y2, 5);
  442.       if CountedColors > Highest then
  443.         begin
  444.           Highest := CountedColors;
  445.           Result := (90 + i);
  446.           WriteLn('Hook box position: '+IntToStr((90 + i))+'');
  447.         end;
  448.     end;
  449. end;
  450.  
  451. {*******************************************************************************
  452. function MoveHook(Box: Integer): Boolean;
  453. by: J J
  454. Description: Moves the hook to a box number you input. The box number resembles
  455.              a position this map: http://img841.imageshack.us/img841/4879/tilesystem.png
  456. *******************************************************************************}
  457. function MoveHook(Box: Integer): Boolean;
  458. var
  459.   H, V, X, Y, BoxRow, HookBoxRow, Horizontal, Vertical, BoxSpot, HookBoxSpot: Integer;
  460.  
  461. begin
  462.   if Box = -1 then
  463.     begin
  464.       Wait(2000 + Random(2000));
  465.       WriteLn('Not moving the hook because the box is false!');
  466.       Exit;
  467.     end;
  468.  
  469.   if not(Box = HookBox) then
  470.     begin
  471.       // Horizontal movement
  472.       BoxRow := (Box / 10);
  473.       HookBoxRow := (HookBox / 10);
  474.       WriteLn('BoxRow: '+IntToStr(BoxRow)+'');
  475.       WriteLn('HookBoxRow: '+IntToStr(HookBoxRow)+'');
  476.  
  477.       if not(BoxRow = HookBoxRow) then
  478.         begin
  479.           if (BoxRow > HookBoxRow) then
  480.             begin
  481.               WriteLn('BoxRow > HookBoxRow');
  482.               Horizontal := (BoxRow - HookBoxRow);
  483.               WriteLn('Move Right '+IntToStr(Horizontal)+' times');
  484.               repeat
  485.                 Inc(H);
  486.                 if (H > 1) then
  487.                   begin
  488.                     GetMousePos(X, Y);
  489.                     MMouse(X, Y, RandomRange(-2, 2), RandomRange(-2, 2));
  490.                     ClickMouse2(1);
  491.                   end else
  492.                   begin
  493.                     MouseBox(700, 325, 720, 340, 1);
  494.                   end;
  495.                 Wait(75 + Random(25));
  496.                 WriteLn('H: '+IntToStr(H)+'');
  497.               until(H >= Horizontal);
  498.             end else
  499.             begin
  500.               WriteLn('HookBoxRow > BoxRow');
  501.               Horizontal := (HookBoxRow - BoxRow);
  502.               WriteLn('Move left '+IntToStr(Horizontal)+' times');
  503.               repeat
  504.                 Inc(H);
  505.                 if (H > 1) then
  506.                   begin
  507.                     GetMousePos(X, Y);
  508.                     MMouse(X, Y, RandomRange(-2, 2), RandomRange(-2, 2));
  509.                     ClickMouse2(1);
  510.                   end else
  511.                   begin
  512.                     MouseBox(570, 325, 590, 340, 1);
  513.                   end;
  514.                 Wait(75 + Random(25));
  515.                 WriteLn('H: '+IntToStr(H)+'');
  516.               until(H >= Horizontal);
  517.             end;
  518.         end else
  519.         begin
  520.           WriteLn('Correct row');
  521.         end;
  522.  
  523.       // Vertical movement
  524.       HookBoxSpot := (HookBox - (HookBoxRow * 10));
  525.       BoxSpot := (Box - (BoxRow * 10));
  526.       WriteLn('HookBoxspot: '+IntToStr(HookBoxSpot)+'');
  527.       WriteLn('Boxspot: '+IntToStr(BoxSpot)+'');
  528.  
  529.       if not(BoxSpot = HookBoxSpot) then
  530.         begin
  531.           if (BoxSpot > HookBoxSpot) then
  532.             begin
  533.               Vertical := (BoxSpot - HookBoxSpot);
  534.               WriteLn('Move up '+IntToStr(Vertical)+' times');
  535.               repeat
  536.                 Inc(V);
  537.                 if (V > 1) then
  538.                   begin
  539.                     GetMousePos(X, Y);
  540.                     MMouse(X, Y, RandomRange(-2, 2), RandomRange(-2, 2));
  541.                     ClickMouse2(1);
  542.                   end else
  543.                   begin
  544.                     MouseBox(635, 265, 650, 280, 1);
  545.                   end;
  546.                 Wait(75 + Random(25));
  547.                 WriteLn('V: '+IntToStr(V)+'');
  548.               until(V >= Vertical);
  549.             end else
  550.             begin
  551.               WriteLn('HookBoxspot > BoxSpot');
  552.               Vertical := (HookBoxSpot - BoxSpot);
  553.               WriteLn('Move down '+IntToStr(Vertical)+' times');
  554.               repeat
  555.                 Inc(V);
  556.                 if (V > 1) then
  557.                   begin
  558.                     GetMousePos(X, Y);
  559.                     MMouse(X, Y, RandomRange(-2, 2), RandomRange(-2, 2));
  560.                     ClickMouse2(1);
  561.                   end else
  562.                   begin
  563.                     MouseBox(635, 385, 650, 405, 1);
  564.                   end;
  565.                 Wait(75 + Random(25));
  566.                 WriteLn('V: '+IntToStr(V)+'');
  567.               until(V >= Vertical);
  568.             end;
  569.         end else
  570.         begin
  571.           WriteLn('Correct spot');
  572.         end;
  573.     end else
  574.     begin
  575.       WriteLn('Correct spot and row!');
  576.       Result := True;
  577.     end;
  578.   Wait(600 + Random(200));
  579. end;
  580.  
  581. {*******************************************************************************
  582. function MollyLocation: TPoint;
  583. by: J J
  584. Description: Returns a TPoint of the location of the correct Molly's boots
  585.              This TPoint can be used in the Mollybox function to convert it
  586.              to a box number
  587. *******************************************************************************}
  588. function MollyLocation: TPoint;
  589. var
  590.   X, Y, Q, i: Integer;
  591.   P, T: TPoint;
  592.   Hair, Boots: TPointArray;
  593.   HairSplit, BootsSplit: T2DPointArray;
  594.   SearchBox: TBox;
  595.   Col, Tol: Array of Integer;
  596.   Hue, Sat: Array of Extended;
  597.  
  598. begin
  599.   case MollyHair of
  600.     'LightBrown': Q := 0;
  601.     'DarkBrown':  Q := 1;
  602.     'LightBlond': Q := 2;
  603.     'DarkBlond':  Q := 3;
  604.     'Red':        Q := 4;
  605.   end;
  606.  
  607.   Col := [3161416, 1517614, 3658722, 3573399, 2710186];
  608.   Tol := [14, 10, 10, 20, 17];
  609.   Hue := [0.13, 0.21, 0.15, 0.08, 0.11];
  610.   Sat := [0.08, 0.64, 2.31, 0.49, 0.59];
  611.  
  612.   ColorToleranceSpeed(2);
  613.   SetColorSpeed2Modifiers(Hue[Q], Sat[Q]);
  614.   if FindColorsSpiralTolerance(X, Y, Hair, Col[Q], MSX1, MSY1, MSX2, 200, Tol[Q]) then
  615.     begin
  616.       if (Length(Hair) > 10)then
  617.         begin
  618.           if Debug then
  619.             SMART_DrawDotsEx(False, Hair, clPurple);
  620.           SplitTPAExWrap(Hair, 1, 1, HairSplit);
  621.           SortATPASize(HairSplit, True);
  622.           for i:=0 to high(HairSplit) do
  623.             begin
  624.               if (Length(HairSplit[i]) > 10) and (Length(HairSplit[i]) < 100) then
  625.                 begin
  626.                   P := MiddleTPA(HairSplit[i]);
  627.                   SearchBox := IntToBox(P.X-6, P.Y+2, P.X+6, P.Y+8);
  628.                   if Debug then
  629.                     SMART_DrawBoxes(False, [SearchBox], clRed);
  630.                   SetColorSpeed2Modifiers(0.09, 0.85);
  631.                   if FindColorSpiralTolerance(X, Y, 4555446, SearchBox.X1, SearchBox.Y1, SearchBox.X2, SearchBox.Y2, 21) then
  632.                     begin
  633.                       WriteLn('Potential Molly has been found at: '+IntToStr(P.X)+', '+IntToStr(P.Y)+'');
  634.                       if Debug then
  635.                         begin
  636.                           SMART_DrawCircle(False, P, 5, True, clGreen);
  637.                           SMART_DrawBoxes(False, [IntToBox(SearchBox.X1-10, SearchBox.Y1+40, SearchBox.X2+10, SearchBox.Y2+70)], clYellow);
  638.                         end;
  639.                       SetColorSpeed2Modifiers(0.40, 0.68);
  640.                       if FindColorsSpiralTolerance(X, Y, Boots, 2176834, SearchBox.X1-5, SearchBox.Y1+40, SearchBox.X2+5, SearchBox.Y2+70, 11) then
  641.                         begin
  642.                           SplitTPAExWrap(Boots, 2, 2, BootsSplit);
  643.                           SortATPASize(BootsSplit, True);
  644.                           T := Point(MiddleTPA(Boots).X, GetTPABounds(BootsSplit[0]).Y2);
  645.                           if Debug then
  646.                             begin
  647.                               SMART_DrawDotsEx(False, Boots, clAqua);
  648.                               SMART_DrawCircle(False, T, 3, True, clRed);
  649.                             end;
  650.                           WriteLn('Detected boots, correct Molly has been found at '+IntToStr(T.X)+', '+IntToStr(T.Y)+'');
  651.                           Result := T;
  652.                           Break;
  653.                         end;
  654.                     end;
  655.                 end;
  656.             end;
  657.         end;
  658.     end;
  659. end;
  660.  
  661. {*******************************************************************************
  662. function MollyBox(MollyTPoint: TPoint): Integer;
  663. by: J J
  664. Description: Returns an integer which resembles the position of Molly on this
  665.              grid: http://img841.imageshack.us/img841/4879/tilesystem.png
  666.              It uses the FindHair function to get the position of Molly.
  667. *******************************************************************************}
  668. function MollyBox(MollyPosition: TPoint): Integer;
  669. var
  670.   X, i, k: Integer;
  671.   YI, YII, Col, Tol, XSplit, YSplit, X1, Y1, X2, Y2, Multiplier, Height: Array of Integer;
  672.   Hue, Sat: Array of Extended;
  673.   Row: Array[0..10] of Array[0..9] of TBox;
  674.  
  675. begin
  676.   YI := [47, 45, 46, 51, 54];
  677.   YII := [237, 241, 250, 241, 250];
  678.   Hue := [0.12, 0.58];
  679.   Sat := [2.77, 0.99];
  680.   Col := [2240266, 3702093];
  681.   Tol := [5, 10];
  682.   XSplit := [6, 8];
  683.   YSplit := [6, 8];
  684.  
  685.   case HookPosition of
  686.     'Normal':   begin
  687.                   X := 0;
  688.                   X1 := [61, 78, 92, 104, 114, 124, 132, 139, 146, 151];
  689.                   Y1 := [210, 178, 152, 130, 112, 95, 81, 68, 57, 47];
  690.                   X2 := [110, 126, 137, 146, 153, 160, 166, 171, 177, 180];
  691.                   Y2 := [234, 199, 171, 145, 124, 106, 90, 77, 64, 53];
  692.                   Multiplier := [58, 52, 48, 45, 41, 39, 36, 34, 32, 31];
  693.                   for i:=0 to 10 do
  694.                     begin
  695.                       for k:=0 to 9 do
  696.                         begin
  697.                           case i of
  698.                             0: Row[i][k] := IntToBox(X1[k] + (-2 * Multiplier[k]), Y1[k], X2[k] + (-2 * Multiplier[k]), Y2[k]);
  699.                             1: Row[i][k] := IntToBox(X1[k] + (-1 * Multiplier[k]), Y1[k], X2[k] + (-1 * Multiplier[k]), Y2[k]);
  700.                             2..10: Row[i][k] := IntToBox(X1[k] + ((i-2) * Multiplier[k]), Y1[k], X2[k] + ((i-2) * Multiplier[k]), Y2[k]);
  701.                           end;
  702.                           if PointInBox(MollyPosition, IntToBox(Row[i][k].X1, Row[i][k].Y1, Row[i][k].X2, Row[i][k].Y2)) then
  703.                             begin
  704.                               Result := ((10 * i) + k);
  705.                               PreviousBox := Result;
  706.                               WriteLn('Molly is in box: '+IntToStr(Result)+'');
  707.                               Exit;
  708.                             end;
  709.                           if Debug then
  710.                             SMART_DrawBoxes(False, [Row[i][k]], clGreen);
  711.                         end;
  712.                     end;
  713.                 end;
  714.     'OneLeft':  begin
  715.                   X := 1;
  716.                   X1 := [69, 89, 105, 118, 140, 151, 162, 172, 180, 186];
  717.                   Y1 := [194, 167, 143, 123, 104, 90, 77, 66, 54, 43];
  718.                   X2 := [118, 133, 144, 156, 169, 180, 188, 197, 204, 211];
  719.                   Y2 := [224, 187, 160, 140, 117, 101, 86, 75, 64, 52];
  720.                   Multiplier := [62, 56, 52, 48, 38, 36, 34, 33, 32, 31];
  721.                   Height := [4, 3, 3, 3, 2, 2, 2, 1, 1, 1];
  722.                   for i:=0 to 10 do
  723.                     begin
  724.                       for k:=0 to 9 do
  725.                         begin
  726.                           case i of
  727.                             0: Row[i][k] := IntToBox(X1[k] + (-1 * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + (-1 * Multiplier[k]), Y2[k] + (Height[k]*i));
  728.                             1: Row[i][k] := IntToBox(X1[k] + (0 * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + (0 * Multiplier[k]), Y2[k] + (Height[k]*i));
  729.                             2..10: Row[i][k] := IntToBox(X1[k] + ((i-1) * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + ((i-1) * Multiplier[k]), Y2[k] + (Height[k]*i));
  730.                           end;
  731.                           if PointInBox(MollyPosition, IntToBox(Row[i][k].X1, Row[i][k].Y1, Row[i][k].X2, Row[i][k].Y2)) then
  732.                             begin
  733.                               Result := ((10 * i) + k);
  734.                               PreviousBox := Result;
  735.                               WriteLn('Molly is in box: '+IntToStr(Result)+'');
  736.                               Exit;
  737.                             end;
  738.                           if Debug then
  739.                             SMART_DrawBoxes(False, [Row[i][k]], clGreen);
  740.                         end;
  741.                     end;
  742.                 end;
  743.     'TwoLeft':  begin
  744.                   X := 2;
  745.                   X1 := [66, 96, 116, 135, 152, 170, 183, 195, 206, 215];
  746.                   Y1 := [184, 158, 135, 118, 101, 90, 77, 66, 55, 46];
  747.                   X2 := [122, 146, 162, 178, 192, 205, 217, 225, 235, 245];
  748.                   Y2 := [210, 181, 153, 135, 116, 102, 87, 75, 63, 53];
  749.                   Multiplier := [62, 56, 52, 48, 44, 41, 38, 35, 33, 31];
  750.                   Height := [8, 7, 7, 6, 6, 5, 5, 5, 4, 3];
  751.                   for i:=0 to 10 do
  752.                     begin
  753.                       for k:=0 to 9 do
  754.                         begin
  755.                           Row[i][k] := IntToBox(X1[k] + (i * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + (i * Multiplier[k]), Y2[k] + (Height[k]*i));
  756.                           if PointInBox(MollyPosition, IntToBox(Row[i][k].X1, Row[i][k].Y1, Row[i][k].X2, Row[i][k].Y2)) then
  757.                             begin
  758.                               Result := ((10 * i) + k);
  759.                               PreviousBox := Result;
  760.                               WriteLn('Molly is in box: '+IntToStr(Result)+'');
  761.                               Exit;
  762.                             end;
  763.                           if Debug then
  764.                             SMART_DrawBoxes(False, [Row[i][k]], clGreen);
  765.                         end;
  766.                     end;
  767.                 end;
  768.     'OneRight': begin
  769.                   X := 3;
  770.                   X1 := [420, 386, 371, 360, 349, 338, 329, 321, 318, 310];
  771.                   Y1 := [196, 167, 144, 123, 106, 89, 78, 64, 52, 40];
  772.                   X2 := [470, 431, 412, 396, 378, 366, 355, 345, 339, 331];
  773.                   Y2 := [222, 187, 160, 138, 118, 102, 88, 75, 60, 49];
  774.                   Multiplier := [62, 56, 52, 48, 44, 41, 38, 35, 34, 32];
  775.                   Height := [4, 4, 3, 3, 3, 3, 2, 2, 2, 2];
  776.                   for i:=0 to 10 do
  777.                     begin
  778.                       for k:=0 to 9 do
  779.                         begin
  780.                           case i of
  781.                             0: Row[i][k] := IntToBox(X1[k] + (1 * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + (1 * Multiplier[k]), Y2[k] + (Height[k]*i));
  782.                             1: Row[i][k] := IntToBox(X1[k] + (0 * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + (0 * Multiplier[k]), Y2[k] + (Height[k]*i));
  783.                             2..10: Row[i][k] := IntToBox(X1[k] + ((-i+1) * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + ((-i+1) * Multiplier[k]), Y2[k] + (Height[k]*i));
  784.                           end;
  785.                           if PointInBox(MollyPosition, IntToBox(Row[i][k].X1, Row[i][k].Y1, Row[i][k].X2, Row[i][k].Y2)) then
  786.                             begin
  787.                               Result := 100 - ((10 * i) - k);
  788.                               PreviousBox := Result;
  789.                               WriteLn('Molly is in box: '+IntToStr(Result)+'');
  790.                               Exit;
  791.                             end;
  792.                           if Debug then
  793.                             SMART_DrawBoxes(False, [Row[i][k]], clGreen);
  794.                         end;
  795.                     end;
  796.                 end;
  797.     'TwoRight': begin
  798.                   X := 4;
  799.                   X1 := [395, 373, 358, 341, 323, 311, 299, 290, 284, 277];
  800.                   Y1 := [182, 158, 137, 119, 103, 89, 79, 66, 52, 41];
  801.                   X2 := [447, 415, 394, 373, 359, 342, 331, 321, 311, 301];
  802.                   Y2 := [210, 177, 153, 132, 115, 99, 86, 74, 63, 54];
  803.                   Multiplier := [54, 45, 36, 34, 40, 38, 36, 33, 33, 33];
  804.                   Height := [8, 6, 4, 4, 4, 4, 4, 4, 4, 3];
  805.                   for i:=0 to 10 do
  806.                     begin
  807.                       for k:=0 to 9 do
  808.                         begin
  809.                           Row[i][k] := IntToBox(X1[k] + (-i * Multiplier[k]), Y1[k] + (Height[k]*i), X2[k] + (-i * Multiplier[k]), Y2[k] + (Height[k]*i));
  810.                           if PointInBox(MollyPosition, IntToBox(Row[i][k].X1, Row[i][k].Y1, Row[i][k].X2, Row[i][k].Y2)) then
  811.                             begin
  812.                               Result := 100 - ((10 * i) - k);
  813.                               PreviousBox := Result;
  814.                               WriteLn('Molly is in box: '+IntToStr(Result)+'');
  815.                               Exit;
  816.                             end;
  817.                           if Debug then
  818.                             SMART_DrawBoxes(False, [Row[i][k]], clGreen);
  819.                         end;
  820.                     end;
  821.                 end;
  822.   end;
  823.   // It only reaches this far if Molly isn't in a box.. If the box is -1 then it won't move the hook!
  824.   Result := -1;
  825. end;
  826.  
  827. {*******************************************************************************
  828. function CatchedMolly: Boolean;
  829. by: J J
  830. Description: Checks if the correct Molly has been catched
  831. *******************************************************************************}
  832. function CatchedMolly: Boolean;
  833. var
  834.   PossibleTexts: Array of String;
  835.   i, j: Integer;
  836.  
  837. begin
  838.   if FindChatBoxText('innoc', 8, clBlack) then
  839.     begin
  840.       Wait(12000 + Random(6000));
  841.       Inc(FalseMolly);
  842.       Result := False;
  843.     end;
  844.  
  845.   PossibleTexts := ['ongratulations', 'ongrat', 'tions', 'evil', 'twin'];
  846.   for i:=0 to high(PossibleTexts) do
  847.     begin
  848.       for j:=1 to 8 do
  849.         begin
  850.           if FindChatBoxText(PossibleTexts[i], j, clBlack) then
  851.             begin
  852.               Inc(CorrectMolly);
  853.               Result := True;
  854.               Break;
  855.             end;
  856.         end;
  857.     end;
  858.  
  859.   ClickContinue(True, True);
  860. end;
  861.  
  862. {*******************************************************************************
  863. procedure MollyMainloop;
  864. by: J J
  865. Description: Handles the Molly random event
  866. *******************************************************************************}
  867. begin
  868.   // Sets up some SRL related things
  869.   SetupLogin;
  870.   Debug := False;
  871.   SMART_ClearCanvas;
  872.   ClickNorth(SRL_Angle_High);
  873.   MarkTime(C);
  874.  
  875.   // Gets from the starting room to the control panel
  876.   OpenMollyDoor('begin');
  877.   Wait(4000 + Random(1500));
  878.   GrabMollyHairColor;
  879.   MollyTalk;
  880.   Wait(3000 + Random(1000));
  881.   UseControls;
  882.   Wait(5000 + Random(2000));
  883.  
  884.   // Handles the grabbing of Molly
  885.   repeat
  886.     repeat
  887.       SMART_ClearCanvas;
  888.       MouseSpeed := 30;
  889.       case HookPosition of
  890.         'Normal': Hookbox := NormalHook;
  891.         'TwoLeft': Hookbox := TwoLeftHook;
  892.         'OneLeft': Hookbox := OneLeftHook;
  893.         'TwoRight': Hookbox := TwoRightHook;
  894.         'OneRight': Hookbox := OneRightHook;
  895.       end;
  896.     until(MoveHook(MollyBox(MollyLocation)));
  897.     MouseSpeed := 100;
  898.     Mousebox(694, 420, 707, 434, 1);
  899.     Wait(3000 + Random(1000));
  900.   until(CatchedMolly);
  901.   Wait(16000 + Random(4000));
  902.   MouseSpeed := 15;
  903.  
  904.   // Handles the talking to Molly to finish
  905.   MollyTalk;
  906.   OpenMollyDoor('end');
  907.   Wait(6000 + Random(2000));
  908.   TalkToMolly;
  909.   Wait(3000 + Random(1000));
  910.   MollyTalk;
  911.  
  912.   WriteLn('Molly completed in: '+MsToTime(TimeFromMark(C), Time_Formal)+'');
  913.   WriteLn('Molly had the following hair color: '+MollyHair+'');
  914.   WriteLn('Innocent civilians caught: '+IntToStr(FalseMolly)+'');
  915. end.
Advertisement
Add Comment
Please, Sign In to add comment