diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index f70fa7dc7d..45b9e79400 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -188,7 +188,7 @@ public sealed partial class GunSystem : SharedGunSystem FireEffects(fromCoordinates, distance, mapDirection.ToAngle(), hitscan, hitEntity); if (hitscan.StaminaDamage > 0f) - _stamina.TakeStaminaDamage(hitEntity, hitscan.StaminaDamage); + _stamina.TakeStaminaDamage(hitEntity, hitscan.StaminaDamage, source:user); var dmg = hitscan.Damage; diff --git a/Content.Shared.Database/LogType.cs b/Content.Shared.Database/LogType.cs index e310e7d240..25b0f3a833 100644 --- a/Content.Shared.Database/LogType.cs +++ b/Content.Shared.Database/LogType.cs @@ -78,4 +78,5 @@ public enum LogType StorePurchase = 73, LatticeCut = 74, Stripping = 75, + Stamina = 76, } diff --git a/Content.Shared/Damage/Systems/StaminaSystem.cs b/Content.Shared/Damage/Systems/StaminaSystem.cs index fddbde5435..8645961338 100644 --- a/Content.Shared/Damage/Systems/StaminaSystem.cs +++ b/Content.Shared/Damage/Systems/StaminaSystem.cs @@ -5,6 +5,7 @@ using Content.Shared.Damage.Components; using Content.Shared.Damage.Events; using Content.Shared.Database; using Content.Shared.IdentityManagement; +using Content.Shared.Interaction; using Content.Shared.Popups; using Content.Shared.Rounding; using Content.Shared.Stunnable; @@ -119,7 +120,7 @@ public sealed class StaminaSystem : EntitySystem return; var damage = args.PushProbability * component.CritThreshold; - TakeStaminaDamage(uid, damage, component); + TakeStaminaDamage(uid, damage, component, source:args.Source); // We need a better method of getting if the entity is going to resist stam damage, both this and the lines in the foreach at the end of OnHit() are awful if (!component.Critical) @@ -174,7 +175,7 @@ public sealed class StaminaSystem : EntitySystem foreach (var comp in toHit) { var oldDamage = comp.StaminaDamage; - TakeStaminaDamage(comp.Owner, damage / toHit.Count, comp); + TakeStaminaDamage(comp.Owner, damage / toHit.Count, comp, source:args.User, with:component.Owner); if (comp.StaminaDamage.Equals(oldDamage)) { _popup.PopupEntity(Loc.GetString("stamina-resist"), comp.Owner, Filter.Entities(args.User)); @@ -186,7 +187,7 @@ public sealed class StaminaSystem : EntitySystem { if (!args.OurFixture.ID.Equals(CollideFixture)) return; - TakeStaminaDamage(args.OtherFixture.Body.Owner, component.Damage); + TakeStaminaDamage(args.OtherFixture.Body.Owner, component.Damage, source:args.OurFixture.Body.Owner); } private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null) @@ -201,7 +202,7 @@ public sealed class StaminaSystem : EntitySystem _alerts.ShowAlert(uid, AlertType.Stamina, (short) severity); } - public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null) + public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null, EntityUid? source = null, EntityUid? with = null) { if (!Resolve(uid, ref component, false) || component.Critical) return; @@ -246,6 +247,17 @@ public sealed class StaminaSystem : EntitySystem EnsureComp(uid); Dirty(component); + + if (value <= 0) + return; + if (source != null) + { + _adminLogger.Add(LogType.Stamina, $"{ToPrettyString(source.Value):user} caused {value} stamina damage to {ToPrettyString(uid):target}{(with != null ? $" using {ToPrettyString(with.Value):using}" : "")}"); + } + else + { + _adminLogger.Add(LogType.Stamina, $"{ToPrettyString(uid):target} took {value} stamina damage"); + } } public override void Update(float frameTime) @@ -305,6 +317,7 @@ public sealed class StaminaSystem : EntitySystem component.NextUpdate = _timing.CurTime + stunTime + StamCritBufferTime; EnsureComp(uid); Dirty(component); + _adminLogger.Add(LogType.Stamina, LogImpact.Medium, $"{ToPrettyString(uid):user} entered stamina crit"); } private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null) @@ -318,6 +331,7 @@ public sealed class StaminaSystem : EntitySystem SetStaminaAlert(uid, component); RemComp(uid); Dirty(component); + _adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit"); } [Serializable, NetSerializable] diff --git a/Content.Shared/Stunnable/SharedStunSystem.cs b/Content.Shared/Stunnable/SharedStunSystem.cs index 58b52dabfa..eee8e2a2fb 100644 --- a/Content.Shared/Stunnable/SharedStunSystem.cs +++ b/Content.Shared/Stunnable/SharedStunSystem.cs @@ -1,4 +1,5 @@ using Content.Shared.ActionBlocker; +using Content.Shared.Administration.Logs; using Content.Shared.Audio; using Content.Shared.DragDrop; using Content.Shared.Interaction; @@ -6,6 +7,7 @@ using Content.Shared.Interaction.Events; using Content.Shared.Inventory.Events; using Content.Shared.Item; using Content.Shared.Bed.Sleep; +using Content.Shared.Database; using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; using Content.Shared.Standing; @@ -26,6 +28,7 @@ namespace Content.Shared.Stunnable [Dependency] private readonly StatusEffectsSystem _statusEffectSystem = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; /// /// Friction modifier for knocked down players. @@ -150,7 +153,10 @@ namespace Content.Shared.Stunnable if (!Resolve(uid, ref status, false)) return false; - return _statusEffectSystem.TryAddStatusEffect(uid, "Stun", time, refresh); + if (!_statusEffectSystem.TryAddStatusEffect(uid, "Stun", time, refresh)) + return false; + _adminLogger.Add(LogType.Stamina, LogImpact.Medium, $"{ToPrettyString(uid):user} stunned for {time.Seconds} seconds"); + return true; } /// diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 2b30c0b761..9340407f8b 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -424,7 +424,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem // If the target has stamina and is taking blunt damage, they should also take stamina damage based on their blunt to stamina factor if (damageResult.DamageDict.TryGetValue("Blunt", out var bluntDamage)) { - _stamina.TakeStaminaDamage(ev.Target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float()); + _stamina.TakeStaminaDamage(ev.Target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float(), source:user, with:(component.Owner == user ? null : component.Owner)); } if (component.Owner == user)