From 7c282037ba5b3d043f53590600ec295fa02bac98 Mon Sep 17 00:00:00 2001 From: oranges Date: Tue, 19 Dec 2017 10:32:21 +1300 Subject: [PATCH] Non movement keys pressed while moving no longer stop movement --- code/modules/keybindings/bindings_atom.dm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 code/modules/keybindings/bindings_atom.dm diff --git a/code/modules/keybindings/bindings_atom.dm b/code/modules/keybindings/bindings_atom.dm new file mode 100644 index 0000000000..9738175d2d --- /dev/null +++ b/code/modules/keybindings/bindings_atom.dm @@ -0,0 +1,18 @@ +// You might be wondering why this isn't client level. If focus is null, we don't want you to move. +// 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"]) + var/movement_dir = NONE + for(var/_key in user.keys_held) + movement_dir = movement_dir | GLOB.movement_keys[_key] + if(user.next_move_dir_add) + movement_dir |= user.next_move_dir_add + if(user.next_move_dir_sub) + movement_dir &= ~user.next_move_dir_sub + // Sanity checks in case you hold left and right and up to make sure you only go up + if((movement_dir & NORTH) && (movement_dir & SOUTH)) + movement_dir &= ~(NORTH|SOUTH) + if((movement_dir & EAST) && (movement_dir & WEST)) + movement_dir &= ~(EAST|WEST) + user.Move(get_step(src, movement_dir), movement_dir) \ No newline at end of file