diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index 8f84040bbd..ba00414343 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -143,7 +143,7 @@ public sealed partial class GunSystem : SharedGunSystem { SetCartridgeSpent(cartridge, true); MuzzleFlash(gun.Owner, cartridge, user); - + PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); // TODO: Can't predict entity deletions. //if (cartridge.DeleteOnSpawn) // Del(cartridge.Owner); @@ -159,11 +159,15 @@ public sealed partial class GunSystem : SharedGunSystem break; case AmmoComponent newAmmo: MuzzleFlash(gun.Owner, newAmmo, user); + PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); if (newAmmo.Owner.IsClientSide()) Del(newAmmo.Owner); else RemComp(newAmmo.Owner); break; + case HitscanPrototype: + PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); + break; } } } diff --git a/Content.Server/Weapon/Ranged/Systems/GunSystem.cs b/Content.Server/Weapon/Ranged/Systems/GunSystem.cs index 957f16a977..14e39f9a80 100644 --- a/Content.Server/Weapon/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapon/Ranged/Systems/GunSystem.cs @@ -73,6 +73,7 @@ public sealed partial class GunSystem : SharedGunSystem SetCartridgeSpent(cartridge, true); MuzzleFlash(gun.Owner, cartridge, user); + PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); if (cartridge.DeleteOnSpawn) Del(cartridge.Owner); @@ -92,6 +93,7 @@ public sealed partial class GunSystem : SharedGunSystem case AmmoComponent newAmmo: shotProjectiles.Add(newAmmo.Owner); MuzzleFlash(gun.Owner, newAmmo, user); + PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); // Do a throw if (!HasComp(newAmmo.Owner)) @@ -139,6 +141,7 @@ public sealed partial class GunSystem : SharedGunSystem { FireEffects(fromCoordinates, hitscan.MaxLength, entityDirection.ToAngle(), hitscan); } + PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); break; default: throw new ArgumentOutOfRangeException(); @@ -200,7 +203,7 @@ public sealed partial class GunSystem : SharedGunSystem protected override void PlaySound(EntityUid gun, string? sound, EntityUid? user = null) { - if (sound == null) return; + if (string.IsNullOrEmpty(sound)) return; SoundSystem.Play(Filter.Pvs(gun, entityManager: EntityManager).RemoveWhereAttachedEntity(e => e == user), sound, gun); } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 515088dc45..9cdecb43d5 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -242,11 +242,8 @@ public abstract partial class SharedGunSystem : EntitySystem return; } - // Shoot confirmed + // Shoot confirmed - sounds also played here in case it's invalid (e.g. cartridge already spent). Shoot(gun, ev.Ammo, fromCoordinates, toCoordinates.Value, user); - - // Predicted sound moment - PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); Dirty(gun); } diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/toy.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/toy.yml index 5a6ceb5e4b..b28f05adf6 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/toy.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/toy.yml @@ -15,6 +15,8 @@ layers: - state: base map: ["enum.AmmoVisualLayers.Base"] + - type: SpentAmmoVisuals + - type: Appearance - type: entity id: CartridgeCap