Nice, but it wouldn't compile.
FindColorsSpiralTolerance is a procedure.
You are supposed to work with the points, do a SplitTPA, then look through the TPAA if any of the TPAs has enough points for a whirlpool (over 50) and if is, then result true. You should use CTS(2) so you are okay with one color and about 15 Tol etc.
Also, you haven't even used the SkipBox, so why use FindColorSkipBox?
And you also need tolerance for the Handling part.
Also, are you sure the first point of the TPA is the top right corner?
No, but would be if you would use FindColorsTolerance without the Spiral, because it looks from x1,y1 to x2,y2 (High would be the down right).
Hope I didn't go too far, and hope you like constructive critisism.
EDIT: I do not mean that use FindColorsTolerance for whole MM, make params for the x1, y1, x2, y2 because people would use it around the fishing spot.
EDIT EDIT: Lets play:
SCAR Code:
Type
TWPH = (StopFishing, WaitAway); // WPH = Whirlpool handler.
// StopFishing stops the fishing and waits until its gone.
// WaitAway waits until it isn't there.
Function BoxFromTPA(TPA: TPointArray): TBox;
Var
L, I: Integer;
Begin
L := High(TPA);
MiddleTPAEx(TPA, Result.x1, Result.y1);
Result.x2 := Result.x1 + 1;
Result.y2 := Result.y1 + 1;
For I := 0 To L Do
Begin
If (TPA[i].x < Result.x1) And (TPA[i].y < Result.y1) Then
Begin
Result.x1 := TPA[i].x;
Result.y1 := TPA[i].y;
End;
If (TPA[i].x > Result.x2) And (TPA[i].y > Result.y2) Then
Begin
Result.x2 := TPA[i].x;
Result.y2 := TPA[i].y;
End;
End;
End;
Function FindWhirlPool(Handle: Boolean; HowHandle: TWPH; x1, y1, x2, y2: Integer): Boolean;
Var
CTS, X, Y, L, C, I, WM: Integer;
wPools: Array of TPointArray;
wPts: TPointArray;
TB: TBox;
Begin
If Not LoggedIn Then Exit;
CTS := GetColorToleranceSpeed;
If Not CTS = 2 Then ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, wPts, 0{a color from whirlpool here},
x1, y1, x2, y2, 15);
wPools := SplitTPA(wPts);
L := High(wPools);
SetArrayLength(wPts, 0);
For I := 0 To L Do
Begin
If GetArrayLength(wPools[i]) >= 50 Then
Begin
Writeln('*** Whirlpool Detected ***');
SetArrayLength(wPts, GetArrayLength(wPools[i]));
wPts := wPools[i];
Result := True;
Break;
End;
End;
If Handle Then
Begin
If HowHandle = StopFishing Then
Begin
MouseFindFlag(MMCX, MMCY, -1, -1);
Wait(500 + Random(250));
End Else
Begin
TB := BoxFromTPA(wPts);
MiddleTPAEx(wPts, X, Y);
C := GetColor(X, Y);
WM := GetSystemTime;
While FindColorTolerance(X, Y, C, TB.x1, TB.y1, TB.x2, TB.y2, 5) Do
If GetSystemTime - WM > 12000 + Random(1000) Then
Break;
End;
End;
ColorToleranceSpeed(CTS);
End;