From ec31d710089c8240fa24eb4c7a4b543dfcc1ff18 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Mon, 17 Dec 2018 15:28:19 -0600 Subject: [PATCH 1/2] sounds: categorize and provide descriptions for all sounds Force all sounds to have descriptions and categories, and then tighten up the conditions for printing out a description of the sound. --- src/activity_handlers.cpp | 17 ++++--- src/ballistics.cpp | 6 +-- src/bionics.cpp | 6 +-- src/computer.cpp | 9 ++-- src/event.cpp | 2 +- src/explosion.cpp | 6 +-- src/game.cpp | 29 ++++++----- src/grab.cpp | 2 +- src/handle_action.cpp | 9 ++-- src/iexamine.cpp | 17 ++++--- src/iuse.cpp | 77 +++++++++++++++------------- src/iuse_actor.cpp | 23 +++++---- src/map.cpp | 72 ++++++++++++++++---------- src/mattack_actors.cpp | 10 +++- src/melee.cpp | 4 +- src/monattack.cpp | 86 +++++++++++++++++--------------- src/mondeath.cpp | 12 ++--- src/monster.cpp | 10 ++-- src/npc.cpp | 17 ++----- src/player.cpp | 14 +++--- src/player_hardcoded_effects.cpp | 4 +- src/ranged.cpp | 3 +- src/sounds.cpp | 61 ++++++++++++---------- src/sounds.h | 17 ++++++- src/speech.cpp | 2 +- src/trapfunc.cpp | 21 ++++---- src/vehicle.cpp | 4 +- src/vehicle_move.cpp | 8 +-- src/vehicle_use.cpp | 28 ++++++----- 29 files changed, 318 insertions(+), 258 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 7ce73c7e59ae3..018a2d3e9f55f 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -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 ); } } @@ -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 ); } } @@ -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!" ) ); } } @@ -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 ); } } @@ -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 ); } } @@ -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 ); } } @@ -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 ); } } @@ -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 ); } } diff --git a/src/ballistics.cpp b/src/ballistics.cpp index 1493d9e047a61..c84601f0c735d 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -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; } @@ -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 ) ) { diff --git a/src/bionics.cpp b/src/bionics.cpp index ec20aeac29f26..be823dc5cb3ab 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -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 @@ -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(); @@ -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] ) { diff --git a/src/computer.cpp b/src/computer.cpp index 14b88d5204d31..fa9328c60601e 100644 --- a/src/computer.cpp +++ b/src/computer.cpp @@ -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: @@ -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; @@ -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; @@ -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() ); } diff --git a/src/event.cpp b/src/event.cpp index d1a4baec2b847..8664f6889de88 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -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 ); diff --git a/src/explosion.cpp b/src/explosion.cpp index fdfab053c39f3..09c4365bbc231 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -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 ); } diff --git a/src/game.cpp b/src/game.cpp index 9b49b746639a1..aef4ee60224b2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4787,7 +4787,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 } @@ -4796,7 +4796,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 ) { @@ -10647,24 +10647,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." ) ); } } @@ -11149,7 +11146,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 ) ); @@ -12186,7 +12184,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 ) { diff --git a/src/grab.cpp b/src/grab.cpp index 871b26de35a08..effaf5fc91b42 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -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." ) ); } } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 235aab6aa7bb5..9ef3a2ff0edce 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -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(); @@ -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; @@ -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 diff --git a/src/iexamine.cpp b/src/iexamine.cpp index af37a1d94641f..61d91ee37edd3 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1055,7 +1055,7 @@ void iexamine::gunsafe_el(player &p, const tripoint &examp) case HACK_FAIL: p.add_memorial_log(pgettext("memorial_male", "Set off an alarm."), pgettext("memorial_female", "Set off an alarm.")); - sounds::sound(p.pos(), 60, _("an alarm sound!")); + sounds::sound(p.pos(), 60, sounds::sound_t::music, _("an alarm sound!")); if( examp.z > 0 && !g->events.queued( EVENT_WANTED ) ) { g->events.add( EVENT_WANTED, calendar::turn + 30_minutes, 0, p.global_sm_location() ); } @@ -1166,8 +1166,8 @@ void iexamine::pedestal_wyrm(player &p, const tripoint &examp) g->summon_mon(mon_dark_wyrm, monp); } } - add_msg(_("The pedestal sinks into the ground, with an ominous grinding noise...")); - sounds::sound(examp, 80, ("")); + add_msg( _( "The pedestal sinks into the ground..." ) ); + sounds::sound( examp, 80, sounds::sound_t::combat, _( "an ominous griding noise...") ); g->m.ter_set(examp, t_rock_floor); g->events.add( EVENT_SPAWN_WYRMS, calendar::turn + rng( 5_turns, 10_turns ) ); } @@ -2771,7 +2771,7 @@ void iexamine::recycle_compactor( player &, const tripoint &examp ) // produce outputs double recover_factor = rng( 6, 9 ) / 10.0; sum_weight = sum_weight * recover_factor; - sounds::sound( examp, 80, _( "Ka-klunk!" ) ); + sounds::sound( examp, 80, sounds::sound_t::combat, _( "Ka-klunk!" ) ); bool out_desired = false; bool out_any = false; for( auto it = m.compacts_into().begin() + o_idx; it != m.compacts_into().end(); ++it ) { @@ -3326,7 +3326,7 @@ void iexamine::pay_gas( player &p, const tripoint &examp ) return; } - sounds::sound( p.pos(), 6, _( "Glug Glug Glug" ) ); + sounds::sound( p.pos(), 6, sounds::sound_t::activity, _( "Glug Glug Glug" ) ); long cost = liters * pricePerUnit; money -= cost; @@ -3344,7 +3344,7 @@ void iexamine::pay_gas( player &p, const tripoint &examp ) case HACK_FAIL: p.add_memorial_log( pgettext( "memorial_male", "Set off an alarm." ), pgettext( "memorial_female", "Set off an alarm." ) ); - sounds::sound( p.pos(), 60, _( "an alarm sound!" ) ); + sounds::sound( p.pos(), 60, sounds::sound_t::music, _( "an alarm sound!" ) ); if( examp.z > 0 && !g->events.queued( EVENT_WANTED ) ) { g->events.add( EVENT_WANTED, calendar::turn + 30_minutes, 0, p.global_sm_location() ); } @@ -3356,7 +3356,8 @@ void iexamine::pay_gas( player &p, const tripoint &examp ) const cata::optional pGasPump = getGasPumpByNumber( examp, uistate.ags_pay_gas_selected_pump ); if( pGasPump && toPumpFuel( pTank, *pGasPump, tankGasUnits ) ) { add_msg( _( "You hack the terminal and route all available fuel to your pump!" ) ); - sounds::sound( p.pos(), 6, _( "Glug Glug Glug Glug Glug Glug Glug Glug Glug" ) ); + sounds::sound( p.pos(), 6, sounds::sound_t::activity, + _( "Glug Glug Glug Glug Glug Glug Glug Glug Glug" ) ); } else { add_msg( _( "Nothing happens." ) ); } @@ -3377,7 +3378,7 @@ void iexamine::pay_gas( player &p, const tripoint &examp ) const cata::optional pGasPump = getGasPumpByNumber( examp, uistate.ags_pay_gas_selected_pump ); long amount = pGasPump ? fromPumpFuel( pTank, *pGasPump ) : 0l; if( amount >= 0 ) { - sounds::sound( p.pos(), 6, _( "Glug Glug Glug" ) ); + sounds::sound( p.pos(), 6, sounds::sound_t::activity, _( "Glug Glug Glug" ) ); cashcard->charges += amount * pricePerUnit / 1000.0f; add_msg( m_info, _( "Your cash cards now hold %s." ), format_money( p.charges_of( "cash_card" ) ) ); p.moves -= 100; diff --git a/src/iuse.cpp b/src/iuse.cpp index c8586562e9abc..fe56ac0f32f27 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -2412,7 +2412,7 @@ int iuse::crowbar( player *p, item *it, bool, const tripoint &pos ) } if( noisy ) { - sounds::sound( pnt, 12, _( "crunch!" ) ); + sounds::sound( pnt, 12, sounds::sound_t::combat, _( "crunch!" ) ); } if( type == t_manhole_cover ) { g->m.spawn_item( pnt, "manhole_cover" ); @@ -2420,7 +2420,7 @@ int iuse::crowbar( player *p, item *it, bool, const tripoint &pos ) if( type == t_door_locked_alarm ) { p->add_memorial_log( pgettext( "memorial_male", "Set off an alarm." ), pgettext( "memorial_female", "Set off an alarm." ) ); - sounds::sound( p->pos(), 40, _( "an alarm sound!" ) ); + sounds::sound( p->pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ) ); if( !g->events.queued( EVENT_WANTED ) ) { g->events.add( EVENT_WANTED, calendar::turn + 30_minutes, 0, p->global_sm_location() ); } @@ -2434,7 +2434,7 @@ int iuse::crowbar( player *p, item *it, bool, const tripoint &pos ) if( dice( 4, difficulty ) > dice( 2, p->get_skill_level( skill_mechanics ) ) + dice( 2, p->str_cur ) ) { p->add_msg_if_player( m_mixed, _( "You break the glass." ) ); - sounds::sound( pnt, 24, _( "glass breaking!" ) ); + sounds::sound( pnt, 24, sounds::sound_t::combat, _( "glass breaking!" ) ); g->m.ter_set( pnt, t_window_frame ); g->m.spawn_item( pnt, "sheet", 2 ); g->m.spawn_item( pnt, "stick" ); @@ -2612,7 +2612,7 @@ int toolweapon_off( player &p, item &it, const bool fast_startup, sfx::play_ambient_variant_sound( "weapon_theme", "chainsaw", sfx::get_heard_volume( p.pos() ), 19, 3000 ); } - sounds::sound( p.pos(), volume, msg_success ); + sounds::sound( p.pos(), volume, sounds::sound_t::combat, msg_success ); it.convert( it.typeId().substr( 0, it.typeId().size() - 4 ) + "_on" ); // 4 is the length of "_off". it.active = true; } else { @@ -2889,7 +2889,10 @@ int iuse::geiger( player *p, item *it, bool t, const tripoint &pos ) if( rads == 0 ) { return it->type->charges_to_use(); } - sounds::sound( pos, 6, "" ); + std::string description = rads > 50 ? _( "buzzing" ) : + rads > 25 ? _( "rapid clicking" ) : _( "clicking" ); + + sounds::sound( pos, 6, sounds::sound_t::alarm, description ); if( !p->can_hear( pos, 6 ) ) { // can not hear it, but may have alarmed other creatures return it->type->charges_to_use(); @@ -3043,7 +3046,8 @@ int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) return 0; } if( t ) { // Simple timer effects - sounds::sound( pos, 0, _( "Merged!" ) ); // Vol 0 = only heard if you hold it + // Vol 0 = only heard if you hold it + sounds::sound( pos, 0, sounds::sound_t::speech, _( "Merged!" ) ); } else if( it->charges > 0 ) { add_msg( m_info, _( "You've already pulled the %s's pin, try throwing it instead." ), it->tname().c_str() ); @@ -3057,7 +3061,7 @@ int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) }; switch( effect_roll ) { case 1: - sounds::sound( pos, 100, _( "BUGFIXES!" ) ); + sounds::sound( pos, 100, sounds::sound_t::speech, _( "BUGFIXES!" ) ); g->draw_explosion( pos, explosion_radius, c_light_cyan ); for( const tripoint &dest : g->m.points_in_radius( pos, explosion_radius ) ) { monster *const mon = g->critter_at( dest, true ); @@ -3068,7 +3072,7 @@ int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) break; case 2: - sounds::sound( pos, 100, _( "BUFFS!" ) ); + sounds::sound( pos, 100, sounds::sound_t::speech, _( "BUFFS!" ) ); g->draw_explosion( pos, explosion_radius, c_green ); for( const tripoint &dest : g->m.points_in_radius( pos, explosion_radius ) ) { if( monster *const mon_ptr = g->critter_at( dest ) ) { @@ -3106,7 +3110,7 @@ int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) break; case 3: - sounds::sound( pos, 100, _( "NERFS!" ) ); + sounds::sound( pos, 100, sounds::sound_t::speech, _( "NERFS!" ) ); g->draw_explosion( pos, explosion_radius, c_red ); for( const tripoint &dest : g->m.points_in_radius( pos, explosion_radius ) ) { if( monster *const mon_ptr = g->critter_at( dest ) ) { @@ -3143,7 +3147,7 @@ int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) break; case 4: - sounds::sound( pos, 100, _( "REVERTS!" ) ); + sounds::sound( pos, 100, sounds::sound_t::speech, _( "REVERTS!" ) ); g->draw_explosion( pos, explosion_radius, c_pink ); for( const tripoint &dest : g->m.points_in_radius( pos, explosion_radius ) ) { if( monster *const mon_ptr = g->critter_at( dest ) ) { @@ -3160,7 +3164,7 @@ int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) } break; case 5: - sounds::sound( pos, 100, _( "BEES!" ) ); + sounds::sound( pos, 100, sounds::sound_t::speech, _( "BEES!" ) ); g->draw_explosion( pos, explosion_radius, c_yellow ); for( const tripoint &dest : g->m.points_in_radius( pos, explosion_radius ) ) { if( one_in( 5 ) && !g->critter_at( dest ) ) { @@ -3207,7 +3211,8 @@ int iuse::grenade_inc_act( player *p, item *it, bool t, const tripoint &pos ) } if( t ) { // Simple timer effects - sounds::sound( pos, 0, _( "Tick!" ) ); // Vol 0 = only heard if you hold it + // Vol 0 = only heard if you hold it + sounds::sound( pos, 0, sounds::sound_t::alarm, _( "Tick!" ) ); } else if( it->charges > 0 ) { p->add_msg_if_player( m_info, _( "You've already released the handle, try throwing it instead." ) ); return 0; @@ -3297,7 +3302,7 @@ int iuse::firecracker_pack_act( player *, item *it, bool, const tripoint &pos ) { time_duration timer = it->age(); if( timer < 2_turns ) { - sounds::sound( pos, 0, _( "ssss..." ) ); + sounds::sound( pos, 0, sounds::sound_t::alarm, _( "ssss..." ) ); it->inc_damage(); } else if( it->charges > 0 ) { int ex = rng( 4, 6 ); @@ -3306,7 +3311,7 @@ int iuse::firecracker_pack_act( player *, item *it, bool, const tripoint &pos ) ex = it->charges; } for( i = 0; i < ex; i++ ) { - sounds::sound( pos, 20, _( "Bang!" ) ); + sounds::sound( pos, 20, sounds::sound_t::combat, _( "Bang!" ) ); } it->charges -= ex; } @@ -3339,12 +3344,12 @@ int iuse::firecracker_act( player *, item *it, bool t, const tripoint &pos ) return 0; } if( t ) { // Simple timer effects - sounds::sound( pos, 0, _( "ssss..." ) ); + sounds::sound( pos, 0, sounds::sound_t::alarm, _( "ssss..." ) ); } else if( it->charges > 0 ) { add_msg( m_info, _( "You've already lit the %s, try throwing it instead." ), it->tname().c_str() ); return 0; } else { // When that timer runs down... - sounds::sound( pos, 20, _( "Bang!" ) ); + sounds::sound( pos, 20, sounds::sound_t::combat, _( "Bang!" ) ); } return 0; } @@ -4321,12 +4326,12 @@ int iuse::boltcutters( player *p, item *it, bool, const tripoint & ) if( g->m.ter( pnt ) == t_chaingate_l ) { p->moves -= 100; g->m.ter_set( pnt, t_chaingate_c ); - sounds::sound( pnt, 5, _( "Gachunk!" ) ); + sounds::sound( pnt, 5, sounds::sound_t::combat, _( "Gachunk!" ) ); g->m.spawn_item( p->posx(), p->posy(), "scrap", 3 ); } else if( g->m.ter( pnt ) == t_chainfence ) { p->moves -= 500; g->m.ter_set( pnt, t_chainfence_posts ); - sounds::sound( pnt, 5, _( "Snick, snick, gachunk!" ) ); + sounds::sound( pnt, 5, sounds::sound_t::combat, _( "Snick, snick, gachunk!" ) ); g->m.spawn_item( pnt, "wire", 20 ); } else { add_msg( m_info, _( "You can't cut that." ) ); @@ -4399,7 +4404,7 @@ int iuse::artifact( player *p, item *it, bool, const tripoint & ) switch( used ) { case AEA_STORM: { - sounds::sound( p->pos(), 10, _( "Ka-BOOM!" ) ); + sounds::sound( p->pos(), 10, sounds::sound_t::combat, _( "Ka-BOOM!" ) ); int num_bolts = rng( 2, 4 ); for( int j = 0; j < num_bolts; j++ ) { int xdir = 0; @@ -4487,7 +4492,7 @@ int iuse::artifact( player *p, item *it, bool, const tripoint & ) break; case AEA_PULSE: - sounds::sound( p->pos(), 30, _( "The earth shakes!" ) ); + sounds::sound( p->pos(), 30, sounds::sound_t::combat, _( "The earth shakes!" ) ); for( const tripoint &pt : g->m.points_in_radius( p->pos(), 2 ) ) { g->m.bash( pt, 40 ); g->m.bash( pt, 40 ); // Multibash effect, so that doors &c will fall @@ -4625,14 +4630,16 @@ int iuse::artifact( player *p, item *it, bool, const tripoint & ) break; case AEA_NOISE: - p->add_msg_if_player( m_bad, _( "Your %s emits a deafening boom!" ), it->tname().c_str() ); - sounds::sound( p->pos(), 100, "" ); + sounds::sound( p->pos(), 100, sounds::sound_t::combat, + string_format( _( "a deafening boom from %s %s" ), + p->disp_name( true ), it->tname() ) ); break; case AEA_SCREAM: - sounds::sound( p->pos(), 40, "" ); + sounds::sound( p->pos(), 40, sounds::sound_t::speech, + string_format( _( "a disturbing scream from %s %s" ), + p->disp_name( true ), it->tname() ) ); if( !p->is_deaf() ) { - p->add_msg_if_player( m_warning, _( "Your %s screams disturbingly." ), it->tname().c_str() ); p->add_morale( MORALE_SCREAM, -10, 0, 30_minutes, 5_turns ); } break; @@ -5137,21 +5144,21 @@ int iuse::gun_repair( player *p, item *it, bool, const tripoint & ) } /** @EFFECT_MECHANICS >=8 allows accurizing ranged weapons */ if( fix.damage() <= 0 ) { - sounds::sound( p->pos(), 6, "" ); + sounds::sound( p->pos(), 6, sounds::sound_t::activity, "crunch" ); p->moves -= 2000 * p->fine_detail_vision_mod(); p->practice( skill_mechanics, 10 ); p->add_msg_if_player( m_good, _( "You accurize your %s." ), fix.tname().c_str() ); fix.mod_damage( -itype::damage_scale ); } else if( fix.damage() > itype::damage_scale ) { - sounds::sound( p->pos(), 8, "" ); + sounds::sound( p->pos(), 8, sounds::sound_t::activity, "crunch" ); p->moves -= 1000 * p->fine_detail_vision_mod(); p->practice( skill_mechanics, 10 ); p->add_msg_if_player( m_good, _( "You repair your %s!" ), fix.tname().c_str() ); fix.mod_damage( -itype::damage_scale ); } else { - sounds::sound( p->pos(), 8, "" ); + sounds::sound( p->pos(), 8, sounds::sound_t::activity, "crunch" ); p->moves -= 500 * p->fine_detail_vision_mod(); p->practice( skill_mechanics, 10 ); p->add_msg_if_player( m_good, _( "You repair your %s completely!" ), @@ -5292,7 +5299,7 @@ int iuse::misc_repair( player *p, item *it, bool, const tripoint & ) int iuse::bell( player *p, item *it, bool, const tripoint & ) { if( it->typeId() == "cow_bell" ) { - sounds::sound( p->pos(), 12, _( "Clank! Clank!" ) ); + sounds::sound( p->pos(), 12, sounds::sound_t::music, _( "Clank! Clank!" ) ); if( !p->is_deaf() ) { const int cow_factor = 1 + ( p->mutation_category_level.find( "CATTLE" ) == p->mutation_category_level.end() ? @@ -5304,7 +5311,7 @@ int iuse::bell( player *p, item *it, bool, const tripoint & ) } } } else { - sounds::sound( p->pos(), 4, _( "Ring! Ring!" ) ); + sounds::sound( p->pos(), 4, sounds::sound_t::music, _( "Ring! Ring!" ) ); } return it->type->charges_to_use(); } @@ -6072,7 +6079,7 @@ int iuse::camera( player *p, item *it, bool, const tripoint & ) trajectory.push_back( aim_point ); p->moves -= 50; - sounds::sound( p->pos(), 8, _( "Click." ) ); + sounds::sound( p->pos(), 8, sounds::sound_t::activity, _( "Click." ) ); for( auto &i : trajectory ) { @@ -6360,7 +6367,7 @@ int iuse::ehandcuffs( player *p, item *it, bool t, const tripoint &pos ) if( it->charges == 0 ) { - sounds::sound( pos, 2, "Click." ); + sounds::sound( pos, 2, sounds::sound_t::combat, "Click." ); it->item_tags.erase( "NO_UNWIELD" ); it->active = false; @@ -6386,7 +6393,7 @@ int iuse::ehandcuffs( player *p, item *it, bool t, const tripoint &pos ) } if( calendar::once_every( 1_minutes ) ) { - sounds::sound( pos, 10, _( "a police siren, whoop WHOOP." ) ); + sounds::sound( pos, 10, sounds::sound_t::alarm, _( "a police siren, whoop WHOOP." ) ); } const int x = it->get_var( "HANDCUFFS_X", 0 ); @@ -6514,7 +6521,7 @@ int iuse::radiocaron( player *p, item *it, bool t, const tripoint &pos ) { if( t ) { //~Sound of a radio controlled car moving around - sounds::sound( pos, 6, _( "buzzz..." ) ); + sounds::sound( pos, 6, sounds::sound_t::movement, _( "buzzz..." ) ); return it->type->charges_to_use(); } else if( !it->ammo_sufficient() ) { @@ -6547,7 +6554,7 @@ void sendRadioSignal( player &p, const std::string &signal ) item &it = p.inv.find_item( i ); if( it.has_flag( "RADIO_ACTIVATION" ) && it.has_flag( signal ) ) { - sounds::sound( p.pos(), 6, _( "beep." ) ); + sounds::sound( p.pos(), 6, sounds::sound_t::alarm, _( "beep." ) ); if( it.has_flag( "RADIO_INVOKE_PROC" ) ) { // Invoke twice: first to transform, then later to proc @@ -6911,7 +6918,7 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) it->erase_var( "COOKTIME" ); //~ sound of a multi-cooker finishing its cycle! - sounds::sound( pos, 8, _( "ding!" ) ); + sounds::sound( pos, 8, sounds::sound_t::alarm, _( "ding!" ) ); return 0; } else { diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 260835a44097d..8dff62ea7b1a7 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -336,7 +336,8 @@ long explosion_iuse::use( player &p, item &it, bool t, const tripoint &pos ) con { if( t ) { if( sound_volume >= 0 ) { - sounds::sound( pos, sound_volume, sound_msg.empty() ? "" : _( sound_msg.c_str() ) ); + sounds::sound( pos, sound_volume, sounds::sound_t::alarm, + sound_msg.empty() ? _( "Tick." ) : _( sound_msg.c_str() ) ); } return 0; } @@ -898,7 +899,7 @@ long pick_lock_actor::use( player &p, item &it, bool, const tripoint & ) const p.add_msg_if_player( m_bad, _( "The lock stumps your efforts to pick it." ) ); } if( type == t_door_locked_alarm && ( door_roll + dice( 1, 30 ) ) > pick_roll ) { - sounds::sound( p.pos(), 40, _( "an alarm sound!" ) ); + sounds::sound( p.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ) ); if( !g->events.queued( EVENT_WANTED ) ) { g->events.add( EVENT_WANTED, calendar::turn + 30_minutes, 0, p.global_sm_location() ); } @@ -1765,9 +1766,9 @@ ret_val enzlave_actor::can_use( const player &p, const item &, bool, const void fireweapon_off_actor::load( JsonObject &obj ) { target_id = obj.get_string( "target_id" ); - success_message = obj.get_string( "success_message" ); + success_message = obj.get_string( "success_message", "hsss" ); lacks_fuel_message = obj.get_string( "lacks_fuel_message" ); - failure_message = obj.get_string( "failure_message", "" ); + failure_message = obj.get_string( "failure_message", "hsss" ); noise = obj.get_int( "noise", 0 ); moves = obj.get_int( "moves", 0 ); success_chance = obj.get_int( "success_chance", INT_MIN ); @@ -1792,7 +1793,7 @@ long fireweapon_off_actor::use( player &p, item &it, bool t, const tripoint & ) p.moves -= moves; if( rng( 0, 10 ) - it.damage_level( 4 ) > success_chance && !p.is_underwater() ) { if( noise > 0 ) { - sounds::sound( p.pos(), noise, _( success_message.c_str() ) ); + sounds::sound( p.pos(), noise, sounds::sound_t::combat, _( success_message.c_str() ) ); } else { p.add_msg_if_player( _( success_message.c_str() ) ); } @@ -1822,7 +1823,7 @@ ret_val fireweapon_off_actor::can_use( const player &p, const item &it, bo void fireweapon_on_actor::load( JsonObject &obj ) { - noise_message = obj.get_string( "noise_message" ); + noise_message = obj.get_string( "noise_message", "hsss" ); voluntary_extinguish_message = obj.get_string( "voluntary_extinguish_message" ); charges_extinguish_message = obj.get_string( "charges_extinguish_message" ); water_extinguish_message = obj.get_string( "water_extinguish_message" ); @@ -1859,7 +1860,7 @@ long fireweapon_on_actor::use( player &p, item &it, bool t, const tripoint & ) c } else if( one_in( noise_chance ) ) { if( noise > 0 ) { - sounds::sound( p.pos(), noise, _( noise_message.c_str() ) ); + sounds::sound( p.pos(), noise, sounds::sound_t::combat, _( noise_message.c_str() ) ); } else { p.add_msg_if_player( _( noise_message.c_str() ) ); } @@ -1872,7 +1873,7 @@ void manualnoise_actor::load( JsonObject &obj ) { no_charges_message = obj.get_string( "no_charges_message" ); use_message = obj.get_string( "use_message" ); - noise_message = obj.get_string( "noise_message", "" ); + noise_message = obj.get_string( "noise_message", "hsss" ); noise = obj.get_int( "noise", 0 ); moves = obj.get_int( "moves", 0 ); } @@ -1894,7 +1895,8 @@ long manualnoise_actor::use( player &p, item &it, bool t, const tripoint & ) con { p.moves -= moves; if( noise > 0 ) { - sounds::sound( p.pos(), noise, noise_message.empty() ? "" : _( noise_message.c_str() ) ); + sounds::sound( p.pos(), noise, sounds::sound_t::activity, + noise_message.empty() ? _( "Hsss" ) : _( noise_message.c_str() ) ); } p.add_msg_if_player( _( use_message.c_str() ) ); } @@ -3800,7 +3802,8 @@ long mutagen_iv_actor::use( player &p, item &it, bool, const tripoint & ) const if( p.is_player() && !( p.has_trait( trait_NOPAIN ) ) && m_category.iv_sound ) { p.mod_pain( m_category.iv_pain ); /** @EFFECT_STR increases volume of painful shouting when using IV mutagen */ - sounds::sound( p.pos(), m_category.iv_noise + p.str_cur, m_category.iv_sound_message() ); + sounds::sound( p.pos(), m_category.iv_noise + p.str_cur, sounds::sound_t::speech, + m_category.iv_sound_message() ); } int mut_count = m_category.iv_min_mutations; diff --git a/src/map.cpp b/src/map.cpp index 224928c2cfd09..1125b6d67113a 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -501,7 +501,8 @@ void map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &facing coll_turn = shake_vehicle( veh, velocity_before, facing.dir() ); const int volume = std::min( 100, sqrtf( impulse ) ); // TODO: Center the sound at weighted (by impulse) average of collisions - sounds::sound( veh.global_pos3(), volume, _( "crash!" ), false, "smash_success", "hit_vehicle" ); + sounds::sound( veh.global_pos3(), volume, sounds::sound_t::combat, _( "crash!" ), + false, "smash_success", "hit_vehicle" ); } if( veh_veh_coll_flag ) { @@ -526,7 +527,8 @@ void map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &facing for( auto &w : wheel_indices ) { const tripoint wheel_p = veh.global_part_pos3( w ); if( one_in( 2 ) && displace_water( wheel_p ) ) { - sounds::sound( wheel_p, 4, _( "splash!" ), false, "environment", "splash" ); + sounds::sound( wheel_p, 4, sounds::sound_t::movement, _( "splash!" ), false, + "environment", "splash" ); } veh.handle_trap( wheel_p, w ); @@ -2896,7 +2898,8 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) // TODO: what if silent is true? if( has_flag( "ALARMED", p ) && !g->events.queued( EVENT_WANTED ) ) { - sounds::sound( p, 40, _( "an alarm go off!" ), false, "environment", "alarm" ); + sounds::sound( p, 40, sounds::sound_t::alarm, _( "an alarm go off!" ), + false, "environment", "alarm" ); // Blame nearby player if( rl_dist( g->u.pos(), p ) <= 3 ) { g->u.add_memorial_log( pgettext( "memorial_male", "Set off an alarm." ), @@ -2910,7 +2913,8 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) // Nothing bashable here if( impassable( p ) ) { if( !params.silent ) { - sounds::sound( p, 18, _( "thump!" ), false, "smash_thump", "smash_success" ); + sounds::sound( p, 18, sounds::sound_t::combat, _( "thump!" ), + false, "smash_thump", "smash_success" ); } params.did_bash = true; @@ -2967,10 +2971,11 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) sound_volume = sound_fail_vol; } - sound = _( bash->sound_fail.c_str() ); + sound = bash->sound_fail.empty() ? _( "Thnk!" ) : _( bash->sound_fail.c_str() ); params.did_bash = true; if( !params.silent ) { - sounds::sound( p, sound_volume, sound, false, "smash_fail", soundfxvariant ); + sounds::sound( p, sound_volume, sounds::sound_t::combat, sound, false, + "smash_fail", soundfxvariant ); } return; @@ -3129,7 +3134,8 @@ void map::bash_ter_furn( const tripoint &p, bash_params ¶ms ) params.success |= success; // Not always true, so that we can tell when to stop destroying params.bashed_solid = true; if( !sound.empty() && !params.silent ) { - sounds::sound( p, sound_volume, sound, false, soundfxid, soundfxvariant ); + sounds::sound( p, sound_volume, sounds::sound_t::combat, sound, false, + soundfxid, soundfxvariant ); } } @@ -3187,7 +3193,8 @@ void map::bash_items( const tripoint &p, bash_params ¶ms ) // Add a glass sound even when something else also breaks if( smashed_glass && !params.silent ) { - sounds::sound( p, 12, _( "glass shattering" ), false, "smash_success", "smash_glass_contents" ); + sounds::sound( p, 12, sounds::sound_t::combat, _( "glass shattering" ), false, + "smash_success", "smash_glass_contents" ); } } @@ -3197,7 +3204,8 @@ void map::bash_vehicle( const tripoint &p, bash_params ¶ms ) if( const optional_vpart_position vp = veh_at( p ) ) { vp->vehicle().damage( vp->part_index(), params.strength, DT_BASH ); if( !params.silent ) { - sounds::sound( p, 18, _( "crash!" ), false, "smash_success", "hit_vehicle" ); + sounds::sound( p, 18, sounds::sound_t::combat, _( "crash!" ), false, + "smash_success", "hit_vehicle" ); } params.did_bash = true; @@ -3300,7 +3308,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) const auto &ammo_effects = proj.proj_effects; if( has_flag( "ALARMED", p ) && !g->events.queued( EVENT_WANTED ) ) { - sounds::sound( p, 30, _( "an alarm sound!" ) ); + sounds::sound( p, 30, sounds::sound_t::alarm, _( "an alarm sound!" ) ); const tripoint abs = ms_to_sm_copy( getabs( p ) ); g->events.add( EVENT_WANTED, calendar::turn + 30_minutes, 0, abs ); } @@ -3309,6 +3317,10 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) if( const optional_vpart_position vp = veh_at( p ) ) { dam = vp->vehicle().damage( vp->part_index(), dam, inc ? DT_HEAT : DT_STAB, hit_items ); } + const auto break_glass = []( const tripoint & p, int vol ) { + sounds::sound( p, vol, sounds::sound_t::combat, _( "glass breaking!" ), false, + "smash", "glass" ); + }; ter_id terrain = ter( p ); if( terrain == t_wall_wood_broken || @@ -3317,7 +3329,8 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) if( hit_items || one_in( 8 ) ) { // 1 in 8 chance of hitting the door dam -= rng( 20, 40 ); if( dam > 0 ) { - sounds::sound( p, 10, _( "crash!" ), false, "smash", "wall" ); + sounds::sound( p, 10, sounds::sound_t::combat, _( "crash!" ), false, + "smash", "wall" ); ter_set( p, t_dirt ); } } else { @@ -3329,7 +3342,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) terrain == t_door_locked_alarm ) { dam -= rng( 15, 30 ); if( dam > 0 ) { - sounds::sound( p, 10, _( "smash!" ), false, "smash", "door" ); + sounds::sound( p, 10, sounds::sound_t::combat, _( "smash!" ), false, "smash", "door" ); ter_set( p, t_door_b ); } } else if( terrain == t_door_boarded || @@ -3338,7 +3351,8 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) terrain == t_rdoor_boarded_damaged ) { dam -= rng( 15, 35 ); if( dam > 0 ) { - sounds::sound( p, 10, _( "crash!" ), false, "smash", "door_boarded" ); + sounds::sound( p, 10, sounds::sound_t::combat, _( "crash!" ), false, + "smash", "door_boarded" ); ter_set( p, t_door_b ); } } else if( terrain == t_window_domestic_taped || @@ -3353,7 +3367,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) } else { dam -= rng( 1, 3 ); if( dam > 0 ) { - sounds::sound( p, 16, _( "glass breaking!" ), false, "smash", "glass" ); + break_glass( p, 16 ); ter_set( p, t_window_frame ); spawn_item( p, "sheet", 1 ); spawn_item( p, "stick" ); @@ -3376,21 +3390,21 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) } else { dam -= rng( 1, 3 ); if( dam > 0 ) { - sounds::sound( p, 16, _( "glass breaking!" ), false, "smash", "glass" ); + break_glass( p, 16 ); ter_set( p, t_window_frame ); } } } else if( terrain == t_window_bars_alarm ) { dam -= rng( 1, 3 ); if( dam > 0 ) { - sounds::sound( p, 16, _( "glass breaking!" ), false, "smash", "glass" ); + break_glass( p, 16 ); ter_set( p, t_window_bars ); spawn_item( p, "glass_shard", 5 ); } } else if( terrain == t_window_boarded ) { dam -= rng( 10, 30 ); if( dam > 0 ) { - sounds::sound( p, 16, _( "glass breaking!" ), false, "smash", "glass" ); + break_glass( p, 16 ); ter_set( p, t_window_frame ); } } else if( terrain == t_wall_glass || @@ -3401,7 +3415,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) } else { dam -= rng( 1, 8 ); if( dam > 0 ) { - sounds::sound( p, 16, _( "glass breaking!" ), false, "smash", "glass" ); + break_glass( p, 16 ); ter_set( p, t_floor ); } } @@ -3422,14 +3436,14 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) } else if( dam >= 40 ) { //high powered bullets penetrate the glass, but only extremely strong // ones (80 before reduction) actually destroy the glass itself. - sounds::sound( p, 16, _( "glass breaking!" ), false, "smash", "glass" ); + break_glass( p, 16 ); ter_set( p, t_floor ); } } } else if( terrain == t_paper ) { dam -= rng( 4, 16 ); if( dam > 0 ) { - sounds::sound( p, 8, _( "rrrrip!" ) ); + sounds::sound( p, 8, sounds::sound_t::combat, _( "rrrrip!" ) ); ter_set( p, t_dirt ); } if( inc ) { @@ -3450,7 +3464,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) } } - sounds::sound( p, 10, _( "smash!" ) ); + sounds::sound( p, 10, sounds::sound_t::combat, _( "smash!" ) ); } ter_set( p, t_gas_pump_smashed ); } @@ -3458,7 +3472,7 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items ) } } else if( terrain == t_vat ) { if( dam >= 10 ) { - sounds::sound( p, 20, _( "ke-rash!" ) ); + sounds::sound( p, 20, sounds::sound_t::combat, _( "ke-rash!" ) ); ter_set( p, t_floor ); } else { dam = 0; @@ -3587,7 +3601,8 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only } if( !check_only ) { - sounds::sound( p, 6, "", true, "open_door", ter.id.str() ); + sounds::sound( p, 6, sounds::sound_t::movement, _( "swish" ), true, + "open_door", ter.id.str() ); ter_set( p, ter.open ); if( ( g->u.has_trait( trait_id( "SCHIZOPHRENIC" ) ) || g->u.has_artifact_with( AEP_SCHIZO ) ) @@ -3604,7 +3619,8 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only } if( !check_only ) { - sounds::sound( p, 6, "", true, "open_door", furn.id.str() ); + sounds::sound( p, 6, sounds::sound_t::movement, _( "swish" ), true, + "open_door", furn.id.str() ); furn_set( p, furn.open ); } @@ -3686,13 +3702,15 @@ bool map::close_door( const tripoint &p, const bool inside, const bool check_onl const auto &furn = this->furn( p ).obj(); if( ter.close && !furn.id ) { if( !check_only ) { - sounds::sound( p, 10, "", true, "close_door", ter.id.str() ); + sounds::sound( p, 10, sounds::sound_t::movement, _( "swish" ), true, + "close_door", ter.id.str() ); ter_set( p, ter.close ); } return true; } else if( furn.close ) { if( !check_only ) { - sounds::sound( p, 10, "", true, "close_door", furn.id.str() ); + sounds::sound( p, 10, sounds::sound_t::movement, _( "swish" ), true, + "close_door", furn.id.str() ); furn_set( p, furn.close ); } return true; @@ -4885,7 +4903,7 @@ static bool trigger_radio_item( item_stack &items, std::list::iterator &n, { bool trigger_item = false; if( n->has_flag( "RADIO_ACTIVATION" ) && n->has_flag( signal ) ) { - sounds::sound( pos, 6, _( "beep." ) ); + sounds::sound( pos, 6, sounds::sound_t::alarm, _( "beep." ) ); if( n->has_flag( "RADIO_INVOKE_PROC" ) ) { // Invoke twice: first to transform, then later to proc // Can't use process_item here - invalidates our iterator diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index aaf0aceae4fd6..7bd829669b736 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -358,6 +358,8 @@ void gun_actor::load_internal( JsonObject &obj, const std::string & ) } if( obj.read( "no_ammo_sound", no_ammo_sound ) ) { no_ammo_sound = _( no_ammo_sound.c_str() ); + } else { + no_ammo_sound = _( "Click." ); } obj.read( "targeting_cost", targeting_cost ); @@ -371,7 +373,10 @@ void gun_actor::load_internal( JsonObject &obj, const std::string & ) if( obj.read( "targeting_sound", targeting_sound ) ) { targeting_sound = _( targeting_sound.c_str() ); + } else { + targeting_sound = _( "Beep." ); } + obj.read( "targeting_volume", targeting_volume ); obj.get_bool( "laser_lock", laser_lock ); @@ -441,7 +446,8 @@ void gun_actor::shoot( monster &z, Creature &target, const gun_mode_id &mode ) c if( not_targeted || not_laser_locked ) { if( targeting_volume > 0 && !targeting_sound.empty() ) { - sounds::sound( z.pos(), targeting_volume, _( targeting_sound.c_str() ) ); + sounds::sound( z.pos(), targeting_volume, sounds::sound_t::alarm, + _( targeting_sound.c_str() ) ); } if( not_targeted ) { z.add_effect( effect_targeted, time_duration::from_turns( targeting_timeout ) ); @@ -469,7 +475,7 @@ void gun_actor::shoot( monster &z, Creature &target, const gun_mode_id &mode ) c if( !gun.ammo_sufficient() ) { if( !no_ammo_sound.empty() ) { - sounds::sound( z.pos(), 10, _( no_ammo_sound.c_str() ) ); + sounds::sound( z.pos(), 10, sounds::sound_t::combat, _( no_ammo_sound.c_str() ) ); } return; } diff --git a/src/melee.cpp b/src/melee.cpp index 289beb1ad285d..5ebe62a8d1514 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -448,7 +448,7 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc // Make a rather quiet sound, to alert any nearby monsters if( !is_quiet() ) { // check martial arts silence - sounds::sound( pos(), 8, "" ); + sounds::sound( pos(), 8, sounds::sound_t::combat, "whack!" ); } std::string material = "flesh"; if( t.is_monster() ) { @@ -1579,7 +1579,7 @@ std::string player::melee_special_effects( Creature &t, damage_instance &d, item weap.tname().c_str() ); } - sounds::sound( pos(), 16, "" ); + sounds::sound( pos(), 16, sounds::sound_t::combat, "Crack!" ); // Dump its contents on the ground for( auto &elem : weap.contents ) { g->m.add_item_or_charges( pos(), elem ); diff --git a/src/monattack.cpp b/src/monattack.cpp index 5367c67ec580f..b4e78b3f8ee47 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -304,7 +304,7 @@ bool mattack::shriek( monster *z ) } z->moves -= 240; // It takes a while - sounds::sound( z->pos(), 50, _( "a terrible shriek!" ) ); + sounds::sound( z->pos(), 50, sounds::sound_t::speech, _( "a terrible shriek!" ) ); return true; } @@ -327,7 +327,7 @@ bool mattack::shriek_alert( monster *z ) } z->moves -= 150; - sounds::sound( z->pos(), 120, _( "a piercing wail!" ) ); + sounds::sound( z->pos(), 120, sounds::sound_t::speech, _( "a piercing wail!" ) ); z->add_effect( effect_shrieking, 1_minutes ); return true; @@ -387,7 +387,7 @@ bool mattack::howl( monster *z ) } z->moves -= 200; // It takes a while - sounds::sound( z->pos(), 35, _( "an ear-piercing howl!" ) ); + sounds::sound( z->pos(), 35, sounds::sound_t::speech, _( "an ear-piercing howl!" ) ); if( z->friendly != 0 ) { // TODO: Make this use mon's faction when those are in for( monster &other : g->all_monsters() ) { @@ -418,7 +418,7 @@ bool mattack::rattle( monster *z ) } z->moves -= 20; // It takes a very short while - sounds::sound( z->pos(), 10, _( "a sibilant rattling sound!" ) ); + sounds::sound( z->pos(), 10, sounds::sound_t::alarm, _( "a sibilant rattling sound!" ) ); return true; } @@ -439,7 +439,7 @@ bool mattack::acid( monster *z ) return false; // Can't see/reach target, no attack } z->moves -= 300; // It takes a while - sounds::sound( z->pos(), 4, _( "a spitting noise." ) ); + sounds::sound( z->pos(), 4, sounds::sound_t::combat, _( "a spitting noise." ) ); projectile proj; proj.speed = 10; @@ -610,8 +610,9 @@ bool mattack::shocking_reveal( monster *z ) { shockstorm( z ); std::string WHAT_A_SCOOP = SNIPPET.random_from_category( "clickbait" ); - sounds::sound( z->pos(), 10, string_format( _( "the %s obnoxiously yelling \"%s!!!\"" ), - z->name().c_str(), WHAT_A_SCOOP ) ); + sounds::sound( z->pos(), 10, sounds::sound_t::speech, + string_format( _( "the %s obnoxiously yelling \"%s!!!\"" ), + z->name().c_str(), WHAT_A_SCOOP ) ); return true; } @@ -1415,7 +1416,7 @@ bool mattack::spit_sap( monster *z ) bool mattack::triffid_heartbeat( monster *z ) { - sounds::sound( z->pos(), 14, _( "thu-THUMP." ) ); + sounds::sound( z->pos(), 14, sounds::sound_t::movement, _( "thu-THUMP." ) ); z->moves -= 300; if( z->friendly != 0 ) { return true; @@ -1481,7 +1482,7 @@ bool mattack::fungus( monster *z ) z->friendly = 100; } //~ the sound of a fungus releasing spores - sounds::sound( z->pos(), 10, _( "Pouf!" ) ); + sounds::sound( z->pos(), 10, sounds::sound_t::combat, _( "Pouf!" ) ); if( g->u.sees( *z ) ) { add_msg( m_warning, _( "Spores are released from the %s!" ), z->name().c_str() ); } @@ -1531,7 +1532,7 @@ bool mattack::fungus( monster *z ) bool mattack::fungus_corporate( monster *z ) { if( x_in_y( 1, 20 ) ) { - sounds::sound( z->pos(), 10, _( "\"Buy SpOreos(tm) now!\"" ) ); + sounds::sound( z->pos(), 10, sounds::sound_t::speech, _( "\"Buy SpOreos(tm) now!\"" ) ); if( g->u.sees( *z ) ) { add_msg( m_warning, _( "Delicious snacks are released from the %s!" ), z->name().c_str() ); g->m.add_item( z->pos(), item( "sporeos" ) ); @@ -1545,7 +1546,7 @@ bool mattack::fungus_corporate( monster *z ) bool mattack::fungus_haze( monster *z ) { //~ That spore sound again - sounds::sound( z->pos(), 10, _( "Pouf!" ) ); + sounds::sound( z->pos(), 10, sounds::sound_t::combat, _( "Pouf!" ) ); if( g->u.sees( *z ) ) { add_msg( m_info, _( "The %s pulses, and fresh fungal material bursts forth." ), z->name().c_str() ); } @@ -1579,18 +1580,18 @@ bool mattack::fungus_big_blossom( monster *z ) add_msg( m_warning, _( "The %s suddenly inhales!" ), z->name().c_str() ); } //~Sound of a giant fungal blossom inhaling - sounds::sound( z->pos(), 20, _( "WOOOSH!" ) ); + sounds::sound( z->pos(), 20, sounds::sound_t::combat, _( "WOOOSH!" ) ); if( u_see ) { add_msg( m_bad, _( "The %s discharges an immense flow of spores, smothering the flames!" ), z->name().c_str() ); } //~Sound of a giant fungal blossom blowing out the dangerous fire! - sounds::sound( z->pos(), 20, _( "POUFF!" ) ); + sounds::sound( z->pos(), 20, sounds::sound_t::combat, _( "POUFF!" ) ); return true; } else { // No fire detected, routine haze-emission //~ That spore sound, much louder - sounds::sound( z->pos(), 15, _( "POUF." ) ); + sounds::sound( z->pos(), 15, sounds::sound_t::combat, _( "POUF." ) ); if( u_see ) { add_msg( m_info, _( "The %s pulses, and fresh fungal material bursts forth!" ), z->name().c_str() ); } @@ -2817,7 +2818,7 @@ void mattack::rifle( monster *z, Creature *target ) if( target == &g->u ) { if( !z->has_effect( effect_targeted ) ) { - sounds::sound( z->pos(), 8, _( "beep-beep." ) ); + sounds::sound( z->pos(), 8, sounds::sound_t::alarm, _( "beep-beep." ) ); z->add_effect( effect_targeted, 8_turns ); z->moves -= 100; return; @@ -2827,9 +2828,9 @@ void mattack::rifle( monster *z, Creature *target ) if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { - sounds::sound( z->pos(), 2, _( "a chk!" ) ); + sounds::sound( z->pos(), 2, sounds::sound_t::combat, _( "a chk!" ) ); } else if( one_in( 4 ) ) { - sounds::sound( z->pos(), 6, _( "boop!" ) ); + sounds::sound( z->pos(), 6, sounds::sound_t::combat, _( "boop!" ) ); } return; } @@ -2863,7 +2864,7 @@ void mattack::frag( monster *z, Creature *target ) // This is for the bots, not add_msg( m_warning, _( "Those laser dots don't seem very friendly..." ) ); g->u.add_effect( effect_laserlocked, 3_turns ); // Effect removed in game.cpp, duration doesn't much matter - sounds::sound( z->pos(), 10, _( "Targeting." ) ); + sounds::sound( z->pos(), 10, sounds::sound_t::speech, _( "Targeting." ) ); z->add_effect( effect_targeted, 5_turns ); z->moves -= 150; // Should give some ability to get behind cover, @@ -2879,9 +2880,9 @@ void mattack::frag( monster *z, Creature *target ) // This is for the bots, not if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { - sounds::sound( z->pos(), 2, _( "a chk!" ) ); + sounds::sound( z->pos(), 2, sounds::sound_t::combat, _( "a chk!" ) ); } else if( one_in( 4 ) ) { - sounds::sound( z->pos(), 6, _( "boop!" ) ); + sounds::sound( z->pos(), 6, sounds::sound_t::combat, _( "boop!" ) ); } return; } @@ -2919,7 +2920,7 @@ void mattack::tankgun( monster *z, Creature *target ) //~ There will be a 120mm HEAT shell sent at high speed to your location next turn. target->add_msg_if_player( m_warning, _( "You're not sure why you've got a laser dot on you..." ) ); //~ Sound of a tank turret swiveling into place - sounds::sound( z->pos(), 10, _( "whirrrrrclick." ) ); + sounds::sound( z->pos(), 10, sounds::sound_t::combat, _( "whirrrrrclick." ) ); z->add_effect( effect_targeted, 1_minutes ); target->add_effect( effect_laserlocked, 1_minutes ); z->moves -= 200; @@ -2941,9 +2942,9 @@ void mattack::tankgun( monster *z, Creature *target ) if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { - sounds::sound( z->pos(), 2, _( "a chk!" ) ); + sounds::sound( z->pos(), 2, sounds::sound_t::combat, _( "a chk!" ) ); } else if( one_in( 4 ) ) { - sounds::sound( z->pos(), 6, _( "clank!" ) ); + sounds::sound( z->pos(), 6, sounds::sound_t::combat, _( "clank!" ) ); } return; } @@ -3248,16 +3249,19 @@ bool mattack::copbot( monster *z ) if( one_in( 3 ) ) { if( sees_u ) { if( foe->unarmed_attack() ) { - sounds::sound( z->pos(), 18, _( "a robotic voice boom, \"Citizen, Halt!\"" ) ); + sounds::sound( z->pos(), 18, sounds::sound_t::speech, + _( "a robotic voice boom, \"Citizen, Halt!\"" ) ); } else if( !cuffed ) { - sounds::sound( z->pos(), 18, _( "a robotic voice boom, \"\ + sounds::sound( z->pos(), 18, sounds::sound_t::speech, + _( "a robotic voice boom, \"\ Please put down your weapon.\"" ) ); } } else - sounds::sound( z->pos(), 18, + sounds::sound( z->pos(), 18, sounds::sound_t::speech, _( "a robotic voice boom, \"Come out with your hands up!\"" ) ); } else { - sounds::sound( z->pos(), 18, _( "a police siren, whoop WHOOP" ) ); + sounds::sound( z->pos(), 18, sounds::sound_t::alarm, + _( "a police siren, whoop WHOOP" ) ); } return true; } @@ -3464,7 +3468,7 @@ bool mattack::ratking( monster *z ) bool mattack::generator( monster *z ) { - sounds::sound( z->pos(), 100, "" ); + sounds::sound( z->pos(), 100, sounds::sound_t::activity, "hmmmm" ); if( calendar::once_every( 1_minutes ) && z->get_hp() < z->get_hp_max() ) { z->heal( 1 ); } @@ -3672,7 +3676,7 @@ bool mattack::flesh_golem( monster *z ) if( one_in( 12 ) ) { z->moves -= 200; // It doesn't "nearly deafen you" when it roars from the other side of bubble - sounds::sound( z->pos(), 80, _( "a terrifying roar!" ) ); + sounds::sound( z->pos(), 80, sounds::sound_t::speech, _( "a terrifying roar!" ) ); return true; } return false; @@ -3891,13 +3895,13 @@ bool mattack::longswipe( monster *z ) bool mattack::parrot( monster *z ) { if( z->has_effect( effect_shrieking ) ) { - sounds::sound( z->pos(), 120, _( "a piercing wail!" ), true ); + sounds::sound( z->pos(), 120, sounds::sound_t::speech, _( "a piercing wail!" ), true ); z->moves -= 40; return false; } else if( one_in( 20 ) ) { z->moves -= 100; // It takes a while const SpeechBubble speech = get_speech( z->type->id.str() ); - sounds::sound( z->pos(), speech.volume, speech.text ); + sounds::sound( z->pos(), speech.volume, sounds::sound_t::speech, speech.text ); return true; } @@ -4089,7 +4093,7 @@ bool mattack::riotbot( monster *z ) z->anger = 0; if( calendar::once_every( 25_turns ) ) { - sounds::sound( z->pos(), 10, + sounds::sound( z->pos(), 10, sounds::sound_t::speech, _( "Halt and submit to arrest, citizen! The police will be here any moment." ) ); } @@ -4106,7 +4110,8 @@ bool mattack::riotbot( monster *z ) //we need empty hands to arrest if( foe == &g->u && !foe->is_armed() ) { - sounds::sound( z->pos(), 15, _( "Please stay in place, citizen, do not make any movements!" ) ); + sounds::sound( z->pos(), 15, sounds::sound_t::speech, + _( "Please stay in place, citizen, do not make any movements!" ) ); //we need to come closer and arrest if( !is_adjacent( z, foe, false ) ) { @@ -4168,13 +4173,13 @@ bool mattack::riotbot( monster *z ) add_msg( _( "The robot puts handcuffs on you." ) ); } - sounds::sound( z->pos(), 5, + sounds::sound( z->pos(), 5, sounds::sound_t::speech, _( "You are under arrest, citizen. You have the right to remain silent. If you do not remain silent, anything you say may be used against you in a court of law." ) ); - sounds::sound( z->pos(), 5, + sounds::sound( z->pos(), 5, sounds::sound_t::speech, _( "You have the right to an attorney. If you cannot afford an attorney, one will be provided at no cost to you. You may have your attorney present during any questioning." ) ); - sounds::sound( z->pos(), 5, + sounds::sound( z->pos(), 5, sounds::sound_t::speech, _( "If you do not understand these rights, an officer will explain them in greater detail when taking you into custody." ) ); - sounds::sound( z->pos(), 5, + sounds::sound( z->pos(), 5, sounds::sound_t::speech, _( "Do not attempt to flee or to remove the handcuffs, citizen. That can be dangerous to your health." ) ); z->moves -= 300; @@ -4221,7 +4226,8 @@ bool mattack::riotbot( monster *z ) } if( calendar::once_every( 5_turns ) ) { - sounds::sound( z->pos(), 25, _( "Empty your hands and hold your position, citizen!" ) ); + sounds::sound( z->pos(), 25, sounds::sound_t::speech, + _( "Empty your hands and hold your position, citizen!" ) ); } if( dist > 5 && dist < 18 && one_in( 10 ) ) { @@ -4238,7 +4244,7 @@ bool mattack::riotbot( monster *z ) target->posz() ); //~ Sound of a riotbot using its blinding flash - sounds::sound( z->pos(), 3, _( "fzzzzzt" ) ); + sounds::sound( z->pos(), 3, sounds::sound_t::combat, _( "fzzzzzt" ) ); std::vector traj = line_to( z->pos(), dest, 0, 0 ); for( auto &elem : traj ) { @@ -4738,7 +4744,7 @@ bool mattack::doot( monster *z ) continue; } } - sounds::sound( z->pos(), 200, _( "DOOT." ) ); + sounds::sound( z->pos(), 200, sounds::sound_t::music, _( "DOOT." ) ); return true; } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index d2c9dabaf3550..ddf0f4cb076a7 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -196,7 +196,7 @@ void mdeath::acid( monster &z ) void mdeath::boomer( monster &z ) { std::string explode = string_format( _( "a %s explode!" ), z.name().c_str() ); - sounds::sound( z.pos(), 24, explode ); + sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode ); for( auto &&dest : g->m.points_in_radius( z.pos(), 1 ) ) { // *NOPAD* g->m.bash( dest, 10 ); if( monster *const z = g->critter_at( dest ) ) { @@ -215,7 +215,7 @@ void mdeath::boomer( monster &z ) void mdeath::boomer_glow( monster &z ) { std::string explode = string_format( _( "a %s explode!" ), z.name().c_str() ); - sounds::sound( z.pos(), 24, explode ); + sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode ); for( auto &&dest : g->m.points_in_radius( z.pos(), 1 ) ) { // *NOPAD* g->m.bash( dest, 10 ); @@ -316,7 +316,7 @@ void mdeath::fungus( monster &z ) } //~ the sound of a fungus dying - sounds::sound( z.pos(), 10, _( "Pouf!" ) ); + sounds::sound( z.pos(), 10, sounds::sound_t::combat, _( "Pouf!" ) ); fungal_effects fe( *g, g->m ); for( auto &&sporep : g->m.points_in_radius( z.pos(), 1 ) ) { // *NOPAD* @@ -633,14 +633,14 @@ void mdeath::darkman( monster &z ) void mdeath::gas( monster &z ) { std::string explode = string_format( _( "a %s explode!" ), z.name().c_str() ); - sounds::sound( z.pos(), 24, explode ); + sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode ); g->m.emit_field( z.pos(), emit_id( "emit_toxic_blast" ) ); } void mdeath::smokeburst( monster &z ) { std::string explode = string_format( _( "a %s explode!" ), z.name().c_str() ); - sounds::sound( z.pos(), 24, explode ); + sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode ); g->m.emit_field( z.pos(), emit_id( "emit_smoke_blast" ) ); } @@ -810,7 +810,7 @@ void mdeath::fireball( monster &z ) g->m.propagate_field( z.pos(), fd_fire, 15, 3 ); std::string explode = string_format( _( "an explosion of tank of the %s's flamethrower!" ), z.name().c_str() ); - sounds::sound( z.pos(), 24, explode ); + sounds::sound( z.pos(), 24, sounds::sound_t::combat, explode ); add_msg( m_good, _( "I love the smell of burning zed in the morning." ) ); } else { normal( z ); diff --git a/src/monster.cpp b/src/monster.cpp index d32789bf15b92..9719897582a90 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1809,7 +1809,7 @@ void monster::process_turn() if( has_flag( MF_ELECTRIC_FIELD ) ) { if( has_effect( effect_emp ) ) { if( calendar::once_every( 10_turns ) ) { - sounds::sound( pos(), 5, _( "hummmmm." ) ); + sounds::sound( pos(), 5, sounds::sound_t::combat, _( "hummmmm." ) ); } } else { for( const tripoint &zap : g->m.points_in_radius( pos(), 1 ) ) { @@ -1818,7 +1818,7 @@ void monster::process_turn() for( auto fiyah = items.begin(); fiyah != items.end(); fiyah++ ) { if( fiyah->made_of( LIQUID ) && fiyah->flammable() ) { // start a fire! g->m.add_field( zap, fd_fire, 2, 1_minutes ); - sounds::sound( pos(), 30, _( "fwoosh!" ) ); + sounds::sound( pos(), 30, sounds::sound_t::combat, _( "fwoosh!" ) ); break; } } @@ -1843,8 +1843,8 @@ void monster::process_turn() } if( g->lightning_active && !has_effect( effect_supercharged ) && g->m.is_outside( pos() ) ) { g->lightning_active = false; // only one supercharge per strike - sounds::sound( pos(), 300, _( "BOOOOOOOM!!!" ) ); - sounds::sound( pos(), 20, _( "vrrrRRRUUMMMMMMMM!" ) ); + sounds::sound( pos(), 300, sounds::sound_t::combat, _( "BOOOOOOOM!!!" ) ); + sounds::sound( pos(), 20, sounds::sound_t::combat, _( "vrrrRRRUUMMMMMMMM!" ) ); if( g->u.sees( pos() ) ) { add_msg( m_bad, _( "Lightning strikes the %s!" ), name().c_str() ); add_msg( m_bad, _( "Your vision goes white!" ) ); @@ -1852,7 +1852,7 @@ void monster::process_turn() } add_effect( effect_supercharged, 12_hours ); } else if( has_effect( effect_supercharged ) && calendar::once_every( 5_turns ) ) { - sounds::sound( pos(), 20, _( "VMMMMMMMMM!" ) ); + sounds::sound( pos(), 20, sounds::sound_t::combat, _( "VMMMMMMMMM!" ) ); } } } diff --git a/src/npc.cpp b/src/npc.cpp index fb80a0768da36..e87e87e1aceee 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1359,19 +1359,12 @@ void npc::say( const std::string &line ) const return; } - const bool sees = g->u.sees( *this ); - const bool deaf = g->u.is_deaf(); - if( sees && !deaf ) { - add_msg( _( "%1$s says: \"%2$s\"" ), name.c_str(), formatted_line.c_str() ); - sounds::sound( pos(), 16, "" ); - } else if( !sees ) { - std::string sound = string_format( _( "%1$s saying \"%2$s\"" ), name.c_str(), - formatted_line.c_str() ); - sounds::sound( pos(), 16, sound ); - } else { - add_msg( m_warning, _( "%1$s says something but you can't hear it!" ), name.c_str() ); - sounds::sound( pos(), 16, "" ); + std::string sound = string_format( _( "%1$s saying \"%2$s\"" ), name, formatted_line ); + if( g->u.sees( *this ) && g->u.is_deaf() ) { + add_msg( m_warning, _( "%1$s says something but you can't hear it!" ), name ); } + // Sound happens even if we can't hear it + sounds::sound( pos(), 16, sounds::sound_t::speech, sound ); } bool npc::wants_to_sell( const item &it ) const diff --git a/src/player.cpp b/src/player.cpp index 50c0a830140ec..eb59f44c8c17d 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2977,7 +2977,7 @@ void player::shout( std::string msg ) add_msg( m_warning, _( "The sound of your voice is significantly muffled!" ) ); } - sounds::sound( pos(), noise, msg ); + sounds::sound( pos(), noise, sounds::sound_t::speech, msg ); } void player::toggle_move_mode() @@ -4741,10 +4741,8 @@ void player::cough(bool harmful, int loudness) if( !is_npc() ) { add_msg(m_bad, _("You cough heavily.")); - sounds::sound(pos(), loudness, ""); - } else { - sounds::sound(pos(), loudness, _("a hacking cough.")); } + sounds::sound( pos(), loudness, sounds::sound_t::speech, _( "a hacking cough." ) ); moves -= 80; @@ -5201,7 +5199,7 @@ void player::suffer() if( has_active_mutation( trait_id( "WINGS_INSECT" ) ) ) { //~Sound of buzzing Insect Wings - sounds::sound( pos(), 10, _("BZZZZZ")); + sounds::sound( pos(), 10, sounds::sound_t::movement, _("BZZZZZ")); } bool wearing_shoes = is_wearing_shoes( side::LEFT ) || is_wearing_shoes( side::RIGHT ); @@ -6070,7 +6068,7 @@ void player::suffer() add_msg(m_bad, _("You feel your faulty bionic shuddering.")); sfx::play_variant_sound( "bionics", "elec_blast_muffled", 100 ); } - sounds::sound( pos(), 60, ""); + sounds::sound( pos(), 60, sounds::sound_t::movement, _( "Crackle!" ) ); } if (has_bionic( bio_power_weakness ) && max_power_level > 0 && power_level >= max_power_level * .75) { @@ -11961,7 +11959,7 @@ void player::spores() { fungal_effects fe( *g, g->m ); //~spore-release sound - sounds::sound( pos(), 10, _("Pouf!")); + sounds::sound( pos(), 10, sounds::sound_t::combat, _("Pouf!")); for( const tripoint &sporep : g->m.points_in_radius( pos(), 1 ) ) { if (sporep == pos()) { continue; @@ -11973,7 +11971,7 @@ void player::spores() void player::blossoms() { // Player blossoms are shorter-ranged, but you can fire much more frequently if you like. - sounds::sound( pos(), 10, _("Pouf!")); + sounds::sound( pos(), 10, sounds::sound_t::combat, _("Pouf!")); for( const tripoint &tmp : g->m.points_in_radius( pos(), 2 ) ) { g->m.add_field( tmp, fd_fungal_haze, rng( 1, 2 ) ); } diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index 1f2b195f45961..a45c2637a49a8 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -255,7 +255,7 @@ static void eff_fun_hallu( player &u, effect &it ) int loudness = 20 + u.str_cur - u.int_cur; loudness = ( loudness > 5 ? loudness : 5 ); loudness = ( loudness < 30 ? loudness : 30 ); - sounds::sound( u.pos(), loudness, npc_text ); + sounds::sound( u.pos(), loudness, sounds::sound_t::speech, npc_text ); } } else if( dur == peakTime ) { // Visuals start @@ -1265,7 +1265,7 @@ void player::hardcoded_effects( effect &it ) it.mod_duration( 10_minutes ); } else if( dur == 2_turns ) { // let the sound code handle the wake-up part - sounds::sound( pos(), 16, _( "beep-beep-beep!" ) ); + sounds::sound( pos(), 16, sounds::sound_t::alarm, _( "beep-beep-beep!" ) ); } } } diff --git a/src/ranged.cpp b/src/ranged.cpp index dba4b4a6f2402..e9ee541b5ad80 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -1567,7 +1567,8 @@ void make_gun_sound_effect( player &p, bool burst, item *weapon ) { const auto data = weapon->gun_noise( burst ); if( data.volume > 0 ) { - sounds::sound( p.pos(), data.volume, data.sound ); + sounds::sound( p.pos(), data.volume, sounds::sound_t::combat, + data.sound.empty() ? _( "Bang!" ) : data.sound ); } } diff --git a/src/sounds.cpp b/src/sounds.cpp index 778421b84c794..b333f5fb92050 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -57,6 +57,7 @@ static const trait_id trait_HEAVYSLEEPER( "HEAVYSLEEPER" ); struct sound_event { int volume; + sounds::sound_t category; std::string description; bool ambient; bool footstep; @@ -83,26 +84,31 @@ static std::unordered_map sound_markers; void sounds::ambient_sound( const tripoint &p, int vol, const std::string &description ) { - sound( p, vol, description, true ); + sound( p, vol, sounds::sound_t::background, description, true ); } -void sounds::sound( const tripoint &p, int vol, std::string description, bool ambient, - const std::string &id, const std::string &variant ) +void sounds::sound( const tripoint &p, int vol, sound_t category, std::string description, + bool ambient, const std::string &id, const std::string &variant ) { if( vol < 0 ) { // Bail out if no volume. debugmsg( "negative sound volume %d", vol ); return; } + // Description is not an optional parameter + if( description.empty() ) { + debugmsg( "Sound at %d:%d has no description!", p.x, p.y ); + } recent_sounds.emplace_back( std::make_pair( p, vol ) ); - sounds_since_last_turn.emplace_back( - std::make_pair( p, sound_event {vol, description, ambient, false, id, variant} ) ); + sounds_since_last_turn.emplace_back( std::make_pair( p, + sound_event {vol, category, description, ambient, + false, id, variant} ) ); } void sounds::add_footstep( const tripoint &p, int volume, int, monster * ) { - sounds_since_last_turn.emplace_back( - std::make_pair( p, sound_event {volume, "", false, true, "", ""} ) ); + sounds_since_last_turn.emplace_back( std::make_pair( p, sound_event { volume, + sound_t::movement, "footsteps", false, true, "", ""} ) ); } template @@ -272,14 +278,13 @@ void sounds::process_sound_markers( player *p ) p->add_effect( effect_deaf, deafness_duration ); if( p->is_deaf() && !is_deaf ) { is_deaf = true; - sfx::do_hearing_loss( to_turns( deafness_duration ) ); continue; } } // The heard volume of a sound is the player heard volume, regardless of true volume level. - const int heard_volume = static_cast( ( raw_volume - weather_vol ) * volume_multiplier ) - - distance_to_sound; + const int heard_volume = static_cast( ( raw_volume - weather_vol ) * + volume_multiplier ) - distance_to_sound; if( heard_volume <= 0 && pos != p->pos() ) { continue; @@ -308,25 +313,27 @@ void sounds::process_sound_markers( player *p ) } } - const std::string &description = sound.description; + const std::string &description = sound.description.empty() ? "a noise" : sound.description; + + // don't print our own noise or things without descriptions if( !sound.ambient && ( pos != p->pos() ) && !g->m.pl_sees( pos, distance_to_sound ) ) { if( !p->activity.is_distraction_ignored( distraction_type::noise ) ) { - const std::string query = description.empty() - ? _( "Heard a noise!" ) - : string_format( _( "Heard %s!" ), description.c_str() ); - + const std::string query = string_format( _( "Heard %s!" ), description ); g->cancel_activity_or_ignore_query( distraction_type::noise, query ); } } - if( !description.empty() ) { - // If it came from us, don't print a direction - if( pos == p->pos() ) { - add_msg( _( "You hear %s" ), description.c_str() ); + if( pos != p->pos() ) { + game_message_type severity = m_info; + if( sound.category == sound_t::combat || sound.category == sound_t::alarm ) { + severity = m_warning; + } + // if we can see it, don't print a direction + if( p->sees( pos ) ) { + add_msg( severity, _( "You hear %1$s" ), description ); } else { - // Else print a direction as well std::string direction = direction_name( direction_from( p->pos(), pos ) ); - add_msg( m_warning, _( "From the %1$s you hear %2$s" ), direction.c_str(), description.c_str() ); + add_msg( severity, _( "From the %1$s you hear %2$s" ), direction, description ); } } @@ -338,14 +345,14 @@ void sounds::process_sound_markers( player *p ) const bool trying_to_sleep = p->in_sleep_state(); if( p->get_effect( effect_alarm_clock ).get_duration() == 1_turns ) { if( slept_through ) { - p->add_msg_if_player( _( "Your alarm clock finally wakes you up." ) ); + add_msg( _( "Your alarm clock finally wakes you up." ) ); } else if( !trying_to_sleep ) { - p->add_msg_if_player( _( "Your alarm clock wakes you up." ) ); + add_msg( _( "Your alarm clock wakes you up." ) ); } else { - p->add_msg_if_player( _( "Your alarm clock goes off and you haven't slept a wink." ) ); + add_msg( _( "Your alarm clock goes off and you haven't slept a wink." ) ); p->activity.set_to_null(); } - p->add_msg_if_player( _( "You turn off your alarm-clock." ) ); + add_msg( _( "You turn off your alarm-clock." ) ); } p->get_effect( effect_alarm_clock ).set_duration( 0_turns ); } @@ -388,7 +395,9 @@ void sounds::process_sound_markers( player *p ) sound_markers.emplace( random_entry( unseen_points ), sound ); } } - sounds_since_last_turn.clear(); + if( p->is_player() ) { + sounds_since_last_turn.clear(); + } } void sounds::reset_sounds() diff --git a/src/sounds.h b/src/sounds.h index c65396e28342f..cd17ddf8d0184 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -15,6 +15,17 @@ class JsonObject; namespace sounds { +enum class sound_t : int { + background = 0, + weather, + music, + activity, + movement, + alarm, + combat, // any violent sounding activity, including construction + speech +}; + // Methods for recording sound events. /** * Sound at (p) of intensity (vol) @@ -24,14 +35,16 @@ namespace sounds * * @param p position of sound. * @param vol Volume of sound. + * @param category general type of sound for faster parsing * @param description Description of the sound for the player * @param ambient Sound does not interrupt player activity if this is true * @param id Id of sound effect * @param variant Variant of sound effect given in id * @returns true if the player could hear the sound. */ -void sound( const tripoint &p, int vol, std::string description, bool ambient = false, - const std::string &id = "", const std::string &variant = "default" ); +void sound( const tripoint &p, int vol, sound_t category, std::string description, + bool ambient = false, const std::string &id = "", + const std::string &variant = "default" ); /** Functions identical to sound(..., true). */ void ambient_sound( const tripoint &p, int vol, const std::string &description ); /** Creates a list of coordinates at which to draw footsteps. */ diff --git a/src/speech.cpp b/src/speech.cpp index 2546e640642a3..2243bffdb2dcc 100644 --- a/src/speech.cpp +++ b/src/speech.cpp @@ -9,7 +9,7 @@ std::map > speech; -SpeechBubble nullSpeech = { "", 0 }; +SpeechBubble nullSpeech = { "hsss", 0 }; void load_speech( JsonObject &jo ) { diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 1c9679a8d73e4..8f191de335e7f 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -66,7 +66,7 @@ void trapfunc::bubble( Creature *c, const tripoint &p ) c->add_memorial_log( pgettext( "memorial_male", "Stepped on bubble wrap." ), pgettext( "memorial_female", "Stepped on bubble wrap." ) ); } - sounds::sound( p, 18, _( "Pop!" ) ); + sounds::sound( p, 18, sounds::sound_t::alarm, _( "Pop!" ) ); g->m.remove_trap( p ); } @@ -86,7 +86,7 @@ void trapfunc::beartrap( Creature *c, const tripoint &p ) if( c != nullptr && c->get_size() == MS_TINY ) { return; } - sounds::sound( p, 8, _( "SNAP!" ) ); + sounds::sound( p, 8, sounds::sound_t::combat, _( "SNAP!" ) ); g->m.remove_trap( p ); if( c != nullptr ) { // What got hit? @@ -309,7 +309,7 @@ void trapfunc::crossbow( Creature *c, const tripoint &p ) void trapfunc::shotgun( Creature *c, const tripoint &p ) { - sounds::sound( p, 60, _( "Kerblam!" ) ); + sounds::sound( p, 60, sounds::sound_t::combat, _( "Kerblam!" ) ); int shots = 1; if( c != nullptr ) { c->add_msg_player_or_npc( m_neutral, _( "You trigger a shotgun trap!" ), @@ -416,7 +416,7 @@ void trapfunc::blade( Creature *c, const tripoint & ) void trapfunc::snare_light( Creature *c, const tripoint &p ) { - sounds::sound( p, 2, _( "Snap!" ) ); + sounds::sound( p, 2, sounds::sound_t::combat, _( "Snap!" ) ); g->m.remove_trap( p ); if( c != nullptr ) { // Determine what gets hit @@ -439,7 +439,7 @@ void trapfunc::snare_light( Creature *c, const tripoint &p ) void trapfunc::snare_heavy( Creature *c, const tripoint &p ) { - sounds::sound( p, 4, _( "Snap!" ) ); + sounds::sound( p, 4, sounds::sound_t::combat, _( "Snap!" ) ); g->m.remove_trap( p ); if( c != nullptr ) { // Determine what got hit @@ -510,7 +510,7 @@ void trapfunc::boobytrap( Creature *c, const tripoint &p ) void trapfunc::telepad( Creature *c, const tripoint &p ) { //~ the sound of a telepad functioning - sounds::sound( p, 6, _( "vvrrrRRMM*POP!*" ) ); + sounds::sound( p, 6, sounds::sound_t::movement, _( "vvrrrRRMM*POP!*" ) ); if( c != nullptr ) { monster *z = dynamic_cast( c ); // TODO: NPC don't teleport? @@ -593,14 +593,15 @@ void trapfunc::dissector( Creature *c, const tripoint &p ) monster *z = dynamic_cast( c ); if( z != nullptr && z->type->in_species( ROBOT ) ) { //The monster is a robot. So the dissector should not try to dissect the monsters flesh. - sounds::sound( p, 4, _( "BEEPBOOP! Please remove non-organic object." ) ); //Dissector error sound. + sounds::sound( p, 4, sounds::sound_t::speech, + _( "BEEPBOOP! Please remove non-organic object." ) ); //Dissector error sound. c->add_msg_player_or_npc( m_bad, _( "The dissector lights up, and shuts down." ), _( "The dissector lights up, and shuts down." ) ); return; } //~ the sound of a dissector dissecting - sounds::sound( p, 10, _( "BRZZZAP!" ) ); + sounds::sound( p, 10, sounds::sound_t::combat, _( "BRZZZAP!" ) ); c->add_msg_player_or_npc( m_bad, _( "Electrical beams emit from the floor and slice your flesh!" ), _( "Electrical beams emit from the floor and slice s flesh!" ) ); c->add_memorial_log( pgettext( "memorial_male", "Stepped into a dissector." ), @@ -1153,7 +1154,7 @@ void trapfunc::hum( Creature * /*c*/, const tripoint &p ) //~ a very loud humming sound sfx = _( "VRMMMMMM" ); } - sounds::sound( p, volume, sfx ); + sounds::sound( p, volume, sounds::sound_t::activity, sfx ); } void trapfunc::shadow( Creature *c, const tripoint &p ) @@ -1206,7 +1207,7 @@ void trapfunc::drain( Creature *c, const tripoint & ) void trapfunc::snake( Creature *c, const tripoint &p ) { //~ the sound a snake makes - sounds::sound( p, 10, _( "ssssssss" ) ); + sounds::sound( p, 10, sounds::sound_t::movement, _( "ssssssss" ) ); if( one_in( 6 ) ) { g->m.remove_trap( p ); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e854d422babd3..60ef74e1243f4 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2943,8 +2943,8 @@ void vehicle::noise_and_smoke( int load, time_duration time ) { const std::array sound_levels = {{ 0, 15, 30, 60, 100, 140, 180, INT_MAX }}; const std::array sound_msgs = {{ - "", _( "hummm!" ), _( "whirrr!" ), _( "vroom!" ), _( "roarrr!" ), _( "ROARRR!" ), - _( "BRRROARRR!" ), _( "BRUMBRUMBRUMBRUM!" ) + _( "hmm" ), _( "hummm!" ), _( "whirrr!" ), _( "vroom!" ), _( "roarrr!" ), + _( "ROARRR!" ), _( "BRRROARRR!" ), _( "BRUMBRUMBRUMBRUM!" ) } }; double noise = 0.0; diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 3b222fa5e74c2..747bd0f7ab1d9 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -526,7 +526,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, k = std::max( 10.0f, std::min( 90.0f, k ) ); bool smashed = true; - std::string snd; // NOTE: Unused! + std::string snd = "Smash!"; // NOTE: Unused! float dmg = 0.0f; float part_dmg = 0.0f; // Calculate Impulse of car @@ -686,7 +686,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, if( part_flag( ret.part, "SHARP" ) ) { critter->bleed(); } else { - sounds::sound( p, 20, snd ); + sounds::sound( p, 20, sounds::sound_t::combat, snd ); } } } else { @@ -702,7 +702,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, } } - sounds::sound( p, smashed ? 80 : 50, snd ); + sounds::sound( p, smashed ? 80 : 50, sounds::sound_t::combat, snd ); } if( smashed && !vert_coll ) { @@ -818,7 +818,7 @@ void vehicle::handle_trap( const tripoint &p, int part ) } } if( noise > 0 ) { - sounds::sound( p, noise, snd ); + sounds::sound( p, noise, sounds::sound_t::combat, snd ); } if( part_damage && chance >= rng( 1, 100 ) ) { // Hit the wheel directly since it ran right over the trap. diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 1ad96ebd24a2a..dafc22c36d9d8 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -776,7 +776,7 @@ bool vehicle::start_engine( const int e ) backfire( e ); } else { const tripoint pos = global_part_pos3( engines[e] ); - sounds::ambient_sound( pos, start_moves / 10, "" ); + sounds::ambient_sound( pos, start_moves / 10, "Bang!" ); } } @@ -884,13 +884,13 @@ void vehicle::honk_horn() //Determine sound if( horn_type.bonus >= 110 ) { //~ Loud horn sound - sounds::sound( horn_pos, horn_type.bonus, _( "HOOOOORNK!" ) ); + sounds::sound( horn_pos, horn_type.bonus, sounds::sound_t::alarm, _( "HOOOOORNK!" ) ); } else if( horn_type.bonus >= 80 ) { //~ Moderate horn sound - sounds::sound( horn_pos, horn_type.bonus, _( "BEEEP!" ) ); + sounds::sound( horn_pos, horn_type.bonus, sounds::sound_t::alarm, _( "BEEEP!" ) ); } else { //~ Weak horn sound - sounds::sound( horn_pos, horn_type.bonus, _( "honk." ) ); + sounds::sound( horn_pos, horn_type.bonus, sounds::sound_t::alarm, _( "honk." ) ); } } @@ -914,7 +914,7 @@ void vehicle::beeper_sound() } //~ Beeper sound - sounds::sound( vp.pos(), vp.info().bonus, _( "beep!" ) ); + sounds::sound( vp.pos(), vp.info().bonus, sounds::sound_t::alarm, _( "beep!" ) ); } } @@ -932,7 +932,7 @@ void vehicle::play_chimes() } for( const vpart_reference &vp : get_enabled_parts( "CHIMES" ) ) { - sounds::sound( vp.pos(), 40, + sounds::sound( vp.pos(), 40, sounds::sound_t::music, _( "a simple melody blaring from the loudspeakers." ) ); } } @@ -947,7 +947,7 @@ void vehicle::operate_plow() const int speed = velocity; const int v_damage = rng( 3, speed ); damage( vp.part_index(), v_damage, DT_BASH, false ); - sounds::sound( start_plow, v_damage, _( "Clanggggg!" ) ); + sounds::sound( start_plow, v_damage, sounds::sound_t::combat, _( "Clanggggg!" ) ); } } } @@ -962,7 +962,7 @@ void vehicle::operate_rockwheel() const int speed = velocity; const int v_damage = rng( 3, speed ); damage( vp.part_index(), v_damage, DT_BASH, false ); - sounds::sound( start_dig, v_damage, _( "Clanggggg!" ) ); + sounds::sound( start_dig, v_damage, sounds::sound_t::combat, _( "Clanggggg!" ) ); } } } @@ -991,7 +991,7 @@ void vehicle::operate_reaper() *seed.type, plant_produced, seed_produced, false ) ) { g->m.add_item_or_charges( reaper_pos, i ); } - sounds::sound( reaper_pos, rng( 10, 25 ), _( "Swish" ) ); + sounds::sound( reaper_pos, rng( 10, 25 ), sounds::sound_t::combat, _( "Swish" ) ); if( vp.has_feature( "CARGO" ) ) { map_stack stack( g->m.i_at( reaper_pos ) ); for( auto iter = stack.begin(); iter != stack.end(); ) { @@ -1023,7 +1023,7 @@ void vehicle::operate_planter() } else if( !g->m.has_flag( "DIGGABLE", loc ) ) { //If it isn't diggable terrain, then it will most likely be damaged. damage( planter_id, rng( 1, 10 ), DT_BASH, false ); - sounds::sound( loc, rng( 10, 20 ), _( "Clink" ) ); + sounds::sound( loc, rng( 10, 20 ), sounds::sound_t::combat, _( "Clink" ) ); } if( !i->count_by_charges() || i->charges == 1 ) { i->set_age( 0 ); @@ -1052,7 +1052,8 @@ void vehicle::operate_scoop() _( "Whirrrr" ), _( "Ker-chunk" ), _( "Swish" ), _( "Cugugugugug" ) } }; - sounds::sound( global_part_pos3( scoop ), rng( 20, 35 ), random_entry_ref( sound_msgs ) ); + sounds::sound( global_part_pos3( scoop ), rng( 20, 35 ), sounds::sound_t::combat, + random_entry_ref( sound_msgs ) ); std::vector parts_points; for( const tripoint ¤t : g->m.points_in_radius( global_part_pos3( scoop ), 1 ) ) { @@ -1085,7 +1086,7 @@ void vehicle::operate_scoop() //The scoop gets a lot louder when breaking an item. sounds::sound( position, rng( 10, that_item_there->volume() / units::legacy_volume_factor * 2 + 10 ), - _( "BEEEThump" ) ); + sounds::sound_t::combat, _( "BEEEThump" ) ); } const int battery_deficit = discharge_battery( that_item_there->weight() / 1_gram * -part_epower_w( scoop ) / rng( 8, 15 ) ); @@ -1110,7 +1111,8 @@ void vehicle::alarm() _( "WHOOP WHOOP" ), _( "NEEeu NEEeu NEEeu" ), _( "BLEEEEEEP" ), _( "WREEP" ) } }; - sounds::sound( global_pos3(), static_cast( rng( 45, 80 ) ), random_entry_ref( sound_msgs ) ); + sounds::sound( global_pos3(), static_cast( rng( 45, 80 ) ), + sounds::sound_t::alarm, random_entry_ref( sound_msgs ) ); if( one_in( 1000 ) ) { is_alarm_on = false; } From fe3a4bde064641383f1c97c34311791fd99ed3f7 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Wed, 19 Dec 2018 14:27:59 -0600 Subject: [PATCH 2/2] npc, sound: pass sound information to NPCs call process_sound_markers() on all NPCs within MAP_VIEW_DISTANCE of the player, and have them call a new npc::handle_sound() function for each sound marker, and then bail before actually placing the sound markers which remains a player only function. npc::handle_sound() ignores speech (for not) and sounds from locations that the NPC can see. If the NPC currently has a low assessment of danger and hears combat noises or movement, they will complain to the player. --- data/json/npcs/talk_tags.json | 22 ++++++++++++++++++++++ src/game.cpp | 7 +++++++ src/npc.h | 4 ++++ src/npcmove.cpp | 4 ++++ src/npctalk.cpp | 26 ++++++++++++++++++++++++++ src/sounds.cpp | 5 +++++ 6 files changed, 68 insertions(+) diff --git a/data/json/npcs/talk_tags.json b/data/json/npcs/talk_tags.json index ecf56cbc22d45..3a887772ce490 100644 --- a/data/json/npcs/talk_tags.json +++ b/data/json/npcs/talk_tags.json @@ -707,6 +707,28 @@ "You're gonna rot in hell for this!" ] }, + { + "type": "snippet", + "category": "", + "text": [ + "That sounds bad.", + "Be alert, something is up!", + "Did you hear that?", + "What's that noise?", + "Who's there?" + ] + }, + { + "type": "snippet", + "category": "", + "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": "", diff --git a/src/game.cpp b/src/game.cpp index aef4ee60224b2..14040b1fe0eff 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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. diff --git a/src/npc.h b/src/npc.h index e2886106a9e5c..af9c467f38822 100644 --- a/src/npc.h +++ b/src/npc.h @@ -610,6 +610,10 @@ class npc : public player void warn_about( const std::string &type, const time_duration &d = 10_minutes, const std::string &name = "" ); bool complain(); // Finds something to complain about and complains. Returns if complained. + + void handle_sound( int priority, const std::string &description, int heard_volume, + const tripoint &spos ); + /* shift() works much like monster::shift(), and is called when the player moves * from one submap to an adjacent submap. It updates our position (shifting by * 12 tiles), as well as our plans. diff --git a/src/npcmove.cpp b/src/npcmove.cpp index f46458f69448b..79365fd03fd1c 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -3214,6 +3214,10 @@ void npc::warn_about( const std::string &type, const time_duration &d, const std snip = is_enemy() ? "" : ""; } else if( type == "kill_player" ) { snip = is_enemy() ? "" : ""; + } else if( type == "combat_noise" ) { + snip = ""; + } else if( type == "movement_noise" ) { + snip = ""; } else { return; } diff --git a/src/npctalk.cpp b/src/npctalk.cpp index da72f364e8a7b..40e05fbb947c2 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -236,6 +236,32 @@ void game::chat() refresh_all(); } +void npc::handle_sound( int priority, const std::string &description, int heard_volume, + const tripoint &spos ) +{ + if( priority == 7 || sees( spos ) ) { + return; + } + add_msg( m_debug, "%s heard '%s', priority %d at volume %d from %d:%d, my pos %d:%d", + disp_name(), description, priority, heard_volume, spos.x, spos.y, pos().x, pos().y ); + switch( priority ) { + case 6: // combat noise is only worth comment if we're not fighting + // TODO: Brave NPCs should be less jumpy + if( ai_cache.total_danger < 1.0f ) { + warn_about( "combat_noise", rng( 1, 10 ) * 1_minutes ); + } + break; + case 4: // movement is is only worth comment if we're not fighting and out of a vehicle + if( ai_cache.total_danger < 1.0f && !in_vehicle ) { + // replace with warn_about when that merges + warn_about( "footsteps", rng( 1, 10 ) * 1_minutes, description ); + } + break; + default: + break; + }; +} + void npc_chatbin::check_missions() { // TODO: or simply fail them? Some missions might only need to be reported. diff --git a/src/sounds.cpp b/src/sounds.cpp index b333f5fb92050..a5dd618aa615a 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -314,6 +314,11 @@ void sounds::process_sound_markers( player *p ) } const std::string &description = sound.description.empty() ? "a noise" : sound.description; + if( p->is_npc() ) { + npc *guy = dynamic_cast( p ); + guy->handle_sound( static_cast( sound.category ), description, heard_volume, pos ); + continue; + } // don't print our own noise or things without descriptions if( !sound.ambient && ( pos != p->pos() ) && !g->m.pl_sees( pos, distance_to_sound ) ) {