Skip to content

Commit

Permalink
Merge pull request #67494 from Night-Pryanik/messages-in-the-log
Browse files Browse the repository at this point in the history
Enable/disable showing several non-player-related messages in the log
  • Loading branch information
Maleclypse authored Aug 8, 2023
2 parents 6965994 + 90fd870 commit eec0cf5
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 73 deletions.
5 changes: 3 additions & 2 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,13 +1128,14 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack
add_msg_player_or_npc(
m_warning,
_( "You avoid %s projectile!" ),
_( "<npcname> avoids %s projectile." ),
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? _( "<npcname> avoids %s projectile." ) : "",
source->disp_name( true ) );
} else {
add_msg_player_or_npc(
m_warning,
_( "You avoid an incoming projectile!" ),
_( "<npcname> avoids an incoming projectile." ) );
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? _( "<npcname> avoids an incoming projectile." ) :
"" );
}
return;
}
Expand Down
29 changes: 16 additions & 13 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10915,19 +10915,22 @@ point game::place_player( const tripoint &dest_loc, bool quick )
and_the_rest += counts[i];
}
}
if( names.size() == 1 ) {
add_msg( _( "You see here %s." ), names[0] );
} else if( names.size() == 2 ) {
add_msg( _( "You see here %s and %s." ), names[0], names[1] );
} else if( names.size() == 3 ) {
add_msg( _( "You see here %s, %s, and %s." ), names[0], names[1], names[2] );
} else if( and_the_rest < 7 ) {
add_msg( n_gettext( "You see here %s, %s and %d more item.",
"You see here %s, %s and %d more items.",
and_the_rest ),
names[0], names[1], and_the_rest );
} else {
add_msg( _( "You see here %s and many more items." ), names[0] );

if( get_option<bool>( "LOG_ITEMS_ON_THE_GROUND" ) ) {
if( names.size() == 1 ) {
add_msg( _( "You see here %s." ), names[0] );
} else if( names.size() == 2 ) {
add_msg( _( "You see here %s and %s." ), names[0], names[1] );
} else if( names.size() == 3 ) {
add_msg( _( "You see here %s, %s, and %s." ), names[0], names[1], names[2] );
} else if( and_the_rest < 7 ) {
add_msg( n_gettext( "You see here %s, %s and %d more item.",
"You see here %s, %s and %d more items.",
and_the_rest ),
names[0], names[1], and_the_rest );
} else {
add_msg( _( "You see here %s and many more items." ), names[0] );
}
}
}
}
Expand Down
26 changes: 16 additions & 10 deletions src/mattack_actors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool leap_actor::call( monster &z ) const
bool seen = player_view.sees( z ); // We can see them jump...
z.setpos( chosen );
seen |= player_view.sees( z ); // ... or we can see them land
if( seen ) {
if( seen && get_option<bool>( "LOG_MONSTER_MOVEMENT" ) ) {
add_msg( message, z.name() );
}

Expand Down Expand Up @@ -717,17 +717,19 @@ bool melee_actor::call( monster &z ) const
game_message_type msg_type = target->is_avatar() ? m_warning : m_info;
sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ),
sfx::get_heard_angle( z.pos() ) );
target->add_msg_player_or_npc( msg_type, miss_msg_u, miss_msg_npc, z.name(),
body_part_name_accusative( bp_id ) );
target->add_msg_player_or_npc( msg_type, miss_msg_u,
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? miss_msg_npc : to_translation( "" ),
z.name(), body_part_name_accusative( bp_id ) );
return true;
}

if( dodgeable ) {
if( hitspread < 0 ) {
sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ),
sfx::get_heard_angle( z.pos() ) );
target->add_msg_player_or_npc( msg_type, miss_msg_u, miss_msg_npc, mon_name,
body_part_name_accusative( bp_id ) );
target->add_msg_player_or_npc( msg_type, miss_msg_u,
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? miss_msg_npc : to_translation( "" ),
mon_name, body_part_name_accusative( bp_id ) );
return true;
}
}
Expand Down Expand Up @@ -857,8 +859,9 @@ bool melee_actor::call( monster &z ) const
} else {
sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ),
sfx::get_heard_angle( z.pos() ) );
target->add_msg_player_or_npc( msg_type, no_dmg_msg_u, no_dmg_msg_npc, mon_name,
body_part_name_accusative( bp_id ) );
target->add_msg_player_or_npc( msg_type, no_dmg_msg_u,
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? no_dmg_msg_npc : to_translation( "" ),
mon_name, body_part_name_accusative( bp_id ) );
if( !effects_require_dmg ) {
for( const mon_effect_data &eff : effects ) {
if( x_in_y( eff.chance, 100 ) ) {
Expand All @@ -873,7 +876,9 @@ bool melee_actor::call( monster &z ) const
if( throw_strength > 0 ) {
if( g->fling_creature( target, coord_to_angle( z.pos(), target->pos() ),
throw_strength ) ) {
target->add_msg_player_or_npc( msg_type, throw_msg_u, throw_msg_npc, mon_name );
target->add_msg_player_or_npc( msg_type, throw_msg_u,
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? throw_msg_npc : to_translation( "" ),
mon_name );

// Items strapped to you may fall off as you hit the ground
// when you break out of a grab you have a chance to lose some things from your pockets
Expand Down Expand Up @@ -917,8 +922,9 @@ void melee_actor::on_damage( monster &z, Creature &target, dealt_damage_instance
const bodypart_id &bp = dealt.bp_hit ;
const std::string mon_name = get_player_character().sees( z.pos() ) ?
z.disp_name( false, true ) : _( "Something" );
target.add_msg_player_or_npc( msg_type, hit_dmg_u, hit_dmg_npc, mon_name,
body_part_name_accusative( bp ) );
target.add_msg_player_or_npc( msg_type, hit_dmg_u,
get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ? hit_dmg_npc : to_translation( "" ),
mon_name, body_part_name_accusative( bp ) );

for( const mon_effect_data &eff : effects ) {
if( x_in_y( eff.chance, 100 ) ) {
Expand Down
61 changes: 34 additions & 27 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "monster_oracle.h"
#include "mtype.h"
#include "npc.h"
#include "options.h"
#include "pathfinding.h"
#include "pimpl.h"
#include "rng.h"
Expand Down Expand Up @@ -1780,15 +1781,19 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter,
if( flies() ) {
moves -= 100;
force = true;
add_msg_if_player_sees( *this, _( "The %1$s flies over the %2$s." ), name(),
here.has_flag_furn( ter_furn_flag::TFLAG_CLIMBABLE, p ) ? here.furnname( p ) :
here.tername( p ) );
if( get_option<bool>( "LOG_MONSTER_MOVEMENT" ) ) {
add_msg_if_player_sees( *this, _( "The %1$s flies over the %2$s." ), name(),
here.has_flag_furn( ter_furn_flag::TFLAG_CLIMBABLE, p ) ? here.furnname( p ) :
here.tername( p ) );
}
} else if( climbs() ) {
moves -= 150;
force = true;
add_msg_if_player_sees( *this, _( "The %1$s climbs over the %2$s." ), name(),
here.has_flag_furn( ter_furn_flag::TFLAG_CLIMBABLE, p ) ? here.furnname( p ) :
here.tername( p ) );
if( get_option<bool>( "LOG_MONSTER_MOVEMENT" ) ) {
add_msg_if_player_sees( *this, _( "The %1$s climbs over the %2$s." ), name(),
here.has_flag_furn( ter_furn_flag::TFLAG_CLIMBABLE, p ) ? here.furnname( p ) :
here.tername( p ) );
}
}
}
}
Expand Down Expand Up @@ -1827,27 +1832,29 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter,
has_flag( mon_flag_AQUATIC ) || ( can_submerge() && !here.veh_at( destination ) )
) && here.is_divable( destination );

//Birds and other flying creatures flying over the deep water terrain
if( was_water && flies() ) {
if( one_in( 4 ) ) {
add_msg_if_player_sees( *this, m_warning, _( "A %1$s flies over the %2$s!" ),
name(), here.tername( pos() ) );
}
} else if( was_water && !will_be_water ) {
// Use more dramatic messages for swimming monsters
add_msg_if_player_sees( *this, m_warning,
//~ Message when a monster emerges from water
//~ %1$s: monster name, %2$s: leaps/emerges, %3$s: terrain name
pgettext( "monster movement", "A %1$s %2$s from the %3$s!" ),
name(), swims() ||
has_flag( mon_flag_AQUATIC ) ? _( "leaps" ) : _( "emerges" ), here.tername( pos() ) );
} else if( !was_water && will_be_water ) {
add_msg_if_player_sees( *this, m_warning, pgettext( "monster movement",
//~ Message when a monster enters water
//~ %1$s: monster name, %2$s: dives/sinks, %3$s: terrain name
"A %1$s %2$s into the %3$s!" ),
name(), swims() ||
has_flag( mon_flag_AQUATIC ) ? _( "dives" ) : _( "sinks" ), here.tername( destination ) );
if( get_option<bool>( "LOG_MONSTER_MOVEMENT" ) ) {
//Birds and other flying creatures flying over the deep water terrain
if( was_water && flies() ) {
if( one_in( 4 ) ) {
add_msg_if_player_sees( *this, m_warning, _( "A %1$s flies over the %2$s!" ),
name(), here.tername( pos() ) );
}
} else if( was_water && !will_be_water ) {
// Use more dramatic messages for swimming monsters
add_msg_if_player_sees( *this, m_warning,
//~ Message when a monster emerges from water
//~ %1$s: monster name, %2$s: leaps/emerges, %3$s: terrain name
pgettext( "monster movement", "A %1$s %2$s from the %3$s!" ),
name(), swims() ||
has_flag( mon_flag_AQUATIC ) ? _( "leaps" ) : _( "emerges" ), here.tername( pos() ) );
} else if( !was_water && will_be_water ) {
add_msg_if_player_sees( *this, m_warning, pgettext( "monster movement",
//~ Message when a monster enters water
//~ %1$s: monster name, %2$s: dives/sinks, %3$s: terrain name
"A %1$s %2$s into the %3$s!" ),
name(), swims() ||
has_flag( mon_flag_AQUATIC ) ? _( "dives" ) : _( "sinks" ), here.tername( destination ) );
}
}

optional_vpart_position vp_orig = here.veh_at( pos() );
Expand Down
44 changes: 23 additions & 21 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1909,13 +1909,15 @@ bool monster::melee_attack( Creature &target, float accuracy )
add_msg( m_good, _( "Your %1$s hits %2$s for %3$d damage!" ), get_name(), target.disp_name(),
total_dealt );
}
if( !u_see_me && u_see_target ) {
add_msg( _( "Something hits the %1$s!" ), target.disp_name() );
} else if( !u_see_target ) {
add_msg( _( "The %1$s hits something!" ), name() );
} else {
//~ %1$s: attacker name, %2$s: target creature name
add_msg( _( "The %1$s hits %2$s!" ), name(), target.disp_name() );
if( get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ) {
if( !u_see_me && u_see_target ) {
add_msg( _( "Something hits the %1$s!" ), target.disp_name() );
} else if( !u_see_target ) {
add_msg( _( "The %1$s hits something!" ), name() );
} else {
//~ %1$s: attacker name, %2$s: target creature name
add_msg( _( "The %1$s hits %2$s!" ), name(), target.disp_name() );
}
}
}
} else if( target.is_avatar() ) {
Expand All @@ -1941,7 +1943,7 @@ bool monster::melee_attack( Creature &target, float accuracy )
body_part_name_accusative( dealt_dam.bp_hit ),
target.disp_name( true ),
target.skin_name() );
} else {
} else if( get_option<bool>( "LOG_MONSTER_ATTACK_MONSTER" ) ) {
//~ $1s is monster name, %2$s is that monster target name,
//~ $3s is target armor name.
add_msg( _( "%1$s hits %2$s but is stopped by its %3$s." ),
Expand Down Expand Up @@ -2127,13 +2129,13 @@ bool monster::move_effects( bool )
bool immediate_break = type->in_species( species_FISH ) || type->in_species( species_MOLLUSK ) ||
type->in_species( species_ROBOT ) || type->bodytype == "snake" || type->bodytype == "blob";
if( !immediate_break && rng( 0, 900 ) > type->melee_dice * type->melee_sides * 1.5 ) {
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s struggles to break free of its bonds." ), name() );
}
} else if( immediate_break ) {
remove_effect( effect_tied );
if( tied_item ) {
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s easily slips out of its bonds." ), name() );
}
here.add_item_or_charges( pos(), *tied_item );
Expand All @@ -2147,7 +2149,7 @@ bool monster::move_effects( bool )
here.add_item_or_charges( pos(), *tied_item );
}
tied_item.reset();
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
if( broken ) {
add_msg( _( "The %s snaps the bindings holding it down." ), name() );
} else {
Expand All @@ -2161,11 +2163,11 @@ bool monster::move_effects( bool )
}
if( has_effect( effect_downed ) ) {
if( rng( 0, 40 ) > type->melee_dice * type->melee_sides * 1.5 ) {
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s struggles to stand." ), name() );
}
} else {
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s climbs to its feet!" ), name() );
}
remove_effect( effect_downed );
Expand All @@ -2174,7 +2176,7 @@ bool monster::move_effects( bool )
}
if( has_effect( effect_webbed ) ) {
if( x_in_y( type->melee_dice * type->melee_sides, 6 * get_effect_int( effect_webbed ) ) ) {
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s breaks free of the webs!" ), name() );
}
remove_effect( effect_webbed );
Expand All @@ -2184,7 +2186,7 @@ bool monster::move_effects( bool )
if( has_effect( effect_lightsnare ) ) {
if( x_in_y( type->melee_dice * type->melee_sides, 12 ) ) {
remove_effect( effect_lightsnare );
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s escapes the light snare!" ), name() );
}
}
Expand All @@ -2196,7 +2198,7 @@ bool monster::move_effects( bool )
remove_effect( effect_heavysnare );
here.spawn_item( pos(), "rope_6" );
here.spawn_item( pos(), "snare_trigger" );
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s escapes the heavy snare!" ), name() );
}
}
Expand All @@ -2207,7 +2209,7 @@ bool monster::move_effects( bool )
if( type->melee_dice * type->melee_sides >= 18 ) {
if( x_in_y( type->melee_dice * type->melee_sides, 200 ) ) {
remove_effect( effect_beartrap );
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s escapes the bear trap!" ), name() );
}
}
Expand All @@ -2217,7 +2219,7 @@ bool monster::move_effects( bool )
if( has_effect( effect_crushed ) ) {
if( x_in_y( type->melee_dice * type->melee_sides, 100 ) ) {
remove_effect( effect_crushed );
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s frees itself from the rubble!" ), name() );
}
}
Expand All @@ -2233,7 +2235,7 @@ bool monster::move_effects( bool )
if( rng( 0, 40 ) > type->melee_dice * type->melee_sides ) {
return false;
} else {
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s escapes the pit!" ), name() );
}
remove_effect( effect_in_pit );
Expand All @@ -2259,7 +2261,7 @@ bool monster::move_effects( bool )
if( grabber == nullptr ) {
remove_effect( grab.get_id() );
add_msg_debug( debugmode::DF_MATTACK, "Orphan grab found and removed" );
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s is no longer grabbed!" ), name() );
}
continue;
Expand All @@ -2271,7 +2273,7 @@ bool monster::move_effects( bool )
if( !x_in_y( monster, grab_str ) ) {
return false;
} else {
if( u_see_me ) {
if( u_see_me && get_option<bool>( "LOG_MONSTER_MOVE_EFFECTS" ) ) {
add_msg( _( "The %s breaks free from the %s's grab!" ), name(), grabber->name() );
}
remove_effect( grab.get_id() );
Expand Down
Loading

0 comments on commit eec0cf5

Please sign in to comment.