From e95cb7540d31a9f35ce644a06219596793eebd88 Mon Sep 17 00:00:00 2001 From: teees Date: Tue, 3 Nov 2015 15:35:52 +0100 Subject: [PATCH 1/3] Fix immovable actors not dropping targets that are out of range --- OpenRA.Mods.Common/Activities/Attack.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 94df1d1af8..8d164ee376 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -76,9 +76,13 @@ namespace OpenRA.Mods.Common.Activities minRange = armaments.Max(a => a.Weapon.MinRange); maxRange = armaments.Min(a => a.MaxRange()); - // Try to move within range - if (move != null && (!Target.IsInRange(self.CenterPosition, maxRange) || Target.IsInRange(self.CenterPosition, minRange))) + if (!Target.IsInRange(self.CenterPosition, maxRange) || Target.IsInRange(self.CenterPosition, minRange)) + { + // Try to move within range, drop the target otherwise + if (move == null) + return NextActivity; return ActivityUtils.SequenceActivities(move.MoveWithinRange(Target, minRange, maxRange), this); + } var desiredFacing = (Target.CenterPosition - self.CenterPosition).Yaw.Facing; if (facing.Facing != desiredFacing) From dc6d31cec8a18c45a93c4c6c080ac54731a79646 Mon Sep 17 00:00:00 2001 From: teees Date: Wed, 4 Nov 2015 09:19:58 +0100 Subject: [PATCH 2/3] Fix turreted immovable actors not dropping targets that are out of range --- OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index 39957d4f0f..1b97dc918e 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -96,8 +96,11 @@ namespace OpenRA.Mods.Common.Traits if (move != null) return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this); + if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) && !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange)) + return this; } + attack.Target = Target.Invalid; return NextActivity; } } From ce62e456d74b99b364727e7cf6a8f38b0262130a Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Wed, 3 Feb 2016 19:28:45 +0100 Subject: [PATCH 3/3] Fix TD gunboat attack behaviour --- OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index 1b97dc918e..c9686ff459 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -58,16 +58,20 @@ namespace OpenRA.Mods.Common.Traits readonly IMove move; readonly Target target; readonly bool forceAttack; + readonly bool onRailsHack; public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack) { attack = self.Trait(); move = allowMove ? self.TraitOrDefault() : null; - // HACK: Mobile.OnRails is horrible + // HACK: Mobile.OnRails is horrible. Blergh. var mobile = move as Mobile; if (mobile != null && mobile.Info.OnRails) + { move = null; + onRailsHack = true; + } this.target = target; this.forceAttack = forceAttack; @@ -96,11 +100,15 @@ namespace OpenRA.Mods.Common.Traits if (move != null) return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this); - if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) && !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange)) + if (!onRailsHack && + target.IsInRange(self.CenterPosition, weapon.MaxRange()) && + !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange)) return this; } - attack.Target = Target.Invalid; + if (!onRailsHack) + attack.Target = Target.Invalid; + return NextActivity; } }