diff --git a/Content.Server/_DV/Weapons/Ranged/Components/FireOnLandComponent.cs b/Content.Server/_DV/Weapons/Ranged/Components/FireOnLandComponent.cs new file mode 100644 index 00000000000..5b12142eedb --- /dev/null +++ b/Content.Server/_DV/Weapons/Ranged/Components/FireOnLandComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Server._DV.Weapons.Ranged.Components; + +[RegisterComponent] +public sealed partial class FireOnLandComponent : Component +{ + /// + /// Chance to trigger. + /// + [DataField] + public float Probability = 0.1f; +} diff --git a/Content.Server/_DV/Weapons/Ranged/Systems/FireOnLandSystem.cs b/Content.Server/_DV/Weapons/Ranged/Systems/FireOnLandSystem.cs new file mode 100644 index 00000000000..7aeaeba74d4 --- /dev/null +++ b/Content.Server/_DV/Weapons/Ranged/Systems/FireOnLandSystem.cs @@ -0,0 +1,31 @@ +using System.Numerics; +using Content.Server._DV.Weapons.Ranged.Components; +using Content.Server.Weapons.Ranged.Systems; +using Content.Shared.Throwing; +using Content.Shared.Weapons.Ranged.Components; +using Robust.Shared.Map; +using Robust.Shared.Random; + +namespace Content.Server._DV.Weapons.Ranged.Systems; + +public sealed class FireOnLandSystem : EntitySystem +{ + [Dependency] private readonly GunSystem _gunSystem = default!; + [Dependency] private readonly IRobustRandom _random = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(FireOnLand); + } + + private void FireOnLand(Entity ent, ref LandEvent args) + { + if (!_random.Prob(ent.Comp.Probability) || !TryComp(ent, out GunComponent? gc)) + return; + + var dir = gc.DefaultDirection; + dir = new Vector2(-dir.Y, dir.X); // 90 degrees counter-clockwise, guns shoot down by default + _gunSystem.AttemptShoot(ent, ent, gc, new EntityCoordinates(ent, dir)); + } +} diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml index 9d550d7a636..ba40558a68a 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml @@ -68,6 +68,7 @@ - type: Appearance - type: StaticPrice price: 500 + - type: FireOnLand # DeltaV - gun safety - type: entity name: viper