SRL Archive - SRL Suggestions

FindBankChest


Spartan 117

2012-01-07 11:33:23

Correct me if I am wrong but I do not believe there is a built in banking function to find bank chests such as the one at neitiznot and other places that I can't think of at the moment. This would be awesome and I would attempt it but I don't even know where to start so that is my suggestion

onilika

2012-01-07 11:38:49

Bank chests are easy to find. You simply need to get the colour from the chest and then ClickMouse(False).

~onilika

Narcle

2012-01-07 12:35:31

Neitiznot would be difficult. Colors are VERY similar to surrounding buildings. Bank chests will have to be per script for now, there's no easy universal way to do them (as they vary so much).

Jhangir

2012-01-07 12:47:16

Findobjex

Coh3n

2012-01-07 14:15:48

From: Narcle
Neitiznot would be difficult. Colors are VERY similar to surrounding buildings. Bank chests will have to be per script for now, there's no easy universal way to do them (as they vary so much).
Why not use a case like we do for the other open bank functions? It's not like there are many bank chests to include.

Narcle

2012-01-07 14:57:23

From: Coh3n
Why not use a case like we do for the other open bank functions? It's not like there are many bank chests to include.


Would only work using ACA with cts2, and even then its not reliable. I spent 3 days getting colors for a color to cts2 it and two days later it was off already. Some chests might not be a problem due to surrounding colors being significantly different, but others wouldn't work for long.

Spartan 117

2012-01-07 20:56:15

I do currently use findobjectex for a script I'm working on there. It works very well surprisingly. I think the colors of the chest are dark enough that it differs from the surrounding colors. At least it differs enough when I try to find them. Also any bank is easy to find. I just thought it would be a cool function. On my script I didn't even use Aca for the chest and it finds it every time for the past week I've had my script so I think it might be possible

Coh3n

2012-01-08 02:19:14

Even if the function doesn't support EVERY bank chest, I still think it's a good idea.

Press Play

2012-01-15 05:49:46

I also think that having the bank chests is a good idea as Cohen said. I just finished developing a fairly accurate function that find the bank chest at Soul Wars (for my fletching script). Here's the excerpt:
function FindBankChest(var x, y: Integer): Boolean;
var
CTS, i, h: Integer;
P: TPoint;
begin
// SetAngle(SRL_ANGLE_HIGH);
case WhichBank of
LOC_SOULW: MakeCompass('W');
LOC_CASTLEW, LOC_BURTHROPE: MakeCompass('N');
end;
if not TestTPABank then
begin
Debug('Method1: Blind...');
MouseBox(290, 160, 314, 187, 3);
for i:=0 to 10 do
begin
if ( WaitUpTextMulti(['ank', 'chest'], 200) ) then
begin
Debug('Found bank using blind check!');
Result:= True;
GetMousePos(x, y);
Exit;
end;
end;
end;

Debug('Method2: TPA...');
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 0.25);

FindColorsSpiralTolerance(MSCX, MSCY, BankChest.TPA, 10198185, MSX1, MSY1, MSX2, MSY2, 21);
ColorToleranceSpeed(CTS);

BankChest.ATPA := SplitTPA(BankChest.TPA, 10);
SortATPAFrom(BankChest.ATPA, Point(MSCX, MSCY));

if ( Length(BankChest.ATPA)=0 ) then
begin
Debug('Bank chest not found.');
Result:= false;
end else
Debug('Found ' +IntToStr(Length(BankChest.ATPA))+ ' possible Bank chests?');

h:= High(BankChest.ATPA);
{
for i := 0 to h do
begin
Paint(BankChest.ATPA[i]);
SMART_DrawBoxEx(false, GetTPABounds(BankChest.TPA), clGreen);
Wait(1000);
end;
Wait(10000); } //for debugginng

for i := 0 to h do
begin
if Length(BankChest.ATPA[i])>20 then
begin
Paint(BankChest.ATPA[i]);
P := MiddleBox(GetTPABounds(BankChest.ATPA[i]));
//SMART_DrawBoxEx(false, GetTPABounds(BankChest.ATPA[i]), clGreen);
MMouse(P.x, P.y, 3, 3);
if ( WaitUpTextMulti(['ank', 'chest'], 200) ) then
begin
Result:= True;
GetMousePos(x, y);
Break;
end else
Result:= false;

if BankScreen or PinScreen then
begin
Debug('Bank is open...');
Result := True;
Exit;
end;
end;
end;
end;
My apologies as this code is very messy and probably hard to read :/ But the main idea is that I find the edge colour of the bank chest, get the TPA bounds and find the centre. The only problem with this method is that You have to have your angle set to high…

If you would like to have something similar in SRL's include, I could come back to this and modify it for you! I'd also take a look at SRL's current bank finding functions and strucure it similarly :)

jakeyboy29

2012-01-15 06:38:18

From: -daazndagger-
I also think that having the bank chests is a good idea as Cohen said. I just finished developing a fairly accurate function that find the bank chest at Soul Wars (for my fletching script). Here's the excerpt:
function FindBankChest(var x, y: Integer): Boolean;
var
CTS, i, h: Integer;
P: TPoint;
begin
// SetAngle(SRL_ANGLE_HIGH);
case WhichBank of
LOC_SOULW: MakeCompass('W');
LOC_CASTLEW, LOC_BURTHROPE: MakeCompass('N');
end;
if not TestTPABank then
begin
Debug('Method1: Blind...');
MouseBox(290, 160, 314, 187, 3);
for i:=0 to 10 do
begin
if ( WaitUpTextMulti(['ank', 'chest'], 200) ) then
begin
Debug('Found bank using blind check!');
Result:= True;
GetMousePos(x, y);
Exit;
end;
end;
end;

Debug('Method2: TPA...');
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 0.25);

FindColorsSpiralTolerance(MSCX, MSCY, BankChest.TPA, 10198185, MSX1, MSY1, MSX2, MSY2, 21);
ColorToleranceSpeed(CTS);

BankChest.ATPA := SplitTPA(BankChest.TPA, 10);
SortATPAFrom(BankChest.ATPA, Point(MSCX, MSCY));

if ( Length(BankChest.ATPA)=0 ) then
begin
Debug('Bank chest not found.');
Result:= false;
end else
Debug('Found ' +IntToStr(Length(BankChest.ATPA))+ ' possible Bank chests?');

h:= High(BankChest.ATPA);
{
for i := 0 to h do
begin
Paint(BankChest.ATPA[i]);
SMART_DrawBoxEx(false, GetTPABounds(BankChest.TPA), clGreen);
Wait(1000);
end;
Wait(10000); } //for debugginng

for i := 0 to h do
begin
if Length(BankChest.ATPA[i])>20 then
begin
Paint(BankChest.ATPA[i]);
P := MiddleBox(GetTPABounds(BankChest.ATPA[i]));
//SMART_DrawBoxEx(false, GetTPABounds(BankChest.ATPA[i]), clGreen);
MMouse(P.x, P.y, 3, 3);
if ( WaitUpTextMulti(['ank', 'chest'], 200) ) then
begin
Result:= True;
GetMousePos(x, y);
Break;
end else
Result:= false;

if BankScreen or PinScreen then
begin
Debug('Bank is open...');
Result := True;
Exit;
end;
end;
end;
end;
My apologies as this code is very messy and probably hard to read :/ But the main idea is that I find the edge colour of the bank chest, get the TPA bounds and find the centre. The only problem with this method is that You have to have your angle set to high…

If you would like to have something similar in SRL's include, I could come back to this and modify it for you! I'd also take a look at SRL's current bank finding functions and strucure it similarly :)



I think this needs to be modified to it doesnt always click nomad ;)

Press Play

2012-01-15 06:47:50

From: jakeyboy29
I think this needs to be modified to it doesnt always click nomad ;)
Ahhaah, this is a major rework on the function currently in the latest version of my fletching script ;) It works differently/much better.

I finished writing/editing some stuff in SRL. Take a look please? :)

(*
OpenBankChestEdge
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function OpenBankChestEdge(Location: String): Boolean;

Opens the bank.
Valid arguments are:
'swb', 'soul wars bank'

.. note::

Author: -daazndagger- (kept WT-Fakawi's structure)
Last Modified: 15/01/2012

Example:

.. code-block:: pascal

if OpenBankChestEdge('swb') then
Withdraw(...);
*)
function OpenBankChestEdge(Location: String): Boolean;
var
bo, i, l, c, z: Integer;
Info: TVariantArray;
Chests: TPointArray;
AChests: T2DPointArray;
UpText: TStringArray;
B: TBox;
begin
result := false;
if (not LoggedIn) then
Exit;
if BankScreen or PinScreen then
begin
Result := True;
Exit;
end;
UpText := ['Bank', 'chest', 'nk che'];
{ 0 1 2 3 4 5 6 7 8 9 10 }
case LowerCase(Location) of { Sort X Sort Y Color Tol Hue Sat Count SplitTPA? W H Compass}
'swb', 'soul wars bank': Info := [MSCX , MSCY, 10198185, 21, 0.08, 0.25, 50, True , 10, 10, 'w'];
else
begin
srl_Warn('OpenBankChestEdge', 'Unknown bank: '+Location, warn_AllVersions);
Exit;
end;
end;

MakeCompass(Info[10]);
//SetAngle(SRL_ANGLE_HIGH); //??
z := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Info[4], Info[5]);

FindColorsSpiralTolerance(Info[0], Info[1], Chests, Info[2], MSX1, MSY1, MSX2, MSY2, Info[3]);
ColorToleranceSpeed(z);
SetColorSpeed2Modifiers(0.2, 0.2);

{ Split to ATPA. }
if Info[7] then
AChests := SplitTPA(Booths, 3)
else
AChests := TPAtoATPA(Booths, 10);

Chests := [];

{ Go through ATPA. }
l := GetArrayLength(AChests) -1;
for i := 0 to l do
begin
{ Too few pixels. }
if (Length(AChests[i]) < Info[6]) then
Continue;

{ Too small TPA bounds. }
B := GetTPABounds(AChests[i]);
If ((B.X2 - B.X1) < Info[8]) Or ((B.Y2 - B.Y1) < Info[9]) Then
Continue;

Inc(bo);
SetArrayLength(Chests, bo);
Chests[bo-1] := MiddleBox(GetTPABounds(AChests[i]));

end;

SortTPAFrom(Chests, Point(Info[0], Info[1]));

l := GetArrayLength(Chests) -1;
for i := 0 to l do
begin

MMouse(Chests[i].X, Chests[i].Y, 3, 3);
if WaitUpTextMulti(UpText, 1000) Then
begin
GetMousePos(Chests[i].X, Chests[i].Y);
Case Random(4) of
0, 1, 2: Mouse(Booths[i].X, Chests[i].Y, 0, 0, mouse_left);
3: begin
Mouse(Booths[i].X, Chests[i].Y, 0, 0, mouse_right);
if not WaitOptionMulti(['Use', 'se'], 1000) then Exit;
end;
end;
FFLag(0);
MarkTime(c);
repeat
Wait(100);
until (BankScreen) or (PinScreen) or (TimeFromMark(c) > 10000);
Wait(Random(300));
if (HowManyPlayers > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
if (Result) then Exit;
end;
end;
end;

(*
OpenBankChest
~~~~~~~~~~~~~

.. code-block:: pascal

function OpenBankChest(WhichBank): Boolean;

Opens the bank if possible.
Valid arguments are:
'swb' (Soul Wars Bank)

.. note::

Author: SRL Dev Team
Last Modified: 15/01/2012

Example:

.. code-block:: pascal

if OpenBankChest('swb') then
Withdraw(...);
*)
function OpenBankChest(WhichBank: String): Boolean;
var
I: Integer;
begin
result := false;
if BankScreen then
begin
Result := True;
Exit;
end;

I := 0;
//for I := 0 to 3 do
begin
case I of
0: Result := OpenBankChestEdge(WhichBank);
end;

if Result then
Exit;
end;
end;
Anyone care to test? :p

jakeyboy29

2012-01-15 07:08:55

From: -daazndagger-
Ahhaah, this is a major rework on the function currently in the latest version of my fletching script ;) It works differently/much better.

I finished writing/editing some stuff in SRL. Take a look please? :)

(*
OpenBankChestEdge
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function OpenBankChestEdge(Location: String): Boolean;

Opens the bank.
Valid arguments are:
'swb', 'soul wars bank'

.. note::

Author: -daazndagger- (kept WT-Fakawi's structure)
Last Modified: 15/01/2012

Example:

.. code-block:: pascal

if OpenBankChestEdge('swb') then
Withdraw(...);
*)
function OpenBankChestEdge(Location: String): Boolean;
var
bo, i, l, c, z: Integer;
Info: TVariantArray;
Chests: TPointArray;
AChests: T2DPointArray;
UpText: TStringArray;
B: TBox;
begin
result := false;
if (not LoggedIn) then
Exit;
if BankScreen or PinScreen then
begin
Result := True;
Exit;
end;
UpText := ['Bank', 'chest', 'nk che'];
{ 0 1 2 3 4 5 6 7 8 9 10 }
case LowerCase(Location) of { Sort X Sort Y Color Tol Hue Sat Count SplitTPA? W H Compass}
'swb', 'soul wars bank': Info := [MSCX , MSCY, 10198185, 21, 0.08, 0.25, 50, True , 10, 10, 'w'];
else
begin
srl_Warn('OpenBankChestEdge', 'Unknown bank: '+Location, warn_AllVersions);
Exit;
end;
end;

MakeCompass(Info[10]);
//SetAngle(SRL_ANGLE_HIGH); //??
z := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Info[4], Info[5]);

FindColorsSpiralTolerance(Info[0], Info[1], Chests, Info[2], MSX1, MSY1, MSX2, MSY2, Info[3]);
ColorToleranceSpeed(z);
SetColorSpeed2Modifiers(0.2, 0.2);

{ Split to ATPA. }
if Info[7] then
AChests := SplitTPA(Booths, 3)
else
AChests := TPAtoATPA(Booths, 10);

Chests := [];

{ Go through ATPA. }
l := GetArrayLength(AChests) -1;
for i := 0 to l do
begin
{ Too few pixels. }
if (Length(AChests[i]) < Info[6]) then
Continue;

{ Too small TPA bounds. }
B := GetTPABounds(AChests[i]);
If ((B.X2 - B.X1) < Info[8]) Or ((B.Y2 - B.Y1) < Info[9]) Then
Continue;

Inc(bo);
SetArrayLength(Chests, bo);
Chests[bo-1] := MiddleBox(GetTPABounds(AChests[i]));

end;

SortTPAFrom(Chests, Point(Info[0], Info[1]));

l := GetArrayLength(Chests) -1;
for i := 0 to l do
begin

MMouse(Chests[i].X, Chests[i].Y, 3, 3);
if WaitUpTextMulti(UpText, 1000) Then
begin
GetMousePos(Chests[i].X, Chests[i].Y);
Case Random(4) of
0, 1, 2: Mouse(Booths[i].X, Chests[i].Y, 0, 0, mouse_left);
3: begin
Mouse(Booths[i].X, Chests[i].Y, 0, 0, mouse_right);
if not WaitOptionMulti(['Use', 'se'], 1000) then Exit;
end;
end;
FFLag(0);
MarkTime(c);
repeat
Wait(100);
until (BankScreen) or (PinScreen) or (TimeFromMark(c) > 10000);
Wait(Random(300));
if (HowManyPlayers > 0) then
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
if (Result) then Exit;
end;
end;
end;

(*
OpenBankChest
~~~~~~~~~~~~~

.. code-block:: pascal

function OpenBankChest(WhichBank): Boolean;

Opens the bank if possible.
Valid arguments are:
'swb' (Soul Wars Bank)

.. note::

Author: SRL Dev Team
Last Modified: 15/01/2012

Example:

.. code-block:: pascal

if OpenBankChest('swb') then
Withdraw(...);
*)
function OpenBankChest(WhichBank: String): Boolean;
var
I: Integer;
begin
result := false;
if BankScreen then
begin
Result := True;
Exit;
end;

I := 0;
//for I := 0 to 3 do
begin
case I of
0: Result := OpenBankChestEdge(WhichBank);
end;

if Result then
Exit;
end;
end;
Anyone care to test? :p


Im using your fletcher atm, ill swap this function with the existing one and post reports here!

Coh3n

2012-01-16 15:09:42

Looks good daazndagger, though I recommend using constants rather than strings because future version of SRL won't have any string cases.

Press Play

2012-01-16 17:02:30

From: Coh3n
Looks good daazndagger, though I recommend using constants rather than strings because future version of SRL won't have any string cases.

Fair enough :) Just like MSI then eh? :p I like constants much more too; I use them in my scripts :) I might see if I can test this banking function. It should work because it has the same colour/tol/mods etc as my own one. And my one ran for 7 hours the other day! :D

Coh3n

2012-01-16 20:40:52

From: -daazndagger-
Fair enough :) Just like MSI then eh? :p I like constants much more too; I use them in my scripts :) I might see if I can test this banking function. It should work because it has the same colour/tol/mods etc as my own one. And my one ran for 7 hours the other day! :D
MSI uses standards that were planned out for SRL6.

Press Play

2012-01-17 17:58:22

I have tested my edit on the bank chest function. Attached is the new bank.simba. Red shows the TPA found, green is it's bounds:

Suggested constants for SRL6? I based them off SRL_ANGLE_HIGH. I changed them to integers too since I'm guessing you want to purge all strings for SRL6. I'm not positive, but would this make everything run faster? (Using integers instead of strings that is)
const              {Old Strings}
SRL_BANK_FE = 1; //'feb' (Falador East Bank)
SRL_BANK_FW = 2; //'fwb' (Falador West Bank)
SRL_BANK_VE = 3; //'veb' (Varrock East Bank)
SRL_BANK_VW = 4; //'vwb' (Varrock West Bank)
SRL_BANK_D = 5; //'db' (Draynor Bank)
SRL_BANK_AK = 6; //'akb' (Al-Kharid Bank)
SRL_BANK_E = 7; //'eb' (Edgeville Bank)
SRL_BANK_L = 8; //'lb' (Lumbridge Bank)
SRL_BANK_C = 9; //'ctb' (Catherby bank)
SRL_BANK_S = 10; //'clt' (Camelot bank) // This is actually 'Seers' bank?
SRL_BANK_AN = 11; //'nab' (North Ardougne bank) // 'north' should be suffix
SRL_BANK_AS = 12; //'sab' (South Ardougne bank) // 'south' should be suffix
SRL_BANK_Y = 13; //'ynb' (Yanille bank)
SRL_BANK_GN = 14; //'ngb' (North gnome bank) // 'north' should be suffix
SRL_BANK_GS = 15; //'sgb' (South gnome bank) // 'south' should be suffix
SRL_BANK_WG = 16; //'wgb' (Warrior guild bank)
SRL_BANK_FG = 17; //'fgb' (Fishing guild bank)

SRL_BANK_SW = 20; // Soul Wars chest
SRL_BANK_CW = 21; // Castle Wars chest
SRL_BANK_B = 21; // Burthrope chest (outside warriors guild)

jakeyboy29

2012-01-17 18:12:21

From: -daazndagger-
I have tested my edit on the bank chest function. Attached is the new bank.simba. Red shows the TPA found, green is it's bounds:

Suggested constants for SRL6? I based them off SRL_ANGLE_HIGH. I changed them to integers too since I'm guessing you want to purge all strings for SRL6. I'm not positive, but would this make everything run faster? (Using integers instead of strings that is)
const              {Old Strings}
SRL_BANK_FE = 1; //'feb' (Falador East Bank)
SRL_BANK_FW = 2; //'fwb' (Falador West Bank)
SRL_BANK_VE = 3; //'veb' (Varrock East Bank)
SRL_BANK_VW = 4; //'vwb' (Varrock West Bank)
SRL_BANK_D = 5; //'db' (Draynor Bank)
SRL_BANK_AK = 6; //'akb' (Al-Kharid Bank)
SRL_BANK_E = 7; //'eb' (Edgeville Bank)
SRL_BANK_L = 8; //'lb' (Lumbridge Bank)
SRL_BANK_C = 9; //'ctb' (Catherby bank)
SRL_BANK_S = 10; //'clt' (Camelot bank) // This is actually 'Seers' bank?
SRL_BANK_AN = 11; //'nab' (North Ardougne bank) // 'north' should be suffix
SRL_BANK_AS = 12; //'sab' (South Ardougne bank) // 'south' should be suffix
SRL_BANK_Y = 13; //'ynb' (Yanille bank)
SRL_BANK_GN = 14; //'ngb' (North gnome bank) // 'north' should be suffix
SRL_BANK_GS = 15; //'sgb' (South gnome bank) // 'south' should be suffix
SRL_BANK_WG = 16; //'wgb' (Warrior guild bank)
SRL_BANK_FG = 17; //'fgb' (Fishing guild bank)

SRL_BANK_SW = 20; // Soul Wars chest
SRL_BANK_CW = 21; // Castle Wars chest
SRL_BANK_B = 21; // Burthrope chest (outside warriors guild)


tested this for days, its been flawless

Coh3n

2012-01-17 18:13:03

Woah, you literally rewrote everything. :p I wasn't expecting that.

That may break scripts, I'm not sure, I'll have to take a look. That bank chest function looks nice, though. Are there similar results for the other chests? What about the Lumbridge cellar one?

Press Play

2012-01-17 18:23:12

From: Coh3n
Woah, you literally rewrote everything. :p I wasn't expecting that.

That may break scripts, I'm not sure, I'll have to take a look. That bank chest function looks nice, though. Are there similar results for the other chests? What about the Lumbridge cellar one?
If you push the attachment, it won't break any script :) They're new functions. The above constants are suggested for SRL6. If/when you change them, then it will break scripts ;)

I'll be going around to other bank chests to see what the colours are like. But after I get 99 fletching :p (140k XP to go)

Coh3n

2012-01-17 18:34:01

Ah okay, great. :) I'll do this as soon as I can.

Press Play

2012-01-18 19:41:49

Tested the other bank chests with the same colour/tol etc.
                 {              0          1         2        3     4     5      6       7       8   9     10   }
case Location of { Sort X Sort Y Color Tol Hue Sat Count SplitTPA? W H Compass}
SRL_BANK_SW : Info := [MSCX , MSCY, 10198185, 21, 0.08, 0.25, 50, True , 10, 10, 'w'];
SRL_BANK_CW : Info := [MSCX , MSCY, 10198185, 21, 0.08, 0.25, 50, True , 10, 10, 'n'];
SRL_BANK_B : Info := [MSCX , MSCY, 10198185, 21, 0.08, 0.25, 50, True , 10, 10, 'n'];
Only difference is which way the compass is facing.

EDIT: I did my first ever pull request on git (took a while, but I know how to do it now!) Not sure if it's the right way to go about it? I can upload the attachment here instead if you prefer.

Burthrope:

Castle Wars:

Kyle Undefined

2012-01-18 23:36:08

Nice work dazzn! :D I'm using this with Coh3n's script :) Rep++

nobody u kno

2012-01-20 21:25:52

How would you go about incorporating this into personal scripts?

Press Play

2012-01-20 21:54:16

To open a particular bank chest, for example Soul wars, use:
if OpenBankChest(SRL_BANK_SW) then
//Put code here;
See the top of the bank.simba file for the other supported banks. They include:
SRL_BANK_SW, SRL_BANK_CW, SRL_BANK_B

nobody u kno

2012-01-21 10:54:37

From: -daazndagger-
To open a particular bank chest, for example Soul wars, use:
if OpenBankChest(SRL_BANK_SW) then
//Put code here;
See the top of the bank.simba file for the other supported banks. They include:
SRL_BANK_SW, SRL_BANK_CW, SRL_BANK_B


Thanks a lot for the help!

Papa_ethan

2012-02-26 17:17:15

Took me ~20 mins to figure out how to fix antileech! But VERY nice script!

Yago

2012-02-26 17:32:41

From: Papa_ethan
Took me ~20 mins to figure out how to fix antileech! But VERY nice script!


This isn't a script. Wrong thread?