Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

Muscle strain: pass 1

Open I-am-Erk opened this issue 1 year ago • 12 comments

Summary

Features "Adds 'strain', modelling muscle use separate from aerobic stamina"

Purpose of change

See https://github.com/CleverRaven/Cataclysm-DDA/issues/59862 for the basic theory. I'm doing this slightly differently than in that proposal.

Basically, currently despite having all kinds of different pools of stats that run out as you use them, "stamina" covers a wide range of things that shouldn't be the same. Put simply, you shouldn't be unable to run after drawing your bow. As long as 'stamina' is a single vague thing, we can't easily balance eg. the ability to swing your sword without getting winded, and we can't easily add a tool for gaining strength as you use your muscles.

Describe the solution

This is a first pass and will be a bit prototypic. It adds a new pool, "strain", which uses roughly the same units as stamina. On the UI end, I would like to represent strain as increasing as the pool is used up, but on the back end I am keeping them the same so that it's easier to shift stamina costs straight over without rebalancing them sometimes. I suspect this will be a little confusing for contributors but I hope not too bad. On the back end you have start at max strain and drop to zero, in other words, calls to update_strain() using negative numbers will lead you closer to muscle failure. The UI is the only place it goes the other way, partly because of the word choice 'strain' and partly because it helps distinguish the two bars.

Strain uses the same 'units' as stamina, whatever those are: to port sometihng over to strain, you can use whatever previous methods we used for stamina calcs. Anything that uses burn_energy_arms now builds up strain primarily, although it still burns stamina at 25% the previous rate. This is a ballpark, eyeballed measure to get things in place to work on. In my playtests I suspect I've set it too low and we should bump it up to like 50% or something but I am not sure. It might also be something we need more refinement on, like maybe stamina should drop faster for low strain weapons and slower for high strain ones.

Strain has a smaller pool than stamina: it reaches its cap much faster. It also recovers faster. When you cap strain out, you're supposed to stop being able to smash and attack, and have to stop aiming your bow; however, I haven't yet been able to get that working. In my playtests, I can make about 8-10 attacks with a heavy sledge, and a lot more with my fists (I lost count) before running out of strain.

As your strain builds up, you also build up what I've called "Burn". This effectively reduces your maximum strain. In the current UI it's hidden, you just run out of strain faster the more you operate at high strain. Burn recovers much slower.

This pass will not add the big fun parts of strain, like the ability to transition Burn into Gainz that increase your strength. We'll get there.

And now a special category for everyone who notices that this totally messes with the game:

This totally messes with the game!

This is a huge paradigm shift to stamina and melee combat balance. I know. It's far, far too broad reaching for me to have even vaguely assembled playtest data, that's what happens next. I don't expect this to work well from the start, it's going to need your feedback.

Things that need fixing sooner rather than later:

  • the balance is probably not correct. There's very little data to use to get an idea of what's going to be right, so I've gone by feel here. I'll be shocked if I got it right.
  • The UI should show Burn. I'd like burn to appear on the end of the strain bar like this: ||\......██ to indicate the latter part of the strain bar can no longer be accessed. EDIT: Renech helped me glue together a very messy solution to this problem, but it definitely needs refinement in a dedicated PR.
  • we need better concepts for what happens as strain rises. Currently it stops you from attacking and bashing things. This should be made more interesting. I'd like to give players a small buff to attack speed when "fresh" and dropping as strain approaches 50%. I'd also like to stop people from drawing a bow and doing other things that need strain when the strain is at its very edge.
    • My thought here is that we should use the flinch/hesitate mechanic I've suggested for pain, so as your strain rises, rather than your attacks getting slower, you have a chance to "hesitate" (better word needed) for 20-50 ticks, aborting the attack temporarily. This will require adding this mechanic. I'd like it if this mechanic completely replaced the current "complete fail due to strain" mechanic, so that when your strain is totally maxed out, you just get a lot of flinches and rapidly rising burn.
So why are we changing things? Stamina worked okay.

It works okay, but not great. Besides the stuff listed, this change is something we've wanted for a long time. Here's some of the stuff it sets the stage for.

  • Strength gains over time
  • the ability to draw bows above your max draw strength at the cost of extra strain burn
  • running and athletics are no longer as penalizing to combat and vice versa (that's kind of already in)
  • cybernetic limbs that never tire
  • melee combat has a form of attrition as you fight so many zombies your arms gradually turn to jelly, but on the bright side, you just had a great upper body workout.

So, please bear with us as we try to add one of the most long-requested features in the game. After all, no pain, no gainz.

Describe alternatives you've considered

I really don't want to add yet another stat that we track, but I can't see any other very good way to balance this without sacrificing a lot of stuff we want.

Testing

Thanks to Renech for helping me do the UI stuff when my brain was too full.

image

When you get up to high levels of strain, for now it just stops you from doing things. This is meant to simulate "the wall" like in a workout, where you've just done so many pullups that your arms don't work any more (for me this happens after like, uh, like thirty pullups, I swear). For attacks, this is based on the stamina/strain cost of the weapon, for smashing this just kicks in if you've got less than 25% strain left. I'd like a finer tuned option for smashing but that can wait for later. Note that you can always make at least one attack even if it would cost more strain than you've got.

image

image

I've tested it a bunch, it's mostly working pretty well, but as I outlined above, the balance is not really bang on. I've tested it a fair bit but it's hard to recreate a realistic testing scenario after staring at the same thing for so long. Also, the balance is likely to change a fair bit as we refine the implementaiton

Additional context

Since it is quite confusing at first, here is the complete list of easily-confused terms for different types of fatigue:

  1. Stamina: Your aerobic capacity: runs out when you run around fast and do other things that would leave you 'winded' irl.
  2. Strain: Your muscle capacity, increases as you do hard resistance exercise like drawing a bow, lifting weights, or swinging a big thing.
  3. Weariness: In general how beat you are as you work hard through the day. Influenced by and has effects on both strain and stamina.
  4. Sleepiness: Formerly fatigue. How close is it to bedtime.
  5. Cardio: How much you've built up your stamina over the course of running around in the apocalypse
  6. Gainz: not yet implemented, but basically the same as cardio for your muscles.
  7. Focus and morale are also types of pool like this and so is hunger. Man we have a lot. I'm sure I'm forgetting some too.

I-am-Erk avatar Mar 30 '24 21:03 I-am-Erk

  1. Climbing should probably cause strain as well, especially when carrying a lot of gear. Might not be a first pass candidate, though.
  2. Thirst is another one of those...

PatrikLundell avatar Mar 31 '24 08:03 PatrikLundell

Just off the top off my head things that should increase strain. Just spitballing increase there is something that you didn´t think off yet:

  1. Being overencumbered (both wearing heavy loads and carrying heavy things).
  2. Melee attacks.
  3. Bashing things (you would be hitting with all your strength as which isn´t the cease with most mellee attacks).
  4. Crafting and construction activities should not just drain stamina but also strain depending on activity level. Probably not more than the passive regeneration of the character unless you have heavy fatigue/weariness or muscle burns.
  5. Digging manually.
  6. Mining manually.
  7. Trying to break free of a grab.
  8. Cutting down trees/cutting wood.
  9. Running. Should be relatively minor and you should run out of stamina long before strain in this cease.
  10. Jumping.
  11. Butchering. Normal butcheries wouldn´t be so bad. Dismemberment would be very draining on strain however.
  12. Breaking sticks.
  13. Swimming. This is a interesting one. Swimming slowly should drain your stamina quicker than your strain. Swimming quickly and forcefully however should drain your strain much quicker than your stamina. Swimming slowly should allow you to recover some strain up to a point.
  14. Specific types of training such as training with weights or strength forcused body exersices should be draining specifically strain.
  15. Dragging things.
  16. Smashing corpses.
  17. Moving objects. Heavily dependent on weight of the object (moving a dozen pillows one at a time shouldn´t cause any, Moving one 50 kilo vehicle frame should cause a lot).
  18. Dragging things. Special consideration should be given to vehicles. Things with wheels should have a massive reduction in the amount of strain they cause.
  19. Farming activities such as plowing, planting, digging and harvesting can be very strenious.

Implementing a strain drain for most activities wouldn´t add much at this stage but it would do much of the work for the next GAINZ part. Meaning you would only have to implement muscle gains and characters would start to automatically become buff from everything that should make them buff.

ADekema avatar Mar 31 '24 22:03 ADekema

The linked issue post is a good place to talk about things that should affect strain. In this PR I'm just trying to implement a prototypic version and it doesn't need to, nor should it, touch on every possible use case.

I-am-Erk avatar Apr 02 '24 02:04 I-am-Erk

Spell checker encountered unrecognized words in the in-game text added in this pull request. See below for details.

Click to expand
  • effective regen rate: %f, base rate: %f, cardio mod: %d, weary mod: %f

This alert is automatically generated. You can simply disregard if this is inaccurate, or (optionally) you can also add the new words to tools/spell_checker/dictionary.txt so they will not trigger an alert next time.

github-actions[bot] avatar Apr 06 '24 18:04 github-actions[bot]

This isn't really ready to merge, but it's ready for some more scrutiny now.

I-am-Erk avatar Apr 07 '24 06:04 I-am-Erk

Trying to add this in a simple form is just opening too many cans of worms, I am going to need to do a bit more infrastructure. not really surprising given the magnitude of the change.

  1. I think #73050 is necessary just to make these tests stop complaining so much. This adds a "flinch" mechanic, which strain will impact as well. Rather than being unable to attack at high strain, you'll 'flinch' more often as your strain bar reaches max. Even maxed out on strain you'll still be able to attack, but at reduced speed due to all the flinching.
  2. since ↑ would make strain do relatively little, we also need strength to drop off precipitously as you approach your strain limit. I would suggest that when you reach 80% of your strain meter, your strength starts linearly dropping until at 100% strain you have only 1/4 of your baseline strength left. Thanks to #72955 we can do this without obnoxiously tanking carry weight and from there movement speed and such. This has a (probably) desired side effect that you might become too weak to continue drawing your bow; in a follow up PR though I'd really like to give you the chance to loose your arrow before the aim action is canceled. (in general, we're probably going to be looking more at how bows and aim work now)

I can do 2 pretty easily, but 1 will require a separate PR by me or someone smart.

I-am-Erk avatar Apr 16 '24 19:04 I-am-Erk

Becoming unable to attack (with a bow) due to strength loss was a major pain in the past, because the STR requirements were incredibly high, including a bow recipe for a bow that wasn't possible to be used by humans using either of the normal character generation methods (not the "grab whatever you feel like" one). That has currently been alleviated by a reduction of the required STR, as well as the ability to adjust the bow tension to allow for a lower STR character to still use the good bows (to a lesser effect, of course). Rapidly tanking STR brings all that back, which is not good. You'd then again have to have an "overpowered" character to make sure you're not rendered weaponless by a single unfortunate hit that hurts a lot. Being able to flee would probably make the end situation marginally better than it was before, depending on how quickly STR loss would disarm you.

PatrikLundell avatar Apr 16 '24 19:04 PatrikLundell

Remember, rapidly tanking STR in this case can only kick in at the end of strain. For a bow, that means you've been holding it drawn for some time, and your muscles have given out. It's not something that kicks in due to externalities... being hit by a zombie doesn't change your strain, for example.

In the longer term, strain should have different impacts on aim for the most part, and this should be mostly unimportant; on a first pass, having your aim action cancel because you tried to aim for a long time and your muscles gave out is not that big a problem, even if it's not where I want it to end.

Remember too, strain recovers in a few seconds. If your str drops, you have to shake your arms out for a moment and then you can try again.

I-am-Erk avatar Apr 16 '24 19:04 I-am-Erk

what else needs to be done for this to be mergeable?

anoobindisguise avatar Apr 23 '24 21:04 anoobindisguise

  1. It has conflicts.
  2. Clang-tidy probably?

NetSysFire avatar Apr 23 '24 22:04 NetSysFire

@anoobindisguise, per the comment:

Trying to add this in a simple form is just opening too many cans of worms, I am going to need to do a bit more infrastructure. not really surprising given the magnitude of the change.

1. I think ["Flinch", a mechanic for making speed penalties less deadly and annoying #73050](https://github.com/CleverRaven/Cataclysm-DDA/issues/73050) is necessary just to make these tests stop complaining so much. This adds a "flinch" mechanic, which strain will impact as well. Rather than being unable to attack at high strain, you'll 'flinch' more often as your strain bar reaches max. Even maxed out on strain you'll still be able to attack, but at reduced speed due to all the flinching.

2. since ↑ would make strain do relatively little, we also need strength to drop off precipitously as you approach your strain limit. I would suggest that when you reach 80% of your strain meter, your strength starts linearly dropping until at 100% strain you have only 1/4 of your baseline strength left. Thanks to [Pain is less painful #72955](https://github.com/CleverRaven/Cataclysm-DDA/pull/72955) we can do this without obnoxiously tanking carry weight and from there movement speed and such. This has a (probably) desired side effect that you might become too weak to continue drawing your bow; in a follow up PR though I'd really like to give you the chance to loose your arrow before the aim action is canceled. (in general, we're probably going to be looking more at how bows and aim work now)

I can do 2 pretty easily, but 1 will require a separate PR by me or someone smart.

However I ran out of easy computer time to do c++, so it's hanging on that for the time being.

I-am-Erk avatar Apr 23 '24 22:04 I-am-Erk

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

github-actions[bot] avatar May 23 '24 23:05 github-actions[bot]