diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 970536f42b0..d59d802d518 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -1,12 +1,14 @@ using Content.Server.Administration.Logs; using Content.Server.Effects; using Content.Server.Weapons.Ranged.Systems; +using Content.Shared._CorvaxNext.Penetration; using Content.Shared.Camera; using Content.Shared.Damage; using Content.Shared.Database; using Content.Shared.Projectiles; using Robust.Shared.Physics.Events; using Robust.Shared.Player; +using Robust.Shared.Random; namespace Content.Server.Projectiles; @@ -17,10 +19,14 @@ 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; public override void Initialize() { base.Initialize(); + _penetratableQuery = GetEntityQuery(); SubscribeLocalEvent(OnStartCollide); } @@ -67,10 +73,21 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St _sharedCameraRecoil.KickCamera(target, direction); } - component.DamagedEntity = true; + // Corvax-Next-Penetration-Start + if (component.PenetrationScore > 0 + && _penetratableQuery.TryGetComponent(target, out var penetratable) + && _random.Next(component.PenetrationScore + penetratable.StoppingPower) >= penetratable.StoppingPower) + { + component.DamagedEntity = component.PenetrationScore < penetratable.StoppingPower; + + component.PenetrationScore -= penetratable.StoppingPower; + } + else + component.DamagedEntity = true; - if (component.DeleteOnCollide) + if (component.DeleteOnCollide && component.DamagedEntity) QueueDel(uid); + // Corvax-Next-Penetration-End if (component.ImpactEffect != null && TryComp(uid, out TransformComponent? xform)) { diff --git a/Content.Shared/Projectiles/ProjectileComponent.cs b/Content.Shared/Projectiles/ProjectileComponent.cs index c24cf2b5ee5..d2fdc3ece2b 100644 --- a/Content.Shared/Projectiles/ProjectileComponent.cs +++ b/Content.Shared/Projectiles/ProjectileComponent.cs @@ -73,4 +73,8 @@ public sealed partial class ProjectileComponent : Component /// [DataField] public bool DamagedEntity; + + // Corvax-Next-Penetration + [DataField] + public int PenetrationScore; } diff --git a/Content.Shared/_CorvaxNext/Penetration/PenetratableComponent.cs b/Content.Shared/_CorvaxNext/Penetration/PenetratableComponent.cs new file mode 100644 index 00000000000..607a57b7553 --- /dev/null +++ b/Content.Shared/_CorvaxNext/Penetration/PenetratableComponent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared._CorvaxNext.Penetration; + +[RegisterComponent, NetworkedComponent] +public sealed partial class PenetratableComponent : Component +{ + [DataField] + public int StoppingPower; +} diff --git a/Resources/Prototypes/Entities/Mobs/base.yml b/Resources/Prototypes/Entities/Mobs/base.yml index d1c6f878bdc..e72eeb03a71 100644 --- a/Resources/Prototypes/Entities/Mobs/base.yml +++ b/Resources/Prototypes/Entities/Mobs/base.yml @@ -60,6 +60,8 @@ components: - type: Damageable damageContainer: Biological + - type: Penetratable + stoppingPower: 1 - type: Destructible thresholds: - trigger: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/antimateriel.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/antimateriel.yml index 65b7dbc1655..1eac72ddf32 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/antimateriel.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/antimateriel.yml @@ -9,5 +9,6 @@ types: Piercing: 40 Structural: 30 + penetrationScore: 3 - type: StaminaDamageOnCollide damage: 35 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/heavy_rifle.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/heavy_rifle.yml index d37555c3443..ca8034ccb05 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/heavy_rifle.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/heavy_rifle.yml @@ -8,6 +8,7 @@ damage: types: Piercing: 19 + penetrationScore: 1 - type: entity id: BulletMinigun @@ -19,3 +20,4 @@ damage: types: Piercing: 5 + penetrationScore: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/light_rifle.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/light_rifle.yml index 7eac4b53d09..d9ff8445f76 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/light_rifle.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/light_rifle.yml @@ -8,6 +8,7 @@ damage: types: Piercing: 19 + penetrationScore: 1 - type: entity id: BulletLightRiflePractice @@ -19,6 +20,7 @@ damage: types: Blunt: 2 + penetrationScore: 1 - type: entity id: BulletLightRifleIncendiary @@ -31,6 +33,7 @@ types: Blunt: 3 Heat: 16 + penetrationScore: 1 - type: entity id: BulletLightRifleUranium @@ -43,3 +46,4 @@ types: Radiation: 9 Piercing: 10 + penetrationScore: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/magnum.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/magnum.yml index b4017fd5507..aaf769bda6b 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/magnum.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/magnum.yml @@ -8,6 +8,7 @@ damage: types: Piercing: 35 + penetrationScore: 1 - type: entity id: BulletMagnumPractice @@ -19,6 +20,7 @@ damage: types: Blunt: 1 + penetrationScore: 1 - type: entity id: BulletMagnumIncendiary @@ -31,6 +33,7 @@ types: Blunt: 3 Heat: 32 + penetrationScore: 1 - type: entity id: BulletMagnumAP @@ -43,6 +46,7 @@ types: Piercing: 26 # 20% decrease ignoreResistances: true + penetrationScore: 1 - type: entity id: BulletMagnumUranium @@ -55,3 +59,4 @@ types: Radiation: 15 Piercing: 20 + penetrationScore: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/rifle.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/rifle.yml index e3e26bf9f32..021682af342 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/rifle.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/rifle.yml @@ -8,6 +8,7 @@ damage: types: Piercing: 17 + penetrationScore: 1 - type: entity id: BulletRiflePractice @@ -19,6 +20,7 @@ damage: types: Blunt: 2 + penetrationScore: 1 - type: entity id: BulletRifleIncendiary @@ -31,6 +33,7 @@ types: Blunt: 2 Heat: 15 + penetrationScore: 1 - type: entity id: BulletRifleUranium @@ -43,4 +46,5 @@ types: Radiation: 7 Piercing: 8 + penetrationScore: 1 diff --git a/Resources/Prototypes/Entities/Structures/Walls/walls.yml b/Resources/Prototypes/Entities/Structures/Walls/walls.yml index 8cdd9e9e795..874205b9d10 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/walls.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/walls.yml @@ -30,6 +30,8 @@ - type: Damageable damageContainer: StructuralInorganic damageModifierSet: StructuralMetallic + - type: Penetratable + stoppingPower: 2 - type: Physics bodyType: Static - type: Fixtures @@ -594,6 +596,8 @@ - type: Damageable damageContainer: StructuralInorganic damageModifierSet: StructuralMetallicStrong + - type: Penetratable + stoppingPower: 3 - type: Destructible thresholds: - trigger: diff --git a/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml b/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml index ed615871086..ad40aaf53b9 100644 --- a/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml +++ b/Resources/Prototypes/Entities/Structures/Windows/reinforced.yml @@ -14,6 +14,8 @@ - type: Damageable damageContainer: StructuralInorganic damageModifierSet: RGlass + - type: Penetratable + stoppingPower: 2 - type: RCDDeconstructable cost: 6 delay: 6 @@ -84,6 +86,8 @@ sprite: Structures/Windows/cracks_directional.rsi - type: Damageable damageModifierSet: RGlass + - type: Penetratable + stoppingPower: 2 - type: RCDDeconstructable cost: 4 delay: 4 diff --git a/Resources/Prototypes/Entities/Structures/base_structure.yml b/Resources/Prototypes/Entities/Structures/base_structure.yml index 71971a66243..963775b1549 100644 --- a/Resources/Prototypes/Entities/Structures/base_structure.yml +++ b/Resources/Prototypes/Entities/Structures/base_structure.yml @@ -9,6 +9,8 @@ - type: Clickable - type: Physics bodyType: Static + - type: Penetratable + stoppingPower: 1 - type: Fixtures fixtures: fix1: