stimulants increase stamina (#18754)
Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
19
Content.Shared/Damage/Components/StaminaModifierComponent.cs
Normal file
19
Content.Shared/Damage/Components/StaminaModifierComponent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Damage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies the entity's <see cref="StaminaComponent.StaminaDamage"/> by the <see cref="Modifier"/>.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(StaminaSystem))]
|
||||
public sealed partial class StaminaModifierComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// What to multiply max stamina by.
|
||||
/// When added this scales max stamina, but not stamina damags to give you an extra boost of survability.
|
||||
/// If you have too much damage when the modifier is removed, you suffer "withdrawl" and instantly stamcrit.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("modifier"), AutoNetworkedField]
|
||||
public float Modifier = 2f;
|
||||
}
|
||||
52
Content.Shared/Damage/Systems/StaminaSystem.Modifier.cs
Normal file
52
Content.Shared/Damage/Systems/StaminaSystem.Modifier.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Content.Shared.Damage.Components;
|
||||
|
||||
namespace Content.Shared.Damage.Systems;
|
||||
|
||||
public sealed partial class StaminaSystem
|
||||
{
|
||||
private void InitializeModifier()
|
||||
{
|
||||
SubscribeLocalEvent<StaminaModifierComponent, ComponentStartup>(OnModifierStartup);
|
||||
SubscribeLocalEvent<StaminaModifierComponent, ComponentShutdown>(OnModifierShutdown);
|
||||
}
|
||||
|
||||
private void OnModifierStartup(EntityUid uid, StaminaModifierComponent comp, ComponentStartup args)
|
||||
{
|
||||
if (!TryComp<StaminaComponent>(uid, out var stamina))
|
||||
return;
|
||||
|
||||
stamina.CritThreshold *= comp.Modifier;
|
||||
}
|
||||
|
||||
private void OnModifierShutdown(EntityUid uid, StaminaModifierComponent comp, ComponentShutdown args)
|
||||
{
|
||||
if (!TryComp<StaminaComponent>(uid, out var stamina))
|
||||
return;
|
||||
|
||||
stamina.CritThreshold /= comp.Modifier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the stamina modifier for an entity.
|
||||
/// If it has <see cref="StaminaComponent"/> it will also be updated.
|
||||
/// </summary>
|
||||
public void SetModifier(EntityUid uid, float modifier, StaminaComponent? stamina = null, StaminaModifierComponent? comp = null)
|
||||
{
|
||||
if (!Resolve(uid, ref comp))
|
||||
return;
|
||||
|
||||
var old = comp.Modifier;
|
||||
|
||||
if (old.Equals(modifier))
|
||||
return;
|
||||
|
||||
comp.Modifier = modifier;
|
||||
Dirty(uid, comp);
|
||||
|
||||
if (Resolve(uid, ref stamina, false))
|
||||
{
|
||||
// scale to the new threshold, act as if it was removed then added
|
||||
stamina.CritThreshold *= modifier / old;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Damage.Systems;
|
||||
|
||||
public sealed class StaminaSystem : EntitySystem
|
||||
public sealed partial class StaminaSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
@@ -41,6 +41,9 @@ public sealed class StaminaSystem : EntitySystem
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
InitializeModifier();
|
||||
|
||||
SubscribeLocalEvent<StaminaComponent, EntityUnpausedEvent>(OnStamUnpaused);
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentShutdown>(OnShutdown);
|
||||
@@ -48,6 +51,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentHandleState>(OnStamHandleState);
|
||||
SubscribeLocalEvent<StaminaComponent, DisarmedEvent>(OnDisarmed);
|
||||
SubscribeLocalEvent<StaminaComponent, RejuvenateEvent>(OnRejuvenate);
|
||||
|
||||
SubscribeLocalEvent<StaminaDamageOnCollideComponent, StartCollideEvent>(OnCollide);
|
||||
SubscribeLocalEvent<StaminaDamageOnHitComponent, MeleeHitEvent>(OnHit);
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
- ForcedSleep
|
||||
- TemporaryBlindness
|
||||
- Pacified
|
||||
- StaminaModifier
|
||||
- type: ThermalRegulator
|
||||
metabolismHeat: 800
|
||||
radiatedHeat: 100
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
- ForcedSleep
|
||||
- TemporaryBlindness
|
||||
- Pacified
|
||||
- StaminaModifier
|
||||
- type: Blindable
|
||||
# Other
|
||||
- type: Inventory
|
||||
|
||||
@@ -124,6 +124,11 @@
|
||||
key: KnockedDown
|
||||
time: 3
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
key: StaminaModifier
|
||||
component: StaminaModifier
|
||||
time: 3
|
||||
type: Add
|
||||
Medicine:
|
||||
metabolismRate: 1.0
|
||||
effects:
|
||||
|
||||
@@ -56,3 +56,6 @@
|
||||
|
||||
- type: statusEffect
|
||||
id: RatvarianLanguage #Praise him
|
||||
|
||||
- type: statusEffect
|
||||
id: StaminaModifier
|
||||
|
||||
Reference in New Issue
Block a user