summaryrefslogtreecommitdiff
path: root/jc_npcs-eat-when-hungry.patch
blob: 1c7bf0c56f9e1feeb1592d796c324f195cc47240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--- a/src/npcmove.cpp
+++ b/src/npcmove.cpp
@@ -1858,7 +1858,9 @@
     }
 
     if( one_in( 3 ) && ( get_thirst() > thirst_levels::thirsty ||
-                         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;
         }
@@ -3820,13 +3822,14 @@
         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 ) {
         complain_about( "camp_food_thanks", 1_hours, "<camp_food_thanks>", false );
         mod_hunger( -camp_kcals );
         mod_stored_kcal( camp_kcals );
         yours->food_supply -= camp_kcals;
+        stomach.mod_calories( camp_kcals );
         return true;
     }
     complain_about( "camp_larder_empty", 1_hours, "<camp_larder_empty>", false );