CleverRaven / Cataclysm-DDA

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

Player is prompted to turn off/extinguish their wet towel (active) #59809

Closed DamienRoyan closed 5 months ago

DamienRoyan commented 2 years ago

Describe the bug

Screenshot says everything

I tried to sleep with this in my inventory and that showed up as if I had a flashlight or something on (I have no such thing in my inventory)

Steps to reproduce

  1. Get wet. Jump in pond in my case
  2. Dry self with towel
  3. Try to sleep with now wet towel in inventory

Expected behavior

Instructions unclear. How do I turn off my towel?... Oh wait that's impossible... or is it >_>

Screenshots

image

Versions and configuration

Additional context

No response

NetSysFire commented 2 years ago

Fun bug. Only thing I could think of why the game would warn you is that having soaking wet stuff around you could cause a cold but there is no way this is handled like this.

CalamityKing commented 2 years ago

As an absolute noob whose last major experience programming anything was in secondary school/high school and can scarcely comprehend some of the code here, I'm going to hazard a guess and say its because the item towel_wet is located the tool_armor type. A lot of other stuff that can be turnt on or off is in there.

descan commented 2 years ago

The 5-point anchor is also something that produces this pop-up.

I'm not sure how it's programmed, but it really should be only things that will keep the player awake that should prompt the pop-up.

PatrikLundell commented 2 years ago

I suspect it's connected to having an "active" state vs. a passive one. Apart from keeping the player awake, I'd also like to see a warning for active things that drain resources. I get a warning about shooter's earplugs, and I think that's OK. Turning them off will make my character deaf, which will help sleep, but may also assist in dying if the screams you can't hear are the ones of your companions dying...

CalamityKing commented 2 years ago

I've looked at the sleep code and the message is triggered to pop if an item: Has the flag: flag_litcig OR is active AND has sufficient ammo AND is considered a tool WITHOUT the flag flag_sleep_ignore.

Or at least I think I've read it right.

// List all active items, bionics or mutations so player can deactivate them std::vector<std::string> active; for( item_location &it : player_character.all_items_loc() ) { if( it->has_flag( flag_LITCIG ) || ( it->active && it->ammo_sufficient( &player_character ) && it->is_tool() && !it->has_flag( flag_SLEEP_IGNORE ) ) ) { active.push_back( it->tname() ); } }

descan commented 2 years ago

Ah, so it sounds like fixing this issue would just be a matter of adding the flag_sleep_ignore flag to a wet towel. I think Patrik is right that things that would drain resources should also produce the flag, so even if keeping a 5-point-anchor on all night is probably wise for the characters it's relevant for, it should still produce a pop-up. Can anyone think of any other items that have produced the pop-up that shouldn't? Or conversely, any items that should produce the pop-up but that do not?

CalamityKing commented 2 years ago

I think the bigger question is WHY does it even cause the message to pop? If I'm interpreting the conditions correctly, and if I'm honest I can't with 100% certainty say I am, it shouldn't appear because it has no ammo.

descan commented 2 years ago

Either somehow it's being thought by the game to have ammo, or the only flag that wet towels have ("WET" oddly enough) is being treated as litcig as well?

PatrikLundell commented 2 years ago

My interpretation is that the wet towel is presumably "active" when wet, and it has sufficient ammo as it doesn't need any. Thus, a check whether it actually has any ammo type ought to do away with this (and other potential) cases.

"Active" "tools" that have two states, such as a folding knife might fall into this category as well?

chrispikula commented 2 years ago

I think the bigger question is WHY does it even cause the message to pop? If I'm interpreting the conditions correctly, and if I'm honest I can't with 100% certainty say I am, it shouldn't appear because it has no ammo.

'AMMO' isn't always ammo, it's a very useful mechanism for several hacky things. See, pens, acetylene torches, metal d20's, etc.