Skip to content

Commit

Permalink
Bugfix: Show correct bodypart in grabs
Browse files Browse the repository at this point in the history
Updates the message `The fat zombie grabs your right arm` so that the bodypart
being used is the same bodypart that is used for the actual grab effect.
Before, there could be cases where the message displayed a different bodypart
than what was actually grabbed since `bp_id` might be changed by the call to
`target->block_hit` after `do_grab` had completed.
  • Loading branch information
inogenous committed Dec 17, 2023
1 parent a45a4fd commit 1bf0e4e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mattack_actors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ bool melee_actor::call( monster &z ) const

// We need to do some calculations in the main function - we might mutate bp_hit
// But first we need to handle exclusive grabs etc.
std::optional<bodypart_id> grabbed_bp_id;
if( is_grab ) {
int eff_grab_strength = grab_data.grab_strength == -1 ? z.get_grab_strength() :
grab_data.grab_strength;
Expand Down Expand Up @@ -831,6 +832,7 @@ bool melee_actor::call( monster &z ) const
} else if( result == 0 ) {
return true;
}
grabbed_bp_id = bp_id;
}

// Damage instance calculation
Expand Down Expand Up @@ -870,7 +872,7 @@ bool melee_actor::call( monster &z ) const
sfx::get_heard_angle( z.pos() ) );
target->add_msg_player_or_npc( msg_type, no_dmg_msg_u,
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? no_dmg_msg_npc : to_translation( "" ),
mon_name, body_part_name_accusative( bp_id ) );
mon_name, body_part_name_accusative( grabbed_bp_id.value_or( bp_id ) ) );
if( !effects_require_dmg ) {
for( const mon_effect_data &eff : effects ) {
if( x_in_y( eff.chance, 100 ) ) {
Expand Down

0 comments on commit 1bf0e4e

Please sign in to comment.