Skip to content

Commit 8dd692d

Browse files
Some more traits (Floof-Station#256)
* Small fix for crawling direction inversion * Stamina traits * Modify AnimationThreshold too * Footstep volume modifier and relevant trait
1 parent 102d8aa commit 8dd692d

13 files changed

Lines changed: 177 additions & 35 deletions

File tree

Content.Client/Damage/Systems/StaminaSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private void PlayAnimation(Entity<StaminaComponent, SpriteComponent> entity)
108108
DebugTools.Assert(entity.Comp1.CritThreshold > entity.Comp1.AnimationThreshold, $"Animation threshold on {ToPrettyString(entity)} was not less than the crit threshold. This will cause errors, animation has been cancelled.");
109109

110110
var step = Math.Clamp((entity.Comp1.StaminaDamage - entity.Comp1.AnimationThreshold) /
111-
(entity.Comp1.CritThreshold - entity.Comp1.AnimationThreshold),
111+
MathF.Max((entity.Comp1.CritThreshold - entity.Comp1.AnimationThreshold), 1), // Floofstation - ensure this doesn't result in division by 0
112112
0f,
113113
1f); // The things I do for project 0 warnings
114114
var frequency = entity.Comp1.FrequencyMin + step * entity.Comp1.FrequencyMod;

Content.Shared/Damage/Components/StaminaComponent.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public sealed partial class StaminaComponent : Component
7070
/// This float determines how fast stamina will regenerate after exiting the stamina crit.
7171
/// </summary>
7272
[DataField, AutoNetworkedField]
73-
public float AfterCritDecayMultiplier = 5f;
73+
public float AfterCritDecayMultiplier = 2f; // Floofstation - lower value
7474

7575
/// <summary>
7676
/// This is how much stamina damage a mob takes when it forces itself to stand up before modifiers
@@ -87,7 +87,7 @@ public sealed partial class StaminaComponent : Component
8787
/// <summary>
8888
/// Thresholds that determine an entity's slowdown as a function of stamina damage.
8989
/// </summary>
90-
[DataField]
90+
[DataField, AutoNetworkedField] // Floofstation - made networked because of traits
9191
public Dictionary<FixedPoint2, float> StunModifierThresholds = new() { {0, 1f }, { 60, 0.7f }, { 80, 0.5f } };
9292

9393
#region Animation Data
@@ -96,7 +96,7 @@ public sealed partial class StaminaComponent : Component
9696
/// Threshold at which low stamina animations begin playing. This should be set to a value that means something.
9797
/// At 50, it is aligned so when you hit 60 stun the entity will be breathing once per second (well above hyperventilation).
9898
/// </summary>
99-
[DataField]
99+
[DataField, AutoNetworkedField] // Floofstation - networked
100100
public float AnimationThreshold = 50;
101101

102102
/// <summary>
@@ -127,13 +127,13 @@ public sealed partial class StaminaComponent : Component
127127
/// Min multipliers for JitterAmplitude in the X and Y directions, animation randomly chooses between these min and max multipliers
128128
/// </summary>
129129
[DataField]
130-
public Vector2 JitterMin = Vector2.Create(0.5f, 0.125f);
130+
public Vector2 JitterMin = Vector2.Create(0.25f, 0.0625f); // Floofstation - lowered because it looks weird.
131131

132132
/// <summary>
133133
/// Max multipliers for JitterAmplitude in the X and Y directions, animation randomly chooses between these min and max multipliers
134134
/// </summary>
135135
[DataField]
136-
public Vector2 JitterMax = Vector2.Create(1f, 0.25f);
136+
public Vector2 JitterMax = Vector2.Create(0.5f, 0.125f); // Floofstation - lowered because it looks weird.
137137

138138
/// <summary>
139139
/// Minimum total animations per second

Content.Shared/Movement/Systems/SharedMoverController.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Numerics;
3-
using Content.Shared._DV.Movement; // DeltaV
3+
using Content.Shared._DV.Movement;
4+
using Content.Shared._Floof.Movement.Footsteps;
45
using Content.Shared.ActionBlocker;
56
using Content.Shared.CCVar;
67
using Content.Shared.Friction;
@@ -63,6 +64,7 @@ public abstract partial class SharedMoverController : VirtualController
6364
protected EntityQuery<PullableComponent> PullableQuery;
6465
protected EntityQuery<TransformComponent> XformQuery;
6566
protected EntityQuery<NoShoesSilentFootstepsComponent> NoShoesSilentQuery; // DeltaV - NoShoesSilentFootstepsComponent
67+
protected EntityQuery<FootstepVolumeModifierComponent> FootstepVolumeQuery; // Floofstation
6668

6769
private static readonly ProtoId<TagPrototype> FootstepSoundTag = "FootstepSound";
6870

@@ -96,6 +98,7 @@ public override void Initialize()
9698
FootstepModifierQuery = GetEntityQuery<FootstepModifierComponent>();
9799
MapGridQuery = GetEntityQuery<MapGridComponent>();
98100
NoShoesSilentQuery = GetEntityQuery<NoShoesSilentFootstepsComponent>(); // DeltaV - NoShoesSilentFootstepsComponent
101+
FootstepVolumeQuery = GetEntityQuery<FootstepVolumeModifierComponent>(); // Floofstation
99102
MapQuery = GetEntityQuery<MapComponent>();
100103

101104
SubscribeLocalEvent<MovementSpeedModifierComponent, TileFrictionEvent>(OnTileFriction);
@@ -345,6 +348,11 @@ public void HandleMobMovement( // DeltaV - made public
345348
var soundModifier = mover.Sprinting ? InputMoverComponent.SprintingSoundModifier
346349
: InputMoverComponent.WalkingSoundModifier;
347350

351+
// Floofstation section - volume modifiers
352+
if (FootstepVolumeQuery.TryGetComponent(uid, out var volumeModifier))
353+
soundModifier += volumeModifier.Volume;
354+
// Floofstation section end
355+
348356
var audioParams = sound.Params
349357
.WithVolume(sound.Params.Volume + soundModifier)
350358
.WithVariation(sound.Params.Variation ?? mobMover.FootstepVariation);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Robust.Shared.GameStates;
2+
3+
namespace Content.Shared._Floof.Movement.Footsteps;
4+
5+
/// <summary>
6+
/// Changes the volume of the mover's footsteps.<br/>
7+
///
8+
/// This component is primarily used in traits, but cannot be made into a simple TraitEffect because SharedMoverController
9+
/// HARDCODES the footstep volume modifiers. I don't want to change the upstream code and make those constants into properties,
10+
/// so here we are.
11+
/// </summary>
12+
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
13+
public sealed partial class FootstepVolumeModifierComponent : Component
14+
{
15+
/// <summary>
16+
/// Volume change, in decibels.
17+
/// </summary>
18+
[DataField, AutoNetworkedField]
19+
public float Volume;
20+
}

Content.Shared/_Floof/Standing/SharedCrawlingExtensionsSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void HandleDirectionToggleRequest(ICommonSession? session)
7979

8080
// +90deg = default horizontal rotation, -90deg = opposite
8181
var rotVisuals = EnsureComp<RotationVisualsComponent>(uid);
82-
_rotVisuals.SetHorizontalAngle((uid, rotVisuals), rotVisuals.DefaultRotation + (ext.InvertedCrawlingDirection ? 0 : Angle.FromDegrees(180)));
82+
_rotVisuals.SetHorizontalAngle((uid, rotVisuals), rotVisuals.DefaultRotation + (!ext.InvertedCrawlingDirection ? 0 : Angle.FromDegrees(180)));
8383
// Have to queue an appearance update so the RotationVisualizerSystem can play an animation if the entity is already laying
8484
Dirty(uid, appearance);
8585
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Content.Shared._DV.Traits.Effects;
2+
using Content.Shared.Damage.Components;
3+
using Content.Shared.FixedPoint;
4+
5+
namespace Content.Shared._Floof.Traits.Effects;
6+
7+
public sealed partial class ModifyStaminaThresholdEffect : BaseTraitEffect
8+
{
9+
/// <summary>
10+
/// Multiplicative stamina threshold and decay bonus.
11+
/// </summary>
12+
[DataField]
13+
public float Multiplier = 1f;
14+
15+
public override void Apply(TraitEffectContext ctx)
16+
{
17+
if (!ctx.EntMan.TryGetComponent<StaminaComponent>(ctx.Player, out var stamina))
18+
{
19+
Log.Error($"Player {ctx.EntMan.ToPrettyString(ctx.Player)} has no {nameof(StaminaComponent)}!");
20+
return;
21+
}
22+
23+
stamina.CritThreshold *= Multiplier;
24+
stamina.Decay *= Multiplier;
25+
stamina.AnimationThreshold *= Multiplier;
26+
27+
// There are several stamina thresholds at which the mob is slowed down, all of which need to be updated
28+
var newThresholds = new Dictionary<FixedPoint2, float>();
29+
foreach (var (threshold, speedMultiplier) in stamina.StunModifierThresholds)
30+
newThresholds[threshold * Multiplier] = speedMultiplier;
31+
32+
stamina.StunModifierThresholds = newThresholds;
33+
ctx.EntMan.Dirty(ctx.Player, stamina);
34+
}
35+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
trait-category-languages = Languages
22
trait-category-natural-languages = Natural languages
3+
trait-category-skills = Skills

Resources/Locale/en-US/_Floof/traits/physical_traits.ftl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@ trait-weightheavy-name = Heavyweight
77
trait-weightheavy-desc =
88
You are naturally heavier than other representatives of your species. Your body density is increased to 140% of normal.
99
Note: [color=red]this will not display in the character creation menu, and will only have effect in-game.[/color]
10+
11+
trait-vigor-name = Vigor
12+
trait-vigor-desc =
13+
Whether by pure determination, fitness, or bionic augmentations, your endurance is enhanced.
14+
Your stamina thresholds are 20% greater than usual.
15+
16+
trait-lethargy-name = Lethargy
17+
trait-lethargy-desc =
18+
You become tired faster than others, making you more vulnerable to exhaustion and fatigue.
19+
Your stamina thresholds are 20% lower than usual.
20+
21+
trait-weakness-name = Weakness
22+
trait-weakness-desc =
23+
You are naturally more vulnerable to fatigue. Your stamina pool is halved, making you greately vulnerable to shoving and stunning attacks.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trait-light-step-name = Light Step
2+
trait-light-step-desc = You move with a gentle step, which makes your footsteps quieter.

Resources/Prototypes/_DV/Traits/trait_categories.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
id: Meta
2929
name: trait-category-meta
3030
priority: 50
31-
maxTraits: 2
31+
maxTraits: 2 # Floof
3232
accentColor: "#eab308" # Yellow

0 commit comments

Comments
 (0)