From baadd60d8da2b15947c9867a4349e4d72829a2e8 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 2 Apr 2019 12:42:00 +0300 Subject: [PATCH] (cd4cc584f) Fixed projectiles not applying status effects on impact if they have no attack defined. Closes #1382 --- .../Source/Items/Components/Projectile.cs | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs index 320adf9ab..1afa079da 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs @@ -361,32 +361,29 @@ namespace Barotrauma.Items.Components AttackResult attackResult = new AttackResult(); Character character = null; - if (attack != null) + if (target.Body.UserData is Submarine submarine) { - if (target.Body.UserData is Submarine submarine) + item.Move(-submarine.Position); + item.Submarine = submarine; + item.body.Submarine = submarine; + return !Hitscan; + } + else if (target.Body.UserData is Limb limb) + { + //severed limbs don't deactivate the projectile (but may still slow it down enough to make it inactive) + if (limb.IsSevered) { - item.Move(-submarine.Position); - item.Submarine = submarine; - item.body.Submarine = submarine; - return !Hitscan; + target.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass); + return true; } - else if (target.Body.UserData is Limb limb) - { - //severed limbs don't deactivate the projectile (but may still slow it down enough to make it inactive) - if (limb.IsSevered) - { - target.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass); - return true; - } - limb.character.LastDamageSource = item; - attackResult = attack.DoDamageToLimb(User, limb, item.WorldPosition, 1.0f); - if (limb.character != null) character = limb.character; - } - else if (target.Body.UserData is Structure structure) - { - attackResult = attack.DoDamage(User, structure, item.WorldPosition, 1.0f); - } + limb.character.LastDamageSource = item; + if (attack != null) { attackResult = attack.DoDamageToLimb(User, limb, item.WorldPosition, 1.0f); } + if (limb.character != null) { character = limb.character; } + } + else if (target.Body.UserData is Structure structure) + { + if (attack != null) { attackResult = attack.DoDamage(User, structure, item.WorldPosition, 1.0f); } } if (character != null) character.LastDamageSource = item;