Change stun baton throwing to be a chance (#6830)

Co-authored-by: fishfish458 <fishfish458>
This commit is contained in:
Fishfish458
2022-02-20 18:17:34 -06:00
committed by GitHub
parent cce1af3d40
commit c208c4f5ba
2 changed files with 10 additions and 3 deletions

View File

@@ -30,6 +30,10 @@ namespace Content.Server.Stunnable.Components
[DataField("energyPerUse")] [DataField("energyPerUse")]
public float EnergyPerUse { get; set; } = 50; public float EnergyPerUse { get; set; } = 50;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("onThrowStunChance")]
public float OnThrowStunChance { get; set; } = 0.20f;
[DataField("stunSound")] [DataField("stunSound")]
public SoundSpecifier StunSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/egloves.ogg"); public SoundSpecifier StunSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/egloves.ogg");

View File

@@ -91,11 +91,14 @@ namespace Content.Server.Stunnable
if (!comp.Activated) if (!comp.Activated)
return; return;
if (!_cellSystem.TryGetBatteryFromSlot(uid, out var battery) || !battery.TryUseCharge(comp.EnergyPerUse)) if (!_cellSystem.TryGetBatteryFromSlot(uid, out var battery))
return; return;
StunEntity(args.Target, comp); if (_robustRandom.Prob(comp.OnThrowStunChance) && battery.TryUseCharge(comp.EnergyPerUse))
SendPowerPulse(args.Target, args.User, uid); {
SendPowerPulse(args.Target, args.User, uid);
StunEntity(args.Target, comp);
}
} }
private void OnPowerCellChanged(EntityUid uid, StunbatonComponent comp, PowerCellChangedEvent args) private void OnPowerCellChanged(EntityUid uid, StunbatonComponent comp, PowerCellChangedEvent args)