Adjust logs for physics-damage (#6494)

This commit is contained in:
Leon Friedrich
2022-02-07 14:52:58 +13:00
committed by GitHub
parent 6d1be412f5
commit 221505bea6
3 changed files with 6 additions and 28 deletions

View File

@@ -1,17 +1,9 @@
using System;
using Content.Server.Administration.Logs;
using Content.Server.Damage.Components;
using Content.Server.Stunnable;
using Content.Server.Stunnable.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Stunnable;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Random;
@@ -26,7 +18,6 @@ namespace Content.Server.Damage.Systems
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly AdminLogSystem _logSystem = default!;
public override void Initialize()
{
@@ -55,10 +46,7 @@ namespace Content.Server.Damage.Systems
var damageScale = (speed / component.MinimumSpeed) * component.Factor;
var dmg = _damageableSystem.TryChangeDamage(uid, component.Damage * damageScale);
if (dmg != null)
_logSystem.Add(LogType.Damaged, $"{ToPrettyString(component.Owner):entity} took {dmg.Total:damage} damage from a high speed collision");
_damageableSystem.TryChangeDamage(uid, component.Damage * damageScale);
}
}
}

View File

@@ -1,18 +1,12 @@
using Content.Server.Administration.Logs;
using Content.Server.Damage.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Throwing;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Damage.Systems
{
public sealed class DamageOnLandSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly AdminLogSystem _logSystem = default!;
public override void Initialize()
{
@@ -22,11 +16,7 @@ namespace Content.Server.Damage.Systems
private void DamageOnLand(EntityUid uid, DamageOnLandComponent component, LandEvent args)
{
var dmg = _damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
if (dmg == null)
return;
_logSystem.Add(LogType.Landed, $"{ToPrettyString(component.Owner):entity} received {dmg.Total:damage} damage from landing");
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
}
}
}

View File

@@ -1,11 +1,9 @@
using Content.Server.Administration.Logs;
using Content.Server.Damage.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.MobState.Components;
using Content.Shared.Throwing;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Damage.Systems
{
@@ -22,7 +20,9 @@ namespace Content.Server.Damage.Systems
private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
{
var dmg = _damageableSystem.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances);
if (dmg != null)
// Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
if (dmg != null && HasComp<MobStateComponent>(args.Target))
_logSystem.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.Total:damage} damage from collision");
}
}