Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 11.22 KB | None | 0 0
  1. program MahoganyPlankMaker;
  2. {$DEFINE SMART}
  3. {$i SRL\SRL.scar}
  4. {$i Reflection\Reflection.Simba}
  5. {$i SRL\SRL\Misc\Stats.Simba}
  6.  
  7.  
  8. const
  9.   S_Mems = True;    //Members?
  10.   S_World = 38;     //Smart world
  11.   S_Signed = True;  //Signed client?
  12.   Stats_User = '';  //SRL Stats username
  13.   Stats_Pass = '';  //SRL Stats password
  14.   ColorRandoms = False; //True for Color antirandoms, False for Reflection
  15.  
  16.  
  17. procedure DeclarePlayers;
  18. begin
  19.   HowManyPlayers := 1;
  20.   NumberOfPlayers(HowManyPlayers);
  21.   CurrentPlayer := 0;
  22.  
  23.   with Players[0] do
  24.   begin
  25.     Name := '';
  26.     Pass := '';
  27.     Nick := '';
  28.     Pin := '';
  29.     Active := True;
  30.   end;
  31. end;
  32.  
  33.  
  34. const
  35.   {Progress report info}
  36.   TimesCasted = 0;
  37.   Levels = 1;
  38.   PlanksMade = 2;
  39.  
  40.  
  41.  
  42. procedure Antiban;
  43. begin
  44.   case (49) of
  45.     0..4: MakeCompass(rs_GetCompassAngleDegrees - 40 + Random(80));
  46.     5..6: HoverSkill(SKILL_MAGIC, False);
  47.     7..8: PickUpMouse;
  48.     9: RandomRClick;
  49.   end;
  50. end;
  51.  
  52.  
  53. procedure Die(Reason: string; Active: Boolean);
  54. begin
  55.   if (Players[CurrentPlayer].Status <> '') then
  56.     Exit;
  57.   Writeln('Player ' + IntToStr(CurrentPlayer) + ' died because: ' + Reason);
  58.   Players[CurrentPlayer].Status := Reason;
  59.   Players[CurrentPlayer].Active := Active;
  60.   if BankScreen then
  61.     CloseBank;
  62.   Logout;
  63. end;
  64.  
  65.  
  66. procedure FRans;
  67. begin
  68.   if ColorRandoms then
  69.     FindNonInventoryRandoms
  70.   else
  71.     R_FindRandoms;
  72. end;
  73.  
  74.  
  75. function AttemptFuncion(func: function: Boolean; Attempts, WaitPer: Integer; RandomMovement: Boolean): Boolean;
  76. var
  77.   i, w, h: Integer;
  78. begin
  79.   for i := 1 to Attempts do
  80.   begin
  81.     if func() then
  82.     begin
  83.       Result := True;
  84.       Exit;
  85.     end;
  86.     if RandomMovement then
  87.     begin
  88.       GetClientDimensions(w, h);
  89.       MMouse(0, 0, w, h);
  90.     end;
  91.     Wait(WaitPer);
  92.     FRans;
  93.   end;
  94. end;
  95.  
  96.  
  97. function AttemptAndSwivel(func: function: Boolean; Attempts, SwivelPer: Integer): Boolean;
  98. var
  99.   i: Integer;
  100. begin
  101.   for i := 1 to Attempts do
  102.   begin
  103.     if func() then
  104.     begin
  105.       Result := True;
  106.       Exit;
  107.     end;
  108.     FRans;
  109.     MakeCompass(rs_GetCompassAngleDegrees + (SwivelPer + Random(10) - Random(10)));
  110.     Wait(800 + Random(80));
  111.   end;
  112. end;
  113.  
  114.  
  115. function FixLunarBook: Boolean;
  116. var
  117.   i: Integer;
  118. begin
  119.   if not(LoggedIn) or not(GameTab(tab_Magic)) then
  120.     Exit;
  121.    for i := 0 to 3 do //Actually click buttons
  122.    begin
  123.     if (i < 3) then
  124.       if (GetColor(589 + (i * 26), 442) <> 16711422) then
  125.       begin
  126.         Mouse(589 + (i * 26), 442, 15, 15, True);
  127.         Wait(950 + Random(600));
  128.       end;
  129.     if (i = 3) then //"Sort by Level" button
  130.       if (GetColor(675, 442) <> 16711422) then
  131.       begin
  132.         Mouse(675, 442, 15, 15, True);
  133.         Wait(950 + Random(600));
  134.       end;
  135.    end;
  136.    for i := 0 to 3 do //Making sure buttons were clicked
  137.    begin
  138.     if (i < 3) then
  139.       if (GetColor(589 + (i * 26), 442) <> 16711422) then
  140.         Exit;
  141.     if (i = 3) then
  142.       if (GetColor(675, 442) = 16711422) then
  143.         Result := True;
  144.    end;
  145. end;
  146.  
  147.  
  148. function PlankMakeActive: Boolean;
  149. begin
  150.   if not(LoggedIn) or not(GameTab(tab_Magic) or not(FixLunarBook)) then
  151.     Exit;
  152.   Result := (CountColorTolerance(7784661, 700, 335, 722, 357, 32) > 25);
  153. end;
  154.  
  155.  
  156. function CountLogs: Integer;
  157. var
  158.   i, x, y, LogDTM: Integer;
  159.   Box: TBox;
  160. begin
  161.   if not(LoggedIn) then
  162.     Exit;
  163.   LogDTM := DTMFromString('mggAAAHicY2NgYDjExMCwD4g3AfEOID4OxKeAuJSRgSEXiMuAuB6Ia4G4CIg7i32BupgwsByQxIYZcWAIAACWWAln');
  164.   for i := 1 to 28 do
  165.   begin
  166.     Box := InvBox(i);
  167.     if FindDTM(LogDTM, x, y, Box.X1, Box.Y1, Box.X2, Box.Y2) then
  168.       Inc(Result);
  169.   end;
  170.   FreeDTM(LogDTM);
  171. end;
  172.  
  173.  
  174. function OpenVWB: Boolean;
  175. var
  176.   TPA: TPointArray;
  177.   ATPA: T2DPointArray;
  178.   i, x, y, CTS: Integer;
  179.   HueMod, SatMod: Extended;
  180. begin
  181.   if not(LoggedIn) then
  182.     Exit;
  183.   CTS := GetColorToleranceSpeed;
  184.   SetColorToleranceSpeed(2);
  185.   GetColorspeed2Modifiers(HueMod, SatMod);
  186.   SetColorspeed2Modifiers(0.13, 0.45);
  187.   FindColorsTolerance(TPA, 2707293, MSX1, MSY1, MSX2, MSY2, 2);
  188.   SetColorToleranceSpeed(CTS);
  189.   SetColorspeed2Modifiers(HueMod, SatMod);
  190.   if (Length(TPA) < 1) then
  191.     Exit;
  192.   ATPA := TPAtoATPA(TPA, 30);
  193.   SortATPAFrom(ATPA, Point(MSCX, MSCY));
  194.   for i := 0 to High(ATPA) do
  195.   begin
  196.     if (Length(ATPA[i]) < 30) then
  197.       Continue;
  198.     MiddleTPAEx(ATPA[i], x, y);
  199.     if (PointInBox(Point(x, y), IntToBox(MSCX - 15, MSCY - 15, MSCX + 15, MSCY + 15))) then
  200.       Continue;
  201.     MMouse(x - 4, y - 4, 8, 8);
  202.     if WaitUptextMulti(['nk bo', 'e Bank b', 'booth'], 900) then
  203.     begin
  204.       ClickMouse2(False);
  205.       Result := WaitOptionMulti(['uickl', '-qui', 'e-quic', 'ckly'], 1800);
  206.     end;
  207.     if Result then
  208.       Break;
  209.   end;
  210.   if Result then
  211.   begin
  212.     Result := WaitFunc(@BankScreen, 10 + Random(10), 8000);
  213.   end;
  214. end;
  215.  
  216.  
  217. function WithdrawLogs: Boolean;
  218. var
  219.   i, LogDTM, Index, x, y, T: Integer;
  220.   Box: TBox;
  221. begin
  222.   if not(LoggedIn) or not(BankScreen) then
  223.     Exit;
  224.   FixBank;
  225.   LogDTM := DTMFromString('mggAAAHicY2NgYDjExMCwD4g3AfEOID4OxKeAuJSRgSEXiMuAuB6Ia4G4CIg7i32BupgwsByQxIYZcWAIAACWWAln');
  226.   for i := 1 to 40 do
  227.   begin
  228.     Box := BankIndexToMSBox(i);
  229.     if FindDTM(LogDTM, x, y, Box.X1, Box.Y1, Box.X2, Box.Y2) then
  230.     begin
  231.       Index := i;
  232.       Break;
  233.     end;
  234.   end;
  235.   FreeDTM(LogDTM);
  236.   if (Index = 0) then
  237.     Exit;
  238.   Box := BankIndexToMSBox(Index);
  239.   MouseBox(Box.X1, Box.Y1, Box.X2, Box.Y2, 3);
  240.   if WaitUpTextMulti(['gany', 'y lo', 'ahog'], 1600) then
  241.   begin
  242.     ClickMouse2(False);
  243.     Result := WaitOptionMulti(['ll Ma', 'All M'], 1500);
  244.   end;
  245.   T := GetSystemTime + 2000;
  246.   while (GetSystemTime < T) do
  247.     if (CountLogs > 0) then
  248.     begin
  249.       Result := True;
  250.       Exit;
  251.     end;
  252. end;
  253.  
  254.  
  255. function WaitTab(Tab, MaxTime: Integer): Boolean;
  256. var
  257.   T: Integer;
  258. begin
  259.   if not(LoggedIn) then
  260.     Exit;
  261.   T := GetSystemTime + MaxTime;
  262.   while (GetSystemTime < T) do
  263.   begin
  264.     if (GetCurrentTab = Tab) then
  265.     begin
  266.       Result := True;
  267.       Exit;
  268.     end;
  269.     WaitNone;
  270.   end;
  271. end;
  272.  
  273.  
  274. function CastPlankMake: Boolean;
  275. begin
  276.   if not(LoggedIn and PlankMakeActive) then
  277.     Exit;
  278.   MMouse(705, 334, 19, 19);
  279.   if WaitUptextMulti(['t Pl', 'nk M', 'ast P', 'lank M'], 2000) then
  280.   begin
  281.     ClickMouse2(True);
  282.     Result := WaitTab(tab_Inv, 2400);
  283.   end;
  284. end;
  285.  
  286.  
  287. function ClickMahogany: Boolean;
  288. var
  289.   i, MahoganyDTM, LogSlot, x, y: Integer;
  290.   Box: TBox;
  291. begin
  292.   if not(LoggedIn) or (GetCurrentTab <> tab_Inv) then
  293.     Exit;
  294.   MahoganyDTM := DTMFromString('mggAAAHicY2NgYDjExMCwD4g3AfEOID4OxKeAuJSRgSEXiMuAuB6Ia4G4CIg7i32BupgwsByQxIYZcWAIAACWWAln');
  295.   for i := 4 to 28 do //slot 1 = runes, slot 2 = runes, slot 3 = cash, slots 3-28 = logs
  296.   begin
  297.     Box := InvBox(i);
  298.     if FindDTM(MahoganyDTM, x, y, Box.X1, Box.Y1, Box.X2, Box.Y2) then
  299.     begin
  300.       LogSlot := i;
  301.       Break;
  302.     end;
  303.   end;
  304.   FreeDTM(MahoganyDTM);
  305.   if (LogSlot = 0) then
  306.   for i := 4 to 28 do
  307.   begin
  308.     Box := InvBox(i);
  309.     MouseBox(Box.X1, Box.Y1, Box.X2, Box.Y2, 3);
  310.     if WaitUptextMulti(['> M', 'e -> Ma'], 1600) then
  311.     begin
  312.       x := Round(Distance(Box.X1, Box.Y1, Box.X2, Box.Y1)/2) + Box.X1;
  313.       y := Round(Distance(Box.X1, Box.Y1, Box.X1, Box.Y2)/2) + Box.Y1;
  314.       Break;
  315.     end;
  316.   end;
  317.   MMouse(x - 8, y - 8, 16, 16);
  318.   if WaitUptextMulti(['> M', 'e -> Ma'], 1600) then
  319.   begin
  320.     ClickMouse2(True);
  321.     Result := WaitTab(tab_Magic, 2400);
  322.   end;
  323. end;
  324.  
  325.  
  326. function CountPlanks: Integer; //Call while bank screen is open
  327. var
  328.   PlankDTM, i, x, y: Integer;
  329.   Box: TBox;
  330. begin
  331.   if not(LoggedIn) then
  332.     Exit;
  333.   PlankDTM := DTMFromString('mggAAAHicY2NgYJjOxMAwE4inAvECIO4F4ilArM3IwCAPxJZArAjE5kCsAcSuJupAXUwYWI4BO2DEgSEAADqWBXA=');
  334.   for i := 4 to 28 do
  335.   begin
  336.     Box := InvBox(i);
  337.     if FindDTM(PlankDTM, x, y, Box.X1, Box.Y1, Box.X2, Box.Y2) then
  338.       Inc(Result);
  339.   end;
  340.   FreeDTM(PlankDTM);
  341. end;
  342.  
  343.  
  344. procedure Report;
  345. var
  346.   i: Integer;
  347. begin
  348.   Writeln('+---------------------------------------------+');
  349.   Writeln('| TomTuff''s Mahogonay Plank Maker             |');
  350.   Writeln('+---------------------------------------------+');
  351.   for i := 0 to High(Players) do
  352.   begin
  353.     Writeln('| Player ' + IntToStr(i) + '(' + Players[i].Nick  + ')');
  354.     writeln('| Worked: ' + MsToTime(PlayerWorked(i), time_Abbrev));
  355.     writeln('| Times Casted: ' + IntToStr(Players[i].Integers[TimesCasted]));
  356.     Writeln('| EXP: ' + IntToStr(Players[i].Integers[TimesCasted] * 90));
  357.     if (Players[i].Integers[Levels] > 0) then
  358.       Writeln('| Levels gained: ' + IntToStr(Players[i].Integers[Levels]));
  359.     Writeln('+---------------------------------------------+');
  360.   end;
  361. end;
  362.  
  363.  
  364. procedure CheckSRLStats;
  365. var
  366.   i: Integer;
  367. begin
  368.   if (Stats_User = '') or (Stats_Pass = '') then
  369.   begin
  370.     Writeln('Please get SRL Stats to avoid this 15 second wait.');
  371.     for i := 15 downto 1 do
  372.     begin
  373.       Writeln(IntToStr(i) + '...');
  374.       Wait(1000);
  375.     end;
  376.   end;
  377. end;
  378.  
  379.  
  380. procedure MainLoop;
  381. var
  382.   RemainingLogs: Integer;
  383. begin
  384.   Smart_Members := S_Mems;
  385.   Smart_Server := S_World;
  386.   Smart_Signed := S_Signed;
  387.   Smart_SuperDetail := False;
  388.   SetupSRL;
  389.   SetupSRLStats(40, Stats_User, Stats_Pass);
  390.   DeclarePlayers;
  391.   if not(LoggedIn) then
  392.   begin
  393.     LogInPlayer;
  394.     Wait(8000 + Random(2000));
  395.   end;
  396.   CheckSRLStats;
  397.   repeat
  398.     SetAngle(True);
  399.     repeat
  400.       RemainingLogs := 0;
  401.       FRans;
  402.       if AttemptAndSwivel(@OpenVWB, 8, 45) then
  403.       begin
  404.         Wait(1200 + Random(600));
  405.         stats_IncVariable('Mahogany Planks Made', CountPlanks);
  406.         IncEx(Players[CurrentPlayer].Integers[PlanksMade], CountPlanks);
  407.         Deposit(4, 28, True);
  408.         if AttemptFuncion(@WithdrawLogs, 5, 1200 + Random(800), True) then
  409.         begin
  410.           if CloseBank then
  411.           begin
  412.             stats_IncVariable('Times Banked', 1);
  413.             Inc(Players[CurrentPlayer].Banked);
  414.             Wait(800 + Random(400));
  415.           end else Die('could not close the bank', False);
  416.         end else Die('could not withdraw logs', False);
  417.       end else Die('could not open VWB', False);
  418.       Antiban;
  419.       repeat
  420.         FRans;
  421.         if AttemptFuncion(@CastPlankMake, 4, 1200 + Random(800), True) then
  422.         begin
  423.           Wait(200 + Random(200));
  424.           RemainingLogs := 0;
  425.           RemainingLogs := CountLogs;
  426.           FRans;
  427.           if AttemptFuncion(@ClickMahogany, 5, 1500 + Random(800), True) then
  428.           begin
  429.             stats_IncVariable('Total EXP Gained', 90);
  430.             stats_IncVariable('Plank Makes Casted', 1);
  431.             Inc(Players[CurrentPlayer].Integers[TimesCasted]);
  432.             Wait(900 + Random(300)); //1 cast = 3 game ticks
  433.             if LevelUp then
  434.             begin
  435.               stats_IncVariable('Total Levels Gained', 1);
  436.               Inc(Players[CurrentPlayer].Integers[Levels]);
  437.             end;
  438.           end else Die('could not click the logs in the inventory', False);
  439.         end else Die('could not cast plank make', False);
  440.       until (RemainingLogs = 1) or not(LoggedIn);
  441.       Report;
  442.       stats_Commit;
  443.     until(not(LoggedIn));
  444.     NextPlayer(Players[CurrentPlayer].Active);
  445.     Report;
  446.   until(AllPlayersInactive);
  447.   Report;
  448. end;
  449.  
  450.  
  451. begin
  452.   MainLoop;
  453.   Writeln('****** FINAL REPORT ******');
  454.   Report;
  455. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement