Skip to content

Commit

Permalink
feat(balance, port): arpen reduction via layered armor, make shields …
Browse files Browse the repository at this point in the history
…block ranged hits (#3522)

* Fix shields, port over ablative arpen effects

Co-Authored-By: Dillon Matchett <[email protected]>

* Fix shields, port over ablative arpen effects

Co-Authored-By: Dillon Matchett <[email protected]>
Co-Authored-By: anoobindisguise <[email protected]>

* Rework thing per feedback

Co-Authored-By: KheirFerrum <[email protected]>

---------

Co-authored-by: Dillon Matchett <[email protected]>
Co-authored-by: anoobindisguise <[email protected]>
Co-authored-by: KheirFerrum <[email protected]>
  • Loading branch information
4 people authored Nov 1, 2023
1 parent 55c436a commit bc909ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( shield_coverage_modifier ) );
Expand All @@ -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 );
Expand Down
6 changes: 4 additions & 2 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc909ac

Please sign in to comment.