I would make one function that handles the identifying of the beertender and the clicking all in one. He could move which could result in misclicking.
Simba Code:
function FindBartender: boolean;
var
i : Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
Box : TBox;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.07, 0.10);
if FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2365496, MSX1, MSY1, MSX2, MSY2, 3) then
begin
ATPA := TPAtoATPAEx(TPA, 15, 15);
SortATPASize(ATPA, True);
for i := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[i]);
Box := IntToBox((MP.X - 20), (MP.Y - 20), (MP.X + 20), (MP.Y + 20));
MMouse(MP.X, MP.Y, 4, 4);
if(WaitUptext('artender', 750))then
begin
ClickMouse2(0);
if WaitOption('alk-to', 500) then
begin
Result := True;
Break;
end;
end;
end;
end;
end;
procedure buybeer;
var
Attempts: Integer;
begin
while not(InvFull) do
begin
if FindBartender then
begin
TypeSendEx(' ', false);
Wait(RandomRange(300, 600));
TypeSendEx(' ', false);
Wait(RandomRange(300, 600));
TypeSendEx(' ', false);
Wait(RandomRange(300, 600));
TypeSendEx(' ', false);
Wait(RandomRange(300, 600));
TypeSendEx(' ', false);
Wait(RandomRange(300, 600));
TypeSendEx(' ', false);
Wait(RandomRange(300, 600));
end else
Inc(Attempts);
if Attempts > 5 then
break;
end;
end;