From 862675e71b1663f329178a3338fdf151cfc63d97 Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Sat, 3 Jan 2026 11:33:28 -0800 Subject: [PATCH] [STAGING] Fix Disabler SMG bolts going through walls (#42195) * RAH RAH RASPUTIN LOVER OF THE RUSSIAN QUEEN! * delete if we do 0 damage * actually change that * dont get soaped into cleaning things up challenge impossible --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> --- .../Projectiles/ProjectileSystem.cs | 96 ++++++++++--------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index cc4eda4307..87fc13b563 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Destructible; using Content.Server.Effects; using Content.Server.Weapons.Ranged.Systems; using Content.Shared.Camera; +using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.Damage.Systems; using Content.Shared.Database; @@ -69,51 +70,11 @@ public sealed class ProjectileSystem : SharedProjectileSystem LogImpact.Medium, $"Projectile {ToPrettyString(uid):projectile} shot by {ToPrettyString(component.Shooter!.Value):user} hit {otherName:target} and dealt {damage:damage} damage"); - // If penetration is to be considered, we need to do some checks to see if the projectile should stop. - if (component.PenetrationThreshold != 0) - { - // If a damage type is required, stop the bullet if the hit entity doesn't have that type. - if (component.PenetrationDamageTypeRequirement != null) - { - var stopPenetration = false; - foreach (var requiredDamageType in component.PenetrationDamageTypeRequirement) - { - if (!damage.DamageDict.Keys.Contains(requiredDamageType)) - { - stopPenetration = true; - break; - } - } - if (stopPenetration) - component.ProjectileSpent = true; - } - - var pierceEv = new ProjectilePierceEvent(target, damageRequired); // DeltaV - Addition of the NT-3 - RaiseLocalEvent(uid, ref pierceEv); - - // If the object won't be destroyed, it "tanks" the penetration hit. - if (damage.GetTotal() < damageRequired) - { - component.ProjectileSpent = true; - } - - if (!component.ProjectileSpent) - { - component.PenetrationAmount += damageRequired; - // The projectile has dealt enough damage to be spent. - if (component.PenetrationAmount >= component.PenetrationThreshold) - { - component.ProjectileSpent = true; - } - } - - if (component.ProjectileSpent && pierceEv.Pierced) // DeltaV - Addition of the NT-3 - component.ProjectileSpent = false; - } - else - { - component.ProjectileSpent = true; - } + component.ProjectileSpent = !TryPenetrate((uid, component), damage, damageRequired, target); // DeltaV - Addition of the NT-3 + } + else + { + component.ProjectileSpent = true; } if (!deleted) @@ -132,4 +93,49 @@ public sealed class ProjectileSystem : SharedProjectileSystem RaiseNetworkEvent(new ImpactEffectEvent(component.ImpactEffect, GetNetCoordinates(xform.Coordinates)), Filter.Pvs(xform.Coordinates, entityMan: EntityManager)); } } + + private bool TryPenetrate(Entity projectile, DamageSpecifier damage, FixedPoint2 damageRequired, EntityUid target) // DeltaV - Addition of the NT-3 + { + // If penetration is to be considered, we need to do some checks to see if the projectile should stop. + if (projectile.Comp.PenetrationThreshold == 0) + return false; + + // If a damage type is required, stop the bullet if the hit entity doesn't have that type. + if (projectile.Comp.PenetrationDamageTypeRequirement != null) + { + foreach (var requiredDamageType in projectile.Comp.PenetrationDamageTypeRequirement) + { + if (damage.DamageDict.Keys.Contains(requiredDamageType)) + continue; + + return false; + } + } + + var pierceEv = new ProjectilePierceEvent(target, damageRequired); // DeltaV - Addition of the NT-3 + RaiseLocalEvent(projectile, ref pierceEv); + + // If the object won't be destroyed, it "tanks" the penetration hit. + if (damage.GetTotal() < damageRequired) + { + return false; + } + + if (!projectile.Comp.ProjectileSpent) + { + projectile.Comp.PenetrationAmount += damageRequired; + // The projectile has dealt enough damage to be spent. + if (projectile.Comp.PenetrationAmount >= projectile.Comp.PenetrationThreshold) + { + return false; + } + + if (projectile.Comp.ProjectileSpent && pierceEv.Pierced) // DeltaV - Addition of the NT-3 + { + return true; + } + } + + return true; + } }