diff --git a/code/__DEFINES/keybinding.dm b/code/__DEFINES/keybinding.dm index e84b58f25b4..2343b980a81 100644 --- a/code/__DEFINES/keybinding.dm +++ b/code/__DEFINES/keybinding.dm @@ -65,6 +65,7 @@ #define COMSIG_KB_MOB_TARGETRIGHTLEG_DOWN "keybinding_mob_targetrightleg_down" #define COMSIG_KB_MOB_TARGETBODYGROIN_DOWN "keybinding_mob_targetbodygroin_down" #define COMSIG_KB_MOB_TARGETLEFTLEG_DOWN "keybinding_mob_targetleftleg_down" +#define COMSIG_KB_MOB_BLOCKMOVEMENT_DOWN "keybinding_mob_blockmovement_down" //Robot #define COMSIG_KB_SILICON_TOGGLEMODULEONE_DOWN "keybinding_silicon_togglemoduleone_down" diff --git a/code/datums/keybinding/mob.dm b/code/datums/keybinding/mob.dm index cbb9d9cfe01..6f1d39504cd 100644 --- a/code/datums/keybinding/mob.dm +++ b/code/datums/keybinding/mob.dm @@ -4,7 +4,7 @@ /datum/keybinding/mob/face_north - hotkey_keys = list("CtrlW", "CtrlNorth") + hotkey_keys = list("AltW", "AltNorth") name = "face_north" full_name = "Face North" description = "" @@ -20,7 +20,7 @@ /datum/keybinding/mob/face_east - hotkey_keys = list("CtrlD", "CtrlEast") + hotkey_keys = list("AltD", "AltEast") name = "face_east" full_name = "Face East" description = "" @@ -36,7 +36,7 @@ /datum/keybinding/mob/face_south - hotkey_keys = list("CtrlS", "CtrlSouth") + hotkey_keys = list("AltS", "AltSouth") name = "face_south" full_name = "Face South" description = "" @@ -51,7 +51,7 @@ return TRUE /datum/keybinding/mob/face_west - hotkey_keys = list("CtrlA", "CtrlWest") + hotkey_keys = list("AltA", "AltWest") name = "face_west" full_name = "Face West" description = "" @@ -165,7 +165,7 @@ return TRUE /datum/keybinding/mob/toggle_move_intent - hotkey_keys = list("Alt") + hotkey_keys = list("C") name = "toggle_move_intent" full_name = "Hold to toggle move intent" description = "Held down to cycle to the other move intent, release to cycle back" @@ -296,3 +296,22 @@ return user.body_l_leg() return TRUE + +/datum/keybinding/mob/prevent_movement + hotkey_keys = list("Alt") + name = "block_movement" + full_name = "Block movement" + description = "Prevents you from moving" + keybind_signal = COMSIG_KB_MOB_BLOCKMOVEMENT_DOWN + +/datum/keybinding/mob/prevent_movement/down(client/user) + . = ..() + if(.) + return + user.movement_locked = TRUE + +/datum/keybinding/mob/prevent_movement/up(client/user) + . = ..() + if(.) + return + user.movement_locked = FALSE diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 4aaed57a626..1f3aff51697 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -170,6 +170,8 @@ var/parallax_movedir = 0 var/parallax_layers_max = 4 var/parallax_animate_timer + ///Are we locking our movement input? + var/movement_locked = FALSE /** * Assoc list with all the active maps - when a screen obj is added to diff --git a/code/modules/keybindings/bindings_atom.dm b/code/modules/keybindings/bindings_atom.dm index 47d6b16feb5..789c852bcfd 100644 --- a/code/modules/keybindings/bindings_atom.dm +++ b/code/modules/keybindings/bindings_atom.dm @@ -2,7 +2,7 @@ // Only way to do that is to tie the behavior into the focus's keyLoop(). /atom/movable/keyLoop(client/user) - if(!user.keys_held["Ctrl"]) + if(!user.movement_locked) var/movement_dir = NONE for(var/_key in user.keys_held) movement_dir = movement_dir | user.movement_keys[_key] diff --git a/code/modules/keybindings/bindings_client.dm b/code/modules/keybindings/bindings_client.dm index 520d6d91b91..c31ae03317c 100644 --- a/code/modules/keybindings/bindings_client.dm +++ b/code/modules/keybindings/bindings_client.dm @@ -41,13 +41,13 @@ winset(src, null, "input.focus=true ; input.text=[url_encode(_key)]") return - //offset by 1 because the buffer address is 0 indexed because the math was simpler + //offset by 1 because the buffer address is 0 indexed because the math was simpler keys_held[current_key_address + 1] = _key //the time a key was pressed isn't actually used anywhere (as of 2019-9-10) but this allows easier access usage/checking keys_held[_key] = world.time current_key_address = ((current_key_address + 1) % HELD_KEY_BUFFER_LENGTH) var/movement = movement_keys[_key] - if(!(next_move_dir_sub & movement) && !keys_held["Ctrl"]) + if(!(next_move_dir_sub & movement) && !movement_locked) next_move_dir_add |= movement // Client-level keybindings are ones anyone should be able to do at any time