From d4bcc222afeeac03f31e2a45dbc3c0975dafae72 Mon Sep 17 00:00:00 2001 From: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:47:43 -0400 Subject: [PATCH] Factions don't mind the player smashing zombie corpses --- src/handle_action.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 9a616997a2db8..df86108296d87 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -902,6 +902,12 @@ static void haul_toggle() get_avatar().toggle_hauling(); } +static bool is_smashable_corpse( const item &maybe_corpse ) +{ + return maybe_corpse.is_corpse() && maybe_corpse.damage() < maybe_corpse.max_damage() && + maybe_corpse.can_revive(); +} + static void smash() { const bool allow_floor_bash = debug_mode; // Should later become "true" @@ -911,7 +917,17 @@ static void smash() } tripoint_bub_ms smashp = tripoint_bub_ms( *smashp_ ); - if( !g->warn_player_maybe_anger_local_faction( true ) ) { + // Little hack: If there's a smashable corpse, it'll always be bashed first. So don't bother warning about + // terrain smashing unless it's actually possible. + bool smashable_corpse_at_target = false; + for( const item &maybe_corpse : get_map().i_at( smashp ) ) { + if( is_smashable_corpse( maybe_corpse ) ) { + smashable_corpse_at_target = true; + break; + } + } + + if( !smashable_corpse_at_target && !g->warn_player_maybe_anger_local_faction( true ) ) { return; // player declined to smash faction's stuff } @@ -1003,8 +1019,7 @@ avatar::smash_result avatar::smash( tripoint_bub_ms &smashp ) bool should_pulp = false; for( const item &maybe_corpse : here.i_at( smashp ) ) { - if( maybe_corpse.is_corpse() && maybe_corpse.damage() < maybe_corpse.max_damage() && - maybe_corpse.can_revive() ) { + if( is_smashable_corpse( maybe_corpse ) ) { if( maybe_corpse.get_mtype()->bloodType()->has_acid && !is_immune_field( fd_acid ) ) { if( !query_yn( _( "Are you sure you want to pulp an acid filled corpse?" ) ) ) {