WarPie90

PowerMiner

Oct 22nd, 2022 (edited)
1,358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 36.16 KB | None | 0 0
  1. program SlackMiner;
  2. {.$DEFINE SRL_DEBUG_MOUSE}
  3. {$DEFINE SRL_USE_REMOTEINPUT}
  4. {$I SRL/osr.simba}
  5. {==============================================================================]
  6.   Slacky's Powerminer™ aka SlackMiner!
  7.  
  8.  
  9.   Remember to set up script for your usage bellow!
  10.   -------------------------------------------
  11.  
  12.   * For short runs, username is not needed. But can't not log you in after a break then.
  13.  
  14.   * WHAT_TO_DROP: You can change this list with other items, like gems if you dont
  15.                   want them to stack up in your inventory.
  16.                   PS: You may eventually have to manually bank at times
  17.  
  18.   * P2P: Specially needed for P2P locations.
  19.  
  20.   * FAST_RESPAWN: Like P2P mining guild, or just mining iron with a slow pickaxe.
  21.                    Without this the miner will act badly in hypermode.
  22.  
  23.   * HYPER_TURN_PERCENTAGE: The script can click empty rocks in order to turn
  24.                            towards it now and then - simulates efficeint player.
  25.  
  26.   * MIN_ORE_DROP_COUNT: TBA.
  27. [==============================================================================}
  28. const
  29.   USERNAME = '';
  30.   PASSWORD = '';
  31.  
  32.   WHAT_TO_DROP: TRSItemArray = ['Iron ore', 'Tin ore'];
  33.   P2P                        = False;  // members?
  34.   FAST_RESPAWN               = False;  // IE guild mine
  35.   HYPER_TURN_PERCENTAGE      = 15;     // %
  36.  
  37.   // Do you wish to force it to mine superfast for a while?
  38.   // Warning: No antiban in this mode, just pure fucking performance
  39.   // 20 = 20 minutes before it turns back to normal mixed mode mining.
  40.   FORCE_HYPER_MODE_MINUTES   = 20;
  41.  
  42.   // ============ FATURE CURRENTLY IGNORED ============ \\
  43.  
  44.   // Extreme and Hyper focus can drop a minimum of? This Should not be more
  45.   // than 3 for 3 rocks spawns, and more than 6 for 2 rock spawns. Has to do
  46.   // with efficient timings.
  47.   MIN_ORE_DROP_COUNT = 2; //4 might be good fit for 2 rock spawn.
  48.  
  49.  
  50.  
  51. type
  52.   EFocusType = (ftNormal, ftUnfocused, ftFocused, ftHyperfocus, ftCompeting);
  53.  
  54.   TClickHistory = record
  55.     History: TRectArray;
  56.   end;
  57.  
  58.   TMiner = record
  59.     RSW: TRSWalker;
  60.     OreLocations: TPointArray;
  61.     Sequence: TIntegerArray;
  62.     OreColor: array of TCTS2Color;
  63.     OreName: string;
  64.  
  65.     SweivelTimer: Double;
  66.  
  67.     UnfocusedTimer: Double;
  68.     FocusTimer: Double;
  69.     HyperFocusTimer: Double;
  70.     CompetingTimer: Double;
  71.  
  72.     CanDebug: TCountDown;
  73.  
  74.     ClickOrder: TClickHistory;
  75.     StartupXP: Int32;
  76.     OreCounter: Int32;
  77.  
  78.     IsDistant_Slow: Boolean;
  79.     LatestLocation: TPoint;
  80.   end;
  81.  
  82. const
  83.   F2P_WORLDS = [301,308,380,434,435,436,437,451];
  84.   P2P_WORLDS = [302,303,304,305,306,307,309,310,311,312,313,314,315,317,318,319,320];
  85.  
  86. var
  87.   Bot: TMiner;
  88.  
  89. {==============================================================================]
  90. | Ore location order, cache structure
  91. [==============================================================================}
  92. function TClickHistory.Push(x: TRectangle): Boolean;
  93.   function IsDuplicateOfCurrent(): Boolean;
  94.   begin
  95.     if Self.History[High(Self.History)].Mean().DistanceTo(x.Mean()) < 16 then
  96.       Exit(True);
  97.   end;
  98.  
  99.   procedure ShiftForward();
  100.   var i: Int32; tmp: TRectangle;
  101.   begin
  102.     //for i:=High(Self.History) downto 0 do
  103.     //  Self.History[srl.Modulo(i+1, Length(Self.History))] := Self.History[i];
  104.  
  105.     tmp := Self.History[0];
  106.     for i:=0 to High(self.History)-1 do Self.History[i] := Self.History[i + 1];
  107.     Self.History[High(self.History)] := tmp;
  108.   end;
  109.  
  110. begin
  111.   // ensure this is not dupicate of the ore that was previously clicked
  112.   // if it is then we shift the array to bring forth the next ore in previous sequence.
  113.   // Note: This should not happen unless we are competing for rocks
  114.   // Also might prevent some unexpected glitches.
  115.   if IsDuplicateOfCurrent() then
  116.   begin
  117.     ShiftForward();
  118.     Exit(False);
  119.   end;
  120.  
  121.   // otherwise, push it in to the first slot. Bringing forth the last clicked rock
  122.   // to the end, which is also the next rock to click.
  123.   // This way we can access it with .Next()
  124.   Insert(x, Self.History, 0);
  125.   SetLength(Self.History, Length(Bot.OreLocations));
  126.   Result := True;
  127. end;
  128.  
  129. function TClickHistory.Next(): TRectangle;
  130. begin
  131.   // only if we have a full set of history should we predict and drop
  132.   if Length(Self.History) >= Length(Bot.OreLocations)  then
  133.   begin
  134.     Result := Self.History[High(Self.History)];
  135.     SetLength(Self.History, Length(Self.History)-1);
  136.   end else
  137.   begin
  138.     Result := Self.History[High(Self.History)]; //XXX: can I do this?
  139.   end;
  140. end;
  141.  
  142. function TClickHistory.Top(): TRectangle;
  143. begin
  144.   Result := Self.History[High(Self.History)];
  145. end;
  146.  
  147. procedure TMouse.Move(Rect: TRectangle; ForcedMove: Boolean = False); override;
  148. begin
  149.   if (ForcedMove) or (not Rect.Contains(Mouse.Position())) then
  150.     Mouse.Move(srl.rowp(mouse.Position(), Rect));
  151. end;
  152.  
  153. procedure TMouse.NearInventory();
  154. var InventoryMouseArea: TBox;
  155. begin
  156.   InventoryMouseArea := Inventory.GetSlotBox(0);
  157.   InventoryMouseArea := InventoryMouseArea.Combine(Inventory.GetSlotBox(5));
  158.   InventoryMouseArea := InventoryMouseArea.Combine(Inventory.GetSlotBox(0).Offset([-45,0]));
  159.   InventoryMouseArea := InventoryMouseArea.Expand(10);
  160.   Mouse.Move(InventoryMouseArea); //prepare for dropping
  161. end;
  162.  
  163.  
  164. {==============================================================================]
  165. | Mix methods like antiban
  166. [==============================================================================}
  167. procedure TSRL.MouseOffClient(direction: Byte);
  168. var
  169.   W,H: Int32;
  170.   pt: TPoint;
  171. begin
  172.   GetClientDimensions(W, H);
  173.   pt := Mouse.Position();
  174.   if (pt.X < 0) or (pt.X > W) or (pt.Y < 0) or (pt.Y > H) then
  175.     Exit();
  176.   if (direction >= 4) then
  177.     direction := Random(0,3);
  178.   case direction of
  179.     0: Mouse.Move(Box(-300, -300, W, 0)); // top
  180.     1: Mouse.Move(Box(0, H, W, H+300));   // bottom
  181.     2: Mouse.Move(Box(-300, 0, 0, H));    // left
  182.     3: Mouse.Move(Box(W, 0, W+300, H));   // right
  183.   end;
  184. end;
  185.  
  186. procedure TAntiban.RandomPOVTask;
  187. begin
  188.   case Random(7) of
  189.     0:   Self.AdjustZoom;
  190.     else Self.RandomRotate;
  191.   end;
  192. end;
  193.  
  194. function TAntiban.HoverPlayerFunc(): Boolean;
  195. var
  196.   i: Int32;
  197.   dots: TPointArray;
  198.   R: TRectangle;
  199. begin
  200.   for i:=0 to Random(0,2) do
  201.   begin
  202.     dots := Minimap.GetDots(ERSMinimapDot.PLAYER);
  203.     if Length(dots) > 0 then
  204.     begin
  205.       R := Minimap.PointToMsRect(dots[Random(Length(dots))]);
  206.       Mouse.Move(R);
  207.       if not MainScreen.IsUpText('level') then
  208.       begin
  209.         if Random() < 0.5 then
  210.           Antiban.Swivel()
  211.         else
  212.           Mouse.Move(R, True);
  213.  
  214.         Result := Random() > 0.5;
  215.         Sleep(srl.TruncatedGauss(500,3100));
  216.       end;
  217.  
  218.       if (Random() > 0.7) and MainScreen.IsUpText('level') then
  219.       begin
  220.         ChooseOption.Open();
  221.         Sleep(srl.TruncatedGauss(0,6000));
  222.         break;
  223.       end;
  224.     end;
  225.   end;
  226. end;
  227.  
  228. procedure TAntiban.HoverPlayer();
  229. begin
  230.   Self.HoverPlayerFunc();
  231. end;
  232.  
  233. procedure TAntiban.LoseFocus(); override;
  234. begin
  235.   if Random() < 0.5 then
  236.     srl.MouseOffClient(srl.SkewedRand(3,0,3));
  237.   Antiban.LoseFocus(srl.SkewedRand(1000,500,30000));
  238. end;
  239.  
  240.  
  241.  
  242. procedure TIntegerArray.Shuffle();
  243. var i: Int32;
  244. begin
  245.   for i:=0 to High(self) do
  246.     Swap(Self[i], Self[Random(0, High(Self))]);
  247. end;
  248.  
  249. procedure TPointArray.Shuffle();
  250. var i: Int32;
  251. begin
  252.   for i:=0 to High(self) do
  253.     Swap(Self[i], Self[Random(0, High(Self))]);
  254. end;
  255.  
  256. procedure TPointArray.Shift(steps: Int32 = 1);
  257. var
  258.   x,i: Int32;
  259.   tmp: TPoint;
  260. begin
  261.   x := 1;
  262.   while(x <= steps) do
  263.   begin
  264.     tmp := Self[0];
  265.     for i:=0 to High(self)-1 do Self[i] := Self[i + 1];
  266.     Self[High(self)] := tmp;
  267.     Inc(x);
  268.   end;
  269. end;
  270.  
  271. { ============================================================================ }
  272. { ============================================================================ }
  273. { ============================================================================ }
  274. procedure TMiner.DeclarePlayers();
  275. begin
  276.   if P2P then
  277.     Login.AddPlayer(USERNAME, PASSWORD, '', P2P_WORLDS)
  278.   else
  279.     Login.AddPlayer(USERNAME, PASSWORD, '', F2P_WORLDS);
  280. end;
  281.  
  282. function TMiner.GetMyPos(): TPoint;
  283. begin
  284.   Result := Self.LatestLocation := RSW.GetMyPos();
  285. end;
  286.  
  287. function TMiner.WorldToMS(PlayerPoint, WorldPoint: TPoint): TRectangle;
  288. var pt: TPoint;
  289. begin
  290.   pt := RSW.WorldToMM(PlayerPoint, WorldPoint, Minimap.GetCompassAngle(False));
  291.   Result := Minimap.PointToMsRect(pt);
  292. end;
  293.  
  294. function TMiner.WorldToMSPt(PlayerPoint, WorldPoint: TPoint): TPoint;
  295. var pt: TPoint;
  296. begin
  297.   pt := RSW.WorldToMM(PlayerPoint, WorldPoint, Minimap.GetCompassAngle(False));
  298.   Result := Minimap.PointToMs(pt);
  299. end;
  300.  
  301. function TMiner.GetOres(fromMouse:Boolean = True): TRectArray;
  302. var
  303.   i: Int32;
  304.   me: TPoint;
  305.   weight: TIntegerArray;
  306. begin
  307.   me := Self.GetMyPos();
  308.   for i:=0 to High(Self.OreLocations) do
  309.     Result += Self.WorldToMS(me, Self.OreLocations[i]);
  310.  
  311.   if fromMouse then
  312.   begin
  313.     for i:=0 to High(Result) do
  314.       weight += Round(Mouse.Position().DistanceTo(Result[i].Mean()));
  315.     Sort(Result, weight, True);
  316.   end;
  317. end;
  318.  
  319. procedure TMiner.OrganizeInv();
  320. var
  321.   move,empty,slots: TIntegerArray;
  322.   i,j: Int32;
  323.   a,b: TBox;
  324. begin
  325.   Inventory.FindItems(WHAT_TO_DROP, slots);
  326.  
  327.   for i:=0 to 27 do
  328.   begin
  329.     if Inventory.IsSlotUsed(i) and (slots.Find(i)=-1) then
  330.       move += i;
  331.     if not Inventory.IsSlotUsed(i) then
  332.       empty += i;
  333.   end;
  334.  
  335.   if Length(empty) = 0 then
  336.     Exit;
  337.  
  338.   for i in move do
  339.   begin
  340.     j := empty[high(empty)];
  341.     if j <= i then break;
  342.  
  343.     a := Inventory.GetSlotBox(i);
  344.     b := Inventory.GetSlotBox(j);
  345.     Mouse.Move(a);
  346.     Mouse.Hold(mouse_left);
  347.     WaitEx(100,15);
  348.     Mouse.Move(b);
  349.     WaitEx(100,15);
  350.     Mouse.Release(mouse_left);
  351.     WaitEx(140,20);
  352.  
  353.     empty.Pop();
  354.     empty.Append(i);
  355.     empty.Sort();
  356.   end;
  357. end;
  358.  
  359.  
  360. function TMiner.IsOreAliveFast(R: TRectangle): Boolean;
  361. var
  362.   TPA: TPointArray;
  363.   B: TBox;
  364.   color: TCTS2Color;
  365. begin
  366.   B := R.Bounds();
  367.   B.LimitTo(MainScreen.Bounds);
  368.   for color in Self.OreColor do
  369.     if srl.FindColors(TPA, color, B) > 200 then
  370.       Exit(True);
  371. end;
  372.  
  373. function TMiner.IsOreAlive(R: TRectangle; out Fitted: TRectangle): Boolean;
  374. var
  375.   TPA: TPointArray;
  376.   B: TBox;
  377.   color: TCTS2Color;
  378. begin
  379.   B := R.Bounds();
  380.   B.LimitTo(MainScreen.Bounds);
  381.  
  382.   for color in Self.OreColor do
  383.     if srl.FindColors(TPA, color, B) then begin
  384.       TPA := R.Filter(TPA).Cluster(MainScreen.NormalizeDistance(9)).Biggest();
  385.       Fitted := TPA.MinAreaRect();
  386.       if Length(TPA) > MainScreen.NormalizeDistance(200) then
  387.         Exit(True);
  388.     end;
  389. end;
  390.  
  391.  
  392. procedure TMiner.TryApplySwivel();
  393. begin
  394.   if (Self.SweivelTimer < GetTimeRunning()) then begin
  395.     Antiban.Swivel();
  396.     Self.SweivelTimer := GetTimeRunning() + srl.SkewedRand(30000, 0, 90000, 3);
  397.   end;
  398. end;
  399.  
  400.  
  401. procedure TMiner.TrackExperience();
  402. var
  403.   xpNow, xpGained: Int32;
  404.   xp_hour: Double;
  405. begin
  406.   if not Self.CanDebug.IsFinished() then
  407.     Exit;
  408.  
  409.   //ClearDebug();
  410.  
  411.   xpNow    := XPBar.Read();
  412.   xpGained := xpNow - Self.StartupXP;
  413.   xp_hour  := xpGained / GetTimeRunning() * 1000 * 60 * 60;
  414.  
  415.   WriteLn('--| SlackMiner |-----------------------------------------');
  416.   WriteLn('* Mode:      ', Self.GetFocus());
  417.   WriteLn('* Runtime:   ', srl.TimeRunning());
  418.   WriteLn('* Exp/hour:  ', FloatToStr(Round(xp_hour,1)));
  419.   WriteLn('* Exp total: ', xpGained);
  420.   WriteLn('---------------------------------------------------------');
  421.  
  422.   Self.CanDebug.Restart(100);
  423. end;
  424.  
  425.  
  426. procedure TMiner.FocusModeInit(Focus: EFocusType; Scale: Double = 1; MarkCompetition: Boolean = False);
  427. begin
  428.   case Focus of
  429.     ftUnfocused:  Self.UnfocusedTimer  := GetTimeRunning() + srl.SkewedRand(ONE_SECOND*25*Scale,  0, ONE_MINUTE*2*Scale, 3);
  430.     ftFocused:    Self.FocusTimer      := GetTimeRunning() + srl.SkewedRand(ONE_MINUTE*2.5*Scale, 0, ONE_MINUTE*5*Scale, 3);
  431.     ftHyperfocus: Self.HyperFocusTimer := GetTimeRunning() + srl.SkewedRand(ONE_MINUTE*2.0*Scale, 0, ONE_MINUTE*5*Scale, 3);
  432.   end;
  433.  
  434.   if MarkCompetition then Self.CompetingTimer := Self.HyperFocusTimer;
  435. end;
  436.  
  437. // allow mixed modes
  438. function TMiner.GetFocus(): set of EFocusType;
  439. begin
  440.   Result := [ftNormal];
  441.   if GetTimeRunning() < Self.HyperFocusTimer then Result += ftHyperfocus;
  442.   if GetTimeRunning() < Self.UnfocusedTimer  then Result += ftUnfocused;
  443.   if GetTimeRunning() < Self.FocusTimer      then Result += ftFocused;
  444.   //if GetTimeRunning() < Self.CompetingTimer  then Result += ftCompeting;
  445. end;
  446.  
  447.  
  448. function TMiner.BurstOfUnfocused(): Boolean;
  449. var
  450.   i,hi: Int32;
  451.   ForceMouseOff: Boolean;
  452. begin
  453.   i := 0;
  454.   WriteLn('[Antiban] Unfocused events!');
  455.   Result := True;
  456.   hi := srl.TruncatedGauss(4,-3);
  457.   while Result and (i < hi) do
  458.   begin
  459.     Result := False;
  460.  
  461.     if (Random() < 0.33) then
  462.     begin
  463.       WriteLn('[Antiban] Unfocused event: Swivel');
  464.       Antiban.SwivelNear(mouse.Position, 0.4, Random(3), Random(25,50), Random() > 0.5, Random(1,4));
  465.     end;
  466.  
  467.     if (Random() < 0.35) or ForceMouseOff then
  468.     begin
  469.       WriteLn('[Antiban] Unfocused event: MouseOff/LoseFocus!');
  470.       srl.MouseOffClient(srl.SkewedRand(3,0,3));
  471.       Antiban.LoseFocus(srl.SkewedRand(1000,500,30000));
  472.       Result := True;
  473.       ForceMouseOff := False;
  474.     end;
  475.  
  476.     if (Random() < 0.10) then
  477.     begin
  478.       WriteLn('[Antiban] Unfocused event: Check skill');
  479.       Antiban.HoverSkill(ERSSkill.MINING, Trunc(srl.SkewedRand(300,100,3000)), Random() > 0.33);
  480.       srl.MouseOffClient(Random(4));
  481.       Antiban.LoseFocus(Random(1000,20000));
  482.       Result := True;
  483.     end;
  484.  
  485.     if (Random() < 0.05) then
  486.     begin
  487.       WriteLn('[Antiban] Unfocused event: Random right');
  488.       Antiban.RandomRightClick();
  489.       Result := True;
  490.     end;
  491.  
  492.     if (Random() < 0.15) then
  493.     begin
  494.       WriteLn('[Antiban] Unfocused event: Examine player');
  495.       ForceMouseOff := not Antiban.HoverPlayerFunc();
  496.       Result := True;
  497.     end;
  498.  
  499.     Inc(i);
  500.   end;
  501. end;
  502.  
  503. procedure TMiner.TryTurn(R: TRectangle);
  504. begin
  505.   if (R.Mean.DistanceTo(Mouse.Position) < 30) and (not Self.IsOreAliveFast(R)) then
  506.   begin
  507.     Mouse.Move(R);
  508.     Sleep(Random(60,90));
  509.     if MainScreen.IsUpText('Mine Rocks') then
  510.       Mouse.Click(R, MOUSE_LEFT, Random() < 0.05);
  511.   end;
  512. end;
  513.  
  514.  
  515. procedure TMiner.DoAntiban(CheckBreaks: Boolean = True; CheckSleeps: Boolean = True);
  516. begin
  517.   Antiban.DoAntiban(CheckBreaks, CheckSleeps);
  518.   if not RSClient.IsLoggedIn() then
  519.     login.LoginPlayer();
  520. end;
  521.  
  522. function TMiner.IsRockDistant(rock: TPoint): Boolean;
  523. begin
  524.   Result := Self.LatestLocation.DistanceTo(Rock) > 5;
  525. end;
  526.  
  527.  
  528. (*
  529.   This method is executed once every mined rocks.
  530.  
  531.   1%  -> 1 in 100 mined rocks chance to activate mode.
  532.   2%  -> 1 in 50  ~~
  533.   5%  -> 1 in 20  ~~
  534.   10% -> 1 in 10  ~~
  535.  
  536.   Multiple modes can be triggered at once. So it can be efficently slow, whatever that means.
  537. *)
  538. function TMiner.TriggerFocusTest(): set of EFocusType;
  539. begin
  540.   Result := Self.GetFocus();
  541.  
  542.   // There's a random 2.0% chance we trigger a burst of halfassed unfocused working
  543.   if (not (ftUnfocused in Self.GetFocus())) and (Random() < 0.02) then
  544.   begin
  545.     Self.FocusModeInit(ftUnfocused);
  546.     Result += ftUnfocused;
  547.  
  548.     WriteLn('[Antiban] Burst of unfocused = Enabled!');
  549.     WriteLn('          Lasts for: ', (Self.UnfocusedTimer-GetTimeRunning()) / 1000, 'sec');
  550.   end;
  551.  
  552.   // There's a random 0.5% chance we trigger focus
  553.   if (not (ftFocused in Self.GetFocus())) and (Random() < 0.005) then
  554.   begin
  555.     Self.FocusModeInit(ftFocused);
  556.     Result += ftFocused;
  557.  
  558.     WriteLn('[Antiban] [RND]: Burst of focus = Enabled!');
  559.     WriteLn('          Lasts for: ', (Self.FocusTimer-GetTimeRunning()) / 1000, 'sec');
  560.   end;
  561.  
  562.   // There's a random 1.5% chance we trigger hyper focus
  563.   if (not (ftHyperfocus in Self.GetFocus())) and (Random() < 0.015) then
  564.   begin
  565.     // hyper focus doesn't mix with other modes.. and we want mixing, so fall back to
  566.     // the next best thing, focused.
  567.     if ftUnfocused in Self.GetFocus() then
  568.     begin
  569.       Self.FocusModeInit(ftFocused);
  570.       Result += ftFocused;
  571.  
  572.       WriteLn('[Antiban] [RND]: Burst of focus = Enabled!');
  573.       WriteLn('      Lasts for: ', (Self.FocusTimer-GetTimeRunning()) / 1000, 'sec');
  574.     end else
  575.     begin
  576.       Self.FocusModeInit(ftHyperfocus);
  577.       Result += ftHyperfocus;
  578.  
  579.       WriteLn('[Antiban] [RND]: Burst of hyper focus = Enabled!');
  580.       WriteLn('          Lasts for: ', (Self.HyperFocusTimer-GetTimeRunning()) / 1000, 'sec');
  581.     end;
  582.   end;
  583. end;
  584.  
  585.  
  586.  
  587. (*
  588.   Mines a series of rocks, and it tries to do it as fast as possible.
  589.  
  590.   There are no added delays like reaction time, other than the search for our
  591.   positon which delays like 20-40 ms, and the PC. Not that good, but just meant
  592.   to be freaking fast.
  593.  
  594.   Note: Sometimes the competition is very fast, and mines full inventory
  595.   should add a handler for that. We could ingore one rock and prep for the next
  596.   after tripple drop. Would be even more crazy logic.. ugh.
  597. *)
  598. function TMiner.MineHyperFocus(): Boolean;
  599. var
  600.   ore, fittedOre, next, junk: TRectangle;
  601.   missing, xp_prior, count: Int32;
  602.   OldMouse: TMouse;
  603.   dropRenderingTimer,oreTimeout: TCountDown;
  604.   ForceDrop: Boolean;
  605.  
  606.   IsDistant: Boolean;
  607.  
  608.   function NextOre(missing: Boolean=False): TRectangle;
  609.   var
  610.     _: Int32;
  611.     spm,me: TPoint;
  612.     weight: TIntegerArray;
  613.   begin
  614.     me := Self.GetMyPos();
  615.  
  616.     if FAST_RESPAWN and (not missing) then
  617.     begin
  618.       // shift location until next is under the mouse so that it matches with
  619.       // prediction.
  620.       spm := Mouse.Position();
  621.       for _:=0 to High(Self.OreLocations) do
  622.         if Self.WorldToMS(me, Self.OreLocations[Self.OreCounter]).Contains(spm) then
  623.           break
  624.         else
  625.           Self.OreCounter := SRL.Modulo(Self.OreCounter+1, Length(Self.OreLocations));
  626.     end;
  627.  
  628.     Result := Self.WorldToMS(me, Self.OreLocations[Self.OreCounter]);
  629.  
  630.     // if it's a distant rock we must know in order to trigger machnaism to
  631.     // handle the change in position.
  632.     IsDistant := Self.IsRockDistant(Self.OreLocations[Self.OreCounter]);
  633.  
  634.     Inc(Self.OreCounter);
  635.     if Self.OreCounter = Length(Self.OreLocations) then Self.OreCounter := 0;
  636.   end;
  637. begin
  638.   OldMouse := Mouse;
  639.   Mouse.MissChance := 0;             // we want to affect mouse globally in SRL.
  640.   Mouse.Speed      := Random(18,23); // I also dont like mouse misses here.
  641.   Mouse.CanIdle    := False;
  642.   dropRenderingTimer.Init(700);
  643.  
  644.   next := NextOre(); //initalize next rock data
  645.   while (ftHyperfocus in Self.GetFocus()) and (not Inventory.IsFull()) do
  646.   begin
  647.     Ore := NextOre(missing > 0); //missing > 0, avoid locking mouse on single ore
  648.  
  649.     if ForceDrop or ((not Self.IsOreAlive(Ore, fittedOre))) then
  650.     begin
  651.       missing += 1;
  652.       if (ForceDrop) or (dropRenderingTimer.IsFinished() and (missing >= Length(Self.OreLocations)) or ((Inventory.Count() > 6) and (Random() < 0.15))) then
  653.       begin
  654.         Self.IntenseDrop(next.Mean());
  655.         dropRenderingTimer.Restart(70);
  656.         missing := 0;
  657.         count := 0;
  658.         ForceDrop := False;
  659.       end;
  660.       continue;
  661.     end;
  662.  
  663.     count += 1;
  664.  
  665.     // We found our next rock, so add it to chache for future lookup
  666.     if ClickOrder.Push(fittedOre) then
  667.       next := ClickOrder.Next();
  668.  
  669.     RSClient.Image.Clear();
  670.     RSClient.Image.DrawRect(fittedOre, $00FF00);
  671.  
  672.     // move mouse to the location, followed by a click
  673.     Mouse.Move(fittedOre, Random() < 0.05);
  674.     Sleep(Random(30,50));
  675.     if not MainScreen.IsUpText('Mine '+Self.OreName+' rocks') then
  676.       continue;
  677.  
  678.     xp_prior := XPBar.Read();
  679.     Mouse.Click(fittedOre, MOUSE_LEFT, Random() < 0.15);
  680.     if not MainScreen.DidRedClick() then
  681.       continue;
  682.  
  683.     // mouse ahead to whatever the next objective is
  684.     if (count < Length(Self.OreLocations)) or (count < MIN_ORE_DROP_COUNT) then
  685.       Mouse.Move(next)
  686.     else if Random() < 0.95 then
  687.     begin
  688.       Mouse.NearInventory();
  689.       ForceDrop := True;
  690.     end;
  691.  
  692.     // wait while we gather the actual ore
  693.     oreTimeout.Init(Random(8000,10000));
  694.     while not((XPBar.Read() <> xp_prior) or ((not IsDistant) and (not Self.IsOreAlive(Ore,junk))) or (Chat.LeveledUp()) or Chat.FindOption('is too full to hold', [CHAT_COLOR_BLACK])) do
  695.     begin
  696.       // increasing odds over time for mouse movement to actual inventory slot
  697.       // rather than just always resting near. Antiban that improves performance.
  698.       if ForceDrop and (Random()*oreTimeout.TimeRemaining()/8000 < 0.08) then
  699.         Mouse.Move(Inventory.GetSlotBox(0));
  700.       Sleep(Random(13,20));
  701.     end;
  702.  
  703.  
  704.     RSClient.Image.DrawRect(fittedOre, $FF);
  705.     if (not FAST_RESPAWN) and (Random(100) < HYPER_TURN_PERCENTAGE) then
  706.       Self.TryTurn(next);
  707.  
  708.     Self.TrackExperience();
  709.  
  710.     //if Inventory.IsFull() then Self.DropInventory();
  711.   end;
  712.  
  713.   Mouse := OldMouse;
  714. end;
  715.  
  716.  
  717. (*
  718.   Mines a single ore.
  719.  
  720.   Computers are differnt than people, they tend to repeat the same task in the
  721.   exact same amount of time, so I've added a variance to this, ReactionTime.
  722.   Humans, notably gamers, have a focused reactiontime of 150-250 ms.
  723.   This kicks in when we have predicted the next ore to be mined correctly.
  724. *)
  725. function TMiner.MineOnce(out Rect,NextRect: TRectangle): Boolean;
  726. var
  727.   arr: TRectArray;
  728.   R: TRectangle;
  729.   circle: TCircle;
  730.   i: Int32;
  731.   HumanResponseTimer, ReactionTime: Double;
  732. begin
  733.   RSClient.Image.Clear();
  734.   HumanResponseTimer := GetTimeRunning();
  735.  
  736.   case ftFocused in Self.GetFocus() of
  737.     True:  ReactionTime := srl.SkewedRand(140, 100, 400);
  738.     False: ReactionTime := srl.SkewedRand(180, 150, 900);
  739.   end;
  740.  
  741.   if ftUnfocused in Self.GetFocus() then
  742.     ReactionTime *= 1.5;
  743.  
  744.   // a 7% chance that our rection time just becomes crap no matter focus
  745.   if(Random() < 0.07) then
  746.     ReactionTime += Random(2000);
  747.  
  748.   // Early version actually ended up trading one guy, idk how
  749.   if ChooseOption.IsOpen() then
  750.     ChooseOption.Close();
  751.  
  752.   arr := Self.GetOres();
  753.   for i:=0 to High(arr) do begin
  754.     if not Self.IsOreAlive(arr[i], R) then
  755.       continue;
  756.  
  757.     // move the mouse
  758.     RSClient.Image.DrawRect(R, $00FF00);
  759.     Mouse.Move(R, Random() < 0.1);
  760.  
  761.  
  762.     Sleep(Random(10,40));
  763.     if not WaitUntil(MainScreen.IsUpText('Mine '+Self.OreName+' rocks'), Random(20,50), Random(200,300)) then
  764.       break;
  765.  
  766.     // a humans reactiontime offset
  767.     WaitUntil(GetTimeRunning() > HumanResponseTimer+ReactionTime, Random(5,15), 2000);
  768.  
  769.     //
  770.     Self.IsDistant_Slow := Self.LatestLocation.DistanceTo(Self.OreLocations[i]) > 5;
  771.  
  772.     // click it!
  773.     Mouse.Click(R, MOUSE_LEFT, Random() < 0.15);
  774.     Result := MainScreen.DidRedClick();
  775.  
  776.     // if we missed the rock, chances are we'd start moving, so recover instantly!
  777.     if not Result then
  778.     begin
  779.       RSW.WalkPath([Self.GetMyPos()]);
  780.       Exit;
  781.     end;
  782.  
  783.     // random extra clicks
  784.     for 1 to SRL.TruncatedGauss(-2, 3) do
  785.     begin
  786.       circle.x := Mouse.Position().X;
  787.       circle.y := Mouse.Position().Y;
  788.       circle.radius := 5;
  789.       Mouse.Click(circle, MOUSE_LEFT, True);
  790.       Sleep(Random(0,150));
  791.     end;
  792.  
  793.     if not Result then
  794.       continue;
  795.  
  796.     //output current rectangle
  797.     Rect := R;
  798.  
  799.     // burst of unfocused
  800.     if (ftUnfocused in Self.GetFocus()) and Self.BurstOfUnfocused() then
  801.       Exit(True);
  802.  
  803.     // fill with current, than fetch the next one
  804.     ClickOrder.Push(R);
  805.     nextRect := ClickOrder.Next();
  806.  
  807.     // move mouse to the next ore
  808.     if (Random() > 0.15) or ((ftFocused in Self.GetFocus()) and (Random() > 0.05)) then
  809.     begin
  810.       Wait(0,1200, wdLeft);
  811.       if nextRect.Mean.InBox(MainScreen.Bounds) then
  812.         Mouse.Move(nextRect, Random() < 0.1);
  813.     end;
  814.     break;
  815.   end;
  816.  
  817.   if (not Result) then
  818.     Self.TryApplySwivel();
  819. end;
  820.  
  821.  
  822. (*
  823.   Mines one inventory of ores
  824. *)
  825. function TMiner.Mine(): Boolean;
  826. var
  827.   next,r,_: TRectangle;
  828.   baseCount,clicks,success,xp_prior: Int32;
  829.   breakrnd: Double;
  830. begin
  831.   Result := False;
  832.   (* the loops criteria like this:
  833.     1. If inventory is open then we check if its full, and if so break
  834.     2. If chat-message too full inventory then be break
  835.     3. If we are in unfocused mode we may click the ore even tho inventory is full a few times
  836.     4. We might miss that it's full on a rare occation as well
  837.   *)
  838.   while True do
  839.   begin
  840.     xp_prior := XPBar.Read();
  841.     if Self.MineOnce(r,next) then
  842.     begin
  843.       if Inventory.IsOpen() then Inc(clicks);
  844.       if Inventory.IsOpen() then baseCount := Inventory.Count();
  845.       Sleep(Random(50,150));
  846.       WaitUntil(not Minimap.IsPlayerMoving(), 30, Random(2000,3000));
  847.  
  848.       WaitUntil((XPBar.Read() <> xp_prior) or ((not Self.IsDistant_Slow) and (not Self.IsOreAlive(r,_))) or (Chat.LeveledUp()) or Chat.FindOption('is too full to hold', [CHAT_COLOR_BLACK]), 20, Random(8000,12000));
  849.       RSClient.Image.DrawRect(R, $FF);
  850.  
  851.       if Inventory.IsOpen() and (Inventory.Count() > baseCount) then Inc(success);
  852.  
  853.       // turn towards next ore (?)
  854.       if (Random() < 0.1) or (ftFocused in Self.GetFocus()) then
  855.         Self.TryTurn(next);
  856.  
  857.       // check if we have an antiban ready and lined up
  858.       Self.DoAntiban();
  859.  
  860.       // Competition for the ore? Let's trigger hyperfocus!
  861.       if (clicks > Random(3,5)) and (success / clicks < 0.67) then
  862.       begin
  863.         Self.FocusModeInit(ftHyperfocus, 1.5, True);
  864.         WriteLn('[Warning: high competition]: Burst of focus = Enabled!');
  865.         WriteLn('                             Lasts for: ', (Self.HyperFocusTimer-GetTimeRunning()) / 1000, 'sec');
  866.         Exit;
  867.       end;
  868.  
  869.       // a 5% chance of just waiting a little extra between ores.
  870.       if (Random() < 0.05) and (not (ftFocused in Self.GetFocus())) then
  871.         Sleep(srl.SkewedRand(70,0,4000));
  872.  
  873.       // check if we should trigger any focus mode:
  874.       if ftHyperfocus in TriggerFocusTest() then
  875.         break; //special mining method for this one
  876.  
  877.  
  878.       // if inventory isn't open then add a chance for actually opening it again
  879.       // assuming we are not in an unfocused burst
  880.       if (Random(14) = 0) and (not Inventory.IsOpen()) and (not (ftUnfocused in Self.GetFocus())) then
  881.         Inventory.Open();
  882.  
  883.       // trigger intense drop every 2-6rd success
  884.       if (ftFocused in Self.GetFocus()) and (success mod srl.SkewedRand(3, 2, 6) = 0) then
  885.         Self.IntenseDrop(next.Mean());
  886.     end;
  887.  
  888.     // A number of checks to see if we should break this loop
  889.     begin
  890.       breakrnd := 0.1;
  891.       if (ftUnfocused in Self.GetFocus()) then breakrnd := 0.5;
  892.  
  893.       // inventory open? If so, is it full?
  894.       if (Inventory.IsOpen() and Inventory.IsFull()) and (Random() > breakrnd) then
  895.         break;
  896.  
  897.       // Where the fuck are we?
  898.       if Self.GetMyPos().DistanceTo(Self.OreLocations[0]) > 12 then
  899.         break;
  900.  
  901.       // well shiiiiit!!!
  902.       if not RSClient.IsLoggedIn() then
  903.         break;
  904.  
  905.       // oh, so it's full.. okay!
  906.       if (Chat.FindOption('is too full to hold', [CHAT_COLOR_BLACK])) and (Random() > breakrnd) then
  907.         break;
  908.     end;
  909.  
  910.     // track XP
  911.     Self.TrackExperience();
  912.   end;
  913.  
  914.   if (Random() < 0.16) and (Chat.FindOption('is too full to hold')) then
  915.     Chat.ClickContinue(Random() > 0.1);
  916. end;
  917.  
  918.  
  919. procedure TMiner.IntenseDrop(ReturnTo: TPoint);
  920. var
  921.   slots,order: TIntegerArray;
  922.   i: Int32;
  923.   n: Int32 = 3;
  924. begin
  925.   // first check if we should reorganize inventory
  926.   Self.OrganizeInv();
  927.  
  928.   // now we can do the dropping
  929.   if Random(5) = 0 then
  930.     n := Random(2,6);
  931.  
  932.   //if ftCompeting in Self.GetFocus() then n := Max(1,n-2);
  933.  
  934.   // in case we have a lot more time to drop, so increase rates!
  935.   if Length(Self.OreLocations) < 3 then
  936.   begin
  937.     n := 6;
  938.     if Random(5) = 0 then
  939.       n := Random(4,12);
  940.   end;
  941.  
  942.   if Inventory.FindItems(WHAT_TO_DROP, Slots) then
  943.     for i:=0 to High(DROP_PATTERN_REGULAR) do
  944.       if Slots.Find(DROP_PATTERN_REGULAR[I]) > -1 then
  945.         order += DROP_PATTERN_REGULAR[I];
  946.  
  947.   if (Length(Slots) >= MIN_ORE_DROP_COUNT) then
  948.   begin
  949.     SetLength(order, Min(Length(order), n));
  950.  
  951.     if Inventory.IsFull() then
  952.     begin
  953.       Self.DropInventory();
  954.       Exit;
  955.     end;
  956.  
  957.     // faster shift dropping with only a single shift-down.
  958.     Keyboard.KeyDown(VK_SHIFT);
  959.     Wait(90, 160, wdLeft);
  960.     slots := Inventory.ErrorPattern(order,3);
  961.     for i:=0 to High(slots) do
  962.     begin
  963.       Mouse.Click(Inventory.GetSlotBox(slots[i]), MOUSE_LEFT);
  964.  
  965.       for 1 to SRL.TruncatedGauss(0, 3) do // Spam click a little
  966.         Mouse.Click(TCircle([Mouse.Position().X, Mouse.Position().Y, 5]), MOUSE_LEFT, True);
  967.  
  968.       if i <> High(i) then Wait(65, 170, wdLeft) else Wait(0, 50, wdLeft);
  969.     end;
  970.     Keyboard.KeyUp(VK_SHIFT);
  971.  
  972.     //Inventory.ShiftDrop(Inventory.ErrorPattern(order,3));
  973.     Mouse.Move(ReturnTo,25);
  974.   end;
  975. end;
  976.  
  977.  
  978. procedure TMiner.DropInventory();
  979. var
  980.   ptrn: TIntegerArray;
  981.   slices: TIntegerArray;
  982.   sequences: T2DIntArray;
  983.   i,hi: Int32;
  984. begin
  985.   ptrn := Inventory.ErrorPattern(DROP_PATTERN_REGULAR, 10);
  986.  
  987.   hi := 0;
  988.   while hi <> Length(ptrn) do
  989.   begin
  990.     if ftUnfocused in Self.GetFocus() then
  991.       slices += Random(hi, Length(ptrn))
  992.     else
  993.       slices += srl.TruncatedGauss(Length(ptrn), hi, 6);
  994.     hi := slices[High(slices)];
  995.   end;
  996.   sequences += Copy(ptrn, 0, slices[0]);
  997.   for i:=1 to High(slices) do
  998.     sequences += Copy(ptrn, slices[i-1], 28-slices[i-1]);
  999.  
  1000.  
  1001.   for i:=0 to High(sequences) do
  1002.   begin
  1003.     ptrn := sequences[i];
  1004.  
  1005.     // check if we have an antiban ready and lined up
  1006.     Self.DoAntiban();
  1007.  
  1008.     // shift-drop the rest of our ores
  1009.     Inventory.ShiftDrop(WHAT_TO_DROP, ptrn);
  1010.     if (ftUnfocused in Self.GetFocus()) then Self.BurstOfUnfocused();
  1011.  
  1012.     if (ftFocused in Self.GetFocus()) and (i = High(sequences))  then
  1013.       break;
  1014.  
  1015.     Sleep(srl.TruncatedGauss(0, 6000, 6));
  1016.  
  1017.     // if we are unfocused shit might happen.
  1018.     if (ftUnfocused in Self.GetFocus()) then
  1019.     begin
  1020.       Self.BurstOfUnfocused();
  1021.       if (Random() < 0.1) then break;
  1022.     end;
  1023.   end;
  1024.  
  1025.   //selection := Inventory.GetSelectedSlot();
  1026.   //if selection <> -1 then Inventory.ClickSlot(i);
  1027. end;
  1028.  
  1029.  
  1030. procedure TMiner.DebugOres();
  1031. var
  1032.   arr: TRectArray;
  1033.   rect,_: TRectangle;
  1034. begin
  1035.   arr := Self.GetOres();
  1036.   for rect in arr do
  1037.   begin
  1038.     if Self.IsOreAlive(rect,_) then
  1039.       RSClient.Image.DrawRect(rect, $00FF00)
  1040.     else
  1041.       RSClient.Image.DrawRect(rect, $FF);
  1042.   end;
  1043. end;
  1044.  
  1045.  
  1046. procedure TMiner.SetupOres(out Locations: T2DPointArray; out Colors: array of array of TCTS2Color; out Name: array of string);
  1047. begin
  1048.   locations := [];
  1049.   colors    := [];
  1050.  
  1051.   // somewhat bugged, may misclick to the wrong ore
  1052.   {EastVarrockMine - iron ore}
  1053.   locations += [[4950+159, 2976-429],[4954+159, 2972-429]];
  1054.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1055.   name      += 'Iron';
  1056.  
  1057.   // working
  1058.   {WestVarrockMine - iron ore}
  1059.   locations += [[4668, 2555], [4668, 2547]];
  1060.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1061.   name      += 'Iron';
  1062.  
  1063.   // questionable
  1064.   {LumbridgeTutor - tin ore}
  1065.   locations += [[4700+159, 3864-429],[4697+159, 3860-429],[4701+159, 3856-429]];
  1066.   colors    += [CTS2(7895427, 14, 0.20, 0.12)];
  1067.   name      += 'Tin';
  1068.  
  1069.   // working
  1070.   {AkharidMine - iron ore}
  1071.   locations += [[5148, 2782],[5144, 2778],[5148,2774]];
  1072.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1073.   name      += 'Iron';
  1074.  
  1075.   // idk.. seemed _OK_ - skeletons tried to kill me though
  1076.   {WildyMine - iron ore}
  1077.   locations += [[4229+159, 2172-428],[4226+159, 2167-428]];
  1078.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1079.   name      += 'Iron';
  1080.  
  1081.   //working
  1082.   {Dwarven mine - 2 rock - iron ore}
  1083.   locations += [[5987, 6526],[5983, 6530]{, [5994, 6523]}];
  1084.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1085.   name      += 'Iron';
  1086.  
  1087.   //working
  1088.   {F2P Mining Guild - 2 rock - iron ore}
  1089.   locations += [[5967, 6683], [5967, 6675]{,[5971, 6683],  [5975, 6680]}];
  1090.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1091.   name      += 'Iron';
  1092.  
  1093.   //working
  1094.   {Nomade lands [Giants plateau] - 2 rock - iron ore}
  1095.   locations += [[5576, 3346], [5580, 3342]];
  1096.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1097.   name      += 'Iron';
  1098.  
  1099.  
  1100.   // Pay to win locations:
  1101.  
  1102.   {P2P Mining Guild - iron ore [untested]}
  1103.   locations += [[5951, 6751], [5954, 6747], [5958, 6751]];
  1104.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1105.   name      += 'Iron';
  1106.  
  1107.   // untested - but should work
  1108.   {EastArdougneMine - iron ore}
  1109.   locations += [[2574+159, 3131-429],[2578+159, 3135-429],[2582+159, 3131-429]];
  1110.   colors    += [CTS2(2240329, 11, 0.12, 0.60)];
  1111.   name      += 'Iron';
  1112. end;
  1113.  
  1114.  
  1115. procedure TMiner.Setup();
  1116. var
  1117.   i,selected: Int32;
  1118.   me: TPoint;
  1119.   best: Double;
  1120.   reg: TBox;
  1121.   locations: T2DPointArray;
  1122.   colors: array of array of TCTS2Color;
  1123.   names: array of string;
  1124. begin
  1125.   RSClient.Image.Clear();
  1126.   Mouse.Speed := Random(14,16);
  1127.   Antiban.DisableDebugging := True;
  1128.  
  1129.   // ===========================================================================
  1130.   // detect ore location automatically based on our current pos:
  1131.   Self.RSW.Setup('world');
  1132.  
  1133.   Self.SetupOres(locations, colors, names);
  1134.  
  1135.   best := $FFFFFF;
  1136.   selected := -1;
  1137.   me := Self.RSW.GetMyPos();
  1138.   WriteLn('Found your location as: ', me);
  1139.   for i:=0 to High(locations) do
  1140.     if (Distance(locations[i][0], me) < 5*5) and   //5 tiles away at most
  1141.        (Distance(locations[i][0], me) < best) then //select closest rocks
  1142.     begin
  1143.       selected := i;
  1144.     end;
  1145.  
  1146.   Self.RSW.Free(); // release world RSW.
  1147.  
  1148.   if selected = -1 then
  1149.     TerminateScript('00000001: There are no ores near by');
  1150.  
  1151.   Self.OreLocations := locations[selected];
  1152.   Self.OreColor := colors[selected];
  1153.   Self.OreName  := names[selected];
  1154.  
  1155.  
  1156.   // ===========================================================================
  1157.   // load powerminer by region:
  1158.   reg := [Self.OreLocations[0].x-150,Self.OreLocations[0].y-150,Self.OreLocations[0].x+150,Self.OreLocations[0].y+150];
  1159.   Self.RSW.Setup('world', TBoxArray([reg]));
  1160.  
  1161.  
  1162.   // ===========================================================================
  1163.   // Debug test
  1164.   Self.DebugOres();
  1165.  
  1166.  
  1167.   // ===========================================================================
  1168.   // Setup standard shit
  1169.   Self.SweivelTimer := GetTimeRunning() + srl.SkewedRand(6000, 0, 15000, 3);
  1170.   Self.DeclarePlayers();
  1171.  
  1172.   Antiban.Skills := [ERSSkill.MINING];
  1173.   Antiban.MaxZoom := 60;
  1174.   Antiban.MinZoom := 30;
  1175.  
  1176.   Antiban.AddTask(5  * ONE_MINUTE, @Antiban.HoverPlayer);
  1177.   Antiban.AddTask(6  * ONE_MINUTE, @Antiban.RandomPOVTask);
  1178. //Antiban.AddTask(8  * ONE_MINUTE, @Antiban.RandomRightClick);
  1179.   Antiban.AddTask(8  * ONE_MINUTE, @Antiban.Swivel);
  1180.   Antiban.AddTask(9  * ONE_MINUTE, @Antiban.HoverSkills);
  1181.   Antiban.AddTask(10 * ONE_MINUTE, @Antiban.LoseFocus);
  1182.   Antiban.AddTask(12 * ONE_MINUTE, @Antiban.RandomTab);
  1183.  
  1184.   Antiban.AddBreak(25  * ONE_MINUTE, 1  * ONE_MINUTE, 0.33, 0.01);
  1185.   Antiban.AddBreak(55  * ONE_MINUTE, 2  * ONE_MINUTE, 0.33, 0.02);
  1186.   Antiban.AddBreak(80  * ONE_MINUTE, 5  * ONE_MINUTE, 0.33, 0.15);
  1187.   Antiban.AddBreak(100 * ONE_MINUTE, 10 * ONE_MINUTE, 0.33, 0.75);
  1188.   Antiban.AddBreak(150 * ONE_MINUTE, 30 * ONE_MINUTE, 0.33, 0.85);
  1189.   //Antiban.AddSleep('00:00', 8, 1, 1.0);
  1190.  
  1191.   Self.RSW.ScreenWalk := True;
  1192.  
  1193.   Self.StartupXP := XPBar.Read();
  1194.  
  1195.   me := Self.GetMyPos();
  1196.   for i:=0 to High(Self.OreLocations) do
  1197.     Self.ClickOrder.History += self.WorldToMS(me, Self.OreLocations[i]);
  1198.  
  1199.   Self.CanDebug.Init(2000);
  1200. end;
  1201.  
  1202. var rsw_time: Double; p: TPoint
  1203. begin
  1204.   srl.Setup();
  1205.   Bot.Setup();
  1206.  
  1207.   rsw_time := PerformanceTimer();
  1208.   p := Bot.GetMyPos();
  1209.   WriteLn(PerformanceTimer() - rsw_time, 'ms to look up position -> ', p);
  1210.   if PerformanceTimer() - rsw_time > 60 then
  1211.     WriteLn('[Warning] Positioning is slow on your computer, this can impact efficiency.');
  1212.  
  1213.   Bot.HyperFocusTimer := 1000*60*FORCE_HYPER_MODE_MINUTES;
  1214.   //Bot.HyperFocusTimer := 1000*60*20;
  1215.   //Bot.CompetingTimer := Bot.HyperFocusTimer;
  1216.  
  1217.   while RSClient.IsLoggedIn() and (not Inventory.IsFull()) do
  1218.   begin
  1219.     if Bot.GetMyPos().DistanceTo(Bot.OreLocations[0]) < 5*5 then
  1220.     begin
  1221.       if ftHyperfocus in Bot.GetFocus() then
  1222.         Bot.MineHyperFocus()
  1223.       else
  1224.         Bot.Mine();
  1225.     end
  1226.     else
  1227.       TerminateScript('00000002: There are no ores near by!');
  1228.  
  1229.     if Inventory.IsFull() then
  1230.       Bot.DropInventory();
  1231.  
  1232.     if not RSClient.IsLoggedIn() then
  1233.       login.LoginPlayer();
  1234.   end;
  1235. end.
  1236.  
Add Comment
Please, Sign In to add comment