-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow mutations to affect cardio #53603
Conversation
f2d32ba
to
957b591
Compare
While we're at it why should either version of the "max stamina" modifier intrinsically increase stamina regen? We have a dedicated mutation property for that (not sure whether that one plays nice with cardio) so it would be trivial to remove this hidden effect and instead spell it out explicitly in the mutation data. |
There's detail, discussion, and math at #39994 where it was added. The gist is, we want total stamina regen time to be the same, even if you have more total stamina. So with a higher max, you need more regen to reach the max in the same amount of time. |
After further testing with various builds (pre-cardio master, post-cardio master, and variations of this branch), I am convinced that the cardio and stamina/regen calculations are definitely broken, or at least wildly skewed from their original behavior with regard to size-altering and cardio-altering mutations. For instance, HUGE characters can somehow run 23 steps further than normal characters in a post-cardio world, and SMALL characters run out of breath 6 steps earlier than normal characters. This should not be happening. I am reconsidering the |
I don't think they're "broken" so much as this is the inevitably result of tying CARDIO heavily to base metabolic rate. A Huge character has a BMR about twice that of an average-sized character, which results in both a significant immediate increase in stamina, and a long-time increase from CARDIO_ACCUMULATOR due to increased calorie consumption. The reverse would be true of mutations like Tiny. e: and of course a significantly increased maximum cardio (and therefore stamina) as well For the same reason, Fast Metabolism is now a colossal buff to stamina - and mutations like Heat Dependant and Light Eater are significant nerfs. If you're curious about the effect sizes at play: I've been playing max-height, Fast Metabolism characters that mutate into Ursine or Cattle lately. That puts my starting BMR at about 3500 and my final BMR somewhere between 6500 and 7000. Such a character starts with about 12k stamina and immediately jumps to about 24k when they mutate Huge. By my calculations, they would eventually hit 50k+ stamina solely as a result of their natural base metabolism, although it would take something like an entire season to get there. And aside from the degree of difference perhaps being a bit extreme, I think that mostly makes sense? The tradeoff cold-blooded creatures make is that they're less active, but require fewer resources. The "Tiny" thing seems weird on the surface, but the relevant lines also have mutations like Rapid Metabolism and Hyperactive that, once they're fully functional again, should more than compensate. And idk about the biology if this one, but at least aesthetically it makes sense that enormous bear person could just keep going and going forever. |
Not really, although most of it is just the square cube law which the game happily ignores otherwise. I am not sure what actually determines the short-term endurance we call "stamina" across the entirety of the animal kingdom but there are many small factors at play. Oxygenation, sugar(/ATP?) supply and heat dissipation definitely are important but many animals are built more around their niche lifestyle (grazers, ambush predators, foragers) than what their broader lineage is physically capable of. Another part of the issue is that we don't really distinguish how exertion scales with character size. The act of dragging a crate of rocks on the ground represents a fixed exertion of force and energy, which means it becomes proportionately easier for larger characters. A similar point could be made for swinging a fixed size sledgehammer although for something lighter like a mace you also need to consider the acceleration of the wielding arm. And running or swimming means you should feel the full impact of square cube scaling because all the energy is deposited within your own body. And then you add body temperature to the mix where larger bodies benefit from both proportionately lower surface area and higher thermal mass (take longer to cool down) and how much temperature management dictates short-term metabolism in different animals. TL;DR: it's complicated, we need a Ph. D in biology for this. |
01d622c
to
43fbac7
Compare
e1f193f
to
f16d274
Compare
After spending the vast majority of my time on this PR trying to get the test case in a fairly robust condition, and between that and tedious manual testing (running back and forth and counting steps like a bloody human FitBit), I am happy with how this balanced out in the end, at least for the three mutations I was most concerned about (Languorous, Indefatigable, and Hyperactive). See test results in the PR description. The test case's I noted several FIXMEs in the test case where some mutations got a significant buff, possibly too much. For example, despite having lower stamina, all the COLDBLOOD traits can run at least 20 steps further than they could before Cardio, and an "Extreme Metabolism" gives more than 30 extra steps. These tests should make them easier to rebalance, but I'm not doing that part in this PR. |
78618a1
to
71c6ca5
Compare
New cardio_multiplier field is applied as a scaling factor to total cardio fitness, similar to the max_stamina_modifier field it replaces. Total balance in terms of running distance is now about the same as it was before cardio. - Implement cardio_multiplier in get_cardiofit - Refactor and document update_stamina - Convert CARDIO mutations to cardio_multiplier - CRIT mod: Convert Persistent Body to cardio_multiplier - Update mutation descriptions to reflect cardio effects. - Replace Debug Stamina mutation with Debug Cardio mutation - Document stamina_regen_modifier and cardio_multiplier in JSON_INFO - Remove max_stamina_modifier entirely
This test covers several aspects of cardio fitness, stamina, and running distance, especially related to mutations affecting cardio and stamina, and in particular the three CARDIO traits affected by CleverRaven#52980. Some FIXMEs are noted, where trait buffs have changed significantly since the introduction of cardio, and may need to be rebalanced. Several stub test cases are included to invite future collaboration.
ef74300
to
2d4a90c
Compare
The numbers seem to be different on current |
Ah, darn, I was afraid of this. Each step drains stamina by a randomized amount, so there's a chance of some discrepancy, but that's an awfully big difference - more than could reasonably be handled by a larger In most of my testing, I got away with Thanks for pointing this out, I will investigate. |
Confirmed running locally with the same
Edit: It failed on one of my own PRs with random seed 1641057818 - these are off by more like 6-8: |
Summary
Bugfixes "Allow mutations to affect cardio"
Purpose of change
Ever since #51880, the
max_stamina_modifier
mutation attribute (intended as a multiplier on maximum stamina) has been wrongly applied to the cardio fitness calculation (being added rather than multiplied), making the "Languorous", "Indefatigable" and "Hyperactive" mutations have virtually no effect on maximum stamina.Fixes #52980
Describe the solution
max_stamina_modifier
mutation attribute withcardio_multiplier
Character::get_cardiofit()
to apply it as a multiplier to cardio fitness, instead of multiplying staminaCharacter::update_stamina()
Describe alternatives you've considered
The original mutation field
max_stamina_modifier
is presently only used by these three mutations in vanilla, and one mutation in CRIT ("Persistent Body"). Could keep the field around in deprecated form for a while before removing it entirely, but with so few usages, it seemed simpler to just change it.Keeping the original name of the field would be misleading, since it affects more than just max stamina now, and it was never just a "modifier" but a "multiplier".
Testing
Run
tests/cata_test '[cardio]'
Find some pavement, and run back and forth; count how many steps you can take before getting winded. Try with different mutations.
My measured in-game barefoot running distances on pavement were as follows:
Additional context
I would like to restore something close to the original balance on these traits, in terms of:
Maximum stamina used to be exactly 10,000. However, with the new cardio system, maximum stamina depends on cardio fitness level; for a default unmutated character, cardio fitness level is 1738, and maximum stamina is 3500 + 3 * 1738 = 8714.
These mutations used
max_stamina_modifier
to adjust maximum stamina by these amounts:So these (approximate) stamina maximums will be the target for the new
cardio_multiplier
equivalent.Since the most measurable in-game effect of maximum stamina (and regen) is how far you can run before getting winded, I would like to also make that as close as feasible to its former (pre-cardio) behavior.
Note See the new test cases for verification on this front.