CleverRaven / Cataclysm-DDA

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

Reimplementation of slipperiness. #74950

Open zachary-kaelan opened 1 month ago

zachary-kaelan commented 1 month ago

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

69555 by @fairyarmadillo added slipperiness from things like boomer bile and slime, that could cause your character to fall over. It was later reverted in #72172, like an earlier attempt at slipperiness from oil was reverted in #47851. I've seen some interest in this feature returning in some form, but more discussion is required.

Solution you would like.

Calculation of slipperiness:

Properties of the footwear, terrain, and liquids should all be taken into account, plus character weight, for calculating a "traction factor". Realistically, the liquids should be a factor in a larger equation rather than being the focal point. Someone wearing bowling shoes on a waxed floor can be slipping even in the absence of any liquids.

Effects of slipperiness:

The traction factor can serve as a modifier that provides bonuses or penalties to a variety of actions and a few limb scores, with a direct impact on footing, and an indirect impact on or checks against balance when moving.

When someone skilled is doing something like dodging or swinging a weapon, they have an ingrained idea of the distances required and the optimal footwork to reach those distances. Obviously moving on slippery ground would significantly interfere with one's ability to be precise and exact with those movements. In particular, "stumbling" would be a lot more dangerous.

What about falling flat on your face? Well, most often when someone loses their balance, they might stagger around for a couple seconds, but don't quite fall. However, if you are hit, dodging a hit, or missing a swing, then that's much harder to recover from. The chance to stumble or get downed could be significantly reduced when next to a wall or piece or furniture, or holding a long enough item. Obviously the traction factor, balance, and footing would all also play a role, as well as various traits and effects. Unit tests would be useful for ensuring reasonable outcomes under various conditions.

Describe alternatives you have considered.

No response

Additional context

Very conveniently, there are tables online for coefficients of friction between a variety of materials, alongside the coefficients of friction while lubricated. There are also the viscosities of a number of fluids, including gasoline and blood.

kevingranade commented 1 month ago

It's a fairly straightforward process, make a list of the floor surfaces in game that have a chance of becoming notably slippery, i.e. smooth concrete (notably, not asphalt) and wood floors, and figure out how slippery they would be in the presence of different fluids. I'm going to assert that coefficient of friction is pretty much not what you're looking for here, many more surfaces are going to be disqualified due to porosity and roughness than due to inherent coefficient of friction of the material.

I.e. "dirt" or even more so "grass" isn't going to become slippery with the application of any reasonable amount of fluid. Asphalt is less absolute, but you need a lot of very slippery fluid to make much impact because of the macro-structure of the asphalt creating channels for the fluid to settle into, not to mention asphalt structures generally being designed with drainage in mind.

I don't think there's any combination of flags on terrains that you can use to infer whether a particular terrain is going to be subject to this, and I don't think adding enough such traits is going to be worthwhile, so I'd recommend that once you have your list of potentially slippery surfaces we can discuss what kind of tiers of slippery potential we need.

zachary-kaelan commented 1 month ago

My rough list from the terrain floors jsons:

A viscous enough fluid could make porous surfaces slippery, the obvious example being mud, but of course water, blood, bile, etc don't meet that requirement.

fairyarmadillo commented 1 month ago

Properties of the footwear, terrain, and liquids should all be taken into account, plus character weight, for calculating a "traction factor". Realistically, the liquids should be a factor in a larger equation rather than being the focal point. Someone wearing bowling shoes on a waxed floor can be slipping even in the absence of any liquids.

This was all in my original PR to some degree, so you could probably reuse most of that code. It also factored in the character's stats, athletic skill, and balance score, replacing these with some more basic checks for monsters (namely move speed, dodge skill, and a penalty for having the STUMBLES flag).

Not sure how you'd best differentiate the flatness/smoothness of tiles. It doesn't seem worth making a new json entry for, and seems kinda frivolous for more than one flag.

kevingranade commented 1 month ago

Looking at this list it seems to break down into:

"mostly flat but still rough on a small scale". I.e. these don't get "slippery when wet" signs, but a particularly slippery fluid would be problematic. Concrete Brick Stone masonry Sidewalk

Very flat and smooth. i.e. these DO get "slippery when wet" signs just based on a basic water spill. Linoleum Marble Waxed Elevator

These are very much "it depends" Wood can be very smooth/flat for engineered board, but can also be pretty rough, so it depends on the details. Scrap I'm not even clear what this is? Metal can be smooth and flat, or very commonly is embossed to specifically avoid being a slippery surface.

Also the not-in-the-game "smooth ice" terrain would bear mentioning as being always slippery.

I think this boils down to "slippery when wet" surfaces and "slippery when lubricated" (better name welcome) surfaces, this can be a pair of JSON flags. The impact of said slipperiness and mitigations to it are another issue. Potentially different lubricants would be free to make things even worse, and then there are mitigations to consider.

ADekema commented 1 month ago

There are more factors besides the types of surfice that can make someone slip.

  1. Snow is a type of weather that can make anything service slippery.
  2. Liquids can freeze and be far slippery as a result. I'm not sure if frozen bile, blood or acid would be more slippery or even if they can freeze. Water can already freeze ingame however and that could make any serfice slippery.
  3. Mud is slippery meaning that any grass or dirt next to water should be slippery as well.
  4. Rain might also make things slippery. I don't think that rain should actually spawn water as this would hit performance. I think instead that rain depending on the severity should have the same effect as if every outdoor serfice was covered by a certain amount of water.
  5. The angle might also affect slip chance. Think a angled roof or any slope covered in ice.
zachary-kaelan commented 1 month ago

347836829-c208651e-e867-4872-bdf8-8d49fdd1818a

I just did some accidental IRL testing and slipped and almost fell on this embossed metal staircase in my dress shoes. It wasn't even wet. We could really get into the weeds on shoe grippiness and surface roughness vs porousness, but if players were randomly slipping on dry surfaces that would be a bit silly and they would definitely be questioning why.

zachary-kaelan commented 1 month ago

This was all in my original PR to some degree, so you could probably reuse most of that code. It also factored in the character's stats, athletic skill, and balance score

The crucial missing piece is footwear. It takes the footing limb score into account, which is correct as footing is defined as “a secure grip with one’s feet”, but rubber boots have an encumbrance of 30 - which means a significant footing penalty - and they’re made for walking through areas that have wet floor signs.

Really, we can have footwear and terrain provide footing bonuses or penalties, and liquids on the ground too (conditional on the terrain they’re on), and have the effects of that propagate, checking just the limb scores to determine stumbles and falls.

There are things like this in the code:

if( you.has_effect( effect_shakes ) && one_turn_in( 75_seconds ) ) {
    you.mod_moves( -to_moves<int>( 1_seconds ) * 0.1 );
    you.add_msg_player_or_npc( m_warning, _( "Your shaking legs make you stumble." ),
                               _( "<npcname> stumbles." ) );
    if( !you.is_on_ground() && one_in( 10 ) ) {
        you.add_msg_player_or_npc( m_bad, _( "You fall over!" ), _( "<npcname> falls over!" ) );
        you.add_effect( effect_downed, rng( 3_turns, 10_turns ) );
        }
}

That can be removed, as the shakes effect for example causes reduced footing and balance, which would automatically result in more stumbling and potential falls.

kevingranade commented 1 month ago

slipped and almost fell on this embossed metal staircase in my dress shoes.

If you want to have footwear that causes otherwise ok surfaces to become slippery, that's fine actually? Dress shoes are notoriously bad about this kind of thing.

zachary-kaelan commented 1 month ago

It can be broken into SLIPPERY, SMOOTH, and NONPOROUS flags, if we want to assume that most terrain is rough and porous by default.

Fields don't appear to have a flags JSON entry. I assume it would be a new optional field with these possible values:

fairyarmadillo commented 1 month ago

rubber boots have an encumbrance of 30 - which means a significant footing penalty

I have never really understood the high encumbrances on footwear, and I feel like they are mostly relics from when all it affected was movement speed - and even that was a bit weird. I can run in boots just as fast as in sneakers, and every boot I've ever worn that didn't have heels was better for traction. Hiking an incline in Doc Martens is waaay easier than trying it in Vans, so maybe that all needs a look as a separate issue.

DSeyka commented 1 month ago

This just looks like it'll be a major PITA to balance vs different survivors. What if PC is a squid or a tiny mouse? Or a half-tree with the aforementioned hard-coded shakes effect?

zachary-kaelan commented 1 month ago

The limbs system and other mutation reworks will handle that.

ADekema commented 1 month ago

I´m not sure if this is already part of the PR but a major factor I that hasn´t been mentioned is movement mode. You are far more likely to slip of you are sprinting than walking and slipping would be very hard to do if you are crouching (you can catch yourself with your hands). Slipping would be impossible when going prone as it is very difficult to fall if you are already lying on the ground.

kevingranade commented 1 month ago

Rather than indirectly referencing attributes of the surface like smooth and nonporous, I'd prefer the flags to just say what they're doing, "slippery", "slippery when wet", "slippery when lubricated". That last one's not so great but it's growing on me. There are a number of attributes of a surface that come together to decide how prone to becoming slippery it is, so there could very well be not-smooth surfaces that nonetheless end up being slippery when wet.

fairyarmadillo commented 1 month ago

I´m not sure if this is already part of the PR but a major factor I that hasn´t been mentioned is movement mode.

The method I tried was that running inflicted a penalty and crouching, running quadripedally, or lying down made you immune. This was not perfect as the checks were happening every second rather than when attempting to move and quadrupeds shouldnt be completely immune, but the system was a first draft and those seemed like solvable problems.

zachary-kaelan commented 1 month ago

a major factor I that hasn´t been mentioned is movement mode

That one's obvious. But instead of movement mode we can just use movespeed straight up.

I'd prefer the flags to just say what they're doing, "slippery", "slippery when wet", "slippery when lubricated".

SLIP, SLIP_WET, SLIP_LUBE. Or we can do SLIP, WET_SLIP, LUBE_SLIP. My main concern though is surfaces like that metal staircase I slipped on dry in my dress shoes. SLIP_SHOES

fairyarmadillo commented 1 month ago

That one's obvious. But instead of movement mode we can just use movespeed straight up.

Sounds like a bad idea to me. Move speed is boosted by things that are meant to suggest you're becoming more nimble, and hampered by things that make you clumsy. Move mode is a much better metric and doesn't get in the way of other systems that would naturally cause slippage like injury etc.

For example, if it was move speed, then having an injured leg would both increase and decrease your chance of slipping, and that's just one example. Tons of stuff affects this, better to not involve it.