WarPie90

Stupid fast miner at al kharid

Jan 3rd, 2023 (edited)
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 4.48 KB | None | 0 0
  1. program new;
  2. {$DEFINE SRL_USE_REMOTEINPUT}
  3. {$I SRL/osr.simba}
  4.  
  5. const
  6.   ORE_LOCATION: TPointArray = [[4985,3208],[4989, 3204],[4990, 3212]];
  7.   WHAT_TO_DROP: TRSItemArray = ['Iron ore','Tin ore'];
  8.  
  9. type
  10.   TClickHistory = record
  11.     Data: TRectArray;
  12.   end;
  13.  
  14.   TMiner = record
  15.     RSW: TRSWalker;
  16.     OreType: TCTS2Color;
  17.     OC: Int32;
  18.     StartupXP: Int32;
  19.   end;
  20.  
  21.  
  22. procedure TMouse.Move(Rect: TRectangle; ForcedMove: Boolean = False); override;
  23. begin
  24.   if (ForcedMove) or (not Rect.Contains(Mouse.Position())) then
  25.     Mouse.Move(srl.rowp(mouse.Position(), Rect));
  26. end;
  27.  
  28.  
  29. function TMiner.NextOre(pop: Boolean): TRectangle;
  30. var
  31.   i: Int32;
  32.   me,pt: TPoint;
  33. begin
  34.   me := RSW.GetMyPos();
  35.   pt := RSW.WorldToMM(me, ORE_LOCATION[OC], Minimap.GetCompassAngle(False));
  36.   Result := Minimap.PointToMsRect(pt);
  37.  
  38.   if pop then Inc(OC);
  39.   if OC = Length(ORE_LOCATION) then OC := 0;
  40. end;
  41.  
  42. function TMiner.IsOreAliveFast(R: TRectangle): Boolean;
  43. var
  44.   TPA: TPointArray;
  45.   B: TBox;
  46. begin
  47.   B := R.Bounds();
  48.   B.LimitTo(MainScreen.Bounds);
  49.   Result := srl.FindColors(TPA, Self.OreType, B) > 200;
  50. end;
  51.  
  52. function TMiner.IsOreAlive(R: TRectangle; out Fitted: TRectangle): Boolean;
  53. var
  54.   TPA: TPointArray;
  55.   B: TBox;
  56. begin
  57.   B := R.Bounds();
  58.   B.LimitTo(MainScreen.Bounds);
  59.  
  60.   if srl.FindColors(TPA, Self.OreType, B) then begin
  61.     TPA := R.Filter(TPA).Cluster(MainScreen.ConvertDistance(8)).Biggest();
  62.     Fitted := TPA.MinAreaRect();
  63.     Result := Length(TPA) > MainScreen.ConvertDistance(200);
  64.   end;
  65. end;
  66.  
  67. procedure TMiner.TryTurn(R: TRectangle);
  68. begin
  69.   if (R.Mean.DistanceTo(Mouse.Position) < 30) and (not Self.IsOreAliveFast(R)) then
  70.   begin
  71.     Mouse.Move(R);
  72.     Sleep(Random(60,90));
  73.     if MainScreen.IsUpText(['Mine', 'Rocks']) then
  74.       Mouse.Click(R, MOUSE_LEFT, Random() < 0.05);
  75.   end;
  76. end;
  77.  
  78. procedure TMiner.IntenseDrop();
  79. var
  80.   p: TPoint;
  81.   slots,order: TIntegerArray;
  82.   i: Int32;
  83.   n: Int32 = 3;
  84. begin
  85.   if Random(5) = 0 then
  86.     n := Random(2,6);
  87.  
  88.   p := MainScreen.Center.Random(50,50);
  89.   if Inventory.FindItems(WHAT_TO_DROP, Slots) then
  90.   begin
  91.     for i := 0 to High(DROP_PATTERN_REGULAR) do
  92.       if Slots.Find(DROP_PATTERN_REGULAR[I]) > -1 then
  93.         order += DROP_PATTERN_REGULAR[I];
  94.   end;
  95.  
  96.   if (Length(Slots) >= n) then
  97.   begin
  98.     SetLength(order, Min(Length(order), n));
  99.     Inventory.ShiftDrop(Inventory.ErrorPattern(order,3));
  100.     Mouse.Move(p,25);
  101.   end;
  102. end;
  103.  
  104. procedure TMiner.TrackExperience();
  105. var
  106.   xpNow, xpGained: Int32;
  107.   xp_hour: Double;
  108. begin
  109.   xpNow    := XPBar.Read();
  110.   xpGained := xpNow - Self.StartupXP;
  111.   xp_hour  := xpGained / GetTimeRunning() * 1000 * 60 * 60;
  112.   WriteLn(FloatToStr(Round(xp_hour,1))+' xp/h');
  113.   WriteLn(xpGained, ' total xp gained');
  114. end;
  115.  
  116. function TMiner.MineFastAsFuck(): Boolean;
  117. var
  118.   ore, fittedOre, next, junk: TRectangle;
  119.   missing, xp_prior, count: Int32;
  120. begin
  121.   while True do
  122.   begin
  123.     Ore := Self.NextOre(True);
  124.     if not Self.IsOreAlive(Ore, fittedOre) then
  125.     begin
  126.       missing += 1;
  127.       if (missing >= 3) or (Inventory.Count() > 6) then
  128.       begin
  129.         Self.IntenseDrop();
  130.         count := 0;
  131.       end;
  132.       continue;
  133.     end;
  134.     missing := 0;
  135.     count += 1;
  136.  
  137.     RSClient.Image.Clear();
  138.     RSClient.Image.DrawRect(fittedOre, $00FF00);
  139.  
  140.     Mouse.Move(fittedOre, Random() < 0.05);
  141.     Sleep(Random(60,90));
  142.     if not MainScreen.IsUpText('Mine Rocks') then
  143.       continue;
  144.  
  145.     xp_prior := XPBar.Read();
  146.     Mouse.Click(fittedOre, MOUSE_LEFT, Random() < 0.15);
  147.     if not MainScreen.DidRedClick() then
  148.       continue;
  149.  
  150.     if count <> 3 then
  151.     begin
  152.       next := Self.NextOre(False);
  153.       Mouse.Move(next);
  154.     end else
  155.       // we should move near item1, but because of a SRL bug, we can't hover the item before
  156.       // shiftdrop as that bugs out, and causes shift to not come down in time.  So we move
  157.       // to the combat tab, which is stupid... But fast
  158.       Mouse.Move(GameTabs.GetTabBox(ERSGameTab.COMBAT));
  159.  
  160.     WaitUntil((XPBar.Read() <> xp_prior) or (not Self.IsOreAlive(Ore,junk)) or (Chat.LeveledUp()) or Chat.FindOption('is too full to hold', [CHAT_COLOR_BLACK]), 20, Random(5000,10000));
  161.     RSClient.Image.DrawRect(fittedOre, $FF);
  162.  
  163.     Self.TryTurn(next);
  164.  
  165.     Self.TrackExperience();
  166.   end;
  167. end;
  168.  
  169.  
  170.  
  171. var
  172.   miner: TMiner;
  173. begin
  174.   miner.OreType := CTS2(2240329, 11, 0.12, 0.60);
  175.   miner.RSW.Setup('World');
  176.   mouse.Speed := Random(22,26);
  177.   miner.StartupXP := XPBar.Read();
  178.   miner.MineFastAsFuck();
  179. end.
Add Comment
Please, Sign In to add comment