Skip to content

Commit

Permalink
Check for armor coverage
Browse files Browse the repository at this point in the history
Also fixed a bug when bees phase through solid matter
  • Loading branch information
Night-Pryanik committed Dec 5, 2019
1 parent d8f47ae commit e812b54
Showing 1 changed file with 16 additions and 41 deletions.
57 changes: 16 additions & 41 deletions src/map_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ bool map::process_fields_in_submap( submap *const current_submap,
// Bees chase the player if in range, wander randomly otherwise.
if( !g->u.is_underwater() &&
rl_dist( p, g->u.pos() ) < 10 &&
clear_path( p, g->u.pos(), 10, 0, 100 ) ) {
clear_path( p, g->u.pos(), 10, 1, 100 ) ) {

std::vector<point> candidate_positions =
squares_in_direction( p.xy(), point( g->u.posx(), g->u.posy() ) );
Expand Down Expand Up @@ -1602,47 +1602,22 @@ void map::player_in_field( player &u )
if( ft == fd_bees ) {
// Player is immune to bees while underwater.
if( !u.is_underwater() ) {
int times_stung = 0;
const int intensity = cur.get_field_intensity();
// If the bees can get at you, they cause steadily increasing pain.
// TODO: Specific stinging messages.
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
times_stung += one_in( 4 ) &&
u.add_env_effect( effect_stung, bp_torso, intensity, 9_minutes );
switch( times_stung ) {
case 0:
// Woo, unscathed!
break;
case 1:
u.add_msg_if_player( m_bad, _( "The bees sting you!" ) );
break;
case 2:
case 3:
u.add_msg_if_player( m_bad, _( "The bees sting you several times!" ) );
break;
case 4:
case 5:
u.add_msg_if_player( m_bad, _( "The bees sting you many times!" ) );
break;
case 6:
case 7:
case 8:
default:
u.add_msg_if_player( m_bad, _( "The bees sting you all over your body!" ) );
break;
// Bees will try to sting you in random body parts, up to 8 times.
for( int i = 0; i < rng( 1, 7 ); i++ ) {
body_part bp = random_body_part();
int sum_cover = 0;
for( const item &i : u.worn ) {
if( i.covers( bp ) ) {
sum_cover += i.get_coverage();
}
}
// Get stung if [clothing on a body part isn't thick enough (like t-shirt) OR clothing covers less than 100% of body part]
// AND clothing on affected body part has low environmental protection value
if( ( u.get_armor_cut( bp ) <= 1 || ( sum_cover < 100 && x_in_y( 100 - sum_cover, 100 ) ) ) &&
u.add_env_effect( effect_stung, bp, intensity, 9_minutes ) ) {
u.add_msg_if_player( m_bad, _( "The bees sting you in %s!" ), body_part_name_accusative( bp ) );
}
}
}
}
Expand Down

0 comments on commit e812b54

Please sign in to comment.