From a75dc2d17f10b4c8ef4f475b17a345cacba58a86 Mon Sep 17 00:00:00 2001 From: mygamingaccount <68995233+mygamingaccount@users.noreply.github.com> Date: Thu, 17 Oct 2024 00:13:47 +0200 Subject: [PATCH] Backwards compatible engine thrust for new drag formula A sub 10 times smaller used to need 10 times less thrust force to achieve the same speed. The new drag formula needs about 4.6 times more than that. This change in the thust-to-weight ratio means faster acceleration for drones and shuttles. Calculate this factor to prevent the top speed from changing in existing submarine designs. --- .../SharedSource/Items/Components/Machines/Engine.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Engine.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Engine.cs index 7083a1fd46..80ef5e303f 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Engine.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Engine.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.Xml.Linq; using Barotrauma.Networking; +using FarseerPhysics.Dynamics; namespace Barotrauma.Items.Components { @@ -144,6 +145,12 @@ public override void Update(float deltaTime, Camera cam) UpdateAITargets(noise); //arbitrary multiplier that was added to changes in submarine mass without having to readjust all engines float forceMultiplier = 0.1f; + if (item.Submarine.SubBody.Body != null) + { + float mass = item.Submarine.SubBody.Body.Mass; + float newDragCorrectionFactor = MathF.Pow(mass / SubmarineBody.InertiaReferenceMass, SubmarineBody.MassToAreaExponent) * SubmarineBody.InertiaReferenceMass / mass; + forceMultiplier *= newDragCorrectionFactor; + } if (User != null) { forceMultiplier *= MathHelper.Lerp(0.5f, 2.0f, (float)Math.Sqrt(User.GetSkillLevel("helm") / 100));