Skip to content

Commit

Permalink
Adds a Toggle Prone keybinding (#62766)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamayana authored Mar 10, 2023
1 parent e641724 commit 5f838a5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,12 @@
"category": "DEFAULTMODE",
"id": "toggle_crouch"
},
{
"type": "keybinding",
"name": "Toggle prone",
"category": "DEFAULTMODE",
"id": "toggle_prone"
},
{
"type": "keybinding",
"name": "Movement mode menu",
Expand Down
7 changes: 7 additions & 0 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -777,6 +779,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.
Expand Down Expand Up @@ -939,6 +945,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 );
Expand Down
1 change: 1 addition & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2345,6 +2345,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" );
Expand Down
4 changes: 4 additions & 0 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2793,6 +2793,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() ) {
Expand Down

0 comments on commit 5f838a5

Please sign in to comment.