diff --git a/BossMod/AI/AIBehaviour.cs b/BossMod/AI/AIBehaviour.cs index ea68434de4..8af401bc3d 100644 --- a/BossMod/AI/AIBehaviour.cs +++ b/BossMod/AI/AIBehaviour.cs @@ -238,11 +238,11 @@ private void UpdateMovement(Actor player, Actor master, Targeting target, bool g ctrl.AllowInterruptingCastByMovement = true; var dir = _naviDecision.Destination.Value - player.Position; var distSq = dir.LengthSq(); - var threshold = 30f.Degrees(); + var threshold = 45f.Degrees(); var forceddir = WorldState.Client.ForcedMovementDirection; var allowMovement = forceddir.AlmostEqual(Angle.FromDirection(dir), threshold.Rad); if (allowMovement) - allowMovement = CalculateUnobstructedPathLength(forceddir) >= Math.Min(4f, distSq); + allowMovement = CalculateUnobstructedPathLength(forceddir) >= Math.Min(3f, distSq); ctrl.NaviTargetPos = allowMovement && distSq >= 0.01f ? _naviDecision.Destination.Value : null; float CalculateUnobstructedPathLength(Angle dir) diff --git a/BossMod/Pathfinding/Map.cs b/BossMod/Pathfinding/Map.cs index 89b21edbf1..d2f2410437 100644 --- a/BossMod/Pathfinding/Map.cs +++ b/BossMod/Pathfinding/Map.cs @@ -213,11 +213,9 @@ public void BlockPixelsInside2(Func shape, float maxG) // enumerate pixels along line starting from (x1, y1) to (x2, y2); first is not returned, last is returned public (int x, int y)[] EnumeratePixelsInLine(int x1, int y1, int x2, int y2) { - var shiftx2x1 = (x2 - x1) >> 31; - var shifty2y1 = (y2 - y1) >> 31; - var absDx = (x2 - x1) ^ (shiftx2x1 - shiftx2x1); - var absDy = (y2 - y1) ^ (shifty2y1 - shifty2y1); - var estimatedLength = (absDx ^ ((absDx ^ absDy) & -(absDx < absDy ? 1 : 0))) + 1; + var absDx = Math.Abs(x2 - x1); + var absDy = Math.Abs(y2 - y1); + var estimatedLength = Math.Max(absDx, absDy); var result = new (int x, int y)[estimatedLength]; @@ -227,9 +225,6 @@ public void BlockPixelsInside2(Func shape, float maxG) for (var i = 0; i < estimatedLength; ++i) { - result[i] = (x1, y1); - if (x1 == x2 && y1 == y2) - break; e2 = 2 * err; if (e2 >= dy) { @@ -241,6 +236,8 @@ public void BlockPixelsInside2(Func shape, float maxG) err += dx; y1 += sy; } + + result[i] = (x1, y1); } return result;