Skip to content

Commit 8d3eac4

Browse files
committed
feat(TRSWalker): Doorhandler should be working
- Removed TRSMinimap.GetCompassAngle()` in favour of `TRSMinimap.CompassRadians` and `TRSMinimap.CompassDegrees` read properties
1 parent dd901eb commit 8d3eac4

File tree

10 files changed

+73
-114
lines changed

10 files changed

+73
-114
lines changed

osrs/antiban/antibantasks.simba

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ end;
8383
procedure TAntiban.SmallCameraRotation();
8484
begin
8585
WriteLn GetDebugLn('Antiban', 'Small camera rotation');
86-
Minimap.SetCompassAngle(Minimap.GetCompassAngle() + Random(-15,15));
86+
Minimap.SetCompassAngle(Minimap.CompassDegrees + Random(-15,15));
8787
end;
8888

8989
procedure TAntiban.LargeCameraRotation();
9090
begin
9191
WriteLn GetDebugLn('Antiban', 'Large camera rotation');
9292

9393
case RandomBoolean(0.5) of
94-
True: Minimap.SetCompassAngle(Minimap.GetCompassAngle() - GaussRand(30, 360));
95-
False: Minimap.SetCompassAngle(Minimap.GetCompassAngle() + GaussRand(30, 360));
94+
True: Minimap.SetCompassAngle(Minimap.CompassDegrees - GaussRand(30, 360));
95+
False: Minimap.SetCompassAngle(Minimap.CompassDegrees + GaussRand(30, 360));
9696
end;
9797
end;
9898

@@ -506,7 +506,7 @@ var
506506
begin
507507
dots := Minimap.GetDots(dotType);
508508
if dots.Length < 1 then Exit;
509-
a := Minimap.GetCompassAngle(False);
509+
a := Minimap.CompassRadians;
510510
repeat
511511
Inc(tries);
512512
rDot := dots[Random(Low(dots),High(dots))];

osrs/interfaces/mainscreen/mainscreen.simba

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ begin
475475
if Self.IsUpText(strings) then
476476
begin
477477
Mouse.Click(EMouseButton.LEFT);
478-
Exit(Self.RedClicked());
478+
if Self.RedClicked() then
479+
Exit(True);
479480
end;
480481

481482
if ChooseOption.Select(strings) then

osrs/interfaces/minimap.simba

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -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

236235
Credits: [slacky](https://slacky.one/)
237236

238237
Example:
239238
```pascal
240-
WriteLn Minimap.GetCompassAngle();
239+
WriteLn Minimap.CompassRadians;
241240
```
242-
243241
If 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-
292245
property TRSMinimap.CompassRadians: Single;
293246
var
294247
center: TPoint;
@@ -335,13 +288,29 @@ begin
335288
Result := Result + TAU;
336289
end;
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+
*)
338308
property TRSMinimap.CompassDegrees: Single;
339309
begin
340310
Result := RadToDeg(Self.CompassRadians);
341311
end;
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);
412380
end;
413381

414382
function TRSMinimap.SetCompassAngle(degrees: Single): Boolean;
@@ -897,7 +865,7 @@ var
897865
img, clean: TImage;
898866
center: TPoint;
899867
begin
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;

osrs/interfaces/mm2ms.simba

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ var
166166
i: Integer;
167167
begin
168168
if (angle = $FFFF) then
169-
angle := Self.GetCompassAngle(False);
169+
angle := Self.CompassRadians;
170170

171171
SetLength(vectors, Length(points));
172172

@@ -182,7 +182,7 @@ end;
182182

183183
function TRSMinimap.Point2MS(pt: TPoint; angle: Single = $FFFF): TPoint;
184184
begin
185-
if (angle = $FFFF) then angle := Self.GetCompassAngle(False);
185+
if (angle = $FFFF) then angle := Self.CompassRadians;
186186
with Self.Normalize(pt, angle) do
187187
Result := MM2MS.Run([[X, Y, 0]], angle)[0];
188188
end;
@@ -192,7 +192,7 @@ var
192192
tpa: TPointArray;
193193
begin
194194
if angle = $FFFF then
195-
angle := Self.GetCompassAngle(False);
195+
angle := Self.CompassRadians;
196196
for tpa in atpa do
197197
Result += Self.Points2MS(tpa, angle);
198198
end;
@@ -246,7 +246,7 @@ end;
246246

247247
function TRSMinimap.Point2MSQuad(pt: TPoint; size: TVector2 = [1,1]; angle: Single = $FFFF): TQuad;
248248
begin
249-
if angle = $FFFF then angle := Self.GetCompassAngle(False);
249+
if angle = $FFFF then angle := Self.CompassRadians;
250250
Result := Self.Vector2MSQuad(pt.ToVec3(), angle, size);
251251
end;
252252

@@ -303,7 +303,7 @@ end;
303303

304304
function TRSMinimap.Point2MSCuboid(pt: TPoint; size: TVector3; angle: Single = $FFFF): TCuboid;
305305
begin
306-
if angle = $FFFF then angle := Self.GetCompassAngle(False);
306+
if angle = $FFFF then angle := Self.CompassRadians;
307307
Result := Self.Vector2MSCuboid(pt.ToVec3(), size, angle);
308308
end;
309309

@@ -644,7 +644,7 @@ var
644644
angle: Single;
645645
tpa: TPointArray;
646646
begin
647-
angle := Self.GetCompassAngle(False);
647+
angle := Self.CompassRadians;
648648

649649
img := Target.GetImage();
650650
img.DrawColor := $00FF00;
@@ -702,7 +702,6 @@ begin
702702
end;
703703
end.
704704
```
705-
706705
```{figure} ../../images/mm2ms_playerbox.gif
707706
```
708707
*)
@@ -714,7 +713,7 @@ begin
714713
if MM2MS.PlayerBoxes[Options.GetZoomLevel()] <> [] then
715714
Exit(MM2MS.PlayerBoxes[Options.GetZoomLevel()]);
716715

717-
compassAngle := Minimap.GetCompassAngle(False);
716+
compassAngle := Minimap.CompassRadians;
718717

719718
vectors := [
720719
Minimap.Center.Offset(-2,0).ToVec3(9).Rotate(-compassAngle, Minimap.Center),

osrs/position/house/house.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ var
238238
begin
239239
Self.Similarity := 0;
240240

241-
angle := Minimap.GetCompassAngle(False);
241+
angle := Minimap.CompassRadians;
242242
clean := Minimap.GetCleanImage(angle, Self.Sample.Radius);
243243
results := Self.ScaledSearch(clean);
244244

@@ -328,7 +328,7 @@ begin
328328
img.DrawImage(map, [10, 20]);
329329
with cleanMinimap.Center do
330330
if RSClient.Mode = ERSMode.FIXED then
331-
p := Point(X, Y).Offset(0, 8).Rotate(-Minimap.GetCompassAngle(False), [X,Y]);
331+
p := Point(X, Y).Offset(0, 8).Rotate(-Minimap.CompassRadians, [X,Y]);
332332

333333
cleanMinimap.DrawColor := $FFFFFF;
334334
cleanMinimap.DrawBoxFilled([p.X - 1, p.Y - 1, p.X + 1, p.Y + 1]);

osrs/position/imagemap.simba

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ var
174174
begin
175175
Self.Similarity := 0;
176176

177-
angle := Minimap.GetCompassAngle(False);
177+
angle := Minimap.CompassRadians;
178178
clean := Minimap.GetCleanImage(angle, Self.Sample.Radius);
179179
results := Self.ScaledSearch(clean);
180180

@@ -265,9 +265,9 @@ begin
265265
with cleanMinimap.Center do
266266
begin
267267
if RSClient.Mode = ERSMode.FIXED then
268-
p := Point(X, Y).Offset(0, 8).Rotate(-Minimap.GetCompassAngle(False), [X,Y])
268+
p := Point(X, Y).Offset(0, 8).Rotate(-Minimap.CompassRadians, [X,Y])
269269
else
270-
p := Point(X, Y).Offset(2, 1).Rotate(-Minimap.GetCompassAngle(False), [X,Y]);
270+
p := Point(X, Y).Offset(2, 1).Rotate(-Minimap.CompassRadians, [X,Y]);
271271
end;
272272

273273
cleanMinimap.DrawColor := $FFFFFF;

osrs/position/map/entities.simba

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ var
162162
weights: TDoubleArray;
163163
begin
164164
coordinates := [];
165-
if angle = $FFFF then angle := Minimap.GetCompassAngle(False);
165+
if angle = $FFFF then angle := Minimap.CompassRadians;
166166

167167
h := Self.Walker^.Height(me);
168168

@@ -351,7 +351,7 @@ begin
351351

352352
if attempt <> (attempts - 1) then Continue;
353353

354-
angle := Minimap.GetCompassAngle();
354+
angle := Minimap.CompassDegrees;
355355
Minimap.SetCompassAngle(angle-50, angle+50);
356356
end;
357357
end;
@@ -423,7 +423,7 @@ begin
423423
Continue;
424424
end;
425425

426-
Minimap.SetCompassAngle(Minimap.GetCompassAngle(), 50);
426+
Minimap.SetCompassAngle(Minimap.CompassDegrees, 50);
427427
end;
428428
end;
429429

@@ -734,7 +734,7 @@ var
734734
coordinates: TPointArray;
735735
begin
736736
me := entity.Walker^.Position();
737-
filters := entity.Walker^.FiltersToMM(me, entity.Filter, Minimap.GetCompassAngle(False));
737+
filters := entity.Walker^.FiltersToMM(me, entity.Filter, Minimap.CompassRadians);
738738

739739
for filter in filters do
740740
begin

osrs/position/map/map.simba

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ begin
285285
Self.Region := [];
286286
Self.Similarity := 0;
287287

288-
angle := Minimap.GetCompassAngle(False);
288+
angle := Minimap.CompassRadians;
289289
clean := Minimap.GetCleanImage(angle, Self.Sample.Radius);
290290
results := Self.ScaledSearch(clean);
291291

@@ -442,7 +442,7 @@ begin
442442
' - Plane : ' + ToStr(Self.Region.Plane),
443443
' - Local : ' + _BoxStr(Self.Region.Region),
444444
' - Original: ' + _BoxStr(Self.Region.Original),
445-
' - Compass: ' + ToStr(Minimap.GetCompassAngle()),
445+
' - Compass: ' + ToStr(Minimap.CompassDegrees),
446446
'',
447447
'Certainty: ' + ToStr(Round(Self.Similarity, 3)),
448448
'Time: ' + ToStr(Round(time)) + ' ms'
@@ -462,9 +462,9 @@ begin
462462
with cleanMinimap.Center do
463463
begin
464464
if RSClient.Mode = ERSMode.FIXED then
465-
p := Point(X, Y).Offset(0, 8).Rotate(-Minimap.GetCompassAngle(False), [X,Y])
465+
p := Point(X, Y).Offset(0, 8).Rotate(-Minimap.CompassRadians, [X,Y])
466466
else
467-
p := Point(X, Y).Offset(2, 1).Rotate(-Minimap.GetCompassAngle(False), [X,Y]);
467+
p := Point(X, Y).Offset(2, 1).Rotate(-Minimap.CompassRadians, [X,Y]);
468468
end;
469469

470470
cleanMinimap.DrawColor := $FFFFFF;
@@ -525,7 +525,7 @@ var
525525
angle, h: Single;
526526
img: TImage;
527527
begin
528-
angle := Minimap.GetCompassAngle(False);
528+
angle := Minimap.CompassRadians;
529529

530530
img := Target.GetImage();
531531
img.DrawColor := $00FF00;
@@ -577,7 +577,7 @@ var
577577
currLoc: TPoint;
578578
arr: TPointArray;
579579
begin
580-
if angle = $FFFF then angle := Minimap.GetCompassAngle(False);
580+
if angle = $FFFF then angle := Minimap.CompassRadians;
581581
vector := Self.Walker.Point2MMVec(me, pt, angle);
582582
pt := vector.ToPoint();
583583

0 commit comments

Comments
 (0)