Skip to content

Commit

Permalink
Jsonize and simplify starving warnings (#36989)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman authored and ZhilkinSerg committed Jan 24, 2020
1 parent 35a949b commit 6d9a296
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
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

0 comments on commit 6d9a296

Please sign in to comment.