diff --git a/Content.Server/Stunnable/Components/StunbatonComponent.cs b/Content.Server/Stunnable/Components/StunbatonComponent.cs index 8dd4a4445f..4e62e60709 100644 --- a/Content.Server/Stunnable/Components/StunbatonComponent.cs +++ b/Content.Server/Stunnable/Components/StunbatonComponent.cs @@ -30,6 +30,10 @@ namespace Content.Server.Stunnable.Components [DataField("energyPerUse")] public float EnergyPerUse { get; set; } = 50; + [ViewVariables(VVAccess.ReadWrite)] + [DataField("onThrowStunChance")] + public float OnThrowStunChance { get; set; } = 0.20f; + [DataField("stunSound")] public SoundSpecifier StunSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/egloves.ogg"); diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index 24a69b9089..df09fa6e8c 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -91,11 +91,14 @@ namespace Content.Server.Stunnable if (!comp.Activated) return; - if (!_cellSystem.TryGetBatteryFromSlot(uid, out var battery) || !battery.TryUseCharge(comp.EnergyPerUse)) + if (!_cellSystem.TryGetBatteryFromSlot(uid, out var battery)) return; - StunEntity(args.Target, comp); - SendPowerPulse(args.Target, args.User, uid); + if (_robustRandom.Prob(comp.OnThrowStunChance) && battery.TryUseCharge(comp.EnergyPerUse)) + { + SendPowerPulse(args.Target, args.User, uid); + StunEntity(args.Target, comp); + } } private void OnPowerCellChanged(EntityUid uid, StunbatonComponent comp, PowerCellChangedEvent args)