Skip to content

Commit

Permalink
Hotfix Stamina System (#1245)
Browse files Browse the repository at this point in the history
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Goal of this PR is to fix the stamina system, as was caused by #1220.

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl:
- fix: Fixed stamina system

Co-authored-by: sleepyyapril <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>
  • Loading branch information
sleepyyapril authored Nov 18, 2024
1 parent 2eea0f7 commit bea5f13
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Content.Shared/Damage/Systems/StaminaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private void OnShutdown(EntityUid uid, StaminaComponent component, ComponentShut
{
RemCompDeferred<ActiveStaminaComponent>(uid);
}
_alerts.ClearAlert(uid, component.StaminaAlert);

SetStaminaAlert(uid);
}

private void OnStartup(EntityUid uid, StaminaComponent component, ComponentStartup args)
Expand Down Expand Up @@ -229,7 +230,10 @@ private void OnCollide(EntityUid uid, StaminaDamageOnCollideComponent component,
private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null)
{
if (!Resolve(uid, ref component, false) || component.Deleted)
{
_alerts.ClearAlert(uid, "Stamina");
return;
}

var severity = ContentHelpers.RoundToLevels(MathF.Max(0f, component.CritThreshold - component.StaminaDamage), component.CritThreshold, 7);
_alerts.ShowAlert(uid, component.StaminaAlert, (short) severity);
Expand Down Expand Up @@ -420,7 +424,6 @@ private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null)
component.NextUpdate = _timing.CurTime;
_movementSpeed.RefreshMovementSpeedModifiers(uid);
SetStaminaAlert(uid, component);
RemComp<ActiveStaminaComponent>(uid);
Dirty(uid, component);
_adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit");
}
Expand All @@ -430,4 +433,4 @@ private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null)
/// Raised before stamina damage is dealt to allow other systems to cancel it.
/// </summary>
[ByRefEvent]
public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false);
public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false);

0 comments on commit bea5f13

Please sign in to comment.