Skip to content

Commit

Permalink
Merge pull request #34290 from BevapDin/guh
Browse files Browse the repository at this point in the history
Fixes quivers not consuming charges.
  • Loading branch information
ZhilkinSerg authored Sep 28, 2019
2 parents 31b43bf + e03f5d5 commit ecedcee
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,23 @@ bool avatar_action::fire( avatar &you, map &m )
// TODO: move handling "RELOAD_AND_SHOOT" flagged guns to a separate function.
if( gun->has_flag( "RELOAD_AND_SHOOT" ) ) {
if( !gun->ammo_remaining() ) {
item::reload_option opt =
you.ammo_location &&
gun->can_reload_with( you.ammo_location->typeId() ) ?
item::reload_option( &you, args.relevant, args.relevant, you.ammo_location ) :
you.select_ammo( *gun );
const auto ammo_location_is_valid = [&]() -> bool {
if( !you.ammo_location )
{
return false;
}
if( !gun->can_reload_with( you.ammo_location->typeId() ) )
{
return false;
}
if( square_dist( you.pos(), you.ammo_location.position() ) > 1 )
{
return false;
}
return true;
};
item::reload_option opt = ammo_location_is_valid() ? item::reload_option( &you, args.relevant,
args.relevant, you.ammo_location ) : you.select_ammo( *gun );
if( !opt ) {
// Menu canceled
return false;
Expand Down

0 comments on commit ecedcee

Please sign in to comment.