Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bodygraph with wetness data #63158

Merged
merged 1 commit into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/character_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ void Character::update_body_wetness( const w_point &weather )
}

// Add effects to track wetness
const int updatedWetness = get_part_wetness( bp );
const int wetnessCapacity = get_part_drench_capacity( bp );
if( updatedWetness < wetnessCapacity * .3 ) {
add_effect( effect_wet, 1_turns, bp, true, 1 );
} else if( updatedWetness < wetnessCapacity * .6 ) {
add_effect( effect_wet, 1_turns, bp, true, 2 );
} else if( updatedWetness < wetnessCapacity ) {
add_effect( effect_wet, 1_turns, bp, true, 3 );
if( get_part_wetness( bp ) > 0 ) {
const float wetness_pct = get_part_wetness_percentage( bp );
const int effect_level =
wetness_pct < BODYWET_PERCENT_WET ? 1 :
wetness_pct < BODYWET_PERCENT_SOAKED ? 2 :
3;

add_effect( effect_wet, 1_turns, bp, true, effect_level );
}
}
}
Expand Down
20 changes: 18 additions & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ static const itype_id fuel_type_muscle( "muscle" );
// Cache for the overmap widget string
static disp_overmap_cache disp_om_cache;
// Cache for the bodygraph widget string
static std::array<disp_bodygraph_cache, 4> disp_bg_cache = { {
static std::array<disp_bodygraph_cache, 5> disp_bg_cache = { {
disp_bodygraph_cache( bodygraph_var::hp ),
disp_bodygraph_cache( bodygraph_var::temp ),
disp_bodygraph_cache( bodygraph_var::encumb ),
disp_bodygraph_cache( bodygraph_var::status )
disp_bodygraph_cache( bodygraph_var::status ),
disp_bodygraph_cache( bodygraph_var::wet )
}
};

Expand Down Expand Up @@ -1600,6 +1601,21 @@ nc_color display::get_bodygraph_bp_color( const Character &u, const bodypart_id
case bodygraph_var::status: {
return display::limb_color( u, bid, true, true, true );
}
case bodygraph_var::wet: {
const int cur_wet = u.get_part_wetness( bid );
if( cur_wet == 0 ) {
return c_light_gray; // dry
} else {
const float cur_wet = u.get_part_wetness_percentage( bid );
if( cur_wet < BODYWET_PERCENT_WET ) {
return c_light_cyan;
} else if( cur_wet < BODYWET_PERCENT_SOAKED ) {
return c_light_blue;
} else {
return c_blue; // maximum wetness
}
}
}
// Fall-through - invalid
case bodygraph_var::last:
break;
Expand Down
1 change: 1 addition & 0 deletions src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum class bodygraph_var : int {
temp, // temperature
encumb, // encumbrance
status, // limb status (bite, bleeding, ...)
wet, // wetness
last // END OF ENUMS
};

Expand Down
7 changes: 7 additions & 0 deletions src/weather.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ static constexpr int BODYTEMP_SCORCHING = 9500;
static constexpr int BODYTEMP_THRESHOLD = 500;
///@}

// Wetness percentage 0.0f is DRY
// Level 1 wetness (DAMP) is between 0.0f and Level 2
// Level 2 wetness percentage
static constexpr float BODYWET_PERCENT_WET = 0.3f;
// Level 3 wetness percentage
static constexpr float BODYWET_PERCENT_SOAKED = 0.6f;

// Rough tresholds for sunlight intensity in W/m2.
namespace irradiance
{
Expand Down
9 changes: 9 additions & 0 deletions src/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ std::string enum_to_string<widget_var>( widget_var data )
return "body_graph_encumb";
case widget_var::body_graph_status:
return "body_graph_status";
case widget_var::body_graph_wet:
return "body_graph_wet";
case widget_var::bp_armor_outer_text:
return "bp_armor_outer_text";
case widget_var::carry_weight_text:
Expand Down Expand Up @@ -1000,6 +1002,7 @@ bool widget::uses_text_function() const
case widget_var::body_graph_temp:
case widget_var::body_graph_encumb:
case widget_var::body_graph_status:
case widget_var::body_graph_wet:
case widget_var::bp_armor_outer_text:
case widget_var::carry_weight_text:
case widget_var::compass_text:
Expand Down Expand Up @@ -1092,6 +1095,12 @@ std::string widget::color_text_function_string( const avatar &ava, unsigned int
update_height = true; // Dynamically adjusted height
apply_color = false; // Already colorized
break;
case widget_var::body_graph_wet:
desc.first = display::colorized_bodygraph_text( ava, _body_graph,
bodygraph_var::wet, _width == 0 ? max_width : _width, _height_max, _height );
update_height = true; // Dynamically adjusted height
apply_color = false; // Already colorized
break;
case widget_var::bp_armor_outer_text:
desc.first = ava.worn.get_armor_display( only_bp() );
apply_color = false; // Item name already colorized by tname
Expand Down
1 change: 1 addition & 0 deletions src/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum class widget_var : int {
body_graph_temp, // Body graph showing color-coded body part temperature
body_graph_encumb, // Body graph showing color-coded body part encumbrance
body_graph_status, // Body graph showing color-coded body part status (bite, bleeding, ...)
body_graph_wet, // Body graph showing color-coded body part wetness
bp_armor_outer_text, // Outermost armor on body part, with color/damage bars
carry_weight_text, // Weight carried, relative to capacity, in %
compass_text, // Compass / visible threats by cardinal direction
Expand Down