Cataclysm-dda: I suspect character.cpp "void Character::update_health( int external_modifiers )" is called too often.

Created on 3 Aug 2020  路  23Comments  路  Source: CleverRaven/Cataclysm-DDA

Description:
I have started a playthrough in experimental where I aimed at making myself completely OP by abusing the debug menu some. I decided to mutate my character past Arachnid threshold and install as many useful CBMs as I can, just to see how crazy OP I could make myself. As the wiki told me using serums is gonna tank my health, I used the debug menu to recover my health to the max. After that, I noticed that health values seem to be dropping REALLY fast and did some testing. For the record: My character is not overweight, and I at least tried to have her eat decently healthy food. I'd say it's about average healthy stuff. She is also not irradiated, and her blood analysis CBM says she has no active effects. I also do NOT have a Leukocyte Breeder system installed, simply because I know how it works, and I don't like that you become dependent on it, so that system is not the issue here.

I then used debug to set my health and health modifier to 200, did stuff / waited around and recorded the health values after certain amounts of time. The time passed in the following list is not 100% accurate, but it should not matter too much.
started at 200 health, 200 health mod.
30 minutes: Health unchanged, Mod at 190.
1h 30 min: Health at 198. Mod at 172.
2h 30 min: Health at 196. Mod at 163.
3h 30 min: Health at 190. Mod at 147.
5h 30 min: Health at 173. Mod at 119.
7h: Health at 158. Mod at 102.
8h: Health at 143. Mod at 87.
9h 30 min: Health at 118. Mod at 67.
11h 30 min: Health at 101. Mod at 54.

Had my character sleep at that point because tired.
19h 30min: Health at 49. Mod at 25.
~27h: Health at 26. Mod at 12.
It just seems really strange to me that both these values deteriorate that quickly. I am not sure if my mutations / CBMs would have anything to do with it, as I couldn't find any informations about if these things are supposed to cap health at a low value or not.

Steps To Reproduce:

  1. Make player
  2. Maybe mutate and install pretty much every CBM you can think of
  3. Use debug to set health and health mod to 200
  4. Wait or do stuff for about 24 (in-game!) hours
  5. Use debug to check health and health mod from time to time, record values

Expected behavior:

I really don't know how quickly these values should drop under normal circumstances. It just seems to me that it is too quick.

EDIT HERE:
Quote from character.cpp void Character::update_health( int external_modifiers ), lines 4931 to 4964:
{
if( has_artifact_with( AEP_SICK ) ) {
// Carrying a sickness artifact makes your health 50 points worse on average
external_modifiers -= 50;
}
// Limit healthy_mod to [-200, 200].
// This also sets approximate bounds for the character's health.
if( get_healthy_mod() > get_max_healthy() ) {
set_healthy_mod( get_max_healthy() );
} else if( get_healthy_mod() < -200 ) {
set_healthy_mod( -200 );
}

// Active leukocyte breeder will keep your health near 100
int effective_healthy_mod = get_healthy_mod();
if( has_active_bionic( bio_leukocyte ) ) {
    // Side effect: dependency
    mod_healthy_mod( -50, -200 );
    effective_healthy_mod = 100;
}

**// Health tends toward healthy_mod.
// For small differences, it changes 4 points per day
// For large ones, up to ~40% of the difference per day**
int health_change = effective_healthy_mod - get_healthy() + external_modifiers;
mod_healthy( sgn( health_change ) * std::max( 1, std::abs( health_change ) / 10 ) );

**// And healthy_mod decays over time.
// Slowly near 0, but it's hard to overpower it near +/-100**
set_healthy_mod( std::round( get_healthy_mod() * 0.95f ) );

add_msg( m_debug, "Health: %d, Health mod: %d", get_healthy(), get_healthy_mod() );

}
End quote.
From the highlighted comments, it looks to me that this function is ought to be called once per day? From what I can tell, my test values up top and in my comment further down where I tested again with a vanilla as possible character who did nothing obvious to lose health quickly seem to indicate that this function is either called once per hour, or every time character performs certain actions. Please tell me if I'm wrong.

Versions and configuration:

  • OS: Windows

    • OS Version: Windows 7

  • Game Version: 0.E-4667-g1d4ea08 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Aftershock [aftershock],
    Blaze Industries [blazeindustries],
    C.R.I.T Expansion Mod [crt_expansion],
    DinoMod [DinoMod],
    Cataclysm++ [Cata++],
    Mythical Martial Arts [MMA],
    Graphical Overmap [Graphical_Overmap],
    Alternative Map Key [alt_map_key],
    Mutation Changes [Mutation_Changes],
    SpeedyDex [speedydex]
    ]

I also attached my save file so if someone wants to they can check my character. Maybe it is something specific to my game.
Eternia.zip

Most helpful comment

I usually am happy keeping my health around 30~40. Never tried to get it to 100, and I need to keep at least moderate exercise. With no exercise I get overweight almost surely but with moderate or high exercise it is pretty hard to get enough calories.

Then I think that when we sleep should really reduce the hunger increasing speed, though your stomach being empty will cause you to be kind of hungry when you wake up.

So they would need to rebalance the hungry and health system. I am sure that keeping your stomach full all the time is really bad for health since digestion puts a heavy strain in the body so you shouldn't eat all the time, only if it is something really light and if you have some problem with diabetes or hypoglycemia that you can't keep naturally a healthy blood sugar level.

All 23 comments

It seems that the Leukocyte Breeder System CBM reduce your health. Don't you have this or a mutation that decrease your health? Or aren't you radiated? As you installed every CBM and mutation probably you should have one that is doing this.

As stated in my original post, I am not irradiated and I do not have the Leukocyte breeder system installed because I don't like that you become dependant on it.
The mutations I have are as follows:
Full Night Vision
Infrared Vision
Furred chitin
Venomous
Web walker
Very dextrous
Spider fangs
Web weaver
Web diver
Rope webs

None of the descriptions of these mutations mention that they negatively affect health.

No parasites, vitamin deficiency or hipervitaminosis, no addiction or drugs used recently, not another sickness that can't be seen immediately? Not wet or problems with warmth?

Just tested and as it seems, as soon as you get hungry or very hungry your health and modifier decreases steadily. It seems that you need to keep always slaked and satisfied to keep them up. No idea if this is intended.

Blood analysis CBM reports no effects.
She isn't addicted and hasn't taken any drugs so far, except one can of beer, but that was close to the end of testing.
She is feeling a bit warm due to her furred chitin and also wearing protective gear, but it's not excessive, and I have intermittently turned on my internal climate control CBM.
No problems with wetness, I have encountered the infinite wetness bug before, but not on this character.
I think it might be vitamin deficiency after I found out how to check it.
grafik
Calcium at -734, Vitamin A at -507, Vitamin B12 at -1 and Vitamin C at -85 are probably not healthy levels. I always heard that they aren't supposed to negatively affect health yet - I guess that's not true in experimental anymore.
I'll try raising those vitamin levels and then test it again.

Probably!

Scurvy is a thing and lack of vitamin A will make you blind.

I fixed the vitamins / calcium levels (Calcium, Vit. B12 and Vit. C cannot be raised above 0, but Vit. A can?) and tried again.
Started with 200 / 200.
3h later: Health 190, Mod 147 (She has not gotten hungry yet, she started out Full and Turgid, too)
5h later: Health 178, Mod 128 (She got very hungry, but that was for just a few minutes, made her eat until satisfied again)
8h later: Health 148, Mod 95 (Had her eat again as she got very hungry once more, also took gummy vitamin)
16h later: Health 77, Mod 42 (She got tired and had her sleep, then ate after waking up as she turned very hungry early in her sleep)
Her vitamin levels (after those 16h) were at -17 calcium, Vit. A 11, Vit. B12 -1 and Vit. C -17. Iron is at 1737 though, does that count as too high? I don't know. It still seems it's tanking way too fast.

The hungry. You need to always eat something healthy when not satisfied. Worked with dandelion tea and bananas for me.

Iron is too high, but I don't know if it is already hypervitaminosis.

Iron too high cause even poisoning.

Okay, I can see Iron being too high, I might try again and fixing that, too.
However, that leaves the question how you're supposed to keep yourself from getting Very Hungry while sleeping as it seems my character gets very hungry about every 3~4 hours and when sleeping takes about 8h, always waking up Very Hungry. I even tried sending her off to sleep with "Hunger : Full" status (where eating more causes a cautionary prompt), and woke up Hungry or even Very Hungry. This was not caused by Metabolic Interchange as I had turned that off for purposes of testing.
I guess I could set an alarm to wake her up after 4h of sleep, eat something, and then sleep again but I don't know if that might cause sleep deprivation.
Even all of that considered, though, I really don't think the Health and Health mod values should tank THAT fast (it's just been 16 hours, not even a full day!)
Also, from that screenshot I attached earlier, you can see she has quite an amount of stored calories - shouldn't that help in case she gets hungry?
Maybe the health effects of hungry / very hungry should be turned down some? Otherwise, sleeping would always cause your health to tank brutally, since you can't eat something when you get very hungry during your sleep.

However, that leaves the question how you're supposed to keep yourself from getting Very Hungry while sleeping as it seems my character gets very hungry about every 3~4 hours and when sleeping takes about 8h, always waking up Very Hungry. I even tried sending her off to sleep with "Hunger : Full" status (where eating more causes a cautionary prompt), and woke up Hungry or even Very Hungry. This was not caused by Metabolic Interchange as I had turned that off for purposes of testing.

I had also problems with hunger, more detailed here: https://github.com/CleverRaven/Cataclysm-DDA/issues/41889
But i havent noticed any health problems.
I have not played much since then because all gameplay turns into "getting food and eat", while barely can keep weight. There probably something wrong, but i couldn't find out what exactly, numbers seems alright, but overall experience is weird.

I don't know if it is really the very hungry or that you should be always eating something healthy, it just seems so. No idea how it really work in depth.

Especially considering that intermittent fasting is healthier than constantly stuffing one's face.
Maybe someone could look into implementing adaptive metabolism states like Ketosis etc.

Well, then try every time you wake up or get very hungry to eat something at least a bit healthy and see if you can keep the health mod from decreasing, anyway if your health and health mod are too different they will change toward the equilibrium, with the health mod changing way more than your actual health, and as food effect should affect the health mod and then it affect the actual health.

But more than this only if someone take a look in the code.

I... believe it might be mutations, especially if you have multiple. I took a quick look at the code and this part seems to imply that the more mutations you have, their effect gets worse and worse, but I am not sure if I am right, or if this only applies when you are in the process of mutating.

void Character::mod_healthy( int nhealthy )
{
float mut_rate = 1.0f;
for( const trait_id &mut : get_mutations() ) {
mut_rate *= mut.obj().healthy_rate;
}
healthy += nhealthy * mut_rate;
}

I think that code means some mutations may modify the change in health (either increasing it if the rate is > 1 or decreasing it if the rate is < 1).

I decided to do some long-term tests as I remembered that healthy food is supposed to have an effect over longer periods of time. I also wanted to eliminate as many factors as possible, so I created a test world with only the core dda content loaded and made an average Jill character. I gave her cooking 10 and survival 10 in order to be able to craft some dandelion tea without messing it up.
I spawned in some basic amenities and had her eat nothing but bananas, drink dandelion tea, and supplemented it with calcium tablets, multivitamin and injectable B12 to keep her vitamin levels up.
I also had her occasionally perform moderate exercise. All other time was spent reading fun books to keep her morale high.
Here are my testing values:
test of health values
Start day 61
Health 200, Health mod 200
day 62
Health 82, Health mod 46
day 63
Health 47, Health mod 38
day 64
Health 46, Health mod 28
day 65
Health 46, Health mod 44 (This is the first time EVER I saw this stat raise)
day 66
Health 45, Health mod 37
day 67
Health 45, Health mod 36 (The drop here is attributable to the fact that she became overweight. Yes, overweight from eating healthy food and exercising.)
day 68
Health 45, Health mod 37

In addition, I found that even with "Hunger: Full" it takes only 4 hours to get to "Hunger: Very hungry". This basically means that you need to set an alarm to 3 hours every time to go to sleep so that you can eat and avoid becoming hungry so your health does not drop too much. The only time where she did not go to "very hungry" after a full night's sleep is when she became slightly overweight, but after waking up, she was still "Hunger: hungry".

I usually am happy keeping my health around 30~40. Never tried to get it to 100, and I need to keep at least moderate exercise. With no exercise I get overweight almost surely but with moderate or high exercise it is pretty hard to get enough calories.

Then I think that when we sleep should really reduce the hunger increasing speed, though your stomach being empty will cause you to be kind of hungry when you wake up.

So they would need to rebalance the hungry and health system. I am sure that keeping your stomach full all the time is really bad for health since digestion puts a heavy strain in the body so you shouldn't eat all the time, only if it is something really light and if you have some problem with diabetes or hypoglycemia that you can't keep naturally a healthy blood sugar level.

Keeping it around 30~40 is probably fine, but the thing is that I wanted to see if it was possible to keep your health and health modifier at the "maximum" value of 200 (at least the wiki says that's the max). I would even have been fine with being able to keep it somewhere around 100, but as you can see, I really struggled with keeping it close to 50, even. I simply don't know what else I'm supposed to do to keep a character healthy.

IIRC, health is supposed to change faster the further away from 0 it is. Last time I checked 10 health was an ok value, and the only way to keep it close to 100 was with a leukocyte breeder. Was it changed? How did you start with 200 health, is it a new default?

No, I used debug. I just wanted to see how the mechanic worked so I could work with it better on a more legit run where I don't have any traits or mutations that let me heal quickly, so I wanted to see what it'd take to get a character from the start - default is still 0 health, 0 health modifier - to at least 100 health and keep him there to get the regeneration buff.

I think that it would be nice to be able to get 100 healthy but probably only with extreme diet and exercise balance. I have no idea if this is possible right now though I can get to 30~40. How much the difference the 100 health does?

It's working as intended, if you want to maintain very positive health (i.e. for faster healing), you need to constantly boost it.

"Boost" how? The person described eats healthy and exercises - what else can they do?

Was this page helpful?
0 / 5 - 0 ratings