Modify damage logging. (#5579)

This commit is contained in:
Leon Friedrich
2021-11-29 02:34:44 +13:00
committed by GitHub
parent b807250021
commit 0de4b7bc9f
28 changed files with 265 additions and 62 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Content.Server.Administration.Logs;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.NodeGroups;
@@ -8,6 +9,7 @@ using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Power.NodeGroups;
using Content.Server.Window;
using Content.Shared.Administration.Logs;
using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
@@ -46,6 +48,7 @@ namespace Content.Server.Electrocution
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly NodeGroupSystem _nodeGroupSystem = default!;
[Dependency] private readonly AdminLogSystem _logSystem = default!;
private const string StatusEffectKey = "Electrocution";
private const string DamageType = "Shock";
@@ -104,7 +107,10 @@ namespace Content.Server.Electrocution
_prototypeManager.Index<DamageTypePrototype>(DamageType),
(int) finished.AccumulatedDamage);
_damageableSystem.TryChangeDamage(finished.Electrocuting, damage);
var actual = _damageableSystem.TryChangeDamage(finished.Electrocuting, damage);
if (actual != null)
_logSystem.Add(LogType.Electrocution,
$"{finished.Owner} took {actual.Total} powered electrocution damage");
}
EntityManager.DeleteEntity(uid);
@@ -337,9 +343,15 @@ namespace Content.Server.Electrocution
// TODO: Sparks here.
if(shockDamage is {} dmg)
_damageableSystem.TryChangeDamage(uid,
{
var actual = _damageableSystem.TryChangeDamage(uid,
new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>(DamageType), dmg));
if (actual != null)
_logSystem.Add(LogType.Electrocution,
$"{statusEffects.Owner} took {actual.Total} powered electrocution damage");
}
_stutteringSystem.DoStutter(uid, time * StutteringTimeMultiplier, statusEffects, alerts);
_jitteringSystem.DoJitter(uid, time * JitterTimeMultiplier, JitterAmplitude, JitterFrequency, true,
statusEffects, alerts);