Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] added preference to toggle run/walk on shift #2697

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code/modules/client/preference_setup/global/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
********************/
Expand Down
36 changes: 28 additions & 8 deletions code/modules/mob/mob_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down