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-simba1400and
https://github.com/ollydev/SRL-Developmentprogram 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.