Skip to content

Commit

Permalink
Prevent counterattacking with large/fragile items (#36704)
Browse files Browse the repository at this point in the history
Attempting to attack with very large items could lead to move
starvation, where the player would spend several turns doing nothing but
attacking.
Additionally, attacking with large items made of glass could break your
arms because the damage from breaking glass items is due to volume.

Prevent counter-attacking with items made of glass, because this can
break them, where the player may not want this to occur.

Prevent attacking with items than take more than 10 turns to attack
with, to prevent the move starvation bug.
  • Loading branch information
anothersimulacrum authored and kevingranade committed Jan 5, 2020
1 parent ada2433 commit 552ecbb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc
}
}
item &cur_weapon = allow_unarmed ? used_weapon() : weapon;

if( cur_weapon.attack_time() > attack_speed( cur_weapon ) * 20 ) {
add_msg( m_bad, _( "This weapon is too unwieldy to attack with!" ) );
return;
}

const bool critical_hit = scored_crit( t.dodge_roll(), cur_weapon );
int move_cost = attack_speed( cur_weapon );

Expand Down Expand Up @@ -1686,6 +1692,8 @@ bool player::block_hit( Creature *source, body_part &bp_hit, damage_instance &da
if( tec != tec_none && !is_dead_state() ) {
if( get_stamina() < get_stamina_max() / 3 ) {
add_msg( m_bad, _( "You try to counterattack but you are too exhausted!" ) );
} else if( weapon.made_of( material_id( "glass" ) ) ) {
add_msg( m_bad, _( "The item you are wielding is too fragile to counterattack with!" ) );
} else {
melee_attack( *source, false, tec );
}
Expand Down

0 comments on commit 552ecbb

Please sign in to comment.