Weapon Random Fixes (documented and removed hardcoded cluwnecomp) (#22352)

Weapon Random Fixes
This commit is contained in:
brainfood1183
2023-12-18 19:42:57 +00:00
committed by GitHub
parent 8958c64e6c
commit 2d04e89007
2 changed files with 11 additions and 29 deletions

View File

@@ -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;
}
}
}