Improve explosion logs (#13351)

* add types to explosion logs

* make explosions logged by default

* add cause parameter to IThresholdBehavior

* add cause to ExplodeBehaviors

* add cause to power cell explosions

* remove useless log

* add triggerer to triggers

* add logs for damage from explosions

* sneaky power cell update
This commit is contained in:
Chief-Engineer
2023-02-10 17:45:38 -06:00
committed by GitHub
parent 57275d97d3
commit 95e35b94b5
27 changed files with 71 additions and 46 deletions

View File

@@ -1,7 +1,11 @@
using System.Linq;
using Content.Server.Explosion.Components;
using Content.Server.Mind.Components;
using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Explosion;
using Content.Shared.FixedPoint;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Spawners.Components;
@@ -388,10 +392,23 @@ public sealed partial class ExplosionSystem : EntitySystem
{
// no damage-dict multiplication required.
_damageableSystem.TryChangeDamage(uid, damage, ignoreResistances: true, damageable: damageable);
if (HasComp<MindComponent>(uid) || HasComp<ExplosiveComponent>(uid))
{
var damageStr = string.Join(", ", damage.DamageDict.Select(entry => $"{entry.Key}: {entry.Value}"));
_adminLogger.Add(LogType.Explosion, LogImpact.Medium,
$"Explosion caused {{{damageStr}}} to {ToPrettyString(uid):target} at {Transform(uid).Coordinates}");
}
}
else
{
_damageableSystem.TryChangeDamage(uid, damage * ev.DamageCoefficient, ignoreResistances: true, damageable: damageable);
var appliedDamage = damage * ev.DamageCoefficient;
_damageableSystem.TryChangeDamage(uid, appliedDamage, ignoreResistances: true, damageable: damageable);
if (HasComp<MindComponent>(uid) || HasComp<ExplosiveComponent>(uid))
{
var damageStr = string.Join(", ", appliedDamage.DamageDict.Select(entry => $"{entry.Key}: {entry.Value}"));
_adminLogger.Add(LogType.Explosion, LogImpact.Medium,
$"Explosion caused {{{damageStr}}} to {ToPrettyString(uid):target} at {Transform(uid).Coordinates}");
}
}
}

View File

@@ -216,22 +216,22 @@ public sealed partial class ExplosionSystem : EntitySystem
int maxTileBreak = int.MaxValue,
bool canCreateVacuum = true,
EntityUid? user = null,
bool addLog = false)
bool addLog = true)
{
var pos = Transform(uid).MapPosition;
var pos = Transform(uid);
QueueExplosion(pos, typeId, totalIntensity, slope, maxTileIntensity, tileBreakScale, maxTileBreak, canCreateVacuum, addLog: false);
QueueExplosion(pos.MapPosition, typeId, totalIntensity, slope, maxTileIntensity, tileBreakScale, maxTileBreak, canCreateVacuum, addLog: false);
if (!addLog)
return;
if (user == null)
_adminLogger.Add(LogType.Explosion, LogImpact.High,
$"{ToPrettyString(uid):entity} exploded at {pos:coordinates} with intensity {totalIntensity} slope {slope}");
$"{ToPrettyString(uid):entity} exploded ({typeId}) at {pos.Coordinates:coordinates} with intensity {totalIntensity} slope {slope}");
else
_adminLogger.Add(LogType.Explosion, LogImpact.High,
$"{ToPrettyString(user.Value):user} caused {ToPrettyString(uid):entity} to explode at {pos:coordinates} with intensity {totalIntensity} slope {slope}");
$"{ToPrettyString(user.Value):user} caused {ToPrettyString(uid):entity} to explode ({typeId}) at {pos.Coordinates:coordinates} with intensity {totalIntensity} slope {slope}");
}
/// <summary>
@@ -245,7 +245,7 @@ public sealed partial class ExplosionSystem : EntitySystem
float tileBreakScale = 1f,
int maxTileBreak = int.MaxValue,
bool canCreateVacuum = true,
bool addLog = false)
bool addLog = true)
{
if (totalIntensity <= 0 || slope <= 0)
return;
@@ -257,7 +257,7 @@ public sealed partial class ExplosionSystem : EntitySystem
}
if (addLog) // dont log if already created a separate, more detailed, log.
_adminLogger.Add(LogType.Explosion, LogImpact.High, $"Explosion spawned at {epicenter:coordinates} with intensity {totalIntensity} slope {slope}");
_adminLogger.Add(LogType.Explosion, LogImpact.High, $"Explosion ({typeId}) spawned at {epicenter:coordinates} with intensity {totalIntensity} slope {slope}");
_explosionQueue.Enqueue(() => SpawnExplosion(epicenter, type, totalIntensity,
slope, maxTileIntensity, tileBreakScale, maxTileBreak, canCreateVacuum));

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Explosion.EntitySystems
public sealed partial class TriggerSystem
{
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
private void InitializeSignal()
{
SubscribeLocalEvent<TriggerOnSignalComponent,SignalReceivedEvent>(OnSignalReceived);
@@ -19,7 +19,7 @@ namespace Content.Server.Explosion.EntitySystems
if (args.Port != component.Port)
return;
Trigger(uid);
Trigger(uid, args.Trigger);
}
private void OnInit(EntityUid uid, TriggerOnSignalComponent component, ComponentInit args)
{

View File

@@ -41,7 +41,7 @@ namespace Content.Server.Explosion.EntitySystems
{
_adminLogger.Add(LogType.Trigger, LogImpact.High,
$"A voice-trigger on {ToPrettyString(uid):entity} was triggered by {ToPrettyString(args.Source):speaker} speaking the key-phrase {component.KeyPhrase}.");
Trigger(uid);
Trigger(uid, args.Source);
}
}