Log enrichment: Explosion damage to players (#29762)
* Log enrichment: Explosion damage to players * Update Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> * Revert to total damage variant only, currently serialised as string. * Make this its own log type. --------- Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
This commit is contained in:
@@ -132,6 +132,6 @@ public sealed class ExplosionCommand : IConsoleCommand
|
||||
}
|
||||
|
||||
var sysMan = IoCManager.Resolve<IEntitySystemManager>();
|
||||
sysMan.GetEntitySystem<ExplosionSystem>().QueueExplosion(coords, type.ID, intensity, slope, maxIntensity);
|
||||
sysMan.GetEntitySystem<ExplosionSystem>().QueueExplosion(coords, type.ID, intensity, slope, maxIntensity, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public sealed partial class AdminVerbSystem
|
||||
var coords = _transformSystem.GetMapCoordinates(args.Target);
|
||||
Timer.Spawn(_gameTiming.TickPeriod,
|
||||
() => _explosionSystem.QueueExplosion(coords, ExplosionSystem.DefaultExplosionPrototypeId,
|
||||
4, 1, 2, maxTileBreak: 0), // it gibs, damage doesn't need to be high.
|
||||
4, 1, 2, args.Target, maxTileBreak: 0), // it gibs, damage doesn't need to be high.
|
||||
CancellationToken.None);
|
||||
|
||||
_bodySystem.GibBody(args.Target);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Explosion;
|
||||
using Content.Shared.Explosion.Components;
|
||||
using Content.Shared.Explosion.EntitySystems;
|
||||
@@ -14,6 +17,7 @@ using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -205,7 +209,8 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
MapCoordinates epicenter,
|
||||
HashSet<EntityUid> processed,
|
||||
string id,
|
||||
float? fireStacks)
|
||||
float? fireStacks,
|
||||
EntityUid? cause)
|
||||
{
|
||||
var size = grid.Comp.TileSize;
|
||||
var gridBox = new Box2(tile * size, (tile + 1) * size);
|
||||
@@ -224,7 +229,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
// process those entities
|
||||
foreach (var (uid, xform) in list)
|
||||
{
|
||||
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks);
|
||||
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks, cause);
|
||||
}
|
||||
|
||||
// process anchored entities
|
||||
@@ -234,7 +239,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
foreach (var entity in _anchored)
|
||||
{
|
||||
processed.Add(entity);
|
||||
ProcessEntity(entity, epicenter, damage, throwForce, id, null, fireStacks);
|
||||
ProcessEntity(entity, epicenter, damage, throwForce, id, null, fireStacks, cause);
|
||||
}
|
||||
|
||||
// Walls and reinforced walls will break into girders. These girders will also be considered turf-blocking for
|
||||
@@ -270,7 +275,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
{
|
||||
// Here we only throw, no dealing damage. Containers n such might drop their entities after being destroyed, but
|
||||
// they should handle their own damage pass-through, with their own damage reduction calculation.
|
||||
ProcessEntity(uid, epicenter, null, throwForce, id, xform, null);
|
||||
ProcessEntity(uid, epicenter, null, throwForce, id, xform, null, cause);
|
||||
}
|
||||
|
||||
return !tileBlocked;
|
||||
@@ -306,7 +311,8 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
MapCoordinates epicenter,
|
||||
HashSet<EntityUid> processed,
|
||||
string id,
|
||||
float? fireStacks)
|
||||
float? fireStacks,
|
||||
EntityUid? cause)
|
||||
{
|
||||
var gridBox = Box2.FromDimensions(tile * DefaultTileSize, new Vector2(DefaultTileSize, DefaultTileSize));
|
||||
var worldBox = spaceMatrix.TransformBox(gridBox);
|
||||
@@ -322,7 +328,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
foreach (var (uid, xform) in state.Item1)
|
||||
{
|
||||
processed.Add(uid);
|
||||
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks);
|
||||
ProcessEntity(uid, epicenter, damage, throwForce, id, xform, fireStacks, cause);
|
||||
}
|
||||
|
||||
if (throwForce <= 0)
|
||||
@@ -336,7 +342,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
|
||||
foreach (var (uid, xform) in list)
|
||||
{
|
||||
ProcessEntity(uid, epicenter, null, throwForce, id, xform, fireStacks);
|
||||
ProcessEntity(uid, epicenter, null, throwForce, id, xform, fireStacks, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,13 +440,28 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
float throwForce,
|
||||
string id,
|
||||
TransformComponent? xform,
|
||||
float? fireStacksOnIgnite)
|
||||
float? fireStacksOnIgnite,
|
||||
EntityUid? cause)
|
||||
{
|
||||
if (originalDamage != null)
|
||||
{
|
||||
GetEntitiesToDamage(uid, originalDamage, id);
|
||||
foreach (var (entity, damage) in _toDamage)
|
||||
{
|
||||
if (damage.GetTotal() > 0 && TryComp<ActorComponent>(entity, out var actorComponent))
|
||||
{
|
||||
// Log damage to player entities only, cause this will create a massive amount of log spam otherwise.
|
||||
if (cause != null)
|
||||
{
|
||||
_adminLogger.Add(LogType.ExplosionHit, LogImpact.Medium, $"Explosion of {ToPrettyString(cause):actor} dealt {damage.GetTotal()} damage to {ToPrettyString(entity):subject}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_adminLogger.Add(LogType.ExplosionHit, LogImpact.Medium, $"Explosion at {epicenter:epicenter} dealt {damage.GetTotal()} damage to {ToPrettyString(entity):subject}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO EXPLOSIONS turn explosions into entities, and pass the the entity in as the damage origin.
|
||||
_damageableSystem.TryChangeDamage(entity, damage, ignoreResistances: true);
|
||||
|
||||
@@ -647,6 +668,8 @@ sealed class Explosion
|
||||
|
||||
public readonly EntityUid VisualEnt;
|
||||
|
||||
public readonly EntityUid? Cause;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a new instance for processing
|
||||
/// </summary>
|
||||
@@ -663,9 +686,11 @@ sealed class Explosion
|
||||
bool canCreateVacuum,
|
||||
IEntityManager entMan,
|
||||
IMapManager mapMan,
|
||||
EntityUid visualEnt)
|
||||
EntityUid visualEnt,
|
||||
EntityUid? cause)
|
||||
{
|
||||
VisualEnt = visualEnt;
|
||||
Cause = cause;
|
||||
_system = system;
|
||||
ExplosionType = explosionType;
|
||||
_tileSetIntensity = tileSetIntensity;
|
||||
@@ -829,7 +854,8 @@ sealed class Explosion
|
||||
Epicenter,
|
||||
ProcessedEntities,
|
||||
ExplosionType.ID,
|
||||
ExplosionType.FireStacks);
|
||||
ExplosionType.FireStacks,
|
||||
Cause);
|
||||
|
||||
// If the floor is not blocked by some dense object, damage the floor tiles.
|
||||
if (canDamageFloor)
|
||||
@@ -847,7 +873,8 @@ sealed class Explosion
|
||||
Epicenter,
|
||||
ProcessedEntities,
|
||||
ExplosionType.ID,
|
||||
ExplosionType.FireStacks);
|
||||
ExplosionType.FireStacks,
|
||||
Cause);
|
||||
}
|
||||
|
||||
if (!MoveNext())
|
||||
@@ -888,4 +915,5 @@ public sealed class QueuedExplosion
|
||||
public float TotalIntensity, Slope, MaxTileIntensity, TileBreakScale;
|
||||
public int MaxTileBreak;
|
||||
public bool CanCreateVacuum;
|
||||
public EntityUid? Cause; // The entity that exploded, for logging purposes.
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
|
||||
var posFound = _transformSystem.TryGetMapOrGridCoordinates(uid, out var gridPos, pos);
|
||||
|
||||
QueueExplosion(mapPos, typeId, totalIntensity, slope, maxTileIntensity, tileBreakScale, maxTileBreak, canCreateVacuum, addLog: false);
|
||||
QueueExplosion(mapPos, typeId, totalIntensity, slope, maxTileIntensity, uid, tileBreakScale, maxTileBreak, canCreateVacuum, addLog: false);
|
||||
|
||||
if (!addLog)
|
||||
return;
|
||||
@@ -281,6 +281,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
float totalIntensity,
|
||||
float slope,
|
||||
float maxTileIntensity,
|
||||
EntityUid? cause,
|
||||
float tileBreakScale = 1f,
|
||||
int maxTileBreak = int.MaxValue,
|
||||
bool canCreateVacuum = true,
|
||||
@@ -324,7 +325,8 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
MaxTileIntensity = maxTileIntensity,
|
||||
TileBreakScale = tileBreakScale,
|
||||
MaxTileBreak = maxTileBreak,
|
||||
CanCreateVacuum = canCreateVacuum
|
||||
CanCreateVacuum = canCreateVacuum,
|
||||
Cause = cause
|
||||
};
|
||||
_explosionQueue.Enqueue(boom);
|
||||
_queuedExplosions.Add(boom);
|
||||
@@ -393,7 +395,8 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
queued.CanCreateVacuum,
|
||||
EntityManager,
|
||||
_mapManager,
|
||||
visualEnt);
|
||||
visualEnt,
|
||||
queued.Cause);
|
||||
}
|
||||
|
||||
private void CameraShake(float range, MapCoordinates epicenter, float totalIntensity)
|
||||
|
||||
@@ -35,6 +35,7 @@ public sealed class LightningTargetSystem : EntitySystem
|
||||
uid.Comp.ExplosionPrototype,
|
||||
uid.Comp.TotalIntensity, uid.Comp.Dropoff,
|
||||
uid.Comp.MaxTileIntensity,
|
||||
uid,
|
||||
canCreateVacuum: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ public sealed class BluespaceLockerSystem : EntitySystem
|
||||
{
|
||||
case BluespaceLockerDestroyType.Explode:
|
||||
_explosionSystem.QueueExplosion(uid.ToCoordinates().ToMap(EntityManager, _transformSystem),
|
||||
ExplosionSystem.DefaultExplosionPrototypeId, 4, 1, 2, maxTileBreak: 0);
|
||||
ExplosionSystem.DefaultExplosionPrototypeId, 4, 1, 2, uid, maxTileBreak: 0);
|
||||
goto case BluespaceLockerDestroyType.Delete;
|
||||
case BluespaceLockerDestroyType.Delete:
|
||||
QueueDel(uid);
|
||||
|
||||
@@ -115,4 +115,10 @@ public enum LogType
|
||||
/// Storage & entity-storage related interactions
|
||||
/// </summary>
|
||||
Storage = 93,
|
||||
|
||||
/// <summary>
|
||||
/// A player got hit by an explosion and was dealt damage.
|
||||
/// </summary>
|
||||
ExplosionHit = 94,
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user