From 1ac801f9e2e565c3628f192dd7c37723880758e8 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Sat, 17 Dec 2022 16:59:23 -0600 Subject: [PATCH] Adds a Toggle Prone keybinding --- data/raw/keybindings.json | 6 ++++++ src/action.cpp | 7 +++++++ src/game.cpp | 1 + src/sdltiles.cpp | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/data/raw/keybindings.json b/data/raw/keybindings.json index a487e52571f55..fccfbe21e9823 100644 --- a/data/raw/keybindings.json +++ b/data/raw/keybindings.json @@ -2922,6 +2922,12 @@ "category": "DEFAULTMODE", "id": "toggle_crouch" }, + { + "type": "keybinding", + "name": "Toggle prone", + "category": "DEFAULTMODE", + "id": "toggle_prone" + }, { "type": "keybinding", "name": "Movement mode menu", diff --git a/src/action.cpp b/src/action.cpp index 27327a4e5ca37..2d070f2ef6b6d 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -169,6 +169,8 @@ std::string action_ident( action_id act ) return "toggle_run"; case ACTION_TOGGLE_CROUCH: return "toggle_crouch"; + case ACTION_TOGGLE_PRONE: + return "toggle_prone"; case ACTION_OPEN_MOVEMENT: return "open_movement"; case ACTION_OPEN: @@ -774,6 +776,10 @@ action_id handle_action_menu() if( player_character.is_crouching() ) { action_weightings[ACTION_TOGGLE_CROUCH] = 300; } + // If we're already prone, make it simple to toggle prone to off. + if( player_character.is_prone() ) { + action_weightings[ACTION_TOGGLE_PRONE] = 300; + } map &here = get_map(); // Check if we're on a vehicle, if so, vehicle controls should be top. @@ -936,6 +942,7 @@ action_id handle_action_menu() REGISTER_ACTION( ACTION_RESET_MOVE ); REGISTER_ACTION( ACTION_TOGGLE_RUN ); REGISTER_ACTION( ACTION_TOGGLE_CROUCH ); + REGISTER_ACTION( ACTION_TOGGLE_PRONE ); REGISTER_ACTION( ACTION_OPEN_MOVEMENT ); REGISTER_ACTION( ACTION_FIRE ); REGISTER_ACTION( ACTION_RELOAD_ITEM ); diff --git a/src/game.cpp b/src/game.cpp index f6ad31211616e..0d453538248ea 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2362,6 +2362,7 @@ input_context get_default_mode_input_context() ctxt.register_action( "reset_move" ); ctxt.register_action( "toggle_run" ); ctxt.register_action( "toggle_crouch" ); + ctxt.register_action( "toggle_prone" ); ctxt.register_action( "open_movement" ); ctxt.register_action( "open" ); ctxt.register_action( "close" ); diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 349d3dcb2e171..42136a0e3e1d2 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -2782,6 +2782,10 @@ static void CheckMessages() if( player_character.is_crouching() ) { actions.insert( ACTION_TOGGLE_CROUCH ); } + // If we're already prone, make it simple to toggle prone to off. + if( player_character.is_prone() ) { + actions.insert( ACTION_TOGGLE_PRONE ); + } // We're not already running or in combat, so remove cycle walk/run if( std::find( actions.begin(), actions.end(), ACTION_CYCLE_MOVE ) == actions.end() ) {