Simba Code:
{$I srl-6/srl.simba}
const
USERNAME = '';
EAT_AT = 350;
DRINK_PRAYER_AT = 450;
TELE_AT = 150;
CLIENTNAME = 'Runique';
CLIENTWIDTH = 765;
CLIENTHEIGHT = 525;
foodDTM = 'mWAAAAHicY2FgYChgYmDIB+IkIK4CYnNGBgZtILYEYjMgnteUDVTFCMesQBIZM6JhEAAAEHUEQw==';
prayDTM = 'mQwAAAHicY2ZgYHBlYmDwAmJ7IHZmZGAwA2JzIHa/vAgoywjFCMCIKgoAlPADTA==';
V = '1.00';
var
sharkDTM, prayerDTM, startXP:integer;
rsClient:TSysProc;
function string.contains(s: string): Boolean;
begin
if ((self <> '') and (s <> '')) then
result := (pos(s, self) > 0)
else
result := False;
end;
function getSimpleText(Colors:TIntegerArray;x1, y1, x2, y2:integer;font:string):String;
var
textTPA:TPointArray;
textATPA, textATPAS:T2DPointArray;
i:integer;
textStr:string;
begin
setLength(textATPAS, length(colors));
for i := 0 to high(colors) do
findColors(textATPAS[i], Colors[i], x1, y1, x2, y2);
textTPA := mergeATPA(textATPAS);
textATPA := SplitTPAEx(textTPA, 1, 10);
filtertpasbetween(textatpa, 0, 1);
SortATPAFromFirstPointX(textATPA, Point(0, 0));
result := getTextATPA(textATPA, 3, font);
end;
function getHealth():integer;
begin;
try
result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 724, 72, 750, 90, 'statchars07'));
except
result := 0;
end;
end;
function getPrayer():integer;
begin;
try
result := strToInt(getSimpleText([65280, 65535, 501500, 855541], 739, 112, 764, 130, 'statchars07'));
except
result := 0;
end;
end;
function getXpBarTPA():TPointArray;
begin
findColors(result, 16777215, 424, 101, 519, 118);
end;
function getXpBarText():string;
var
textTPA:TPointArray;
textATPA:T2DPointArray;
begin
textTPA := getXpBarTPA();
textATPA := splittpaex(textTPA, 1, 10);
filtertpasbetween(textatpa, 0, 1);
SortATPAFromFirstPointX(textATPA, Point(0, 0));
result := getTextATPA(textatpa, 3, 'smallchars07');
end;
function xpBarOpen():boolean;
begin
result := getXPBarText().contains('XP:');
end;
function getXpBarTotal():integer;
var
BARstring:string;
begin
BARstring := getXpBarText();
BARstring := replace(BARstring, '''', '', [rfReplaceAll]);
BARstring := replace(BARstring, 'XP:', '', [rfReplaceAll]);
BARstring := replace(BARstring, ' ', '', [rfReplaceAll]);
result := strtoInt(barString);
end;
function activateRsClient(firstTime:boolean):boolean;
var
processes: TSysProcArr;
i: integer;
begin
result := false;
processes := GetProcesses();
if (firstTime) then
writeln('Scanning for ' , CLIENTNAME , 'Client..');
for i := 0 to high(processes) do
if (processes[i].title.contains(CLIENTNAME)) and (processes[i].width = CLIENTWIDTH) and (processes[i].height = CLIENTHEIGHT) then
begin
if (firstTime) then
begin
writeln('Found client');
writeln('Target set to: ' , toStr(processes[i]));
end;
rsClient := processes[i];
setTarget(processes[i]);
ActivateClient();
exit(true);
end;
end;
function getClientName():string;
begin
activateRsClient(false);
result := rsClient.title;
end;
function isLoggedIn():boolean; override;
begin
if (USERNAME = '') then
begin
writeln('Please enter a username at the top of the script');
terminateScript();
end else
result := getClientName().contains(USERNAME);
end;
function getFightingMonster():string;
begin
result := getSimpleText([16777215], 33, 78, 142, 103, 'UpChars07');
end;
function perHour(what:extended):int64;
begin
result := Round(what * (3600.0 / (GetTimeRunning / 1000.0)));
end;
procedure state(s:string);
var
h, p, currentXP:integer;
begin
currentXP := getXPBarTotal();
h := getHealth();
p := getPrayer();
clearDebug();
writeln('======================================Version[',toStr(V),']');
writeln('State: ' , s);
writeln('Health: ' , toStr(h), '[', toStr(h - EAT_AT),']');
writeln('Prayer: ' , toStr(p), '[', toStr(p - DRINK_PRAYER_AT),']');
writeln('XP Gained: ' , toStr(currentXP - startXP), ' Per hour: ' , toStr(perHour(currentXP - startXP)));
writeln('======================================');
end;
procedure checkHealth();
var
i, x, y:integer;
begin
if (getHealth() < EAT_AT) then
begin
if findDTM(sharkDTM, x, y, 562, 257, 728, 507) then
begin
state('Eating');
mouse(Point(x, y), mouse_left);
wait(2000);
end else
if (getHealth() < TELE_AT) then
begin
state('Health too low and no food teleporting home!');
sendKeys('::home', 30, 30);
terminateScript();
end;
end else
if (getPrayer() < DRINK_PRAYER_AT) then
if findDTM(prayerDTM, x, y, 562, 257, 728, 507) then
begin
mouse(Point(x, y), mouse_left);
state('Drinking prayer potion');
wait(2000);
end;
end;
procedure initDTMz();
begin
sharkDTM := DTMFromString(foodDTM);
prayerDTM := DTMFromString(prayDTM);
end;
procedure freememory;
begin
freeDTM(sharkDTM);
freeDTM(prayerDTM);
end;
procedure loop();
begin
if (not isLoggedIn()) then
begin
state('Logged out');
terminateScript();
end else
begin
if (getFightingMonster() <> '') then
begin
state('Fighting ' + getFightingMonster() + 's Checking health and prayer');
wait(2000);
end else
state('Checking health and prayer');
end;
checkHealth();
end;
begin
initDTMz();
addOnTerminate('freeMemory');
activateRsClient(true);
if (not isLoggedIn()) then
begin
writeln('Please login before starting the script');
terminateScript();
end else
begin
if (not XPBarOpen()) then
begin
mouse(Point(535, 110), mouse_left);
wait(1000);
end;
startXP := getXPBarTotal();
end;
repeat
loop();
wait(2000);
Until False;
end.