SRL Archive - OSR Fishing

[SRL][OSRS] Slacky's FlyFisher™


Pythius

2019-03-06 15:21:36


+---| STATS |----------------------------------------
|- Script Runtime : 01h 46m 46s
|- Time Since Break : 10m 10s
|- Dismissed Randoms : 0
|- Loads Done : 19
|- Energy Level : 96.41
+----------------------------------------------------
Successfully executed.

+---| STATS |----------------------------------------
|- Script Runtime : 06h 25m 12s
|- Time Since Break : 12m 21s
|- Dismissed Randoms : 1
|- Loads Done : 56
|- Energy Level : 82.38
+----------------------------------------------------
Successfully executed.
Left it overnight.

Ran the script in increments of 2hrs and half an hour of breaks in the middle and got to 50 Cooking and fishing in no time.

Thanks for the script!

P.S.
Added loads done and dismissing randoms to the script spliced from other scripts

ravensdruid

2019-04-01 08:36:55

Hello there, not too sure I'm using the outdated SRL, but I have changed "Inventory.FindItem(dtm)" to "Inventory.FindDTM(dtm)", just so if anyone is having trouble running the codeline. Cheers!

Pntbllfrk

2019-06-28 09:20:56

Script works great!


+---| STATS |----------------------------------------
|- Script Runtime : 05h 37m 01s
|- Time Since Break : 22m 25s
|- Energy Level : 61.7
+----------------------------------------------------

Emarian

2021-01-18 10:05:30

Script still works wonderfully, even today. @ @slacky, your stuff is amazing. I don't know much, but what I do I learned it from your stuff. You're the best dude

I adjusted this for catching caskets! An easy way to get that cosmic talisman on an ironman. This is an updated version that can be adjusted to anywhere.



program BarbFlyFisher_V004;
{$I SRL/OSR.simba}
{$I RSWalker/Walker.simba}
{.$I SRL/utils/rsclient.simba}
{.$I SRL/utils/rsclient_overrides.simba}
{.$I WindowOverlay/WindowOverlay.simba}
{$H-}

const
LOGIN_NAME = 'yourname';
LOGIN_PASS = 'yourpass';
RS_WORLD = -1; // preferred world, -1 = random world
IS_MEMBER = FALSE; // TRUE or FALSE

type
TFisher = record
StatsDebugTick, failsafe, casketwait, casketcount: Int64;
Antiban: TAntiban;
end;

var
Bot: TFisher;
RSW: TRSWalker;

{$ifdecl TWindowOverlay}
Overlay: TWindowOverlay;
Debug: TMufasaBitmap;
{$endif}
var
CasketDTM := DTMFromString('mlwAAAHicY2dgYChgYmBIA+IqKM4H4iQgjgPiZ0D520D8EIhfA/F7IH4HxE+B+OxTKSDJiBXLMVAEAOyLC04=');
NetDTM := DTMFromString('mggAAAHicY2NgYDjExMBwDoh3AfFOID7GBBF7BJR7DMR3gfglEL8H4ptAHOFrByQZMbAcAzkAAE4fCvc=');
TaliDTM := DTMFromString('mrAAAAHic42BgYJjKxMAwHYjnA/E8IJ4CxD1A3AvlPwaquQXEN4D4ARB/AuJ3QPwQiJ8D8eSODiDJiBPLMVAHAAD6wA2y');
TenKGold := DTMFromString('mggAAAHicY2NgYHBiYmAIAGIfILYGYmMofgqUew7En4D4IwOE/xaIH2yTApKMGFiOgRwAADx1COY=');
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// OVERRIDES AND METHODS FOR FATIGUE

procedure WaitFatigue(t: Double; Exp: Double=0.2);
begin
System.Wait(Trunc(2*t * (1-Power(System.Max(0.0001, Bot.Antiban.EnergyLevel()/100),Exp))));
end;

procedure Wait(min, max:Double; weight:EWaitDir=wdMean); override;
var t: Double;
begin
t := PerformanceTimer();
inherited(min, max, weight);
WaitFatigue(PerformanceTimer()-t);
end;

procedure WaitEx(mean, dev:Double); override;
var t: Double;
begin
t := PerformanceTimer();
inherited(mean, dev);
WaitFatigue(PerformanceTimer()-t);
end;


// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// FISHER

procedure TFisher.DeclarePlayers();
begin
with Players.New()^ do
begin
LoginName := LOGIN_NAME;
Password := LOGIN_PASS;
IsActive := True;
IsMember := IS_MEMBER;
World := RS_WORLD;
end;
Players.SetCurrent(0);
end;

procedure TFisher.DoAntiban();
begin
srl.DismissRandom();
if Self.Antiban.DoAntiban() then
Players.GetCurrent()^.Login(); // if we got logged out, and not logged back in
end;

procedure TFisher.PostAction(AntiBan:Boolean=True);
begin
WaitEx(450,70);
if AntiBan then Self.DoAntiban;
end;


procedure TFisher.ProcessWhileWaiting();
begin
if GetTickCount() - StatsDebugTick > 2000 then
begin
ClearDebug();
ClearDebug();
WriteLn('+---| STATS |----------------------------------------');
WriteLn('|- Script Runtime : ', SRL.MsToTime(GetTimeRunning, Time_Short));
WriteLn('|- Time Since Break : ', SRL.MsToTime(Antiban.TimeSinceBreak(), Time_Short));
//WriteLn('|- Recent Break Len : ', SRL.MsToTime(Antiban.ResidualBreakValue(), Time_Short));
WriteLn('|- Energy Level : ', Round(Antiban.EnergyLevel,2));
WriteLn('|- Caskets Opened: : ', IntToStr(casketcount));
WriteLn('|- # Waiting For : ', IntToStr(casketwait + 1));
WriteLn('+----------------------------------------------------');
Self.StatsDebugTick := GetTickCount();
end;
Self.DoAntiban;
end;


// Find fishingspots by finding the edges of the water, over and over again
// Then do some fancy stuff to remove land->water borders.
// what's left is an accurate TPA of the fishingspot
function TFisher.FindFishingSpot(scanTime: Int32=450): T2DPointArray;
var
i: Int32;
SUM,TPA: TPointArray;
R: TRectangle;
t: TCountDown;
begin
t.Init(scanTime);
while not t.IsFinished do
begin
srl.FindColors(TPA, CTS2(8875103,16,0.2,0.7), Mainscreen.GetBounds);
SUM += TPA.Edges();
end;

SUM.ClearDuplicates();
SUM := ClearTPAFromTPA(Sum, Sum.Edges());
Result := SUM.Cluster(5);
Result.FilterSize(12, __GT__);

{$ifdecl TWindowOverlay}
Debug.Clear();
for i:=0 to High(Result) do
Debug.DrawTPA(Result[i], Random($FFFFFF));
{$endif}
end;

// Basically we find the fishingrod by checking the two tiles infront of
// our character. It can fail if your character covers most of the rod
function TFisher.IsFishing(): Boolean;
var
x, y: Integer;
begin
if findColorTolerance(x, y, 65280, 10, 20, 150, 50, 3) then
Result := True;
end;

// Finds fishing spots, click one, and waits while we are fishing
//
function TFisher.Fish(): Boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
begin
if (not Inventory.Contains(NetDTM)) or
(not Inventory.Contains(TenKGold)) then
TerminateScript('Need big net and at least 10k gold, terminating..');

ATPA := Self.FindFishingSpot();
ATPA.SortByMiddle(mainscreen.GetMiddle);
for TPA in ATPA do
begin
mouse.Move(TPA.Bounds);
if not MainScreen.IsUpText(['Fishing spot']) then
Continue;

if mouse.Click(ctRed) then
begin
Wait(700,1000);
Minimap.WaitPlayerMoving();
Wait(10000,20000);
failsafe := 0;
Self.FindFishingSpot(); //update drawing.
while Self.IsFishing() do
begin
Self.ProcessWhileWaiting();
Chatbox.HandleLevelUp();
WaitEx(70,10);
end;
Wait(100, 15000, wdLeft);
Exit(True);
end else
begin
Wait(700,1200);
Minimap.WaitPlayerMoving();
Wait(700,1200);
Exit(False);
end;
end;
end;


// Clear the inventory by dropping, or banking fish.
//
procedure TFisher.DoInventory();
var
dtms, slots: TIntArray;
dtm: Int32;
t: TCountDown;
Ptrn, arr: TIntArray;
i: Int32;

begin
if Inventory.Count(CasketDTM) > casketwait then
begin
casketwait := Random(4);
casketcount += Inventory.Count(CasketDTM);
repeat
arr := Inventory.FindDTM(CasketDTM);
if(arr = []) then Break;

Inventory.MouseSlot(arr[0]);
if MainScreen.IsUpText('Casket') then
mouse.Click(mouse_Left);
WaitEx(1500,200);
until False;

if Inventory.Contains(TaliDTM) then
TerminateScript('Job complete, found talisman');

end else
begin
dtms := [CasketDTM, NetDTM, TenKGold];
for dtm in dtms do
slots += Inventory.FindDTM(dtm);

for i:=0 to 27 do
if slots.Find(i) <> -1 then
Ptrn += i;

Inventory.DropItemsExcept(ptrn);
Exit;
end;
end;


// Runs the bot
//
procedure TFisher.Run();
begin
MainScreen.SetAngle(True);
casketwait := Random(4);

while srl.IsLoggedIn() do
begin
if failsafe > 5 then
TerminateScript('Failsafe reached, ending script');

if Inventory.IsFull() then
begin
self.DoInventory();
self.PostAction();
end;

if not self.Fish() then
begin
if RSW.GetMyPos.DistanceTo([2390,1608]) > 30 then
RSW.WebWalk(Point(2390, 1608),10,0.8)
else
inc(failsafe);
WaitEx(1000,200);
end;

{$ifdecl TWindowOverlay}
Debug.Clear();
{$endif}
Self.ProcessWhileWaiting();
end;
end;

procedure TFisher.SetupAntiban();
begin
Antiban.Init(SKILL_FISHING);

Antiban.AddTask([@Antiban.LoseFocus, ONE_MINUTE*6, 0.65]);
Antiban.AddTask([@Antiban.VeryShortBreak, ONE_MINUTE*12, 0.65]);

end;

procedure TFisher.Init();
begin
RSW.Init('world.png');
{$ifdecl TWindowOverlay}
Overlay := TWindowOverlay.Create();
Overlay.PaintInterval(100);
Debug := Overlay.ToMufasaBitmap();
{$endif}

self.DeclarePlayers();
self.SetupAntiban();

Inventory.ShiftDrop := True;

Players.LoginCurrent();
end;

procedure TFisher.Free();
begin
RSW.Free();
{$ifdecl TWindowOverlay}
Overlay.Free();
Debug.Free();
{$endif}
FreeDTMs([CasketDTM, NetDTM, TaliDTM, TenKGold]);
end;


begin
{$ifdecl RSClient}
srl.SetupForClient([soDebugAntiban]);
RSClient.SetFocus();
{$else}
srl.Setup([]);
{$endif}

bot.Init();
AddOnTerminate(@bot.Free);
bot.Run();
end.

saml1991

2021-06-01 08:29:58

Hi all,

In my attempts to learn RS Simba code I adapted Slackys script to work with Simba 1400 and SRL-Development. This code got me from 15 cooking and fishing up to 60 about 3 months ago (I haven't used it since but account still going strong! :) )

Adaptations I made in future scripts were to reference the TRSItem ID in const section (such as BRONZE_BAR: TRSITEM = '2349'; https://www.osrsbox.com/tools/item-search/ is a cool tool for this)

The below code uses
https://github.com/ollydev/Simba/releases/tag/autobuild-simba1400
and
https://github.com/ollydev/SRL-Development


program BarbFlyFisher_V003;
{$DEFINE SRL_USE_REMOTEINPUT}
{$I SRL/osr.simba}
{$H-}
{$i diagnostics.simba}

{.$loadlib libwindowoverlay}
{==============================================================================]
| Barbarian FlyFisher ™ Written by slacky, butchered by Sam to work with SRL-Development
|
| Steps to use:
| 1. For longer runs you need to declare user details bellow
| 2. Start the script wherever, just have fishing rod and feathers in your inv
|
| Any issues starting it: Re-target RS, and try again, may help if you log
| in manually before starting it.
|
| Banking might not work very well.
[==============================================================================}
type
TFisherStyle = (FishCookBank, FishCookDrop, FishDrop);

const
LOGIN_NAME = '';
LOGIN_PASS = '';
RS_WORLD = - 1;
// preferred world, -1 = random world
IS_MEMBER = FALSE;
// TRUE or FALSE
STYLE = FishCookDrop;
// FishCookBank or FishCookDrop, FishDrop
type
TFisher = record
StatsDebugTick: Int64;
Antiban: TAntiban;
end;

var
Bot: TFisher;
RSW: TRSWalker;
{$ifdecl TWindowOverlay}
Overlay: TWindowOverlay;
// Debug: TMufasaBitmap;
{$endif}

procedure TFisher.DeclarePlayers();
begin
Login.AddPlayer(LOGIN_NAME, LOGIN_PASS, 'pin');
end;

procedure TFisher.DoAntiban();
begin
Antiban.DismissRandom();
if Self.Antiban.DoAntiban() then
login.LoginPlayer;
// if we got logged out, and not logged back in
end;

procedure TFisher.PostAction(AntiBan: Boolean = True);
begin
WaitEx(850, 900);
if AntiBan then
Self.DoAntiban;
end;

procedure TFisher.ProcessWhileWaiting();
begin
if GetTickCount() - StatsDebugTick > 20000 then
begin
// WriteLn('+---| STATS |----------------------------------------');
// WriteLn('|- Script Runtime : ', SRL.MsToTime(GetTimeRunning, Time_Short));
// WriteLn('|- Time Until Break : ', Antiban.TimeUntilBreak - GetTimeRunning());
//WriteLn('|- Recent Break Len : ', SRL.MsToTime(Antiban.ResidualBreakValue(), Time_Short));
//WriteLn('|- Energy Level : ', Round(Antiban.EnergyLevel,2));
// WriteLn('+----------------------------------------------------');
// Self.StatsDebugTick := GetTickCount();
end;
Self.DoAntiban;
end;
// Find fishingspots by finding the edges of the water, over and over again
// Then do some fancy stuff to remove land->water borders.
// what's left is an accurate TPA of the fishingspot
function TFisher.FindFishingSpot(scanTime: Int32 = 450): T2DPointArray;
var
i: Int32;
SUM, TPA: TPointArray;
R: TRectangle;
t: TCountDown;
begin
t.Init(scanTime);
while not t.IsFinished do
begin
srl.FindColors(TPA, CTS2(8875103, 16, 0.2, 0.7), mainscreen.Bounds);
SUM += TPA.Edges();
end;
SUM.ClearDuplicates();
SUM := ClearTPAFromTPA(Sum, Sum.Edges());
SUM += Sum.Edges();
Result := SUM.Cluster(5);
Result.FilterSize(12, __GT__);
{$ifdecl TWindowOverlay}
Debug.Clear();
for i := 0 to High(Result) do
Debug.DrawTPA(Result[i], Random($FFFFFF));
{$endif}
end;
// Basically we find the fishingrod by checking the two tiles infront of
// our character. It can fail if your character covers most of the rod
function TFisher.WaitFishing(): Boolean;
var
c, currCount: Int32;
t: TCountDown;
begin
c := Inventory.CountItem('Raw Trout') + Inventory.CountItem('Raw Salmon') + Inventory.CountItem('Raw Shrimps');
t.Init(35500);
repeat
inventory.Open;
if Chat.leveledup then
Break;
currCount := Inventory.CountItem('Raw Trout') + Inventory.CountItem('Raw Salmon') + Inventory.CountItem('Raw Shrimps');
if currCount <> c then
begin
c := currCount;
t.Restart(50);
end;
Self.ProcessWhileWaiting();
Wait(70);
until t.IsFinished() or (inventory.IsFull);
Result := True;
end;
// Finds fishing spots, click one, and waits while we are fishing
//
function TFisher.Fish(): Boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
TMP: TIntegerArray;
begin
if (not Inventory.FindItems(['Fly fishing rod', 'Feather', 'Small fishing net'], tmp)) then
TerminateScript('No feathers or fly fishing rod or net');
ATPA := Self.FindFishingSpot();
ATPA.SortByMiddle(mainscreen.GetPlayerBox.Middle);
for TPA in ATPA do
begin
mouse.Move(TPA.Bounds);
if not MainScreen.IsUpText(['Fishing spot']) then
Continue;
mouse.click(mouse_left);
if mainscreen.DidRedClick then
begin
Wait(700, 1000);
Minimap.WaitPlayerMoving();
Wait(1400, 1700);
self.WaitFishing;
end
else
begin
Wait(700, 1200);
Minimap.WaitPlayerMoving();
Wait(700, 1200);
Exit(False);
end;
end;
end;
// Waits while we are cooking.
// Cooking is determined by checking if the number of raw fish in our inventory
// is reducing. It must reduce by at least 1 within 5.5 seconds.
function TFisher.WaitCooking(): Boolean;
var
c, currCount: Int32;
t: TCountDown;
begin
c := Inventory.CountItem('Raw Trout') + Inventory.CountItem('Raw Salmon') + Inventory.CountItem('Raw Shrimps');
t.Init(5500);
repeat
if Chat.leveledup then
Break;
currCount := Inventory.CountItem('Raw Trout') + Inventory.CountItem('Raw Salmon') + Inventory.CountItem('Raw Shrimps');
if currCount <> c then
begin
c := currCount;
t.Restart(50);
end;
Self.ProcessWhileWaiting();
Wait(70);
until t.IsFinished() or (c = 0);
Result := True;
end;
// Do the cooking!
// 1. Walks to a point near the eternal fire.
// 2. Searches for the fire and uses a fish on the fire
// If it fails to find the fire it rotates the screen and tries again.
// 3. Cooks it, and waits til we dont cook any more, or till we level up.
// Repeats #2->#3 until there are no more fish in our inventory.
function TFisher.Cook(): Boolean;
var
idx: Int32;
arr: TIntegerArray;
rect: TRectangle;
ATPA: T2DPointArray;
TPA: TPointArray;
FoundFire: Boolean;
begin
wait(600, 10000);
Inventory.Open();
if (not Inventory.FindItems(['Raw trout', 'Raw Salmon', 'Raw Shrimps', 'Raw anchovies'], arr)) then
Exit;
while ((Inventory.FindItems(['Raw trout', 'Raw Salmon', 'Raw Shrimps', 'Raw anchovies'], arr))) do
begin
arr := [];
Inventory.FindItems(['Raw Trout', 'Raw Salmon', 'Raw Shrimps', 'Raw anchovies'], arr);
//arr wasn't updating above
FoundFire := False;
srl.FindColors(TPA, CTS2(12348, 15), MainScreen.Bounds);
ATPA := TPA.Cluster(5);
ATPA.FilterSize(16, __GT__);
ATPA.SortByMiddle(mainscreen.GetPlayerBox.Middle);
if length(arr) > 0 then
begin
inventory.Open;
waitex(850, 200);
Inventory.Clickslot(arr[0]);
for TPA in ATPA do
begin
rect := TPA.MinAreaRect();
mouse.Move(rect);
Wait(60, 100);
if MainScreen.IsUpText(['Fire']) then
begin
mouse.Click(mouse_Left);
wait(1000, 40);
minimap.IsPlayerMoving();
waitex(1900, 400);
FoundFire := True;
keyboard.presskey(VK_SPACE);
end
else if MainScreen.IsUpText(['options']) then
begin
if not ChooseOption.Select('Fire') then
begin
Wait(60, 200);
Continue;
end
wait(1000, 40);
minimap.IsPlayerMoving();
waitex(1900, 400);
FoundFire := True;
keyboard.presskey(VK_SPACE);
end
else
continue;
if Self.WaitCooking() then
Break;
end;
if (not FoundFire) then
begin
if Distance(Point(4230, 2718), RSW.GetMyPos) > 8 then
RSW.WebWalk(Point(4230, 2718), 2);
Minimap.SetCompassAngle([0, 90, 180, 270][Random(4)] + Random(- 15, 15));
end;
end;
end;
end;
// Clear the inventory by dropping, or banking fish.
//
procedure TFisher.DoInventory();
var
dtms, slots: TintegerArray;
dtm: Int32;
t: TCountDown;
// drop all the fish in our inventory, cooked, raw and burnt.
procedure Drop();
var
Ptrn, orderedptrn, PATTERN: TintegerArray;
index: integer;
begin
Inventory.FindItems(['Raw Trout', 'Raw Salmon', 'Trout', 'Salmon', 'Raw Shrimps', 'Raw anchovies', 'Shrimps', 'Anchovies', 'Burnt Shrimp', 323, 343, 357, 367, 369, 20854, 23873], Ptrn);
for Index in [DROP_PATTERN_SNAKE, DROP_PATTERN_SNAKE_R, DROP_PATTERN_TOPDOWN, DROP_PATTERN_TOPDOWN_R, DROP_PATTERN_REGULAR, DROP_PATTERN_REGULAR_R, DROP_PATTERN_SPIRAL][Random(0, 6)] do
begin
if ptrn.Find(Index) <> - 1 then
Pattern += Index;
end
Inventory.ShiftDrop(Inventory.ErrorPattern(Pattern));
end;

begin
if STYLE in [FishCookDrop, FishDrop] then
Drop()
else
TerminateScript('I havent wewritten banking');
//Deposit();
end;
// Runs the bot
//
procedure TFisher.Run();
begin
// MainScreen.SetupAlignment;
while RSClient.IsLoggedIn() do
begin
if Inventory.IsFull() then
begin
if STYLE <> FishDrop then
begin
self.Cook();
self.PostAction();
end;
self.DoInventory();
self.PostAction();
end;
if not self.Fish() and not inventory.IsFull() then
begin
if RSW.GetMyPos.DistanceTo([4245, 2716]) > 20 then
RSW.WebWalk(Point(4245, 2716), 3)
else
RSW.WebWalk(Point(4223, 2748), 3);
Wait(700, 1200);
end;
{$ifdecl TWindowOverlay}
Debug.Clear();
{$endif}
Self.ProcessWhileWaiting();
end;
end;

procedure TFisher.Antiban_Randomness;
begin
case Random(5) of
0: Antiban.RandomRotate();
1: Antiban.RandomTab();
2: Antiban.HoverSkills();
3: Antiban.SmallRandomMouse();
4: Antiban.AdjustZoom();
end;
end;

procedure TFisher.SetupAntiban();
begin
Antiban.Skills := [ERSSKILL.FISHING];
Antiban.MinZoom := 0;
Antiban.MaxZoom := 75;
Antiban.AddSleep('04:00', 6 * ONE_HOUR);
Antiban.AddBreak(30 * ONE_MINUTE, 5 * ONE_MINUTE, 0.30, 0.10);
Antiban.AddBreak(45 * ONE_MINUTE, 1 * ONE_MINUTE, 0.30, 0.10);
Antiban.AddBreak(60 * ONE_MINUTE, 5 * ONE_MINUTE, 0.30, 0.10);
Antiban.AddBreak(120 * ONE_MINUTE, 20 * ONE_MINUTE, 0.30);
Antiban.AddTask(2 * ONE_MINUTE, @ Antiban.LoseFocus);
Antiban.AddTask(20 * ONE_MINUTE, @ Antiban.LoseFocus);
Antiban.AddTask(20 * ONE_MINUTE, @ Self.Antiban_Randomness);
Antiban.AddTask(40 * ONE_MINUTE, @ Self.Antiban_Randomness);
end;

procedure TFisher.Init();
begin
RSW.Setup('world');
{$ifdecl TWindowOverlay}
Overlay := TWindowOverlay.Create();
Overlay.PaintInterval(100);
Debug := Overlay.ToMufasaBitmap();
{$endif}
self.DeclarePlayers();
self.SetupAntiban();
diagnostics.init();
diagnostics.preventOutOfBounds := false;
//using losefocus antiban
// Inventory.ShiftDrop := True;
login.LoginPlayer;
end;

procedure TFisher.Free();
begin
RSW.Free();
{$ifdecl TWindowOverlay}
Overlay.Free();
Debug.Free();
{$endif}
end;

begin
{$ifdecl RSClient}
// srl.SetupForClient([soDebugAntiban]);
// RSClient.SetFocus();
{$else}
srl.Setup([]);
{$endif}
bot.Init();
AddOnTerminate(@ bot.Free);
bot.Run();
end.