SRL Archive - SRL Archives

Bank.scar


Naike

2009-05-26 18:07:32

Been trying to find stuff to make or update, and it's getting harder and harder…

  • SearchBankDTM
  • ItemToBankTab


{*******************************************************************************
Function SearchBankDTM(DTM: Integer; var x, y: Integer): Boolean;
by: N1ke!
Description: Searches for a Item(DTM) in your bank scrolling down.
Returns Cords and True if found.
*******************************************************************************}
Function SearchBankDTM(DTM: Integer; var x, y: Integer): Boolean;
var
sx, sy, tm: Integer;
mx, my: Integer;
begin
If(Not(LoggedIn))Or(Not(BankScreen))Then Exit;
Result := False;
FixBankTab;
FixBank;
Result := FindDTM(DTM, x, y, 31, 88, 477, 292);
If Result then
Exit;
tm := GetSystemTime;
MMouse(488, 284, 3, 3);
GetMousePos(mx, my);
Repeat
HoldMouse(mx, my, True);
Wait(200+Random(380));
ReleaseMouse(mx, my, True);
Wait(400+Random(2000));
Result := FindDTM(DTM, x, y, 31, 88, 477, 292);
Until(Result)or(Not(FindColorTolerance(sx, sy, 1975337, 485, 268, 491, 274, 5))or(GetSystemTime - tm > 20000));
end;

{*******************************************************************************
Function ItemToBankTab(Name: String; x, y, Tab: Integer): Boolean;
by: N1ke!
Description: Moves the item to the given BankTab.
*******************************************************************************}
Function ItemToBankTab(Name: String; x, y, Tab: Integer): Boolean;
var
lx, ly: Integer;
begin
Result := False;
MMouse(x, y, 5, 5);
Wait(175+Random(100));
If not IsUpText(Name) then
Exit;
GetMousePos(lx, ly);
HoldMouse(lx, ly, True);
Wait(200+Random(800));
Result := BankTab(Tab);
ReleaseMouse(lx, ly, True);
end;

ShowerThoughts

2009-05-26 20:48:21

Try random solving? That's the only problem we are dealing with.

Nava2

2009-05-27 03:59:45

Hm, why not just use search bank?

Awkwardsaw

2009-05-27 05:04:00

is there already searchbank in srl? that (shouldn't) be to hard to make, even for me :P

but i like this, since i usually just scroll down instead of searching.

Da 0wner

2009-05-27 15:20:11

Actually, yes there is.
  procedure SearchBank(Item:string);

Naike

2009-05-27 20:13:49

If you read what that procedure does, and you look at mine then you see the diffrence.

Da 0wner

2009-05-28 01:40:49

Yes, I looked at yours, I was saying that to the poster.

Nava2

2009-05-28 01:54:27

{*******************************************************************************
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;
By: Nava2
Description: Withdraws an item from the bank by using "Ident" with tol[0]
as color tolerance, tol[1] as contour tolerance in case of bmp
masks, or the count of colors for TPA item finding.
Valid IdentTypes are all in FindItem.
Index: The Bank Index where the item is found, must be a variable.
Speeds up future withdraws.
Amount: Amount to withdraw from bank.
UpText: The UpText which the function checks for.
*******************************************************************************}
function WithdrawItemEx(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: String; Tol: TIntegerArray): Boolean;
var
x, y: integer;
BPoint: TPoint;
BankBox: TBox;
Found: Boolean;
t: TPointArray;
label
Start;
begin
Result := False;
if not BankScreen then Exit;
FixBank;

if (Index = 0) then
begin
Start:
for Index := 1 to 50 do
begin
if FindItemEx(x, y, IdentType, Ident, BankIndexToMSBox(Index), Tol) then
begin
MMouse(x, y, 4, 4);
Wait(120 + Random(50));
if IsUpText(UpText) then
begin
Writeln('Found Item at Bank Slot ' + IntToStr(Index) + '.');
Found := True;
Break;
end else
Writeln('Found Incorrect Item, Moving to new Bank Spot.');
end;
end;
end else
begin
BankBox := BankIndexToMSBox(Index);
FindColors(t, 65536, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
BankBox := GetTPABounds(t);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, 3);
Wait(120 + Random(50));
if IsUpText(UpText) then
Found := true
else
begin
Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
GoTo Start;
end;
end;
Wait(RandomRange(200, 350));
if Found then
begin
BPoint := BankIndexToBankPoint(Index);
//Writeln(IntToStr(BPoint.x) + ', ' + IntToStr(BPoint.y));
Withdraw(BPoint.x, BPoint.y, Amount);
Result := True;
end else
begin
Index := 0;
SRL_Warn('WithdrawItem', 'Could not Find ' + IdentType + ' in Bank. [Uptext: ' + UpText + ']', Warn_AllVersions);
end;
end;

{*******************************************************************************
function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
by: Nava2
Description: Withdraws an item using WithdrawItemEx, but removes the Index check.
*******************************************************************************}
function WithdrawItem(Ident: integer; IdentType: string; Amount: integer; UpText: String; Tol: TIntegerArray): boolean;
var
I : Integer;
begin
Result := WithdrawItemEx(Ident, IdentType, I, Amount, UpText, Tol);
end;