diff --git a/src/morale.cpp b/src/morale.cpp index 2cf12f611a652..c6fe179779d98 100644 --- a/src/morale.cpp +++ b/src/morale.cpp @@ -354,6 +354,24 @@ morale_mult player_morale::get_temper_mult() const return mult; } +int player_morale::get_total_fancy_points() const +{ + const auto bp_bonus = [this](body_part bp, int bonus) -> int { + return ( + body_parts[bp].fancy > 0 || + body_parts[opposite_body_part(bp)].fancy > 0) ? bonus : 0; + }; + return std::min(static_cast(2 * super_fancy_items.size()) + + 2 * std::min(static_cast(no_body_part.fancy), 3) + + bp_bonus(bp_torso, 6) + + bp_bonus(bp_head, 3) + + bp_bonus(bp_eyes, 2) + + bp_bonus(bp_mouth, 2) + + bp_bonus(bp_leg_l, 2) + + bp_bonus(bp_foot_l, 1) + + bp_bonus(bp_hand_l, 1), 20); +} + void player_morale::calculate_percentage() { const morale_mult mult = get_temper_mult(); @@ -817,23 +835,10 @@ void player_morale::update_stylish_bonus() { int bonus = 0; - if( stylish ) { - const auto bp_bonus = [ this ]( body_part bp, int bonus ) -> int { - return ( - body_parts[bp].fancy > 0 || - body_parts[opposite_body_part( bp )].fancy > 0 ) ? bonus : 0; - }; - bonus = std::min( static_cast( 2 * super_fancy_items.size() ) + - 2 * std::min( static_cast( no_body_part.fancy ), 3 ) + - bp_bonus( bp_torso, 6 ) + - bp_bonus( bp_head, 3 ) + - bp_bonus( bp_eyes, 2 ) + - bp_bonus( bp_mouth, 2 ) + - bp_bonus( bp_leg_l, 2 ) + - bp_bonus( bp_foot_l, 1 ) + - bp_bonus( bp_hand_l, 1 ), 20 ); - } - set_permanent( MORALE_PERM_FANCY, bonus ); + if (stylish) { + bonus = get_total_fancy_points(); + } + set_permanent(MORALE_PERM_FANCY, bonus); } void player_morale::update_masochist_bonus() diff --git a/src/morale.h b/src/morale.h index 0addd24aa64cf..55a747fbd6010 100644 --- a/src/morale.h +++ b/src/morale.h @@ -58,6 +58,7 @@ class player_morale int get_total_positive_value() const; int get_total_negative_value() const; + int get_total_fancy_points() const; void on_mutation_gain( const trait_id &mid ); void on_mutation_loss( const trait_id &mid ); diff --git a/src/npc.cpp b/src/npc.cpp index 6b16387c474e2..797bcaa9490ba 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1223,10 +1223,13 @@ void npc::form_opinion( const player &u ) op_of_u.fear += 6; } + // TODO: Opinions for being naked; humans are weird int u_ugly = 0; for( trait_id &mut : u.get_mutations() ) { u_ugly += mut.obj().ugliness; } + // Hey, ugliness ain't all about the body + u_ugly += u.get_clothes_ugliness; op_of_u.fear += u_ugly / 2; op_of_u.trust -= u_ugly / 3; diff --git a/src/player.cpp b/src/player.cpp index d180d4c836907..41f6eb819ab39 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -6383,6 +6383,13 @@ void player::update_body_wetness( const w_point &weather ) // TODO: Make clothing slow down drying } +// Get total worn ugliness bonus +int player::get_clothes_ugliness() const +{ + return -roll_remainder(sqrt(morale->get_total_fancy_points())); + // TODO: Take filthiness into account +} + int player::get_morale_level() const { return morale->get_level(); diff --git a/src/player.h b/src/player.h index b5b94d3936f4e..f64aacb7f3f03 100644 --- a/src/player.h +++ b/src/player.h @@ -1233,7 +1233,9 @@ class player : public Character bool has_activity( const std::vector &types ) const; void cancel_activity(); void resume_backlog_activity(); - + + /** Uses factors like fanciness to get an ugliness value for clothing. */ + int player::get_clothes_ugliness() const int get_morale_level() const; // Modified by traits, &c void add_morale( const morale_type &type, int bonus, int max_bonus = 0, const time_duration &duration = 1_hours,