Add stamina logs (#12921)
This commit is contained in:
@@ -188,7 +188,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
FireEffects(fromCoordinates, distance, mapDirection.ToAngle(), hitscan, hitEntity);
|
||||
|
||||
if (hitscan.StaminaDamage > 0f)
|
||||
_stamina.TakeStaminaDamage(hitEntity, hitscan.StaminaDamage);
|
||||
_stamina.TakeStaminaDamage(hitEntity, hitscan.StaminaDamage, source:user);
|
||||
|
||||
var dmg = hitscan.Damage;
|
||||
|
||||
|
||||
@@ -78,4 +78,5 @@ public enum LogType
|
||||
StorePurchase = 73,
|
||||
LatticeCut = 74,
|
||||
Stripping = 75,
|
||||
Stamina = 76,
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Rounding;
|
||||
using Content.Shared.Stunnable;
|
||||
@@ -119,7 +120,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
return;
|
||||
|
||||
var damage = args.PushProbability * component.CritThreshold;
|
||||
TakeStaminaDamage(uid, damage, component);
|
||||
TakeStaminaDamage(uid, damage, component, source:args.Source);
|
||||
|
||||
// We need a better method of getting if the entity is going to resist stam damage, both this and the lines in the foreach at the end of OnHit() are awful
|
||||
if (!component.Critical)
|
||||
@@ -174,7 +175,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
foreach (var comp in toHit)
|
||||
{
|
||||
var oldDamage = comp.StaminaDamage;
|
||||
TakeStaminaDamage(comp.Owner, damage / toHit.Count, comp);
|
||||
TakeStaminaDamage(comp.Owner, damage / toHit.Count, comp, source:args.User, with:component.Owner);
|
||||
if (comp.StaminaDamage.Equals(oldDamage))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("stamina-resist"), comp.Owner, Filter.Entities(args.User));
|
||||
@@ -186,7 +187,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
{
|
||||
if (!args.OurFixture.ID.Equals(CollideFixture)) return;
|
||||
|
||||
TakeStaminaDamage(args.OtherFixture.Body.Owner, component.Damage);
|
||||
TakeStaminaDamage(args.OtherFixture.Body.Owner, component.Damage, source:args.OurFixture.Body.Owner);
|
||||
}
|
||||
|
||||
private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null)
|
||||
@@ -201,7 +202,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
_alerts.ShowAlert(uid, AlertType.Stamina, (short) severity);
|
||||
}
|
||||
|
||||
public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null)
|
||||
public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null, EntityUid? source = null, EntityUid? with = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false) || component.Critical)
|
||||
return;
|
||||
@@ -246,6 +247,17 @@ public sealed class StaminaSystem : EntitySystem
|
||||
|
||||
EnsureComp<ActiveStaminaComponent>(uid);
|
||||
Dirty(component);
|
||||
|
||||
if (value <= 0)
|
||||
return;
|
||||
if (source != null)
|
||||
{
|
||||
_adminLogger.Add(LogType.Stamina, $"{ToPrettyString(source.Value):user} caused {value} stamina damage to {ToPrettyString(uid):target}{(with != null ? $" using {ToPrettyString(with.Value):using}" : "")}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_adminLogger.Add(LogType.Stamina, $"{ToPrettyString(uid):target} took {value} stamina damage");
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -305,6 +317,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
component.NextUpdate = _timing.CurTime + stunTime + StamCritBufferTime;
|
||||
EnsureComp<ActiveStaminaComponent>(uid);
|
||||
Dirty(component);
|
||||
_adminLogger.Add(LogType.Stamina, LogImpact.Medium, $"{ToPrettyString(uid):user} entered stamina crit");
|
||||
}
|
||||
|
||||
private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null)
|
||||
@@ -318,6 +331,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
SetStaminaAlert(uid, component);
|
||||
RemComp<ActiveStaminaComponent>(uid);
|
||||
Dirty(component);
|
||||
_adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit");
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -6,6 +7,7 @@ using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Standing;
|
||||
@@ -26,6 +28,7 @@ namespace Content.Shared.Stunnable
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectSystem = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Friction modifier for knocked down players.
|
||||
@@ -150,7 +153,10 @@ namespace Content.Shared.Stunnable
|
||||
if (!Resolve(uid, ref status, false))
|
||||
return false;
|
||||
|
||||
return _statusEffectSystem.TryAddStatusEffect<StunnedComponent>(uid, "Stun", time, refresh);
|
||||
if (!_statusEffectSystem.TryAddStatusEffect<StunnedComponent>(uid, "Stun", time, refresh))
|
||||
return false;
|
||||
_adminLogger.Add(LogType.Stamina, LogImpact.Medium, $"{ToPrettyString(uid):user} stunned for {time.Seconds} seconds");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -424,7 +424,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
// If the target has stamina and is taking blunt damage, they should also take stamina damage based on their blunt to stamina factor
|
||||
if (damageResult.DamageDict.TryGetValue("Blunt", out var bluntDamage))
|
||||
{
|
||||
_stamina.TakeStaminaDamage(ev.Target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float());
|
||||
_stamina.TakeStaminaDamage(ev.Target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float(), source:user, with:(component.Owner == user ? null : component.Owner));
|
||||
}
|
||||
|
||||
if (component.Owner == user)
|
||||
|
||||
Reference in New Issue
Block a user