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

Fancy clothing affects NPC opinions #34245

Closed
wants to merge 6 commits into from
Closed
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
39 changes: 22 additions & 17 deletions src/morale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(2 * super_fancy_items.size()) +
2 * std::min(static_cast<int>(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();
Expand Down Expand Up @@ -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<int>( 2 * super_fancy_items.size() ) +
2 * std::min( static_cast<int>( 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()
Expand Down
1 change: 1 addition & 0 deletions src/morale.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,9 @@ class player : public Character
bool has_activity( const std::vector<activity_id> &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,
Expand Down