Simba Code:
program Wheat_Farm_V1;
{$H-}
{$define SMART}
{$I SRL/OSR.simba}
{$I RSWalker/Walker.simba}
var
Walker : TRSWalker;
Supplies_Path,
Bank_Path : TPointArray;
procedure WalkTo(Path: TPointArray);
begin
Walker.WalkPath(Path);
end;
const
LOGIN_NAME = ''; //Username/Email
LOGIN_PASS = ''; //Password
RS_WORLD = -1; //Desired World (-1 = Random)
IS_MEMBER = false; //True if your player is a Member
procedure 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;
type
TMSObject = record
WorldLoc : TPointArray; //locations on the world map
Color : TCTS2Color; //must have color
MinCount : Int32; //size of TPA
SplitDist : Int32;
end;
function TMSObject.Find(DoSort: Boolean=False; Expand:Int32=0): TRectArray;
var
loc, me : TPoint;
rect : TRectangle;
locations, TPA : TPointArray;
ATPA : T2DPointArray;
begin
me := Walker.GetMyPos();
locations := Copy(Self.WorldLoc);
if DoSort then Locations.Sorted(me);
for loc in Locations do
begin
rect := Walker.GetTileMSEx(me, loc, 1).Expand(Expand);
if MainScreen.GetBounds.Contains(rect.Bounds) then
begin
if (srl.FindColors(TPA, Color, rect.Bounds) < Self.MinCount) then
Continue;
if (Self.SplitDist > 0) then
begin
TPA := rect.Filter(TPA);
ATPA := TPA.Cluster(Self.SplitDist);
ATPA.SortByMiddle(rect.Mean);
Result += ATPA[0].MinAreaRect;
end else
Result += rect.Expand(-Expand);
end;
end;
end;
procedure waitLoop();
var
InvCount: Integer;
T: TTimeMarker;
begin
if not SRL.isLoggedIn() then
Exit;
InvCount := Inventory.Count(); //Gets the count in our inventory
T.Start; //Start our timer
repeat
wait(randomRange(75, 250)); //Wait a random amount of time
until((Inventory.Count() > InvCount) or (T.GetTime > 7000)); //Stop repeating once inv count changes or we time out
end;
procedure Fill_inventory_with_supplies();
var
TPA, Wheat: TPointArray;
ATPA: T2DPointArray;
begin
if not SRL.isLoggedIn() then //If not logged in, then terminate script
TerminateScript;
if (SRL.FindColors(TPA, CTS2(6798010, 7, 0.04, 1.52), MainScreen.GetBounds) > 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.GetMiddle); //Sort by closest to Middle of the screen
{$IFDEF SMART} //If we are using SMART, then...
Smart.Image.DrawATPA(ATPA); //Draws the ATPA's on the screen.
//smart.Image.DebugATPA(ATPA) works as well
{$ENDIF} //End SMART IF
for Wheat in ATPA do //For every possible Wheat in our ATPA
begin
Mouse.Move(Wheat[Random(Length(Wheat))]); //Move the mouse to the Wheat
if MainScreen.IsUpText('Wheat') then //If the uptext is 'Wheat', try to click it
begin
if Mouse.Click(ctRed) then //Clicks the mouse and looks to see if red 'x' appeard when cicked
begin
waitLoop(); //Call to our waitLoop because we want to wait while picking.
smart.Image.Clear();
Repeat
while (not Inventory.IsFull) do // Keeps filling the Inventory until its full
Fill_inventory_with_supplies();
until(true);
Break; //If found red 'x', then break because we clicked it
WriteLn('its me Mario');
end;
end;
end;
end;
{$IFDEF SMART}
Smart.Image.Clear; //Clears the ATPA's from screen
{$ENDIF}
end;
function Deposite_Supplies(): boolean;
begin
BankScreen.Open(blVarrockWest); // Open bank using SRL's built in banker function
if BankScreen.IsOpen(5000) then // If bank screen is open sometime within the 5 sec wait
begin
wait(randomRange(150, 500)); // Have a realistic wait time before we actually do anything
BankScreen.DepositAll(); // Deposit all Wheat
wait(randomRange(2500, 2777)); // Have a realistic wait time before we actually do anything
Result := True; // We want to return true when the function finishes, so we set Result to True
end;
end;
function Open_Gate(): boolean;
var
i : Int32;
obj : TMSObject;
rectangles: array of TRectangle;
tpa : TPointArray;
atpa : T2DPointArray;
Pnts : TPointArray;
Pnt : Tpoint;
begin
while True do
begin // Gate Location open and closed
// Tile 1 Tile 2 Tile 3 Tile 4 Tile 5 Tile 6 color of Gate, min points, splitDist.
obj := [[[4373, 2619],[4373, 2616],[4378, 2613],[4373, 2619],[4373, 2616],[4378, 2613]], CTS2(4813184, 6), 20, 3];
rectangles := obj.Find(True, 50);
smart.Image.Clear();
for i:=0 to High(rectangles) do
smart.Image.DrawTPA(rectangles[i].ToTPA.Connect, $00FFFF);
begin
wait(RandomRange(1320, 1460));
mouse.Move(rectangles[0].Bounds);
wait(RandomRange(1320, 1460));
if MainScreen.IsUpText(['Op', 'en']) then
mouse.Click(mouse_Left);
wait(RandomRange(1320, 1460));
smart.Image.Clear();
wait(RandomRange(1320, 1460));
Fill_inventory_with_supplies();
end;
smart.Image.Clear();
end;
end;
function Walk_to_supplies(): Boolean;
begin
walkTo(Supplies_Path); // Walks to the Supplies
Open_Gate(); // Opens the Gate
Result := True;
end;
function Walk_to_Bank(): Boolean;
begin
walkTo(Bank_Path); // Walks to the Bank
wait(randomRange(1700, 2460)); // Have a realistic wait time before we actually do anything
Deposite_Supplies(); // Banks the Wheat
Result := True;
end;
function Check_Inventory(): Boolean;
begin
Result := Gametabs.Open(tabInventory); // Opens the Inventory Tab
while (not Inventory.IsFull) do // If the Inventory is not full then....
begin
Walk_to_supplies();
end else
Walk_to_Bank();
end;
function setUp(): boolean
begin
{$IFDEF SMART} // If we are using SMART, then...
Smart.EnableDrawing := True; // let us draw on SMART
{$ENDIF} // end SMART IF
SRL.Setup([]); // Setup SRL to allow us to acces it's functions.
declarePlayers(); // Declare the player we are using
Walker.Init('World.png'); // Setup RSWalker by initializing the map we want to use.
// The path that we plan to walk (Supplies_path = Grain field)
Supplies_path := [[4538, 2690], [4540, 2658], [4521, 2630], [4500, 2620], [4460, 2611], [4427, 2610], [4402, 2619], [4375, 2623]];
// The path that we plan to walk (Bank_path = Varrock West Bank)
Bank_path := [[4373, 2624], [4430, 2625], [4471, 2638], [4509, 2643], [4537, 2688]];
AddOnTerminate(@Walker.Free); // automatic free once script shuts down
Walker.skipClose := 40; // how close to the target point before we try to click the next point.
if (not SRL.isLoggedIn) then // If not logged in then..
begin
Players.LoginCurrent(); // Log player in
MainScreen.setAngle(True); // Sets the camera angle to the highest point
wait(RandomRange(2010, 2530));
Minimap.SetCompassAngle(RandomRange(150, 0), False);
end;
Result := True;
end;
begin //Main
if setUp then //Calls the setup of the script
writeln('We are set up and ready to go!');
repeat
Check_Inventory();
until(false);
end.