Skip to content

Commit

Permalink
Make Dionas Slow And Steady (#704)
Browse files Browse the repository at this point in the history
# Description

Dionas now have 25% slower movement speed in exchange for total slip
immunity and slow immunity (except lying down).

Note that this also prevents slowdowns from hunger and thirst.

This also fixes an existing bug with Sluggish and Snail-Paced related to
`TraitSpeedModifierSystem`, as it was not applying the reduced movement
speed upon spawning, only when the movement speed has been modified by
another source. `TraitSpeedModifierSystem` has been moved from
`Content.Server` to `Content.Shared`.

This used to be a trait costing 3 points, but is now given for free to
all Dionas per request of @VMSolidus.

## Media

<details><summary>Expand</summary>

**Speed with no items**


![image](https://github.com/user-attachments/assets/b723614a-79fe-401c-ae53-2ad98ff9a6d3)

**Speed wearing a jugsuit, wearing a duffel bag, holding one duffel bag
in each arm, and walking through a puddle of glue covered in spider
webs.**


![image](https://github.com/user-attachments/assets/a934d2c1-437f-463c-8fe3-63b7b54a1f58)

</details>

# Changelog

:cl: Skubman
- add: Dionas have been given a 25% slower movement speed. In exchange
for that, they gain absolute slip immunity and movement speed modifier
immunity. This makes them immune to slowdown from things like
duffelbags, hardsuits, and spider webs.
- fix: Sluggish and Snail-Paced will now properly apply their movement
penalties upon joining.
  • Loading branch information
angelofallars authored Aug 9, 2024
1 parent f034031 commit f4d2e35
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Standing/LayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void OnRefreshMovementSpeed(EntityUid uid, LayingDownComponent component
if (TryComp<StandingStateComponent>(uid, out var standingState) && standingState.Standing)
return;

args.ModifySpeed(component.DownedSpeedMultiplier, component.DownedSpeedMultiplier);
args.ModifySpeed(component.DownedSpeedMultiplier, component.DownedSpeedMultiplier, bypassImmunity: true);
}

private void OnParentChanged(EntityUid uid, LayingDownComponent component, EntParentChangedMessage args)
Expand Down
19 changes: 0 additions & 19 deletions Content.Server/Traits/Assorted/TraitSpeedModifierSystem.cs

This file was deleted.

23 changes: 21 additions & 2 deletions Content.Shared/Movement/Systems/MovementSpeedModifierSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Inventory;
using Content.Shared.Movement.Components;
using Content.Shared.Traits.Assorted.Components;
using Robust.Shared.Timing;

namespace Content.Shared.Movement.Systems
Expand All @@ -16,7 +17,11 @@ public void RefreshMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierCo
if (_timing.ApplyingState)
return;

var ev = new RefreshMovementSpeedModifiersEvent();
var isImmune = false;
if (HasComp<SpeedModifierImmunityComponent>(uid))
isImmune = true;

var ev = new RefreshMovementSpeedModifiersEvent(isImmune);
RaiseLocalEvent(uid, ev);

if (MathHelper.CloseTo(ev.WalkSpeedModifier, move.WalkSpeedModifier) &&
Expand Down Expand Up @@ -64,10 +69,24 @@ public sealed class RefreshMovementSpeedModifiersEvent : EntityEventArgs, IInven
public float WalkSpeedModifier { get; private set; } = 1.0f;
public float SprintSpeedModifier { get; private set; } = 1.0f;

public void ModifySpeed(float walk, float sprint)
/// <summary>
/// Whether this entity is immune to most movement speed modifiers.
/// Bypassable by setting bypassImmunity to true.
/// </summary
private bool IsImmune = false;

public void ModifySpeed(float walk, float sprint, bool bypassImmunity = false)
{
if (IsImmune && !bypassImmunity)
return;

WalkSpeedModifier *= walk;
SprintSpeedModifier *= sprint;
}

public RefreshMovementSpeedModifiersEvent(bool isImmune = false)
{
IsImmune = isImmune;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Traits.Assorted.Components;

/// <summary>
/// This is used to make an entity's movement speed constant and
/// never affected by almost all movement speed modifiers.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class SpeedModifierImmunityComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
namespace Content.Server.Traits.Assorted;
using Robust.Shared.GameStates;

namespace Content.Shared.Traits.Assorted.Components;

/// <summary>
/// This component is used for traits that modify movement speed.
/// </summary>
[RegisterComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class TraitSpeedModifierComponent : Component
{
[DataField(required: true)]
[DataField, AutoNetworkedField]
public float WalkModifier = 1.0f;

[DataField(required: true)]
[DataField, AutoNetworkedField]
public float SprintModifier = 1.0f;
}
31 changes: 31 additions & 0 deletions Content.Shared/Traits/Assorted/Systems/TraitSpeedModifierSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Traits.Assorted.Components;

namespace Content.Shared.Traits.Assorted.Systems;

public sealed class TraitSpeedModifierSystem : EntitySystem
{
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<TraitSpeedModifierComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<TraitSpeedModifierComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed);
}

private void OnRefreshMovementSpeed(EntityUid uid, TraitSpeedModifierComponent component, RefreshMovementSpeedModifiersEvent args)
{
args.ModifySpeed(component.WalkModifier, component.SprintModifier, bypassImmunity: true);
}

private void OnStartup(EntityUid uid, TraitSpeedModifierComponent component, ComponentStartup args)
{
if (!TryComp<MovementSpeedModifierComponent>(uid, out var move))
return;

_movement.RefreshMovementSpeedModifiers(uid, move);
}
}
5 changes: 5 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Species/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
understands:
- GalacticCommon
- RootSpeak
- type: TraitSpeedModifier
sprintModifier: 0.75
walkModifier: 0.75
- type: SpeedModifierImmunity
- type: NoSlip

- type: entity
parent: BaseSpeciesDummy
Expand Down
8 changes: 8 additions & 0 deletions Resources/Prototypes/Traits/disabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
traits:
- ParkourTraining
- SnailPaced
- !type:CharacterSpeciesRequirement
inverted: true
species:
- Diona
components:
- type: TraitSpeedModifier
sprintModifier: 0.85
Expand All @@ -124,6 +128,10 @@
traits:
- ParkourTraining
- Sluggish
- !type:CharacterSpeciesRequirement
inverted: true
species:
- Diona
components:
- type: TraitSpeedModifier
sprintModifier: 0.7
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Traits/skills.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
traits:
- Sluggish
- SnailPaced
- !type:CharacterSpeciesRequirement
inverted: true
species:
- Diona
components:
- type: ClimbDelayModifier
climbDelayMultiplier: 0.70
Expand Down

0 comments on commit f4d2e35

Please sign in to comment.