Skip to content

Commit

Permalink
Use breathability to measure protection against liquid ammo
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed May 19, 2024
1 parent 1fdb21c commit 44bb7dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,19 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack
}
}

if( attack.proj.proj_effects.count( "LIQUID" ) > 0 ) {
if( Character *char_target = as_character() ) {
// clothing_wetness_mult returns the effective permeability of the armor on bp_hit
// as a float between 0 and 1
// 0 permeability means no liquid touches the skin and the damage is negated
// 1 permeability means all liquid touches the skin and no damage is negated
float permeability = char_target->worn.clothing_wetness_mult( hit_selection.bp_hit );
permeability = std::clamp( permeability, 0.0f, 1.0f );

impact.mult_damage( permeability );
}
}

dealt_dam = deal_damage( source, hit_selection.bp_hit, impact, wp_attack_copy );
// Force damage instance to match the selected body point
dealt_dam.bp_hit = hit_selection.bp_hit;
Expand Down
4 changes: 4 additions & 0 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2053,6 +2053,10 @@ static projectile make_gun_projectile( const item &gun )
proj.range = gun.gun_range();
proj.proj_effects = gun.ammo_effects();

if( gun.ammo_data()->phase == phase_id::LIQUID ) {
proj.proj_effects.insert( "LIQUID" );
}

auto &fx = proj.proj_effects;

if( ( gun.ammo_data() && gun.ammo_data()->phase == phase_id::LIQUID ) ||
Expand Down

0 comments on commit 44bb7dc

Please sign in to comment.