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 #98 from FireNameFN/PenetrationSystem
Browse files Browse the repository at this point in the history
Added penetration system
  • Loading branch information
Zekins3366 authored May 2, 2024
2 parents d2d8aab + 1022144 commit add2341
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Content.Server/Projectiles/ProjectileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Effects;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Camera;
using Content.Shared.Corvax.Penetration;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Projectiles;
Expand All @@ -18,9 +19,12 @@ public sealed class ProjectileSystem : SharedProjectileSystem
[Dependency] private readonly GunSystem _guns = default!;
[Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!;

private EntityQuery<PenetratableComponent> _penetratableQuery;

public override void Initialize()
{
base.Initialize();
_penetratableQuery = GetEntityQuery<PenetratableComponent>();
SubscribeLocalEvent<ProjectileComponent, StartCollideEvent>(OnStartCollide);
}

Expand Down Expand Up @@ -67,9 +71,16 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St
_sharedCameraRecoil.KickCamera(target, direction);
}

component.DamagedEntity = true;
if (component.PenetrationScore > 0 && _penetratableQuery.TryGetComponent(target, out var penetratable))
{
component.DamagedEntity = component.PenetrationScore < penetratable.StoppingPower;

component.PenetrationScore -= penetratable.StoppingPower;
}
else
component.DamagedEntity = true;

if (component.DeleteOnCollide)
if (component.DeleteOnCollide && component.DamagedEntity)
QueueDel(uid);

if (component.ImpactEffect != null && TryComp<TransformComponent>(uid, out var xform))
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/Corvax/Penetration/PenetratableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Corvax.Penetration;

[RegisterComponent, NetworkedComponent]
public sealed partial class PenetratableComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
public int StoppingPower;
}
3 changes: 3 additions & 0 deletions Content.Shared/Projectiles/ProjectileComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@ public sealed partial class ProjectileComponent : Component
/// </summary>
[DataField]
public bool DamagedEntity;

[DataField]
public int PenetrationScore;
}
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
components:
- type: Damageable
damageContainer: Biological
- type: Penetratable
stoppingPower: 1
- type: Destructible
thresholds:
- trigger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
- type: Physics
- type: Damageable
damageContainer: Inorganic
- type: Penetratable
stoppingPower: 1
- type: Destructible
thresholds:
- trigger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
types:
Piercing: 40
Structural: 30
penetrationScore: 3
- type: StaminaDamageOnCollide
damage: 35
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 19
penetrationScore: 1

- type: entity
id: BulletMinigun
Expand All @@ -19,3 +20,4 @@
damage:
types:
Piercing: 5
penetrationScore: 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 19
penetrationScore: 1

- type: entity
id: BulletLightRiflePractice
Expand Down Expand Up @@ -54,3 +55,4 @@
types:
Radiation: 9
Piercing: 10
penetrationScore: 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 35
penetrationScore: 1

- type: entity
id: BulletMagnumPractice
Expand Down Expand Up @@ -55,6 +56,7 @@
damage:
types:
Piercing: 26 # 20% decrease
penetrationScore: 2
ignoreResistances: true

- type: entity
Expand All @@ -68,3 +70,4 @@
types:
Radiation: 15
Piercing: 20
penetrationScore: 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
damage:
types:
Piercing: 17
penetrationScore: 1

- type: entity
id: BulletRiflePractice
Expand Down Expand Up @@ -54,4 +55,5 @@
types:
Radiation: 7
Piercing: 8
penetrationScore: 1

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
damage:
types:
Piercing: 28
penetrationScore: 2

- type: entity
id: PelletShotgunBeanbag
Expand Down Expand Up @@ -41,6 +42,7 @@
damage:
types:
Piercing: 10
penetrationScore: 1

- type: entity
id: PelletShotgunIncendiary
Expand Down Expand Up @@ -177,6 +179,7 @@
types:
Radiation: 5
Piercing: 5
penetrationScore: 1

- type: entity
id: PelletGrapeshot #tally fucking ho
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Structures/Walls/walls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: StructuralMetallic
- type: Penetratable
stoppingPower: 2
- type: Physics
bodyType: Static
- type: Fixtures
Expand Down Expand Up @@ -530,6 +532,8 @@
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: StructuralMetallicStrong
- type: Penetratable
stoppingPower: 3
- type: Destructible
thresholds:
- trigger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: RGlass
- type: Penetratable
stoppingPower: 2
- type: RCDDeconstructable
cost: 6
delay: 6
Expand Down Expand Up @@ -103,6 +105,8 @@
sprite: Structures/Windows/cracks_directional.rsi
- type: Damageable
damageModifierSet: RGlass
- type: Penetratable
stoppingPower: 2
- type: RCDDeconstructable
cost: 4
delay: 4
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Structures/base_structure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- type: Clickable
- type: Physics
bodyType: Static
- type: Penetratable
stoppingPower: 1
- type: Fixtures
fixtures:
fix1:
Expand Down

0 comments on commit add2341

Please sign in to comment.