Floor66
2009-04-05 14:09:20
{*******************************************************************************
Function DifferentMSColours: Boolean;
By: Floor66
Description: This function takes the colours of specific MainScreen points,
waits 100 + Random(50), takes new colours, and checks if the
colours are different from the first ones taken.
*******************************************************************************}
Function DifferentMSColours(MS_Points : Integer): Boolean;
Var
BeginColours, CheckColours : Array Of Integer;
ColorCoords : TPointArray;
i, Results : Integer;
Begin
SetLength(ColorCoords, MS_Points);
SetLength(BeginColours, MS_Points);
SetLength(CheckColours, MS_Points);
For i := 0 To High(BeginColours) Do
Begin
ColorCoords[i].x := MSCX + Random(50);
ColorCoords[i].y := MSCY + Random(50);
BeginColours[i] := GetColor(ColorCoords[i].x, ColorCoords[i].y);
End;
Wait(100 + Random(50));
For i := 0 To High(CheckColours) Do
Begin
CheckColours[i] := GetColor(ColorCoords[i].x, ColorCoords[i].y);
If BeginColours[i] <> CheckColours[i] Then
Result := True;
End;
End;
{*******************************************************************************
Procedure CharacterMoving;
By: Floor66
Description: This procedure incorporates the function DifferentMSColours to do
a check if the character is still moving. A real handy check when
doing something with walking!
*******************************************************************************}
Procedure CharacterMoving;
Var
Checks, t : Integer;
Begin
Wait(500 + Random(50));
MarkTime(t);
Repeat
If (Not DifferentMSColours(7)) Then
Inc(Checks);
If (Checks >= 2) Or (Not FlagPresent) Then
Exit;
If TimeFromMark(t) >= (10 * 1000) Then
Exit;
Until(False);
End;
In reflection, there is/was a function called CharacterMoving. But reflection breaks all the time because of hooks (no offence; it's great).
I've gotten this idea from Nadeem, who made something like this, and I sort of expanded it.
This waits until the character has 100% STOPPED moving, or if the flag disappears. It does 2 checks to make sure, and there's a 15-sec failsafe.
PLEASE TEST IT! I'M ALREADY USING IT MYSELF AND IT WORKS FOR ME, BUT I WANT TO SEE IT WITH OTHERS!