WarPie90

Untitled

Dec 29th, 2022
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.32 KB | None | 0 0
  1. (*
  2.   Mines a single ore.
  3.  
  4.   Computers are differnt than people, they tend to repeat the same task in the
  5.   exact same amount of time, so I've added a variance to this, ReactionTime.
  6.   Humans, notably gamers, have a focused reactiontime of 150-250 ms.
  7.   This kicks in when we have predicted the next ore to be mined correctly.
  8. *)
  9. function TMiner.MineOnce(out Rect: TRectangle): Boolean;
  10. var
  11.   arr: TRectArray;
  12.   R,_,next: TRectangle;
  13.   circle: TCircle;
  14.   i: Int32;
  15.   HumanResponseTimer, ReactionTime: Double;
  16. begin
  17.   RSClient.Image.Clear();
  18.   HumanResponseTimer := GetTimeRunning();
  19.  
  20.   case Self.IsHyperFocused() of
  21.     True:  ReactionTime := srl.SkewedRand(150, 100, 450);
  22.     False: ReactionTime := srl.SkewedRand(180, 150, 900);
  23.   end;
  24.  
  25.   if Self.IsUnfocused() then
  26.     ReactionTime *= 1.5;
  27.  
  28.   // a 7% chance that our rection time just becomes crap no matter focus
  29.   if(Random() < 0.07) then
  30.     ReactionTime += Random(2000);
  31.  
  32.   // It actually ended up trading one guy, idk how
  33.   if ChooseOption.IsOpen then
  34.     ChooseOption.Close();
  35.  
  36.   arr := Self.FindOres();
  37.  
  38.   for i:=0 to High(Self.OreLocations) do begin
  39.     if not Self.IsOreAlive(arr[i], R) then
  40.       continue;
  41.  
  42.     // move the mouse
  43.     RSClient.Image.DrawRect(R, $00FF00);
  44.     if (not R.Contains(Mouse.Position())) or (Random() < 0.1) then
  45.       Mouse.Move(srl.rowp(mouse.Position(), R));
  46.    
  47.     Sleep(Random(10,40));
  48.     if not WaitUntil(MainScreen.IsUpText(['Mine','Rocks']), Random(20,50), Random(200,300)) then
  49.       Exit(False);
  50.  
  51.     // a humans reactiontime offset
  52.     WaitUntil(GetTimeRunning() > HumanResponseTimer+ReactionTime, Random(5,15), 2000);
  53.  
  54.     // click it!
  55.     Mouse.Click(R, MOUSE_LEFT, Random() < 0.15);
  56.     Result := MainScreen.DidRedClick();
  57.     if not Result then
  58.        WriteLn('OH FUCK!! SHIT IS GOING DOWN NOW');
  59.        
  60.      
  61.     // random extra clicks
  62.     for 1 to SRL.TruncatedGauss(-2, 3) do
  63.     begin
  64.       circle.x := Mouse.Position().X;
  65.       circle.y := Mouse.Position().Y;
  66.       circle.radius := 5;
  67.       Mouse.Click(circle, MOUSE_LEFT, True);
  68.       Sleep(Random(0,150));
  69.     end;
  70.  
  71.     // to ensure there is no repaid clicking due to walking
  72.     Sleep(Random(300,600));
  73.     Minimap.WaitPlayerMoving();
  74.     arr := Self.FindOres();
  75.     Self.IsOreAlive(arr[i], R);
  76.  
  77.     if not Result then
  78.       continue;
  79.  
  80.     // update our mouse sequence
  81.     ClickOrder.Push(R);
  82.  
  83.     //output current rectangle
  84.     Rect := R;
  85.  
  86.     // safety mechanism
  87.     if not Self.IsOreAlive(R,_) then
  88.     begin
  89.       Result := False;
  90.       continue;
  91.     end;
  92.  
  93.     //if we missed it, then 60% chance to do a quick swirl
  94.     if not Result then
  95.       if (Random() < 0.6) then
  96.       begin
  97.         Antiban.SwivelNear(Mouse.Position, 0.4, Random(1,2), Random(20,35), Random() > 0.5);
  98.         Exit;
  99.       end;
  100.  
  101.     // burst of unfocused
  102.     if Self.IsUnfocused() and Self.BurstOfUnfocused() then
  103.       Exit(True);
  104.  
  105.     // next ore id
  106.     next := ClickOrder.Top();
  107.  
  108.     // move mouse to the next ore
  109.     if (Random() > 0.3) or (Self.IsHyperFocused() and (Random() > 0.05)) then
  110.     begin
  111.       Sleep(srl.TruncatedGauss(0, 2000));
  112.       if next.Mean.InBox(MainScreen.Bounds) then
  113.         Mouse.Move(next);
  114.     end;
  115.     break;
  116.   end;
  117.  
  118.   if (not Result) then
  119.   begin
  120.     Self.TryApplySwivel();
  121.   end;
  122. end;
Add Comment
Please, Sign In to add comment