@@ -232,11 +232,11 @@ var
232232 arr: TPointArray;
233233begin
234234 if not me.InRange(mapPoint, MM2MS.MAX_RENDER_DISTANCE) then Exit;
235- if radians = $FFFF then radians := Minimap.GetCompassAngle(False) ;
235+ if radians = $FFFF then radians := Minimap.CompassRadians ;
236236 vector := Self.Point2MMVec(me, mapPoint, radians);
237237 pt := vector.ToPoint();
238238
239- vector := Minimap.NormalizeEx(vector, radians );
239+ vector := vector.Rotate(-radians, Minimap.Center.ToVec2() );
240240 me := Self.GetLocal(me);
241241
242242 h := Self.Height(me - [1,3], False) + Self.Height(me + [3,-3], False) +
@@ -265,11 +265,11 @@ var
265265 arr: TPointArray;
266266begin
267267 if not me.InRange(mapPoint, MM2MS.MAX_RENDER_DISTANCE) then Exit;
268- if radians = $FFFF then radians := Minimap.GetCompassAngle(False) ;
268+ if radians = $FFFF then radians := Minimap.CompassRadians ;
269269 vector := Self.Point2MMVec(me, mapPoint, radians);
270270 pt := vector.ToPoint();
271271
272- vector := Minimap.NormalizeEx(vector, radians );
272+ vector := vector.Rotate(-radians, Minimap.Center.ToVec2() );
273273 me := Self.GetLocal(me);
274274
275275 h := Self.Height(me - [1,3], False) + Self.Height(me + [3,-3], False) +
@@ -299,7 +299,7 @@ function TRSWalker.MM2Map(me, minimapPoint: TPoint; radians: Single = $FFFF): TP
299299begin
300300 Result := me + minimapPoint - Minimap.Center;
301301 if (radians = $FFFF) then
302- radians := Minimap.GetCompassAngle(False) ;
302+ radians := Minimap.CompassRadians ;
303303 Result := Result.Rotate(-radians, me);
304304end;
305305
433433 speed: Double;
434434 angle, h, diff: Single;
435435 begin
436- angle := Minimap.GetCompassAngle(False) ;
436+ angle := Minimap.CompassRadians ;
437437 idx := Self._Index;
438438
439439 while (idx < High(Self._Path)) and Self.IsWalkable(Self._Path[idx+1].Node, myPos, tmp, angle) do
@@ -511,7 +511,7 @@ begin
511511 if position.Current <> position.Previous then
512512 countdown.Restart();
513513
514- //if (Self._Node <> EGraphNode.NORMAL) and Self.FlagMoved(position.Current, Minimap.GetCompassAngle(False) ) then
514+ //if (Self._Node <> EGraphNode.NORMAL) and Self.FlagMoved(position.Current, Minimap.CompassRadians ) then
515515 begin
516516 Self.Walking := False;
517517 Break;
@@ -584,7 +584,11 @@ begin
584584
585585 if Self.ScreenWalk then
586586 begin
587- pt := mapPoint.Random(-8, 8);
587+ if randomness = 0 then
588+ pt := mapPoint
589+ else
590+ pt := mapPoint.Random(-randomness, randomness);
591+
588592 if not me.InRange(pt, MM2MS.MAX_RENDER_DISTANCE) then Exit;
589593
590594 quad := Self.GetQuadMS(me, pt);
@@ -666,7 +670,7 @@ begin
666670 if @Self.OnWalkEvent <> nil then Self.OnWalkEvent(@Self, me, mapPoint);
667671 if Time() - t > 100 then me := Self.Position(); //Check if event took too long and update position.
668672
669- if not Self.Walking or not Self.IsWalkable(mapPoint, me, minimapPoint, Minimap.GetCompassAngle(False) ) then
673+ if not Self.Walking or not Self.IsWalkable(mapPoint, me, minimapPoint, Minimap.CompassRadians ) then
670674 Exit(not Self.Walking);
671675
672676 if Minimap.Center.InRange(minimapPoint, 4) then
@@ -720,28 +724,26 @@ end;
720724function TRSWalker.CrossDoor(me: TPoint; index: Integer; attempts: Integer = 3): Boolean;
721725var
722726 tmp: TPoint;
723- door, furthest: Integer;
727+ furthest: Integer;
724728 radians: Double;
725729 mapPt, minimapPt, flag: TPoint;
726730 shouldExit, handleDoor: Boolean;
727731 cuboid: TCuboid;
728732begin
729- WriteLn GetDebugLn(Self.Name, 'Attempting to cross door');
730733 if attempts = 0 then Exit;
731-
732734 if index = High(Self._Path) then
733735 raise GetDebugLn(Self.Name, 'Paths should not end at a door node.');
736+ WriteLn GetDebugLn(Self.Name, 'Attempting to cross door');
734737
735- door := Self._Path.IndexOf(Self._Path[index].Node);
736- furthest := door;
738+ furthest := index;
737739
738- radians := Minimap.GetCompassAngle(False) ;
740+ radians := Minimap.CompassRadians ;
739741 while (furthest < High(Self._Path)) and Self.IsWalkable(Self._Path[furthest+1].Node, me, tmp, radians) do
740742 if Self._Path[furthest+1].Typ = EGraphNode.NORMAL then
741743 Inc(furthest);
742744
743745 if Biometrics.RandomBoolean(0.002) then
744- furthest := Random(door , furthest);
746+ furthest := Random(index , furthest);
745747
746748 mapPt := Self._Path[furthest].Node;
747749 if not Self._WalkStepHelper(me, mapPt, 0, minimapPt, shouldExit) then
@@ -750,7 +752,7 @@ begin
750752 if shouldExit then Exit;
751753
752754 if Self.WaitFlag(flag) then
753- handleDoor := Self.FlagMoved(flag, radians)
755+ handleDoor := not me.InRange(flag, 12) and Self.FlagMoved(flag, radians)
754756 else
755757 handleDoor := True;
756758
@@ -766,7 +768,7 @@ begin
766768 if handleDoor then
767769 begin
768770 WriteLn GetDebugLn(Self.Name, 'Attempting to open door');
769- cuboid := Self.GetCuboidMS(me, Self._Path[door ].Node, [0.6,0.6,4], radians);
771+ cuboid := Self.GetCuboidMS(me, Self._Path[index ].Node, [0.6,0.6,4], radians);
770772 ShowOnTarget(cuboid);
771773 Mouse.Move(cuboid.ShapeFill().RandomMean());
772774 if MainScreen.IsUpText('Open') then
821823 path: TPointArray;
822824 compass: Single;
823825begin
824- compass := Minimap.GetCompassAngle(False) ;
826+ compass := Minimap.CompassRadians ;
825827 for i := 0 to High(Self._Path) do
826828 if me.InRange(Self._Path[i].Node, 90) then
827829 path += Self.Point2MM(me, Self._Path[i].Node, compass);
@@ -971,7 +973,7 @@ begin
971973 if (Result = 5) then
972974 begin
973975 Minimap.SetCompassAngle(RadToDeg(angle) + RandomLeft(30, 360) * Random(-1,1));
974- angle := Minimap.GetCompassAngle(False) ;
976+ angle := Minimap.CompassRadians ;
975977 end;
976978
977979 if Result mod 2 = 0 then
@@ -1007,7 +1009,7 @@ var
10071009begin
10081010 Self._WalkPathSetup(path);
10091011
1010- angle := Minimap.GetCompassAngle(False) ;
1012+ angle := Minimap.CompassRadians ;
10111013 while Self.Walking and (fails < 10) do
10121014 begin
10131015 me := Self.Position();
@@ -1165,7 +1167,7 @@ Wrapper function used to attempt to make a Point visible on the MainScreen.
11651167*)
11661168function TRSWalker.MakePointVisible(me: TPoint; pt: TPoint): Boolean;
11671169begin
1168- Result := Minimap.MakePointVisible(Self.Point2MM(me, pt, Minimap.GetCompassAngle(False) ));
1170+ Result := Minimap.MakePointVisible(Self.Point2MM(me, pt, Minimap.CompassRadians ));
11691171end;
11701172
11711173function TRSWalker.MakePointVisible(pt: TPoint): Boolean; overload;
0 commit comments