Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$DEFINE SMART}
- {$I SRL/OSR.simba}
- const
- Color_Door: TColorEx = [2509163, 10, [2, [0.07, 0.40]]];
- function GetColor(AColor: TColorEx; Area: TBox): TPointArray; overload;
- begin
- with AColor do
- FindColorsTolerance(Result, Color, Area, Tolerance, Settings);
- end;
- function Modulo(X,Y:Double): Double;
- begin
- Result := X - Floor(X / Y) * Y;
- end;
- function DeltaAngle(DegA,DegB:Double; R:Double=360): Double;
- begin
- Result := Modulo((DegA - DegB + R/2), R) - R/2;
- end;
- function Door(): Boolean;
- function mbrAngle(mbr: TPointArray): Double;
- begin
- if Distance(mbr[0], mbr[3]) < Distance(mbr[0], mbr[1]) then
- Result := Modulo(ArcTan2((mbr[0].Y-mbr[1].Y), (mbr[0].X-mbr[1].X)),PI*2)
- else
- Result := Modulo(ArcTan2((mbr[0].Y-mbr[3].Y), (mbr[0].X-mbr[3].X)),PI*2);
- if Result > PI then
- Result := Result-PI*2;
- end;
- const
- DOOR_WIDTH = 35;
- DOOR_HEIGHT = 5;
- var
- TPA: TPointArray;
- ATPA: T2DPointArray;
- i,W,H, compass,doorAngle:Int32;
- begin
- ATPA := ClusterTPA(GetColor(Color_Door, MainScreen.GetBounds()), 1);
- for i := 0 to High(ATPA) do
- begin
- TPA := MinAreaRectEx(FindTPAEdges(ATPA[i]), W, H);
- if InRange(W, DOOR_WIDTH - 8, DOOR_WIDTH + 8) and
- InRange(H, DOOR_HEIGHT - 3, DOOR_HEIGHT + 3) then
- begin
- compass := Round(Modulo(Minimap.GetCompassAngle(),180));
- doorAngle := 90+round(Degrees(mbrAngle(TPA)));
- Result := not (Abs(DeltaAngle(compass, doorAngle,180)) < 30);
- Exit;
- end;
- end;
- end;
- begin
- Srl.DisableDebug := True;
- Smart.EnableDrawing := True;
- Smart.Init();
- if Door() then WriteLn('Open') else WriteLn('Closed');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement