2024-08-02 11:50:26 +00:00
|
|
|
using Content.Shared._White.Blocking;
|
2024-02-20 19:28:44 +09:00
|
|
|
using Content.Shared.Damage;
|
|
|
|
|
using Content.Shared.Damage.Prototypes;
|
|
|
|
|
using Content.Shared.Weapons.Melee.Events;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server._White.Other.RandomDamageSystem;
|
|
|
|
|
|
|
|
|
|
public sealed class RandomDamageSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2024-08-02 11:50:26 +00:00
|
|
|
SubscribeLocalEvent<RandomDamageComponent, MeleeHitEvent>(HandleHit, before: new [] {typeof(MeleeBlockSystem)});
|
2024-02-20 19:28:44 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleHit(Entity<RandomDamageComponent> ent, ref MeleeHitEvent args)
|
|
|
|
|
{
|
|
|
|
|
var damage = _random.NextFloat() * ent.Comp.Max;
|
2024-03-04 16:02:16 +09:00
|
|
|
if (args.Direction != null) // Heavy attack
|
2024-06-06 10:22:49 +00:00
|
|
|
damage *= 0.5f;
|
2024-02-20 19:28:44 +09:00
|
|
|
args.BonusDamage = new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Slash"), damage);
|
|
|
|
|
}
|
|
|
|
|
}
|