CleverRaven / Cataclysm-DDA

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

Clarify Health and make it work as expected #37446

Open I-am-Erk opened 4 years ago

I-am-Erk commented 4 years ago

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

Health as it exists in game is a nebulous concept that most players don't even realize exists. It fluctuates, sometimes wildly, with changes in diet and weight, and can be improved by drinking a lot of tea. All in all it doesn't make a lot of sense as it stands.

Describe the solution you'd like

Health as a concept is very reasonable, representing vague elements of "living well" that reduce the survivor's chance of illness. For this to work we need to calculate it much differently.

Daily health vs Lifestyle

I recommend that there be multiple contributing factors for Health. We should keep the current concept, where we have two health stats, one which defines healthy living over the short term and has little active game effect, and one which represents longer term health as a summary, and has a more profound effect. In game these are called health and health_mod, but since those terms are very vague, I will call the short-term effect daily_health and the long term effect lifestyle.

Once per twenty four hours, the character's daily_health net value is saved into a running health_tally, which tracks the daily_health value over the last week. At the same time, the current health_tally is divided by 7 and added to lifestyle. So while lifestyle changes every day, it is by an average of the character's health over the last seven days. We could consider applying additional maths to health_tally to reduce the effect of particularly healthy or healthy days, like tossing out the highest and lowest value and dividing the remainder by 5 instead of 7.

At game start, health_tally assumes zero health for the last seven days before game start.

Things impacting daily_health

For my sanity in editing, if I say 'health' here, I mean daily_health, ok?

Food

Food should have an impact on health, but not to the same degree it currently does. I propose that food be limited to "normal" and "junk". Junky food should get a -1 to health, and all other food should sit at zero. This reduces the qualitative impact of particular foods being arguably more or less healthy, and stops our current ridiculous "superfood" thing. Positive effects from food can be represented with vitamins.

We may want to put a hard cap on how low your health can get from eating nothing but soda pop and potato chips. I would hazard that more than -25 is pretty crazy. When crunching the numbers, we should ensure that if your BMI is okay and you're getting all your vitamins, and getting good sleep and exercise, eating junk alone isn't enough to put you into the negatives.

Getting all your vitamins

For every vitamin you hit 100% of the RDA for in a day, you should get +1 health. There might be an argument for this to drop back to zero if you go too far and overdose on the vitamin, but for most of our vitamins that's not a reasonable risk, so it could be specific to the vitamin itself and set in the vitamin json file.

Getting enough sleep

Every hour of sleep should give +1 daily health, sleeping more than six hours without interruption should double the total sleep effect (likely bringing it to the cap). Traits that reduce need for sleep should cause you to gain the double/triple/quadruple bonuses faster. There should be a hard cap of +10 for getting all your sleep. Sleep deprivation could apply a penalty.

Getting exercise

Reducing your stamina below 25% should give you a +1 health boost, up to five times per day, to represent your character getting some good ol' aerobic exercise.

Not dropping your stamina below 50% at all during the course of the day should apply a penalty, something like -4 since it's pretty tough to be that sedentary.

If your cardio accumulator for the day is positive, you should get a +1 health, or -1 if negative. If it is double digits, a +2 or -2.

Possible but maybe not necessary: If your cardio_accumulator is equal to or greater than 1/2 your BMR at the end of the day, you should get a +2 health bonus for that day as well. This means that someone in overall great shape who has a single sedentary day doesn't get less healthy, and in general having exercised a lot stacks and continues to improve your health over time. I am marking this as less certain because we're seeing pretty rapid rises in health now and we may not need this.

Getting hurt

Every point of damage you take should have a chance, probably around 10%, to apply a -1 health penalty for that day. Particular monster attacks could be given a higher chance of causing a health penalty. When we have better wound modelling we could have a requirement for things to break the skin before the penalty is applied.

A better suggestion from Dziugaske in comments: have health penalty based on time spent wounded. For ease of tracking we could still manage it as a chance of health penalty per turn that increases the lower your HP gets. Something like (total max HP - total current HP)/1000% chance each minute. This would just represent crap getting into your wounds, not enough to cause infection but enough that you're fighting it off.

Reducing stress

Every four hours you spend with an average negative morale below a threshold point (I'd say -10) should have a -1 health penalty, and every 4 hours with an average positive morale (anything +1 or more) should have a +1 health bonus. This would require keeping an "average morale" score and dumping it every four hours. Should be fairly straightforward I think.

Not being obese

Rather than our current (actually pretty reasonable) health cap system based on body weight, I propose that when daily_health is tallied into the average, we look at your BMI and provide a flat health bonus of about +2 if it's ideal weight, 0 if it's mildly over or under, and -2 for every category off the base - possibly increasing faster towards the extremes of over and underweight.

Before getting too up in arms about this one, see my recommendations for adjusting weight gain and loss.

Other factors

Doing drugs, eating rotting meat, and recovering from infection should have some impact on health. These should be handled on a case by case basis.

Gamma globulin shots should be removed, as should the huge health penalties for being poisoned. No individual effect should be more than around +1 or +2 per dose, unless it's a multi-hour thing like sleeping.

Effects of lifestyle

In general I think we're already modeling this quite well, with healing times and likelihood to get sick impacted by health. Surgery success should also be, if it's not already.

Going forward, having a high health should contribute to how quickly you improve attributes through exercise and practice.

Describe alternatives you've considered

Leaving the system as-is and just capping any effect on health to a +1 or -1 would actually be pretty effective.

Additional context

Some graphs and calculation to check my seat of the pants numbers will be needed here.

esotericist commented 4 years ago

For every vitamin you hit 100% of the RDA for in a day

this would require quite a lot of additional tracking, since we don't actually have any measure of "how many of each vitamin i've had today" only "how many of each vitamin I have total".

Do we really need to count if they're getting it all that day, instead of just checking if they're maintaining a healthy amount? I find it difficult to believe that getting e.g. 100% of iron literally every day is going to magically be better than getting 90% one day and 110% the next; the aggregate result is the same.

I-am-Erk commented 4 years ago

I would say if you hit 100% rda of that vitamin you get a +1 health bonus to your daily_health, and you can only have that bonus once. When your daily_health gets added into health_tally and resets, you become eligible to get it again. We don't have to track aggregate rda, just whether or not you got enough at some point in a day.

Overall if you're getting enough of the vitamin you should get this bonus quite frequently. There are enough bonus sources that missing it once in a while shouldn't matter.

esotericist commented 4 years ago

What I'm saying is that we do track aggregate right now.

I-am-Erk commented 4 years ago

Right, I just don't see a good way to use the aggregate to track whether or not you're getting enough, it would be a bit random to only look at what the aggregate is at the time daily_health is added to health_tally. Then if you're at 90% right that instant but were at 120% earlier in the day, it doesn't count. By tracking where it hits 100% and adding it to the tally right then, we assume your levels are bouncing up and down but by definition you're getting enough

Dziugaske commented 4 years ago

What about drinking bleach, methacola, atomic coffee and all other really nasty food items? I agree that a lot of food could just be rounded down to -1, but those seem a bit egregious.

I-am-Erk commented 4 years ago

Methacola and atomic coffee fall under the "drugs" case, and while they should have a penalty I don't think each dose should be very high.

Drinking bleach is a poison. It doesn't make you more likely to catch a cold, it kills you.

esotericist commented 4 years ago

the aggregate we have right now isn't "how close are you to maintaining 100% average intake" it's "you have x much in you"

my argument is all we need to know is: is the player at a 'good' total amount of stored-in-body for a given vitamin. outside of those bounds, then you don't get a bonus. too far outside of those bounds, then you get a penalty.

this gets the same effect as tracking if the player is getting approximately the right amount of stuff every day, because to stay within those bounds you need to have a pretty consistent intake.

no need to add any additional tracking, just define the bounds we consider good, the bounds we consider extra bad. just like when we define deficiencies and excess.

I-am-Erk commented 4 years ago

That's what the RDA represents, though. If a player has 75% of their RDA in their system, that should mean that at least at that moment, they don't have enough of that vitamin. As an instantaneous fluctuation that might be fine, but if that's a high point of their day, it means they're not getting enough of that thing and shouldn't get a health bonus.

esotericist commented 4 years ago

The values we store are much larger than "a day's worth of that vitamin", because the body holds more than a day's worth of that vitamin.

I-am-Erk commented 4 years ago

The other option we could look at, though I like it less, is giving a chance of a +1 health bonus equal to the amount of RDA you intake. So if you eat something with 75% of your RDA of vitamin C, you have a 75% chance of getting a +1 health bonus. However, I still wouldn't want you to get more than +1 health in this way so AFAICT it would be the same amount of tracking?

I'm not sure how much tracking this all represents, though. It could literally be just a boolean per vitamin, set to "true" the moment they hit daily allowance and reset when daily_health is added to the tracker, probably defined in the effects.json entry for the vitamin as a syndrome (because we don't want a health bonus for eating "enough" toxin, eg)

Dziugaske commented 4 years ago

Is getting hurt health penalty uncapped? Does the health penalty change depending on how much damage you take or is it always a flat 10%?

I-am-Erk commented 4 years ago

Good questions. I would say it should maybe be something like 1% per point of damage, really, maybe with a multiplier associated with particular types of injury, but we're really getting into better wound modeling there.

I don't think it should be capped, because really at the end of the day there's a hard cap of 'how many HP can I feasibly lose in one day'.

Dziugaske commented 4 years ago

I don't think it should be capped, because really at the end of the day there's a hard cap of 'how many HP can I feasibly lose in one day'.

My cyborg with Repair Nanobots would disagree :P We also have zombies that spew smoke, throw acid, shock and vomit on us. Seeing as none of these things are very healthy, it would be nice if they applied a health penalty. It would encourage players to seek out countermeasures, such as gas masks, rubber boots, nonconductive clothing and so on.

As for getting hurt, what if we tied the health penalty to being hurt? The longer you spend at low hitpoints, the more your health takes a toll. If you have a good first aid skill and use medicine, you would recover quicker and wouldn't take a massive health penalty. It would also work nicely with the lifestyle health stat, since recovering from wounds can take multiple days.

I-am-Erk commented 4 years ago

Yeah, I like that mechanic. For ease of tracking we could still manage it as a chance of health penalty per turn that increases the lower your HP gets. Something like (total max HP - total current HP)/1000% chance each minute. This would just represent crap getting into your wounds, not enough to cause infection but enough that you're fighting it off.

scorpion451 commented 4 years ago

The various resistances (disease resistant, infection resistant, poison resistant, etc.) should probably also be factored into the health drain calculation, with an interesting question of how: Subtracting the bonuses from the total means you ignore the chance of losing health up to a certain threshold, and offset the scaling as your HP drops. Adding bonuses to the divisor means you always have a chance to loose heath, but the relative benefits increase as injuries get more severe. So one makes you more tolerant of shallow injuries and favors those with low max HP, the other makes you more tolerant of deep injuries and benefits those with lots of HP more.

Malorn-Deslor commented 4 years ago

The basic idea of health actually being...useful sounds wonderful. In terms of RDA, however, make sure to allow for carryover, rather then requiring the RDA actually be eaten within the same day. Having to make sure you have good food that supplies the nutrition you need is fun and interesting. Micro-managing 'ok I need to drink one tea and then eat X, and then maybe some of X' each day sounds...not so fun. It doesn't actually make the game harder, since the difficulty is HAVING the nutrition, but it will add a lot of work for players that is is merely time-consuming, not difficult or meaningful.

Consider also, that lowering stamina is actually very easy to do, and can be done in any space that is more then a single square. (Turn on run, then move back and forth.) Since this can, in nearly EVERY situation, be entirely possible to do, it once again does not add difficulty, but merely adds make-work. Realism is important and useful, but at the same time realism only informs good gameplay. Getting exercise after the apocalypse is generally not going to be very difficult or problematic, and CDDA represents that quite realistically.

Is the goal really to have players have a checklist of things they HAVE to do each day, many of which are not themselves difficult or risky? Isn't the whole reason we automate things like farming and tree chopping is because the actions involved are not actually difficult, merely repetitive?

Or another way to look at it, can we assume the survivor is budgeting an 'exercise period' in days when they are not exerting themselves otherwise? What is gained by having that simulated? (Of course, you could go the farming route and merely have 'exercise' as an automatic activity, but it seems kinda unnecessary to add a feature in order to make that feature automatic so players could ignore it.)

Sorry if I merely sound negative. I really do like a lot of what was outlined, especially with removing superfoods and massive fluctuations in health.

I-am-Erk commented 4 years ago

Remember, the balance of this should only be such that it doesn't require micromanaging, just making sure your character doesn't sit in their bunker eating junk food and reading books. I realize we're all gamers and generally want to get The Most Points All The Time, but your health score is averaged over a week of game time, and a +1 or +2 here or there will have almost no individual effect. What it is meant to do is discourage your character from just sitting inside all the time, and add a small incentive to shaking it up a bit. If you choose to do that by running in circles, that's kind of your choice.

Having a maintenance action for using exercise equipment, when we have general maintenance actions, would be fine. When we have access to that stuff I'd suggest we get more granular about what constitutes exercise as well. For now the reason I kept it so general is that this makes it very easy to get that bonus most of the time.

Malorn-Deslor commented 4 years ago

Well, we certainly agree on the goal, then. I guess once it is in play it will be pretty clear if players find it worthwhile to 'micro' or not. I admit I think it will be something I will hate doing but won't be able to stop myself from doing, since it's 'free' benefit. Not everybody is going to be like that, of course.

My only other suggestion I can think of would perhaps be making the entire system 'week-wide'. That way there isn't the micro 'each day'. Then it's a benefit from getting some exercise over the week itself, allowing for more flexibility and less interruption of each daily activity.

One last question, do tasks like farming and chopping trees have any effect on stamina? Would it be possible to 'work' all day and still not gain the health benefits, since stamina never really dropped?

I-am-Erk commented 4 years ago

There are some definitions for activity levels in game for things like that that affect stamina. We might be better off tracking the amount of time players spend doing activity levels than tracking stamina, although I don't know if that works for combat and running. @KorGgenT do you know?

KorGgenT commented 4 years ago

"combat" (that is, hitting monsters with melee) and running/walking/crouching is indeed currently tracked with activity levels.

Do note that the activity levels don't tell you what activity raised the level.

scorpion451 commented 4 years ago

Crafting should probably give at least some amount of activity level, maybe linked to the type of tools used?

I can tell you from experience that 8 hours of working on a large painting will have you feeling the burn in your back, legs, and arms like few other things; basically like doing hours of aerobics while you solve geometry problems in your head. Things like blacksmithing or churning butter can be a hell of a workout, too, and even activities like sewing, soldering, or cooking can have you moving a lot more than you'd realize while doing it.

bloodraven983 commented 4 years ago

I wanna contribute:

A better suggestion from Dziugaske in comments: have health penalty based on time spent wounded.

I would add another detail: a bigger healthmalus for being infected or with a deep wound, based on how long do you have those kind of wounds

faefux commented 4 years ago

Every point of damage you take should have a chance, probably around 10%, to apply a -1 health penalty for that day. Particular monster attacks could be given a higher chance of causing a health penalty. When we have better wound modelling we could have a requirement for things to break the skin before the penalty is applied.

I know you --'d this out but this seems like a good idea with regard to getting poisoned or inhaling noxious gasses which currently are solely short term affects.

danielkwinsor commented 4 years ago

I've recently been working on healthchecks at work. I'd like to adapt a healthcheck response here for possible inspiration to the team. Because it's large, I'll put it at the bottom.

First let me recommend not to always do things as +1 or -1 but sometimes as weights and percentages. An example is if you ate 15 small "fun size" candy bars and 1 large turkey, entire thing. Are you at -14 for health? Perhaps these should have been scaled to the amount of food in weight or calories.

Things can be categorized, aggregated, and weighted too. The weighting will be especially helpful to allow the code to scale and be extended when new categories are added. Weighting example: If diet consisted of only food, give it a weight point value of 10. Pretend this is a "normal" value and roughly equals 10% of overall health. But for each unit of drugs and bleach eaten in diet, increase the weighting by 20*drug strength. No matter how good your diet was for the day, if you did too many hard drugs and brought diet down to 0%, it doesn't count for just a mere 10% overall; it could count for 50% and actually kill you. Please note... drugs might be kept separate from diet in actual implementation, but just for illustration here...

{
  "health": "75%",
  "components": {
    "exercise": {
      "status": "UP",
      "description" : "worked hard all day",
      "details": {
        "stamina_min": "33%",
        "stamina_average": "60%"
      }
    },
    "diet": {
      "status": "POOR",
      "junkFoodVersusGoodFood": {
        "ate": [
          "candy",
          "candy",
          "candy",
          "turkey"
        ]
      }
    },
    "vitaminsRemainingInBody" [
      "a":"100 milligrams",
      "iron": {
        "amount": 0,
        "description": "apply an iron deficiency malus"
      }
    ],
    "bodyParts": {
      "health": "50%",
      "components": {
        "torso": {
          "heart": "PUMPING",
          "CBM_1": "85%",
          "CBM_2": {
            "status": "0%",
            "reason": "needs battery"
        },
        "arm_right": {
          "status": "100%"
        },
        "arm_left": {
          "status": "100%"
        },
        "leg_right": {
          "status": "100%"
        },
        "leg_left": {
          "status": "MISSING",
          "details": {
            "put a malus to movement"
          }
        }
      }
    },
  }
}
I-am-Erk commented 4 years ago

Well, for one thing, if you ate fifteen chocolate bars and a turkey you'd be at -15 to health. A major part of my above recommendation is to remove the positive effects of food on health, in a large part because the idea that you can cancel out a chocolate bar by eating a salad is ridiculous, and also because the decisions for what is healthy are fully arbitrary.

Overall you have some interesting ideas there but I think you're imagining a more granular health system than I'm describing. A lot of individual nitty gritty aspects of health are covered, or will be covered, by other stats. Health needs to make more sense than it currently does, but doesn't need to stand in for every aspect of physical well-being. Rather, I picture it as the general summary of lifestyle effects more subtle than cardiovascular fitness or muscle strength. I'm not sure but it sounds like you're modeling it to cover a much broader scope?

danielkwinsor commented 4 years ago

That's right; I didn't put every detail in because that scope is yet to be defined, but with this methodology you can start small and build upon it. I do understand that right now health is mostly used (in simply terms, no offense) as a check for whether to randomly apply the flu or not, and you can keep it that way or track more things and start applying more and varied sicknesses / maluses.

Sorry, I was not meaning to say the good food should cancel out the junk food. I was calling out the difference between eating 15 tiny pieces of candy in 15 sittings, of 10 calories each, versus 1 King size bar at more than 150 calories. Your proposal will penalize one of those scenarios. Maybe I should have said cookie: which in game varies between 26 and 799 kcal. If you accept that the empty calories are what matter in this unhealthiness, and adopt a solution that scales by weight/calorie, then there's a next logical --and optional-- step in saying there's a difference between vegetarian nachos and toaster pastry, both "junk foods" about 200 kcal. This difference can be modeled by saying -1 and -0.1

I-am-Erk commented 4 years ago

Ah I getcha. Yeah, we could easily add a formula like "every 200 kcal of junk is -1 health". I like that.

Cimanyd0 commented 2 years ago

Here are some issues I've noticed, which I mention here since all of those changes by @Fris0uman refer back to here.

I-am-Erk commented 2 years ago

Due to my bad formatting, indeed there was a bug and a less well thought out initial idea was implemented instead of the correct one. I've fixed the formatting, too late, but we should adjust this to use cardio. It is agnostic to source of exercise and amount of exercise and instead will look at your overall amount of activity for the day based on your health. There are still some tweaks needed to cardio accumulator as well but they would all flow downstream anyway

I-am-Erk commented 2 years ago

Reviewing the remaining points in the issue, I think we can basically leave out the last few impacts on health we currently have here, besides possibly reviewing how obesity affects it. I would like to audit the places health is used in the code, such as wound healing, and make sure it doesn't have too strong an effect on any one of these: health should have a minor noticeable impact on a wide range of things, but not any singularly huge impacts.

kevingranade commented 1 year ago

This issue has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/no-positive-health-foods/28249/14