Skip to content

Commit

Permalink
Warmth is now more granular on sub covered limbs (#57096)
Browse files Browse the repository at this point in the history
* warmth fixes

* CLANNNNNG
  • Loading branch information
bombasticSlacks authored Apr 24, 2022
1 parent 30af53e commit 968108c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/character_attire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,7 @@ std::map<bodypart_id, int> outfit::warmth( const Character &guy ) const
std::map<bodypart_id, int> total_warmth;
for( const bodypart_id &bp : guy.get_all_body_parts() ) {
double warmth_val = 0.0;
float limb_coverage = 0.0f;
const float wetness_pct = guy.get_part_wetness_percentage( bp );
for( const item &clothing : worn ) {
if( !clothing.covers( bp ) ) {
Expand All @@ -1840,7 +1841,24 @@ std::map<bodypart_id, int> outfit::warmth( const Character &guy ) const
if( !clothing.made_of( material_wool ) ) {
warmth_val *= 1.0 - 0.66 * wetness_pct;
}
total_warmth[bp] += std::round( warmth_val );
// calculate how much of the limb the armor ideally covers
// idea being that an item that covers the shoulders and torso shouldn't
// heat the whole arm like it covers it
// TODO: fully configure this per armor entry
if( !clothing.has_sublocations() ) {
// if it doesn't have sublocations it has 100% covered
limb_coverage = 100;
} else {
for( const sub_bodypart_str_id &sbp : bp->sub_parts ) {
if( !clothing.covers( sbp ) ) {
continue;
}

// TODO: handle non 100% sub body part coverages
limb_coverage += sbp->max_coverage;
}
}
total_warmth[bp] += std::round( warmth_val * limb_coverage / 100.0f );
}
total_warmth[bp] += guy.get_effect_int( effect_heating_bionic, bp );
}
Expand Down

0 comments on commit 968108c

Please sign in to comment.