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

Jsonize and simplify starving warnings #36989

Merged
merged 5 commits into from
Jan 24, 2020
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
40 changes: 40 additions & 0 deletions data/json/snippets/health_msgs.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,45 @@
"type": "snippet",
"category": "health_horrible",
"text": "Awareness seems to only come with a battle… and your body seem to be on its side."
},
{
"type": "snippet",
"category": "empty_starving",
"text": "You're too weak to be hungry anymore. Is this what starving to death feels like?"
},
{
"type": "snippet",
"category": "starving",
"text": "Even though you've eaten not too long ago you still feel drained of energy. It will take more than that to get you back up."
},
{
"type": "snippet",
"category": "empty_emaciated",
"text": "Your empty stomach gnaws at you. You really need something to eat."
},
{
"type": "snippet",
"category": "emaciated",
"text": "You are EMACIATED!"
},
{
"type": "snippet",
"category": "empty_malnutrition",
"text": "You feel weak due to malnutrition."
},
{
"type": "snippet",
"category": "malnutrition",
"text": "Despite having something in your stomach, you still feel like you haven't eaten in days…"
},
{
"type": "snippet",
"category": "empty_low_cal",
"text": "You've lost quite a bit of weight recently. You might want to eat richer food."
},
{
"type": "snippet",
"category": "low_cal",
"text": "You feel that your body needs more nutritious food."
}
]
24 changes: 14 additions & 10 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4128,29 +4128,33 @@ void Character::check_needs_extremes()
hp_cur[hp_torso] = 0;
} else {
if( calendar::once_every( 1_hours ) ) {
std::string message;
std::string category;
if( stomach.contains() <= stomach.capacity( *this ) / 4 ) {
if( get_kcal_percent() < 0.1f ) {
message = _( "Food…" );
category = "starving";
} else if( get_kcal_percent() < 0.25f ) {
message = _( "Due to insufficient nutrition, your body is suffering from starvation." );
category = "emaciated";
} else if( get_kcal_percent() < 0.5f ) {
message = _( "Despite having something in your stomach, you still feel like you haven't eaten in days…" );
category = "malnutrition";
} else if( get_kcal_percent() < 0.8f ) {
message = _( "Your stomach feels so empty…" );
category = "low_cal";
}
} else {
if( get_kcal_percent() < 0.1f ) {
message = _( "Food…" );
category = "empty_starving";
} else if( get_kcal_percent() < 0.25f ) {
message = _( "You are EMACIATED!" );
category = "empty_emaciated";
} else if( get_kcal_percent() < 0.5f ) {
message = _( "You feel weak due to malnutrition." );
category = "empty_malnutrition";
} else if( get_kcal_percent() < 0.8f ) {
message = _( "You feel that your body needs more nutritious food." );
category = "empty_low_cal";
}
}
add_msg_if_player( m_warning, message );
if( !category.empty() ) {
const translation message = SNIPPET.random_from_category( category ).value_or( translation() );
add_msg_if_player( m_warning, message );
}

}
}
}
Expand Down