This was a valuable learning exercise for me, to try and rework this script to work with latest SRL-Dev and simba from olly's github.
I've noticed a ton of things don't quite work for me:
1) Smart doesn't work at all
2) Include log in function doesn't hit the "Login" button after typing in information
3) Include doesn't change camera angle
4) RSWalker is included in SRL-Dev so no need for separate dependency
5) Open bank at tile wasn't working for me, maybe I was using tile coords instead of screen coords, but don't know how to tranlate that without reflection method
6) Lots of little syntax changes between the old and new include, most of the antiban section for example.
7) The ACA bit of the tutorial with the color picker tool still works perfectly well
I was able to piece together the components and this is what I came up with – it may be sloppy but at least I got it to run again as it was intended. Sharing it here for anyone who may follow the main link path for getting introduced to this community:
program cabbage;
{$define SMART}
{$I SRL/OSR.simba}
//Declare our Constants
const
LOGIN_NAME = ''; //Username/Email
LOGIN_PASS = ''; //Password
//Declare our variables
var
Walk: TRSWalker; //Used for RSWalker (to walk paths)
pathToPatch: TPointArray;
{*******************************************************************************
Name: declarePlayers();
Function: Sets the proper variables using the constants above to allow
a successful login.
*******************************************************************************}
procedure declarePlayers();
begin
Login.AddPlayer(LOGIN_NAME, LOGIN_PASS);
end;
{*******************************************************************************
Name: setupAntiban();
Function: Sets up the built-in antiban included with the SRL include.
NOTE: Please feel free to customize this and make it unique to you.
*******************************************************************************}
procedure setupAntiban();
begin
Antiban.AddTask(ONE_MINUTE*5, @Antiban.LoseFocus);
Antiban.AddTask(ONE_MINUTE*10, @Antiban.HoverSkills);
Antiban.AddTask(ONE_MINUTE*10, @Antiban.RandomTab);
//Antiban.AddTask(ONE_MINUTE*25, @Antiban.VeryShortBreak);
//Antiban.AddTask(ONE_MINUTE*25, @Antiban.DoMiscStuff);
//Antiban.AddTask(ONE_MINUTE*45, @Antiban.RandomCompass);
Antiban.AddBreak(35*ONE_MINUTE,05*ONE_MINUTE,0.05, 0.03);
Antiban.AddBreak(02*ONE_HOUR,05*ONE_MINUTE,0.20, 0.85);
Antiban.AddBreak(05*ONE_HOUR,05*ONE_MINUTE,0.85, 0.85);
Antiban.AddBreak(16*ONE_HOUR,05*ONE_MINUTE,0.99, 0.99);
end;
{*******************************************************************************
Name: setUp();
Function: Sets up the script by initializing everything and logging player in.
*******************************************************************************}
function setUp(): boolean;
begin
SRL.Setup(); //Setup SRL to allow us to access it's functions.
Walk.Setup('world'); //Setup RSWalker by initializing the map we want to use
declarePlayers(); //Declare the player we are using
pathToPatch := [[4177, 3463], [4159,3449], [4135, 3436], [4128, 3402], [4121, 3364], [4089, 3335], [4049, 3335], [4024, 3310], [4025, 3288], [4025, 3288]];
setupAntiban(); //Setup our antiban
if not Login.LoginPlayer() then
TerminateScript('Failed to login!');
MainScreen.SetHighestPitch(); //this doesn't actually do anything atm
Result := True;
end;
{*******************************************************************************
Name: myAntiban();
Function: Executes the antiban and checks for random events.
*******************************************************************************}
Procedure myAntiban;
begin
if (not RSClient.IsLoggedIn) then
Exit;
Antiban.DismissRandom(); //Dismiss random events if any are found
Antiban.DoAntiban(); //Do the antiban
end;
{*******************************************************************************
Name: waitLoop();
Function: Waits until we have collected our cabbage
*******************************************************************************}
procedure waitLoop();
var
InvCount: Integer;
T: TStopwatch;
begin
if (not RSClient.IsLoggedIn) then
Exit;
InvCount := Inventory.Count(); //Gets the count in our inventory
T.Start; //Start our timer
repeat
myAntiban();
wait(randomRange(75, 250)); //Wait a random amount of time
until((Inventory.Count() > InvCount) or (T.ElapsedTime > 7000)); //Stop repeating once inv count changes or we time out
end;
{*******************************************************************************
Name: findCabbages();
Function: Locates cabbage in the field. Will print on screen if using SMART.
*******************************************************************************}
procedure findCabbages();
var
TPA, Cabbage: TPointArray;
ATPA: T2DPointArray;
CabbageColor: TCTS2Color;
begin
if (not RSClient.IsLoggedIn) then //If not logged in, then terminate script
TerminateScript;
CabbageColor := CTS2(2727797, 20, 0.05, 1.15);
if (SRL.FindColors(TPA, CabbageColor, MainScreen.Bounds) > 0) then //If we find colours at all then...
begin
ATPA := TPA.Cluster(2); //Group them within a max pixel distance of 2
ATPA.FilterSize(100, 500); //Remove and ATPA of size < 100, or > 500.
ATPA.SortByIndex(MainScreen.Center); //Sort by closest to Middle of the screen
for Cabbage in ATPA do //For every possible cabbage in our ATPA
begin
Mouse.Move(Cabbage[Random(Length(Cabbage))]); //Move the mouse to the cabbage
if MainScreen.IsUpText('Cabbage') then //If the uptext is 'Cabbage', try to click it
begin
Mouse.Click(MOUSE_LEFT);
if (not MainScreen.DidRedClick) then Exit;
waitLoop(); //Call to our waitLoop because we want to wait while picking.
Break;
end;
end;
end;
end;
function manualBank(): boolean;
var
TPA, BankBooth: TPointArray;
ATPA: T2DPointArray;
BankColor: TCTS2Color;
begin
if (not RSClient.IsLoggedIn) then //If not logged in, then terminate script
TerminateScript;
BankColor := CTS2(5527903, 5, 0.71, 0.53);
writeln("Looking for bank via ATPA");
if (SRL.FindColors(TPA, BankColor, MainScreen.Bounds) > 0) then //If we find colours at all then...
begin
writeln("found some potential banks");
ATPA := TPA.Cluster(2); //Group them within a max pixel distance of 2
ATPA.SortByIndex(MainScreen.Center); //Sort by closest to Middle of the screen
for BankBooth in ATPA do //For every possible BankBooth in our ATPA
begin
writeln(BankBooth);
Mouse.Move(BankBooth[Random(Length(BankBooth))]); //Move the mouse to the BankBooth
if MainScreen.IsUpText('Bank booth') then //If the uptext is 'BankBooth', try to click it
begin
Mouse.Click(MOUSE_LEFT);
Result:= True;
Exit;
end;
end;
end;
end;
begin //Main
if setUp then
writeln('We are set up and ready to go!');
repeat
if not Inventory.IsFull then
begin
Writeln("Walking to cabbage patch!");
Walk.WalkPath(pathToPatch);
end
while (not Inventory.IsFull) do
begin
findCabbages(); //Collect Cabbages until inv is full
end
Writeln("Walking to bank!");
Walk.WebWalk(WorldWeb.LOCATION_DRYNOR_BANK); //Walk to Bank
while (not manualBank) do //open bank
begin
Writeln("Trying to open bank");
wait(randomRange(75, 250));
end;
while Bank.IsOpen(5000) do
begin
writeln("trying to deposit");
wait(randomRange(75, 250));
Bank.DepositAll();
wait(randomRange(75, 250));
Bank.Close();
end
until(false);
end.