From ac2fc06e10b4a077f263b99b578b5dbad27c688f Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:30:47 -0700 Subject: [PATCH] Invert the Running/Walking States (#485) # Description Ports https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/pull/39 A change made to encourage people to [stop and smell the roses](https://www.urbandictionary.com/define.php?term=slow+down+and+smell+the+roses), instead of sprinting everywhere trying to get shit done. This goes well with #486, so people don't actually *have* to rush places to try to get things done before the shift ends fatally. It's weird anyway how we're all constantly sprinting everywhere and have to *very actively* choose not to (and why would you?). Increases the default speeds so that walking isn't painfully slow and sprinting feels more like sprinting in combination with the active choice to sprint. Someone needs to PR changing the default sprint or examine buttons, so people can fight and sprint with this change. (A lot of other default keybinds suck or conflict too and need to change) # Media Terrible video but whatever https://github.com/user-attachments/assets/5ff3863d-92c8-4df3-b76b-82874b5e1ae3 # Changelog :cl: - tweak: The station's crew hivemind has decided to slow down their movement and enjoy The Park instead of sprinting everywhere --------- Signed-off-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Co-authored-by: Pspritechologist <81725545+Pspritechologist@users.noreply.github.com> --- .../Tests/Slipping/SlippingTest.cs | 10 +++++++--- Content.Shared/CCVar/CCVars.cs | 7 +++++++ .../Movement/Components/CanWalkComponent.cs | 11 ----------- .../Movement/Components/InputMoverComponent.cs | 7 ++++++- .../Components/MovementSpeedModifierComponent.cs | 4 ++-- .../Movement/Systems/SharedMoverController.Input.cs | 2 +- .../Movement/Systems/SharedMoverController.cs | 8 +++----- .../Locale/en-US/escape-menu/ui/options-menu.ftl | 4 ++-- .../Entities/Mobs/Cyborgs/base_borg_chassis.yml | 1 - Resources/Prototypes/Entities/Mobs/NPCs/animals.yml | 1 - Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml | 1 - Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml | 1 - Resources/Prototypes/Entities/Mobs/NPCs/slimes.yml | 1 - Resources/Prototypes/Entities/Mobs/Species/base.yml | 1 - Resources/Prototypes/Entities/Mobs/Species/harpy.yml | 5 ++--- .../Entities/Objects/Specific/Mech/mechs.yml | 1 - 16 files changed, 30 insertions(+), 35 deletions(-) delete mode 100644 Content.Shared/Movement/Components/CanWalkComponent.cs diff --git a/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs b/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs index 7f77146f455..511a720ed07 100644 --- a/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs +++ b/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs @@ -1,11 +1,14 @@ #nullable enable using System.Collections.Generic; using Content.IntegrationTests.Tests.Interaction; +using Content.Shared.CCVar; using Content.Shared.Movement.Components; using Content.Shared.Slippery; using Content.Shared.Stunnable; +using Robust.Shared.Configuration; using Robust.Shared.GameObjects; using Robust.Shared.Input; +using Robust.Shared.IoC; using Robust.Shared.Maths; namespace Content.IntegrationTests.Tests.Slipping; @@ -14,6 +17,7 @@ public sealed class SlippingTest : MovementTest { public sealed class SlipTestSystem : EntitySystem { + [Dependency] public readonly IConfigurationManager Config = default!; public HashSet Slipped = new(); public override void Initialize() { @@ -30,6 +34,7 @@ private void OnSlip(EntityUid uid, SlipperyComponent component, ref SlipEvent ar public async Task BananaSlipTest() { var sys = SEntMan.System(); + var sprintWalks = sys.Config.GetCVar(CCVars.GamePressToSprint); await SpawnTarget("TrashBananaPeel"); var modifier = Comp(Player).SprintSpeedModifier; @@ -42,7 +47,7 @@ public async Task BananaSlipTest() #pragma warning restore NUnit2045 // Walking over the banana slowly does not trigger a slip. - await SetKey(EngineKeyFunctions.Walk, BoundKeyState.Down); + await SetKey(EngineKeyFunctions.Walk, sprintWalks ? BoundKeyState.Up : BoundKeyState.Down); await Move(DirectionFlag.East, 1f); #pragma warning disable NUnit2045 Assert.That(Delta(), Is.LessThan(0.5f)); @@ -51,10 +56,9 @@ public async Task BananaSlipTest() AssertComp(false, Player); // Moving at normal speeds does trigger a slip. - await SetKey(EngineKeyFunctions.Walk, BoundKeyState.Up); + await SetKey(EngineKeyFunctions.Walk, sprintWalks ? BoundKeyState.Down : BoundKeyState.Up); await Move(DirectionFlag.West, 1f); Assert.That(sys.Slipped, Does.Contain(SEntMan.GetEntity(Player))); AssertComp(true, Player); } } - diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 3c3bfa8862d..df463b27299 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -407,6 +407,13 @@ public static readonly CVarDef public static readonly CVarDef GameAutoEatDrinks = CVarDef.Create("game.auto_eat_drinks", false, CVar.REPLICATED); + + /// + /// When true, you have to press the change speed button to sprint. + /// + public static readonly CVarDef GamePressToSprint = + CVarDef.Create("game.press_to_sprint", true, CVar.REPLICATED); + #if EXCEPTION_TOLERANCE /// /// Amount of times round start must fail before the server is shut down. diff --git a/Content.Shared/Movement/Components/CanWalkComponent.cs b/Content.Shared/Movement/Components/CanWalkComponent.cs deleted file mode 100644 index fab851595c7..00000000000 --- a/Content.Shared/Movement/Components/CanWalkComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Robust.Shared.GameStates; - -namespace Content.Shared.Movement.Components; - -/// -/// Indicates if the entity can toggle walking or not. -/// -[NetworkedComponent, RegisterComponent] -public sealed partial class CanWalkComponent : Component -{ -} diff --git a/Content.Shared/Movement/Components/InputMoverComponent.cs b/Content.Shared/Movement/Components/InputMoverComponent.cs index 263190d46fd..916ecc90af1 100644 --- a/Content.Shared/Movement/Components/InputMoverComponent.cs +++ b/Content.Shared/Movement/Components/InputMoverComponent.cs @@ -1,6 +1,8 @@ using System.Numerics; using Content.Shared.Alert; +using Content.Shared.CCVar; using Content.Shared.Movement.Systems; +using Robust.Shared.Configuration; using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; @@ -72,7 +74,10 @@ public sealed partial class InputMoverComponent : Component public const float LerpTime = 1.0f; - public bool Sprinting => (HeldMoveButtons & MoveButtons.Walk) == 0x0; + //NOTE I don't think I'm supposed to do this + public bool Sprinting => IoCManager.Resolve().GetCVar(CCVars.GamePressToSprint) + ? (HeldMoveButtons & MoveButtons.Walk) != 0x0 + : (HeldMoveButtons & MoveButtons.Walk) == 0x0; [ViewVariables(VVAccess.ReadWrite)] public bool CanMove = true; diff --git a/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs b/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs index 813a18f974c..0f404f45b97 100644 --- a/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs +++ b/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs @@ -22,8 +22,8 @@ public sealed partial class MovementSpeedModifierComponent : Component public const float DefaultFriction = 20f; public const float DefaultFrictionNoInput = 20f; - public const float DefaultBaseWalkSpeed = 2.5f; - public const float DefaultBaseSprintSpeed = 4.5f; + public const float DefaultBaseWalkSpeed = 3f; + public const float DefaultBaseSprintSpeed = 5f; [AutoNetworkedField, ViewVariables] public float WalkSpeedModifier = 1.0f; diff --git a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs index 891bd518b1c..50cffa6ffea 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs @@ -620,7 +620,7 @@ public enum MoveButtons : byte Down = 2, Left = 4, Right = 8, - Walk = 16, + Walk = 16, // This may be either a sprint button or a walk button, depending on server config AnyDirection = Up | Down | Left | Right, } diff --git a/Content.Shared/Movement/Systems/SharedMoverController.cs b/Content.Shared/Movement/Systems/SharedMoverController.cs index 4c2c91db6a1..0944634db35 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.cs @@ -289,12 +289,10 @@ protected void HandleMobMovement( PhysicsSystem.SetAngularVelocity(physicsUid, 0, body: physicsComponent); } - public void WalkingAlert(EntityUid player, bool walking) + private void WalkingAlert(EntityUid player, bool walking) { - if (HasComp(player)) - { - _alerts.ShowAlert(player, AlertType.Walking, walking ? (short) 0 : (short) 1); - } + walking = _configManager.GetCVar(CCVars.GamePressToSprint) ? !walking : walking; + _alerts.ShowAlert(player, AlertType.Walking, walking ? (short) 0 : (short) 1); } public void LerpRotation(EntityUid uid, InputMoverComponent mover, float frameTime) diff --git a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl index 8c6cf575d54..7b25b616b24 100644 --- a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl +++ b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl @@ -112,13 +112,13 @@ ui-options-header-dev = Development ui-options-header-general = General ui-options-hotkey-keymap = Use US QWERTY Keys -ui-options-hotkey-toggle-walk = Toggle Walk +ui-options-hotkey-toggle-walk = Toggle Speed ui-options-function-move-up = Move Up ui-options-function-move-left = Move Left ui-options-function-move-down = Move Down ui-options-function-move-right = Move Right -ui-options-function-walk = Walk +ui-options-function-walk = Change Speed ui-options-function-camera-rotate-left = Rotate left ui-options-function-camera-rotate-right = Rotate right diff --git a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml index eba1253dde4..9ff9837a3b9 100644 --- a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml +++ b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml @@ -223,7 +223,6 @@ understands: - GalacticCommon - RobotTalk - - type: CanWalk - type: entity id: BaseBorgChassisNT diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index 92ede14d3ec..29234ea34cf 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -1313,7 +1313,6 @@ tags: - VimPilot - DoorBumpOpener - - type: CanWalk - type: entity name: monkey diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml b/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml index 2515c7880ac..c2380c40278 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml @@ -293,7 +293,6 @@ solution: bloodstream - type: DrainableSolution solution: bloodstream - - type: CanWalk - type: entity name: Reagent Slime Spawner diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml b/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml index e10bdbcf0ec..d1b3bd6a6a9 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml @@ -126,7 +126,6 @@ understands: - GalacticCommon - Mouse - - type: CanWalk - type: entity id: MobRatKingBuff diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/slimes.yml b/Resources/Prototypes/Entities/Mobs/NPCs/slimes.yml index 3735bcc4eca..fbf133a0f1e 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/slimes.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/slimes.yml @@ -128,7 +128,6 @@ speechSounds: Slime - type: TypingIndicator proto: slime - - type: CanWalk - type: entity name: blue slime diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index 1b9e9674f44..c4906f6f975 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -229,7 +229,6 @@ - CanPilot - FootstepSound - DoorBumpOpener - - type: CanWalk - type: entity save: false diff --git a/Resources/Prototypes/Entities/Mobs/Species/harpy.yml b/Resources/Prototypes/Entities/Mobs/Species/harpy.yml index b265d9343a3..05d70e8adc5 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/harpy.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/harpy.yml @@ -119,8 +119,8 @@ False: {visible: false} True: {visible: true} - type: MovementSpeedModifier - baseWalkSpeed: 2.5 - baseSprintSpeed: 5.0 + baseWalkSpeed: 3 + baseSprintSpeed: 5.5 weightlessAcceleration: 2.5 - type: Inventory speciesId: harpy @@ -140,7 +140,6 @@ understands: - GalacticCommon - SolCommon - - type: entity save: false name: Urist McHands diff --git a/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml b/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml index 471801f3a1f..6e5362d9bbb 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml @@ -92,7 +92,6 @@ - type: GuideHelp guides: - Robotics - - type: CanWalk - type: entity id: MechRipley