Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a Toggle Prone keybinding option #62766

Merged
merged 4 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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