SRL Archive - SRL Archives

Using Timing.scar in SRL


Naike

2009-07-01 18:53:14

Added use of the new functions in Timing.scar in SRL.

I noticed it got a bit messy, my excuses again.. It's hard showing everything without making a big mess.
Simply added WaitOption/WaitUpText to functions/procedures inside SRL.. Skipped those that don't need/would mess up at.

Note: Couldn't attach all the files, to many…

Bank.scar

WithdrawItemEx

New:

{*******************************************************************************
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;
By: Nava2
Description: Withdraws an item from the bank by using "Ident" with tol[0]
as color tolerance, tol[1] as contour tolerance in case of bmp
masks, or the count of colors for TPA item finding.
Valid IdentTypes are all in FindItem.
Index: The Bank Index where the item is found, must be a variable.
Speeds up future withdraws.
Amount: Amount to withdraw from bank.
UpText: The UpText which the function checks for.
*******************************************************************************}
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): Boolean;
var
x, y: integer;
BPoint: TPoint;
BankBox: TBox;
Found: Boolean;
t: TPointArray;
label
Start;
begin
Result := False;
if not BankScreen then Exit;
FixBank;

if (Index = 0) then
begin
Start:
for Index := 1 to 50 do
begin
if FindItemEx(x, y, IdentType, Ident, BankIndexToMSBox(Index), Tol) then
begin
MMouse(x, y, 4, 4);
if WaitUpText(UpText, 200+Random(100)) then
begin
Writeln('Found Item at Bank Slot ' + IntToStr(Index) + '.');
Found := True;
Break;
end else
Writeln('Found Incorrect Item, Moving to new Bank Spot.');
end;
end;
end else
begin
BankBox := BankIndexToMSBox(Index);
FindColors(t, 65536, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
BankBox := GetTPABounds(t);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, 3);
Wait(120 + Random(50));
if IsUpText(UpText) then
Found := true
else
begin
Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
GoTo Start;
end;
end;
Wait(RandomRange(200, 350));
if Found then
begin
BPoint := BankIndexToBankPoint(Index);
//Writeln(IntToStr(BPoint.x) + ', ' + IntToStr(BPoint.y));
Withdraw(BPoint.x, BPoint.y, Amount);
Result := True;
end else
begin
Index := 0;
SRL_Warn('WithdrawItem', 'Could not Find ' + IdentType + ' in Bank. [Uptext: ' + UpText + ']', Warn_AllVersions);
end;
end;
end;

Old:

{*******************************************************************************
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;
By: Nava2
Description: Withdraws an item from the bank by using "Ident" with tol[0]
as color tolerance, tol[1] as contour tolerance in case of bmp
masks, or the count of colors for TPA item finding.
Valid IdentTypes are all in FindItem.
Index: The Bank Index where the item is found, must be a variable.
Speeds up future withdraws.
Amount: Amount to withdraw from bank.
UpText: The UpText which the function checks for.
*******************************************************************************}
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): Boolean;
var
x, y: integer;
BPoint: TPoint;
BankBox: TBox;
Found: Boolean;
t: TPointArray;
label
Start;
begin
Result := False;
if not BankScreen then Exit;
FixBank;

if (Index = 0) then
begin
Start:
for Index := 1 to 50 do
begin
if FindItemEx(x, y, IdentType, Ident, BankIndexToMSBox(Index), Tol) then
begin
MMouse(x, y, 4, 4);
Wait(120 + Random(50));
if IsUpText(UpText) then
begin
Writeln('Found Item at Bank Slot ' + IntToStr(Index) + '.');
Found := True;
Break;
end else
Writeln('Found Incorrect Item, Moving to new Bank Spot.');
end;
end;
end else
begin
BankBox := BankIndexToMSBox(Index);
FindColors(t, 65536, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
BankBox := GetTPABounds(t);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, 3);
Wait(120 + Random(50));
if IsUpText(UpText) then
Found := true
else
begin
Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
GoTo Start;
end;
end;
Wait(RandomRange(200, 350));
if Found then
begin
BPoint := BankIndexToBankPoint(Index);
//Writeln(IntToStr(BPoint.x) + ', ' + IntToStr(BPoint.y));
Withdraw(BPoint.x, BPoint.y, Amount);
Result := True;
end else
begin
Index := 0;
SRL_Warn('WithdrawItem', 'Could not Find ' + IdentType + ' in Bank. [Uptext: ' + UpText + ']', Warn_AllVersions);
end;
end;


OpenBankQuiet

New:

{*******************************************************************************
function OpenBankQuiet(WhichBank: string): Boolean;
By: WT-Fakawi and modified by Ron
Description: Opens any given bank in the free world using
FindDeformedBitmapToleranceIn. Avoids strange mouse movements. Will cause
significant lag (approx. 1 second), but finds the bank with one click.

Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'eb' (Edgeville Bank)
'akb' (Al-Kharid Bank)
*******************************************************************************}

function OpenBankQuiet(WhichBank: string): Boolean;
var
TheCounter, dx, dy, tol, Mark2, Mark3: Integer;
acc, accthres: Extended;
begin
case WhichBank of
'feb', 'fwb': TheCounter := BitmapFromString(1, 10, '6C583296897A948779948779736' +
'C63A59E968C7F6F9686749B8A7685663E');
// varrock west
'vwb': TheCounter:= BitmapFromString(10, 1, 'A0997F504A49504A49504A495E4' +
'F215E4F215E4F215E4F212C250EA0997F');
// varrock east
'veb': TheCounter := BitmapFromString(1, 10, '5E4D1589826D88806D88806D867' +
'F6C9996907C7664847D648C836891876B');
// draynor and this works too for alkharid
'akb', 'db', 'eb': TheCounter:= BitmapFromString(12, 1, '584209735C29735C29735C29605' +
'85558504D60504D58504D58504D58504D58504D605855');
else
begin
srl_Warn('OpenBankQuiet', 'Unknown bank: ' + WhichBank, warn_AllVersions);
Exit;
end;
end;

MarkTime(Mark3);
tol := 1;
accthres := 0.6;
repeat
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
if WaitUptextMulti(['ank', 'Bo', 'ot'], 200) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, False);
if WaitOption('uickly', 200) then
begin
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
end;

FindDeformedBitmapToleranceIn(TheCounter, dx, dy, MSX1 + 50, MSY1 + 50, MSX2
- 50, MSY2 - 50, tol, 4, True, acc);
if (acc >= accthres) then
begin
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
MMouse(dx, dy, 0, 0);
if WaitUptextMulti(['ank', 'Bo', 'ot'], 200) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, False);
if WaitOption('uickly', 200) then
begin
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
end;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
end;
Wait(100);
tol := tol + 4;
if tol >= 20 then
begin
tol := 1;
accthres := accthres - 0.1;
if accthres < 0.2 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
end;
until TimeFromMark(Mark3) > 60000;
FreeBitmap(TheCounter);
end;

Old:

{*******************************************************************************
function OpenBankQuiet(WhichBank: string): Boolean;
By: WT-Fakawi and modified by Ron
Description: Opens any given bank in the free world using
FindDeformedBitmapToleranceIn. Avoids strange mouse movements. Will cause
significant lag (approx. 1 second), but finds the bank with one click.

Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'eb' (Edgeville Bank)
'akb' (Al-Kharid Bank)
*******************************************************************************}

function OpenBankQuiet(WhichBank: string): Boolean;
var
TheCounter, dx, dy, tol, Mark2, Mark3: Integer;
acc, accthres: Extended;
begin
case WhichBank of
'feb', 'fwb': TheCounter := BitmapFromString(1, 10, '6C583296897A948779948779736' +
'C63A59E968C7F6F9686749B8A7685663E');
// varrock west
'vwb': TheCounter:= BitmapFromString(10, 1, 'A0997F504A49504A49504A495E4' +
'F215E4F215E4F215E4F212C250EA0997F');
// varrock east
'veb': TheCounter := BitmapFromString(1, 10, '5E4D1589826D88806D88806D867' +
'F6C9996907C7664847D648C836891876B');
// draynor and this works too for alkharid
'akb', 'db', 'eb': TheCounter:= BitmapFromString(12, 1, '584209735C29735C29735C29605' +
'85558504D60504D58504D58504D58504D58504D605855');
else
begin
srl_Warn('OpenBankQuiet', 'Unknown bank: ' + WhichBank, warn_AllVersions);
Exit;
end;
end;

MarkTime(Mark3);
tol := 1;
accthres := 0.6;
repeat
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
if IsUpTextMultiCustom(['ank', 'Bo', 'ot']) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, False);
if ChooseOption('uickly') then
begin
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
end;

FindDeformedBitmapToleranceIn(TheCounter, dx, dy, MSX1 + 50, MSY1 + 50, MSX2
- 50, MSY2 - 50, tol, 4, True, acc);
if (acc >= accthres) then
begin
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
MMouse(dx, dy, 0, 0);
if IsUpTextMultiCustom(['ank', 'Bo', 'ot']) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, False);
if ChooseOption('uickly') then
begin
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
end;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
end;
Wait(100);
tol := tol + 4;
if tol >= 20 then
begin
tol := 1;
accthres := accthres - 0.1;
if accthres < 0.2 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
end;
until TimeFromMark(Mark3) > 60000;
FreeBitmap(TheCounter);
end;


OpenBankGlass

New:

{*******************************************************************************
function OpenBankGlass(WhichBank: String; ChangeCompass, ChangeAngle: Boolean): Boolean;
By: Wizzup? and modified by Ron updated to P2p banks by N1ke!
Description: Opens the bank.
Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'akb' (Al-Kharid Bank)
'ctb' (Catherby bank)
'clt' (Camelot bank)
'nab' (North Ardougne bank)
'sab' (South Ardougne bank)
'ynb' (Yanille bank)
'ngb' (North gnome bank)
'sgb' (South gnome bank)
'wgb' (Warrior guild bank)
'fgb' (Fishing guild bank)
*******************************************************************************}
function OpenBankGlass(WhichBank: string; ChangeCompass, ChangeAngle: Boolean): Boolean;
var
OBC: TPoint;
c, Speed, Col: Integer;
begin
Speed := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if ChangeAngle then SetAngle(True);
if ChangeCompass then
begin
c := Random(2);
case WhichBank of
'feb', 'fwb', 'veb', 'ctb', 'clt', 'nab': if c = 0 then MakeCompass('N') else MakeCompass('S');
'akb', 'db', 'eb', 'vwb', 'sab', 'ynb', 'sgb', 'wgb', 'fgb': if c = 0 then MakeCompass('E') else MakeCompass('W');
'ngb': if c = 0 then MakeCompass(45) else MakeCompass(225);
end;
end;
Col := 10070458;
If (WhichBank = 'nab') or (WhichBank = 'sab')then
Col := 8095371;
if FindColorSpiralTolerance(OBC.x, OBC.y, Col, MSX1, MSY1, MSX2, MSY2, 10) then
begin
MMouse(OBC.x, OBC.y, 4, 4);
if WaitUptextMulti(['nk', 'bo', 'ot'], 200) then
begin
Mouse(OBC.x, OBC.y, 0, 0, False);
WaitOption('uickly', 200);
FFlag(0);
Wait(2000 + Random(500));
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
end;
end else
if FindObj(OBC.x, OBC.y, 'ank', 10070458, 20) then
begin
Mouse(OBC.x, OBC.y, 0, 0, False);
WaitOption('uickly', 200);
FFlag(0);
Wait(2000 + Random(500));
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
end;
ColorToleranceSpeed(Speed);
end;

Old:

{*******************************************************************************
function OpenBankGlass(WhichBank: String; ChangeCompass, ChangeAngle: Boolean): Boolean;
By: Wizzup? and modified by Ron updated to P2p banks by N1ke!
Description: Opens the bank.
Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'akb' (Al-Kharid Bank)
'ctb' (Catherby bank)
'clt' (Camelot bank)
'nab' (North Ardougne bank)
'sab' (South Ardougne bank)
'ynb' (Yanille bank)
'ngb' (North gnome bank)
'sgb' (South gnome bank)
'wgb' (Warrior guild bank)
'fgb' (Fishing guild bank)
*******************************************************************************}
function OpenBankGlass(WhichBank: string; ChangeCompass, ChangeAngle: Boolean): Boolean;
var
OBC: TPoint;
c, Speed, Col: Integer;
begin
Speed := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if ChangeAngle then SetAngle(True);
if ChangeCompass then
begin
c := Random(2);
case WhichBank of
'feb', 'fwb', 'veb', 'ctb', 'clt', 'nab': if c = 0 then MakeCompass('N') else MakeCompass('S');
'akb', 'db', 'eb', 'vwb', 'sab', 'ynb', 'sgb', 'wgb', 'fgb': if c = 0 then MakeCompass('E') else MakeCompass('W');
'ngb': if c = 0 then MakeCompass(45) else MakeCompass(225);
end;
end;
Col := 10070458;
If (WhichBank = 'nab') or (WhichBank = 'sab')then
Col := 8095371;
if FindColorSpiralTolerance(OBC.x, OBC.y, Col, MSX1, MSY1, MSX2, MSY2, 10) then
begin
MMouse(OBC.x, OBC.y, 4, 4);
Wait(RandomRange(80, 110));
if IsUpTextMultiCustom(['nk', 'bo', 'ot']) then
begin
Mouse(OBC.x, OBC.y, 0, 0, False);
Wait(RandomRange(80, 110));
ChooseOption('uickly');
FFlag(0);
Wait(2000 + Random(500));
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
end;
end else
if FindObj(OBC.x, OBC.y, 'ank', 10070458, 20) then
begin
Mouse(OBC.x, OBC.y, 0, 0, False);
Wait(RandomRange(80, 110));
ChooseOption('uickly');
FFlag(0);
Wait(2000 + Random(500));
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
end;
ColorToleranceSpeed(Speed);
end;


OpenBankFast

New:

{*******************************************************************************
function OpenBankFast(Location: String): Boolean;
By: Wizzup? and Nielsie95 updated by N1ke!
Description: Opens the bank.
Valid arguments are:
'feb', 'falador east bank'
'fwb', 'falador west bank'
'veb', 'varrock east bank'
'vwb', 'varrock west bank'
'db' , 'draynor bank'
'akb', 'al-kharid bank'
'ctb', 'catherby bank'
'clt', 'camelot bank'
'nab', 'north ardougne bank'
'sab', 'south ardougne bank'
'ynb', 'yanille bank'
'ngb', 'north gnome bank'
'sgb', 'south gnome bank'
'wgb', 'warrior guild bank'
'fgb', 'fishing guild bank'
*******************************************************************************}
function OpenBankFast(Location: String): Boolean;
var
x, y, i, l, c, z: Integer;
Info: TIntegerArray;
Booths, t: TPointArray;
begin
Wait(400);
case LowerCase(Location) of
'akb', 'al kharid': Info := [MSCX, MSCY, 7969203, 25, 1];
'lb', 'lumbridge': Info := [MSCX, MSCY, 4807788, 10, 1];
'veb', 'varrock east': Info := [MSCX, MSCY, 2971236, 10, 1];
'vwb', 'varrock west': Info := [270, 270, 5689318, 25, 1];
'feb', 'falador east': Info := [MSCX, MSCY + 50, 4612728, 14, 1];
'fwb', 'falador west': Info := [MSCY, MSCY, 4612728, 14, 1];
'db', 'draynor': Info := [MSCX, MSCY, 2512235, 4, 2];
'eb', 'edgeville bank': Info := [MSCX + 50, MSCY, 3230295, 9, 2];
'ctb', 'catherby bank': Info := [MSCX, MSCY, 3239049, 8, 2];
'clt', 'camelot bank': Info := [MSCX, MSCY, 7636882, 5, 2];
'nab', 'north ardougne bank': Info := [MSCX, MSCY, 4084572, 5, 2];
'sab', 'south ardougne bank': Info := [MSCX, MSCY, 4084572, 5, 2];
'ynb', 'yanille bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'ngb', 'north gnome bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'sgb', 'south gnome bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'wgb', 'warrior guild bank': Info := [MSCX, MSCY, 2578286, 7, 2];
'fgb', 'fishing guild bank': Info := [MSCX, MSCY, 2908796, 10, 2];
else
begin
srl_Warn('OpenBankFast', 'Unknown bank: '+Location, warn_AllVersions);
Exit;
end;
end;

MakeCompass('n');
z := GetColorToleranceSpeed;
ColorToleranceSpeed(Info[4]);
FindColorsSpiralTolerance(Info[0], Info[1], Booths, Info[2], MSX1, MSY1, MSX2, MSY2, Info[3]);
ColorToleranceSpeed(z);
SetArrayLength(t, 0);
t := Booths;
SetArrayLength(Booths, 0);
Booths := ReArrangeAndShortenArray(t, 14);
l := GetArrayLength(Booths) -1;
for i := 0 to l do
begin
if (not LoggedIn) or BankScreen or PinScreen then
Break;
if (LowerCase(Location) = 'vwb') or (LowerCase(Location) = 'varrock west') then
begin
Booths[i].X := Booths[i].X + 5;
Booths[i].Y := Booths[i].Y - 20;
end;
MMouse(Booths[i].X, Booths[i].Y, 3, 3);
if WaitUpText('ooth', 200) Then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
if WaitOption('uickly', 200) then
begin
FFLag(0);
MarkTime(c);
repeat
Wait(100);
until (BankScreen) or (PinScreen) or (TimeFromMark(c) > 3000);
Wait(Random(300));
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
end;
end;
end;
Result := (BankScreen) or (PinScreen);
end;

Old:

{*******************************************************************************
function OpenBankFast(Location: String): Boolean;
By: Wizzup? and Nielsie95 updated by N1ke!
Description: Opens the bank.
Valid arguments are:
'feb', 'falador east bank'
'fwb', 'falador west bank'
'veb', 'varrock east bank'
'vwb', 'varrock west bank'
'db' , 'draynor bank'
'akb', 'al-kharid bank'
'ctb', 'catherby bank'
'clt', 'camelot bank'
'nab', 'north ardougne bank'
'sab', 'south ardougne bank'
'ynb', 'yanille bank'
'ngb', 'north gnome bank'
'sgb', 'south gnome bank'
'wgb', 'warrior guild bank'
'fgb', 'fishing guild bank'
*******************************************************************************}
function OpenBankFast(Location: String): Boolean;
var
x, y, i, l, c, z: Integer;
Info: TIntegerArray;
Booths, t: TPointArray;
begin
Wait(400);
case LowerCase(Location) of
'akb', 'al kharid': Info := [MSCX, MSCY, 7969203, 25, 1];
'lb', 'lumbridge': Info := [MSCX, MSCY, 4807788, 10, 1];
'veb', 'varrock east': Info := [MSCX, MSCY, 2971236, 10, 1];
'vwb', 'varrock west': Info := [270, 270, 5689318, 25, 1];
'feb', 'falador east': Info := [MSCX, MSCY + 50, 4612728, 14, 1];
'fwb', 'falador west': Info := [MSCY, MSCY, 4612728, 14, 1];
'db', 'draynor': Info := [MSCX, MSCY, 2512235, 4, 2];
'eb', 'edgeville bank': Info := [MSCX + 50, MSCY, 3230295, 9, 2];
'ctb', 'catherby bank': Info := [MSCX, MSCY, 3239049, 8, 2];
'clt', 'camelot bank': Info := [MSCX, MSCY, 7636882, 5, 2];
'nab', 'north ardougne bank': Info := [MSCX, MSCY, 4084572, 5, 2];
'sab', 'south ardougne bank': Info := [MSCX, MSCY, 4084572, 5, 2];
'ynb', 'yanille bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'ngb', 'north gnome bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'sgb', 'south gnome bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'wgb', 'warrior guild bank': Info := [MSCX, MSCY, 2578286, 7, 2];
'fgb', 'fishing guild bank': Info := [MSCX, MSCY, 2908796, 10, 2];
else
begin
srl_Warn('OpenBankFast', 'Unknown bank: '+Location, warn_AllVersions);
Exit;
end;
end;

MakeCompass('n');
z := GetColorToleranceSpeed;
ColorToleranceSpeed(Info[4]);
FindColorsSpiralTolerance(Info[0], Info[1], Booths, Info[2], MSX1, MSY1, MSX2, MSY2, Info[3]);
ColorToleranceSpeed(z);
SetArrayLength(t, 0);
t := Booths;
SetArrayLength(Booths, 0);
Booths := ReArrangeAndShortenArray(t, 14);
l := GetArrayLength(Booths) -1;
for i := 0 to l do
begin
if (not LoggedIn) or BankScreen or PinScreen then
Break;
if (LowerCase(Location) = 'vwb') or (LowerCase(Location) = 'varrock west') then
begin
Booths[i].X := Booths[i].X + 5;
Booths[i].Y := Booths[i].Y - 20;
end;
MMouse(Booths[i].X, Booths[i].Y, 3, 3);
Wait(125 + Random(75));
if IsUpText('ooth') Then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
Wait(75 + Random(75));
if ChooseOption('uickly') then
begin
FFLag(0);
MarkTime(c);
repeat
Wait(100);
until (BankScreen) or (PinScreen) or (TimeFromMark(c) > 3000);
Wait(Random(300));
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
end;
end;
end;
Result := (BankScreen) or (PinScreen);
end;


GameTab.scar

SetRest
New:

{*******************************************************************************
function SetRest: Boolean;
By: ZephyrsFury
Description: Turns Rest on. Result True if successful.
*******************************************************************************}

function SetRest: Boolean;
var
T: Integer;
begin
if (CountColor(3777879, 713, 107, 732, 115) < 10) then
begin
Mouse(715, 95, 10, 10, False);
if (WaitOption('Rest', 200)) then
begin
T := GetSystemTime;
while (CountColor(3777879, 713, 107, 732, 115) < 10) and (GetSystemTime - T < 5000) do
Wait(100);
Result := (CountColor(3777879, 713, 107, 732, 115) > 10);
end;
end;
end;

Old:

{*******************************************************************************
function SetRest: Boolean;
By: ZephyrsFury
Description: Turns Rest on. Result True if successful.
*******************************************************************************}

function SetRest: Boolean;
var
T: Integer;
begin
if (CountColor(3777879, 713, 107, 732, 115) < 10) then
begin
Mouse(715, 95, 10, 10, False);
Wait(100 + Random(100));
if (ChooseOption('Rest')) then
begin
T := GetSystemTime;
while (CountColor(3777879, 713, 107, 732, 115) < 10) and (GetSystemTime - T < 5000) do
Wait(100);
Result := (CountColor(3777879, 713, 107, 732, 115) > 10);
end;
end;
end;


Inventory.scar

ClickAllItemsExcept

New:

{*******************************************************************************
function ClickAllItemsExcept(Identifier: Integer; ItemType, option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer;
By: WT-Fakawi / Sumilion & Nava2
Description: Performs "option" popup menu action on all items with:
ItemType - 'dtm', 'bitmap', 'bitmap mask', 'color'
Item - name/value of your dtm/bmp/color/bmpmask.
Tol - 'dtm' - [] (dtm's can't have tolerance).
'bmp' - [BMPTol].
'color' - [COLOUR Tol, Colour Count].
'bmpmask' - [BMPTol, ContourTol].
Will not click items in slots SlotIgnores
*******************************************************************************}
function ClickAllItemsExcept(Identifier: Integer; ItemType, option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer;
var
i, x, y: Integer;
TB: Tbox;
arr:array of Integer;
begin
Result := 0;

arr :=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28];
for i := 1 to 28 - 4 do
Swap(arr[RandomRange(i - 1, i + 4)], arr[RandomRange(i - 1, i + 4)] );

SetLength(Tol, 2);
GameTab(4);
for i := 0 to 27 do
begin
if InIntArray(SlotIgnores, arr[i] + 1) then Continue;
TB := InvBox(arr[i]);
if ExistsItem(arr[i]) then
try
if not FindItemEx(x, y, ItemType, Identifier, TB, Tol) then Continue;
if Option <> '' then
begin
MouseItem(arr[i], False);
WaitOption(Option, waitnum);
Inc(Result);
end
else
MouseItem(arr[i], True);
Wait(waitnum);
except end;
end;
end;

Old:

{*******************************************************************************
function ClickAllItemsExcept(Identifier: Integer; ItemType, option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer;
By: WT-Fakawi / Sumilion & Nava2
Description: Performs "option" popup menu action on all items with:
ItemType - 'dtm', 'bitmap', 'bitmap mask', 'color'
Item - name/value of your dtm/bmp/color/bmpmask.
Tol - 'dtm' - [] (dtm's can't have tolerance).
'bmp' - [BMPTol].
'color' - [COLOUR Tol, Colour Count].
'bmpmask' - [BMPTol, ContourTol].
Will not click items in slots SlotIgnores
*******************************************************************************}
function ClickAllItemsExcept(Identifier: Integer; ItemType, option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer;
var
i, x, y: Integer;
TB: Tbox;
arr:array of Integer;
begin
Result := 0;

arr :=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28];
for i := 1 to 28 - 4 do
Swap(arr[RandomRange(i - 1, i + 4)], arr[RandomRange(i - 1, i + 4)] );

SetLength(Tol, 2);
GameTab(4);
for i := 0 to 27 do
begin
if InIntArray(SlotIgnores, arr[i] + 1) then Continue;
TB := InvBox(arr[i]);
if ExistsItem(arr[i]) then
try
if not FindItemEx(x, y, ItemType, Identifier, TB, Tol) then Continue;
if Option <> '' then
begin
MouseItem(arr[i], False);
Wait(waitnum);
ChooseOption(option);
Inc(Result);
end
else
MouseItem(arr[i], True);
Wait(waitnum);
except end;
end;
end;


DropItem

New:

{*******************************************************************************
procedure DropItem(i: Integer);
By: Lorax
Description: Drops item at given position (1-28)
*******************************************************************************}
function DropItem(i: Integer): Boolean;
begin
Result := False;
if ExistsItem(i) then
begin
MouseItem(i, False);
if (WaitOption('rop', 250)) then
begin
Result := True;
Wait(RandomRange(50, 200));
end;
end;
end;

Old:

{*******************************************************************************
procedure DropItem(i: Integer);
By: Lorax
Description: Drops item at given position (1-28)
*******************************************************************************}

function DropItem(i: Integer): Boolean;
begin
Result := False;
if ExistsItem(i) then
begin
MouseItem(i, False);
Wait(170 + Random(50));
if (ChooseOption('rop')) then
begin
Result := True;
Wait(RandomRange(50, 200));
end;
end;
end;


ClickAllItemsBlackLine
New:

{*******************************************************************************
Function ClickAllItemsBlackLine(Count, Tol: Integer; Option: String): Integer;
By: n3ss3s
Description: Finds all items in inventory with blackline points amount of Count
with Tol tolerance, and returns the amount of items could choose the
option Option to. Waits the WaitT amount of millisecs between items, with
WaitR randomness of milliseconds.
*******************************************************************************}

Function ClickAllItemsBlackLine(Count, Tol, WaitT, WaitR: Integer; Option: String): Integer;
Var
TPA: TPointArray;
X, Y, Z, H: Integer;
TPAA: T2DPointArray;
Begin
GameTab(2);
FindColorsTolerance(TPA, 65536, MIX1, MIY1, MIX2, MIY2, 0);
TPAA := TPAToATPAEx(TPA, 42, 36);
H := High(TPAA);
For z := 0 To H Do
If InRange(GetArrayLength(TPAA[z]), Count - Tol, Count + Tol) Then
Begin
MiddleTPAEx(TPAA[z], X, Y);
Mouse(X, Y, 2, 2, False);
If WaitOption(Option, 250) Then
Begin
Result := Result + 1;
Wait(WaitT + Random(WaitR));
End;
End;
End;

Old:

{*******************************************************************************
Function ClickAllItemsBlackLine(Count, Tol: Integer; Option: String): Integer;
By: n3ss3s
Description: Finds all items in inventory with blackline points amount of Count
with Tol tolerance, and returns the amount of items could choose the
option Option to. Waits the WaitT amount of millisecs between items, with
WaitR randomness of milliseconds.
*******************************************************************************}

Function ClickAllItemsBlackLine(Count, Tol, WaitT, WaitR: Integer; Option: String): Integer;
Var
TPA: TPointArray;
X, Y, Z, H: Integer;
TPAA: T2DPointArray;
Begin
GameTab(2);
FindColorsTolerance(TPA, 65536, MIX1, MIY1, MIX2, MIY2, 0);
TPAA := TPAToATPAEx(TPA, 42, 36);
H := High(TPAA);
For z := 0 To H Do
If InRange(GetArrayLength(TPAA[z]), Count - Tol, Count + Tol) Then
Begin
MiddleTPAEx(TPAA[z], X, Y);
Mouse(X, Y, 2, 2, False);
If ChooseOption(Option) Then
Begin
Result := Result + 1;
Wait(WaitT + Random(WaitR));
End;
End;
End;


Mouse.scar

Added
Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean;Forward;
To line 268, So it compiles.

SpiralMouseMulti
New:

{*******************************************************************************
function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean;
By: Nava2
Description: Spirals the mouse in a circle from the center of the defined box.
It will continue to spiral until it finds a spiral completely outside
the box, always skipping points outside.
Returns the occurance of the first occurance of UpText into fx, fy.
Takes multiple UpTexts as a TStringArray.
PpC: The number of pixels to increase per spiral.
aInc: The number of stops to make around each spiral.
Takes some testing to get the right combination of PpC and aInc.
*******************************************************************************}
function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean;
var
aStep, a, rStep, rV, oB: Extended;
pX, pY, ms: Integer;
sP: TPoint;
L2R: Boolean;
begin
Result := False;
ms := MouseSpeed;
MouseSpeed := 25 + RandomRange(-3, 3);
sP := MiddleTPA([Point(x1, y1), Point(x2, y2)]);
aStep := Pi / (aInc / 2);
a := 0;
rStep := (PpC / aInc);
L2R := Random(2) = 0;
//Writeln('aStep: ' + FloatToStr(aStep) + ' rStep ' + FloatToStr(rStep));
repeat
rV := rV + rStep;
pX := Round(rV * cos(a)) + sP.x;
pY := Round(rV * sin(a)) + sP.y;
if L2R then
a := a + aStep
else
a := a - aStep;
if InRange(pX, x1, x2) and InRange(pY, y1, y2) then
begin
oB := 0;
MMouse(pX - 2, pY - 2, 5, 5);
if WaitUptextMulti(UpText, 100+Random(60)) then
begin
GetMousePos(fx, fy);
Result := True;
end;
end else
oB := oB + aStep;
until Result or (oB > (2 * Pi));
MouseSpeed := ms;
end;

Old:

{*******************************************************************************
function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean;
By: Nava2
Description: Spirals the mouse in a circle from the center of the defined box.
It will continue to spiral until it finds a spiral completely outside
the box, always skipping points outside.
Returns the occurance of the first occurance of UpText into fx, fy.
Takes multiple UpTexts as a TStringArray.
PpC: The number of pixels to increase per spiral.
aInc: The number of stops to make around each spiral.
Takes some testing to get the right combination of PpC and aInc.
*******************************************************************************}
function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean;
var
aStep, a, rStep, rV, oB: Extended;
pX, pY, ms: Integer;
sP: TPoint;
L2R: Boolean;
begin
Result := False;
ms := MouseSpeed;
MouseSpeed := 25 + RandomRange(-3, 3);
sP := MiddleTPA([Point(x1, y1), Point(x2, y2)]);
aStep := Pi / (aInc / 2);
a := 0;
rStep := (PpC / aInc);
L2R := Random(2) = 0;
//Writeln('aStep: ' + FloatToStr(aStep) + ' rStep ' + FloatToStr(rStep));
repeat
rV := rV + rStep;
pX := Round(rV * cos(a)) + sP.x;
pY := Round(rV * sin(a)) + sP.y;
if L2R then
a := a + aStep
else
a := a - aStep;
if InRange(pX, x1, x2) and InRange(pY, y1, y2) then
begin
oB := 0;
MMouse(pX - 2, pY - 2, 5, 5);
Wait(100 + Random(60));
if IsUpTextMultiCustom(UpText) then
begin
GetMousePos(fx, fy);
Result := True;
end;
end else
oB := oB + aStep;
until Result or (oB > (2 * Pi));
MouseSpeed := ms;
end;


Object.scar

FindObjEx
New:

{*******************************************************************************
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
By: Starblaster100
Description: Searches for an object using an array of colors and texts within the area
you specify. Will start searching from the middle and returns true if found.
Parameters:
cx, cy: Coordinate Position of object if result is true
Text: Array of string you want to search for
Color: Array of colors you want to search for
Tol: Tolerance of the colors you will allow
Step: How big you want to make the search squares. 50 = Default. 30-70 Recommended
xs, ys, xe, ye: Bounds you want to search in
*******************************************************************************}

function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
var
CurX, CurY, a, b, c, i: Integer;
Start: Boolean;
begin
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorSpiralTolerance(cx, cy, color[b], xs, ys, xe, ye, Tol)) then
begin
Start := True;
Break;
end;
end;
if (Start) then
begin
CurX := Round((xs + xe) div 2);
CurY := Round((ys + ye) div 2) - Step;
i := 1;
repeat
for c := 1 to i do
begin
case a of
0: begin //To allow for beginning offset and loop
a := a + 1;
i := 0;
CurY := CurY + Step;
end;
1: CurX := CurX + Step;
2: CurY := CurY - Step;
3: CurX := CurX - Step;
4: CurY := CurY + Step;
end;
if (CurX >= xs) and (CurX <= xe) and (CurY >= ys) and (CurY <= ye) then
begin
try
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorTolerance(cx, cy, Color[b], CurX-(Step/2), CurY-(Step/2), CurX+(Step/2), CurY+(Step/2), Tol)) then
begin
MMouse(cx, cy, 3, 3);
If (WaitUptextMulti(Text, 75+Random(50))) then
begin
GetMousePos(cx, cy);
Result := True;
Exit;
end;
end;
end;
except
end;
end;
end;
a := a + 1;
if a mod 5 = 0 then a := 1;
if (a = 1) or (a = 3) then i := i + 1;
until (Result) or ((CurX > xe) and (CurY > ye))
end;
end;

Old:

{*******************************************************************************
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
By: Starblaster100
Description: Searches for an object using an array of colors and texts within the area
you specify. Will start searching from the middle and returns true if found.
Parameters:
cx, cy: Coordinate Position of object if result is true
Text: Array of string you want to search for
Color: Array of colors you want to search for
Tol: Tolerance of the colors you will allow
Step: How big you want to make the search squares. 50 = Default. 30-70 Recommended
xs, ys, xe, ye: Bounds you want to search in
*******************************************************************************}

function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
var
CurX, CurY, a, b, c, i: Integer;
Start: Boolean;
begin
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorSpiralTolerance(cx, cy, color[b], xs, ys, xe, ye, Tol)) then
begin
Start := True;
Break;
end;
end;
if (Start) then
begin
CurX := Round((xs + xe) div 2);
CurY := Round((ys + ye) div 2) - Step;
i := 1;
repeat
for c := 1 to i do
begin
case a of
0: begin //To allow for beginning offset and loop
a := a + 1;
i := 0;
CurY := CurY + Step;
end;
1: CurX := CurX + Step;
2: CurY := CurY - Step;
3: CurX := CurX - Step;
4: CurY := CurY + Step;
end;
if (CurX >= xs) and (CurX <= xe) and (CurY >= ys) and (CurY <= ye) then
begin
try
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorTolerance(cx, cy, Color[b], CurX-(Step/2), CurY-(Step/2), CurX+(Step/2), CurY+(Step/2), Tol)) then
begin
MMouse(cx, cy, 3, 3);
Wait(50 + Random(50));
If (IsUpTextMultiCustom(Text)) then
begin
GetMousePos(cx, cy);
Result := True;
Exit;
end;
end;
end;
except
end;
end;
end;
a := a + 1;
if a mod 5 = 0 then a := 1;
if (a = 1) or (a = 3) then i := i + 1;
until (Result) or ((CurX > xe) and (CurY > ye))
end;
end;


FindObjectDeformed
New:

{*******************************************************************************
function FindObjectDeformed(var ObjX, ObjY: Integer; UpText1, UpText2: String; BMP, a, b, c, d: Integer): Boolean;
By: WT-Fakawi
Description: Finds Object in Box a,b,c,d, specified by BitMap and Uptext1 or Uptext2
Returns coords in ObjX and ObjY.
Uses Deformed Bitmap. FindObjectDeformed will gradually lower Tol and reduce Accuracy.
Functon can cause severe Lag when using bitmaps bigger then 16 pixels. Works but Lags.
*******************************************************************************}

function FindObjectDeformed(var ObjX, ObjY: Integer; UpText1, UpText2: string;
BMP, a, b, c, d: Integer): Boolean;
var
acc, ref: Extended;
XT, YT, times, tol: Integer;
begin
ref := 0.9;
tol := 0;
for times := 1 to 50 do
begin
FindDeformedBitmapToleranceIn(BMP, XT, YT, a, b, c, d, tol, 2, True, acc);
if (acc >= ref) then
begin
MMouse(XT, YT, 0, 0);
if (WaitUptextMulti([UpText1, UpText2], 400+Random(400))) then
begin
ObjX := XT;
ObjY := YT;
Result := True;
Exit;
end;
end;
if times mod 5 = 0 then
begin
ref := ref - 0.1;
tol := tol + 10;
end;
Wait(1);
end;
end;

Old:

{*******************************************************************************
function FindObjectDeformed(var ObjX, ObjY: Integer; UpText1, UpText2: String; BMP, a, b, c, d: Integer): Boolean;
By: WT-Fakawi
Description: Finds Object in Box a,b,c,d, specified by BitMap and Uptext1 or Uptext2
Returns coords in ObjX and ObjY.
Uses Deformed Bitmap. FindObjectDeformed will gradually lower Tol and reduce Accuracy.
Functon can cause severe Lag when using bitmaps bigger then 16 pixels. Works but Lags.
*******************************************************************************}

function FindObjectDeformed(var ObjX, ObjY: Integer; UpText1, UpText2: string;
BMP, a, b, c, d: Integer): Boolean;
var
acc, ref: Extended;
XT, YT, times, tol: Integer;
begin
ref := 0.9;
tol := 0;
for times := 1 to 50 do
begin
FindDeformedBitmapToleranceIn(BMP, XT, YT, a, b, c, d, tol, 2, True, acc);
if (acc >= ref) then
begin
MMouse(XT, YT, 0, 0);
Wait(400 + Random(400));
if (IsUpText(UpText1) or IsUpText(UpText2)) then
begin
ObjX := XT;
ObjY := YT;
Result := True;
Exit;
end;
end;
if times mod 5 = 0 then
begin
ref := ref - 0.1;
tol := tol + 10;
end;
Wait(1);
end;
end;

__________________________________________________________________________________________

Use turtoise diff to check the diffrence between these.

New Bank.scar

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Bank Routines --//
//-----------------------------------------------------------------//

// * function BankScreen: Boolean; // * by SRL Dev Team
// * function DepositScreen: Boolean; // * by Shuttleu
// * function PinScreen: Boolean; // * by Starblaster100
// * function InPin(Pin: string): Boolean; // * by ZephyrsFury and Nava2
// * function BankIndexToBankPoint(Ind: Integer): TPoint; // * by Wizzup
// * function BankPointToIndex(P: TPoint): Integer; // * by Wizzup
// * function BankIndexToMSBox(Ind: Integer): TBox; // * by Wizzup
// * function MSTPointToBankIndex(P: TPoint): Integer; // * by Wizzup
// * function DepositItemBox: TBox; // * by ZephyrsFury
// * Procedure Fixbank // * by lordsaturn & Nava2
// * Function FixBankTab: Boolean; // * by Wizzup?
// * Function CurrentBankTab: Integer; // * by Narcle
// * Function ExistsBankTab(T: Integer): Boolean; // * by Narcle
// * Function BankTab(T: Integer): Boolean; // * by Narcle
// * procedure SearchBank(Item: string); // * by ZephyrsFury
// * Procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant); // * by PPLSUQBAWLZ / Stupid3ooo
// * procedure Withdraw(Col,Row,Amount:integer); // * by Odie3355/Stupid3ooo/Starblaster100 fixed by Town
// * procedure DepositAll; // * by ZephyrsFury
// * procedure Notes(SwitchOn: Boolean); // * by lordsaturn, idea by R1ch
// * Procedure CloseBank; // * by Starblaster100
// * Function OpenBankQuiet(WhichBank:string):Boolean; // * by WT-Fakawi
// * Function OpenBankGlass(WhichBank:String; ChangeCompass:Boolean): Boolean; // * By Wizzup? & N1ke!
// * function OpenBankFast(Location: String): Boolean; // * by Wizzup?, Nielsie95 & N1ke!
// * function OpenBank(WhichBank:String; ChangeCompass:Boolean): Boolean; // * by SRL
// * Function FindBank(TheBank: string): Boolean; // * by WT-Fakawi & N1ke!
// * function OpenDepositBox: Boolean; // * by Shuttleu


{*******************************************************************************
function BankScreen: Boolean;
by: SRL Dev Team
Description: Finds Bankscreen. Returns true if Found.
*******************************************************************************}

function BankScreen: Boolean;
var
c: Integer;
begin
if (CountColor(0, MSX1, MSY1, MSX2, MSY2) > 113000) then
begin
MouseBox(26, 138, 489, 157, 1);
c := GetTimeRunning + 45000;
while (not BankScreen) and (GetTimeRunning < c) do
Wait(50);
Wait(RandomRange(100, 150));
end;
Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
end;

{*******************************************************************************
function DepositScreen: Boolean;
by: Shuttleu
Description: Returns true if deposit screen is Found.
*******************************************************************************}

function DepositScreen: Boolean;
var
X, Y: Integer;
begin
Result := FindText(x, y, 'Deposit Box', upchars, 92, 29, 396, 54);
end;

{*******************************************************************************
function PinScreen: Boolean;
by: Starblaster100
Description: Finds Pin Screen. Returns true if Found.
*******************************************************************************}

function PinScreen: Boolean;
Var
x, y: Integer;
begin
Result := FindText(x, y, 'First', upchars, 175, 80, 212, 100);
end;

{*******************************************************************************
function InPin(Pin: String): Boolean;
by: ZephyrsFury and Nava2
Description: Enters bank pin. Will try 3 times, returns true if bank is opened.
*******************************************************************************}

function InPin(Pin: string): Boolean;
var
TMouseSpeed, iNumber, Tx, Ty, Counter, i: Integer;
Boxes: array of TBox;
OnBox: Boolean;
begin
Result := False;
if (not(PinScreen)) then Exit;
if (GetNumbers(Pin) <> Pin) then
begin
srl_Warn('InPin', '''' + Pin + ''' is not a valid Pin', warn_AllVersions);
Exit;
end;
if (Length(Pin) <> 4) then
begin
srl_Warn('InPin', 'Pin must be 4 digits long', warn_AllVersions);
Exit;
end;
Boxes := [IntToBox(37, 107, 100, 170), IntToBox(131, 107, 194, 170), IntToBox(225, 107, 288, 170), IntToBox(309, 107, 372, 170),
IntToBox(37, 179, 100, 242), IntToBox(131, 179, 194, 242), IntToBox(225, 179, 288, 242), IntToBox(37, 251, 100, 314),
IntToBox(131, 251, 194, 314), IntToBox(225, 251, 288, 314)];
TMouseSpeed := MouseSpeed;
MouseSpeed := 25;
Counter := 0;
repeat
if (PinScreen) then
begin
for iNumber := 1 to Length(Pin) do
begin
if OnBox then
begin
repeat
Tx := Random(MSX2);
Ty := Random(MSY2);
for i := 0 to 9 do
begin
if IntInBox(Tx, ty, Boxes[i]) then
begin
OnBox := True;
Break;
end;
OnBox := False;
end;
until (not(OnBox));
MMouse(Tx, Ty, 0, 0);
Wait(500 + Random(500));
end;

if (FindText(Tx, Ty, Pin[iNumber], UpChars, 30, 100, 383, 319)) then
Begin
for i := 0 to 9 do
begin
OnBox := False;
if IntInBox(Tx, Ty, Boxes[i]) then
with Boxes[i] do
begin
OnBox := True;
MouseBox(x1, y1, x2, y2, 1);
Break;
end;
end;
Wait(1000 + Random(500));
End;
end;
end;
Wait(1000 + Random(500));
if (BankScreen) then
begin
Result := True;
MouseSpeed := TMouseSpeed;
Exit;
end;
ClickContinue(True, True);
while (not(FindColor(Tx, Ty, 0, 7, 460, 69, 474))) do
begin
if (not(LoggedIn)) then
begin
MouseSpeed := TMouseSpeed;
Exit;
end;
Wait(1000 + Random(500));
end;
Inc(Counter);
until(Counter > 2);
end;

{*******************************************************************************
Function MSTPointToBankPoint(P: TPoint): TPoint;
by: Wizzup
Description: Converts a point on the Mainscreen to the point in the Bank.
First Row and Col are (0,0).
*******************************************************************************}
Function MSTPointToBankPoint(MSP: TPoint): TPoint;

Begin
Result.X := (MSP.X - 38) / 44;
Result.Y := (MSP.Y - 90) / 45;
End;

{*******************************************************************************
function BankPointToBankIndex(P: TPoint): Integer;
by: Wizzup?
Description: Converts a Bank Point (Row,Col) to Bank Index (spot in bank).
(0, 0) = 1
*******************************************************************************}

Function BankPointToBankIndex(P: TPoint): Integer;

Begin
Result := P.Y * 10 + P.X + 1;
End;

{*******************************************************************************
function BankIndexToBankPoint(ind: Integer): TPoint;
by: Wizzup
Description: Converts the Bank Index (spot in bank) to a Bank Point (Row,Col).
1 = (0, 0)
*******************************************************************************}
Function BankIndexToBankPoint(Index: Integer): TPoint;

Begin
Index := Index - 1;
Result := Point((Index Mod 10), Floor(Index Div 10));
End;

{*******************************************************************************
Function BankIndexToMSPoint(Index: Integer): TPoint;
by: Wizzup?
Description: Converts the Bank Index (spot in bank) to a Mainscreen TPoint of
the Index. (Top Left)
*******************************************************************************}

Function BankIndexToMSPoint(Index: Integer): TPoint;

Begin
Index := Index - 1;
Result := Point(38 + (Index Mod 10) * 44, 90 + Floor(Index Div 10) * 45);
End;

{*******************************************************************************
function BankIndexToMSBox(ind:Integer): TBox;
by: Wizzup
Description: Converts the Bank Index (spot in bank) to a Mainscreen TBox of
the Index.
*******************************************************************************}

Function BankIndexToMSBox(Index: Integer): TBox;

Var
P: TPoint;
Begin
P := BankIndexToMSPoint(Index);
Result.X1 := P.X;
Result.Y1 := P.Y;
Result.X2 := Result.X1 + 31;
Result.Y2 := Result.Y1 + 32;
End;

{*******************************************************************************
function DepositItemBox(Item: Integer): TBox;
by: ZephyrsFury
Description: Returns a TBox surround Item (1 to 28) in the Deposit Box screen.
*******************************************************************************}

function DepositItemBox(Item: Integer): TBox;
begin
Result.X1 := 97 + (Item - 1) mod 7 * 48;
Result.Y1 := 60 + (Item - 1) div 7 * 50;
Result.X2 := Result.X1 + 48;
Result.Y2 := Result.Y1 + 50;
end;

{*******************************************************************************
procedure FixBank;
by: lordsaturn and Nava2
Description: Scrolls the bank screen up.
*******************************************************************************}

procedure FixBank;
begin
if GetColor(489, 101) = 2830904 then exit;
if BankScreen then
if GetColor(489, 101) <> 1316634 then
begin
Mouse(485, 102, 7, 10, True);
while GetColor(489, 101) <> 1316634 do
Wait(20);
Wait(100 + Random(200));
end;
end;

{*******************************************************************************
Function FixBankTab: Boolean;
by: Wizzup?
Description: Fixes the BankTab to 'View All'
*******************************************************************************}

Function FixBankTab: Boolean;

Var
activeTPA, notactiveTPA: TPointArray;
T: Integer;
Begin
Result := False;
FindColorsTolerance(activeTPA, 2896954, 25, 45, 70, 80, 5);
FindColorsTolerance(notactiveTPA, 2437688, 25, 45, 70, 80, 5);

If Length(activeTPA) > Length(notactiveTPA) Then
Begin
Result := True;
Exit;
End;

Mouse(40, 60, 10, 10, True);
T := GetSystemTime;
While Length(activeTPA) <= Length(notactiveTPA) Do
Begin
FindColorsTolerance(activeTPA, 2896954, 25, 45, 70, 80, 5);
FindColorsTolerance(notactiveTPA, 2437688, 25, 45, 70, 80, 5);
Wait(500);
If ((GetSystemTime - T) / 1500) Mod 2 = 0 Then
Mouse(40, 60, 10, 10, True);
If GetSystemTime - T > 10000 Then
Exit;
End;
End;

{*******************************************************************************
Function CurrentBankTab: Integer;
by: Narcle
Description: Returns Current Bank Tab selected
*******************************************************************************}
function CurrentBankTab: Integer;
begin
if not BankScreen then
Exit;
for Result := 1 to 9 do
if GetColor(40 + 48 * (Result - 1), 83) = 2896954 then
Exit;
Result := 0;
end;

{*******************************************************************************
Function ExistsBankTab(T: Integer): Boolean;
by: Narcle
Description: Returns true if Bank Tab Exists
*******************************************************************************}

Function ExistsBankTab(T: Integer): Boolean;
var
x, y: integer;
begin
Result := False;
if not BankScreen then
begin
srl_Warn('ExistsBankTab', 'Bank not open.', warn_AllVersions);
Exit;
end;
if (not(InRange(T, 1, 9))) then
begin
srl_Warn('ExistsBankTab', 'Bank Tab: ' + IntToStr(T) + ' is not possible (1..9) only.', warn_AllVersions);
Exit;
end;
if T = 1 then
Result := true;

if FindColor(x, y, 65536, 27+(T-1)*48, 51, 70+(T-1)*48, 81) then
Result := true;
end;

{*******************************************************************************
Function BankTab(T: Integer): Boolean;
by: Narcle
Description: If Bank Tab is there will switch to it.
*******************************************************************************}

Function BankTab(T: Integer): Boolean;

begin
if not BankScreen then
Exit;

if T = CurrentBankTab then
Begin
Result := true;
Exit;
end;

if not ExistsBankTab(T) then
srl_Warn('BankTab', 'Bank Tab '+inttostr(T) +' does not Exist.', warn_AllVersions)
else
Mouse(48 * T, 57, 10, 10, true);

Result := T = CurrentBankTab;
end;


{*******************************************************************************
procedure SearchBank(Item: string);
by: ZephyrsFury
Description: Searches for Item in your bank.
*******************************************************************************}

procedure SearchBank(Item: string);
var
T, II: Integer;
begin
if (not(BankScreen)) then Exit;
for II := 0 to 2 do
begin
FixBankTab;
Mouse(75, 300, 20, 10, True);
T := GetSystemTime;
while (BankScreen) and (GetSystemTime - T < 5000) do
begin
Wait(500 + Random(500));
if (FindTextTpa(0, 0, 350, 392, 399, 410, 'search', UpChars, Nothing)) then
begin
TypeSend(Item);
Exit;
end;
end;
Wait(500 + Random(500));
end;
end;

{*******************************************************************************
Procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant);
by: WT-Fakawi/PPLSUQBAWLZ/Stupid3ooo/Town
Description: Deposits from Slot to ToSlot.
vType True = Deposit All. vType False = Deposit one by one.
Any integer is deposit with Deposit X. (except for 5 and 10)
*******************************************************************************}

Procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant);

Var
DepositX, BScreen, DScreen: Boolean;
All: Variant;
I, T, x, y: Integer;
B: TBox;
Begin
BScreen := BankScreen;
if (not(BScreen)) then
DScreen := DepositScreen;
If Not (BScreen or DScreen) Then
Exit;
If vType = 2 Then
srl_Warn('Deposit', '2 now means store per 2, not ''All''', 15);
DepositX := False;
Case VarType(vType) Of
3: Begin
DepositX := Not InIntArray([1, 5, 10], vType);
If vType = 1 Then
All := False
Else
All := True;
End;
11: All := vType;
End;
For I := SlotFrom To SlotTo Do
Begin
if (BScreen) then
begin
If Not ExistsItem(I) Then
Continue;
MouseItem(I, Not All);
end else
begin
B := DepositItemBox(I);
if (not(FindColor(X, Y, 65536, B.X1, B.Y1, B.X2, B.Y2))) then
Continue;
Mouse((B.X1 + B.X2) shr 1, (B.Y1 + B.Y2) shr 1, 0, 0, not All);
end;
If DepositX Then
Begin
ChooseOption('Deposit-X');
T := GetSystemTime;
While (Not FindColor(x, y, 8388608, MCX1, MCY1, MCX2, MCY2)) And (GetSystemTime - T < 3000) Do
Wait(100);
TypeSend(vType);
End Else If VarType(vType) = 3 Then
ChooseOption('Deposit-' + vType)
Else
ChooseOption('Deposit-All');
T := GetSystemTime;
Wait(RandomRange(200, 300));
repeat
if (BScreen) then
if (not(ExistsItem(I))) then Break;
if (DScreen) then
if (not(FindColor(X, Y, 65536, B.X1, B.Y1, B.X2, B.Y2))) then Break;
Wait(50);
until(GetSystemTime - T > 2000);
End;
End;

{*******************************************************************************
procedure Withdraw(Col, Row, Amount: Integer);
by: Starblaster100, Town, Wizzup? and Narcle
Description: Withdraws Amount at Column/Row.
*******************************************************************************}
procedure Withdraw(col, row, Amount: Integer);
var
BBox: TBox;
begin
FixBank;
FixBankTab;

{
if Col > 1 then Dec(Col);
if Row > 1 then Dec(Row);
}

BBox := BankIndexToMSBox(BankPointToBankIndex(Point(Col, Row)));
If Amount = 1 Then
Begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 1);
Wait(RandomRange(50, 150));
End
Else
Begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 2);
if (Amount = 5) or (Amount = 10) then
ChooseOption('Withdraw-' +IntToStr(Amount))
else if Amount = 0 then
ChooseOption('Withdraw-All')
else
if not ChooseOption('Withdraw-'+IntToStr(Amount)+' ') then
begin
MouseBox(BBox.X1 + 5, BBox.Y1 + 5, BBox.X2 - 5, BBox.Y2 - 5, 2);
if (ChooseOption('Withdraw-X')) then
begin
Wait(1000 + Random(100));
TypeSend(IntToStr(Amount));
end;
end;
end;
end;

{*******************************************************************************
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;
By: Nava2
Description: Withdraws an item from the bank by using "Ident" with tol[0]
as color tolerance, tol[1] as contour tolerance in case of bmp
masks, or the count of colors for TPA item finding.
Valid IdentTypes are all in FindItem.
Index: The Bank Index where the item is found, must be a variable.
Speeds up future withdraws.
Amount: Amount to withdraw from bank.
UpText: The UpText which the function checks for.
*******************************************************************************}
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): Boolean;
var
x, y: integer;
BPoint: TPoint;
BankBox: TBox;
Found: Boolean;
t: TPointArray;
label
Start;
begin
Result := False;
if not BankScreen then Exit;
FixBank;

if (Index = 0) then
begin
Start:
for Index := 1 to 50 do
begin
if FindItemEx(x, y, IdentType, Ident, BankIndexToMSBox(Index), Tol) then
begin
MMouse(x, y, 4, 4);
if WaitUpText(UpText, 200) then
begin
Writeln('Found Item at Bank Slot ' + IntToStr(Index) + '.');
Found := True;
Break;
end else
Writeln('Found Incorrect Item, Moving to new Bank Spot.');
end;
end;
end else
begin
BankBox := BankIndexToMSBox(Index);
FindColors(t, 65536, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
BankBox := GetTPABounds(t);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, 3);
Wait(120 + Random(50));
if IsUpText(UpText) then
Found := true
else
begin
Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
GoTo Start;
end;
end;
Wait(RandomRange(200, 350));
if Found then
begin
BPoint := BankIndexToBankPoint(Index);
//Writeln(IntToStr(BPoint.x) + ', ' + IntToStr(BPoint.y));
Withdraw(BPoint.x, BPoint.y, Amount);
Result := True;
end else
begin
Index := 0;
SRL_Warn('WithdrawItem', 'Could not Find ' + IdentType + ' in Bank. [Uptext: ' + UpText + ']', Warn_AllVersions);
end;
end;

{*******************************************************************************
function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
by: Nava2
Description: Withdraws an item using WithdrawItemEx, but removes the Index check.
*******************************************************************************}
function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;
var
I : Integer;
begin
Result := WithdrawItemEx(Ident, IdentType, I, Amount, UpText, Tol);
end;

{*******************************************************************************
function DepositAll: Boolean;
by: ZephyrsFury & Quickmarch
Description: Deposits all items in your inventory
*******************************************************************************}

function DepositAll: Boolean;
var
T, X, Y: Integer;
BScreen, DScreen: Boolean;
begin
BScreen := BankScreen;
if (not(BScreen)) then
DScreen := DepositScreen;
if (BScreen) or (DScreen) then
if (InvCount > 0) or (FindColor(X, Y, 65536, 98, 68, 436, 257) and (DSCreen)) then
begin
Mouse(390 - 50 * Integer(DScreen), 305 - 30 * Integer(DScreen), 15, 10, True);
Wait(200 + Random(300));
T := GetSystemTime;
while (InvCount > 0) or (FindColor(X, Y, 65536, 98, 68, 436, 257) and (DSCreen)) and (GetSystemTime - T < 2000) do
Wait(100);
Result := (InvEmpty) or (not(FindColor(X, Y, 65536, 98, 68, 436, 257)) and (DScreen));
end;
end;


{*******************************************************************************
procedure Notes(SwitchOn: Boolean);
By: lordsaturn, idea by R1ch
Description: Toggles note withdrawal on or off.
*******************************************************************************}
procedure Notes(SwitchOn: Boolean);
begin
if BankScreen then
if (GetColor(254, 306) = 5863290) xor SwitchOn then
Mouse(250, 300, 10, 10, True);
end;

{*******************************************************************************
function CloseBank: Boolean;
By: Starblaster100
Description: Closes the bank window - Tries twice before exiting
*******************************************************************************}
function CloseBank: Boolean;
var
i, Timer: Integer;
begin
Result := False;
if BankScreen then
begin
Timer := GetTimeRunning + 8000;
repeat
Mouse(483, 28, 10, 12, True);
for i := 0 to 30 do
begin
if not BankScreen then
begin
Result:= True;
Break;
end;
Wait(100);
end;
Wait(Random(100));
until (GetTimeRunning > Timer) or Result;
end;
end;

{*******************************************************************************
function OpenBankQuiet(WhichBank: string): Boolean;
By: WT-Fakawi and modified by Ron
Description: Opens any given bank in the free world using
FindDeformedBitmapToleranceIn. Avoids strange mouse movements. Will cause
significant lag (approx. 1 second), but finds the bank with one click.

Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'eb' (Edgeville Bank)
'akb' (Al-Kharid Bank)
*******************************************************************************}

function OpenBankQuiet(WhichBank: string): Boolean;
var
TheCounter, dx, dy, tol, Mark2, Mark3: Integer;
acc, accthres: Extended;
begin
case WhichBank of
'feb', 'fwb': TheCounter := BitmapFromString(1, 10, '6C583296897A948779948779736' +
'C63A59E968C7F6F9686749B8A7685663E');
// varrock west
'vwb': TheCounter:= BitmapFromString(10, 1, 'A0997F504A49504A49504A495E4' +
'F215E4F215E4F215E4F212C250EA0997F');
// varrock east
'veb': TheCounter := BitmapFromString(1, 10, '5E4D1589826D88806D88806D867' +
'F6C9996907C7664847D648C836891876B');
// draynor and this works too for alkharid
'akb', 'db', 'eb': TheCounter:= BitmapFromString(12, 1, '584209735C29735C29735C29605' +
'85558504D60504D58504D58504D58504D58504D605855');
else
begin
srl_Warn('OpenBankQuiet', 'Unknown bank: ' + WhichBank, warn_AllVersions);
Exit;
end;
end;

MarkTime(Mark3);
tol := 1;
accthres := 0.6;
repeat
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
if WaitUptextMulti(['ank', 'Bo', 'ot'], 200) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, False);
if WaitOption('uickly', 200) then
begin
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
end;

FindDeformedBitmapToleranceIn(TheCounter, dx, dy, MSX1 + 50, MSY1 + 50, MSX2
- 50, MSY2 - 50, tol, 4, True, acc);
if (acc >= accthres) then
begin
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
if BankScreen or PinScreen then
begin
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
MMouse(dx, dy, 0, 0);
if WaitUptextMulti(['ank', 'Bo', 'ot'], 200) then
begin
GetMousePos(dx, dy);
Mouse(dx, dy, 0, 0, False);
if WaitOption('uickly', 200) then
begin
MarkTime(Mark2);
repeat
Wait(10);
if TimeFromMark(Mark2) > 20000 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
until BankScreen or PinScreen;
end;
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := True;
FreeBitmap(TheCounter);
Exit;
end;
end;
Wait(100);
tol := tol + 4;
if tol >= 20 then
begin
tol := 1;
accthres := accthres - 0.1;
if accthres < 0.2 then
begin
WriteLn('Couldn''t find the bank. Exiting');
FreeBitmap(TheCounter);
Exit;
end;
end;
until TimeFromMark(Mark3) > 60000;
FreeBitmap(TheCounter);
end;

{*******************************************************************************
function OpenBankGlass(WhichBank: String; ChangeCompass, ChangeAngle: Boolean): Boolean;
By: Wizzup? and modified by Ron updated to P2p banks by N1ke!
Description: Opens the bank.
Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'akb' (Al-Kharid Bank)
'ctb' (Catherby bank)
'clt' (Camelot bank)
'nab' (North Ardougne bank)
'sab' (South Ardougne bank)
'ynb' (Yanille bank)
'ngb' (North gnome bank)
'sgb' (South gnome bank)
'wgb' (Warrior guild bank)
'fgb' (Fishing guild bank)
*******************************************************************************}
function OpenBankGlass(WhichBank: string; ChangeCompass, ChangeAngle: Boolean): Boolean;
var
OBC: TPoint;
c, Speed, Col: Integer;
begin
Speed := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if ChangeAngle then SetAngle(True);
if ChangeCompass then
begin
c := Random(2);
case WhichBank of
'feb', 'fwb', 'veb', 'ctb', 'clt', 'nab': if c = 0 then MakeCompass('N') else MakeCompass('S');
'akb', 'db', 'eb', 'vwb', 'sab', 'ynb', 'sgb', 'wgb', 'fgb': if c = 0 then MakeCompass('E') else MakeCompass('W');
'ngb': if c = 0 then MakeCompass(45) else MakeCompass(225);
end;
end;
Col := 10070458;
If (WhichBank = 'nab') or (WhichBank = 'sab')then
Col := 8095371;
if FindColorSpiralTolerance(OBC.x, OBC.y, Col, MSX1, MSY1, MSX2, MSY2, 10) then
begin
MMouse(OBC.x, OBC.y, 4, 4);
if WaitUptextMulti(['nk', 'bo', 'ot'], 200) then
begin
Mouse(OBC.x, OBC.y, 0, 0, False);
WaitOption('uickly', 200);
FFlag(0);
Wait(2000 + Random(500));
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
end;
end else
if FindObj(OBC.x, OBC.y, 'ank', 10070458, 20) then
begin
Mouse(OBC.x, OBC.y, 0, 0, False);
WaitOption('uickly', 200);
FFlag(0);
Wait(2000 + Random(500));
if (Length(Players) > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
end;
ColorToleranceSpeed(Speed);
end;

{*******************************************************************************
function OpenBankFast(Location: String): Boolean;
By: Wizzup? and Nielsie95 updated by N1ke!
Description: Opens the bank.
Valid arguments are:
'feb', 'falador east bank'
'fwb', 'falador west bank'
'veb', 'varrock east bank'
'vwb', 'varrock west bank'
'db' , 'draynor bank'
'akb', 'al-kharid bank'
'ctb', 'catherby bank'
'clt', 'camelot bank'
'nab', 'north ardougne bank'
'sab', 'south ardougne bank'
'ynb', 'yanille bank'
'ngb', 'north gnome bank'
'sgb', 'south gnome bank'
'wgb', 'warrior guild bank'
'fgb', 'fishing guild bank'
*******************************************************************************}
function OpenBankFast(Location: String): Boolean;
var
x, y, i, l, c, z: Integer;
Info: TIntegerArray;
Booths, t: TPointArray;
begin
Wait(400);
case LowerCase(Location) of
'akb', 'al kharid': Info := [MSCX, MSCY, 7969203, 25, 1];
'lb', 'lumbridge': Info := [MSCX, MSCY, 4807788, 10, 1];
'veb', 'varrock east': Info := [MSCX, MSCY, 2971236, 10, 1];
'vwb', 'varrock west': Info := [270, 270, 5689318, 25, 1];
'feb', 'falador east': Info := [MSCX, MSCY + 50, 4612728, 14, 1];
'fwb', 'falador west': Info := [MSCY, MSCY, 4612728, 14, 1];
'db', 'draynor': Info := [MSCX, MSCY, 2512235, 4, 2];
'eb', 'edgeville bank': Info := [MSCX + 50, MSCY, 3230295, 9, 2];
'ctb', 'catherby bank': Info := [MSCX, MSCY, 3239049, 8, 2];
'clt', 'camelot bank': Info := [MSCX, MSCY, 7636882, 5, 2];
'nab', 'north ardougne bank': Info := [MSCX, MSCY, 4084572, 5, 2];
'sab', 'south ardougne bank': Info := [MSCX, MSCY, 4084572, 5, 2];
'ynb', 'yanille bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'ngb', 'north gnome bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'sgb', 'south gnome bank': Info := [MSCX, MSCY, 3239049, 7, 2];
'wgb', 'warrior guild bank': Info := [MSCX, MSCY, 2578286, 7, 2];
'fgb', 'fishing guild bank': Info := [MSCX, MSCY, 2908796, 10, 2];
else
begin
srl_Warn('OpenBankFast', 'Unknown bank: '+Location, warn_AllVersions);
Exit;
end;
end;

MakeCompass('n');
z := GetColorToleranceSpeed;
ColorToleranceSpeed(Info[4]);
FindColorsSpiralTolerance(Info[0], Info[1], Booths, Info[2], MSX1, MSY1, MSX2, MSY2, Info[3]);
ColorToleranceSpeed(z);
SetArrayLength(t, 0);
t := Booths;
SetArrayLength(Booths, 0);
Booths := ReArrangeAndShortenArray(t, 14);
l := GetArrayLength(Booths) -1;
for i := 0 to l do
begin
if (not LoggedIn) or BankScreen or PinScreen then
Break;
if (LowerCase(Location) = 'vwb') or (LowerCase(Location) = 'varrock west') then
begin
Booths[i].X := Booths[i].X + 5;
Booths[i].Y := Booths[i].Y - 20;
end;
MMouse(Booths[i].X, Booths[i].Y, 3, 3);
if WaitUpText('ooth', 200) Then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
if WaitOption('uickly', 200) then
begin
FFLag(0);
MarkTime(c);
repeat
Wait(100);
until (BankScreen) or (PinScreen) or (TimeFromMark(c) > 3000);
Wait(Random(300));
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
end;
end;
end;
Result := (BankScreen) or (PinScreen);
end;

{*******************************************************************************
function OpenBank(WhichBank: String, ChangeCompass, ChangeAngle: Boolean): Boolean;
by: SRL Development Team
Description: Opens the bank if possible.
Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'akb' (Al-Kharid Bank)
'lb' (Lumbridge Bank)
'ctb' (Catherby bank)
'clt' (Camelot bank)
'nab' (North Ardougne bank)
'sab' (South Ardougne bank)
'ynb' (Yanille bank)
'ngb' (North gnome bank)
'sgb' (South gnome bank)
'wgb' (Warrior guild bank)
'fgb' (Fishing guild bank)
*******************************************************************************}

function OpenBank(WhichBank: String; ChangeCompass, ChangeAngle: Boolean): Boolean;
begin
if not BankScreen then
begin
Result := True;
if LowerCase(WhichBank) <> 'eb' then
if OpenBankFast(WhichBank) then Exit;
if LowerCase(WhichBank) <> 'lb' then
begin
if (Random(11) > 5) then
begin
if not OpenBankGlass(WhichBank, ChangeCompass, ChangeAngle) then
if not OpenBankQuiet(WhichBank) then
Result := False;
end else
begin
if not OpenBankQuiet(WhichBank) then
if not OpenBankGlass(WhichBank, ChangeCompass, ChangeAngle) then
Result := False;
end;
end;
end else
Result := True;
end;

{*******************************************************************************
function FindBank(TheBank: String): Boolean;
By: WT-Fakawi and modified by Ron Updated to P2p by N1ke!
Description: Finds and opens any given bank in the free world.
If the MM DTM is found it will find and open the bank.
Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'akb' (Al-Kharid Bank)
'ctb' (Catherby bank)
'clt' (Camelot bank)
'nab' (North Ardougne bank)
'sab' (South Ardougne bank)
'ynb' (Yanille bank)
'ngb' (North gnome bank)
'sgb' (South gnome bank)
'fgb' (Fishing guild bank)
*******************************************************************************}

function FindBank(TheBank: string): Boolean;
var
bx, by, TheDTM: Integer;
WhichAngle: Extended;
begin
TheBank := LowerCase(TheBank);
case TheBank of
'feb': TheDTM := DTMFromString('78DA63AC67626088634001FFFFFD63F80FA41' +
'9416C2060AC01AA4987C83141D5FCF9C3C4C0055503028CAD44A8' +
'E924AC0600131E11B5');
'fwb': TheDTM := DTMFromString('78DA636C676260086540038C0CFFC12403C37' +
'F206004A98986C8304155FCF9C3C4C0055503D6D14C849A6EC26A' +
'009F5A0EA1');
'db': TheDTM := DTMFromString('78DA632C6162608866400181DEDE0CFF81342' +
'310FF0702C62CA09A4454357FFE30313043D58000584D1C116AC2' +
'F0AB0100EC370F0C');
'veb': TheDTM := DTMFromString('78DA63EC61626008624001FFFFFD63F80FA41' +
'9416C2060EC00AA8982C83141D5FCF9C3C4C0055503028C138850' +
'D343580D00122211A9');
'vwb': TheDTM := DTMFromString('78DA63EC606260B066C000FF819811440301E' +
'354A01A3B88381354FECF1F260611A81A1000AB3125428D2E7E35' +
'0087F80E5E');
'akb': TheDTM := DTMFromString('78DA636C606260F06140019D9D710CFF81342' +
'310FF0702C652A01A37881C1354CD9F3F4C0C5C5035200056E345' +
'841A3FFC6A002A3B0F97');

'ctb': TheDTM := DTMFromString('78DA63CC63626008624001478F1E65F80FA41' +
'981F83F1030A602D578A0AAF9F387898119AA060418F388505344' +
'849A32C26A00FE5D12EE');
'clt': TheDTM := DTMFromString('78DA63CC67626008604001E78E1F67F80FA41' +
'981F83F10306601D5B8A2AAF9F387898119AA060418CB88505345' +
'849A3AC26A000B52130B');
'nab': TheDTM := DTMFromString('78DA63AC61626008654001135A8B19FE03694' +
'620FE0F048C454035B1A86AFEFC61626086AA0101C66A22D47400' +
'D5C4E057030045F20FE7');
'sab': TheDTM := DTMFromString('78DA632C656260086040017DCD850CFF81342' +
'310FF0702C63AA09A6454357FFE30313043D58000584D180135F5' +
'40359EF8D500003F560FC7');
'ynb': TheDTM := DTMFromString('78DA632C60626008654001E78E1F67F80FA41' +
'981F83F10305601D5F8A2AAF9F387898119AA0604182B31CDC1AA' +
'260ABF1A009CFB108C');
'ngb': TheDTM := DTMFromString('78DA632C66626008654001FFFFFF67F80FA41' +
'921ECFF8CB94035B1A86AFEFC61626086AA0101C632C26A00AD6D' +
'0E64');
'sgb': TheDTM := DTMFromString('78DA632C606260086640038C0CFFC12403C37' +
'F20604C05AA894255F1E70F130333540D5807484D18116AFCF0AB' +
'01006D100DF4');

'fgb': TheDTM := DTMFromString('78DA632C626260F0654001F5311E0CFF81342' +
'310FF0702C64CA01A1754357FFE30313043D58000588D27116A02' +
'8950138A5F0D0041A911BD');
else
begin
srl_Warn('FindBank', 'Invalid bank name', warn_Warning);
Exit;
end;
end;

Result := False;
if FindDtmRotated(TheDTM, bx, by, MMX1, MMY1, MMX2, MMY2, Radians(-30), Radians(30), 0.05, WhichAngle) then
begin
Mouse(bx, by, 0, 0, True);
FFlag(0);
Wait(300+Random(400));
Result := OpenBank(TheBank, False, False);
end;
FreeDTM(TheDTM);
end;

{*******************************************************************************
function OpenDepositBox : Boolean;
by: Shuttleu
Description: Opens the deposit box.
*******************************************************************************}

function OpenDepositBox : Boolean;
var
X, Y, T:integer;
begin
If(not(LoggedIn)) then exit;
begin
if FindObjTPA(x, y, 739167, 10, -1, 30, 30, 200, ['deposit']) then
begin
GetMousePos(X, Y);
Mouse(x, y, 0, 0, True);
Result := True;
T :=0
repeat
Inc(T);
Wait(500+random(500));
until (DepositScreen) or (T>=30);
end else
Writeln('Could not find the deposit box');
end;
end;

Naike

2009-07-01 18:54:14

New GameTab.scar

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » GameTab Routines I --//
//-----------------------------------------------------------------//
// * function GetCurrentTab: Integer; // * by Wizzup?
// * function TabExists(TabNumber: Integer): Boolean; // * by Flyboy
// * function GameTab(tabnumber: Integer): Boolean; // * by Starblaster100 & Nava2
// * function SetFightMode(oFightMode: Integer): Boolean; // * by Nielsie95
// * function SetCombatType(Kind: String): Boolean; // * by Narcle & Nava2
// * function GetCombatLevel: Integer; // * by Nielsie95
// * procedure Retaliate(AutoRet:Boolean); // * By WT-Fakawi & n3ss3s
// * function SkillCoords(row, column: Integer): TPoint; // * by RsN
// * function SkillToCoords(Skill: Variant): TPoint; // * by Masquerader, Cheesehunk, Raymond, Wizzup? & ZephyrsFury
// * function GetSkillInfo(Skill: Variant; Amount: Boolean): Integer; // * by Raymond
// * function GetSkillLevel(Skill: Variant): Integer; // * by Raymond
// * function GetMMLevels: integer; // * by Raymond
// * function GetXP(Skill: Variant): Integer; // * by Nielsie95
// * function XpTillNextLevel(Skill: Variant): Integer; // * by Nielsie95
// * function HpPercent: Integer; // * by Wizzup?
// * procedure GetAllLevels; // * by WT-Fakawi
// * function CurrentWorld: Integer; // * by Cheesehunk and modified by Ron
// * function EquipmentCoords(i : Integer) : TPoint; // * by RsN
// * function GetEquippedItemBounds(Which: String): TBox; // * by Nava2
// * procedure MouseEquippedItem(Which : String; Left : Integer); // * by Nava2
// * function WearingItem(i: Integer): Boolean; // * by RsN
// * procedure TakeOff(i: Integer); // * by RsN
// * function CheckEquipItems(number: Integer): Boolean; // * by SDcit
// * function SetRun(run: Boolean: Boolean; // * by Wizzup? and EvilChicken!
// * function RunEnergy(Min: Integer): Boolean; // * by lordsaturn
// * function SetRest: Boolean; // * by ZephyrsFury
// * function RestUntil(Energy: Integer): Boolean; // * by ZephyrsFury
// * procedure SetGraphics(Brightness: Integer; vl, rr, gd, td, id, fl, gt, cs: string); // * by ZephyrsFury
// * procedure SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) ); // * by ZephyrsFury
// * procedure SetBar(Brightness, Volume, SFX, Area: Integer); // * by ZephyrsFury
// * procedure DoEmote(EmoteNumber: Integer); // * by Sumilion

//****************************************************************************//

// * GameTab 1 = Fightmode
// * GameTab 2 = Statistic
// * GameTab 3 = Quest
// * GameTab 4 = Inventory (see Inventory.scar)
// * GameTab 5 = Wield
// * GameTab 6 = Prayer
// * GameTab 7 = Mage
// * GameTab 8 = Add Friend
// * GameTab 9 = Del Friend
// * GameTab 10 = ClanChat
// * GameTab 11 = Run/Tools
// * GameTab 12 = Emotes
// * GameTab 13 = Music
// * GameTab 14 = LogOut
// * GameTab 15 = Summoning

//****************************************************************************//

type
TSMSetting = (Stereo, Mono, NoChange);

Function InStrArrEx(S: String; StrArr: TStringArray; Var Where: Integer): Boolean; forward;
function CloseWindow: Boolean; forward;
function ClickContinue(Click, Wait: Boolean): Boolean; forward;
function ChooseOption(Txt: string): Boolean; forward;
{ const GameTab Constants;
Description: Constants representing gametab numbers. }
const
tab_Combat = 1;
tab_Stats = 2;
tab_Quest = 3;
tab_Inv = 4;
tab_Equip = 5;
tab_Prayer = 6;
tab_Magic = 7;
tab_Friends = 8;
tab_Ignore = 9;
tab_Clan = 10;
tab_Options = 11;
tab_Emotes = 12;
tab_Music = 13;
tab_Logout = 14;
tab_Summoning = 15;

{*******************************************************************************
function GetCurrentTab: Integer;
By: Wizzup?
Description: Returns current tab
*******************************************************************************}
function GetCurrentTab: Integer;
var
b: Boolean;
begin
b := False;
for Result := 1 to 15 do
begin
case Result of
1: b := (GetColor(543, 178) = 1580634);
2: b := (GetColor(570, 179) = 1778795);
3: b := (GetColor(604, 174) = 1910385);
4: b := (GetColor(632, 172) = 1910385);
5: b := (GetColor(666, 182) = 1647204);
6: b := (GetColor(699, 177) = 1910385);
7: b := (GetColor(735, 177) = 1778795);
8: b := (GetColor(569, 471) = 1910385);
9: b := (GetColor(598, 471) = 1910385);
10: b := (GetColor(633, 478) = 1778795);
11: b := (GetColor(668, 476) = 1778795);
12: b := (GetColor(703, 481) = 1580634);
13: b := (GetColor(740, 471) = 1778795);
14: b := (GetColor(555, 275) = 2070783);
15: b := (GetColor(533, 475) = 1581150);
end;
if b then
Exit;
end;
Result := 0;
end;

{*******************************************************************************
function TabExists(TabNumber: Integer): Boolean;
By: Flyboy
Description: Returns true if tab exists.
Very useful for tutorial Is. as well as a simple double check to make sure
your fully logged in.
*******************************************************************************}

function TabExists(TabNumber: Integer): Boolean;
begin
case TabNumber of
1: Result := (GetColor(533, 177) = 65536);
2: Result := (GetColor(565, 175) = 65536);
3: Result := (GetColor(609, 175) = 1052688);
4: Result := (GetColor(638, 174) = 65536);
5: Result := (GetColor(670, 176) = 65536);
6: Result := (GetColor(708, 171) = 65536);
7: Result := (GetColor(740, 175) = 65536);
8: Result := (GetColor(575, 474) = 65536);
9: Result := (GetColor(605, 474) = 65536);
10: Result := (GetColor(640, 472) = 65536);
11: Result := (GetColor(680, 472) = 65536);
12: Result := (GetColor(710, 470) = 65536);
13: Result := (GetColor(735, 473) = 65536);
14: Result := (GetColor(743, 1) = 65536);
15: Result := (GetColor(537, 477) = 65536);
end;
end;


{*******************************************************************************
function GameTab(tabnumber: Integer): Boolean;
By: Starblaster100 & Nava2
Description: Switches between tabs.
*******************************************************************************}
function GameTab(tabnumber: Integer): Boolean;
var
c: Integer;
Coords: TPoint;
begin
if not InRange(TabNumber, 1, 15) then
begin
srl_Warn('GameTab', IntToStr(tabnumber) + ' is not a valid GameTab', warn_AllVersions);
Result := False;
Exit;
end;
if not TabExists(tabnumber) then
begin
srl_Warn('GameTab', IntToStr(tabnumber) + ' does not exist', warn_Notice);
Result := False;
Exit;
end;
case TabNumber of
1..7: Coords := Point(540 + ((tabnumber -1) * 33), 185);
14: Coords := Point(752, 12);
15: Coords := Point(538, 485);
else
Coords := Point(540 + ((tabnumber mod 7) * 33), 485);
end;
Result := (GetCurrentTab = TabNumber);
if not Result then
begin
Mouse(Coords.x, Coords.y, 8, 8, True);
while not Result and (c < 4) do
Begin
Wait(RandomRange(100, 200));
Result := (GetCurrentTab = tabnumber);
Inc(c);
end;
end;
end;

//****************************************************************************//
// * GameTab 1 Related Functions.
//****************************************************************************//
{*******************************************************************************
function SetFightMode(oFightMode: Integer): Boolean;
By: Nielsie95, Quickmarch, Timer, and Nava2
Description: Sets fight mode. Returns false if failed to set desired mode.
*******************************************************************************}

function SetFightMode(oFightMode: Variant): Boolean;
var
i, x, y, r: Integer;
b: TBox;
cmbBoxes: array of TBox;
strs: array of array of String;
begin
Result := False;
if not(Loggedin)then Exit;
GameTab(1);
Wait(200 + Random(777));

cmbBoxes := [IntToBox(575, 255, 630, 290), IntToBox(660, 255, 710, 290), IntToBox(575, 310, 630, 345), IntToBox(660, 310, 710, 345)];
strs := [TStringArray(['attack', 'att']), TStringArray(['strength', 'str']), TStringArray(['controlled', 'control', 'ctrl', 'multi']), TStringArray(['defence', 'def', 'defense'])];
case VarType(oFightMode) of
3: begin b := cmbBoxes[Integer(oFightMode) - 1]; r := oFightMode; end;
256: for x := 0 to 3 do
begin
i := High(strs[x]);
for y := 0 to i do
if Lowercase(oFightMode) = strs[x][y] then
begin
b := cmbBoxes[x];
r := x + 1;
Break;
end;
if b.x1 <> 0 then Break;
end;
end;
i := 0;
while (i < 4) do
begin
Result := FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2);
if (Result) then Exit;
Mouse(RandomRange(b.x1, b.x2), RandomRange(b.y1, b.y2), 0, 0, True);
Wait(500 + Random(300));
Inc(i);
end;
if (not Result) and (r = 4) then
SetFightMode(3);
end;

{*******************************************************************************
function SetCombatType(Kind : string): Boolean;
By: Narcle & Nava2
Description: Sets Combat mode inputted into Kind, treat like UpText.
*******************************************************************************}
function SetCombatType(Kind : string): Boolean;
var
x, y, i, ii, T: integer;
Xarr, Yarr: array of integer;
TB: TBox;
TP: TPointArray;
begin
Xarr := [595, 680, 595, 680];
Yarr := [270, 270, 325, 325];
GameTab(1);
for i := 0 to 3 do
begin
MMouse(Xarr[i], Yarr[i], 12, 12);
T := GetSystemTime + 3000;
repeat
Wait(200);
if GetSystemTime > T then
Exit;
until FindColor(x, y, 10551295, 540, 205, 750, 465);
wait(200);
GetClientDimensions(TB.X2, TB.Y2);
TB := IntToBox(0, 0, TB.X2, TB.Y2);
FindColorsTolerance(TP, 10551295, TB.X1, TB.Y1, TB.X2, TB.Y2, 0);
if Length(TP) = 0 then
Exit;
TB := GetTPABounds(TP);
TB.Y1 := TB.Y1 + 1;
for ii := 0 to 3 do
begin
Result := Pos(Kind, LowerCase(GetTextAtEx(TB.X1 + 1, TB.Y1, 0, SmallChars, False, True, 0, 1, - 1, 30, False, tr_AlphaNumericChars))) <> 0;
if Result then
begin
Result := SetFightMode(I + 1);
Exit;
end;
TB.Y1 := TB.Y1 + 13;
end;
end;
end;

{*******************************************************************************
function GetCombatLevel: Integer;
By: Nielsie95
Description: Returns the players combat level.
*******************************************************************************}
function GetCombatLevel: Integer;
var
x, y: Integer;
begin
Gametab(1);
Wait(100 + Random(100));
if IsTextInAreaEx(590, 225, 690, 245, x, y, 'Combat', 0, StatChars, False, False, 0, 2, 2070783) then
Result := StrToIntDef(Trim(GetTextAtEx(x, y, 0, StatChars, False, False, 0, 2, 2070783, 20, True, tr_Digits)), -1);
end;

{*******************************************************************************
procedure Retaliate(RetTrue: Boolean);
By: WT-Fakawi & n3ss3s, slight mod by EvilChicken!
Description: Set's Auto Retaliate ON of OFF.
*******************************************************************************}

procedure Retaliate(RetTrue: Boolean);
Var
X, Y: Integer;
Begin
GameTab(1);
If RetTrue Xor FindColor(X, Y, 1777020, 624, 385, 719, 396) Then
MouseBox(624, 385, 719, 396, 1);
End;

//****************************************************************************//
// * GameTab 2 Related Functions.
//****************************************************************************//

{ const Skill Constants;
Description: Constants representing player skills. }
const
skill_Attack = 1;
skill_Strength = 2;
skill_Defence = 3;
skill_Range = 4;
skill_Prayer = 5;
skill_Magic = 6;
skill_Runecrafting = 7;
skill_Hitpoints = 8;
skill_Agility = 9;
skill_Herblore = 10;
skill_Thieving = 11;
skill_Crafting = 12;
skill_Fletching = 13;
skill_Slayer = 14;
skill_Mining = 15;
skill_Smithing = 16;
skill_Fishing = 17;
skill_Cooking = 18;
skill_Firemaking = 19;
skill_Woodcutting = 20;
skill_Farming = 21;
skill_Construction = 22;
skill_Hunting = 23;
skill_Summoning = 24;

{*******************************************************************************
function SkillCoords(row, column: Integer): TPoint;
By: RsN fixed by dark sniper and fixed by Raymond
Description: Returns Coords of Skill's Row and Column (Used for GetSkill functions)
*******************************************************************************}

function SkillCoords(row, column: Integer): TPoint;
begin
case Column of
1: Result.x := 577;
2: Result.x := 631;
3: Result.x := 687;
end;
case row of
1: Result.y := 228;
2: Result.y := 260;
3: Result.y := 293;
4: Result.y := 324;
5: Result.y := 356;
6: Result.y := 388;
7: Result.y := 420;
8: Result.y := 419;
end;
end;

{*******************************************************************************
function SkillToCoords(ScrollDownIfNeeded : Boolean; skill: string): TPoint;
By: Masquerader, Cheesehunk, Raymond, Wizzup? & ZephyrsFury
Description: Turns skill string into tpoint.
If Scroll returns true then you must scroll down.
*******************************************************************************}

function SkillToCoords(ScrollDownIfNeeded : Boolean; skill: Variant): TPoint;
var
Scroll: Boolean;
CX, CY, Col, skNo: Integer;
ScrollP : TPoint;
SkillS: string;
SkillArr: TStringArray;
begin
if (not(LoggedIn)) then Exit;

if (VarType(Skill) = 11) then
SkillS := IntToStr(Skill)
else
SkillS := Lowercase(Skill);

case Lowercase(SkillS) of
'hp': SkillS := 'hitpoints';
'ranged': SkillS := 'range';
'hunter': SkillS := 'hunting';
end;

SkillArr := ['attack', 'strength', 'defence', 'range', 'prayer', 'magic', 'runecrafting',
'hitpoints', 'agility', 'herblore', 'thieving', 'crafting', 'fletching',
'slayer', 'mining', 'smithing', 'fishing', 'cooking', 'firemaking',
'woodcutting', 'farming', 'construction', 'hunting', 'summoning'];
if (GetNumbers(SkillS) = SkillS) and (InRange(StrToIntDef(GetNumbers(SkillS), -1), 1, Length(SkillArr))) then
skNo := StrToInt(SkillS) - 1
else
if (not(InStrArrEx(SkillS, SkillArr, skNo))) then
begin
srl_Warn('SkillToCoords', 'Invalid Skill Name/Number: ''' + Skill + '''', warn_AllVersions);
Exit;
end;

if (InRange(skNo + 1, 1, 21)) then
begin
CX := skNo div 7 + 1;
CY := skNo mod 7 + 1;
end else
begin
CX := skNo mod 3 + 1;
CY := skNo div 3 + 1;
end;

Result := SkillCoords(CY, CX);

Scroll := (ScrollDownIfNeeded) and (InRange(skNo + 1, 21, 24));
ScrollP := Point(724, 240 + 194 * Integer(Scroll));
Col := 1316634 - 658704 * Integer(Scroll);
GameTab(2);

if (GetColor(ScrollP.X, ScrollP.Y) <> Col) then
begin
MMouse(ScrollP.X, ScrollP.Y + 10 * (2 * Integer(Scroll) - 1), 5, 5);
GetMousePos(CX, CY);
HoldMouse(CX, CY, True);
while (GetColor(ScrollP.X, ScrollP.Y) <> Col) and (GetColor(724, 239) = 657930) do
Wait(500 + Random(500));
ReleaseMouse(CX, CY, True);
end;
end;

{*******************************************************************************
function GetSkillInfo(skill: Variant; Amount : Boolean): Integer;
By: Raymond
Description: Gets the amount / level of a skill.
E.G.
0/15
Amount = True will return 0.
Amount = False will return 15 (The actual level).
*******************************************************************************}

function GetSkillInfo(skill: Variant; Amount : Boolean): Integer;
var
TP: TPoint;
Box : TBox;
TPA : TPointArray;
Cts : Integer;
begin
GameTab(2);
TP := SkillToCoords(True,skill);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(0);
if not Amount then
TP := Point(TP.x + 7,TP.y + 13);
FindColorsTolerance(TPA,65535,TP.x - 2,TP.y - 2, TP.x + 15,TP.y + 15,0);
Box := GetTPABounds(TPA);
Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1-2, Box.y1 -1, 100,
StatChars, False, True, 0, 5,65535, 2, True, tr_Digits)),0);
ColorToleranceSpeed(CTS);
end;

{*******************************************************************************
Function GetSkillLevel(skill: Variant): Integer;
By: Raymond
Description: Gets the max level for a particular skill.
*******************************************************************************}

Function GetSkillLevel(skill: Variant): Integer;
Begin
Result := GetSkillInfo(skill, False);
End;

{*******************************************************************************
Function GetMMLevels(LevelType : String;var ColorSign : String): integer;
By: Raymond / Wizzup
Description: Returns the level shown next to the minimap.
Colorsign returns the color of the text (Green,Yellow,Orange,Red).
Returns -1 if failed.
*******************************************************************************}

Function GetMMLevels(LevelType : String; var ColorSign : String): integer;
var
TP : TPoint;
I: Integer;
Colors : TIntegerArray;
P: TPointArray;
B: TBox;
Signs : TStringArray;
begin;
Result := -1;
ColorSign := '';
Case LowerCase(Leveltype) of
'health','hp','hitpoints' : TP := Point(729,29);
'prayer','pray' : TP := Point(746,68);
'run','energy' : TP := Point(740,107);
else
begin;
srl_Warn('GetMMLevels', 'Invalid LevelType: ''' + LevelType + '', warn_AllVersions);
Exit;
end;
end;
Colors := [65280,65535,2070783,255];
Signs := ['Green','Yellow','Orange','Red'];
For I := 0 to 3 do
Begin
FindColorsTolerance(P, Colors[I], TP.X - 5, TP.Y - 5, TP.X + 40, TP.Y + 20, 0);
If Length(P) < 1 Then
Continue;
B := GetTPABounds(P);
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1 , B.Y1 - 1, 0, statChars,
False, False, 0, 4, Colors[I], 20, False, tr_Digits)), 1);
ColorSign := Signs[I];
End;
end;

{*******************************************************************************
function GetXP(Skill: Variant): Integer;
By: Nielsie95
Description: Returns current xp for a skill. Returns -1 if failed.
*******************************************************************************}

function GetXp(skill: Variant): Integer;
var
p: TPoint;
i, tx, ty, x, y: Integer;
begin
Result := -1;
if (not LoggedIn) or (not TabExists(2)) then Exit;
GameTab(2);
if (GetCurrentTab <> 2) then Exit;
p := SkillToCoords(True,Skill);
if (p.x < 1) then Exit;
MMouse(p.x, p.y +5, 12, 4);
while (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) and (i < 50) do
begin
Wait(100);
Inc(i);
end;
Wait(200 + Random(150));
if (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) then Exit;
if IsTextInAreaEx(x, y, x + 60, y + 60, tx, ty, 'urrent', 0, SmallChars, False, False, 0, 1, 0) then
Result := StrToIntDef(GetNumbers(GetTextAtEx(tx, ty, 0, SmallChars, False, True, 0, 1, 0, 50, False, tr_AllChars)), -1);
end;

{*******************************************************************************
function XpTillNextLevel(Skill: Variant): Integer;
By: Nielsie95
Description: Returns current xp til you level up in a skill.
Returns -1 if failed.
*******************************************************************************}

function XpTillNextLevel(Skill: Variant): Integer;
var
p: TPoint;
i, tx, ty, x, y: Integer;
begin
Result := -1;
if (not LoggedIn) or (not TabExists(2)) then Exit;
GameTab(2);
if (GetCurrentTab <> 2) then Exit;
p := SkillToCoords(True,Skill);
if (p.x < 1) then Exit;
MMouse(p.x, p.y +5, 12, 4);
while (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) and (i < 50) do
begin
Wait(100);
Inc(i);
end;
Wait(200 + Random(150));
if (not FindColor(x, y, 10551295, MIX1, MIY1, MIX2, MIY2)) then Exit;
if IsTextInAreaEx(x, y, x + 60, y + 60, tx, ty, 'ainder', 0, SmallChars, False, False, 0, 1, 0) then
Result := StrToIntDef(GetNumbers(GetTextAtEx(tx, ty, 0, SmallChars, False, True, 0, 1, 0, 50, False, tr_AllChars)), -1);
end;

{*******************************************************************************
function HpPercent: Integer;
By: Wizzup?
Description: Returns Hp left as a percentage.
If The HP level is set, it does not switch tabs.
*******************************************************************************}

function HPPercent: Integer;

Var
ColorString: String;
Begin
If Players[CurrentPlayer].Level[8] < 1 Then
Players[CurrentPlayer].Level[8] := Max(1, GetSkillInfo('hitpoints', False));

Result := Round(GetMMLevels('hp', ColorString) * 100 / Players[CurrentPlayer].Level[8]);
End;

{****************************************************************************//
procedure GetAllLevels;
By: WT-Fakawi & ZephyrsFury
Description: Sets all 21 skilllevels to Players.Level[21]

* 1 8 15
* 2 9 16
* 3 10 17
* 4 11 18
* 5 12 19
* 6 13 20
* 7 14 21
* 22 23 24

* 1 = attack
* 2 = strength
* 3 = defence
* 4 = range
* 5 = prayer
* 6 = magic
* 7 = runecrafting
* 8 = hitpoints
* 9 = agility
* 10 = herblore
* 11 = thieving
* 12 = crafting
* 13 = fletching
* 14 = slayer
* 15 = mining
* 16 = smithing
* 17 = fishing
* 18 = cooking
* 19 = firemaking
* 20 = woodcutting
* 21 = farming
* 22 = construction
* 23 = hunting
* 24 = summoning
*******************************************************************************}

procedure GetAllLevels;
var
II: Integer;
begin
try
for II := 1 to High(Players[CurrentPlayer].Level) do
Players[CurrentPlayer].Level[II] := GetSkillLevel(II);
except
srl_Warn('GetAllLevels', 'Could not get all skill levels!', warn_AllVersions);
end;
end;

{procedure GetAllLevels;
begin
try
Players[CurrentPlayer].level[1] := GetSkillInfo('attack',False);
Players[CurrentPlayer].level[2] := GetSkillInfo('strength',False);
Players[CurrentPlayer].level[3] := GetSkillInfo('defence',False);
Players[CurrentPlayer].level[4] := GetSkillInfo('range',False);
Players[CurrentPlayer].level[5] := GetSkillInfo('prayer',False);
Players[CurrentPlayer].level[6] := GetSkillInfo('magic',False);
Players[CurrentPlayer].level[7] := GetSkillInfo('runecrafting',False);
Players[CurrentPlayer].level[8] := GetSkillInfo('hitpoints',False);
Players[CurrentPlayer].level[9] := GetSkillInfo('agility',False);
Players[CurrentPlayer].level[10] := GetSkillInfo('herblore',False);
Players[CurrentPlayer].level[11] := GetSkillInfo('thieving',False);
Players[CurrentPlayer].level[12] := GetSkillInfo('crafting',False);
Players[CurrentPlayer].level[13] := GetSkillInfo('fletching',False);
Players[CurrentPlayer].level[14] := GetSkillInfo('slayer',False);
Players[CurrentPlayer].level[15] := GetSkillInfo('mining',False);
Players[CurrentPlayer].level[16] := GetSkillInfo('smithing',False);
Players[CurrentPlayer].level[17] := GetSkillInfo('fishing',False);
Players[CurrentPlayer].level[18] := GetSkillInfo('cooking',False);
Players[CurrentPlayer].level[19] := GetSkillInfo('firemaking',False);
Players[CurrentPlayer].level[20] := GetSkillInfo('woodcutting',False);
Players[CurrentPlayer].level[21] := GetSkillInfo('farming',False);
Players[CurrentPlayer].level[22] := GetSkillInfo('construction', False);
Players[CurrentPlayer].level[23] := GetSkillInfo('hunting', False);
Players[CurrentPlayer].level[24] := GetSkillInfo('summoning', False);
except
WriteLn('Could not get all skill levels');
Exit;
end;
end;

//****************************************************************************//
// * GameTab 4 Related Functions. SEE ALSO INVENTORY.SCAR
//****************************************************************************//

//****************************************************************************//
// * GameTab 5 Related Functions.
//****************************************************************************//

{*******************************************************************************
function EquipmentCoords(i : Integer) : TPoint;
By: RsN modded by WT-Fakawi and Nielsie95
Description: Returns X and Y of the coordinates of the specified equipment item
*******************************************************************************}

function EquipmentCoords(i: Integer): TPoint;
begin
case i of
1: Result := IntToPoint(640, 225);
2: Result := IntToPoint(600, 266);
3: Result := IntToPoint(640, 266);
4: Result := IntToPoint(684, 266);
5: Result := IntToPoint(588, 304);
6: Result := IntToPoint(644, 304);
7: Result := IntToPoint(700, 304);
8: Result := IntToPoint(642, 343);
9: Result := IntToPoint(588, 384);
10: Result := IntToPoint(643, 384);
11: Result := IntToPoint(700, 384);
end;
end;

{*******************************************************************************
function GetEquippedItemBounds(Which: String): TBox;
By: Nava2
Description: Returns TBox of eqquipped item in which.
*******************************************************************************}

function GetEquippedItemBounds(Which: String): TBox;
var
P : TPoint;
I : Byte;
begin
case Lowercase(Which) of
'1', 'helm', 'helmet' :
I := 1;
'2', 'cape' :
I := 2;
'3', 'amulet', 'neck', 'necklace' :
I := 3;
'4', 'arrows', 'bolts' :
I := 4;
'5', 'right hand', 'weapon' :
I := 5;
'6', 'plate', 'chest', 'platebody' :
I := 6;
'7', 'left hand', 'sheild' :
I := 7;
'8', 'legs', 'platelegs', 'skirt', 'plateskirt' :
I := 8;
'9', 'gloves', 'gauntlets' :
I := 9;
'10', 'ring' :
I := 10;
else
begin
SRL_Warn('GetEquiptItemBounds', 'Invalid entry.', Warn_AllVersions);
Result := IntToBox(0, 0, 0, 0);
Exit;
end;
end;
P := EquipmentCoords(I);
Result := IntToBox(P.x - 11, P.y - 11, P.x + 11, P.y + 11);
end;

{*******************************************************************************
procedure MouseEquippedItem(Which : String; Left : Integer);
By: Nava2
Description: Mouses Equipped item like MouseItem.
*******************************************************************************}
procedure MouseEquippedItem(Which : String; Left : Integer);

var
B : TBox;

begin
B := GetEquippedItemBounds(Which);
if (B.x1 = 0) and (B.x2 = 0) then Exit;
GameTab(5);
MouseBox(B.x1, B.y1, B.x2, B.y2, Left);
end;

{*******************************************************************************
function WearingItem(i: Integer): Boolean;
By: RsN
Description: Results True if an item is equiped at i
*******************************************************************************}

function WearingItem(i: Integer): Boolean;
var
x, y:Integer;
T: TPoint;
begin
GameTab(5);
T := EquipmentCoords(i);
If FindColor(x, y, 65536, T.x - 8, T.y - 8, T.x + 8, T.y + 8 ) then
Result := True;
end;

{*******************************************************************************
procedure TakeOff(i: Integer);
By: RsN
Description: UnEquips Item specified in i.
*******************************************************************************}

procedure TakeOff(i: Integer);
var
T: TPoint;
begin
GameTab(5);
T := EquipmentCoords(i);
if (WearingItem(i)) then
begin
Mouse(T.x, T.y, 5, 5, True);
Wait(200 + Random(100));
end;
end;

{*******************************************************************************
function CheckEquipItems(number: Integer): Boolean;
By: SDcit
Description: Sees if there are number items equiped and returns true if yes.
*******************************************************************************}
function CheckEquipItems(number: Integer): Boolean;
var
CheckCoords: Integer;
x: integer;
begin
x := 0;
for CheckCoords := 1 to 11 do
begin
if WearingItem(CheckCoords) then
Inc(x);
end;
Result := x > number;
if not Result then
SRL_Warn('CheckEquipItems', 'You have more than ' + IntToStr(number) +' items equiped. Currently have '
+ IntToStr(x) + ' equipped.', Warn_AllVersions);
end;

//****************************************************************************//
// * GameTab 6 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 7 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 8 Related Functions.
//****************************************************************************//

{*******************************************************************************
function CurrentWorld: Integer;
By: Cheesehunk, Ron and fixed by ZephyrsFury
Description: Returns the current world you are on.
*******************************************************************************}
function CurrentWorld: Integer;
var
TextX, TextY: Integer;
begin
Result := -1;
GameTab(8);
Wait(RandomRange(50, 100));
if (IsTextInAreaEx(635, 205, 727, 226, TextX, TextY, 'RuneSca', 0, SmallChars, False, False, 0, 0, -1)) then
Result := StrToIntDef(Trim(GetTextAtEx(TextX + 65, TextY, 0, SmallChars, True,
False, 0, 0, -1, 3, False, tr_AllChars)), -1);
if (Result = -1) then
SRL_Warn('CurrentWorld', 'Could not get Current World.', Warn_AllVersions);
end;

//****************************************************************************//
// * GameTab 9 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 10 Related Functions.
//****************************************************************************//

//****************************************************************************//
// * GameTab 11 Related Functions.
//****************************************************************************//
{*******************************************************************************
function SetRun(Run: Boolean): Boolean;
By: Wizzup? & EvilChicken!
Description: Sets Run on or off.
*******************************************************************************}

function SetRun(Run: Boolean): Boolean;
Begin
if (CountColorTolerance(5753055, 715, 105, 731, 110, 30) +
CountColorTolerance(514811, 715, 105, 731, 110, 30) > 10) xor (Run) then
begin
Mouse(715, 95, 10, 10, True);
Result := True;
end;
End;

{*******************************************************************************
function RunEnergy(Min: Integer): Boolean;
By: lordsaturn
Description: Toggles run if energy is greater or equal to MinEnergy. Results
true if energy is greater or equal to minimum.
*******************************************************************************}

function RunEnergy(Min: Integer): Boolean;
var
t: String;
begin
Result := (GetMMLevels('run', t) >= Min);
if (Result) then SetRun(True);
end;

{*******************************************************************************
function SetRest: Boolean;
By: ZephyrsFury
Description: Turns Rest on. Result True if successful.
*******************************************************************************}

function SetRest: Boolean;
var
T: Integer;
begin
if (CountColor(3777879, 713, 107, 732, 115) < 10) then
begin
Mouse(715, 95, 10, 10, False);
if (WaitOption('Rest', 200)) then
begin
T := GetSystemTime;
while (CountColor(3777879, 713, 107, 732, 115) < 10) and (GetSystemTime - T < 5000) do
Wait(100);
Result := (CountColor(3777879, 713, 107, 732, 115) > 10);
end;
end;
end;

{*******************************************************************************
function RestUntil(Energy: Integer): Boolean;
By: ZephyrsFury
Description: Rests until your Run energy is above Energy. Results True if
successful.
*******************************************************************************}

function RestUntil(Energy: Integer): Boolean;
var
S: string;
begin
Result := True;
if (GetMMLevels('run', S) >= Energy) then Exit;
SetRest;
while (GetMMLevels('run', S) < Energy) do
begin
Result := (CountColor(3777879, 713, 107, 732, 115) > 10);
if (not(Result)) then Exit;
Wait(1000 + Random(1000));
end;
end;

{*******************************************************************************
procedure SetGraphics(Brightness: Integer; vl, rr, gd, td, id, fe, gt, cs: string);
By: ZephyrsFury
Description: Sets graphic options through the Graphics Screen in GameTab 11.
Use: Enter the desired Setting for the desired Option. Leave as '' for no change

Parameter Option Setting
vl Visible Levels Current / All
rr Remove Roofs Always / Selectively
gd Ground Decoration Off / On
td Texture Detail Low / High
ia Idle Animations Few / Many
fe Flickering Effects Off / On
gt Ground Textures Few / Many
cs Character Shadows Off / On
1 2 3 4
Brightness: <---o---o---o---o--->

EG. SetGraphics(2, 'current', '', 'off', 'low', 'few', '', 'few', 'off');
For Autoing: SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
*******************************************************************************}

procedure SetGraphics(Brightness: Integer; vl, rr, gd, td, ia, fe, gt, cs: string);
var
Settings, PosSettings, OptionName, tArr: TStringArray;
TB: TBox;
II, Tx, Ty, Col, Where: Integer;
P: TPoint;
begin
if (not(LoggedIn)) then Exit;
CloseWindow;
if (not(FindColor(Tx, Ty, 0, 7, 460, 69, 474))) then
if (not(ClickContinue(True, True))) then
Mouse(MMCX, MMCY, 2, 2, True);
II := 0;
while (CountColor(2070753, 201, 28, 317, 46) <> 367) and (LoggedIn) do
begin
GameTab(11);
MouseBox(605, 258, 623, 277, 1);
Wait(500 + Random(200));
Inc(II);
if (II > 3) then
begin
WriteLn('Could not open Graphics Options screen.');
Exit;
end;
end;
if (not(InRange(Brightness, 0, 4))) then
srl_Warn('Login_SetGraphics', 'Brightness must be between 0 and 4', warn_AllVersions)
else
if (Brightness <> 0) then
begin
P := Point(140 + ((Brightness - 1) * 31), 185);
if (GetColor(P.x, P.y) = 65536) then
Mouse(P.x - 2, P.y - 2, 5, 5, True);
end;
PosSettings := ['Current', 'All', 'Always', 'Selectively', 'Off', 'On', 'Low',
'High', 'Few', 'Many', 'Off', 'On', 'Few', 'Many', 'Off', 'On'];
OptionName := ['Visible Levels', 'Remove Roofs', 'Ground Decoration', 'Texture Detail',
'Idle Animations', 'Flickering Effects', 'Ground Textures', 'Character Shadows'];
Settings := [vl, rr, gd, td, ia, fe, gt, cs];
for II := 0 to High(Settings) do
begin
if (Settings[II] = '') then Continue;
TB.x1 := 149 + ((II + 1) div 7) * 239;
TB.y1 := 173 + ((II + 1) mod 7) * 17;
TB.x2 := TB.x1 + 104;
TB.y2 := TB.y1 + 14;
tArr := [PosSettings[II * 2], PosSettings[II * 2 + 1]];
if (not(InStrArrEx(Capitalize(Settings[II]), tArr, Where))) then
begin
srl_Warn('SetGraphics', 'Setting: ' + Settings[II] + ' is not valid for Option: ' + OptionName[II], warn_AllVersions);
Continue;
end;
Col := Where * 16777008 + 207;
if (FindColor(Tx, Ty, Col, TB.x1, TB.y1, TB.x2, TB.y2)) then
Continue;
Mouse(TB.x1 + 10, TB.y1 + 3, 10, 5, True);
Wait(50);
if (FindColor(Tx, Ty, Col , TB.x1, TB.y2 + 1, TB.x2, TB.y2 + 1 + 51)) then
begin
Mouse(Tx, Ty, 10, 5, True);
Wait(50);
while (CountColor(16777215, 5, 5, 161, 35) > 100) do Wait(100);
end else
Mouse(TB.x1 + 10, TB.y1 + 3, 10, 5, True);
end;
Wait(500 + Random(500));
CloseWindow;
end;

{*******************************************************************************
procedure SetAudio(Volume, SFX, Area: Integer; SMSetting: (Stereo, Mono, NoChange) );
By: ZephyrsFury
Description: Sets audio options through the Audio screen in GameTab 11
Use: Enter the desired Setting AS A POINT for the desired Option. Make option 0
for no change.
1 2 3 4 5
Volume, SFX, Area: <--o---o---o---o---o-->

EG. SetAudio(1, 4, 0, Stereo);
*******************************************************************************}

procedure SetAudio(Volume, SFX, Area: Integer; SMSetting: TSMSetting);
var
Settings: TIntegerArray;
OptionName: TStringArray;
II, C, Tx, Ty: Integer;
P: TPoint;
begin
if (not(LoggedIn)) then Exit;
Settings := [Volume, SFX, Area];
OptionName := ['Volume', 'SFX', 'Area'];
C := 0;
CloseWindow;
if (not(FindColor(Tx, Ty, 0, 7, 460, 69, 474))) then
if (not(ClickContinue(True, True))) then
Mouse(MMCX, MMCY, 2, 2, True);
while (CountColor(2070753, 201, 46, 296, 65) <> 309) and (LoggedIn) do
begin
GameTab(11);
MouseBox(654, 252, 677, 278, 1);
Wait(500 + Random(200));
Inc(C);
if (C > 3) then
begin
WriteLn('Could not open Graphics Options screen.');
Exit;
end;
end;
for II := 0 to 2 do
begin
if (not(InRange(Settings[II], 0, 5))) then
begin
srl_Warn('SetAudio', IntToStr(Settings[II]) + ' is not a valid setting ' +
'for: ' + OptionName[II] + '. Must be between 0 and 5', warn_AllVersions);
Continue;
end;
if (Settings[II] = 0) then Continue;
P.x := Round(201.0 + 25.5 * (Settings[II] - 1));
P.y := Round(1.5 * II * II + 54.5 * II + 118.0);
if (GetColor(P.x, P.y) <> 16777215) then
Mouse(P.x - 6, P.y, 0, 5, True);
Wait(10);
end;
if (GetColor(238, 268) = 181) and (SMSetting = Stereo) then
Mouse(302, 265, 7, 7, True)
else
if (GetColor(305, 268) = 181) and (SMSetting = Mono) then
Mouse(235, 265, 7, 7, True);
Wait(500 + Random(500));
CloseWindow;
end;

{*******************************************************************************
procedure SetBar(Brightness, Volume, SFX, Area: Integer);
By: ZephyrsFury
Description: Sets each bar to the specific point. 1-4 for Brightness, 1-5 for
others. For no change in the value make the respective parameter 0.
*******************************************************************************}

procedure SetBar(Brightness, Volume, SFX, Area: Integer);
var
Settings: TIntegerArray;
Names: TStringArray;
II, K: Integer;
begin
Settings := [Brightness, Volume, SFX, Area];
Names := ['Brightness', 'Volume', 'SFX', 'Area'];
for II := 0 to 3 do
begin
K := 5 - Integer(II = 0);
if (not(InRange(Settings[II], 0, K))) then
begin
srl_Warn('SetBar', 'Setting: ' + IntToStr(Settings[II]) + ' is not valid for Bar: ' + Names[II] + '.', warn_AllVersions);
Settings[II] := 0;
end;
end;
SetGraphics(Settings[0], '', '', '', '', '', '', '', '');
Wait(100 + Random(500));
SetAudio(Settings[1], Settings[2], Settings[3], NoChange);
end;

//****************************************************************************//
// * GameTab 12 Related Functions.
//****************************************************************************//

{*******************************************************************************
procedure DoEmote(EmoteNumber: Integer);
By: Sumilion
Description: Clicks on an emote specified by EmoteNumber (1 to 37)
*******************************************************************************}

procedure DoEmote(EmoteNumber: Integer);
var
row, X1, Y1, X2, Y2, Others: Integer;
begin
if (not(InRange(EmoteNumber, 1, 37))) then
begin
srl_Warn('DoEmote', 'Invalid EmoteNumber: ' + IntToStr(EmoteNumber) + ', Valid Emotes: 1..37', warn_AllVersions);
Exit;
end;
GameTab(12);
if (EmoteNumber > 20) then
begin
if (GetColor(734, 442) = 1777699) then
Mouse(734, 442, 10, 10, True);
Others := 10;
end else if (GetColor(733, 224) = 1777699) then
Mouse(733, 224, 10, 10, True);
if (EmoteNumber > 4) then
begin
repeat;
row := row + 1;
EmoteNumber := EmoteNumber - 4;
until (EmoteNumber <= 4) or (row = 10)
end;
if (row >= 5) then
row := row - 5;
EmoteNumber := EmoteNumber - 1;
X1 := 554 + (43 * EmoteNumber);
Y1 := 211 + (49 * row) + Others;
X2 := 592 + (43 * EmoteNumber);
Y2 := 257 + (49 * row) + Others;
MouseBox(X1 + 10, Y1 + 10, X2 - 10, Y2 - 10, 1);
end;

New Inventory.scar

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Inventory Routines --//
//-----------------------------------------------------------------//
// * function GetInven(Inven : Integer) : TInvenItem; // * Sky Scripter
// * function GetInventoryArray : array of TInvenItem; // * Sky Scripter
// * function InvBox(i :Integer): TBox; // * WT-Fakawi / Wizzup?
// * function ItemCoords(i: Integer): TPoint; // * by RsN
// * Function CoordsToItem(x,y : integer) : Integer; // * by Raymond
// * Function GetInvItemBounds(InvSpot: Integer; T: TBox): Boolean; // * by Wizzup?
// * procedure MMouseItem(i: Integer); // * by WT-Fakawi
// * procedure MouseItem(i: Integer; left: Boolean); // * by WT-Fakawi
// * procedure DragItem(inv1, inv2: Integer); // * by RsN
// * function ExistsItem(i: Integer): Boolean; // * by RsN
// * function InvCount: Integer; // * by RsN
// * function InvEmpty: Boolean; // * by WT-Fakawi
// * function InvFull: Boolean; // * by RsN
// * function CountItems(identifier: Integer; identifiertype: string; tol: TIntegerArray): Integer; // * by WT-Fakawi / Sumilion
// * function ClickAllItemsExcept(identifier: Integer; identifiertype, option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer; // * by WT-Fakawi / Sumilion & Nava2
// * function ClickAllItems(identifier: Integer; identifiertype, option: string; waitnum: Integer; tol: TIntegerArray):Integer; // * by Nava2
// * procedure DropItem(i: Integer); // * by Lorax
// * procedure DropAll; // * by Lorax
// * procedure ArrangeInv; // * by Cheesehunk


{ type TInvenItem;
Description: Holds data regarding an inventory item }
type
TInvenItem = record
Width, Height : Integer; // the width and height of the item
Count : Integer; // the count of the item
ItemBox : TBox; // the exact box around the item
CenterPoint: TPoint; // the center point inside the item
ExistsItem : Boolean; // to define the item Exists
end;

function CountItemsIn(area, ItemType: string; Item: Integer; Tol: TIntegerArray): Integer; forward;
function FindItemEx(var x, y: Integer; IdentType: string; Ident: Integer; Area: TBox; Tol: TIntegerArray): Boolean; forward;

{*******************************************************************************
function GetInven(Inven : Integer) : TInvenItem;
By: SKy Scripter
Description: Returns The Width, Height, Count, ItemBox and CenterPoint of the
Given Item Slot.
*******************************************************************************}

function GetInven(Inven : Integer) : TInvenItem;
var
Slot, Row, Ix, Iy, I, Cx, Cy: Integer;
P : TPointArray;
MinP, MaxP : TPoint;
begin
Inven := Inven - 1;
Slot := Inven mod 4;
Row := Inven div 4;
IX := 560 + (Slot * 42);
IY := 210 + (Row * 36);
FindColorsTolerance(P, 65536, IX, IY, IX + 41, IY + 35, 0);
Result.Count := Length(P);
if (Result.Count = 0) then Exit;
Result.ExistsItem := True;
MinP := P[0];
MaxP := P[Result.Count-1];
Cx := P[0].x + P[Result.Count-1].x;
Cy := P[0].y + P[Result.Count-1].y;
for I := 1 to Result.Count - 2 do
begin
if (P[i].x < MinP.x) then MinP.x := P[i].x;
if (P[i].y < MinP.y) then MinP.y := P[i].y;
if (P[i].x > MaxP.x) then MaxP.x := P[i].x;
if (P[i].y > MaxP.y) then MaxP.y := P[i].y;
Cx := Cx + P[i].x;
Cy := Cy + P[i].y;
end;
Cx := Cx / Result.Count;
Cy := Cy / Result.Count;
Result.CenterPoint := Point(Cx, Cy);
Result.Width := MaxP.x - MinP.x;
Result.Height := MaxP.y - MinP.y;
Result.ItemBox := PointToBox(MinP, MaxP);
end;

{*******************************************************************************
function GetInventoryArray : array of TInvenItem;
By: SKy Scripter
Description: Returns The Width, Height, Count, ItemBox and CenterPoint
in array [0..27] of all Items in the inventory.
*******************************************************************************}

function GetInventoryArray : array of TInvenItem;
var
i : Integer;
begin
SetArrayLength(Result, 28);
for i := 0 to 27 do
Result[i] := GetInven(i + 1);
end;

{*******************************************************************************
Function InvBox(i :Integer): TBox;
By: WT-Fakawi/Wizzup?
Description: Returns TBox of surrounding Inventory SlotBox
1-2-3-4
5-6-7-8
etc.
*******************************************************************************}

Function InvBox(i :Integer): TBox;
var
row, col: Integer;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
row :=i mod 4; if row = 0 then row := 4;
col := i / 4 ; if i mod 4 <> 0 then Inc(col);
Result.x1 := 518 + (row * 42); // First X coord - 42 - 5 for proper Tbox
Result.y1 := 172 + (col * 36); // First Y coord - 36 - 5 for proper Tbox
Result.x2 := 560 + (row * 42);
Result.y2 := 210 + (col * 36);
end;

{*******************************************************************************
function ItemCoords(i: Integer): TPoint;
By: RsN
Description: Returns X and Y of Specified Inventory Spot
*******************************************************************************}
function ItemCoords(i: Integer): TPoint;
var
Box: TBox;
begin
Box := InvBox(i);
Result.X := (Box.X1 + Box.X2) Shr 1;
Result.Y := (Box.Y1 + Box.Y2) Shr 1;
end;

{*******************************************************************************
Function CoordsToItem(x,y : integer) : Integer;
By: Raymond
Description: Returns the invetory spot at x and y.
If x or y are incorrect it returns 0.
*******************************************************************************}
Function CoordsToItem(x,y : integer) : Integer;
var
TP : TPoint;
begin;
result := 0;
if not (InRange(x, MIX1, MIX2) and InRange(y, MIY1, MIY2)) then
begin
srl_Warn('CoordsToItem', 'Point not in Inventory', warn_AllVersions);
Exit;
end;
TP.x := x - 560;
TP.y := y - 208;
Result := TP.x div 42 + 1;
Result := Result + (TP.y div 36) * 4;
end;

{*******************************************************************************
Function GetInvItemBounds(InvSpot: Integer; T: TBox): Boolean;
By: Wizzup?
Description: If item exists, returns TBox of the item, else returns the normal InvBox.
*******************************************************************************}
Function GetInvItemBounds(InvSpot: Integer; Var T: TBox): Boolean;
Var
TPA: TPointArray;
Begin
GameTab(4);
T := InvBox(InvSpot);
FindColorsTolerance(TPA, 65536, T.x1, T.y1, T.x2, T.y2, 0);
If Length(TPA) = 0 Then
Begin
Result := False;
T := InvBox(InvSpot);
Exit;
End;
Result := True;
T := GetTPABounds(TPA);
End;

{*******************************************************************************
procedure MMouseItem(i: Integer);
By: WT-Fakawi
Description: Moves mouse to specified inventory spot
*******************************************************************************}

procedure MMouseItem(i: Integer);
var
TB: TBox;
begin
GameTab(4);
GetInvItemBounds(I, TB);
MouseBox(TB.X1 + 4, TB.Y1 + 4, TB.X2 - 4, TB.Y2 - 4, 3);
end;

{*******************************************************************************
procedure MouseItem(i: Integer; left: Boolean);
By: WT-Fakawi
Description: Moves Mouse to invin spot then clicks left or right
*******************************************************************************}

procedure MouseItem(i: Integer; left: Boolean);
var
x, y: integer;
begin
MMouseItem(i);
GetMousePos(x, y);
Mouse(x, y, 0, 0, left);
end;

{*******************************************************************************
procedure DragItem(inv1, inv2: Integer);
By: RsN
Description: Drags Item from first position Inv1 to Inv2 (Inventory Slots)
*******************************************************************************}

procedure DragItem(inv1, inv2: Integer);
var
x, y: Integer;
begin
MMouseItem(Inv1);
GetMousePos(x, y);
HoldMouse(x, y, True);
Wait(150 + Random(50));
MMouseItem(Inv2);
GetMousePos(x, y);
ReleaseMouse(x, y, True);
Wait(100 + Random(100));
MMouse(x, y, 2, 2)
end;

{*******************************************************************************
function ExistsItem(i: Integer): Boolean;
By: WT-Fakawi
Description: Checks if item in inventory at specified position exists
*******************************************************************************}

function ExistsItem(i: Integer): Boolean;
var
x, y:Integer;
TB: TBox;
begin
GameTab(4);
TB := InvBox(i);
Result := FindColor(x, y, 65536, TB.x1 + 5, TB.y1 + 5, TB.x2 - 5, TB.y2 - 5);
end;

{*******************************************************************************
Function InvCount: Integer;
By: RsN
Description: Returns amount of items in your inventory
*******************************************************************************}

function InvCount: Integer;
var
i: Integer;
begin
GameTab(4);
Result := 0;
for i := 1 to 28 do
if (ExistsItem(i)) then
Inc(Result);
end;

{*******************************************************************************
function InvEmpty: Boolean;
By: WT-Fakawi
Description: Returns True if inventory is empty
*******************************************************************************}

function InvEmpty: Boolean;
Var
x, y: integer;
begin
GameTab(4);
Result := not FindColor(x, y, 65536, MIX1, MIY1, MIX2, MIY2);
end;

{*******************************************************************************
function InvFull: Boolean;
By: n3ss3s
Description: Returns True if inventory is full
*******************************************************************************}

Function InvFull: Boolean;
Begin
Result := InvCount = 28;
End;

{*******************************************************************************
function CountItems(Identifier: Integer; ItemType: string; tol: TIntegerArray): Integer;
By: WT-Fakawi / Sumilion
Description: Counts Items in the inventory.
ItemType - 'dtm', 'bitmap', 'bitmap mask', 'color'
Item - name/value of your dtm/bmp/color/bmpmask.
Tol - 'dtm' - [] (dtm's can't have tolerance).
'bmp' - [BMPTol].
'color' - [COLOUR Tol, Colour Count].
'bmpmask' - [BMPTol, ContourTol].
*******************************************************************************}

function CountItems(Identifier: Integer; ItemType: string; tol: TIntegerArray): Integer;
begin
GameTab(4);
Result := CountItemsIn('inv', ItemType, Identifier, Tol);
end;

{*******************************************************************************
function ClickAllItemsExcept(Identifier: Integer; ItemType, option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer;
By: WT-Fakawi / Sumilion & Nava2
Description: Performs "option" popup menu action on all items with:
ItemType - 'dtm', 'bitmap', 'bitmap mask', 'color'
Item - name/value of your dtm/bmp/color/bmpmask.
Tol - 'dtm' - [] (dtm's can't have tolerance).
'bmp' - [BMPTol].
'color' - [COLOUR Tol, Colour Count].
'bmpmask' - [BMPTol, ContourTol].
Will not click items in slots SlotIgnores
*******************************************************************************}
function ClickAllItemsExcept(Identifier: Integer; ItemType, option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer;
var
i, x, y: Integer;
TB: Tbox;
arr:array of Integer;
begin
Result := 0;

arr :=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28];
for i := 1 to 28 - 4 do
Swap(arr[RandomRange(i - 1, i + 4)], arr[RandomRange(i - 1, i + 4)] );

SetLength(Tol, 2);
GameTab(4);
for i := 0 to 27 do
begin
if InIntArray(SlotIgnores, arr[i] + 1) then Continue;
TB := InvBox(arr[i]);
if ExistsItem(arr[i]) then
try
if not FindItemEx(x, y, ItemType, Identifier, TB, Tol) then Continue;
if Option <> '' then
begin
MouseItem(arr[i], False);
WaitOption(Option, waitnum);
Inc(Result);
end
else
MouseItem(arr[i], True);
Wait(waitnum);
except end;
end;
end;

{*******************************************************************************
function ClickAllItems(Identifier: Integer; ItemType, option: string; waitnum: Integer; tol: TIntegerArray):Integer;
By: Nava2
Description: See ClickAllItemsExcept, this doesn't ignore any slots.
*******************************************************************************}
function ClickAllItems(Identifier: Integer; ItemType, option: string; waitnum: Integer; tol: TIntegerArray):Integer;
begin
Result := ClickAllItemsExcept(Identifier, ItemType, option, [], waitnum, tol);
end;

{*******************************************************************************
procedure DropItem(i: Integer);
By: Lorax
Description: Drops item at given position (1-28)
*******************************************************************************}
function DropItem(i: Integer): Boolean;
begin
Result := False;
if ExistsItem(i) then
begin
MouseItem(i, False);
if (WaitOption('rop', 250)) then
begin
Result := True;
Wait(RandomRange(50, 200));
end;
end;
end;

{*******************************************************************************
procedure DropAll;
By: Lorax
Description: Drops all items
*******************************************************************************}
procedure DropAll;
var
i: Integer;
arr:array of Integer;
begin
arr :=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28];

for i := 1 to 28 - 4 do
Swap(arr[RandomRange(i - 1, i + 4)], arr[RandomRange(i - 1, i + 4)] );

for i := 0 to 27 do
DropItem(arr[i]);
end;

{*******************************************************************************
procedure ArrangeInv;
By: Cheesehunk
Description: Arrange's inventory in an orderly fashion.
*******************************************************************************}

procedure ArrangeInv;
var
InvSpace, i, c, OpenSpace: Integer;
InvSpotFull: array[1..28] of Boolean;
begin
InvSpace := InvCount;
if (InvSpace <= 0) or (InvSpace >= 28) then
Exit;
for i := 1 to 28 do
InvSpotFull[i] := ExistsItem(i);

for i := 1 to 28 do
if InvSpotFull[i] then
for c := 1 to 28 do
if not ExistsItem(c) then
begin
OpenSpace := c;
if (i > 1) and (c < i) then
begin
DragItem(i, c);
Break;
end;
end;
end;

{*******************************************************************************
Function CountItemsBlackLine(Count, Tol: Integer): Integer;
By: n3ss3s
Description: Returns the number of items in inventory with Count amount of
blackline points and Tol tolerance in the amount of points.
*******************************************************************************}

Function CountItemsBlackLine(Count, Tol: Integer): Integer;
Var
TPA: TPointArray;
I, H: Integer;
TPAA: T2DPointArray;
Begin
GameTab(2);
FindColorsTolerance(TPA, 65536, MIX1, MIY1, MIX2, MIY2, 0);
TPAA := TPAToATPAEx(TPA, 42, 36);
H := High(TPAA);
For I := 0 To H Do
If InRange(GetArrayLength(TPAA[i]), Count - Tol, Count + Tol) Then
Result := Result + 1;
End;


{*******************************************************************************
Function ClickAllItemsBlackLine(Count, Tol: Integer; Option: String): Integer;
By: n3ss3s
Description: Finds all items in inventory with blackline points amount of Count
with Tol tolerance, and returns the amount of items could choose the
option Option to. Waits the WaitT amount of millisecs between items, with
WaitR randomness of milliseconds.
*******************************************************************************}

Function ClickAllItemsBlackLine(Count, Tol, WaitT, WaitR: Integer; Option: String): Integer;
Var
TPA: TPointArray;
X, Y, Z, H: Integer;
TPAA: T2DPointArray;
Begin
GameTab(2);
FindColorsTolerance(TPA, 65536, MIX1, MIY1, MIX2, MIY2, 0);
TPAA := TPAToATPAEx(TPA, 42, 36);
H := High(TPAA);
For z := 0 To H Do
If InRange(GetArrayLength(TPAA[z]), Count - Tol, Count + Tol) Then
Begin
MiddleTPAEx(TPAA[z], X, Y);
Mouse(X, Y, 2, 2, False);
If WaitOption(Option, 250) Then
Begin
Result := Result + 1;
Wait(WaitT + Random(WaitR));
End;
End;
End;

New Mouse.scar

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Mouse Routines --//
//-----------------------------------------------------------------//
// * procedure WindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended) // * by BenLand100
// * procedure MMouse(x, y, rx, ry: integer); // * by BenLand100
// * procedure Mouse(mousex, mousey, ranx, rany: Integer; left: Boolean); // * by Mutant Squirrle
// * procedure SleepAndMoveMouse(Time: Integer); // * by RsN
// * procedure IdleTime(Time, Rand: integer; Gravity: extended); // * by BenLand100
// * function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean; // * by Nava2
// * function SpiralMouse(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: String; PpC, aInc: Integer): Boolean; // * by Nava2

var
MouseSpeed: Integer;

{$IFDEF UseLaptopMouse}
LMouse_MissChance: Integer;
{$ENDIF}

{*******************************************************************************
procedure WindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
By: Benland100
Description:
*******************************************************************************}
procedure WindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
lastX, lastY: integer;
sqrt2, sqrt3, sqrt5: extended;
begin
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
while hypot(xs - xe, ys - ye) > 1 do
begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
if (maxStep < 3) then
begin
maxStep:= random(3) + 3.0;
end else
begin
maxStep:= maxStep / sqrt5;
end;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) / 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
wait(round((maxWait - minWait) * (step / maxStep) + minWait));
lastdist:= dist;
end;
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));
end;

{*******************************************************************************
procedure MMouse(x, y, rx, ry: integer);
By: Benland100
Laptop Movement by Hobbit with help from nielsie95!
Description: Moves the mouse.
*******************************************************************************}
procedure MMouse(x, y, rx, ry: integer);
var
cx, cy: integer;
randSpeed: Extended;
{$IFDEF UseLaptopMouse}
seg, e, f, g, nx, ny, hypo: Integer;
a, b, c: Extended;
Miss: Boolean;
{$ENDIF}
begin
GetMousePos(cx, cy);
{$IFDEF UseLaptopMouse}
miss := (Random(LMouse_MissChance) = 0);
e:= 0;
a:= x - cx;
b:= y - cy;
c:= Pow(a,2) + Pow(b,2)
hypo:= Round(Sqrt(c));
case hypo of
0: Exit;
1..225: seg:=1;
226..600: seg:= Random(2) + 1;
601..1800: seg:= random(3) + 2;
else seg := 5;
end;
f := Round( a / seg);
g := Round( b / seg);
repeat
Wait(30 + random(50));
{Begin: Modified from MMouse by Benland100}
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
if randSpeed = 0.0 then
randSpeed := 0.1;
getMousePos(cx,cy);
nx:= (cx + (f * e)) + random(rx);
ny:= (cy + (g * e)) + random(ry);
{End: Modified from MMouse by Benland100}
if Miss then
begin
nx:= nx + RandomRange(rx, rx * 2);
ny:= ny + RandomRange(ry, ry * 2);
end;
WindMouse(cx,cy,nx,ny,11.0,8.0,10.0/randSpeed,12.0/randSpeed,10.0*randSpeed,10.0*randSpeed);
e:= e + 1;
until(e = seg);
GetMousePos(cx, cy);
if not PointInBox(Point(cx, cy), IntToBox(x, y, x + rx, y + ry)) then
begin
Wait(30 + random(30));
WindMouse(cx,cy,(x + random(rx)),(y + random(ry)),11.0,6.0,10.0/randSpeed,15.0/randSpeed,10.0*randSpeed,10.0*randSpeed);
end;
{$ELSE}
randSpeed:= (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
if randSpeed = 0.0 then
randSpeed := 0.1;
X := x + random(rx);
Y := y + random(ry);
WindMouse(cx,cy,x,y,9.0,3.0,10.0/randSpeed,15.0/randSpeed,10.0*randSpeed,10.0*randSpeed);
{$ENDIF}
end;
{*******************************************************************************
procedure Mouse(mousex, mousey, ranx, rany: Integer; left: Boolean);
By: Mutant Squirrle, with a small fix by hy71194
Description: Moves then clicks mouse.
*******************************************************************************}

procedure Mouse(mousex, mousey, ranx, rany: Integer; left: Boolean);
var
a, b, c: Integer;
begin
MMouse(mousex, mousey, ranx, rany);
Wait(60 + Random(30));
GetMousePos(b, c);
HoldMouse(b, c, left);
repeat
Wait(20 + Random(30));
a := a + 1;
until (a > 4);
GetMousePos(b, c);
ReleaseMouse(b, c, left);
Wait(100 + Random(100));
end;

{*******************************************************************************
procedure SleepAndMoveMouse(Time: Integer);
By: RSN
Description: Waits for specified time and moves mouse around like bored human would.
*******************************************************************************}

procedure SleepAndMoveMouse(Time: Integer);
var
Moving: Boolean;
mx, my: Integer;
x, y, xv, yv: Extended;
gx, gy: Extended;
T: Integer;
begin
GetMousePos(mx, my);
x := mx;
y := my;
if (Random(2) = 0) then
Moving := False
else
Moving := True;
gx := 130 + Random(500);
gy := 130 + Random(300);
T := GetTickCount;
repeat
Sleep(10);
if (Moving) then
begin
if (gx > x) then
xv := xv + 0.1
else
xv := xv - 0.1;
if (gy > y) then
yv := yv + 0.1
else
yv := yv - 0.1;
x := x + xv;
y := y + yv;
MoveMouse(Round(x), Round(y));
end;
if (Random(100) = 0) then
Moving := not Moving;
if (Random(30) = 0) then
begin
gx := 130 + Random(500);
gy := 130 + Random(300);
end;
until (Abs(GetTickCount - T) >= Time);
end;

{*******************************************************************************
procedure IdleTime(Time, Rand: integer; Gravity: extended);
By: BenLand100
Description: Randomly moves the mouse (Rand, and Gravity) for Time milliseconds
*******************************************************************************}

procedure IdleTime(Time, Rand: Integer; Gravity: Extended);
var
H, W, Cx, Cy, i, n, St: Integer;
Controls, Path: TPointArray;
LastC, LastP: TPoint;
begin
St := GetSystemTime;
GetClientDimensions(W, H);
SetArrayLength(Controls, 4);
GetMousePos(Cx, Cy);
LastP.x := Cx;
LastP.y := Cy;
LastC.x := LastP.x + (Random(Rand * 2) - Rand)
LastC.y := LastP.y + (Random(Rand * 2) - Rand)
repeat
Controls[0].x := LastP.x;
Controls[0].y := LastP.y;
Controls[1].x := LastP.x + -(LastC.x - LastP.x);
Controls[1].y := LastP.y + -(LastC.y - lastP.y);
Controls[2].x := Controls[1].x + (Random(Rand * 2) - Rand);
Controls[2].y := Controls[1].y + (Random(Rand * 2) - Rand);
Controls[3].x := Controls[2].x + (Random(Rand * 2) - Rand);
Controls[3].x := Controls[3].x + Round(-(Controls[3].x - (W / 2)) *
(Gravity));
Controls[3].y := Controls[2].y + (Random(Rand * 2) - Rand);
Controls[3].y := Controls[3].y + Round(-(Controls[3].y - (H / 2)) *
(Gravity));
LastC.x := Controls[2].x;
LastC.y := Controls[2].y;
LastP.x := Controls[3].x;
LastP.y := Controls[3].y;
Path := MakeSplinePath(Controls, 0.01);
Path := MidPoints(Path, 5);
n := GetArrayLength(Path);
for i := 0 to n - 1 do
begin
MoveMouse(Path[i].x, Path[i].y);
Wait(Random(2) + 2);
if (GetSystemTime - St >= Time) then Break
end;
until (GetSystemTime - St >= Time)
end;

function IsUpTextMultiCustom(Text: TStringArray): Boolean;Forward;
Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean;Forward;

{*******************************************************************************
function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean;
By: Nava2
Description: Spirals the mouse in a circle from the center of the defined box.
It will continue to spiral until it finds a spiral completely outside
the box, always skipping points outside.
Returns the occurance of the first occurance of UpText into fx, fy.
Takes multiple UpTexts as a TStringArray.
PpC: The number of pixels to increase per spiral.
aInc: The number of stops to make around each spiral.
Takes some testing to get the right combination of PpC and aInc.
*******************************************************************************}
function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean;
var
aStep, a, rStep, rV, oB: Extended;
pX, pY, ms: Integer;
sP: TPoint;
L2R: Boolean;
begin
Result := False;
ms := MouseSpeed;
MouseSpeed := 25 + RandomRange(-3, 3);
sP := MiddleTPA([Point(x1, y1), Point(x2, y2)]);
aStep := Pi / (aInc / 2);
a := 0;
rStep := (PpC / aInc);
L2R := Random(2) = 0;
//Writeln('aStep: ' + FloatToStr(aStep) + ' rStep ' + FloatToStr(rStep));
repeat
rV := rV + rStep;
pX := Round(rV * cos(a)) + sP.x;
pY := Round(rV * sin(a)) + sP.y;
if L2R then
a := a + aStep
else
a := a - aStep;
if InRange(pX, x1, x2) and InRange(pY, y1, y2) then
begin
oB := 0;
MMouse(pX - 2, pY - 2, 5, 5);
if WaitUptextMulti(UpText, 100+Random(60)) then
begin
GetMousePos(fx, fy);
Result := True;
end;
end else
oB := oB + aStep;
until Result or (oB > (2 * Pi));
MouseSpeed := ms;
end;

{*******************************************************************************
function SpiralMouse(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: String; PpC, aInc: Integer): Boolean;
By: Nava2
Description: Spirals the mouse in a circle from the center of the defined box.
It will continue to spiral until it finds a spiral completely outside
the box, always skipping points outside.
Returns the occurance of the UpText into fx, fy.
PpC: The number of pixels to increase per spiral.
aInc: The number of stops to make around each spiral.
Takes some testing to get the right combination of PpC and aInc.
*******************************************************************************}
function SpiralMouse(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: String; PpC, aInc: Integer): Boolean;
begin
Result := SpiralMouseMulti(fx, fy, x1, y1, x2, y2, [UpText], PpC, aInc);
end;

New Object.scar

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » ObjectFinding Routines --//
//-----------------------------------------------------------------//

// » function FindAllObjsRecord(var Objects: TPointArray; AutoInfo: TAutoColorInfo; // * By Sumilion
// x1, y1, x2, y2: Integer; QuickSorting, RGBXYZCheck: Boolean): Boolean;
// » function FindObjRecordEx(var fx, fy: Integer; AutoInfo: TAutoColorInfo; QuickSorting, // * By Sumilion
// RGBXYZCheck: Boolean): Boolean;
// » function FindObjRecord(var fx, fy: Integer; AutoInfo: TAutoColorInfo): Boolean; // * By Sumilion
// » function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol, // * By Starblaster100
// CenterX, CenterY: Integer; Step: Extended; xs, ys, xe, ye: Integer): Boolean;
// » function FindObj(var cx, cy: Integer; Text: string; Color, Tol: Integer): Boolean; // * By Starblaster100
// » function FindObjCustom(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; // * By Starblaster100
// Tol: Integer): Boolean;
// » function FindObjectDeformed(var ObjX, ObjY :integer; UpText1, UpText2: String; BMP, // * By WT-Fakawi
// a, b, c, d: integer): Boolean;
// » function FindObjTPA(Var x, y: Integer; color, tol, cts, ObjWidth, ObjHeight, // * by Wizzup
// minCount: Integer; UpText: string): Boolean;
// » function FindObjTPAMulti(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, // * by Wizzup
// minCount :Integer; UpText: tstringarray): Boolean;

{*******************************************************************************
function FindAllObjsRecord(var Objects: TPointArray; AutoInfo: TAutoColorInfo; x1, y1, x2, y2: Integer; QuickSorting, RGBXYZCheck: Boolean): Boolean;
By: Sumilion
Description: Finds an Object using a TAutoColorInfo record, returns the center of the found objects.
*******************************************************************************}

function FindAllObjsRecord(var Objects: TPointArray; AutoInfo: TAutoColorInfo; x1, y1, x2, y2: Integer; QuickSorting, RGBXYZCheck: Boolean): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
i, j, arL, arL2, tmpCTS: Integer;
R, G, B: Integer;
X, Y, Z: Extended;
arLC: Integer;
begin
with AutoInfo do
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(HueMod, SatMod);

if not(FindColorsTolerance(arP, Color, x1, y1, x2 - 3, y2 - 3, LumTol)) then
begin
//Writeln('Failed to find the object.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

Result := True;

if RGBXYZCheck then
begin
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);

for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);

if (R >= MinR) and (R <= MaxR) and (G >= MinG) and (G <= MaxG) and (B >= MinB) and (B <= MaxB) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= MinX) and (X <= MaxX) and (Y >= MinY) and (Y <= MaxX) and (Z >= MinZ) and (Z <= MaxZ) then
begin
SetLength(arAP, arL2 + 1);
for j := 0 to arL2 do
if (arUC[i] = arC[j]) then
begin
arAP[arLC] := arP[j];
Inc(arLC);
end;
SetLength(arAP, arLC);
end;
end;
end;
end else
arAP := arP;

if QuickSorting then
ararP := TPAtoATPA(arAP, MaxDist)
else
ararP := SplitTPA(arAP, MaxDist);

arL := High(ararP);
SetLength(Objects, arL + 1);
arLC := 0;

for i := 0 to arL do
begin
if (Length(ararP[i]) < MinCount) then Continue;
if (Length(ararP[i]) > MaxCount) and (MaxCount > 0) then Continue;
Objects[arLC] := MiddleTPA(ararP[i]);
Inc(arLC);
end;
SetLength(Objects, arLC);

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;

{*******************************************************************************
function FindObjRecordEx(var fx, fy: Integer; AutoInfo: TAutoColorInfo; QuickSorting, RGBXYZCheck: Boolean): Boolean;
By: Sumilion
Description: Finds an Object using a TAutoColorInfo record with extra options.
*******************************************************************************}

function FindObjRecordEx(var fx, fy: Integer; AutoInfo: TAutoColorInfo; x1, y1, x2, y2: Integer; QuickSorting, RGBXYZCheck: Boolean): Boolean;
var
arP: TPointArray;
i, arL: Integer;
begin
with AutoInfo do
begin
if FindAllObjsRecord(arP, AutoInfo, x1, y1, x2, y2, QuickSorting, RGBXYZCheck) then
begin
SortTPAFrom(arP, Point(MSCX, MSCY));
arL := High(arP);

for i := 0 to arL do
begin
if (Distance(arP[i].x, arP[i].y, MSCX, MSCY) > MaxDistCenter) and (MaxDistCenter > 0) then Continue;
MMouse(arP[i].x, arP[i].y, 5, 5);
Wait(100 + Random(100));
if (IsUpText(UpText) and (UpText <> '')) or
(IsUpTextMultiCustom(UpTextMulti) and (Length(UpTextMulti) > 0)) then
begin;
Result := True;
Break;
end;
end;

if (i = arL + 1) then
begin
//Writeln('FindObjRecord could not find the object.');
Exit;
end;

GetMousePos(fx, fy);
end;
end;
end;

{*******************************************************************************
function FindObjRecord(var fx, fy: Integer; AutoInfo: TAutoColorInfo): Boolean;
By: Sumilion
Description: Finds an Object using a TAutoColorInfo record.
*******************************************************************************}

function FindObjRecord(var fx, fy: Integer; AutoInfo: TAutoColorInfo): Boolean;
begin
Result := FindObjRecordEx(fx, fy, AutoInfo, MSX1, MSY1, MSX2, MSY2, False, True);
end;

{*******************************************************************************
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
By: Starblaster100
Description: Searches for an object using an array of colors and texts within the area
you specify. Will start searching from the middle and returns true if found.
Parameters:
cx, cy: Coordinate Position of object if result is true
Text: Array of string you want to search for
Color: Array of colors you want to search for
Tol: Tolerance of the colors you will allow
Step: How big you want to make the search squares. 50 = Default. 30-70 Recommended
xs, ys, xe, ye: Bounds you want to search in
*******************************************************************************}

function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
var
CurX, CurY, a, b, c, i: Integer;
Start: Boolean;
begin
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorSpiralTolerance(cx, cy, color[b], xs, ys, xe, ye, Tol)) then
begin
Start := True;
Break;
end;
end;
if (Start) then
begin
CurX := Round((xs + xe) div 2);
CurY := Round((ys + ye) div 2) - Step;
i := 1;
repeat
for c := 1 to i do
begin
case a of
0: begin //To allow for beginning offset and loop
a := a + 1;
i := 0;
CurY := CurY + Step;
end;
1: CurX := CurX + Step;
2: CurY := CurY - Step;
3: CurX := CurX - Step;
4: CurY := CurY + Step;
end;
if (CurX >= xs) and (CurX <= xe) and (CurY >= ys) and (CurY <= ye) then
begin
try
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorTolerance(cx, cy, Color[b], CurX-(Step/2), CurY-(Step/2), CurX+(Step/2), CurY+(Step/2), Tol)) then
begin
MMouse(cx, cy, 3, 3);
If (WaitUptextMulti(Text, 75+Random(50))) then
begin
GetMousePos(cx, cy);
Result := True;
Exit;
end;
end;
end;
except
end;
end;
end;
a := a + 1;
if a mod 5 = 0 then a := 1;
if (a = 1) or (a = 3) then i := i + 1;
until (Result) or ((CurX > xe) and (CurY > ye))
end;
end;

{*******************************************************************************
function FindObj(var cx, cy: Integer; Text: string; Color, Tol: Integer): Boolean;
By: Starblaster100
Description: Finds Object
*******************************************************************************}

function FindObj(var cx, cy: Integer; Text: string; Color: Integer; Tol: Integer): Boolean;
begin
Result := FindObjEx(cx, cy, [Text], [Color], Tol, 50, MSX1, MSY1, MSX2, MSY2);
end;

{*******************************************************************************
function FindObjCustom(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol: Integer): Boolean;
By: Starblaster100
Description: Finds Object with custom amount of colors and custom amount of Uptext
Example: FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5);
*******************************************************************************}

function FindObjCustom(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol: Integer): Boolean;
begin
Result := FindObjEx(cx, cy, Text, Color, Tol, 50, MSX1, MSY1, MSX2, MSY2);
end;

{*******************************************************************************
function FindObjectDeformed(var ObjX, ObjY: Integer; UpText1, UpText2: String; BMP, a, b, c, d: Integer): Boolean;
By: WT-Fakawi
Description: Finds Object in Box a,b,c,d, specified by BitMap and Uptext1 or Uptext2
Returns coords in ObjX and ObjY.
Uses Deformed Bitmap. FindObjectDeformed will gradually lower Tol and reduce Accuracy.
Functon can cause severe Lag when using bitmaps bigger then 16 pixels. Works but Lags.
*******************************************************************************}

function FindObjectDeformed(var ObjX, ObjY: Integer; UpText1, UpText2: string;
BMP, a, b, c, d: Integer): Boolean;
var
acc, ref: Extended;
XT, YT, times, tol: Integer;
begin
ref := 0.9;
tol := 0;
for times := 1 to 50 do
begin
FindDeformedBitmapToleranceIn(BMP, XT, YT, a, b, c, d, tol, 2, True, acc);
if (acc >= ref) then
begin
MMouse(XT, YT, 0, 0);
if (WaitUptextMulti([UpText1, UpText2], 400+Random(400))) then
begin
ObjX := XT;
ObjY := YT;
Result := True;
Exit;
end;
end;
if times mod 5 = 0 then
begin
ref := ref - 0.1;
tol := tol + 10;
end;
Wait(1);
end;
end;

{*******************************************************************************
function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray): Boolean;
By: Wizzup?
Description: Finds object using WizzyPlugin functions.
Starts with a Spiral from x and y.
Put in the color, Tolerance and ColorToleranceSpeed.
If you don't know what colortolerancespeed to choose, put in -1.
ObjWidth and ObjHeight are the parameters TPAToATPAEx uses, thus filtering
the MS's FindColorsSpiralTolerance points in boxes defined by
ObjWidth and ObjHeigth.
minCount is the amount of colors it should at least find in a Object box.
UpText, is ofcourse the text the object should have. In the Multi variant the
UpText is a string array.

*******************************************************************************}

function FindObjTPA(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: TStringArray): Boolean;
var
I, j, tCTS: Integer;
myPoint: TPoint;
Points: TPointArray;
aPoints: T2DPointArray;
s: string;
begin
Result := False;
if not LoggedIn then exit;
tCTS := GetColorToleranceSpeed;
if CTS * 9 mod 3 <> 0 then
CTS := 1;
ColorToleranceSpeed(CTS);
FindColorsSpiralTolerance(X, Y, Points, Color, MSX1, MSY1, MSX2, MSY2, Tol);
if Length(Points) = 0 then
begin
ColorToleranceSpeed(tCTS);
Exit;
end;
ColorToleranceSpeed(1);
aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
SetLength(Points, 0);
for I := 0 to High(aPoints) do
begin
if Length(aPoints[I]) < minCount then
Continue;
myPoint := MiddleTPA(aPoints[I]);
MMouse(myPoint.X, myPoint.Y, 0, 0);
Wait(100 + Random(50));
s := RS_GetUpText;
for j := 0 to High(UpText) do
if Pos(uptext[j], s) > 0 then
begin
GetMousePos(X, Y);
Result := True;
ColorToleranceSpeed(tCTS);
Exit;
end;
end;
ColorToleranceSpeed(tCTS);
end;

MylesMadness

2009-07-01 19:17:03

wow, that's a lot of changing…

n3ss3s

2009-07-01 20:05:40

But doesn't this just save the one line used for Wait ?

EvilChicken!

2009-07-01 20:12:59

From: n3ss3s
But doesn't this just save the one line used for Wait ?


It speeds up functions and saves quite some time, especially with all these combined. It waits until it finds the uptext and then exits, instead of waiting the entire ~300 ms and then checking for the uptext.

Apparently, it also makes the functions less detectable.

Tickyy

2009-07-01 20:16:09

wow, the next revision is going to be a bomb :p.

Nice work n1ke.

Naike

2009-07-01 20:27:31

Thanks people, glad you liked it.

And Markus have now showed me the art of Diff, so every future update by me
will be with Diff.

Gu3st...

2009-07-01 22:32:44

Wow, you do alot of work here for us… Do you get any kind of payment or something?
I'm sure the staff can figure out something ;) *hint hint*

Home

2009-07-02 00:12:02

Well done matey and loads of cookies for you!
~Home

Harry

2009-07-02 00:43:25

Tasty cake. :D

Rubix

2009-07-02 00:55:36

wow? that is one heck of a lot of changes.

cycrosism

2009-07-02 05:25:39

Very nice work. REP++

Nava2

2009-07-02 20:38:15

Saves me the effort.

Thanks for doing that! :) I ended up changing A LOT more functions than just the ones you did ;)

Wizzup?

2009-07-04 13:59:59

From: EvilChicken!
It speeds up functions and saves quite some time, especially with all these combined. It waits until it finds the uptext and then exits, instead of waiting the entire ~300 ms and then checking for the uptext.

Apparently, it also makes the functions less detectable.


Well, I'm not sure about this. If you keep constantly checking for the uptext, then waiting a little bit, SCAR will use much more CPU, because it will constantly check for the uptext rather than once. Also, humans don't normally instantly click as soon as the up text appears. So it won't be less (or more) detectable.

Good idea, but I'm not sure if I like it. I like it more when SRL uses less CPU :)

EvilChicken!

2009-07-04 15:27:21

From: Wizzup?
Well, I'm not sure about this. If you keep constantly checking for the uptext, then waiting a little bit, SCAR will use much more CPU, because it will constantly check for the uptext rather than once. Also, humans don't normally instantly click as soon as the up text appears. So it won't be less (or more) detectable.

Good idea, but I'm not sure if I like it. I like it more when SRL uses less CPU :)


I meant that it would speed up the script.
For an average computer nowadays this issue of frequent uptext lookup should be no problem at all.

And, regarding the detectability, I agree with you. I only wrote that since it said so in the thread by Rasta. (Hence the "apparently".)