diff --git a/code/__DEFINES/dcs/signals/signals_atom/signals_atom_movement.dm b/code/__DEFINES/dcs/signals/signals_atom/signals_atom_movement.dm index 0c9523b9c20..25eb8b15f38 100644 --- a/code/__DEFINES/dcs/signals/signals_atom/signals_atom_movement.dm +++ b/code/__DEFINES/dcs/signals/signals_atom/signals_atom_movement.dm @@ -47,6 +47,11 @@ #define COMSIG_ATOM_DIR_CHANGE "atom_dir_change" ///from base of atom/setDir(): (old_dir, new_dir). Called after the direction changes. #define COMSIG_ATOM_POST_DIR_CHANGE "atom_dir_change" +///from base of atom/movable/keybind_face_direction(): (dir). Called before turning with the movement lock key. +#define COMSIG_MOVABLE_KEYBIND_FACE_DIR "keybind_face_dir" + ///ignores the movement lock key, used for turning while strafing in a mech + #define COMSIG_IGNORE_MOVEMENT_LOCK (1<<0) + /// from /datum/component/singularity/proc/can_move(), as well as /obj/energy_ball/proc/can_move() /// if a callback returns `SINGULARITY_TRY_MOVE_BLOCK`, then the singularity will not move to that turf #define COMSIG_ATOM_SINGULARITY_TRY_MOVE "atom_singularity_try_move" diff --git a/code/modules/keybindings/bindings_atom.dm b/code/modules/keybindings/bindings_atom.dm index e728ae4d8e2..6dadcd5768e 100644 --- a/code/modules/keybindings/bindings_atom.dm +++ b/code/modules/keybindings/bindings_atom.dm @@ -18,7 +18,8 @@ if(user && movement_dir) //If we're not moving, don't compensate, as byond will auto-fill dir otherwise movement_dir = turn(movement_dir, -dir2angle(user.dir)) //By doing this we ensure that our input direction is offset by the client (camera) direction - if(user?.movement_locked) + //turn without moving while using the movement lock key, unless something wants to ignore it and move anyway + if(user?.movement_locked && !(SEND_SIGNAL(src, COMSIG_MOVABLE_KEYBIND_FACE_DIR, movement_dir) & COMSIG_IGNORE_MOVEMENT_LOCK)) keybind_face_direction(movement_dir) else user?.Move(get_step(src, movement_dir), movement_dir) diff --git a/code/modules/vehicles/mecha/mecha_mob_interaction.dm b/code/modules/vehicles/mecha/mecha_mob_interaction.dm index 07b13a27ec0..0789216400c 100644 --- a/code/modules/vehicles/mecha/mecha_mob_interaction.dm +++ b/code/modules/vehicles/mecha/mecha_mob_interaction.dm @@ -158,12 +158,16 @@ /obj/vehicle/sealed/mecha/add_occupant(mob/M, control_flags) RegisterSignal(M, COMSIG_MOB_CLICKON, PROC_REF(on_mouseclick), TRUE) RegisterSignal(M, COMSIG_MOB_SAY, PROC_REF(display_speech_bubble), TRUE) + RegisterSignal(M, COMSIG_MOVABLE_KEYBIND_FACE_DIR, PROC_REF(on_turn), TRUE) . = ..() update_appearance() /obj/vehicle/sealed/mecha/remove_occupant(mob/M) - UnregisterSignal(M, COMSIG_MOB_CLICKON) - UnregisterSignal(M, COMSIG_MOB_SAY) + UnregisterSignal(M, list( + COMSIG_MOB_CLICKON, + COMSIG_MOB_SAY, + COMSIG_MOVABLE_KEYBIND_FACE_DIR, + )) M.clear_alert(ALERT_CHARGE) M.clear_alert(ALERT_MECH_DAMAGE) if(M.client) diff --git a/code/modules/vehicles/mecha/mecha_movement.dm b/code/modules/vehicles/mecha/mecha_movement.dm index e8c43ae48f9..766826e8f5a 100644 --- a/code/modules/vehicles/mecha/mecha_movement.dm +++ b/code/modules/vehicles/mecha/mecha_movement.dm @@ -49,6 +49,11 @@ return TRUE return FALSE +///Called when the driver turns with the movement lock key +/obj/vehicle/sealed/mecha/proc/on_turn(mob/living/driver, direction) + SIGNAL_HANDLER + return COMSIG_IGNORE_MOVEMENT_LOCK + /obj/vehicle/sealed/mecha/relaymove(mob/living/user, direction) . = TRUE if(!canmove || !(user in return_drivers())) @@ -121,11 +126,11 @@ break //if we're not facing the way we're going rotate us - if(dir != direction && !strafe || forcerotate || keyheld) + if(dir != direction && (!strafe || forcerotate || keyheld)) if(dir != direction && !(mecha_flags & QUIET_TURNS) && !step_silent) playsound(src,turnsound,40,TRUE) setDir(direction) - if(!pivot_step) //If we pivot step, we don't return here so we don't just come to a stop + if(keyheld || !pivot_step) //If we pivot step, we don't return here so we don't just come to a stop return TRUE set_glide_size(DELAY_TO_GLIDE_SIZE(movedelay))