From 9566e007669d5eacb1c844b2ea35022e0831176d Mon Sep 17 00:00:00 2001 From: Spookerton <918997+Spookerton@users.noreply.github.com> Date: Fri, 4 Oct 2024 01:25:36 +0000 Subject: [PATCH] [MIRROR] added preference to toggle run/walk on shift --- .../preference_setup/global/preferences.dm | 7 ++++ code/modules/mob/mob_movement.dm | 36 ++++++++++++++----- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/code/modules/client/preference_setup/global/preferences.dm b/code/modules/client/preference_setup/global/preferences.dm index 939c29b4cb6c9..d91a794f4eff9 100644 --- a/code/modules/client/preference_setup/global/preferences.dm +++ b/code/modules/client/preference_setup/global/preferences.dm @@ -338,6 +338,13 @@ var/global/list/_client_preferences_by_type default_value = GLOB.PREF_SHORT +/datum/client_preference/toggle_run + description = "Shift toggles run (vs hold to run)" + key = "TOGGLE_RUN" + options = list(GLOB.PREF_YES, GLOB.PREF_NO) + default_value = GLOB.PREF_NO + + /******************** * General Staff Preferences * ********************/ diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 7de3edeeac4e8..72ef605ecb7a7 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -360,27 +360,47 @@ to_chat(src, "You will now default to [default_run_intent] when moving quickly.") /client/verb/setmovingslowly() - set hidden = 1 - if(mob) + set hidden = TRUE + if (!mob) + return + if (mob.get_preference_value(/datum/client_preference/toggle_run) == GLOB.PREF_NO) mob.set_moving_slowly() + /mob/proc/set_moving_slowly() - if(!default_walk_intent) + if (!default_walk_intent) default_walk_intent = get_movement_datum_by_missing_flag(MOVE_INTENT_QUICK) - if(default_walk_intent && move_intent != default_walk_intent) + if (default_walk_intent && move_intent != default_walk_intent) set_move_intent(default_walk_intent) + /client/verb/setmovingquickly() - set hidden = 1 - if(mob) + set hidden = TRUE + if (!mob) + return + if (mob.get_preference_value(/datum/client_preference/toggle_run) == GLOB.PREF_NO) mob.set_moving_quickly() + else + mob.toggle_moving_quickly() + /mob/proc/set_moving_quickly() - if(!default_run_intent) + if (!default_run_intent) default_run_intent = get_movement_datum_by_flag(MOVE_INTENT_QUICK) - if(default_run_intent && move_intent != default_run_intent) + if (default_run_intent && move_intent != default_run_intent) set_move_intent(default_run_intent) + +/mob/proc/toggle_moving_quickly() + var/quick = get_movement_datum_by_flag(MOVE_INTENT_QUICK) + if (move_intent == quick) + var/slow = get_movement_datum_by_missing_flag(MOVE_INTENT_QUICK) + if (slow && move_intent != slow) + set_move_intent(slow) + else if (quick) + set_move_intent(quick) + + /mob/proc/can_sprint() return FALSE