Melee rebalancing (#17520)

This commit is contained in:
metalgearsloth
2023-08-06 12:55:38 +10:00
committed by GitHub
parent 28a5e32f5e
commit aa8efc9a26
22 changed files with 124 additions and 502 deletions

View File

@@ -36,12 +36,12 @@ public sealed class StaminaComponent : Component
/// <summary>
/// How much stamina damage is required to entire stam crit.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("excess")]
[ViewVariables(VVAccess.ReadWrite), DataField("critThreshold")]
public float CritThreshold = 100f;
/// <summary>
/// To avoid continuously updating our data we track the last time we updated so we can extrapolate our current stamina.
/// </summary>
[DataField("lastUpdate", customTypeSerializer:typeof(TimeOffsetSerializer))]
[DataField("nextUpdate", customTypeSerializer:typeof(TimeOffsetSerializer))]
public TimeSpan NextUpdate = TimeSpan.Zero;
}

View File

@@ -227,6 +227,23 @@ public sealed class StaminaSystem : EntitySystem
_alerts.ShowAlert(uid, AlertType.Stamina, (short) severity);
}
/// <summary>
/// Tries to take stamina damage without raising the entity over the crit threshold.
/// </summary>
public bool TryTakeStamina(EntityUid uid, float value, StaminaComponent? component = null, EntityUid? source = null, EntityUid? with = null)
{
if (!Resolve(uid, ref component, false))
return false;
var oldStam = component.StaminaDamage;
if (oldStam + value > component.CritThreshold || component.Critical)
return false;
TakeStaminaDamage(uid, value, component, source, with);
return true;
}
public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null, EntityUid? source = null, EntityUid? with = null)
{
if (!Resolve(uid, ref component, false))