diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 6e7e623df16..3a152e9d7f5 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Projectiles; using Robust.Shared.Physics.Events; using Robust.Shared.Player; +using Robust.Shared.Random; namespace Content.Server.Projectiles; @@ -18,6 +19,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem [Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly GunSystem _guns = default!; [Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!; + [Dependency] private readonly IRobustRandom _random = default!; private EntityQuery _penetratableQuery; @@ -92,7 +94,7 @@ public bool TryHandleProjectile(EntityUid target, Entity pr var afterProjectileHitEvent = new AfterProjectileHitEvent(component.Damage, target); RaiseLocalEvent(uid, ref afterProjectileHitEvent); - if (component.PenetrationScore > 0 && _penetratableQuery.TryGetComponent(target, out var penetratable)) + if (component.PenetrationScore > 0 && _penetratableQuery.TryGetComponent(target, out var penetratable) && _random.Prob(component.PenetrationProb)) { component.DamagedEntity = component.PenetrationScore < penetratable.StoppingPower; diff --git a/Content.Shared/Projectiles/ProjectileComponent.cs b/Content.Shared/Projectiles/ProjectileComponent.cs index 8cbe54fce3e..292bdcb3547 100644 --- a/Content.Shared/Projectiles/ProjectileComponent.cs +++ b/Content.Shared/Projectiles/ProjectileComponent.cs @@ -76,4 +76,7 @@ public sealed partial class ProjectileComponent : Component [DataField] public int PenetrationScore; + + [DataField] + public float PenetrationProb = 0.7f; }