From 42209cb39a6d278e0c3ad9dafd13bba47d3f9adb Mon Sep 17 00:00:00 2001 From: jc_gargma Date: Mon, 18 Jan 2021 05:01:02 -0800 Subject: Revert the npc sleep on tables patch Add patch to prevent non-faction NPCs becoming sleep deprived --- jc_npcs-eat-when-hungry.patch | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 jc_npcs-eat-when-hungry.patch (limited to 'jc_npcs-eat-when-hungry.patch') diff --git a/jc_npcs-eat-when-hungry.patch b/jc_npcs-eat-when-hungry.patch new file mode 100644 index 0000000..2074bef --- /dev/null +++ b/jc_npcs-eat-when-hungry.patch @@ -0,0 +1,30 @@ +--- a/src/npcmove.cpp ++++ b/src/npcmove.cpp +@@ -1829,7 +1829,9 @@ + } + + if( one_in( 3 ) && ( get_thirst() > 40 || +- get_stored_kcal() + stomach.get_calories() < get_healthy_kcal() * 0.95 ) ) { ++ get_stored_kcal() + stomach.get_calories() < get_healthy_kcal() * 0.95 || ++ ( get_hunger() > 160 && ++ ( get_stored_kcal() + stomach.get_calories() < get_healthy_kcal() ) ) ) ) { + if( consume_food_from_camp() ) { + return npc_noop; + } +@@ -3697,12 +3699,15 @@ + return true; + } + faction *yours = g->u.get_faction(); +- int camp_kcals = std::min( std::max( 0, 19 * get_healthy_kcal() / 20 - get_stored_kcal() - ++ int camp_kcals = std::min( std::max( 0, get_healthy_kcal() - get_stored_kcal() - + stomach.get_calories() ), yours->food_supply ); + if( camp_kcals > 0 ) { + mod_hunger( -camp_kcals ); + mod_stored_kcal( camp_kcals ); + yours->food_supply -= camp_kcals; ++ stomach.mod_calories( camp_kcals ); ++ stomach.mod_contents( -2400_ml ); ++ stomach.mod_contents( 1200_ml ); + return true; + } + return false; -- cgit v1.2.1