From 163688fc397f9d873fcb38243a40bd12e86f74f2 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 12 Mar 2016 20:41:35 +0000 Subject: [PATCH] Prevent turrets from firing until they are aligned with the target. --- OpenRA.Mods.Common/Traits/Armament.cs | 3 +++ OpenRA.Mods.Common/Traits/Turreted.cs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index 1fc2298d50..45fd8d3a2a 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -186,6 +186,9 @@ namespace OpenRA.Mods.Common.Traits if (ammoPool != null && !ammoPool.HasAmmo()) return null; + if (turret != null && !turret.HasAchievedDesiredFacing) + return null; + if (!target.IsInRange(self.CenterPosition, MaxRange())) return null; diff --git a/OpenRA.Mods.Common/Traits/Turreted.cs b/OpenRA.Mods.Common/Traits/Turreted.cs index ab477a653b..6d14a6eacd 100644 --- a/OpenRA.Mods.Common/Traits/Turreted.cs +++ b/OpenRA.Mods.Common/Traits/Turreted.cs @@ -113,7 +113,12 @@ namespace OpenRA.Mods.Common.Traits var delta = target.CenterPosition - self.CenterPosition; DesiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : TurretFacing; MoveTurret(); - return TurretFacing == DesiredFacing.Value; + return HasAchievedDesiredFacing; + } + + public bool HasAchievedDesiredFacing + { + get { return DesiredFacing != null && TurretFacing == DesiredFacing.Value; } } // Turret offset in world-space