Nava2
2008-08-15 14:32:30
{*******************************************************************************
function WithdrawItem(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
By: Nava2
Sections by: WT-Fakawi / Sumilion
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. Valid IdentTypes are :
bmp, mask, color, dtm.
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 WithdrawItem(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
var
x1, y1, coltol, contol : integer;
BPoint : TPoint;
BankBox : TBox;
F, Found : boolean;
label
Start;
begin
{Written by WT-Fakawi / Sumilion, from this line to {end}
case LowerCase(IdentType) of
'bmpmask', 'bitmapmask', 'bmp mask', 'bitmap mask', 'mask':
try
begin
coltol := tol[0];
contol := tol[1];
end;
except
srl_Warn('WithdrawItem', 'Tol was incorrect', warn_AllVersions);
Exit;
end;
'dtm': begin end; //I guess this is a check to make sure its a valid identifier?
'bmp', 'bitmap', 'color':
try
coltol := tol[0];
except
srl_Warn('WithdrawItem', 'Tol was incorrect', warn_AllVersions);
Exit;
end;
else begin
srl_Warn('WithdrawItem', 'Invalid identifier type: ' + IdentType, warn_AllVersions);
Exit;
end;
end;
{End}
if (Index = 0) then
begin
Start:
for Index := 1 to 50 do
begin
BankBox := BankIndexToMSBox(Index);
case LowerCase(IdentType) of
'bmp', 'bitmap': F := FindBitmapSpiralTolerance(Ident, x1, y1, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, coltol);
'bmpmask', 'bitmapmask', 'bmp mask', 'bitmap mask', 'mask': F :=FindBitmapMaskTolerance(Ident, x1, y1, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, coltol, contol);
'color': F := FindColorTolerance(x1, y1, Ident, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, coltol);
'dtm': F := FindDtm(Ident, x1, y1, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
end;
if F then
begin
MMouse(x1, y1, 4, 4);
Wait(100+random(50));
if IsUpTextMultiCustom(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);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, 3);
Wait(100+random(50));
if IsUpTextMultiCustom(UpText) then
Found := true
else
begin
Writeln('Item Moved from Bank Slot ' + IntToStr(Index) + ', checking bank again.');
GoTo Start;
end;
end;
Wait(200+random(150));
if Found then
begin
BPoint := MSTPointToBankPoint(Point(x1, y1));
Withdraw(BPoint.x, BPoint.y, Amount);
Result := true;
end else
begin
Index := 0;
Writeln('Could not Find ' + IdentType + ' in Bank.');
end;
end;
{*******************************************************************************
function WithdrawItemEx(Ident: integer; IdentType: string; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
by: Nava2
Description: Withdraws an item using WithdrawItem, but removes the Index check.
*******************************************************************************}
function WithdrawItemEx(Ident: integer; IdentType: string; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): boolean;
var
I : integer;
begin
Result := WithdrawItem(Ident, IdentType, I, Amount, UpText, Tol);
end;Read the descriptions to see how the functions work. The DTM and Bitmap withdrawing works flawlessly, I'm uncertain as to the mask and colors.
The second function removes the index checking, which is a cool feature which allows scar to remember where the item is.
Please post comments and suggestions.