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

Prevent wielding items under certain conditions while driving #75955

Merged
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
10 changes: 10 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7777,6 +7777,16 @@ ret_val<void> Character::can_wield( const item &it ) const
mount->type->mech_weapon && it.typeId() != mount->type->mech_weapon ) {
return ret_val<void>::make_failure( _( "You cannot wield anything while piloting a mech." ) );
}
if( controlling_vehicle ) {
if( worn_with_flag( flag_RESTRICT_HANDS ) ) {
return ret_val<void>::make_failure(
_( "Something you are wearing hinders the use of both hands." ) );
}
if( !has_two_arms_lifting() || it.has_flag( flag_ALWAYS_TWOHAND ) ) {
return ret_val<void>::make_failure( _( "You can't wield your %s while driving." ),
it.tname() );
}
}

return ret_val<void>::make_success();
}
Expand Down
29 changes: 29 additions & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5537,6 +5537,35 @@ void game::control_vehicle()
if( !veh->handle_potential_theft( u ) ) {
return; // player not owner and refused to steal
}
const item_location weapon = u.get_wielded_item();
if( weapon ) {
if( u.worn_with_flag( flag_RESTRICT_HANDS ) ) {
add_msg( m_info, _( "Something you are wearing hinders the use of both hands." ) );
return;
}
if( !u.has_two_arms_lifting() ) {
if( query_yn(
_( "You can't drive because you have to wield a %s.\n\nPut it away?" ),
weapon->tname() ) ) {
if( !u.unwield() ) {
return;
}
} else {
return;
}
}
if( weapon->is_two_handed( u ) ) {
if( query_yn(
_( "You can't drive because you have to wield a %s with both hands.\n\nPut it away?" ),
weapon->tname() ) ) {
if( !u.unwield() ) {
return;
}
} else {
return;
}
}
}
if( veh->engine_on ) {
u.controlling_vehicle = true;
add_msg( _( "You take control of the %s." ), veh->name );
Expand Down
Loading