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.
[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.