From bc909ac41295b535d7545bce74c59f74268c436b Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Wed, 1 Nov 2023 01:56:36 -0500 Subject: [PATCH] feat(balance, port): arpen reduction via layered armor, make shields block ranged hits (#3522) * Fix shields, port over ablative arpen effects Co-Authored-By: Dillon Matchett <4514073+bombasticSlacks@users.noreply.github.com> * Fix shields, port over ablative arpen effects Co-Authored-By: Dillon Matchett <4514073+bombasticSlacks@users.noreply.github.com> Co-Authored-By: anoobindisguise <56016372+anoobindisguise@users.noreply.github.com> * Rework thing per feedback Co-Authored-By: KheirFerrum <102964889+KheirFerrum@users.noreply.github.com> --------- Co-authored-by: Dillon Matchett <4514073+bombasticSlacks@users.noreply.github.com> Co-authored-by: anoobindisguise <56016372+anoobindisguise@users.noreply.github.com> Co-authored-by: KheirFerrum <102964889+KheirFerrum@users.noreply.github.com> --- src/character.cpp | 4 +++- src/item.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index b74f734c10b9..cbef2a53f4f5 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -10848,7 +10848,7 @@ bool Character::block_ranged_hit( Creature *source, bodypart_id &bp_hit, damage_ } // Modify chance based on coverage and blocking ability, with lowered chance if hitting the legs. Exclude armguards here. const float technic_modifier = coverage_modifier_by_technic( level, is_leg_hit( bp_hit ) ); - const float shield_coverage_modifier = shield.get_coverage( bp_hit ) * technic_modifier; + const float shield_coverage_modifier = shield.get_avg_coverage() * technic_modifier; add_msg( m_debug, _( "block_ranged_hit success rate: %i%%" ), static_cast( shield_coverage_modifier ) ); @@ -10870,6 +10870,8 @@ bool Character::block_ranged_hit( Creature *source, bodypart_id &bp_hit, damage_ const float block_amount = get_block_amount( shield, elem ); elem.amount -= block_amount; blocked_damage += block_amount; + const resistances res = resistances( shield ); + elem.res_pen = std::max( 0.0f, elem.res_pen - res.type_resist( elem.type ) ); } blocked_damage = std::min( total_damage, blocked_damage ); add_msg( m_debug, _( "expected base damage: %i" ), total_damage ); diff --git a/src/item.cpp b/src/item.cpp index 8fe1b955f678..ba8cbd60a054 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -6194,8 +6194,10 @@ void item::mitigate_damage( damage_unit &du ) const { const resistances res = resistances( *this ); const float mitigation = res.get_effective_resist( du ); - du.amount -= mitigation; - du.amount = std::max( 0.0f, du.amount ); + // get_effective_resist subtracts the flat penetration value before multiplying the remaining armor. + // therefore, res_pen is reduced by the full value of the item's armor value even though mitigation might be smaller (such as an attack with a 0.5 armor multiplier) + du.res_pen = std::max( 0.0f, du.res_pen - res.type_resist( du.type ) ); + du.amount = std::max( 0.0f, du.amount - mitigation ); } int item::damage_resist( damage_type dt, bool to_self ) const