From 8ddc64e321fd1abd1c7b9c981cd43aa7b4b918b2 Mon Sep 17 00:00:00 2001 From: FN Date: Wed, 1 May 2024 16:37:29 +0700 Subject: [PATCH 1/6] Added penetration system --- Content.Server/Projectiles/ProjectileSystem.cs | 15 +++++++++++++-- .../Corvax/Penetration/PenetratableComponent.cs | 10 ++++++++++ Content.Shared/Projectiles/ProjectileComponent.cs | 3 +++ Resources/Prototypes/Entities/Mobs/base.yml | 2 ++ .../Guns/Ammunition/Projectiles/antimateriel.yml | 1 + .../Entities/Structures/Walls/walls.yml | 4 ++++ .../Entities/Structures/base_structure.yml | 2 ++ 7 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Content.Shared/Corvax/Penetration/PenetratableComponent.cs diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 970536f42b0..79960cd3ec6 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -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; @@ -18,9 +19,12 @@ public sealed class ProjectileSystem : SharedProjectileSystem [Dependency] private readonly GunSystem _guns = default!; [Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!; + private EntityQuery _penetratableQuery; + public override void Initialize() { base.Initialize(); + _penetratableQuery = GetEntityQuery(); SubscribeLocalEvent(OnStartCollide); } @@ -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(uid, out TransformComponent? xform)) diff --git a/Content.Shared/Corvax/Penetration/PenetratableComponent.cs b/Content.Shared/Corvax/Penetration/PenetratableComponent.cs new file mode 100644 index 00000000000..72d275050a7 --- /dev/null +++ b/Content.Shared/Corvax/Penetration/PenetratableComponent.cs @@ -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; +} diff --git a/Content.Shared/Projectiles/ProjectileComponent.cs b/Content.Shared/Projectiles/ProjectileComponent.cs index c24cf2b5ee5..8cbe54fce3e 100644 --- a/Content.Shared/Projectiles/ProjectileComponent.cs +++ b/Content.Shared/Projectiles/ProjectileComponent.cs @@ -73,4 +73,7 @@ public sealed partial class ProjectileComponent : Component /// [DataField] public bool DamagedEntity; + + [DataField] + public int PenetrationScore; } diff --git a/Resources/Prototypes/Entities/Mobs/base.yml b/Resources/Prototypes/Entities/Mobs/base.yml index d1c6f878bdc..fdb8ae337c9 100644 --- a/Resources/Prototypes/Entities/Mobs/base.yml +++ b/Resources/Prototypes/Entities/Mobs/base.yml @@ -10,6 +10,8 @@ drawdepth: Mobs - type: Physics bodyType: KinematicController + - type: Penetratable + stoppingPower: 1 - type: Fixtures fixtures: fix1: 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/Structures/Walls/walls.yml b/Resources/Prototypes/Entities/Structures/Walls/walls.yml index 8cdd9e9e795..571e8a1f32a 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/walls.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/walls.yml @@ -32,6 +32,8 @@ damageModifierSet: StructuralMetallic - type: Physics bodyType: Static + - type: Penetratable + stoppingPower: 2 - type: Fixtures fixtures: fix1: @@ -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/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: From b24b351bdba46d5d4d80dd0e22533527c7639e8c Mon Sep 17 00:00:00 2001 From: FN Date: Wed, 1 May 2024 21:01:42 +0700 Subject: [PATCH 2/6] Penetration transfered from BaseMob to MobDamageable --- Resources/Prototypes/Entities/Mobs/base.yml | 4 ++-- Resources/Prototypes/Entities/Structures/Walls/walls.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/Prototypes/Entities/Mobs/base.yml b/Resources/Prototypes/Entities/Mobs/base.yml index fdb8ae337c9..e72eeb03a71 100644 --- a/Resources/Prototypes/Entities/Mobs/base.yml +++ b/Resources/Prototypes/Entities/Mobs/base.yml @@ -10,8 +10,6 @@ drawdepth: Mobs - type: Physics bodyType: KinematicController - - type: Penetratable - stoppingPower: 1 - type: Fixtures fixtures: fix1: @@ -62,6 +60,8 @@ components: - type: Damageable damageContainer: Biological + - type: Penetratable + stoppingPower: 1 - type: Destructible thresholds: - trigger: diff --git a/Resources/Prototypes/Entities/Structures/Walls/walls.yml b/Resources/Prototypes/Entities/Structures/Walls/walls.yml index 571e8a1f32a..874205b9d10 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/walls.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/walls.yml @@ -30,10 +30,10 @@ - type: Damageable damageContainer: StructuralInorganic damageModifierSet: StructuralMetallic - - type: Physics - bodyType: Static - type: Penetratable stoppingPower: 2 + - type: Physics + bodyType: Static - type: Fixtures fixtures: fix1: From a3229c9591ea35f879982a9e971ae5543161ba1a Mon Sep 17 00:00:00 2001 From: FN Date: Wed, 1 May 2024 23:39:42 +0700 Subject: [PATCH 3/6] Added stopping power to reinforced windows --- .../Prototypes/Entities/Structures/Windows/reinforced.yml | 4 ++++ 1 file changed, 4 insertions(+) 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 From b10731fe1a255f28c0845652d4f720ddbb0bc56e Mon Sep 17 00:00:00 2001 From: FN Date: Fri, 8 Nov 2024 11:07:50 +0700 Subject: [PATCH 4/6] Added random, and rifles and magnums --- Content.Server/Projectiles/ProjectileSystem.cs | 6 +++++- .../Weapons/Guns/Ammunition/Projectiles/heavy_rifle.yml | 2 ++ .../Weapons/Guns/Ammunition/Projectiles/light_rifle.yml | 4 ++++ .../Objects/Weapons/Guns/Ammunition/Projectiles/magnum.yml | 5 +++++ .../Objects/Weapons/Guns/Ammunition/Projectiles/rifle.yml | 4 ++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 79960cd3ec6..0f7535d5699 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -21,6 +21,8 @@ public sealed class ProjectileSystem : SharedProjectileSystem private EntityQuery _penetratableQuery; + private Random _random = new(); + public override void Initialize() { base.Initialize(); @@ -71,7 +73,9 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St _sharedCameraRecoil.KickCamera(target, direction); } - if (component.PenetrationScore > 0 && _penetratableQuery.TryGetComponent(target, out var penetratable)) + if (component.PenetrationScore > 0 + && _penetratableQuery.TryGetComponent(target, out var penetratable) + && _random.Next(component.PenetrationScore + penetratable.StoppingPower) >= penetratable.StoppingPower) { component.DamagedEntity = component.PenetrationScore < penetratable.StoppingPower; 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 From ae4f0850eb4ba963dae8f63934207f13bf9d0324 Mon Sep 17 00:00:00 2001 From: FN Date: Fri, 8 Nov 2024 19:49:32 +0700 Subject: [PATCH 5/6] Next adaptation --- Content.Server/Projectiles/ProjectileSystem.cs | 3 ++- Content.Shared/Projectiles/ProjectileComponent.cs | 1 + .../Penetration/PenetratableComponent.cs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) rename Content.Shared/{Corvax => _CorvaxNext}/Penetration/PenetratableComponent.cs (64%) diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 0f7535d5699..10e31d81c53 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -1,8 +1,8 @@ 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.Corvax.Penetration; using Content.Shared.Damage; using Content.Shared.Database; using Content.Shared.Projectiles; @@ -73,6 +73,7 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St _sharedCameraRecoil.KickCamera(target, direction); } + // Corvax-Next-Penetration if (component.PenetrationScore > 0 && _penetratableQuery.TryGetComponent(target, out var penetratable) && _random.Next(component.PenetrationScore + penetratable.StoppingPower) >= penetratable.StoppingPower) diff --git a/Content.Shared/Projectiles/ProjectileComponent.cs b/Content.Shared/Projectiles/ProjectileComponent.cs index 8cbe54fce3e..d2fdc3ece2b 100644 --- a/Content.Shared/Projectiles/ProjectileComponent.cs +++ b/Content.Shared/Projectiles/ProjectileComponent.cs @@ -74,6 +74,7 @@ public sealed partial class ProjectileComponent : Component [DataField] public bool DamagedEntity; + // Corvax-Next-Penetration [DataField] public int PenetrationScore; } diff --git a/Content.Shared/Corvax/Penetration/PenetratableComponent.cs b/Content.Shared/_CorvaxNext/Penetration/PenetratableComponent.cs similarity index 64% rename from Content.Shared/Corvax/Penetration/PenetratableComponent.cs rename to Content.Shared/_CorvaxNext/Penetration/PenetratableComponent.cs index 72d275050a7..607a57b7553 100644 --- a/Content.Shared/Corvax/Penetration/PenetratableComponent.cs +++ b/Content.Shared/_CorvaxNext/Penetration/PenetratableComponent.cs @@ -1,10 +1,10 @@ using Robust.Shared.GameStates; -namespace Content.Shared.Corvax.Penetration; +namespace Content.Shared._CorvaxNext.Penetration; [RegisterComponent, NetworkedComponent] public sealed partial class PenetratableComponent : Component { - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField] public int StoppingPower; } From f6a8ce0be48c25d40c66dc82454724cdb1932d94 Mon Sep 17 00:00:00 2001 From: FN Date: Sun, 10 Nov 2024 19:22:47 +0700 Subject: [PATCH 6/6] Requests --- Content.Server/Projectiles/ProjectileSystem.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 10e31d81c53..d59d802d518 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,11 +19,10 @@ 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; - private Random _random = new(); - public override void Initialize() { base.Initialize(); @@ -73,7 +73,7 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St _sharedCameraRecoil.KickCamera(target, direction); } - // Corvax-Next-Penetration + // Corvax-Next-Penetration-Start if (component.PenetrationScore > 0 && _penetratableQuery.TryGetComponent(target, out var penetratable) && _random.Next(component.PenetrationScore + penetratable.StoppingPower) >= penetratable.StoppingPower) @@ -87,6 +87,7 @@ private void OnStartCollide(EntityUid uid, ProjectileComponent component, ref St if (component.DeleteOnCollide && component.DamagedEntity) QueueDel(uid); + // Corvax-Next-Penetration-End if (component.ImpactEffect != null && TryComp(uid, out TransformComponent? xform)) {