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

Commit

Permalink
Merge pull request #339 from NEirotoXiN00/ReworkPent
Browse files Browse the repository at this point in the history
Chance Penetration
  • Loading branch information
Vonsant authored Jun 25, 2024
2 parents e2387a0 + afc4b4b commit 9d1bfbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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;
}

0 comments on commit 9d1bfbd

Please sign in to comment.