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);
|
FireEffects(fromCoordinates, distance, mapDirection.ToAngle(), hitscan, hitEntity);
|
||||||
|
|
||||||
if (hitscan.StaminaDamage > 0f)
|
if (hitscan.StaminaDamage > 0f)
|
||||||
_stamina.TakeStaminaDamage(hitEntity, hitscan.StaminaDamage);
|
_stamina.TakeStaminaDamage(hitEntity, hitscan.StaminaDamage, source:user);
|
||||||
|
|
||||||
var dmg = hitscan.Damage;
|
var dmg = hitscan.Damage;
|
||||||
|
|
||||||
|
|||||||
@@ -78,4 +78,5 @@ public enum LogType
|
|||||||
StorePurchase = 73,
|
StorePurchase = 73,
|
||||||
LatticeCut = 74,
|
LatticeCut = 74,
|
||||||
Stripping = 75,
|
Stripping = 75,
|
||||||
|
Stamina = 76,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Shared.Damage.Components;
|
|||||||
using Content.Shared.Damage.Events;
|
using Content.Shared.Damage.Events;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Rounding;
|
using Content.Shared.Rounding;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
@@ -119,7 +120,7 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var damage = args.PushProbability * component.CritThreshold;
|
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
|
// 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)
|
if (!component.Critical)
|
||||||
@@ -174,7 +175,7 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
foreach (var comp in toHit)
|
foreach (var comp in toHit)
|
||||||
{
|
{
|
||||||
var oldDamage = comp.StaminaDamage;
|
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))
|
if (comp.StaminaDamage.Equals(oldDamage))
|
||||||
{
|
{
|
||||||
_popup.PopupEntity(Loc.GetString("stamina-resist"), comp.Owner, Filter.Entities(args.User));
|
_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;
|
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)
|
private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null)
|
||||||
@@ -201,7 +202,7 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
_alerts.ShowAlert(uid, AlertType.Stamina, (short) severity);
|
_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)
|
if (!Resolve(uid, ref component, false) || component.Critical)
|
||||||
return;
|
return;
|
||||||
@@ -246,6 +247,17 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
|
|
||||||
EnsureComp<ActiveStaminaComponent>(uid);
|
EnsureComp<ActiveStaminaComponent>(uid);
|
||||||
Dirty(component);
|
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)
|
public override void Update(float frameTime)
|
||||||
@@ -305,6 +317,7 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
component.NextUpdate = _timing.CurTime + stunTime + StamCritBufferTime;
|
component.NextUpdate = _timing.CurTime + stunTime + StamCritBufferTime;
|
||||||
EnsureComp<ActiveStaminaComponent>(uid);
|
EnsureComp<ActiveStaminaComponent>(uid);
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
|
_adminLogger.Add(LogType.Stamina, LogImpact.Medium, $"{ToPrettyString(uid):user} entered stamina crit");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null)
|
private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null)
|
||||||
@@ -318,6 +331,7 @@ public sealed class StaminaSystem : EntitySystem
|
|||||||
SetStaminaAlert(uid, component);
|
SetStaminaAlert(uid, component);
|
||||||
RemComp<ActiveStaminaComponent>(uid);
|
RemComp<ActiveStaminaComponent>(uid);
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
|
_adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
|
using Content.Shared.Administration.Logs;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
@@ -6,6 +7,7 @@ using Content.Shared.Interaction.Events;
|
|||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Bed.Sleep;
|
using Content.Shared.Bed.Sleep;
|
||||||
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
using Content.Shared.Movement.Systems;
|
using Content.Shared.Movement.Systems;
|
||||||
using Content.Shared.Standing;
|
using Content.Shared.Standing;
|
||||||
@@ -26,6 +28,7 @@ namespace Content.Shared.Stunnable
|
|||||||
[Dependency] private readonly StatusEffectsSystem _statusEffectSystem = default!;
|
[Dependency] private readonly StatusEffectsSystem _statusEffectSystem = default!;
|
||||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
|
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Friction modifier for knocked down players.
|
/// Friction modifier for knocked down players.
|
||||||
@@ -150,7 +153,10 @@ namespace Content.Shared.Stunnable
|
|||||||
if (!Resolve(uid, ref status, false))
|
if (!Resolve(uid, ref status, false))
|
||||||
return 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>
|
/// <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 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))
|
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)
|
if (component.Owner == user)
|
||||||
|
|||||||
Reference in New Issue
Block a user