Skip to content

Commit

Permalink
Fix issues about unwield bionic weapons.
Browse files Browse the repository at this point in the history
  • Loading branch information
wwkk222208 committed Mar 10, 2024
1 parent 0f9df4f commit 8b3b3f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7970,7 +7970,7 @@ bool Character::unwield()
// currently the only way to unwield NO_UNWIELD weapon is if it's a bionic that can be deactivated
if( weapon.has_flag( flag_NO_UNWIELD ) ) {
std::optional<bionic *> bio_opt = find_bionic_by_uid( get_weapon_bionic_uid() );
return bio_opt && can_deactivate_bionic( **bio_opt ).success();
return bio_opt ? deactivate_bionic( **bio_opt ) : false;
}

const std::string query = string_format( _( "Stop wielding %s?" ), weapon.tname() );
Expand Down
8 changes: 5 additions & 3 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2559,10 +2559,12 @@ std::optional<int> holster_actor::use( Character *you, item &it, const tripoint
if( pos >= 0 ) {
item_location weapon = you->get_wielded_item();
if( weapon && weapon.get_item()->has_flag( flag_NO_UNWIELD ) ) {
you->add_msg_if_player( m_bad, _( "You can't unwield your %s." ), weapon.get_item()->tname() );
return std::nullopt;
std::optional<bionic *> bio_opt = you->find_bionic_by_uid( you->get_weapon_bionic_uid() );
if( !bio_opt || !you->deactivate_bionic( **bio_opt ) ) {
you->add_msg_if_player( m_bad, _( "You can't unwield your %s." ), weapon.get_item()->tname() );
return std::nullopt;
}
}

// worn holsters ignore penalty effects (e.g. GRABBED) when determining number of moves to consume
if( you->is_worn( it ) ) {
you->wield_contents( it, internal_item, false, it.obtain_cost( *internal_item ) );
Expand Down

0 comments on commit 8b3b3f6

Please sign in to comment.