Can anyone explain to me why only sometimes this function fails to wait for the bank screen to open? Also, it only happens because once every few times ChooseOption sort of pauses before it clicks. Once the bank screen is open it moves the mouse rapidly up and down in a small box towards the center of the screen.
Any help would be very much appreciated.
SCAR Code:
function Bank: Boolean;
var x, y, i, Counter: Integer; Arr: array of TPoint; ATPA: T2DPointArray; P: TPoint;
label Start;
begin
if not AtBank then Exit;
Writeln('Banking..');
Start:
Arr := GetColorPoints(x, y, 8424083, MSx1, MSy1, MSx2, MSy2, 1, 1, 5);
if Length(Arr) < 5 then
begin
SetAngle(False);
if Counter >= 1 then Exit;
Inc(Counter);
goto Start;
end;
atpa := TPAtoATPAEx(Arr, 1, 1);
for i := 0 to High(atpa) do
begin
P := MiddleTPA(atpa[i]);
MMouse(P.x, P.y, 5, 5);
Wait(80 + Random(30));
if Pos('ank booth', Rs_GetUpText) > 0 then
begin
GetMousePos(x, y);
Mouse(x, y, 1, 1, False);
Wait(80 + Random(30));
ChooseOption('uickly');
MarkTime(k);
while not BankScreen do
begin
Wait(150);
Writeln('Waiting for BankScreen('+IntToStr(TimeFromMark(k))+');');
if TimeFromMark(k) > 7000 + Random(1000) then
Break;
end;
Wait(1500 + Random(80));
Result := BankScreen;
end;
if Result then
begin
Writeln('Banking successful.');
Exit;
end;
end;
end;