From 6777a039d5d6927b735f7685f77a36c8f0f17c25 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 30 Dec 2017 02:17:08 +0200 Subject: [PATCH] Characters receive damage when crushed between a sub and the level and are gibbed if the impact is hard enough. Closes #186 --- .../BarotraumaShared/Source/Map/SubmarineBody.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Barotrauma/BarotraumaShared/Source/Map/SubmarineBody.cs b/Barotrauma/BarotraumaShared/Source/Map/SubmarineBody.cs index fb1bd935a..783dcce34 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/SubmarineBody.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/SubmarineBody.cs @@ -491,6 +491,22 @@ namespace Barotrauma if (contactDot > 0.0f) { Body.LinearVelocity -= Vector2.Normalize(Body.LinearVelocity) * contactDot; + + float damageAmount = contactDot * Body.Mass / limb.character.Mass; + + Vector2 n; + FixedArray2 contactPos; + contact.GetWorldManifold(out n, out contactPos); + limb.character.DamageLimb(ConvertUnits.ToDisplayUnits(contactPos[0]), limb, DamageType.Blunt, damageAmount, 0.0f, 0.0f, true, 0.0f); + + if (limb.character.IsDead) + { + foreach (LimbJoint limbJoint in limb.character.AnimController.LimbJoints) + { + if (limbJoint.IsSevered || (limbJoint.LimbA != limb && limbJoint.LimbB != limb)) continue; + limb.character.AnimController.SeverLimbJoint(limbJoint); + } + } } }