Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program CanItMine;
- {$DEFINE SRL_USE_REMOTEINPUT}
- {$I SRL/osr.simba}
- const
- USERNAME = '';
- PASSWORD = '';
- const
- // Everything else is kept, meaning you have to manually bank at times
- WHAT_TO_DROP: TRSItemArray = ['Iron ore','Tin ore'];
- // Extreme and Hyper focus can drop a minimum of? This Should not be more
- // than 3 for 3 rocks spawns, and more than 6 for 2 rock spawns. Has to do
- // with efficient timings.
- MIN_ORE_DROP_COUNT = 3; //4 might be good fit for 2 rock spawn.
- // How often is extreme mode allowed to turn towards the next ore, in percent
- // This mainly effects 2-rock spawns like 2xIron, 3xIron would almost always
- // have ores present, so not much turning there if any.
- EXTREME_TURN_PERCENTAGE = 75;
- type
- TClickHistory = record
- History: TRectArray;
- end;
- TMiner = record
- RSW: TRSWalker;
- OreLocations: TPointArray;
- Sequence: TIntegerArray;
- OreColor: array of TCTS2Color;
- SweivelTimer: Double;
- UnfocucsedTimer: Double;
- HyperFocusTimer: Double;
- ExtremeFocusTimer: Double;
- CanDebug: TCountDown;
- ClickOrder: TClickHistory;
- StartupXP: Int32;
- OreCounter: Int32;
- end;
- const
- F2P_WORLDS = [301,308,380,434,435,436,437,451];
- P2P_WORLDS = [302,303,304,305,306,307,309,310,311,312,313,314,315,317,318,319,320];
- var
- Bot: TMiner;
- procedure TClickHistory.Push(x: TRectangle);
- function IsDuplicateOfCurrent(): Boolean;
- var i: Int32;
- begin
- if Self.History[High(Self.History)].Mean().DistanceTo(x.Mean()) < 16 then
- Exit(True);
- end;
- procedure ShiftForward();
- var i: Int32;
- begin
- for i:=High(Self.History) downto 0 do
- Self.History[srl.Modulo(i+1, Length(Self.History))] := Self.History[i];
- end;
- begin
- // ensure this is not dupicate of the ore that was previously clicked
- // if it is then we shift the array to bring forth the next ore in previous sequence.
- // Note: This should not happen unless we are competing for rocks
- // Also might prevent some unexpected glitches.
- if IsDuplicateOfCurrent() then
- begin
- ShiftForward();
- Exit;
- end;
- // otherwise, push it in to the first slot. Bringing forth the last clicked rock
- // to the end, which is also the next rock to click.
- // This way we can access it with .Next()
- Insert(x, Self.History, 0);
- SetLength(Self.History, Length(Bot.OreLocations));
- end;
- function TClickHistory.Next(): TRectangle;
- begin
- // only if we have a full set of history should we predict
- if Length(Self.History) >= Length(Bot.OreLocations) then
- begin
- Result := Self.History[High(Self.History)];
- SetLength(Self.History, Length(Self.History)-1);
- end;
- end;
- function TClickHistory.Top(): TRectangle;
- begin
- Result := Self.History[High(Self.History)];
- 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;
- procedure TSRL.MouseOffClient(direction: Byte);
- var
- W,H: Int32;
- pt: TPoint;
- begin
- GetClientDimensions(W, H);
- pt := Mouse.Position();
- if (pt.X < 0) or (pt.X > W) or (pt.Y < 0) or (pt.Y > H) then
- Exit();
- if (direction >= 4) then
- direction := Random(0,3);
- case direction of
- 0: Mouse.Move(Box(-300, -300, W, 0)); // top
- 1: Mouse.Move(Box(0, H, W, H+300)); // bottom
- 2: Mouse.Move(Box(-300, 0, 0, H)); // left
- 3: Mouse.Move(Box(W, 0, W+300, H)); // right
- end;
- end;
- procedure TAntiban.RandomPOVTask;
- begin
- case Random(7) of
- 0: Self.AdjustZoom;
- else Self.RandomRotate;
- end;
- end;
- function TAntiban.HoverPlayerFunc(): Boolean;
- var
- i: Int32;
- dots: TPointArray;
- R: TRectangle;
- begin
- for i:=0 to Random(0,2) do
- begin
- dots := Minimap.GetDots(ERSMinimapDot.PLAYER);
- if Length(dots) > 0 then
- begin
- R := Minimap.PointToMsRect(dots[Random(Length(dots))]);
- Mouse.Move(R);
- if not MainScreen.IsUpText('level') then
- begin
- if Random() < 0.5 then
- Antiban.Swivel()
- else
- Mouse.Move(R, True);
- Result := Random() > 0.5;
- Sleep(srl.TruncatedGauss(500,3100));
- end;
- if (Random() > 0.7) and MainScreen.IsUpText('level') then
- begin
- ChooseOption.Open();
- Sleep(srl.TruncatedGauss(0,6000));
- break;
- end;
- end;
- end;
- end;
- procedure TAntiban.HoverPlayer();
- begin
- Self.HoverPlayerFunc();
- end;
- procedure TAntiban.LoseFocus(); override;
- begin
- if Random() < 0.5 then
- srl.MouseOffClient(srl.SkewedRand(3,0,3));
- Antiban.LoseFocus(srl.SkewedRand(1000,500,30000));
- end;
- procedure TIntegerArray.Shuffle();
- var i: Int32;
- begin
- for i:=0 to High(self) do
- Swap(Self[i], Self[Random(0, High(Self))]);
- end;
- procedure TPointArray.Shuffle();
- var i: Int32;
- begin
- for i:=0 to High(self) do
- Swap(Self[i], Self[Random(0, High(Self))]);
- end;
- { ============================================================================ }
- { ============================================================================ }
- { ============================================================================ }
- procedure TMiner.DeclarePlayers();
- begin
- Login.AddPlayer(USERNAME, PASSWORD, '', F2P_WORLDS);
- end;
- function TMiner.WorldToMS(PlayerPoint, WorldPoint: TPoint): TRectangle;
- var pt: TPoint;
- begin
- pt := RSW.WorldToMM(PlayerPoint, WorldPoint, Minimap.GetCompassAngle(False));
- Result := Minimap.PointToMsRect(pt);
- end;
- function TMiner.GetOres(): TRectArray;
- var
- i: Int32;
- me: TPoint;
- begin
- me := RSW.GetMyPos();
- for i:=0 to High(Self.OreLocations) do
- Result += Self.WorldToMS(me, Self.OreLocations[i]);
- end;
- procedure TMiner.OrganizeInv();
- var
- move,empty,slots: TIntegerArray;
- i,j,k: Int32;
- a,b: TBox;
- begin
- Inventory.FindItems(WHAT_TO_DROP, slots);
- for i:=0 to 27 do
- begin
- if Inventory.IsSlotUsed(i) and (slots.Find(i)=-1) then
- move += i;
- if not Inventory.IsSlotUsed(i) then
- empty += i;
- end;
- if Length(empty) = 0 then
- Exit;
- for i in move do
- begin
- j := empty[high(empty)];
- if j <= i then break;
- a := Inventory.GetSlotBox(i);
- b := Inventory.GetSlotBox(j);
- Mouse.Move(a);
- Mouse.Hold(mouse_left);
- WaitEx(100,15);
- Mouse.Move(b);
- WaitEx(100,15);
- Mouse.Release(mouse_left);
- WaitEx(100,15);
- empty.Pop();
- empty.Append(i);
- empty.Sort();
- end;
- end;
- function TMiner.IsOreAliveFast(R: TRectangle): Boolean;
- var
- TPA: TPointArray;
- B: TBox;
- color: TCTS2Color;
- begin
- B := R.Bounds();
- B.LimitTo(MainScreen.Bounds);
- for color in Self.OreColor do
- if srl.FindColors(TPA, color, B) > 200 then
- Exit(True);
- end;
- function TMiner.IsOreAlive(R: TRectangle; out Fitted: TRectangle): Boolean;
- var
- TPA: TPointArray;
- B: TBox;
- color: TCTS2Color;
- begin
- B := R.Bounds();
- B.LimitTo(MainScreen.Bounds);
- for color in Self.OreColor do
- if srl.FindColors(TPA, color, B) then begin
- TPA := R.Filter(TPA).Cluster(MainScreen.NormalizeDistance(9)).Biggest();
- Fitted := TPA.MinAreaRect();
- if Length(TPA) > MainScreen.NormalizeDistance(200) then
- Exit(True);
- end;
- end;
- procedure TMiner.TryApplySwivel();
- begin
- if (Self.SweivelTimer < GetTimeRunning()) then begin
- Antiban.Swivel();
- Self.SweivelTimer := GetTimeRunning() + srl.SkewedRand(30000, 0, 90000, 3);
- end;
- end;
- procedure TMiner.TrackExperience();
- var
- xpNow, xpGained: Int32;
- xp_hour: Double;
- begin
- if not Self.CanDebug.IsFinished() then
- Exit;
- //ClearDebug();
- xpNow := XPBar.Read();
- xpGained := xpNow - Self.StartupXP;
- xp_hour := xpGained / GetTimeRunning() * 1000 * 60 * 60;
- WriteLn('--| CanItMine |----------------------------------------');
- if Self.IsHyperFocused() then WriteLn('CanItMine is set to Hyper focused')
- else if Self.IsExtremeFocused() then WriteLn('CanItMine is set to Extremely focused')
- else if Self.IsUnfocused() then WriteLn('CanItMine is set to Unfocused')
- else WriteLn('CanItMine is set to Regular');
- WriteLn('* Exp/hour: ', FloatToStr(Round(xp_hour,1)));
- WriteLn('* Exp total: ', xpGained);
- WriteLn('---------------------------------------------------------');
- Self.CanDebug.Restart(100);
- end;
- procedure TMiner.UnfocusedInit();
- begin
- Self.UnfocucsedTimer := GetTimeRunning() + srl.SkewedRand(50000, 0, ONE_MINUTE*3, 3);
- end;
- function TMiner.IsUnfocused(): Boolean;
- begin
- Result := (GetTimeRunning() < Self.UnfocucsedTimer);
- end;
- procedure TMiner.HyperFocusInit();
- begin
- Self.HyperFocusTimer := GetTimeRunning() + srl.SkewedRand(ONE_MINUTE*2.5, 0, ONE_MINUTE*5, 3);
- end;
- procedure TMiner.ExtremeFocusInit();
- begin
- Self.ExtremeFocusTimer := GetTimeRunning() + srl.SkewedRand(ONE_MINUTE*2.5, 0, ONE_MINUTE*5, 3);
- end;
- procedure TMiner.LongExtremeFocusInit();
- begin
- Self.ExtremeFocusTimer := GetTimeRunning() + srl.SkewedRand(ONE_MINUTE*4, 0, ONE_MINUTE*7, 3);
- end;
- function TMiner.IsHyperFocused(): Boolean;
- begin
- Result := (GetTimeRunning() < Self.HyperFocusTimer);
- end;
- function TMiner.IsExtremeFocused(): Boolean;
- begin
- Result := (GetTimeRunning() < Self.ExtremeFocusTimer);
- end;
- function TMiner.BurstOfUnfocused(): Boolean;
- var
- i,hi: Int32;
- ForceMouseOff: Boolean;
- begin
- i := 0;
- WriteLn('[Antiban] Unfocused events!');
- Result := True;
- hi := srl.TruncatedGauss(5,0);
- while Result and (i < hi) do
- begin
- Result := False;
- if (Random() < 0.33) then
- begin
- WriteLn('[Antiban] Unfocused event: Swivel');
- Antiban.SwivelNear(mouse.Position, 0.4, Random(3), Random(25,50), Random() > 0.5, Random(1,4));
- end;
- if (Random() < 0.35) or ForceMouseOff then
- begin
- WriteLn('[Antiban] Unfocused event: MouseOff/LoseFocus!');
- srl.MouseOffClient(srl.SkewedRand(3,0,3));
- Antiban.LoseFocus(srl.SkewedRand(1000,500,30000));
- Result := True;
- ForceMouseOff := False;
- end;
- if (Random() < 0.10) then
- begin
- WriteLn('[Antiban] Unfocused event: Check skill');
- Antiban.HoverSkill(ERSSkill.MINING, Trunc(srl.SkewedRand(300,100,3000)), Random() > 0.33);
- srl.MouseOffClient(Random(4));
- Antiban.LoseFocus(Random(1000,20000));
- Result := True;
- end;
- if (Random() < 0.05) then
- begin
- WriteLn('[Antiban] Unfocused event: Random right');
- Antiban.RandomRightClick();
- Result := True;
- end;
- if (Random() < 0.15) then
- begin
- WriteLn('[Antiban] Unfocused event: Examine player');
- ForceMouseOff := not Antiban.HoverPlayerFunc();
- Result := True;
- end;
- Inc(i);
- 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.DoAntiban(CheckBreaks: Boolean = True; CheckSleeps: Boolean = True);
- begin
- Antiban.DoAntiban(CheckBreaks, CheckSleeps);
- if not RSClient.IsLoggedIn() then
- login.LoginPlayer();
- end;
- (*
- Mines a series of rocks, and it tries to do it as fast as possible.
- There are no added delays like reaction time, other than the search for our
- positon which delays like 20-40 ms, and the PC. Not that good, but just meant
- to be freaking fast.
- *)
- function TMiner.MineExtremeFocus(): Boolean;
- var
- ore, fittedOre, next, junk: TRectangle;
- missing, xp_prior, count: Int32;
- FastMouse: TMouse;
- dropRenderingTimer: TCountDown;
- ForceDrop: Boolean;
- function NextOre(pop: Boolean=True): TRectangle;
- var me: TPoint;
- begin
- me := RSW.GetMyPos();
- Result := Self.WorldToMS(me, Self.OreLocations[Self.OreCounter]);
- if pop then
- begin
- Inc(Self.OreCounter);
- if Self.OreCounter = Length(Self.OreLocations) then Self.OreCounter := 0;
- end;
- end;
- begin
- FastMouse := Mouse;
- FastMouse.Speed := Random(18,23);
- dropRenderingTimer.Init(700);
- next := NextOre(); //initalize next rock data
- while Self.IsExtremeFocused() do
- begin
- Ore := NextOre();
- if ForceDrop or ((not Self.IsOreAlive(Ore, fittedOre))) then
- begin
- missing += 1;
- if ForceDrop or (dropRenderingTimer.IsFinished() and (missing >= Length(Self.OreLocations)) or ((Inventory.Count() > 6) and (Random() < 0.15))) then
- begin
- Self.IntenseDrop(next.Mean());
- dropRenderingTimer.Restart(70);
- missing := 0;
- count := 0;
- ForceDrop := False;
- end;
- continue;
- end;
- count += 1;
- // we just click this rock, so add it + cache where we are:
- ClickOrder.Push(fittedOre);
- next := ClickOrder.Next();
- RSClient.Image.Clear();
- RSClient.Image.DrawRect(fittedOre, $00FF00);
- FastMouse.Move(fittedOre, Random() < 0.05);
- Sleep(Random(60,90));
- if not MainScreen.IsUpText('Mine Rocks') then
- continue;
- xp_prior := XPBar.Read();
- FastMouse.Click(fittedOre, MOUSE_LEFT, Random() < 0.15);
- if not MainScreen.DidRedClick() then
- continue;
- if {(count < Length(Self.OreLocations)) or }(count < MIN_ORE_DROP_COUNT) then
- FastMouse.Move(next)
- else
- begin
- FastMouse.Move(Inventory.GetSlotBox(0)); //prepare for dropping
- ForceDrop := True;
- end;
- 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(8000,10000));
- RSClient.Image.DrawRect(fittedOre, $FF);
- if Random(100) < EXTREME_TURN_PERCENTAGE then
- Self.TryTurn(next);
- Self.TrackExperience();
- end;
- end;
- (*
- Mines a single ore.
- Computers are differnt than people, they tend to repeat the same task in the
- exact same amount of time, so I've added a variance to this, ReactionTime.
- Humans, notably gamers, have a focused reactiontime of 150-250 ms.
- This kicks in when we have predicted the next ore to be mined correctly.
- *)
- function TMiner.MineOnce(out Rect,NextRect: TRectangle): Boolean;
- var
- arr: TRectArray;
- R,_: TRectangle;
- circle: TCircle;
- i: Int32;
- HumanResponseTimer, ReactionTime: Double;
- begin
- RSClient.Image.Clear();
- HumanResponseTimer := GetTimeRunning();
- case Self.IsHyperFocused() of
- True: ReactionTime := srl.SkewedRand(140, 100, 400);
- False: ReactionTime := srl.SkewedRand(180, 150, 900);
- end;
- if Self.IsUnfocused() then
- ReactionTime *= 1.5;
- // a 7% chance that our rection time just becomes crap no matter focus
- if(Random() < 0.07) then
- ReactionTime += Random(2000);
- // It actually ended up trading one guy, idk how
- if ChooseOption.IsOpen then
- ChooseOption.Close();
- arr := Self.GetOres();
- for i:=0 to High(arr) do begin
- if not Self.IsOreAlive(arr[i], R) then
- continue;
- // move the mouse
- RSClient.Image.DrawRect(R, $00FF00);
- Mouse.Move(R, Random() < 0.1);
- Sleep(Random(10,40));
- if not WaitUntil(MainScreen.IsUpText(['Mine','Rocks']), Random(20,50), Random(200,300)) then
- break;
- // a humans reactiontime offset
- WaitUntil(GetTimeRunning() > HumanResponseTimer+ReactionTime, Random(5,15), 2000);
- // click it!
- Mouse.Click(R, MOUSE_LEFT, Random() < 0.15);
- Result := MainScreen.DidRedClick();
- if not Result then
- WriteLn('This might be bad');
- // random extra clicks
- for 1 to SRL.TruncatedGauss(-2, 3) do
- begin
- circle.x := Mouse.Position().X;
- circle.y := Mouse.Position().Y;
- circle.radius := 5;
- Mouse.Click(circle, MOUSE_LEFT, True);
- Sleep(Random(0,150));
- end;
- if not Result then
- continue;
- //output current rectangle
- Rect := R;
- // burst of unfocused
- if Self.IsUnfocused() and Self.BurstOfUnfocused() then
- Exit(True);
- // fill with current, than fetch the next one
- ClickOrder.Push(R);
- nextRect := ClickOrder.Next();
- // move mouse to the next ore
- if (Random() > 0.1) or (Self.IsHyperFocused() and (Random() > 0.05)) then
- begin
- Wait(0,700, wdLeft);
- if nextRect.Mean.InBox(MainScreen.Bounds) then
- Mouse.Move(nextRect, Random() < 0.1);
- end;
- break;
- end;
- if (not Result) then
- Self.TryApplySwivel();
- end;
- (*
- Mines one inventory of ores
- *)
- function TMiner.Mine(): Boolean;
- var
- next,r,_: TRectangle;
- baseCount,clicks,success,xp_prior: Int32;
- breakrnd: Double;
- begin
- Result := False;
- (* the loops criteria like this:
- 1. If inventory is open then we check if its full, and if so break
- 2. If chat-message too full inventory then be break
- 3. If we are in unfocused mode we may click the ore even tho inventory is full a few times
- 4. We might miss that it's full on a rare occation as well
- *)
- while True do
- begin
- xp_prior := XPBar.Read();
- if Self.MineOnce(r,next) then
- begin
- if Inventory.IsOpen() then Inc(clicks);
- if Inventory.IsOpen() then baseCount := Inventory.Count();
- Sleep(Random(50,150));
- WaitUntil(not Minimap.IsPlayerMoving(), 30, Random(2000,3000));
- WaitUntil((XPBar.Read() <> xp_prior) or (not Self.IsOreAlive(r,_)) or (Chat.LeveledUp()) or Chat.FindOption('is too full to hold', [CHAT_COLOR_BLACK]), 20, Random(8000,12000));
- RSClient.Image.DrawRect(R, $FF);
- if Inventory.IsOpen() and (Inventory.Count() > baseCount) then Inc(success);
- // turn towards next ore (?)
- if (Random() < 0.1) or Self.IsHyperFocused() then
- Self.TryTurn(next);
- // check if we have an antiban ready and lined up
- Self.DoAntiban();
- // High competition for the ore? Let's trigger hyper focus!
- if (clicks > Random(3,5)) and (success / clicks < 0.67) then
- begin
- Self.LongExtremeFocusInit();
- WriteLn('[Warning: high competition]: Burst of extreme focus = Enabled!');
- WriteLn(' Lasts for: ', (Self.HyperFocusTimer-GetTimeRunning()) / 1000, 'sec');
- Exit;
- end;
- // a 5% chance of just waiting a little extra between ores.
- if (Random() < 0.05) and (not Self.IsHyperFocused()) then
- Sleep(srl.SkewedRand(70,0,4000));
- // There's a random 1.5% chance we trigger a burst of halfassed unfocused working
- if (not Self.IsUnfocused()) and (Random() < 0.015) then
- begin
- Self.UnfocusedInit();
- WriteLn('[Antiban] Burst of unfocused = Enabled!');
- WriteLn(' Lasts for: ', (Self.UnfocucsedTimer-GetTimeRunning()) / 1000, 'sec');
- end;
- // There's a random 0.5% chance we trigger hyper focus
- if (not Self.IsHyperFocused()) and (Random() < 0.005) then
- begin
- Self.HyperFocusInit();
- WriteLn('[Antiban] [RND]: Burst of hyper focus = Enabled!');
- WriteLn(' Lasts for: ', (Self.HyperFocusTimer-GetTimeRunning()) / 1000, 'sec');
- end;
- // There's a random 1.5% chance we trigger extreme focus
- if (not Self.IsExtremeFocused()) and (Random() < 0.015) then
- begin
- Self.ExtremeFocusInit();
- WriteLn('[Antiban] [RND]: Burst of extreme focus = Enabled!');
- WriteLn(' Lasts for: ', (Self.ExtremeFocusTimer-GetTimeRunning()) / 1000, 'sec');
- break;
- end;
- // if inventory isn't open then add a chance for actually opening it again
- // assuming we are not in an unfocused burst
- if (Random(14) = 0) and (not Inventory.IsOpen()) and (not Self.IsUnfocused()) then
- Inventory.Open();
- // trigger intense drop every 3th success
- if Self.IsHyperFocused() and (success mod 3 = 0) then
- Self.IntenseDrop(next.Mean());
- end;
- // working out loop conditions:
- breakrnd := 0.1;
- if Self.IsUnfocused() then breakrnd := 0.5;
- if (Inventory.IsOpen() and Inventory.IsFull()) and (Random() > breakrnd) then
- break;
- if RSW.GetMyPos().DistanceTo(Self.OreLocations[0]) > 10 then
- break;
- if not RSClient.IsLoggedIn() then
- break;
- if (Chat.FindOption('is too full to hold', [CHAT_COLOR_BLACK])) and (Random() > breakrnd) then
- break;
- // track XP
- Self.TrackExperience();
- end;
- if (Random() < 0.16) and (Chat.FindOption('is too full to hold')) then
- Chat.ClickContinue(Random() > 0.1);
- end;
- procedure TMiner.IntenseDrop(ReturnTo: TPoint);
- var
- slots,order: TIntegerArray;
- i: Int32;
- n: Int32 = 3;
- begin
- // first check if we should reorganize inventory
- Self.OrganizeInv();
- // now we can do the dropping
- if Random(5) = 0 then
- n := Random(2,6);
- // in case we have a lot more time to drop, so increase rates!
- if Length(Self.OreLocations) < 3 then
- begin
- n := 6;
- if Random(5) = 0 then
- n := Random(4,12);
- end;
- if Inventory.FindItems(WHAT_TO_DROP, Slots) then
- for i := 0 to High(DROP_PATTERN_REGULAR) do
- if Slots.Find(DROP_PATTERN_REGULAR[I]) > -1 then
- order += DROP_PATTERN_REGULAR[I];
- if (Length(Slots) >= MIN_ORE_DROP_COUNT) then
- begin
- SetLength(order, Min(Length(order), n));
- Inventory.ShiftDrop(Inventory.ErrorPattern(order,3));
- Mouse.Move(ReturnTo,25);
- end;
- end;
- procedure TMiner.DropInventory();
- var
- ptrn: TIntegerArray;
- slices: TIntegerArray;
- sequences: T2DIntArray;
- i,hi: Int32;
- begin
- ptrn := Inventory.ErrorPattern(DROP_PATTERN_REGULAR, 10);
- hi := 0;
- while hi <> Length(ptrn) do
- begin
- if Self.IsUnfocused() then
- slices += Random(hi, Length(ptrn))
- else
- slices += srl.TruncatedGauss(Length(ptrn), hi, 6);
- hi := slices[High(slices)];
- end;
- sequences += Copy(ptrn, 0, slices[0]);
- for i:=1 to High(slices) do
- sequences += Copy(ptrn, slices[i-1], 28-slices[i-1]);
- for i:=0 to High(sequences) do
- begin
- ptrn := sequences[i];
- // check if we have an antiban ready and lined up
- Self.DoAntiban();
- // shift-drop the rest of our ores
- Inventory.ShiftDrop(WHAT_TO_DROP, ptrn);
- if Self.IsUnfocused() then Self.BurstOfUnfocused();
- if (Self.IsHyperFocused()) and (i = High(sequences)) then
- break;
- Sleep(srl.TruncatedGauss(0, 6000, 6));
- // if we are unfocused shit might happen.
- if Self.IsUnfocused() then
- begin
- Self.BurstOfUnfocused();
- if (Random() < 0.1) then break;
- end;
- end;
- //selection := Inventory.GetSelectedSlot();
- //if selection <> -1 then Inventory.ClickSlot(i);
- end;
- procedure TMiner.DebugOres();
- var
- arr: TRectArray;
- rect,_: TRectangle;
- begin
- arr := Self.GetOres();
- for rect in arr do
- begin
- if Self.IsOreAlive(rect,_) then
- RSClient.Image.DrawRect(rect, $00FF00)
- else
- RSClient.Image.DrawRect(rect, $FF);
- end;
- end;
- procedure TMiner.SetupOres(out Locations: T2DPointArray; out Colors: array of array of TCTS2Color);
- begin
- locations := [];
- colors := [];
- {EastVarrockMine - iron ore}
- locations += [[4950+159, 2976-429],[4954+159, 2972-429]];
- colors += [CTS2(2240329, 11, 0.12, 0.60)];
- {EastArdougneMine - iron ore}
- locations += [[2574+159, 3131-429],[2578+159, 3135-429],[2582+159, 3131-429]];
- colors += [CTS2(2240329, 11, 0.12, 0.60)];
- {LumbridgeTutor - tin ore}
- locations += [[4700+159, 3864-429],[4697+159, 3860-429],[4701+159, 3856-429]];
- colors += [CTS2(8421769, 10, 0.29, 0.17)];
- {AkaridMine - iron ore}
- locations += [[5148, 2782],[5144, 2778],[5148,2774]];
- colors += [CTS2(2240329, 11, 0.12, 0.60)];
- {WildyMine - iron ore}
- locations += [[4229+159, 2172-429],[4226+159, 2167-429]];
- colors += [CTS2(2240329, 11, 0.12, 0.60)];
- {F2P Mining Guild - 2 rock - iron ore}
- locations += [[5987, 6526],[5983, 6530]];
- colors += [CTS2(2240329, 11, 0.12, 0.60)];
- end;
- procedure TMiner.Setup();
- var
- i: Int32;
- me: TPoint;
- reg: TBox;
- locations: T2DPointArray;
- colors: array of array of TCTS2Color;
- R: TRectangle;
- begin
- RSClient.Image.Clear();
- Mouse.Speed := Random(14,16);
- // ===========================================================================
- // detect ore location automatically based on our current pos:
- RSW.Setup('world');
- Self.SetupOres(locations, colors);
- me := RSW.GetMyPos();
- WriteLn('Found your location as: ', me);
- for i:=0 to High(locations) do
- if Distance(locations[i][0], me) < 4*4 then //4 tiles away at most
- begin
- Self.OreLocations := locations[i];
- break;
- end;
- if Self.OreLocations = [] then
- TerminateScript('Not near any ores');
- RSW.Free(); // release world RSW.
- Self.OreColor := colors[i]; // `i` was defined in the loop above.
- // ===========================================================================
- // load powerminer by region:
- reg := [Self.OreLocations[0].x-150,Self.OreLocations[0].y-150,Self.OreLocations[0].x+150,Self.OreLocations[0].y+150];
- Self.RSW.Setup('world', TBoxArray([reg]));
- // ===========================================================================
- // Debug test
- Self.DebugOres();
- // ===========================================================================
- // Setup standard shit
- Self.SweivelTimer := GetTimeRunning() + srl.SkewedRand(2000, 0, 10000, 3);
- Self.DeclarePlayers();
- Antiban.Skills := [ERSSkill.MINING];
- Antiban.MaxZoom := 60;
- Antiban.MinZoom := 30;
- Antiban.AddTask(5 * ONE_MINUTE, @Antiban.HoverPlayer);
- Antiban.AddTask(6 * ONE_MINUTE, @Antiban.RandomPOVTask);
- //Antiban.AddTask(8 * ONE_MINUTE, @Antiban.RandomRightClick);
- Antiban.AddTask(8 * ONE_MINUTE, @Antiban.Swivel);
- Antiban.AddTask(9 * ONE_MINUTE, @Antiban.HoverSkills);
- Antiban.AddTask(10 * ONE_MINUTE, @Antiban.LoseFocus);
- Antiban.AddTask(12 * ONE_MINUTE, @Antiban.RandomTab);
- Antiban.AddBreak(30 * ONE_MINUTE, 1 * ONE_MINUTE, 0.33, 0.01);
- Antiban.AddBreak(60 * ONE_MINUTE, 2 * ONE_MINUTE, 0.33, 0.02);
- Antiban.AddBreak(80 * ONE_MINUTE, 5 * ONE_MINUTE, 0.33, 0.15);
- Antiban.AddBreak(100 * ONE_MINUTE, 10 * ONE_MINUTE, 0.33, 0.75);
- Antiban.AddBreak(150 * ONE_MINUTE, 30 * ONE_MINUTE, 0.33, 0.85);
- //Antiban.AddSleep('00:00', 8, 1, 1.0);
- RSW.ScreenWalk := True;
- Self.StartupXP := XPBar.Read();
- me := Self.RSW.GetMyPos();
- for i:=0 to High(Self.OreLocations) do
- Self.ClickOrder.History += self.WorldToMS(me, Self.OreLocations[i]);
- Self.CanDebug.Init(2000);
- end;
- var rsw_time: Double;
- begin
- srl.Setup();
- Bot.Setup();
- rsw_time := PerformanceTimer();
- Bot.RSW.GetMyPos();
- WriteLn(PerformanceTimer() - rsw_time, 'ms to look up position!');
- while RSClient.IsLoggedIn() do
- begin
- if Bot.RSW.GetMyPos().DistanceTo(Bot.OreLocations[0]) < 10 then
- begin
- if Bot.IsExtremeFocused() then
- Bot.MineExtremeFocus()
- else
- Bot.Mine();
- end
- else
- TerminateScript('There are no ores near by');
- if Inventory.IsFull() then
- Bot.DropInventory();
- if not RSClient.IsLoggedIn() then
- login.LoginPlayer();
- end;
- end.
Add Comment
Please, Sign In to add comment