From c208c4f5bae975f2121c2428bb94435637f61d34 Mon Sep 17 00:00:00 2001 From: Fishfish458 <47410468+Fishfish458@users.noreply.github.com> Date: Sun, 20 Feb 2022 18:17:34 -0600 Subject: [PATCH] Change stun baton throwing to be a chance (#6830) Co-authored-by: fishfish458 --- .../Stunnable/Components/StunbatonComponent.cs | 4 ++++ Content.Server/Stunnable/StunbatonSystem.cs | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) 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)