Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Chance Penetration #339

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Content.Server/Projectiles/ProjectileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<PenetratableComponent> _penetratableQuery;

Expand Down Expand Up @@ -92,7 +94,7 @@ public bool TryHandleProjectile(EntityUid target, Entity<ProjectileComponent> 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;

Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Projectiles/ProjectileComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ public sealed partial class ProjectileComponent : Component

[DataField]
public int PenetrationScore;

[DataField]
public float PenetrationProb = 0.7f;
}
Loading