Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Randomly Fire Dropped Weapons #471

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Content.Server/Weapons/Ranged/Systems/FireOnDropSystem.cs
Original file line number Diff line number Diff line change
@@ -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<GunComponent, ThrowDoHitEvent>(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()));
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Weapons/Ranged/Components/GunComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ public sealed partial class GunComponent : Component
/// </summary>
[DataField]
public bool ClumsyProof = false;

/// <summary>
/// The percentage chance of a given gun to accidentally discharge if violently thrown into a wall or person
/// </summary>
[DataField]
public float FireOnDropChance = 0.1f;
}

[Flags]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/kinetic_accel.ogg
fireOnDropChance: 1
- type: AmmoCounter
- type: Appearance
- type: GenericVisualizer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
selectedMode: SemiAuto
availableModes:
- SemiAuto
fireOnDropChance: 0.15
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/laser.ogg
- type: Battery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@
containers:
gun_magazine: !type:ContainerSlot
gun_chamber: !type:ContainerSlot
- type: Gun
fireRate: 6
selectedMode: SemiAuto
availableModes:
- SemiAuto
- FullAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/pistol.ogg
fireOnDropChance: 0.3

- type: entity
name: cobra
Expand All @@ -125,6 +134,7 @@
volume: -14
availableModes:
- SemiAuto
fireOnDropChance: 0.1
- type: ItemSlots
slots:
gun_magazine:
Expand Down Expand Up @@ -169,6 +179,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/mk58.ogg
fireOnDropChance: 0.5

- type: entity
id: WeaponPistolMk58Nonlethal
Expand Down Expand Up @@ -198,7 +209,7 @@
name: N1984
parent: BaseWeaponPistol
id: WeaponPistolN1984 # the spaces in description are for formatting.
description: The sidearm of any self respecting officer. Comes in .45 magnum, the lord's caliber.
description: The sidearm of any self respecting officer. Comes in .45 magnum, the lord's caliber.
DEATHB4DEFEAT marked this conversation as resolved.
Show resolved Hide resolved
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Pistols/N1984.rsi
Expand All @@ -219,6 +230,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/mk58.ogg
fireOnDropChance: 0.6
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/revolver.ogg
fireOnDropChance: 0.5
- type: UseDelay
delay: 0.66
- type: ContainerContainer
Expand Down Expand Up @@ -127,6 +128,7 @@
path: /Audio/Weapons/Guns/Gunshots/revolver.ogg
params:
volume: 2.25
fireOnDropChance: 0.3

- type: entity
name: Python
Expand Down Expand Up @@ -155,6 +157,7 @@
sprite: Objects/Weapons/Guns/Revolvers/pirate_revolver.rsi
- type: Gun
fireRate: 1
fireOnDropChance: 1
- type: ContainerContainer
containers:
revolver-ammo: !type:Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
fireRate: 5
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/rifle2.ogg
fireOnDropChance: 0.5
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/ltrifle_cock.ogg
Expand Down Expand Up @@ -159,6 +160,7 @@
- type: Gun
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/ltrifle.ogg
fireOnDropChance: 0.2
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
fireRate: 10
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/atreides.ogg
fireOnDropChance: 0.3
- type: MagazineVisuals
magState: mag
steps: 1
Expand All @@ -96,6 +97,7 @@
- type: Gun
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/c-20r.ogg
fireOnDropChance: 0.3
- type: ChamberMagazineAmmoProvider
autoEject: true
- type: MagazineVisuals
Expand Down Expand Up @@ -126,6 +128,7 @@
path: /Audio/Weapons/Guns/Gunshots/atreides.ogg
availableModes:
- FullAuto
fireOnDropChance: 0.2
- type: ItemSlots
slots:
gun_magazine:
Expand Down Expand Up @@ -173,6 +176,7 @@
path: /Audio/Weapons/Guns/Gunshots/atreides.ogg
availableModes:
- FullAuto
fireOnDropChance: 0.1
- type: ItemSlots
slots:
gun_magazine:
Expand Down Expand Up @@ -225,6 +229,7 @@
selectedMode: FullAuto
availableModes:
- FullAuto
fireOnDropChance: 0.1
- type: ItemSlots
slots:
gun_magazine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg
soundEmpty:
path: /Audio/Weapons/Guns/Empty/empty.ogg
fireOnDropChance: 0.2
- type: BallisticAmmoProvider
whitelist:
tags:
Expand Down Expand Up @@ -75,6 +76,7 @@
path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg
soundEmpty:
path: /Audio/Weapons/Guns/Empty/empty.ogg
fireOnDropChance: 0.3
- type: ItemSlots
slots:
gun_magazine:
Expand Down Expand Up @@ -115,6 +117,7 @@
heldPrefix: db
- type: Gun
fireRate: 2
fireOnDropChance: 0.5
- type: BallisticAmmoProvider
capacity: 2
- type: Construction
Expand Down Expand Up @@ -190,6 +193,7 @@
heldPrefix: sawn
- type: Gun
fireRate: 4
fireOnDropChance: 0.5
- type: BallisticAmmoProvider
capacity: 2
- type: Construction
Expand Down Expand Up @@ -226,6 +230,7 @@
sprite: Objects/Weapons/Guns/Shotguns/hm_pistol.rsi
- type: Gun
fireRate: 4
fireOnDropChance: 1
- type: BallisticAmmoProvider
capacity: 1
- type: Construction
Expand All @@ -250,6 +255,7 @@
sprite: Objects/Weapons/Guns/Shotguns/blunderbuss.rsi
- type: Gun
fireRate: 2
fireOnDropChance: 1
- type: BallisticAmmoProvider
capacity: 1
- type: StaticPrice
Expand All @@ -273,6 +279,7 @@
heldPrefix: improvised
- type: Gun
fireRate: 4 #No reason to stifle the firerate since you have to manually reload every time anyways.
fireOnDropChance: 1
- type: BallisticAmmoProvider
capacity: 1
proto: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi
- type: Gun
fireRate: 0.75
selectedMode: SemiAuto
availableModes:
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/sniper.ogg
fireOnDropChance: 1

- type: entity
name: Hristov
Expand Down Expand Up @@ -82,6 +90,7 @@
selectedMode: SemiAuto
availableModes:
- SemiAuto
fireOnDropChance: 1
- type: UseDelayOnShoot
- type: UseDelay
delay: 8 #it's a musket
Expand Down Expand Up @@ -111,6 +120,7 @@
- type: Gun
minAngle: 0
maxAngle: 30 #miss him entirely because the barrel is smoothbore
fireOnDropChance: 1
- type: Item
size: Small
storedRotation: 90
Expand Down
Loading