[Add] Minimal Movement Speed (#593)

* crawling in my sleeeeeeeeeep

* fix

---------

Co-authored-by: vanx <discord@vanxxxx>
This commit is contained in:
vanx
2025-06-18 09:22:18 +03:00
committed by GitHub
parent 02b6a89375
commit 7e2cd40a2c
5 changed files with 36 additions and 10 deletions

View File

@@ -44,4 +44,10 @@ public sealed partial class BodyComponent : Component
[DataField, AutoNetworkedField]
public bool ThermalVisibility = true;
/// <summary>
/// WWDP; Minimal move speed regardless of any bodyparts
/// </summary>
[DataField, AutoNetworkedField]
public float MinimumMovementSpeed = 1f;
}

View File

@@ -20,6 +20,7 @@ using Content.Shared.Containers.ItemSlots;
using Content.Shared.Humanoid;
using Content.Shared.Inventory;
using Content.Shared.Random;
using Content.Shared.Traits.Assorted.Components;
namespace Content.Shared.Body.Systems;
@@ -708,8 +709,17 @@ public partial class SharedBodySystem
}
var walkSpeed = 0f;
var sprintSpeed = 0f;
var sprintSpeed= 0f;
var acceleration = 0f;
// WWDP edit - minimal movement speed
var minspeed = body.MinimumMovementSpeed;
if (HasComp<LegsParalyzedComponent>(bodyId))
{
Movement.ChangeBaseSpeed(bodyId, minspeed, minspeed, MovementSpeedModifierComponent.DefaultAcceleration, movement);
return;
}
foreach (var legEntity in body.LegEntities)
{
if (!TryComp<MovementBodyPartComponent>(legEntity, out var legModifier))
@@ -719,8 +729,9 @@ public partial class SharedBodySystem
sprintSpeed += legModifier.SprintSpeed;
acceleration += legModifier.Acceleration;
}
walkSpeed /= body.RequiredLegs;
sprintSpeed /= body.RequiredLegs;
walkSpeed = Math.Max(minspeed, walkSpeed / body.RequiredLegs);
sprintSpeed = Math.Max(minspeed, sprintSpeed / body.RequiredLegs);
// WWDP edit end
acceleration /= body.RequiredLegs;
Movement.ChangeBaseSpeed(bodyId, walkSpeed, sprintSpeed, acceleration, movement);
}

View File

@@ -17,6 +17,8 @@ using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Serialization;
using Content.Shared.Movement.Components;
using Content.Shared.Traits.Assorted.Components;
namespace Content.Shared.Standing;
@@ -159,6 +161,7 @@ public abstract class SharedLayingDownSystem : EntitySystem
|| !TryComp<BodyComponent>(uid, out var body)
|| body.LegEntities.Count < body.RequiredLegs
|| HasComp<DebrainedComponent>(uid)
|| HasComp<LegsParalyzedComponent>(uid) // WWDP
|| TryComp<MovementSpeedModifierComponent>(uid, out var movement) && movement.CurrentWalkSpeed == 0)
return false;

View File

@@ -20,13 +20,18 @@ public sealed class LegsParalyzedSystem : EntitySystem
SubscribeLocalEvent<Components.LegsParalyzedComponent, BuckledEvent>(OnBuckled);
SubscribeLocalEvent<Components.LegsParalyzedComponent, UnbuckledEvent>(OnUnbuckled);
SubscribeLocalEvent<Components.LegsParalyzedComponent, ThrowPushbackAttemptEvent>(OnThrowPushbackAttempt);
SubscribeLocalEvent<Components.LegsParalyzedComponent, UpdateCanMoveEvent>(OnUpdateCanMoveEvent);
//SubscribeLocalEvent<Components.LegsParalyzedComponent, UpdateCanMoveEvent>(OnUpdateCanMoveEvent); // WWDP
}
private void OnStartup(EntityUid uid, Components.LegsParalyzedComponent component, ComponentStartup args)
{
// TODO: In future probably must be surgery related wound
_movementSpeedModifierSystem.ChangeBaseSpeed(uid, 0, 0, 20);
// WWDP edit start
//_movementSpeedModifierSystem.ChangeBaseSpeed(uid, 0, 0, 20);
_standingSystem.Down(uid);
_bodySystem.UpdateMovementSpeed(uid);
// WWDP edit end
}
private void OnShutdown(EntityUid uid, Components.LegsParalyzedComponent component, ComponentShutdown args)
@@ -39,7 +44,8 @@ public sealed class LegsParalyzedSystem : EntitySystem
private void OnUnbuckled(EntityUid uid, Components.LegsParalyzedComponent component, ref UnbuckledEvent args) => _standingSystem.Down(uid);
private void OnUpdateCanMoveEvent(EntityUid uid, Components.LegsParalyzedComponent component, UpdateCanMoveEvent args) => args.Cancel();
// WWDP disabled since there is a minimal move speed
// private void OnUpdateCanMoveEvent(EntityUid uid, Components.LegsParalyzedComponent component, UpdateCanMoveEvent args) => args.Cancel();
private void OnThrowPushbackAttempt(EntityUid uid, Components.LegsParalyzedComponent component, ThrowPushbackAttemptEvent args) => args.Cancel();
}

View File

@@ -19,7 +19,7 @@
components:
- type: BuckleOnMapInit
prototype: VehicleWheelchair
# - type: LegsStartParalyzed # unnecessary if you just can't move at all
- type: TraitSpeedModifier # makes inability to walk unfixable
sprintModifier: 0.0
walkModifier: 0.0
- type: LegsParalyzed # WWDP - now works and is untreatable IC
# - type: TraitSpeedModifier # WWDP
# sprintModifier: 0.1
# walkModifier: 0.1