SRL Archive - SRL Archives

*DepositBox


Tootoot222

2009-01-18 16:07:15

This uses the deposit box that is in all banks, is usefull for if you have a wcer that you don't need to withdraw anything for, just dump it in the deposit box. (this contains no ways to open the deposit box, just to store)

{*******************************************************************************
function GetItemCount(B: TBox): Integer;
By: Tootoot222
Description: Returns the amount of stacked items in B.
Returns 0 if nothing is there, 1 if non-stackable.
*******************************************************************************}
function GetItemCount(B: TBox): Integer;
var
X, Y, Z, T: Integer;
begin
Result:= 0;
if(FindColor(X, Y, 65536, B.X1, B.Y1, B.X2, B.Y2)) then
begin
Result:= 1;
try
if(FindColor(X, Y, 65535, B.X1, B.Y1, B.X2, B.Y2)) then
if(FindColorSpiral(Z, T, 65535, B.X1, B.Y1, B.X2, B.Y2)) then
Result:= StrToInt(TrimLetters(Replace(Replace(Lowercase(Trim(TrimOthers(GetTextAtEx(Z, Y - 1, 6, StatChars, False, False, 0, 3, 65535, 5, False, tr_AllChars)))), 'k', '000'), 'm', '000000')));
except
end;
end;
end;

{*******************************************************************************
function GetDepositBoxBounds(Slot: Integer): TBox;
By: Tootoot222
Description: Returns a TBox of the deposit box Slot.
Use: GetDepositBoxBounds(28);
*******************************************************************************}
function GetDepositBoxBounds(Slot: Integer): TBox;
var
X, Y: Integer;
begin
Slot:= Slot - 1;
X:= 106 + (48 * (Slot mod 7));
Y:= 70 + (50 * Floor(Slot div 7));
Result:= IntToBox(X, Y, X + 35, Y + 31);
end;

{*******************************************************************************
function DepositBoxRCToSlot(Row, Col: Integer): Integer;
By: Tootoot222
Description: Returns the slot of Row and Col.
Use: DepositBoxRCToSlot(3, 6); will return 28 (Row and Col start at 0)
*******************************************************************************}
function DepositBoxRCToSlot(Row, Col: Integer): Integer;
begin
Result:= (Row * 7) + Col + 1;
end;

{*******************************************************************************
procedure DepositBox(Skip: array of Integer);
By: Tootoot222
Description: Deposits all items except those in Skip (Uses the deposit box)
Use: DepositBox([1]); will deposit all except the first item
*******************************************************************************}
procedure DepositBox(Skip: array of Integer);

var
I, II, III, IV, A, T, TT, SkipL: Integer;
BlackTPA, ItemTPA, ResultTPA, SkipTPA: TPointArray;
NotAll: Boolean;
B: TBox;

begin
T:= GetSystemTime;
while(not(FindTextTPA(2070783, 20, 145, 35, 390, 50, 'posit Box', UpChars, Nothing))) do
begin
Wait(100);
if(TimeFromMark(T) > 2000) then
Exit;
end;
SkipL:= 0;
for I:= 0 to 3 do
for II:= 0 to 6 do
if(InIntArray(Skip, DepositBoxRCToSlot(I, II))) then
begin
B:= GetDepositBoxBounds(DepositBoxRCToSlot(I, II));
FindColorsTolerance(SkipTPA, 65536, B.X1, B.Y1, B.X2, B.Y2, 0);
SkipL:= SkipL + Length(SkipTPA);
end;
T:= GetSystemTime;
repeat
for I:= 0 to 3 do
for II:= 0 to 6 do
begin
FindColorsTolerance(BlackTPA, 65536, 106, 70, 429, 251, 0);
Writeln(IntToStr(High(BlackTPA)) + ' - ' + IntToStr(SkipL) + ' = ' + IntToStr((High(BlackTPA) - SkipL)));
if((High(BlackTPA) - SkipL) < 1) then
Exit;
if(InIntArray(Skip, DepositBoxRCToSlot(I, II))) then
Continue;
B:= GetDepositBoxBounds(DepositBoxRCToSlot(I, II));
A:= GetItemCount(B);
case A of
0: Continue;
1:
begin
FindColorsTolerance(ItemTPA, 65536, B.X1, B.Y1, B.X2, B.Y2, 0);
FindTPAinTPA(ItemTPA, BlackTPA, ResultTPA);
if(High(ResultTPA) > 0) then
begin
NotAll:= False;
for III:= 0 to High(Skip) do
for IV:= 0 to High(ResultTPA) do
if(PointInBox(ResultTPA[IV], GetDepositBoxBounds(Skip[III]))) then
NotAll:= True;
if(not(NotAll)) then
begin
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 2);
Wait(300 + Random(500));
ChooseOptionMulti(['All']);
end else
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 1);
end else
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 1);
end;
else
begin
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 2);
Wait(300 + Random(500));
ChooseOptionMulti([IntToStr(A), 'All']);
end;
end;
TT:= GetSystemTime;
while(CountColor(65536, B.X1, B.Y1, B.X2, B.Y2) > 0) do
begin
Wait(100);
if(TimeFromMark(TT) > 2000) then
Break;
end;
Wait(300 + Random(700));
end;
until(TimeFromMark(T) > 70000);
end;

jakeyboy29

2009-01-18 16:11:23

i think it should be added. are all box's same colour?

ian.

2009-01-18 16:39:01

yeah they are.. there not in every bank tho D:

Tootoot222

2009-01-18 16:47:49

From: jakeyboy29
i think it should be added. are all box's same colour?

idk, benjaa just asked me to make something that deposits from the deposit box, so i did lol thought i might post it here

benjaa

2009-01-18 18:20:08

it didnt quite work for me

it deposited all, then sat there repeating a wait im guessing

ZaSz

2009-01-18 18:37:00

your DepositBox procedure has a repeat until false… Thats why its not working for you benjaa

benjaa

2009-01-18 18:39:07

so, what could i change it to?

repeat 
...
until (GetItemCount(2->28) = 0);

??

ZaSz

2009-01-18 18:41:49

Just by looking at it, i say u do not even need the repeat at all, so just take out.
repeat
...
until false;

benjaa

2009-01-18 18:47:16

ohkk

ill try it

Edit: Works beautifully without repeat

thanks tootoot and zaxz

Tootoot222

2009-01-19 03:24:25

From: benjaa
it didnt quite work for me

it deposited all, then sat there repeating a wait im guessing


doh! i put the repeat in there because if it missed something for whatever reason, it would go back and try again, and had it break out when there was no black in the whole box, but i forgot that there would be skippage, i'll edit something in

BTW, repeat until(False) isn't bad, as long as you have a way to break out, which i did. but just as a failsafe i'll add a timer

benjaa

2009-01-19 05:12:46

it works well without the repeat :)

ill just leave them out

thankyou very much
rep++