Naum
2008-10-22 13:18:43
This function basically follows a color with the mouse, good for things like fast moving NPC's.
Usage
{*******************************************************************************
Function FollowColor(Var ff, gg : Integer; HoverTime, Speed, C0l0r, T0l : Integer) : Boolean;
By: NaumanAkhlaQ
Description: Follows a Specific Color until Hover time is reached.
Times out after 40 seconds.
Usage : ff, gg are the 'x, y' variables. Hover Time is the max time it will
take until the object is stationary. Speed is the wait time.
C0l0r is the color of the object and t0l is the tolerance.
*******************************************************************************}
Function FollowColor(Var ff, gg : Integer; HoverTime, Speed, C0l0r, T0l : Integer) : Boolean;
Var Mar8, GC, U : Integer;
Begin
MarkTime(Mar8);
Repeat
If FindColorTolerance(ff, gg, c0l0r, MSX1, MSY1, MSX2, MSY2, T0l) Then
Begin
MMouse(ff, gg, 0, 0);
GC := GetColor(ff, gg);
Inc(U);
end;
Wait(Speed + Random(80));
Until(TimeFromMark(mar8) >= HoverTime)and(GetColor(ff, gg) = GC) Xor
(U > 500);
If U > 500 Then
Result := False
else
GetMousePos(ff, gg);
Result := True;
end;Usage
If FollowColor(x, y, 4000, 10, 7576521, 10) Then
Mouse(x, y, 1, 1, True);