Silent
2012-02-21 14:23:17
I'm sure there is a simpler solution, but here it is. Multi stands for the multi-uptext that it can handle… This was really bothering me so I modified WithdrawItemEx to build it. Not really that many significant changes.
function WithdrawItemExMulti(Ident: integer; IdentType: string; var Index: integer; Amount: integer; UpText: TStringArray; Tol: TIntegerArray): Boolean;
var
x, y, i: 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);
if WaitUpTextMulti(UpText, 300) 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, srl_outline_black, BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2);
BankBox := GetTPABounds(t);
MouseBox(BankBox.x1, BankBox.y1, BankBox.x2, BankBox.y2, mouse_move);
if WaitUpTextMulti(UpText, 300) 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;
for i:=1 to Length(UpText) do
begin
SRL_Warn('WithdrawItem', 'Could not Find ' + IdentType + ' in Bank. [Uptext: ' + UpText[i] + ']', Warn_AllVersions);
end;
end;
end;