SRL Archive - SRL Archives

8 Functions & A Fix


Rich

2009-08-31 01:45:13

First off, the 6 functions:

{*******************************************************************************
function WaitPIN(Pin, WaitMS : Integer) : Boolean;
By: R1ch
Description: Waits maximum of WaitMS milliseconds for PINScreen, then inputs PIN
*******************************************************************************}
function WaitPIN(Pin, WaitMS : Integer) : Boolean;
var
I : Integer;

begin
if WaitFunc(@PinScreen, 20, WaitMS) then
InPin(Pin);
end;

{*******************************************************************************
function WaitBankScreen(WaitMS : Integer) : Boolean;
By: R1ch
Description: Waits maximum of WaitMS milliseconds for BankScreen
*******************************************************************************}
function WaitBankScreen(WaitMS : Integer) : Boolean;
begin
Result:= WaitFunc(@BankScreen, 20, WaitMS);
end;


{*******************************************************************************
function WaitDeposit(WaitMS : Integer) : Boolean;
By: R1ch
Description: Waits maximum of WaitMS milliseconds for DepositScreen
*******************************************************************************}
function WaitDeposit(WaitMS : Integer) : Boolean;
begin
Result:= WaitFunc(@DepositScreen, 20, WaitMS);
end;

{*******************************************************************************
function WaitScreen(WaitMS : Integer; Bank : Boolean) : Boolean;
By: R1ch
Description: Waits maximum of WaitMS milliseconds for either BankScreen, or
DepositScreen, depending on Bank.
*******************************************************************************}
function WaitScreen(WaitMS : Integer; Bank : Boolean) : Boolean;
var
I : Integer;

begin
if Bank then
Result:= WaitBankScreen(WaitMS)
else
Result:= WaitDeposit(WaitMS);
end;

{*******************************************************************************
function LevelUp : Boolean;
By: R1ch
Description: Returns true if you level up
*******************************************************************************}
function LevelUp : Boolean;
var
X, Y : Integer;

begin
if not FindColorTolerance(X, Y, 14474460, 0, 455, 75, 455) then
Result:= FindNPCChatText('gratu', Nothing);
if Result then
begin
while ClickContinue(True, True) do
Wait(50 + Random(50));
WriteLn(Players[CurrentPlayer].Name + ' leveled up');
end;
end;

{*******************************************************************************
function CountWords(Text : string) : Integer;
By: R1ch
Description: Counts the amount of words in a given string.
*******************************************************************************}
function CountWords(Text : string) : Integer;
var
T : TStringArray;

begin
Text:= Trim(Text);
T:= SRL_Explode(Text, ' ');
Result:= GetArrayLength(T);
end;

{*******************************************************************************
function TrimMulti(Text : string; Times : Integer) : string;
By: R1ch
Description: Trims all types of characters of the begin and end of Text,
multiple times, depending on Times.
*******************************************************************************}
function TrimMulti(Text : string; Times : Integer) : string;
var
I : Integer;

begin
for I:= 1 to Times do
begin
Delete(Text, 1, 1);
Delete(Text, Length(Text), Length(Text));
end;
Result:= Text;
end;

{*******************************************************************************
procedure RandomAngle(HowToEnd : Variant);
By: R1ch
Description: Randomly changes the angle of the compass. Finishes depending on
HowToEnd. 1, 'up', True = Up - 2, 'down', False = Up
Put nothing to leave it as it is.
*******************************************************************************}
procedure RandomAngle(HowToEnd : Variant);
var
Key : Byte;
B : Boolean;

begin
B:= RBoolEx(2);
if B then
Key:= 38
else
Key:= 40;
SetAngle(B);
Wait(RandomRange(500, 1000));
KeyDown(Key);
Wait(RandomRange(500, 1100));
KeyUp(Key);
Wait(RandomRange(500, 1000));
case (HowToEnd) of
1, 'up', True : SetAngle(True);
2, 'down', False : SetAngle(False);
end;
end;

I made WaitBankScreen and WaitDeposit, as well as WaitScreen because I didn't know whether people would prefer having the 2 or the 1 function.

Also the fix, which isn't really a fix. I posted this in another thread but it got no required attention.

All of the OpenBank functions which opened Edgeville bank (all of them apart from FindBank) apart from OpenBankQuiet did not have Edgeville listed in the comments, so I've added that. Also, FindBank is meant to open all F2P banks, but did not open Edgeville. I've now added Edgeville to it.

{*******************************************************************************
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)
'eb' (Edgeville 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'], 300) then
begin
Mouse(OBC.x, OBC.y, 0, 0, False);
WaitOption('uickly', 300);
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', 300);
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'
'eb' (Edgeville 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', 300) Then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
if WaitOption('uickly', 300) 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)
'eb' (Edgeville 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! Eb added by R1ch
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');
'eb' : TheDTM := DTMFromString('78DA63E4666060E0614001EF2F2832FC07D28' +
'C40FC1F0818E5800C7154355FBF426846289F51124848A3AAF9F3' +
'8709558D0490504255F3EF9F20A6395AF8D500008FCC0FE1');
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;

I tried adding Lumbridge bank, but I couldn't do it as there is only one banker, and no other possible sub-points for the DTM.

Comments?
Richard.

rogeruk

2009-08-31 01:56:05

Doesnt BankScreen; already have a wait built inside it?

Sabzi

2009-08-31 02:02:40

We got WaitFunc for those. I mean the waiting functions.

TRiLeZ

2009-08-31 03:46:38

I thought of making pin waiting and back screen waiting for srl but i thought you could just waitcolor it. So I never attempted it…
I dont really thinks it's necessary.

Sir R. M8gic1an

2009-08-31 12:55:08

WaitPin : if WaitFunc(@PinScreen, 20, 500) then InPin(Pin) ;
WaitBankScreen & WaitDeposit & WaitScreen : WaitFunc
LevelUp: I guess it could be added… will think
CountWords: I don't see any practical use, but it could be useful
Bank Stuff: I guess i'll commit t when i decide on the other ones.

~RM

Rich

2009-08-31 12:55:29

Ok, I removed WaitBankScreen, since it does have a wait in it. However, I've kept WaitPIN and WaitDeposit as DepositScreen, and InPIN and PINScreen don't have waits.

Richard

EDIT: Added WaitBankScreen and WaitScreen again since RM is interested. Modified with RM's suggestion.

Nava2

2009-09-02 08:09:34

All those wait functions are useless.. they are one line.. And the point of WaitFunc was that.

ZephyrsFury

2009-09-02 10:38:36

From: Nava2
All those wait functions are useless.. they are one line.. And the point of WaitFunc was that.


Not really useless just too simple to create separate functions for IMO.

Rich

2009-09-02 12:03:36

From: Nava2
All those wait functions are useless.. they are one line.. And the point of WaitFunc was that.


From: ZephyrsFury
Not really useless just too simple to create separate functions for IMO.


OK. They are your opinions and I accept them. What about the other functions?

Richard

ZephyrsFury

2009-09-02 12:12:37

Most of the rest are pretty nice. Thanks especially for fixing up the bank openers. :)

With LevelUp, you might want to do a quick colour check (for example of the non-existance of the player's name in the corner) before you check for text. Doing a simple find colour would be a lot faster than checking for text everytime.

RandomAngle I like, I'll add that later if I have the time.

And Da 0wner suggested using GetArrayLength and srl_Explode for CountWords. Just thought I'd pass it on to you.

Rich

2009-09-02 12:31:57

Ok. I've added a colour check to LevelUp. If it finds the colour isn't there, it will carry on with the text check. I couldn't GetColor, as the colours of the pixels vary depending on the characters in the persons name.

Also, I've changed CountWords to what you said.

Thanks,
Richard

Rich

2009-09-04 19:45:42

From: ZephyrsFury
Most of the rest are pretty nice. Thanks especially for fixing up the bank openers. :)

With LevelUp, you might want to do a quick colour check (for example of the non-existance of the player's name in the corner) before you check for text. Doing a simple find colour would be a lot faster than checking for text everytime.

RandomAngle I like, I'll add that later if I have the time.

And Da 0wner suggested using GetArrayLength and srl_Explode for CountWords. Just thought I'd pass it on to you.


Are you going to add the bank fix and the other bits you said you would?

ZephyrsFury

2009-09-04 20:34:16

I've been a bit preoccupied.

Rich

2009-09-04 20:56:22

From: ZephyrsFury
I've been a bit preoccupied.


With saving Ian? ;) Anyway, no problem. I just wanted to make sure the bank fix was getting in at the least.

ZephyrsFury

2009-09-06 10:23:23

From: R1ch
With saving Ian? ;) Anyway, no problem. I just wanted to make sure the bank fix was getting in at the least.


;)

I added LevelUp, RandomAngle and ofc your bank edits. Thanks a lot :)