From df8295fa2c14f1dc9ec8212d2c72d0581e03ac3d Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 18 Jun 2021 19:34:54 +0200 Subject: [PATCH] Make aircraft turn speed scale with speed modifiers --- OpenRA.Mods.Common/Activities/Air/Fly.cs | 2 +- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Activities/Air/Fly.cs b/OpenRA.Mods.Common/Activities/Air/Fly.cs index f128da2412..4c3c298282 100644 --- a/OpenRA.Mods.Common/Activities/Air/Fly.cs +++ b/OpenRA.Mods.Common/Activities/Air/Fly.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities move = moveOverride; var oldFacing = aircraft.Facing; - var turnSpeed = idleTurn ? aircraft.IdleTurnSpeed ?? aircraft.TurnSpeed : aircraft.TurnSpeed; + var turnSpeed = aircraft.GetTurnSpeed(idleTurn); aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, turnSpeed); var roll = idleTurn ? aircraft.Info.IdleRoll ?? aircraft.Info.Roll : aircraft.Info.Roll; diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index b05d8cdfef..cb3f6d3b92 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -268,6 +268,18 @@ namespace OpenRA.Mods.Common.Traits public WAngle TurnSpeed => IsTraitDisabled || IsTraitPaused ? WAngle.Zero : Info.TurnSpeed; public WAngle? IdleTurnSpeed => IsTraitDisabled || IsTraitPaused ? null : Info.IdleTurnSpeed; + public WAngle GetTurnSpeed(bool isIdleTurn) + { + // A MovementSpeed of zero indicates either a speed modifier of zero percent or that the trait is paused or disabled. + // Bail early in that case. + if ((isIdleTurn && IdleMovementSpeed == 0) || MovementSpeed == 0) + return WAngle.Zero; + + var turnSpeed = isIdleTurn ? IdleTurnSpeed ?? TurnSpeed : TurnSpeed; + + return new WAngle(Util.ApplyPercentageModifiers(turnSpeed.Angle, speedModifiers).Clamp(1, 1024)); + } + public Actor ReservedActor { get; private set; } public bool MayYieldReservation { get; private set; } public bool ForceLanding { get; private set; }