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

@@ -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)