CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.03k stars 4.09k forks source link

Remove direct "bloodloss" temperature drop from character.cpp #47676

Closed Fosheze closed 2 years ago

Fosheze commented 3 years ago

Is your feature request related to a problem? Please describe.

It has never made sense that a limb gets colder just because it is damaged. In reality if my arm is bruised it doesn't get cold because of it; when I broke my foot it wasn't freezing until it healed. The hypovolemia effects already model temperature loss because of blood loss so the legacy code that reduces body part temperature based solely on body part health is no longer necessary.

Describe the solution you'd like

Remove this chunk of code and all references to it. https://github.com/CleverRaven/Cataclysm-DDA/blob/483cd09a897ef22802c759a672deebc721f4dfdf/src/character.cpp#L7136-L7152

Describe alternatives you've considered

Adding in a more complex internal bleeding system for blunt damage would be nice at some point but that is an entirely different issue and it doesn't justify the continued existence of this old code.

Additional context

Took my first look at the body temp code in #47428 and realized that it could use some updating. This seems like an easy change in that direction and I might do it myself but having my first C++ PR be unceremoniously ripping a chunk of ancient code out of character.cpp right before a release version terrifies me. I definitely wouldn't complain if someone else took the blame it on.

actual-nh commented 3 years ago

Would the hypovolemia effects need to be increased to compensate?

Fosheze commented 3 years ago

Would the hypovolemia effects need to be increased to compensate?

Now that I look at it more closely it would likely need to be adjusted. But that should be as easy as moving the temperature alterations out of the case statements and tweaking the numbers. Currently it looks like the temperature loss is a random chance with hypovolemia where it should be a constant and scaling thing. If I'm reading it right, it also looks like you only lose temperature in the first stage of hypovolemia/anemia but in the later stages you are fine in regard to temperature. This may have been deliberate at the time due to the current body part temp mechanics.

As soon as I get my compiler running I'll rip the bloodloss temp alterations out of character.cpp and playtest it locally. That's the only real way to find out.

Linking the code here so I can find it later. https://github.com/CleverRaven/Cataclysm-DDA/blob/5cc608ccea74ba783c2f1569fafdbc2b9caf0021/src/player_hardcoded_effects.cpp#L904-L1127

kevingranade commented 3 years ago

We'd generally prefer to avoid arguments like "since you're doing one thing, you should do a different thing to cancel it out", unless we have a well-defined expectation documented for what outcome we expect. The status quo is that many aspects of the game are not in some "ideal" state that must be preserved.

actual-nh commented 3 years ago

See this comment for why there does need to be significant loss of temperature with sufficient trauma. (I knew that Fosheze was familiar with that; sorry for not explaining that to others.)

Fosheze commented 3 years ago

At this point I've pretty much committed myself to working on this. At least it won't go through until after release so that makes it easier.

So far my plan as soon as my compiler is running is to rip that chunk of code out and then twiddle with the numbers on the hypovolemia and anemia effects until I reach the -30 indicated by Venera3 in #47428 unless I can find more concrete numbers. I actually happen to know a paramedic instructor so I'll see if I can get some figures from them and see what I can find online as well. @Venera3 if you have any input on where the temperature loss should start/stop and the rate it should decrease at (linear, exponential, log, etc.) for extremities and core body temp it would also be greatly appreciated. I'm assuming that the 30 degree temperature drop you indicated earlier was at the extremities. @nexusmrsep if you are still around and have any input on this that would be appreciated as well seeing as how you are the one who implemented the blood system.

Venera3 commented 3 years ago

I think you can start the scaling at intensity 1 for the hands and feet, moving on to the arms and legs for intensity 2 and starting to cool the torso and the head at intensity 3 ( unless you want to base it off the actual blood volume, but I think that would be a lot of extra work to get right for little gain ). The endpoint for the extremities should be whatever suffices to have the danger of frostbite in a few hours without attention. Most of the actual dangers of hypothermia aren't simulated, so that's kind of what we're left with ingame. The IRL numbers aren't going to be very helpful, since the game uses that weird aggregate subjective temperature and you'll only find data about objective central temperature drop. For reference, we tend to get antsy at 35 °C, and around persistent 32 °C is where we'd start doing some pretty invasive things to coax it higher.

actual-nh commented 3 years ago

Is it a "30 degree drop", or "a drop to 30 degrees" in what you said earlier, BTW? (I am guessing the latter.) Thanks!

Venera3 commented 3 years ago

About a 30 degree drop in the game's terms, but that's very much an eyeball estimate. It's cold enough so that you need extra clothing/a blanket to prevent frostbite and to slow you down a bit. I'll admit that I haven't really tested temperature stuff yet, so I might be a bit off the mark there.

Fosheze commented 3 years ago

Thank you for all of the awesome info. I can work with that.

The endpoint for the extremities should be whatever suffices to have the danger of frostbite in a few hours without attention. Most of the actual dangers of hypothermia aren't simulated, so that's kind of what we're left with ingame. The IRL numbers aren't going to be very helpful, since the game uses that weird aggregate subjective temperature and you'll only find data about objective central temperature drop. For reference, we tend to get antsy at 35 °C, and around persistent 32 °C is where we'd start doing some pretty invasive things to coax it higher.

That's an excellent point on the aggregate temp. That's something that we should look at as the wounds/body parts systems are expanded. Having a direct body temp separate from the aggregate would give a lot more control for various effects like hypothermia, fever, blood loss, etc. That's out of scope for this though.

I think you can start the scaling at intensity 1 for the hands and feet, moving on to the arms and legs for intensity 2 and starting to cool the torso and the head at intensity 3 ( unless you want to base it off the actual blood volume, but I think that would be a lot of extra work to get right for little gain ).

Ideally I would like to setup an equation that starts taking effect at stage 1 and smoothly scales temp loss with blood volume. But that will have to wait until a true body temp metric is added like I said above. For now I will just pull the current temp loss effects out of the case statements so that they will take effect every time and then tweak the numbers until frost bite becomes a concern for the extremities at room temp with normal clothing when blood loss is severe like you said. That preserves some of the current temp loss mechanics after I rip "bloodloss" out.

Just spit balling numbers here because I haven't tested anything yet but I'm imagining something like this. Stage1: -Hands and feet reduced by 10 degrees C (uncomfortable but not damaging if managed)

Stage 2: -Hands and feet reduced by 20 degrees C (frostbite becomes a major concern but not certain) -Arms and legs reduced by 10 degrees C (uncomfortable but not damaging if managed)

Stage 3: -Hands and feet reduced by 30 degrees C (frost bite almost certain) -Arms and legs reduced by 20 degrees C (frostbite becomes a major concern but not certain) -Torso and head reduced by 10 degrees C (uncomfortable but not damaging if managed)

Stage 4 (if somehow still alive): -Hands and feet reduced by 40 degrees C (your limbs will break) -Arms and legs reduced by 30 degrees C (frost bite almost certain) -Torso and head reduced by 20 degrees C (frostbite becomes a major concern but not certain)

actual-nh commented 3 years ago

Of course, it is rather unlikely that the character's surface temperature will drop (much?) below the temperature of the surroundings. In terms of converting body surface temperatures to core temperatures - try looking up remote/IR thermometers vs core body temperature.

actual-nh commented 3 years ago

One interesting interaction would be with the "Climate Control" CBM, or other things (e.g., spell effects) made possible by #47713. (With the CBM, there is the question of at what point it would stop working in a damaged extremity - a question that extends further than this particular case. I can see something like nanobots being active (and carbon nanofilament (sp?) armor being effective) in a body part as long as it was attached; others are more uncertain.)

Venera3 commented 3 years ago

I wouldn't go as far as breaking, because only major parts can break and the direct damage would be limited to the hands and feet at room temperature and piling more damage onto an already battered survivor could result in some very frustrating failure spirals. If I recall correctly the speed debuffs alone will discourage anything other than crawling into a hole to rest. Keep in mind that significant blood loss will mostly happen to early game characters who won't necessarily have a hoard of extra clothing on hand.

On adding central temperature simulation, that's a big chunky project that would need to be hooked up to a lot of things to work well. Off the top of my head, activity levels, dynamic shivering and baseline metabolism raising it, perspiration to lower it, fever and relevant mutations messing with the goal value, CBMs helping with regulating it, and adding a bleed resist for it to be lowered by hypothermia. I think it would definitely be worthwhile, but it's the kind of stuff I could only help with reality checking.

Fosheze commented 3 years ago

I wouldn't go as far as breaking, because only major parts can break and the direct damage would be limited to the hands and feet at room temperature and piling more damage onto an already battered survivor could result in some very frustrating failure spirals. If I recall correctly the speed debuffs alone will discourage anything other than crawling into a hole to rest. Keep in mind that significant blood loss will mostly happen to early game characters who won't necessarily have a hoard of extra clothing on hand.

Sorry, I should have phrased that better. When I said "the limb will break" I was referring to the fact that at that temperature frostbite damage wouldn't really be able to be mitigated without taking the most extreme measures. Eventually it would rack up to the point where the limb breaks but the survivor would still have an hour or more of functionality before that. That also would only take place at stage 4 hypovolemia so odds are the survivor would drop dead of a heart attack long before the limb took enough damage to break anyways. This would just be a long term effect of bleeding out that bad if by some miracle they didn't outright die of other causes. My reasoning there is that to my limited understanding IRL when someone is in the last stages of hypovolemia there will be significant cell death in the fingers and toes which can result in their loss if something isn't done quickly. Correct me if I'm wrong there because I'm definitely not an expert. In CDDA odds are the survivor is not going to receive adequate treatment to save those appendages. Seeing as how individual fingers/toes are not yet modeled and amputation isn't a thing I figured that having the limb take damage until it breaks was a good stand in. IRL if your fingers on a hand die off or your toes on a foot die off then that whole arm or leg is going to be pretty useless. In game a broken limb isn't a death sentence. I always play fragile imperceptive healer so I've had my fair share of games where I have been wandering around for months on 2 broken legs and I am by no means good at the game (hence the 2 broken legs). It is definitely a survivable and playable situation even in the early game; it just requires a lot of of extra care.

As far as early game temp management in this scenario goes there aren't many clothing options like you said, however there are still other readily available options. Emergency blankets can be found in most versions of the evac shelter and those are pretty much what you would use IRL too. Other blankets are fairly common items as well. Lighting fires or entering vehicles can also mitigate the cold for a time. It won't be easy to deal with but bleeding out alone with no supplies shouldn't be easily survivable. I'm not aware of warmth options available for in-a-woods characters but I am also not aware of anything that you would find out there which could cause enough bleed damage for any of this to matter anyways.

On adding central temperature simulation, that's a big chunky project that would need to be hooked up to a lot of things to work well. Off the top of my head, activity levels, dynamic shivering and baseline metabolism raising it, perspiration to lower it, fever and relevant mutations messing with the goal value, CBMs helping with regulating it, and adding a bleed resist for it to be lowered by hypothermia. I think it would definitely be worthwhile, but it's the kind of stuff I could only help with reality checking.

I agree completely. I only mentioned that because I know that I saw one of the devs talking about a planned overhaul of the wounds/body systems and changing it so that death is caused by actual medical causes and specific wounds to specific parts rather than just a generic HP bar falling to zero. I am definitely not going to be the one doing that change though. I just brought it up because this whole system will have to be overhauled at that time too so that would be the time to add the proper blood volume to temperature math along with a proper core body temp.

Fosheze commented 3 years ago

One interesting interaction would be with the "Climate Control" CBM, or other things (e.g., spell effects) made possible by #47713. (With the CBM, there is the question of at what point it would stop working in a damaged extremity - a question that extends further than this particular case. I can see something like nanobots being active (and carbon nanofilament (sp?) armor being effective) in a body part as long as it was attached; others are more uncertain.)

I believe that by default the Climate control CBM can do 30 degree (not sure if C or F) temp swings at max so there is a limit. It isn't even enough to counter ice labs on it's own. As far as CBMs stopping working due to damage goes that's a whole different issue that I'm not even going to touch with a 10 ft pole.

Of course, it is rather unlikely that the character's surface temperature will drop (much?) below the temperature of the surroundings. In terms of converting body surface temperatures to core temperatures - try looking up remote/IR thermometers vs core body temperature.

Like Venera pointed out earlier, temp right now doesn't track actual body temp. It's some sort of weird aggregate. Due to that I probably won't even worry about the numbers shown when I test. I'm just going to tweak the internal numbers until I get the proper level of cold feeling/frostbite at the different stages.

As a side note though, now I'm wondering who will try bleeding themselves to avoid the summer heat first. I'm not going to worry about fixing that with this change because it's out of scope and it's still an issue with the current system too but it is an oddity that comes to mind.

Venera3 commented 3 years ago

Barring ambient tempertures that would lead to frostbite on their own, you wouldn't see major limb damage. After a few hours you'd have some affected fingertips getting on the problematic side, but your arm becomig essentiallx broken is overblown. I'd have to look up the cold debuffs properly, but pain and very occasional damage would get the point across without going too far. The pain from fighting, bleeding and hypovolemia debuffs on top will take the survivor out of the fight for a good few days anyway.

Fosheze commented 3 years ago

Barring ambient tempertures that would lead to frostbite on their own, you wouldn't see major limb damage. After a few hours you'd have some affected fingertips getting on the problematic side, but your arm becomig essentiallx broken is overblown. I'd have to look up the cold debuffs properly, but pain and very occasional damage would get the point across without going too far. The pain from fighting, bleeding and hypovolemia debuffs on top will take the survivor out of the fight for a good few days anyway.

Sounds good. I'll dial back the whole scale so that "frostbite" in the hands only barely begins to be a slight concern at the very end stages (at room temp with assumed no hand coverings) with the other stages just being increasing degrees of cold. Now that I'm putting more thought into it, you're right the cold debuffs can be severe enough on their own. I remember having my speed drop down to 25 in ice labs. This wouldn't be that severe but any speed reduction is still killer. I'll try and balance the hypovolemia and anemia temp drop to that together because I'm assuming that as soon as the survivor becomes somewhat hypovolemic then anemia will start kicking in very shortly too (need to check if that actually is the case first). I don't want to double up on the symptoms too much when they overlap. That would also serve to give the survivor a bit of a buffer to run away when hypovolemic before the anemia kicks in as well and cripples them further.

Venera3 commented 3 years ago

You can keep the temperature changes hypovolemia-only for sanity's sake. Anemia certainly would play a role, but the shock itself is the main culprit (and until other kinds of shock make it in it's a bit of a moot distinction).