From a3c5945f2a7036c51444dd5e66ac44650d2050fb Mon Sep 17 00:00:00 2001 From: dnqbob Date: Sat, 29 Jul 2023 20:53:04 +0800 Subject: [PATCH] Set BackwardDuration to -1 means ignore the time and set MaxBackwardCells to -1 means ignore the distance. --- OpenRA.Mods.Common/Activities/Move/Move.cs | 5 ++++- OpenRA.Mods.Common/Traits/Mobile.cs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index c037c74629..6d63f05af8 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -160,7 +160,10 @@ namespace OpenRA.Mods.Common.Activities var firstFacing = self.World.Map.FacingBetween(mobile.FromCell, nextCell.Value.Cell, mobile.Facing); - if (mobile.Info.CanMoveBackward && path.Count < mobile.Info.MaxBackwardCells && self.World.WorldTick - startTicks < mobile.Info.BackwardDuration && Math.Abs(firstFacing.Angle - mobile.Facing.Angle) > 256) + if (mobile.Info.CanMoveBackward + && (mobile.Info.MaxBackwardCells < 0 || path.Count < mobile.Info.MaxBackwardCells) + && (mobile.Info.BackwardDuration < 0 || self.World.WorldTick - startTicks < mobile.Info.BackwardDuration) + && Math.Abs(firstFacing.Angle - mobile.Facing.Angle) > 256) { ActorFacingModifier = new WAngle(512); firstFacing += ActorFacingModifier; diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 3aba310d6d..9a9c74cc2d 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -71,10 +71,12 @@ namespace OpenRA.Mods.Common.Traits [Desc("Can move backward if possible")] public readonly bool CanMoveBackward = false; - [Desc("After how many ticks the actor will turn forward during backoff")] + [Desc("After how many ticks the actor will turn forward during backoff.", + "If set to -1 the unit will be allowed to move backwards without time limit.")] public readonly int BackwardDuration = 40; - [Desc("Actor will try to move backward if the number of the cells in path lower than this")] + [Desc("Actor will only try to move backwards when the path (in cells) is shorter than this value.", + "If set to -1 the unit will be allowed to move backwards without range limit.")] public readonly int MaxBackwardCells = 15; [ConsumedConditionReference]