From 88a7642b6619be6d013cd17e48be1cba2f1105fe Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:41:51 +0300 Subject: [PATCH] =?UTF-8?q?[Port]=20=D0=A1=D0=BB=D1=83=D1=87=D0=B0=D0=B9?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=B2=D1=8B=D1=81=D1=82=D1=80=D0=B5=D0=BB?= =?UTF-8?q?=D1=8B=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=B0=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BE=D1=80=D1=83=D0=B6=D0=B8=D1=8F=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * FireOnDrop * whoopsy --- .../Ranged/Systems/FireOnDropSystem.cs | 27 +++++++++++++++++++ .../Weapons/Ranged/Components/GunComponent.cs | 6 +++++ .../Objects/Weapons/Guns/Basic/base_pka.yml | 1 + .../Weapons/Guns/Battery/battery_guns.yml | 1 + .../Objects/Weapons/Guns/Pistols/pistols.yml | 1 + .../Weapons/Guns/Revolvers/revolvers.yml | 1 + .../Objects/Weapons/Guns/Rifles/rifles.yml | 1 + .../Objects/Weapons/Guns/SMGs/smgs.yml | 1 + .../Weapons/Guns/Shotguns/shotguns.yml | 1 + .../Objects/Weapons/Guns/Snipers/snipers.yml | 1 + 10 files changed, 41 insertions(+) create mode 100644 Content.Server/_CorvaxNext/Weapons/Ranged/Systems/FireOnDropSystem.cs diff --git a/Content.Server/_CorvaxNext/Weapons/Ranged/Systems/FireOnDropSystem.cs b/Content.Server/_CorvaxNext/Weapons/Ranged/Systems/FireOnDropSystem.cs new file mode 100644 index 00000000000..a6112ad49cf --- /dev/null +++ b/Content.Server/_CorvaxNext/Weapons/Ranged/Systems/FireOnDropSystem.cs @@ -0,0 +1,27 @@ +using Content.Shared.Throwing; +using Content.Shared.Weapons.Ranged.Components; +using Content.Shared.Weapons.Ranged.Systems; +using Robust.Shared.Random; + +namespace Content.Server.Weapons.Ranged.Systems; + +public sealed class FireOnDropSystem : EntitySystem +{ + [Dependency] private readonly SharedGunSystem _gun = default!; + [Dependency] private readonly IRobustRandom _random = default!; + + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(HandleLand); + } + + + private void HandleLand(EntityUid uid, GunComponent component, ref ThrowDoHitEvent args) + { + if (_random.Prob(component.FireOnDropChance)) + _gun.AttemptShoot(uid, uid, component, Transform(uid).Coordinates.Offset(Transform(uid).LocalRotation.ToVec())); + } +} diff --git a/Content.Shared/Weapons/Ranged/Components/GunComponent.cs b/Content.Shared/Weapons/Ranged/Components/GunComponent.cs index 98b1d2fe2a4..bcc56c28ab1 100644 --- a/Content.Shared/Weapons/Ranged/Components/GunComponent.cs +++ b/Content.Shared/Weapons/Ranged/Components/GunComponent.cs @@ -263,6 +263,12 @@ public sealed partial class GunComponent : Component /// [DataField] public Vector2 DefaultDirection = new Vector2(0, -1); + + /// + /// Corvax-Next. The percentage chance of a given gun to accidentally discharge if violently thrown into a wall or person + /// + [DataField] + public float FireOnDropChance = 0.1f; } [Flags] diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml index a661323c7c3..03dc3a2dc0b 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml @@ -22,6 +22,7 @@ - SemiAuto soundGunshot: path: /Audio/Weapons/Guns/Gunshots/kinetic_accel.ogg + fireOnDropChance: 1 # Corvax-Next-FireOnDrop - type: AmmoCounter - type: Appearance - type: GenericVisualizer diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml index 55499a0a979..7dbb328e42c 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml @@ -20,6 +20,7 @@ - SemiAuto soundGunshot: path: /Audio/Weapons/Guns/Gunshots/laser.ogg + fireOnDropChance: 0.15 # Corvax-Next-FireOnDrop - type: Battery maxCharge: 1000 startingCharge: 1000 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml index 167e21e15f2..7cf0f06ccde 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml @@ -33,6 +33,7 @@ - FullAuto soundGunshot: path: /Audio/Weapons/Guns/Gunshots/pistol.ogg + fireOnDropChance: 0.3 # Corvax-Next-FireOnDrop - type: ChamberMagazineAmmoProvider soundRack: path: /Audio/Weapons/Guns/Cock/pistol_cock.ogg diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml index a34d0a4fe0a..e0aa5057f45 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Revolvers/revolvers.yml @@ -29,6 +29,7 @@ - SemiAuto soundGunshot: path: /Audio/Weapons/Guns/Gunshots/revolver.ogg + fireOnDropChance: 0.6 # Corvax-Next-FireOnDrop - type: UseDelay delay: 0.66 - type: ContainerContainer diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml index 44b8944592e..d51e95088e8 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml @@ -22,6 +22,7 @@ - FullAuto soundGunshot: path: /Audio/Weapons/Guns/Gunshots/batrifle.ogg + fireOnDropChance: 0.5 # Corvax-Next-FireOnDrop - type: ChamberMagazineAmmoProvider soundRack: path: /Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml index bccb514c63f..cca78cb4ffe 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml @@ -29,6 +29,7 @@ soundGunshot: path: /Audio/Weapons/Guns/Gunshots/smg.ogg defaultDirection: 1, 0 + fireOnDropChance: 0.3 # Corvax-Next-FireOnDrop - type: ChamberMagazineAmmoProvider soundRack: path: /Audio/Weapons/Guns/Cock/smg_cock.ogg diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml index 02f6b5c03de..5887669fd0e 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml @@ -28,6 +28,7 @@ path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg soundEmpty: path: /Audio/Weapons/Guns/Empty/empty.ogg + fireOnDropChance: 0.3 # Corvax-Next-FireOnDrop - type: BallisticAmmoProvider whitelist: tags: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml index 9cb0b630b7e..7e2586f485e 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml @@ -25,6 +25,7 @@ - SemiAuto soundGunshot: path: /Audio/Weapons/Guns/Gunshots/sniper.ogg + fireOnDropChance: 0.9 # Corvax-Next-FireOnDrop - type: BallisticAmmoProvider capacity: 10 proto: CartridgeLightRifle