Skip to content

Commit

Permalink
Backwards compatible engine thrust for new drag formula
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mygamingaccount committed Oct 16, 2024
1 parent b7cdd42 commit a75dc2d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using System.Xml.Linq;
using Barotrauma.Networking;
using FarseerPhysics.Dynamics;

namespace Barotrauma.Items.Components
{
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit a75dc2d

Please sign in to comment.