From 0ed1b339585ab1b54cad4f1f0a5c57bbd396151f Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Jan 2020 00:16:02 +0100 Subject: [PATCH 1/4] Jsonize and simplify starving warnings --- data/json/snippets/health_msgs.json | 25 ++++++++++++++++++++ src/player.cpp | 36 +++++++++++------------------ 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/data/json/snippets/health_msgs.json b/data/json/snippets/health_msgs.json index 9ade8a81653f6..dddaed1bc41cd 100644 --- a/data/json/snippets/health_msgs.json +++ b/data/json/snippets/health_msgs.json @@ -148,5 +148,30 @@ "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": "starving", + "text": "Food…" + }, + { + "type": "snippet", + "category": "emaciated", + "text": "Due to insufficient nutrition, your body is suffering from starvation." + }, + { + "type": "snippet", + "category": "emaciated", + "text": "You are EMACIATED!" + }, + { + "type": "snippet", + "category": "malnutrition", + "text": "You feel weak due to malnutrition." + }, + { + "type": "snippet", + "category": "low_cal", + "text": "You feel that your body needs more nutritious food." } ] diff --git a/src/player.cpp b/src/player.cpp index 3355c4a32e826..242221597893b 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2400,29 +2400,21 @@ void player::check_needs_extremes() hp_cur[hp_torso] = 0; } else { if( calendar::once_every( 1_hours ) ) { - std::string message; - if( stomach.contains() <= stomach.capacity( *this ) / 4 ) { - if( get_kcal_percent() < 0.1f ) { - message = _( "Food…" ); - } else if( get_kcal_percent() < 0.25f ) { - message = _( "Due to insufficient nutrition, your body is suffering from starvation." ); - } else if( get_kcal_percent() < 0.5f ) { - message = _( "Despite having something in your stomach, you still feel like you haven't eaten in days…" ); - } else if( get_kcal_percent() < 0.8f ) { - message = _( "Your stomach feels so empty…" ); - } - } else { - if( get_kcal_percent() < 0.1f ) { - message = _( "Food…" ); - } else if( get_kcal_percent() < 0.25f ) { - message = _( "You are EMACIATED!" ); - } else if( get_kcal_percent() < 0.5f ) { - message = _( "You feel weak due to malnutrition." ); - } else if( get_kcal_percent() < 0.8f ) { - message = _( "You feel that your body needs more nutritious food." ); - } + std::string category = "good"; + if( get_kcal_percent() < 0.1f ) { + category = "starving"; + } else if( get_kcal_percent() < 0.25f ) { + category = "emaciated"; + } else if( get_kcal_percent() < 0.5f ) { + category = "malnutrition"; + } else if( get_kcal_percent() < 0.8f ) { + category = "low_cal"; } - add_msg_if_player( m_warning, message ); + if( category != "good" ) { + const translation message = SNIPPET.random_from_category( category ).value_or( translation() ); + add_msg_if_player( m_warning, message ); + } + } } } From eaeabdcd9dd744e3b25f6f6dae04f56b98729e8f Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Mon, 13 Jan 2020 19:35:36 +0100 Subject: [PATCH 2/4] Empty stomach variants --- data/json/snippets/health_msgs.json | 23 +++++++++++++++++---- src/player.cpp | 32 ++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/data/json/snippets/health_msgs.json b/data/json/snippets/health_msgs.json index dddaed1bc41cd..058d50b7526d1 100644 --- a/data/json/snippets/health_msgs.json +++ b/data/json/snippets/health_msgs.json @@ -149,15 +149,20 @@ "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 that what starving to death feels like?" + }, { "type": "snippet", "category": "starving", - "text": "Food…" + "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": "emaciated", - "text": "Due to insufficient nutrition, your body is suffering from starvation." + "category": "empty_emaciated", + "text": "Your empty stomach gnaws at you. You really need something to eat." }, { "type": "snippet", @@ -166,9 +171,19 @@ }, { "type": "snippet", - "category": "malnutrition", + "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", diff --git a/src/player.cpp b/src/player.cpp index 242221597893b..ef2c2774f7aca 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2400,17 +2400,29 @@ void player::check_needs_extremes() hp_cur[hp_torso] = 0; } else { if( calendar::once_every( 1_hours ) ) { - std::string category = "good"; - if( get_kcal_percent() < 0.1f ) { - category = "starving"; - } else if( get_kcal_percent() < 0.25f ) { - category = "emaciated"; - } else if( get_kcal_percent() < 0.5f ) { - category = "malnutrition"; - } else if( get_kcal_percent() < 0.8f ) { - category = "low_cal"; + std::string category; + if( stomach.contains() <= stomach.capacity( *this ) / 4 ) { + if( get_kcal_percent() < 0.1f ) { + category = "starving"; + } else if( get_kcal_percent() < 0.25f ) { + category = "emaciated"; + } else if( get_kcal_percent() < 0.5f ) { + category = "malnutrition"; + } else if( get_kcal_percent() < 0.8f ) { + category = "low_cal"; + } + } else { + if( get_kcal_percent() < 0.1f ) { + category = "empty_starving"; + } else if( get_kcal_percent() < 0.25f ) { + category = "empty_emaciated"; + } else if( get_kcal_percent() < 0.5f ) { + category = "empty_malnutrition"; + } else if( get_kcal_percent() < 0.8f ) { + category = "empty_low_cal"; + } } - if( category != "good" ) { + if( !category.empty() ) { const translation message = SNIPPET.random_from_category( category ).value_or( translation() ); add_msg_if_player( m_warning, message ); } From 2c112c7caf32c50a887fc0fd8137cbece90f1bcf Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 19 Jan 2020 21:09:11 +0100 Subject: [PATCH 3/4] this --- data/json/snippets/health_msgs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/snippets/health_msgs.json b/data/json/snippets/health_msgs.json index 058d50b7526d1..a70ea9e0db995 100644 --- a/data/json/snippets/health_msgs.json +++ b/data/json/snippets/health_msgs.json @@ -152,7 +152,7 @@ { "type": "snippet", "category": "empty_starving", - "text": "You're too weak to be hungry anymore. Is that what starving to death feels like?" + "text": "You're too weak to be hungry anymore. Is this what starving to death feels like?" }, { "type": "snippet", From d386d3c2e403e4568507f65a39684d0e69c8ba9b Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Fri, 24 Jan 2020 10:03:57 +0300 Subject: [PATCH 4/4] Update character.cpp --- src/character.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index aa7b4a99a2be7..483e2bc178cd8 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -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 ); + } + } } }