Mods / Hungry While Injured

Tags: #Food #Other #Tweak #Utility
Author: traugdor
Side: Server
Created: Sep 21st at 2:23 AM
Last modified: 4 days ago
Downloads: 329
Follow Unfollow 23

Recommended download (for Vintage Story 1.21.2 - 1.21.5):
hungrywhileinjured_2.0.0.zip  1-click install


Ever play with an extremely low health regeneration rate?

And as a result, do you ever think, "Man, my hunger paused while I'm injured? This is kind of broken...", to yourself before?

Do I ever have a solution for you!

 

This mod is inspired by Smooth Digestion mod, but designed to actually be compatible with other mods.

It's not a hard dependency, but this mod is required for Expanded Stomach to work properly.

 

This mod is recommended for every version of the game.

 

Hunger will continue to drain as normal even with extremely low regeneration rates to mimic how an injured person still needs to eat, more so if they are actively healing from an injury!

 

Planned features (in no particular order):

  • Increased health regeneration based on nutrition levels. A balanced diet restores the body faster.

 

Enjoy!

Mod Version For Game version Downloads Released Changelog Download 1-click mod install*
2.0.0
1.21.2 - 1.21.5
34 4 days ago hungrywhileinjured_2.0.0.zip 1-click install

refactored code for 1.21.2 - 1.21.5

1.0.1 278 Sep 21st at 3:07 AM HungerPatcher.zip 1-click install

removed debugging output

set to server-only

1.0.0 17 Sep 21st at 2:23 AM HungerPatcher.zip 1-click install

Initial release


11 Comments (oldest first | newest first)

💬 traugdor , Sep 22nd at 8:40 PM

Misteyes 

> (None of these details matter for the fix - I checked your PR and it does fix the bug, so I assume the mod is good as well.)

Yes, the source code is on my Expanded Stomach mod. I will probably split it out into it's own repo, but since ES requires this mod as a soft dependency, I will keep them in the same repo. I have a branch that hasn't been merged yet because I'm still working on it but the code is there. :)

💬 Misteyes, Sep 22nd at 7:00 AM (modified Sep 22nd at 7:02 AM)

traugdor - Yeah, the souce of the damage doesn't matter, but your current satiety does. I suggested starvation damage because it conveniently sets up both conditions for optimal repro (very low satiety and less-than-full health). The rate at which health regerneration consumes SaturationLossDelay* is proportional to your current satiety. So if you're starving and eat a flax grain, you'll get only 10 points of SaturationLossDelayGrain, but those 10 points will last a really long time because your current satiety is 30/1500. Meals provide a lot more SaturationLossDelay* than flax grains do (in fact, in vanilla, everything except pies and cooked meals grants exactly 10 LossDelay, regardless of satiety), but because meals also provide a lot more satiety, your health regeneration will eat through that loss delay sooner, leading to the hunger clock restarting. Flax grains specifically work well because they have the "best" ratio of Satiety to LossDelay in the game.

Eating a meal while starving will pause the timer for 1/3 as long as eating a flax grain while starving. Eating a meal while not starving will pause the timer for less time, proportionately with your current satiety.

(None of these details matter for the fix - I checked your PR and it does fix the bug, so I assume the mod is good as well.)

💬 traugdor , Sep 21st at 8:43 PM

Misteyes I have updated it to say that...sort of. What you point out is one extreme example, but I tested it with a TON of debugging output to make sure that meals weren't the problem and basically what it amounted to was that it didn't really matter where the damage came from (I tested with fall damage) and it didn't matter what food you ate immediately after. All that mattered was that the hungerCounter was going negative, so I put a stop to that.

💬 LadyWYT, Sep 21st at 8:38 PM

SeniLiX In all fairness, it's a bit of a difficult bug to spot outside of multiplayer. I'm not entirely sure why. I usually play Blackguard though and it's definitely suspect when the Blackguard is able to go multiple days without needing even a snack! 😂 But like traugdor noted, it's not necessarily a pesky bug, unless you are playing with Expanded Stomach...in which case, players can get unfairly penalized quite easily due to the game assuming they have bad dietary habits, when they don't.

💬 SeniLiX, Sep 21st at 8:18 PM

traugdor I stand corrected.

I guess I never encountered (or noticed) this myself.

Hopefully it gets fixed.

💬 Misteyes, Sep 21st at 7:03 PM

"Take damage then eat a meal" sounds like it could plausibly be intended behavior. I recommend changing the repro to say, "Take starvation damage, then eat a flax grain (and nothing else)." This will pause your hunger for multiple in-game days, and is obviously not intended.

💬 traugdor , Sep 21st at 4:44 PM

SeniLiX this mod is not for the saturation delay given by eating meals. It is for a BUG that causes your satiety meter to pause of an indefinitely period of time (like 5-6 in-game hours!) that is triggered by eating any food after taking damage. I can walk you through the bug and how it works if you want to read below, but there are at least 5 issue tickets on the issue tracker for Vintage Story and 1 pull request (authored by me) that is intended to fix those bugs.

Bug Walkthrough

How to trigger the bug

  1. Take damage
  2. Eat a meal
  3. ???
  4. Profit

 

Why it does this:

  1. The game keeps track of time using an internal counter called hungerCounter. This counter gets increased every time the game ticks in the OnGameTick method of the EntityBehaviorHunger class. Because the game tick speed is not an exact number it just accumulates by about one second.
  2. Once the hungerCounter exceeds 10, it is assumed that 10s of real world time have passed.
  3. The OnGameTick method of the EntityBehaviorHunger class triggers a ReduceSaturation method.
  4. This method checks to see if there is any meal delay (because of the benefit of eating meals as you pointed out).
  5. If there is still a delay, the delay has a small number subtracted from it and a variable is set called isondelay and given a true/false value of true.
  6. If isondelay is set to true, the game will then subtract 10 from the hungerCounter and the method ends.
  7. IF the player is injured, the game will attempt to exchange satiety for health. It does this by calculating an amount of satiety to consume every game in the OnGameTick method of the EntityBehaviorHealth class. NOTE: This is different from the previous EntityBehaviorHunger class. It then sends this value to a method called ConsumeSaturation.
  8. ConsumeSaturation does not adhere to the 10s rule because it is outside of the OnGameTick method of the EntityBehaviorHunger class. Thus instead of being called once every 10s, it is being called once every 1s. It gets called 10x as often when the player is injured!
  9. ConsumeSaturation does some calculations and passes the value off to ReduceSaturation! Remember this is once every 1s instead of once every 10s!
  10. Because the player JUST ate, the meal delay values are quite high. Because you are only sacrificing a small amount of hunger to regenerate your health, the meal delay values take a long time to decrease. Every time this happens, the hungerCounter is lowered by 10.

 

So to summarize:

  1. The game increases hungerCounter by roughly 1s every game tick.
  2. If the player is injured and has a meal delay, hungerCounter is decreased by 10s every game tick. This has a net result of lowering hungerCounter by roughly 9s every game tick.
  3. If it takes a couple of minutes for the player to heal, hungerCounter will decrease to -1080 or so, meaning it's going to take another 1090 or so ticks for the hungerCounter to reach 10 again.
  4. 1090 ticks is 18 MINUTES of real world time. A day in Vintage Story takes 48 minutes of real world time. By doing some math, that's 9 in-game hours of the satiety meter not budging because hungerCounter never gets over 10 and thereby never triggers ReduceSaturation again.

 

This is a real problem, and that is what this mod is addressing.

💬 SeniLiX, Sep 21st at 8:14 AM

The pause after eating a meal is not a bug.

It is by design to reward the player into using the meal system.

💬 traugdor , Sep 21st at 7:42 AM (modified Sep 21st at 8:00 AM)

MrMutant is correct. This mod is a fix directly related to that bug. It is triggered by taking any damage and then immediately eating a meal afterwards.

 

If you don't find the bug annoying or game-breaking, then you don't have to use this mod, but I designed it specifically to be used with my other mod, Expanded Stomach, because this causes my other mod to think the player is just constantly overeating or not getting any exercise via running, walking, working in the mines or hammering ingots into tools, etc. As a result they start to experience the drawbacks of overeating a lot sooner than they should. This mod fixes that bug in a way that makes my other mod less likely to break.

💬 MrMutant, Sep 21st at 7:16 AM

hopefully this isnt related to the meal pause, but for those that dont know there is a bug that makes hunger pause outside of meals, and even a pretty easy to do "trick" where you eat after taking starvation damage and your hunger wont drain for a couple mins. Possibly a fix for that

💬 MetalTYR, Sep 21st at 7:07 AM

you do know your hunger bar is supposed to pause when you eat a cooked meal right?

its one of the benefits of eating cooked meals rather than chowing down on a dozen carrots.

i have never noticed any satiety meter pause that was not due to eating a meal, but i could have missed it.

 (edit comment delete)
Основной веб-сайт | Почтовый сервер | FTP сервер | Административная панель | API интерфейс | Content Delivery Network | Статические файлы | Ресурсы сайта | Изображения | Файловое хранилище | Блог | Интернет-магазин | Техническая поддержка | Справочная система | Документация | Форум | Новости | Загрузки | Демонстрация | Тестовая среда | Приложение | Медиа контент | Разработка | Промежуточная среда | Бета версия | Безопасная зона | Вход в систему | Панель управления | Портал | Система управления контентом