Skip to content

Commit

Permalink
Merge pull request #596 from FFXIV-CombatReborn/mergeWIP
Browse files Browse the repository at this point in the history
misdirection tweak
  • Loading branch information
CarnifexOptimus authored Feb 9, 2025
2 parents f5a581a + 5fbfa76 commit e7cc31d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions BossMod/AI/AIBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 5 additions & 8 deletions BossMod/Pathfinding/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,9 @@ public void BlockPixelsInside2(Func<WPos, float> 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];

Expand All @@ -227,9 +225,6 @@ public void BlockPixelsInside2(Func<WPos, float> 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)
{
Expand All @@ -241,6 +236,8 @@ public void BlockPixelsInside2(Func<WPos, float> shape, float maxG)
err += dx;
y1 += sy;
}

result[i] = (x1, y1);
}

return result;
Expand Down

0 comments on commit e7cc31d

Please sign in to comment.