From c093e7c90bdf8361c9e8b1aa46ec0023680f20f4 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Tue, 25 Jul 2023 10:43:08 +0300 Subject: [PATCH] Fix hunt incorrectly pathing to uncrushable targets --- OpenRA.Mods.Common/Activities/Hunt.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Hunt.cs b/OpenRA.Mods.Common/Activities/Hunt.cs index 6362507639..7875ec0c10 100644 --- a/OpenRA.Mods.Common/Activities/Hunt.cs +++ b/OpenRA.Mods.Common/Activities/Hunt.cs @@ -36,11 +36,18 @@ namespace OpenRA.Mods.Common.Activities if (IsCanceling) return true; - var target = targets.ClosestTo(self); - if (target == null) + var targetActor = targets.ClosestTo(self); + if (targetActor == null) return false; - QueueChild(new AttackMoveActivity(self, () => move.MoveTo(target.Location, 2))); + var target = Target.FromActor(targetActor); + var range = self.TraitsImplementing().Max(ab => ab.GetMaximumRangeVersusTarget(target)); + + // We want to keep at least 2 cells of distance from the target to prevent the pathfinder from thinking the target position is blocked. + if (range.Length < 2048) + range = WDist.FromCells(2); + + QueueChild(new AttackMoveActivity(self, () => move.MoveWithinRange(Target.FromCell(self.World, targetActor.Location), range))); QueueChild(new Wait(25)); return false; }