Files
OldThink/Content.Server/_White/Other/RandomDamageSystem/RandomDamageSystem.cs
Aviu00 27268d4e28 Better melee combat (#542)
* - add: NextMobAttack, EquipCooldown.

* - fix: Some combat fixes.

* - add: Telebaton.

* - add: Stun baton rework.

* - tweak: Reduce melee range.

* - add: Rework melee block system.

* - add: ExaminedEvent.
2024-08-02 14:50:26 +03:00

30 lines
1.0 KiB
C#

using Content.Shared._White.Blocking;
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();
SubscribeLocalEvent<RandomDamageComponent, MeleeHitEvent>(HandleHit, before: new [] {typeof(MeleeBlockSystem)});
}
private void HandleHit(Entity<RandomDamageComponent> ent, ref MeleeHitEvent args)
{
var damage = _random.NextFloat() * ent.Comp.Max;
if (args.Direction != null) // Heavy attack
damage *= 0.5f;
args.BonusDamage = new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Slash"), damage);
}
}