DoorOpen - Door open on MM?
Thanks to Wizzy and everyone else who helped me with ArcTan etc.
Some doors on minimap show it if they are open, some don't.
Anyways, I made a function to check if the ones that show if open, are open.
DoorMid X and Y - Coords of the doors end on MM
VerticalHorizontal - If you are dealing with a door that's line on MM is vertical, True, Else, False.
SCAR Code:
Function DoorOpen(DoorMidX, DoorMidY: Integer; VerticalHorizontal: Boolean): Boolean;
Var
TPA: TPointArray;
C, X, Y, Dx, Dy, Sx, Sy: Integer;
A2: Extended;
Slope: TPoint;
//* Thanks to Wizzy and everybody else for teaching about ArcTan =)
//* Credits to Wizzy for the 90 - (A2 * -1)...
Begin
C := GetColor(DoorMidX, DoorMidY);
X := DoorMidX;
Y := DoorMidY;
FindColorsSpiralTolerance(X, Y, TPA, C, X - 4, Y - 4, X + 4, Y + 4, 5);
Dx := TPA[High(TPA)].x;
Dy := TPA[High(TPA)].y;
FindColorsSpiralTolerance(DX, DY, TPA, C, X - 4, Y - 4, X + 4, Y + 4, 5);
Sx := TPA[High(TPA)].x;
Sy := TPA[High(TPA)].y;
Slope.x := iAbs(Dx - Sx);
Slope.y := iAbs(Dy - Sy);
A2 := Degrees(ArcTan2(Slope.x, Slope.y));
Writeln(FloatToStr(A2));
If A2 < 0 Then
A2 := A2 + 360;
Case VerticalHorizontal Of
True: Result := InRange(Round(A2), 85, 95);
False: Result := (Round(A2) = 0);
End;
End;