WarPie90

Aerial fishing thingy

Jul 24th, 2023 (edited)
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 8.86 KB | None | 0 0
  1. program new;
  2. {$DEFINE SRL_USE_REMOTEINPUT}
  3. {$I SRL/osr.simba}
  4.  
  5. const
  6.   USERNAME = '';
  7.   PASSWORD = '';
  8.  
  9.  
  10.  
  11. var
  12.   current: TPoint;
  13.   FastMouse: TMouse := Mouse;
  14.   FishingSites: TCircleArray;
  15.   fishing_xp, hunter_xp: single;
  16.  
  17.  
  18.  
  19. const
  20.   P2P_WORLDS = [302,303,304,305,306,307,309,310,311,312,313,314,315,317,318,319,320];
  21.  
  22. procedure TSRL.MouseOffClient(direction: Byte);
  23. var
  24.   W,H: Int32;
  25.   pt: TPoint;
  26. begin
  27.   GetClientDimensions(W, H);
  28.   pt := Mouse.Position();
  29.   if (pt.X < 0) or (pt.X > W) or (pt.Y < 0) or (pt.Y > H) then
  30.     Exit();
  31.   if (direction >= 4) then
  32.     direction := Random(0,3);
  33.   case direction of
  34.     0: Mouse.Move(Box(-300, -300, W, 0)); // top
  35.     1: Mouse.Move(Box(0, H, W, H+300));   // bottom
  36.     2: Mouse.Move(Box(-300, 0, 0, H));    // left
  37.     3: Mouse.Move(Box(W, 0, W+300, H));   // right
  38.   end;
  39. end;
  40.  
  41. procedure TAntiban.RandomPOVTask;
  42. begin
  43.   case Random(7) of
  44.     0:   Self.AdjustZoom;
  45.     else Self.RandomRotate;
  46.   end;
  47. end;
  48.  
  49. procedure TAntiban.LoseFocus(); override;
  50. begin
  51.   if Random() < 0.5 then
  52.     srl.MouseOffClient(srl.SkewedRand(3,0,3));
  53.   Antiban.LoseFocus(srl.SkewedRand(1000,500,30000));
  54. end;
  55.  
  56. procedure DoAntiban(CheckBreaks: Boolean = True; CheckSleeps: Boolean = True);
  57. begin
  58.   Antiban.DoAntiban(CheckBreaks, CheckSleeps);
  59.   if not RSClient.IsLoggedIn() then
  60.     login.LoginPlayer();
  61. end;
  62.  
  63. function FindFish(): TCircleArray;
  64. var
  65.   TPA: TPointArray;
  66.   ATPA: T2DPointArray;
  67.   i: Int32;
  68.   c: TCircle;
  69. begin
  70.   srl.FindColors(TPA, CTS2(11634814, 8, 0.13, 0.99), MainScreen.Bounds);
  71.   if Length(TPA) = 0 then Exit;
  72.  
  73.   ATPA := TPA.Cluster(5);
  74.   ATPA.SortByMiddle(Mouse.Position());
  75.  
  76.   if Length(ATPA) = 0 then Exit;
  77.  
  78.   if not ATPA[0].Bounds().Contains(Mouse.Position) then
  79.     ATPA.SortByMiddle(MainScreen.Center);
  80.  
  81.   for i:=0 to High(ATPA) do
  82.   begin
  83.     if Length(TPA) < 100 then continue;
  84.     c := ATPA[i].MinAreaCircle();
  85.     if c.Radius > 8 then
  86.       Result += c;
  87.   end;
  88.  
  89.   RSClient.Image.Clear();
  90.   for i:=0 to High(result) do
  91.     RSClient.Image.DrawCircle(Result[i].Mean(), Result[i].Radius, 1);
  92. end;
  93.  
  94. function MouseNext(): Boolean;
  95. var i: Int32;
  96. begin
  97.   FishingSites := FindFish();
  98.   for i:=0 to High(FishingSites) do
  99.     if not FishingSites[i].Contains(current) then
  100.     begin
  101.       FastMouse.Move(FishingSites[i].Mean, FishingSites[i].Radius);
  102.       break;
  103.     end;
  104. end;
  105.  
  106. function TrackBird(DbgColor: Int32 = 0; offset: TPoint=[0,0]): TPoint;
  107. var
  108.   TPA,wat,line: TPointArray;
  109.   ATPA: T2DPointArray;
  110.   i,n: Int32;
  111.   m: TPoint;
  112.   b: TBox;
  113. begin
  114.   m := current;
  115.   line := TPAFromLine(m, MainScreen.Center);
  116.   b := line.Bounds().Expand(50);
  117.   b.LimitTo(MainScreen.Bounds);
  118.  
  119.   n := 0;
  120.   repeat
  121.     srl.FindColors(TPA, CTS2(5064528, 12, 2.74, 0.48), b);
  122.  
  123.     TPA := TPA.PointsInRangeOf(line, 0, 50);
  124.  
  125.     ATPA := TPA.Cluster(10);
  126.     ATPA.FilterSize(30,200);
  127.     TPA := ATPA.Means();
  128.     TPA.SortFromLine(m, MainScreen.Center);
  129.  
  130.     if DbgColor <> 0 then
  131.     begin
  132.       RSClient.Image.Clear(b);
  133.       if Length(TPA) > 0 then
  134.         RSClient.Image.DrawCircle(TPA[0]+offset, 8, DbgColor);
  135.     end;
  136.     n += 1;
  137.   until Length(TPA) > 0;
  138.  
  139.   TPA.Sort(MainScreen.Center);
  140.   Result := TPA[0];
  141. end;
  142.  
  143. function WaitBird(dist: Single): Boolean;
  144. var
  145.   a,b,o: TPoint;
  146.   return: Boolean;
  147.   slot: Int32;
  148.   t: TCountDown;
  149.  
  150.   function Dbgoff(a,b: TPoint): TPoint;
  151.   var t: Single;
  152.   begin
  153.     if a.DistanceTo(b) < 10 then Exit(Point(0,0));
  154.     t := ArcTan2(b.y-a.y, b.x-a.x);
  155.     Result := [Round(6*cos(t)), Round(6*sin(t))];
  156.   end;
  157. begin
  158.   // this is the point where the bird starts to return, furthest away!
  159.   // we can drop a fish right here!
  160.   while not return do
  161.   begin
  162.     a := TrackBird();
  163.     t.Init(70);
  164.     while not t.IsFinished() do begin
  165.       b := TrackBird($FF, o);
  166.       Sleep(1);
  167.     end;
  168.     o := Dbgoff(a,b);
  169.  
  170.     if (a.DistanceTo(b) <= 5) then break; //Exit(True);
  171.  
  172.     return := False;
  173.     if a.DistanceTo(MainScreen.Center) > b.DistanceTo(MainScreen.Center)+10 then
  174.       return := True;
  175.   end;
  176.  
  177.   Result := WaitUntil(MainScreen.Center.DistanceTo(TrackBird($00FF00, Dbgoff(a,b))) < dist, 10, 2000);
  178.   MouseNext();
  179. end;
  180.  
  181. function WaitLiftoff(): Boolean;
  182. begin
  183.   Result := WaitUntil(
  184.     (TrackBird($00FF00) <> Point(0,0)) and (MainScreen.Center.DistanceTo(TrackBird($00FF00)) > 25),
  185.     10, 2000
  186.   );
  187. end;
  188.  
  189. function IsBirdAway(dist: single): Boolean;
  190. var
  191.   t: TCountDown;
  192.   b: TPoint;
  193. begin
  194.   t.Init(100);
  195.   while not t.IsFinished() do
  196.   begin
  197.     b := TrackBird($00FF00);
  198.     Exit(MainScreen.Center.DistanceTo(b) > dist);
  199.   end;
  200. end;
  201.  
  202. procedure DebugXP(baseXp: Int32);
  203. var
  204.   gained: Int32;
  205. begin
  206.   gained := XPBar.Read() - baseXp;
  207.   WriteLn('---------------------------------------');
  208.   WriteLn('Time running:      ', srl.TimeRunning());
  209.   WriteLn('Gained XP:         ', gained);
  210.   WriteLn('Gained Fishing XP: ', srl.FormatNumber(fishing_xp));
  211.   WriteLn('Gained Hunter  XP: ', srl.FormatNumber(hunter_xp));
  212.   //WriteLn('Gained Cooking XP: ', srl.FormatNumber(cooking_xp));
  213.  
  214.   WriteLn('Fishing XP/H: ', srl.FormatNumber((fishing_xp) / GetTimeRunning() * 1000 * 60 * 60));
  215.   WriteLn('Hunter  XP/H: ', srl.FormatNumber((hunter_xp) / GetTimeRunning() * 1000 * 60 * 60));
  216.   //WriteLn('Cooking XP/H: ', srl.FormatNumber((caught *  3.5) / GetTimeRunning() * 1000 * 60 * 60));
  217.   WriteLn('---------------------------------------');
  218. end;
  219.  
  220.  
  221. procedure Setup();
  222. begin
  223.   Login.AddPlayer(USERNAME, PASSWORD, '', P2P_WORLDS);
  224.  
  225.   Antiban.Skills := [ERSSkill.HUNTER, ERSSkill.FISHING];
  226.   Antiban.MaxZoom := 40;
  227.   Antiban.MinZoom := 20;
  228.  
  229.   //Antiban.AddTask(5  * ONE_MINUTE, @Antiban.HoverPlayer);
  230.   Antiban.AddTask(6  * ONE_MINUTE, @Antiban.RandomPOVTask);
  231.   Antiban.AddTask(8  * ONE_MINUTE, @Antiban.RandomRightClick);
  232.   Antiban.AddTask(8  * ONE_MINUTE, @Antiban.Swivel);
  233.   Antiban.AddTask(9  * ONE_MINUTE, @Antiban.HoverSkills);
  234.   Antiban.AddTask(10 * ONE_MINUTE, @Antiban.LoseFocus);
  235.   Antiban.AddTask(12 * ONE_MINUTE, @Antiban.RandomTab);
  236.  
  237.   Antiban.AddBreak(25  * ONE_MINUTE, 1  * ONE_MINUTE, 0.33, 0.01);
  238.   Antiban.AddBreak(55  * ONE_MINUTE, 2  * ONE_MINUTE, 0.33, 0.02);
  239.   Antiban.AddBreak(80  * ONE_MINUTE, 5  * ONE_MINUTE, 0.33, 0.15);
  240.   Antiban.AddBreak(100 * ONE_MINUTE, 10 * ONE_MINUTE, 0.33, 0.75);
  241.   Antiban.AddBreak(150 * ONE_MINUTE, 30 * ONE_MINUTE, 0.33, 0.85);
  242.   //Antiban.AddSleep('00:00', 8, 1, 1.0);
  243. end;
  244.  
  245. procedure FastDrop1();
  246. var
  247.   slots: TIntegerArray;
  248.   catch: string;
  249. begin
  250.   if Inventory.FindItems(['Bluegill', 'Common tench'], slots) then
  251.   begin
  252.     FastMouse.Move(Inventory.GetSlotBox(slots[0]));
  253.     ChooseOption.Open();
  254.     catch := ChooseOption.GetOptions()[1].Text
  255.     //Inventory.ShiftDrop([slot]);
  256.     //if Inventory.IsSlotSelected(slot) then
  257.     //begin
  258.     //  Inventory.ClickSlot(slot);
  259.     if catch.Pos('Bluegill') > 0 then
  260.     begin
  261.       hunter_xp  += 16.5;
  262.       fishing_xp += 11.5;
  263.     end;
  264.  
  265.     if catch.Pos('Common') > 0 then
  266.     begin
  267.       hunter_xp  += 45;
  268.       fishing_xp += 40;
  269.     end;
  270.  
  271.  
  272.     if not ChooseOption.Select('Drop') then
  273.       ChooseOption.Close();
  274.     //end;
  275.   end;
  276. end;
  277.  
  278. procedure Main();
  279. var
  280.   i: Int32;
  281.   xp: Int32;
  282. begin
  283.   xp := XPBar.Read();
  284.  
  285.   while True do
  286.   begin
  287.     Mouse.Speed := Random(16,21);
  288.     Mouse.CanIdle     := Random() > 0.75;
  289.     FastMouse.CanIdle := Random() > 0.95;
  290.     FastMouse.Speed   := Random(22,30);
  291.  
  292.  
  293.     if Inventory.IsFull() then
  294.     begin
  295.       Inventory.Use('Knife', 'Bluegill');
  296.       WaitUntil(Inventory.CountItem('Bluegill') <= 0, 50, 40000);
  297.  
  298.       Inventory.Use('Knife', 'Common tench' );
  299.       WaitUntil(Inventory.CountItem('Common tench' ) <= 0, 50, 40000);
  300.     end;
  301.  
  302.     // ensure bird has returned
  303.     if IsBirdAway(130) then
  304.     begin
  305.       Wait(30,100);
  306.       continue;
  307.     end;
  308.  
  309.     WriteLn('> Find fish!');
  310.     FishingSites := FindFish();
  311.     if Length(FishingSites) = 0 then continue;
  312.     for i:=0 to High(FishingSites) do
  313.     begin
  314.       current := FishingSites[i].Mean();
  315.       Mouse.Move(current, FishingSites[i].Radius);
  316.       Wait(50,100);
  317.       if MainScreen.IsUpText('Catch') then
  318.       begin
  319.         Mouse.Click(MOUSE_LEFT);
  320.         if MainScreen.DidRedClick() then
  321.         begin
  322.           //Drop1: XX uomment to collect and use knife
  323.           FastMouse.Move(Inventory.GetSlotBox(4).Expand(20));
  324.  
  325.           // not drop 1..
  326.           WriteLn('> Wait for liftoff');
  327.           WaitLiftoff();
  328.  
  329.           //Drop1: XX comment to collect and use knife
  330.           FastDrop1();
  331.  
  332.           MouseNext();
  333.           RSClient.Image.Clear();
  334.         end;
  335.       end;
  336.       break; // only really care about first, because
  337.              // spots only last so long.
  338.     end;
  339.     WriteLn('> Wait for bird to return');
  340.     WaitBird(130);
  341.  
  342.     DoAntiban();
  343.  
  344.     // xp...
  345.     DebugXP(xp);
  346.  
  347.     if Inventory.CountStack(0) < 100 then
  348.       TerminateScript;
  349.   end;
  350. end;
  351.  
  352. begin
  353.   Main();
  354. end;
Add Comment
Please, Sign In to add comment