diff --git a/Content.Server/Destructible/DestructibleSystem.cs b/Content.Server/Destructible/DestructibleSystem.cs index 07668ba063..0dc062bdea 100644 --- a/Content.Server/Destructible/DestructibleSystem.cs +++ b/Content.Server/Destructible/DestructibleSystem.cs @@ -1,3 +1,5 @@ +using System.Linq; +using Content.Server.Administration.Logs; using Content.Server.Body.Systems; using Content.Server.Chemistry.EntitySystems; using Content.Server.Construction; @@ -8,6 +10,7 @@ using Content.Server.Explosion.EntitySystems; using Content.Server.Fluids.EntitySystems; using Content.Server.Stack; using Content.Shared.Damage; +using Content.Shared.Database; using Content.Shared.Destructible; using Content.Shared.FixedPoint; using JetBrains.Annotations; @@ -33,6 +36,7 @@ namespace Content.Server.Destructible [Dependency] public readonly PuddleSystem PuddleSystem = default!; [Dependency] public readonly IPrototypeManager PrototypeManager = default!; [Dependency] public readonly IComponentFactory ComponentFactory = default!; + [Dependency] public readonly IAdminLogManager _adminLogger = default!; public override void Initialize() { @@ -51,6 +55,27 @@ namespace Content.Server.Destructible { RaiseLocalEvent(uid, new DamageThresholdReached(component, threshold), true); + // Convert behaviors into string for logs + var triggeredBehaviors = string.Join(", ", threshold.Behaviors.Select(b => + { + if (b is DoActsBehavior doActsBehavior) + { + return $"{b.GetType().Name}:{doActsBehavior.Acts.ToString()}"; + } + return b.GetType().Name; + })); + + if (args.Origin != null) + { + _adminLogger.Add(LogType.Damaged, LogImpact.Medium, + $"{ToPrettyString(args.Origin.Value):actor} caused {ToPrettyString(uid):subject} to trigger [{triggeredBehaviors}]"); + } + else + { + _adminLogger.Add(LogType.Damaged, LogImpact.Medium, + $"Unknown damage source caused {ToPrettyString(uid):subject} to trigger [{triggeredBehaviors}]"); + } + threshold.Execute(uid, this, EntityManager, args.Origin); }