Renax
2023-01-01 23:46:46
Happy New Year! Below is my first OSRS SIMBA script which is designed to mine iron ore south of Falador and bank it. I put this together using various tutorials around the site and some very dated memories of SCAR from the early 2000s. I just ran it successfully for ~2 hours across ~20 trips but YMMV. There is very little quality-of-life functionality which is what I plan to focus on next. For now, the script is designed to run using the official OSRS app in the "fixed classic" layout. The pick needs to be equipped, the map should be set to the farthest zoom and highest brightness, and you should be facing north. You can start in either the Falador Bank or at the mining site and the script should do the rest. One notable issue is that the script doesn't handle random events. I thought "Antiban.DismissRandom" was meant to identify and dismiss them but I haven't had any luck (but that could just be my implementation).
Thanks all.
EDIT: Just added a progress report below. There was another player also mining while I was there for this and I continually lost out to him so that slowed everything down on a few runs.
Script has been running for: 1 Hours, 43 Minutes and 4 Seconds
You have completed 13 Trips
You have mined 340 iron ore and gained 11900 mining experience.
Thanks all.
EDIT: Just added a progress report below. There was another player also mining while I was there for this and I continually lost out to him so that slowed everything down on a few runs.
Script has been running for: 1 Hours, 43 Minutes and 4 Seconds
You have completed 13 Trips
You have mined 340 iron ore and gained 11900 mining experience.
program FaladorIronMinerandBanker; //Written for latest SIMBA 32 bit using OSRS official client in fixed classic layout
{$DEFINE SRL_USE_REMOTEINPUT}
{$I SRL-D/OSR.simba} //Using the latest development file from github. Downloaded on 12/30/2022.
const
LOGIN_NAME = ''; //Username/Email
LOGIN_PASS = ''; //Password
PPIN = '';
PIXEL_SHIFT = 14; //% shift within the playerbox to be considered "animating"
RS_WORLD = 430; //Desired World (-1 = Random)
IS_MEMBER = false; //True if your player is a Member
BankBoothLight = 5600910; //If script can't find bank booth, update color
BankBoothDark = 4416636; //If script can't find bank booth, update color
RockColor = 2700624; //If script can't find rock, update color
Version = 'Beta v1.0'; //Beta v1.0 as of 1/1/2023
var
Trips,Mined: Int32;
OreColor: TCTS2Color;
BankPath,BankPath2,MiningPath,MiningPath2: TPointArray;
FaladorBank: TPoint;
RSW: TRSWalker;
// Script
procedure declarePlayers(); //Taken from Flight
begin
Login.AddPlayer(LOGIN_NAME, LOGIN_PASS, PPIN, []);
end;
Procedure SetupAB();
begin
Antiban.AddTask(ONE_SECOND*45, @Antiban.RandomMouse);
Antiban.AddTask(ONE_MINUTE*4, @Antiban.RandomRightClick);
Antiban.AddTask(ONE_MINUTE*6, @Antiban.LoseFocus);
Antiban.AddTask(ONE_MINUTE*8, @Antiban.RandomTab);
//Antiban.AddTask(ONE_MINUTE*15, @Antiban.RandomRotate);
Antiban.AddTask(ONE_MINUTE*9, @Antiban.HoverSkills);
Antiban.AddBreak(ONE_MINUTE*18, ONE_SECOND*40, 0.2, 0.0);
end;
Procedure RunAB(); //Taken from Flight
begin
Antiban.DismissRandom();
if Antiban.DoAntiban() then
if (not RSClient.IsLoggedIn) then
Login.LoginPlayer();
end;
Procedure Setup();
begin
RSClient.Image.Clear(Mainscreen.Bounds);
BankPath := [[3721,3445], [3757, 3400], [3797,3355], [3829,3305], [3833,3204], [3833,3159], [3838,3096],[3836,3040],[3836,3053],[3856,3029]];
BankPath2 := [[3716,3448],[3725,3396],[3745,3351],[3806,3335],[3820,3288],[3829,3245],[3836,3192], [3838,3139],[3838,3092],[3833,3040],[3853,3029]];
MiningPath := [[3836,3060],[3838,3112], [3836,3164],[3836,3209],[3829,3256], [3813,3299],[3790,3335],[3764,3380],[3741,3416],[3716,3448],[3692,3488]];
MiningPath2 := [[3845,3065],[3838,3112],[3849,3168],[3820,3200],[3802,3236],[3788,3285],[3773,3328],[3754,3371],[3732,3416],[3709,3465],[3689,3497]];
FaladorBank:= [3860,3029];
RSW.Setup('world');
RSW.AdaptiveWalk:= True;
RSW.FancyMouse:= True;
Trips:= 0;
Mined:= 0;
OreColor:= CTS2(RockColor, 5, 0.2, 0.2);
declarePlayers();
if not RSClient.IsLoggedIn then
begin
Login.LoginPlayer(); //Log player in
MainScreen.setHighestPitch; //Sets the camera angle to the highest point
end;
SetupAB();
Cleardebug();
Writeln('Starting Falador Iron Miner and Banker ', Version);
end;
// Combination of miss mouse + slowing near the target destination borrowed from Flight
procedure TMouse.HumanMove(Point: TPoint);
var
mPt: TPoint;
S: Int32;
Miss: Double;
Range: Int64;
begin
S := Self.Speed;
Range := Trunc(Power(Self.Position().DistanceTo(Point), 0.80)); // how much possible range to miss
Miss := SRL.SkewedRand(0.9, 0.1, 1.5); // Where miss will happen. 1 = destination (P).
mPt.X := Trunc((1-Miss)*Self.Position().X + Miss*Point.X);
mPt.Y := Trunc((1-Miss)*Self.Position().Y + Miss*Point.Y);
mPt.X += SRL.NormalRange(-Range, Range);
mPt.Y += SRL.NormalRange(-Range, Range);
Self.Move(mPt);
Self.Speed := round(S*0.85);
Self.Move(Point);
Self.Speed := S;
end;
Procedure DoMining; //Credit to Slacky for TPA/ATPA tutorial
var
TPA: TPointArray;
ATPA: T2DPointArray;
i: Int32;
Begin
Writeln('Mining for ore.');
MainScreen.setHighestPitch;
While not Inventory.IsFull() do
begin
RunAB();
if SRL.FindColors(TPA, OreColor, MainScreen.Bounds) then
begin
ATPA:= TPA.Cluster(5);
ATPA.FilterSize(15,90);
ATPA.SortbyIndex(MainScreen.Center);
For i:= 0 to high(ATPA) do
begin
Mouse.HumanMove(ATPA[i].Mean());
Wait(200);
if MainScreen.IsUpText('Mine', 200) then
Mouse.Click(MOUSE_LEFT);
if MainScreen.DidRedClick() then
Break;
end;
Minimap.Waitflag(0);
end;
While SRL.GetPixelShift(MainScreen.GetPlayerBox,500) >= PIXEL_SHIFT do //Pixel shift concept from Flight
begin
Wait(Random(300,600));
RunAB();
end;
end;
Writeln('Finished mining.');
end;
Procedure WalktoBank();
var
myPos: TPoint;
TimeOut: Int32;
begin
Writeln('Beginning walk to bank.');
RunAB();
if Random(0,10)>5 then
begin
RSW.WalkPath(BankPath, Random(5,8));
Minimap.Waitflag(0);
end else
begin
RSW.WalkPath(BankPath2, Random(5,8));
Minimap.Waitflag(0);
end;
myPos:= RSW.GetMyPos();
If myPos.DistanceTo(FaladorBank) >= 35 then
begin
TimeOut:= 0;
While myPos.DistanceTo(FaladorBank) >= 30 do
begin
RSW.WalkBlind(FaladorBank,0);
TimeOut:= TimeOut + 1;
myPos:= RSW.GetMyPos();
if TimeOut > 10 then
Break;
end;
if TimeOut > 10 then
begin
Logout.ClickLogout();
TerminateScript('Failed to reach bank. Terminating script.');
end;
end;
end;
Procedure WalktoMine();
var
myPos: TPoint;
begin
Writeln('Beginning walk to mine.');
RunAB();
myPos:= RSW.GetMyPos();
If myPos.DistanceTo(FaladorBank) <= 30 then
begin
if Random(0,10)>5 then
begin
RSW.WalkPath(MiningPath, Random(1,3));
Minimap.Waitflag(0);
end else
begin
RSW.WalkPath(MiningPath, Random(1,3));
Minimap.Waitflag(0);
end;
end;
end;
function OpenBankBackup(): Boolean; // Original code borrowed from Flight's fisher
var
i,c: Int32;
ATPA: T2DPointArray;
Finder: TRSObjectFinder;
begin
Finder.ColorClusters += [ // Set object bank booth parameters
CTS2(BankBoothLight, 4, 1.11, 1.12), // Light Brown
CTS2(BankBoothDark, 2, 0.15, 1.05), // Dark Brown
4];
Finder.Grow:= 2;
Finder.ClusterDistance:= 3;
c:= 0; // Set counter to 0
Repeat
if not Bank.IsOpen then
begin
c:= c + 1;
ATPA := MainScreen.FindObject(Finder);
if (ATPA.Len > 0) then
begin
ATPA.SortByMiddle(Mainscreen.Center);
for i:= 0 to high(ATPA) do
begin
Mouse.HumanMove(ATPA[i].Mean());
Wait(100);
if MainScreen.IsUpText(['Bank Bank', 'Bank booth', 'Bank chest', 'eposit']) then
begin
Mouse.Click(MOUSE_LEFT);
Minimap.Waitflag(0);
Wait(500);
end;
if Bank.IsOpen() then
begin
Result:= True;
Exit(True);
end;
end;
end;
end;
until c > 10;
if Bank.IsOpen then
begin
Result:= True;
Exit(True);
end;
if c > 10 then
begin
Result:= False;
Exit(False);
end;
end;
Procedure DoBanking();
var
BankLocation: T2DPointArray;
i,c: int32;
begin
Writeln('Opening bank.');
RunAB();
MainScreen.setHighestPitch;
Mined:= Mined + Inventory.Count();
Trips:= Trips + 1;
c:= 0;
While Inventory.IsFull do
begin
BankLocation:= Bank._FindFaladorEast();
BankLocation.SortByMiddle(Mainscreen.Center);
For i := 0 to high(BankLocation) do
begin
Mouse.HumanMove(BankLocation[i].Mean());
Wait(100);
if MainScreen.IsUpText('Bank ', 200) then
begin
Mouse.Click(MOUSE_LEFT);
Minimap.Waitflag(0);
Wait(500);
end;
if Bank.IsOpen() then
Break;
end;
if Bank.IsOpen() then
begin
Bank.DepositAll();
if random(0,10) >= 5 then
Bank.ClickCloseButton();
Break;
end;
c:= c + 1;
if c > 5 then
begin
if OpenBankBackup() then
begin
Bank.DepositAll();
if random(0,10) >= 5 then
Bank.ClickCloseButton();
Break;
end else
Logout.ClickLogout();
TerminateScript('Failed to open bank. Terminating script.');
end;
end;
end;
Procedure Reporting();
begin
ClearDebug();
Writeln('Script has been running for: ', SRL.TimeRunning(Time_Formal));
Writeln('You have completed ',IntToStr(Trips),' Trips');
Writeln('You have mined ',IntToStr(Mined),' iron ore and gained ',IntToStr(35*Mined),' mining experience.');
Writeln(' ');
end;
begin
Setup();
DoBanking();
WalktoMine();
Repeat
DoMining();
WalktoBank();
DoBanking();
Reporting();
WalktoMine();
until not RSClient.isloggedin();
end.