JTcm
2012-08-25 17:12:14
Pretty much what the title says. Not really happy with this double loop. Any thoughts?
procedure StartBattle();
var
findDTMResultOne, findDTMResultTwo: Boolean;
x1, y1, x2, y2, repeatCounter, failSafe: Integer;
begin
findDTMResultOne := FindDTM(DTMFromString(startButtonDTMString), x1, y1, GSX1, GSY1, GSX2, GSY2);
Mouse(x1, y1, 0, 0, mouse_Left);
// Outer loop with fail safe
failSafe := 0;
repeat
// Inner loop checking if fight has started
repeatCounter := 0;
repeat
Wait(150);
Inc(repeatCounter);
findDTMResultTwo := FindDTM(DTMFromString(fightStartedDTMString), x2, y2, GSX1, GSY1, GSX2, GSY2);
until ((findDTMResultTwo = true) or (repeatCounter > 50));
Inc(failSafe);
until((findDTMResultTwo = true) or (failSafe > 3));
if ((findDTMResultTwo = false) or (failSafe > 3)) then
ThrowErrorAndTerminate('Error starting the fight');
end;