Weapon Random Fixes (documented and removed hardcoded cluwnecomp) (#22352)
Weapon Random Fixes
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Shared.Cluwne;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
|
||||
namespace Content.Server.Weapons.Melee.WeaponRandom;
|
||||
|
||||
/// <summary>
|
||||
/// This adds a random damage bonus to melee attacks based on damage bonus amount and probability.
|
||||
/// </summary>
|
||||
public sealed class WeaponRandomSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
@@ -17,22 +18,15 @@ public sealed class WeaponRandomSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<WeaponRandomComponent, MeleeHitEvent>(OnMeleeHit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Melee hit there is a possible chance of additional bonus damage occuring.
|
||||
/// </summary>
|
||||
private void OnMeleeHit(EntityUid uid, WeaponRandomComponent component, MeleeHitEvent args)
|
||||
{
|
||||
foreach (var entity in args.HitEntities)
|
||||
if (_random.Prob(component.RandomDamageChance))
|
||||
{
|
||||
if (HasComp<CluwneComponent>(entity) && component.AntiCluwne)
|
||||
{
|
||||
_audio.PlayPvs(component.DamageSound, uid);
|
||||
args.BonusDamage = component.DamageBonus;
|
||||
}
|
||||
|
||||
else if (_random.Prob(component.RandomDamageChance) && component.RandomDamage)
|
||||
{
|
||||
_audio.PlayPvs(component.DamageSound, uid);
|
||||
args.BonusDamage = component.DamageBonus;
|
||||
}
|
||||
_audio.PlayPvs(component.DamageSound, uid);
|
||||
args.BonusDamage = component.DamageBonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user