@@ -226,69 +226,22 @@ end;
226226
227227
228228(*
229- ## Minimap.GetCompassAngle
229+ ## Minimap.CompassRadians
230230```pascal
231- function TRSMinimap.GetCompassAngle(asDegrees: Boolean = True) : Single;
231+ property TRSMinimap.CompassRadians : Single;
232232```
233- Returns the minimap compass angle either in radians or degrees.
234- By default, degrees are used.
233+ Returns the minimap compass angle as radians.
235234
236235Credits: [slacky](https://slacky.one/)
237236
238237Example:
239238```pascal
240- WriteLn Minimap.GetCompassAngle() ;
239+ WriteLn Minimap.CompassRadians ;
241240```
242-
243241If you are not sure what the compass refers to, it refers to this:
244242```{figure} ../../images/compass.png
245243```
246244*)
247- function TRSMinimap.GetCompassAngle(asDegrees: Boolean = True): Single;
248- var
249- center: TPoint;
250- bounds: TBox;
251- north,south,west,east: TPoint;
252- Nclr, dials, southArr, westArr, eastArr: TPointArray;
253- n,w,e,s,x,y: Single;
254- begin
255- center := Self.Compass.Circle.Center;
256- bounds := Self.Compass.Circle.Bounds;
257-
258- dials := Target.FindColor($26259C, 12, bounds);
259- Nclr := Target.FindColor($1D2931, 0.6, bounds);
260-
261- dials := dials.ExtractDist(center, 10, 20);
262- north := Nclr.ExtractDist(center, 0,20).Mean();
263-
264- southArr := dials.ExtractDist(north, 21, 50);
265- south := southArr.FurthestPoint(center);
266-
267- dials := dials.Difference(southArr);
268-
269- for dials in dials.Cluster(3) do
270- if CrossProduct(dials.Mean(), north, south) > 0 then
271- westArr := dials
272- else
273- eastArr := dials;
274-
275- west := westArr.FurthestPoint(eastArr.Mean()); //late edit: Should not this be middle, not eastarr.mean
276- east := eastArr.FurthestPoint(westArr.Mean()); //late edit: Should not this be middle, not westarr.mean
277-
278- n := ArcTan2(north.y-center.y, north.x-center.x) + HALF_PI;
279- s := ArcTan2(south.y-center.y, south.x-center.x) - HALF_PI;
280- w := ArcTan2(west.y-center.y, west.x-center.x)+PI;
281- e := ArcTan2(east.y-center.y, east.x-center.x);
282-
283- x := Cos(s) + Cos(e) + Cos(w) + Cos(n);
284- y := Sin(s) + Sin(e) + Sin(w) + Sin(n);
285-
286- Result := ArcTan2(y/4, x/4);
287- if Result < 0 then Result := Result + PI*2;
288-
289- if asDegrees then Result := RadToDeg(Result);
290- end;
291-
292245property TRSMinimap.CompassRadians: Single;
293246var
294247 center: TPoint;
@@ -335,13 +288,29 @@ begin
335288 Result := Result + TAU;
336289end;
337290
291+ (*
292+ ## Minimap.CompassDegrees
293+ ```pascal
294+ property TRSMinimap.CompassDegrees: Single;
295+ ```
296+ Returns the minimap compass angle as radians.
297+
298+ Credits: [slacky](https://slacky.one/)
299+
300+ Example:
301+ ```pascal
302+ WriteLn Minimap.CompassDegrees;
303+ ```
304+ If you are not sure what the compass refers to, it refers to this:
305+ ```{figure} ../../images/compass.png
306+ ```
307+ *)
338308property TRSMinimap.CompassDegrees: Single;
339309begin
340310 Result := RadToDeg(Self.CompassRadians);
341311end;
342312
343313
344-
345314(*
346315## Minimap.SetCompassAngle
347316```pascal
@@ -373,10 +342,10 @@ begin
373342 timeout := Time() + RandomMean(6000, 8000);
374343
375344 repeat
376- remaining := Round(DeltaAngle(Self.GetCompassAngle() , degrees));
345+ remaining := Round(DeltaAngle(Self.CompassDegrees , degrees));
377346 if Abs(remaining) <= accuracy then Exit(True);
378347
379- pixels := Round(Abs(DeltaAngle(Self.GetCompassAngle() , degrees)) * DEG_PER_PIXEL);
348+ pixels := Round(Abs(DeltaAngle(Self.CompassDegrees , degrees)) * DEG_PER_PIXEL);
380349 left2right := InRange(remaining, 1, 180) or (remaining < -180);
381350
382351 if left2right then
@@ -404,11 +373,10 @@ begin
404373 until Time() > timeout;
405374
406375 WriteLn GetDebugLn('Minimap', 'SetCompassAngle timed out.', ELogLevel.WARN);
407- //TODO:
408- //if not RSClient.IsLoggedIn() then
409- // Login.LoginPlayer()
410- //else
411- // Self.DebugLn('Make sure the setting "Middle mouse button controls the camera" is enabled in the game settings.');
376+ if not RSClient.IsLoggedIn() then
377+ Login.DoLogin()
378+ else
379+ WriteLn GetDebugLn('Minimap', 'Make sure the setting "Middle mouse button controls the camera" is enabled in the game settings.', ELogLevel.WARN);
412380end;
413381
414382function TRSMinimap.SetCompassAngle(degrees: Single): Boolean;
897865 img, clean: TImage;
898866 center: TPoint;
899867begin
900- if angle = $FFFF then angle := Self.GetCompassAngle(False) ;
868+ if angle = $FFFF then angle := Self.CompassRadians ;
901869
902870 if radius = -1 then
903871 radius := Self.Radius;
0 commit comments