Change stun baton throwing to be a chance (#6830)
Co-authored-by: fishfish458 <fishfish458>
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -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);
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user