SRL Archive - SRL Archives

Follow Colour


Naum

2008-10-22 13:18:43

This function basically follows a color with the mouse, good for things like fast moving NPC's.

{*******************************************************************************
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);

jakeyboy29

2008-10-22 13:21:23

umm, sexy. will be useful with voids and others.

Naum

2008-10-22 13:22:16

Thanks, just a small function I'll use in my guild script.

jakeyboy29

2008-10-22 13:23:12

for what things in ur guid will it be needed?

Naum

2008-10-22 13:25:20

Like when the player moves, then it will hover over that rock and not misclick it :p

jakeyboy29

2008-10-22 13:36:41

ahh, nice. that will be sex.

Claymore

2008-10-29 19:20:22

What about adding a cts feature?

ColorToleranceSpeed(prefcts);

Narcle

2008-10-29 19:50:30

Only problem is if it finds a similar color and moves to that instead.
Function FollowColor(Var x, y : Integer; HoverTime, Speed, Color, T0l : Integer) : Boolean;
Var
Mar8, GC, U : Integer;
Begin
MarkTime(Mar8);
Repeat
If FindColorTolerance(x, y, Color, MSX1, MSY1, MSX2, MSY2, T0l) Then
Begin
MMouse(x, y, 0, 0);
GC := GetColor(x, y);
Inc(U);
end;
Wait(Speed + Random(80));
Until(TimeFromMark(mar8) >= HoverTime) and (GetColor(x, y) = GC) Xor (U > 500);
If U < 500 Then
begin
GetMousePos(x, y);
Result := True;
end;
end;

Shortened in any case. ;)