Simba Code:
{$I SRL/SRL.Simba}
{$i SRL/srl/misc/debug.simba}
var
debug:boolean;
t_username, t_password:string;
procedure t_declarePlayers;
begin
t_username := '';
t_password := '';
debug := false;
end;
Procedure t_SetangleHigh;
begin
Keydown(VK_Up);
wait(RandomRange(2000, 3000));
KeyUp(VK_Up);
end;
procedure t_logout;
begin
Mouse(755, 11, 0, 0, Mouse_left);
wait(400);
Mouse(641, 406, 0, 0, Mouse_left);
wait(500);
end;
function t_loggedin:Boolean;
begin
result := (GetColor(472, 491) = 16777215);
end;
function countText:Integer;
var
textTPA:TPointArray;
begin
FindColorsTolerance(textTPA, 12378347, 251, 145, 514, 362, 1);
result := length(textTPA);
end;
function LoginError:String;
begin
case (countText) of
364: result := 'internet';
2181: result := 'details';
end;
end;
function d_boxup:Boolean;
begin
result := (CountColortolerance(1842209, 270, 172, 493, 250, 5)<200);
end;
Procedure DeleteSpace(amt:integer);
var
i:integer;
begin
for i := 0 to amt do
begin
KeyDown(8);
wait(40);
end;
KeyUp(8);
end;
function noDetails:Boolean;
begin
result := ((t_username = '') or (t_password = ''));
end;
Procedure t_loginPlayer;
var
x, y:Integer;
begin
if t_loggedin then
exit;
if noDetails then
begin
Writeln('You are logged out and did not enter in any login details, terminating script');
TerminateScript;
end;
if (d_boxup) then
begin
case (LoginError) of
'internet':
begin
Writeln('Error connecting to server waiting');
wait(10000);
Mouse(381, 320, 0, 0, Mouse_left);
wait(500);
end;
'details':
begin
Writeln('Invalid username or password');
Mouse(378, 375, 0, 0, Mouse_left);
wait(500)
end;
end;
end;
if (findColorTolerance(x, y, 1315865, 280, 175, 486, 197, 15) and findColorTolerance(x, y, 2334391, 299, 268, 464, 286, 15)) then
begin
Mouse(475, 186, 0, 0, Mouse_Left);
DeleteSpace(20);
TypeSend(t_username);
wait(200);
DeleteSpace(15);
TypeSend(t_password);
waitfunc(@T_loggedin, 400, 5000);
end;
end;
procedure filterTPAsBetween(var atpa: T2DPointArray; len1, len2: integer);
var
h, l, i: integer;
c: T2DPointArray;
begin
h := high(atpa);
for i := 0 to h do
begin
l := length(atpa[i]);
if (not (inRange(l, len1, len2))) then
begin
setLength(c, length(c) + 1);
c[high(c)] := atpa[i];
end;
end;
atpa := c;
end;
function findGrass:Boolean;
var
TPA, TPA2:TPointArray;
ATPA:T2DPointArray;
i, x, y:Integer;
b:Tbox;
begin
if (not t_loggedin) then
exit;
FindColorsSpiralTolerance(256, 166, TPA, 2975603, 5, 5, 515, 337, 5);
if (Length(TPA) > 0) then
begin
SplitTPAWrap(TPA, 30, ATPA);
SortATPAFromFirstpoint(ATPA, Point(256, 166));
if (debug = true) then
DebugATPABounds(ATPA);
for i := 0 to high(ATPA) do
begin
b := GetTPABounds(ATPA[i]);
FindColorstolerance(TPA2, 2325351, b.x1, b.y1, b.x2, b.y2, 14);
if (length(TPA2) > 100) then
begin
MiddleTPAEx(ATPA[i], x, y);
result := true;
Mouse(x, y, 0, 0, Mouse_left);
exit;
end;
end;
end;
end;
function getMap:TBox;
var
TPA:TPointArray;
ATPA:T2DPointArray;
i, x, y:Integer;
b:Tbox;
begin
if (not t_loggedin) then
exit;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.19, 0.61);
FindColorsSpiralTolerance(256, 166, TPA, 2246749, 549, 9, 710, 158, 10);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.02, 0.02);
if (Length(TPA) > 0) then
begin
SplitTPAWrap(TPA, 11, ATPA);
filterTPAsBetween(ATPA, 1, 80);
SortATPAFromFirstpoint(ATPA, Point(256, 166));
if (debug = true) then
DebugATPABounds(ATPA);
for i := 0 to high(ATPA) do
begin
b := GetATPABounds(ATPA);
if (FindColortolerance(x, y, 582627, b.x1, b.y1, b.x2, b.y2, 37)) then
begin
result := b;
exit;
end;
end;
end;
end;
function getPosition:TPoint;
var
b:Tbox;
begin
b := getMap;
result := Point((628 - b.X1), (86 - b.Y1));
end;
procedure walkPoint(pnt:TPoint);
var
b:TBox;
begin
b := getMap;
Mouse(b.x1 + pnt.x, b.y1 + pnt.y, 0, 0, Mouse_left);
end;
procedure Report(s:string);
begin
ClearDebug;
Writeln('==================================');
Writeln('Time running: ' + timerunning);
Writeln('State: ' + s);
Writeln('Position: ' + ToStr(getPosition));
Writeln('==================================');
end;
begin
t_declarePlayers;
MouseSpeed := 15;
repeat
if (not t_loggedin) then
begin
report('Logging in');
t_loginPlayer;
Mouse(545, 26, 0, 0, Mouse_left);
t_SetangleHigh;
end;
if (getPosition.x = 628) then
begin
report('Bad map colors, relogging');
t_logout;
end;
case findGrass of
True:
begin
report('Weeding');
while (ismoving) do
begin
report('Moving');
wait(200);
end;
wait(2000);
end;
False:
begin
report('Waiting for grass spawn');
if (getPosition.x < 30) then
walkPoint(Point(25, 12));
if (getPosition.x > 30) then
walkPoint(Point(30, 33));
while (isMoving) do
wait(200);
wait(3000);
end;
end;
Until(IsKeyDown(113));
end.