PDA

View Full Version : A few bank additions



Flight
03-21-2012, 04:50 AM
I don't expect any of these to be important enough to be added to the library so I'm posting them here for anyone to use.

[Function GetSlotAmount: Integer]
Purpose: Returns the amount of an item in the given slot

Function GetSlotAmount(slot: Integer): Integer;
Var
TB: TBox;
begin
GetInvItemBounds(slot, TB);
Result := GetAmountBox(TB);
end;

^Tested, works fine.

[Function DBoxItemCount: Integer]
Purpose: Returns the number of items in the depositbox screen

Function DBoxItemCount: Integer;
Var
B: TBox;
I,X,Y: Integer;
begin
Result := 0;
if not DepositScreen then Exit;
for I := 1 to 28 do
begin
B := DepositItemBox(I);
if FindColor(X, Y, srl_outline_black, B.X1, B.Y1, B.X2, B.Y2) then
Inc(Result);
end;
end;

^Untested.

[Function DepositAllExcept(IgnoreSlots: TIntegerArray; FastDeposit: Boolean): Boolean]
Purpose: Deposits all slots individually excluding the the 'IgnoreSlots'. Should work for banks as well as deposit boxes.

Function DepositAllExcept(IgnoreSlots: TIntegerArray; FastDeposit: Boolean): Boolean;
Var
B: TBox;
i,T,X,Y: Integer;
Label
Start;
begin
Result := False;
if ((not BankScreen) and (not DepositScreen)) then Exit;

Start:
For i := 1 to 28 do
begin
if not InIntArray(IgnoreSlots, i) then
begin
if BankScreen then
begin
if ExistsItem(i) then
MouseItem(i, mouse_right)
end else if DepositScreen then
begin
B := DepositItemBox(I);
if (not(FindColor(X, Y, srl_outline_black, 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, mouse_right);
end;

if FastDeposit then
begin
if ((GetSlotAmount(i) = 0) or (GetSlotAmount(i) = 1)) then
MenuOption(1)
else if ((GetSlotAmount(i) > 1) and (GetSlotAmount(i) < 6)) then
MenuOption(5)
else if (GetSlotAmount(i) > 5) then
MenuOption(6);

if (i = 28) then
Wait(RandomRange(300, 450));
end else
begin
WaitOptionMulti(['Deposit-All', 'All', 'osit'], 400);
T := GetSystemTime;
repeat
if BankScreen then
if (not(ExistsItem(I))) then Break;
if DepositScreen then
if (not(FindColor(X, Y, srl_outline_black, B.X1, B.Y1, B.X2, B.Y2))) then Break;
Wait(50);
until(GetSystemTime - T > 2000)
end;
end;
end;

{Possible infinate loop? Depends on the accuracy of your IgnoreSlots array}
if BankScreen then
if not (InvCount = Length(IgnoreSlots)) then
goto Start
else if DepositScreen then
if not (DBoxItemCount = Length(IgnoreSlots)) then
goto Start;

Result := True;
end;

^Bank depositing tested, deposit box untested.

Also, for that last function you'll need this as well:

Procedure MenuOption(Line: Integer);
Var
X,Y,pY: Integer;
begin
case Line of
1: pY := 28;
2: pY := 44;
3: pY := 60;
4: pY := 76;
5: pY := 93;
6: pY := 108;
7: pY := 126;
end;

GetMousePos(X, Y);
Mouse(X, (Y+pY), 10, 3, Mouse_Left); //This can (should) be adjusted to a more appropriate formula
end;


I wrote this because I needed a way to deposit all of the multiple stacks of runes in my inventory while keeping a few items left alone. I also wanted the depositing to be done as fast as possible, so I used static coordinate clicking based on the stack size of the item in the given inventory slot. The DepositAllExcept function works quite fast if you have 'FastDepost' set to True.

Hopefully someone else will find some uses for these few functions.

Er1k
03-21-2012, 04:59 AM
The first one is highly useful. I use a similar SRL bank function to check for items in the bank. That way the slot is always held and progress report is accurate to any item amount below 100k.

Wyn
03-22-2012, 05:01 PM
Is FastDeposit in DepositAllExcept a depiction of mousekeys?

Nice idea would to incorporate something like that into Withdraw.

Le Jingle
10-23-2012, 01:21 AM
procedure MenuOption(Line: Integer);
var
i, x, y, pY: integer;
begin
if not inrange(line, 1, 7) then
exit;
for i := 0 to Line-1 do
pY := 28+(i*16);

if line = 5 then
pY := pY + 1;
if line = 7 then
pY := pY + 2;

GetMousePos(X, Y);
Mouse(X, (Y+pY), 10, 3, Mouse_Left);
end;

or alternatively, (given, too, that the case statement y's can be 1-2 off:

procedure MenuOption(Line: Integer);
var
i, x, y, pY: integer;
begin
for i := 0 to Line-1 do
pY := 28+(i*16);

GetMousePos(X, Y);
Mouse(X, (Y+pY), 10, 3, Mouse_Left);
end;


All in all, I find this as yet another handy brew of code :)

Cheers,
Lj

Nebula
10-23-2012, 07:00 PM
procedure MenuOption(Line: Integer);
var
x, y, pY: integer;
begin
pY := 28 + ((Line-1)*16);
GetMousePos(X, Y);
Mouse(X, (Y+pY), 10, 3, Mouse_Left);
end;

Why did you "gravedig" this? Also there's no need for looping it.

Le Jingle
10-23-2012, 07:04 PM
Ah didn't think of not looping it >.< Still working on applying that horrid math background of mine to code.

Cheers,
Lj

E; don't think you can gravedig tuts, and this is kinda a tut on good code/snippets