Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$DEFINE SRL_USE_REMOTEINPUT}
- {$I SRL/osr.simba}
- const
- ORE_LOCATION: TPointArray = [[4985,3208],[4989, 3204],[4990, 3212]];
- WHAT_TO_DROP: TRSItemArray = ['Iron ore','Tin ore'];
- type
- TClickHistory = record
- Data: TRectArray;
- end;
- TMiner = record
- RSW: TRSWalker;
- OreType: TCTS2Color;
- OC: Int32;
- StartupXP: Int32;
- end;
- procedure TMouse.Move(Rect: TRectangle; ForcedMove: Boolean = False); override;
- begin
- if (ForcedMove) or (not Rect.Contains(Mouse.Position())) then
- Mouse.Move(srl.rowp(mouse.Position(), Rect));
- end;
- function TMiner.NextOre(pop: Boolean): TRectangle;
- var
- i: Int32;
- me,pt: TPoint;
- begin
- me := RSW.GetMyPos();
- pt := RSW.WorldToMM(me, ORE_LOCATION[OC], Minimap.GetCompassAngle(False));
- Result := Minimap.PointToMsRect(pt);
- if pop then Inc(OC);
- if OC = Length(ORE_LOCATION) then OC := 0;
- end;
- function TMiner.IsOreAliveFast(R: TRectangle): Boolean;
- var
- TPA: TPointArray;
- B: TBox;
- begin
- B := R.Bounds();
- B.LimitTo(MainScreen.Bounds);
- Result := srl.FindColors(TPA, Self.OreType, B) > 200;
- end;
- function TMiner.IsOreAlive(R: TRectangle; out Fitted: TRectangle): Boolean;
- var
- TPA: TPointArray;
- B: TBox;
- begin
- B := R.Bounds();
- B.LimitTo(MainScreen.Bounds);
- if srl.FindColors(TPA, Self.OreType, B) then begin
- TPA := R.Filter(TPA).Cluster(MainScreen.ConvertDistance(8)).Biggest();
- Fitted := TPA.MinAreaRect();
- Result := Length(TPA) > MainScreen.ConvertDistance(200);
- end;
- end;
- procedure TMiner.TryTurn(R: TRectangle);
- begin
- if (R.Mean.DistanceTo(Mouse.Position) < 30) and (not Self.IsOreAliveFast(R)) then
- begin
- Mouse.Move(R);
- Sleep(Random(60,90));
- if MainScreen.IsUpText(['Mine', 'Rocks']) then
- Mouse.Click(R, MOUSE_LEFT, Random() < 0.05);
- end;
- end;
- procedure TMiner.IntenseDrop();
- var
- p: TPoint;
- slots,order: TIntegerArray;
- i: Int32;
- n: Int32 = 3;
- begin
- if Random(5) = 0 then
- n := Random(2,6);
- p := MainScreen.Center.Random(50,50);
- if Inventory.FindItems(WHAT_TO_DROP, Slots) then
- begin
- for i := 0 to High(DROP_PATTERN_REGULAR) do
- if Slots.Find(DROP_PATTERN_REGULAR[I]) > -1 then
- order += DROP_PATTERN_REGULAR[I];
- end;
- if (Length(Slots) >= n) then
- begin
- SetLength(order, Min(Length(order), n));
- Inventory.ShiftDrop(Inventory.ErrorPattern(order,3));
- Mouse.Move(p,25);
- end;
- end;
- procedure TMiner.TrackExperience();
- var
- xpNow, xpGained: Int32;
- xp_hour: Double;
- begin
- xpNow := XPBar.Read();
- xpGained := xpNow - Self.StartupXP;
- xp_hour := xpGained / GetTimeRunning() * 1000 * 60 * 60;
- WriteLn(FloatToStr(Round(xp_hour,1))+' xp/h');
- WriteLn(xpGained, ' total xp gained');
- end;
- function TMiner.MineFastAsFuck(): Boolean;
- var
- ore, fittedOre, next, junk: TRectangle;
- missing, xp_prior, count: Int32;
- begin
- while True do
- begin
- Ore := Self.NextOre(True);
- if not Self.IsOreAlive(Ore, fittedOre) then
- begin
- missing += 1;
- if (missing >= 3) or (Inventory.Count() > 6) then
- begin
- Self.IntenseDrop();
- count := 0;
- end;
- continue;
- end;
- missing := 0;
- count += 1;
- RSClient.Image.Clear();
- RSClient.Image.DrawRect(fittedOre, $00FF00);
- Mouse.Move(fittedOre, Random() < 0.05);
- Sleep(Random(60,90));
- if not MainScreen.IsUpText('Mine Rocks') then
- continue;
- xp_prior := XPBar.Read();
- Mouse.Click(fittedOre, MOUSE_LEFT, Random() < 0.15);
- if not MainScreen.DidRedClick() then
- continue;
- if count <> 3 then
- begin
- next := Self.NextOre(False);
- Mouse.Move(next);
- end else
- // we should move near item1, but because of a SRL bug, we can't hover the item before
- // shiftdrop as that bugs out, and causes shift to not come down in time. So we move
- // to the combat tab, which is stupid... But fast
- Mouse.Move(GameTabs.GetTabBox(ERSGameTab.COMBAT));
- 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));
- RSClient.Image.DrawRect(fittedOre, $FF);
- Self.TryTurn(next);
- Self.TrackExperience();
- end;
- end;
- var
- miner: TMiner;
- begin
- miner.OreType := CTS2(2240329, 11, 0.12, 0.60);
- miner.RSW.Setup('World');
- mouse.Speed := Random(22,26);
- miner.StartupXP := XPBar.Read();
- miner.MineFastAsFuck();
- end.
Add Comment
Please, Sign In to add comment