Skip to content

Commit

Permalink
Merge pull request #27152 from mlangsdorf/npc_hearing
Browse files Browse the repository at this point in the history
NPC hearing
  • Loading branch information
kevingranade committed Dec 21, 2018
2 parents 4651d55 + fe3a4bd commit db52035
Show file tree
Hide file tree
Showing 33 changed files with 386 additions and 258 deletions.
22 changes: 22 additions & 0 deletions data/json/npcs/talk_tags.json
Expand Up @@ -707,6 +707,28 @@
"You're gonna rot in hell for this!"
]
},
{
"type": "snippet",
"category": "<combat_noise_warning>",
"text": [
"That sounds bad.",
"Be alert, something is up!",
"Did you hear that?",
"What's that noise?",
"Who's there?"
]
},
{
"type": "snippet",
"category": "<movement_noise_warning>",
"text": [
"I hear something moving - sounded like",
"What's that sound? I heard",
"Who's there? I heard",
"Did you hear that? Sounded like",
"Who is making that sound? I can hear the"
]
},
{
"type": "snippet",
"category": "<BGSS_intro_question>",
Expand Down
17 changes: 9 additions & 8 deletions src/activity_handlers.cpp
Expand Up @@ -171,7 +171,8 @@ void activity_handlers::burrow_do_turn( player_activity *act, player *p )
{
if( calendar::once_every( 1_minutes ) ) {
//~ Sound of a Rat mutant burrowing!
sounds::sound( act->placement, 10, _( "ScratchCrunchScrabbleScurry." ) );
sounds::sound( act->placement, 10, sounds::sound_t::movement,
_( "ScratchCrunchScrabbleScurry." ) );
messages_in_process( *act, *p );
}
}
Expand Down Expand Up @@ -1787,7 +1788,7 @@ void activity_handlers::pickaxe_do_turn( player_activity *act, player *p )
const tripoint &pos = act->placement;
if( calendar::once_every( 1_minutes ) ) { // each turn is too much
//~ Sound of a Pickaxe at work!
sounds::sound( pos, 30, _( "CHNK! CHNK! CHNK!" ) );
sounds::sound( pos, 30, sounds::sound_t::combat, _( "CHNK! CHNK! CHNK!" ) );
messages_in_process( *act, *p );
}
}
Expand Down Expand Up @@ -2180,7 +2181,7 @@ void activity_handlers::oxytorch_do_turn( player_activity *act, player *p )
act->values[0] -= int( charges_used );

if( calendar::once_every( 2_turns ) ) {
sounds::sound( act->placement, 10, _( "hissssssssss!" ) );
sounds::sound( act->placement, 10, sounds::sound_t::combat, _( "hissssssssss!" ) );
}
}

Expand Down Expand Up @@ -2753,7 +2754,7 @@ void activity_handlers::hacksaw_do_turn( player_activity *act, player *p )
{
if( calendar::once_every( 1_minutes ) ) {
//~ Sound of a metal sawing tool at work!
sounds::sound( act->placement, 15, _( "grnd grnd grnd" ) );
sounds::sound( act->placement, 15, sounds::sound_t::combat, _( "grnd grnd grnd" ) );
messages_in_process( *act, *p );
}
}
Expand Down Expand Up @@ -2818,7 +2819,7 @@ void activity_handlers::chop_tree_do_turn( player_activity *act, player *p )
{
if( calendar::once_every( 1_minutes ) ) {
//~ Sound of a wood chopping tool at work!
sounds::sound( act->placement, 15, _( "CHK!" ) );
sounds::sound( act->placement, 15, sounds::sound_t::combat, _( "CHK!" ) );
messages_in_process( *act, *p );
}
}
Expand Down Expand Up @@ -2879,7 +2880,7 @@ void activity_handlers::jackhammer_do_turn( player_activity *act, player *p )
{
if( calendar::once_every( 1_minutes ) ) {
//~ Sound of a jackhammer at work!
sounds::sound( act->placement, 15, _( "TATATATATATATAT!" ) );
sounds::sound( act->placement, 15, sounds::sound_t::combat, _( "TATATATATATATAT!" ) );
messages_in_process( *act, *p );
}
}
Expand All @@ -2902,7 +2903,7 @@ void activity_handlers::dig_do_turn( player_activity *act, player *p )
{
if( calendar::once_every( 1_minutes ) ) {
//~ Sound of a shovel digging a pit at work!
sounds::sound( act->placement, 10, _( "hsh!" ) );
sounds::sound( act->placement, 10, sounds::sound_t::combat, _( "hsh!" ) );
messages_in_process( *act, *p );
}
}
Expand All @@ -2929,7 +2930,7 @@ void activity_handlers::fill_pit_do_turn( player_activity *act, player *p )
{
if( calendar::once_every( 1_minutes ) ) {
//~ Sound of a shovel filling a pit or mound at work!
sounds::sound( act->placement, 10, _( "hsh!" ) );
sounds::sound( act->placement, 10, sounds::sound_t::combat, _( "hsh!" ) );
messages_in_process( *act, *p );
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ballistics.cpp
Expand Up @@ -44,7 +44,7 @@ static void drop_or_embed_projectile( const dealt_projectile_attack &attack )
}
// TODO: Non-glass breaking
// TODO: Wine glass breaking vs. entire sheet of glass breaking
sounds::sound( pt, 16, _( "glass breaking!" ) );
sounds::sound( pt, 16, sounds::sound_t::combat, _( "glass breaking!" ) );
return;
}

Expand Down Expand Up @@ -92,9 +92,9 @@ static void drop_or_embed_projectile( const dealt_projectile_attack &attack )

if( effects.count( "HEAVY_HIT" ) ) {
if( g->m.has_flag( "LIQUID", pt ) ) {
sounds::sound( pt, 10, _( "splash!" ) );
sounds::sound( pt, 10, sounds::sound_t::combat, _( "splash!" ) );
} else {
sounds::sound( pt, 8, _( "thud." ) );
sounds::sound( pt, 8, sounds::sound_t::combat, _( "thud." ) );
}
const trap &tr = g->m.tr_at( pt );
if( tr.triggered_by_item( dropped_item ) ) {
Expand Down
6 changes: 3 additions & 3 deletions src/bionics.cpp
Expand Up @@ -213,7 +213,7 @@ bool player::activate_bionic( int b, bool eff_only )
}
} else if( bio.id == "bio_resonator" ) {
//~Sound of a bionic sonic-resonator shaking the area
sounds::sound( pos(), 30, _( "VRRRRMP!" ) );
sounds::sound( pos(), 30, sounds::sound_t::combat, _( "VRRRRMP!" ) );
for( const tripoint &bashpoint : g->m.points_in_radius( pos(), 1 ) ) {
g->m.bash( bashpoint, 110 );
g->m.bash( bashpoint, 110 ); // Multibash effect, so that doors &c will fall
Expand Down Expand Up @@ -398,7 +398,7 @@ bool player::activate_bionic( int b, bool eff_only )
} else if( bio.id == "bio_hydraulics" ) {
add_msg( m_good, _( "Your muscles hiss as hydraulic strength fills them!" ) );
//~ Sound of hissing hydraulic muscle! (not quite as loud as a car horn)
sounds::sound( pos(), 19, _( "HISISSS!" ) );
sounds::sound( pos(), 19, sounds::sound_t::activity, _( "HISISSS!" ) );
} else if( bio.id == "bio_water_extractor" ) {
bool extracted = false;
for( auto it = g->m.i_at( pos() ).begin();
Expand Down Expand Up @@ -715,7 +715,7 @@ void player::process_bionic( int b )
}
} else if( bio.id == "bio_hydraulics" ) {
// Sound of hissing hydraulic muscle! (not quite as loud as a car horn)
sounds::sound( pos(), 19, _( "HISISSS!" ) );
sounds::sound( pos(), 19, sounds::sound_t::activity, _( "HISISSS!" ) );
} else if( bio.id == "bio_nanobots" ) {
for( int i = 0; i < num_hp_parts; i++ ) {
if( power_level >= 5 && hp_cur[i] > 0 && hp_cur[i] < hp_max[i] ) {
Expand Down
9 changes: 5 additions & 4 deletions src/computer.cpp
Expand Up @@ -387,7 +387,8 @@ void computer::activate_function( computer_action action )
//Toll is required for the church computer/mechanism to function
case COMPACT_TOLL:
//~ the sound of a church bell ringing
sounds::sound( g->u.pos(), 120, _( "Bohm... Bohm... Bohm..." ) );
sounds::sound( g->u.pos(), 120, sounds::sound_t::music,
_( "Bohm... Bohm... Bohm..." ) );
break;

case COMPACT_SAMPLE:
Expand Down Expand Up @@ -432,7 +433,7 @@ void computer::activate_function( computer_action action )
case COMPACT_RELEASE:
g->u.add_memorial_log( pgettext( "memorial_male", "Released subspace specimens." ),
pgettext( "memorial_female", "Released subspace specimens." ) );
sounds::sound( g->u.pos(), 40, _( "an alarm sound!" ) );
sounds::sound( g->u.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ) );
g->m.translate_radius( t_reinforced_glass, t_thconc_floor, 25.0, g->u.pos(), true );
query_any( _( "Containment shields opened. Press any key..." ) );
break;
Expand All @@ -442,7 +443,7 @@ void computer::activate_function( computer_action action )
remove_submap_turrets();
/* fallthrough */
case COMPACT_RELEASE_BIONICS:
sounds::sound( g->u.pos(), 40, _( "an alarm sound!" ) );
sounds::sound( g->u.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ) );
g->m.translate_radius( t_reinforced_glass, t_thconc_floor, 3.0, g->u.pos(), true );
query_any( _( "Containment shields opened. Press any key..." ) );
break;
Expand Down Expand Up @@ -1277,7 +1278,7 @@ void computer::activate_failure( computer_failure_type fail )
case COMPFAIL_ALARM:
g->u.add_memorial_log( pgettext( "memorial_male", "Set off an alarm." ),
pgettext( "memorial_female", "Set off an alarm." ) );
sounds::sound( g->u.pos(), 60, _( "an alarm sound!" ) );
sounds::sound( g->u.pos(), 60, sounds::sound_t::alarm, _( "an alarm sound!" ) );
if( g->get_levz() > 0 && !g->events.queued( EVENT_WANTED ) ) {
g->events.add( EVENT_WANTED, calendar::turn + 30_minutes, 0, g->u.global_sm_location() );
}
Expand Down
2 changes: 1 addition & 1 deletion src/event.cpp
Expand Up @@ -75,7 +75,7 @@ void event::actualize()
}
// You could drop the flag, you know.
if( g->u.has_amount( "petrified_eye", 1 ) ) {
sounds::sound( g->u.pos(), 60, "" );
sounds::sound( g->u.pos(), 60, sounds::sound_t::speech, _( "a tortured scream!" ) );
if( !g->u.is_deaf() ) {
add_msg( _( "The eye you're carrying lets out a tortured scream!" ) );
g->u.add_morale( MORALE_SCREAM, -15, 0, 30_minutes, 5_turns );
Expand Down
6 changes: 3 additions & 3 deletions src/explosion.cpp
Expand Up @@ -284,13 +284,13 @@ void game::explosion( const tripoint &p, const explosion_data &ex )
{
const int noise = ex.power * ( ex.fire ? 2 : 10 );
if( noise >= 30 ) {
sounds::sound( p, noise, _( "a huge explosion!" ) );
sounds::sound( p, noise, sounds::sound_t::combat, _( "a huge explosion!" ) );
sfx::play_variant_sound( "explosion", "huge", 100 );
} else if( noise >= 4 ) {
sounds::sound( p, noise, _( "an explosion!" ) );
sounds::sound( p, noise, sounds::sound_t::combat, _( "an explosion!" ) );
sfx::play_variant_sound( "explosion", "default", 100 );
} else if( noise > 0 ) {
sounds::sound( p, 3, _( "a loud pop!" ) );
sounds::sound( p, 3, sounds::sound_t::combat, _( "a loud pop!" ) );
sfx::play_variant_sound( "explosion", "small", 100 );
}

Expand Down
36 changes: 21 additions & 15 deletions src/game.cpp
Expand Up @@ -1529,6 +1529,13 @@ bool game::do_turn()

perhaps_add_random_npc();

// Process NPC sound events before they move or they hear themselves talking
for( npc &guy : all_npcs() ) {
if( rl_dist( guy.pos(), u.pos() ) < MAX_VIEW_DISTANCE ) {
sounds::process_sound_markers( &guy );
}
}

process_activity();

// Process sound events into sound markers for display to the player.
Expand Down Expand Up @@ -4787,7 +4794,7 @@ void game::flashbang( const tripoint &p, bool player_immune )
}
}
}
sounds::sound( p, 12, _( "a huge boom!" ) );
sounds::sound( p, 12, sounds::sound_t::combat, _( "a huge boom!" ) );
// TODO: Blind/deafen NPC
}

Expand All @@ -4796,7 +4803,7 @@ void game::shockwave( const tripoint &p, int radius, int force, int stun, int da
{
draw_explosion( p, radius, c_blue );

sounds::sound( p, force * force * dam_mult / 2, _( "Crack!" ) );
sounds::sound( p, force * force * dam_mult / 2, sounds::sound_t::combat, _( "Crack!" ) );

for( monster &critter : all_monsters() ) {
if( rl_dist( critter.pos(), p ) <= radius ) {
Expand Down Expand Up @@ -10656,24 +10663,21 @@ bool game::walk_move( const tripoint &dest_loc )
if( !u.has_artifact_with( AEP_STEALTH ) && !u.has_trait( trait_id( "DEBUG_SILENT" ) ) ) {
if( !u.has_trait( trait_id( "LEG_TENTACLES" ) ) && !u.has_trait( trait_id( "SMALL2" ) ) &&
!u.has_trait( trait_id( "SMALL_OK" ) ) ) {
int volume = 6;
if( u.has_trait( trait_id( "LIGHTSTEP" ) ) || u.is_wearing( "rm13_armor_on" ) ) {
sounds::sound( dest_loc, 2, "", true, "none",
"none" ); // Sound of footsteps may awaken nearby monsters
sfx::do_footstep();
volume = 2;
} else if( u.has_trait( trait_id( "CLUMSY" ) ) ) {
sounds::sound( dest_loc, 10, "", true, "none", "none" );
sfx::do_footstep();
volume = 10;
} else if( u.has_bionic( bionic_id( "bio_ankles" ) ) ) {
sounds::sound( dest_loc, 12, "", true, "none", "none" );
sfx::do_footstep();
} else {
sounds::sound( dest_loc, 6, "", true, "none" );
sfx::do_footstep();
volume = 12;
}
sounds::sound( dest_loc, volume, sounds::sound_t::movement, _( "footsteps" ), true,
"none", "none" ); // Sound of footsteps may awaken nearby monsters
sfx::do_footstep();
}

if( one_in( 20 ) && u.has_artifact_with( AEP_MOVEMENT_NOISE ) ) {
sounds::sound( u.pos(), 40, _( "You emit a rattling sound." ) );
sounds::sound( u.pos(), 40, sounds::sound_t::movement, _( "a rattling sound." ) );
}
}

Expand Down Expand Up @@ -11158,7 +11162,8 @@ bool game::grabbed_furn_move( const tripoint &dp )
}
}
}
sounds::sound( fdest, furntype.move_str_req * 2, _( "a scraping noise." ) );
sounds::sound( fdest, furntype.move_str_req * 2, sounds::sound_t::movement,
_( "a scraping noise." ) );

// Actually move the furniture
m.furn_set( fdest, m.furn( fpos ) );
Expand Down Expand Up @@ -12195,7 +12200,8 @@ void game::update_stair_monsters()

add_msg( m_warning, dump.str().c_str() );
} else {
sounds::sound( dest, 5, _( "a sound nearby from the stairs!" ) );
sounds::sound( dest, 5, sounds::sound_t::movement,
_( "a sound nearby from the stairs!" ) );
}

if( critter.staircount > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/grab.cpp
Expand Up @@ -88,7 +88,7 @@ bool game::grabbed_veh_move( const tripoint &dp )
str_req++;
//if vehicle has no wheels str_req make a noise.
if( str_req <= u.get_str() ) {
sounds::sound( grabbed_vehicle->global_pos3(), str_req * 2,
sounds::sound( grabbed_vehicle->global_pos3(), str_req * 2, sounds::sound_t::movement,
_( "a scraping noise." ) );
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/handle_action.cpp
Expand Up @@ -340,11 +340,12 @@ static void rcdrive( int dx, int dy )
tripoint dest( cx + dx, cy + dy, cz );
if( m.impassable( dest ) || !m.can_put_items_ter_furn( dest ) ||
m.has_furn( dest ) ) {
sounds::sound( dest, 7, _( "sound of a collision with an obstacle." ) );
sounds::sound( dest, 7, sounds::sound_t::combat,
_( "sound of a collision with an obstacle." ) );
return;
} else if( !m.add_item_or_charges( dest, *rc_car ).is_null() ) {
//~ Sound of moving a remote controlled car
sounds::sound( src, 6, _( "zzz..." ) );
sounds::sound( src, 6, sounds::sound_t::movement, _( "zzz..." ) );
u.moves -= 50;
m.i_rem( src, rc_car );
car_location_string.clear();
Expand Down Expand Up @@ -594,7 +595,7 @@ static void smash()

if( m.get_field( smashp, fd_web ) != nullptr ) {
m.remove_field( smashp, fd_web );
sounds::sound( smashp, 2, "" );
sounds::sound( smashp, 2, sounds::sound_t::combat, "hsh!" );
add_msg( m_info, _( "You brush aside some webs." ) );
u.moves -= 100;
return;
Expand Down Expand Up @@ -627,7 +628,7 @@ static void smash()
for( auto &elem : u.weapon.contents ) {
m.add_item_or_charges( u.pos(), elem );
}
sounds::sound( u.pos(), 24, "" );
sounds::sound( u.pos(), 24, sounds::sound_t::combat, "CRACK!" );
u.deal_damage( nullptr, bp_hand_r, damage_instance( DT_CUT, rng( 0, vol ) ) );
if( vol > 20 ) {
// Hurt left arm too, if it was big
Expand Down

0 comments on commit db52035

Please sign in to comment.