CleverRaven / Cataclysm-DDA

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

Toggle bionics/deactivate mutations causes bonus stats ignored until next turn #78050

Closed osuphobia closed 1 day ago

osuphobia commented 4 days ago

Describe the bug

Activate/deactivate bionics or deactivate mutations will make bonus stats temporarily not applied to PC. Didn't check if it's a display-only issue or it actually affects your abilities.

Attach save file

Saint Bernard-trimmed.tar.gz

Steps to reproduce

1.Load the save, toggle bionics/mutations, wait a turn, see how stats change.

Expected behavior

Bonus stats displayed/applied correctly.

Screenshots

https://github.com/user-attachments/assets/463d90fc-dda4-4375-bf3c-78633a1f15bd

Versions and configuration

Additional context

No response

osuphobia commented 2 days ago

Turns out that this is another piece of the enchantment mess. Toggle bionics will call Character::reset, while deactivate mutations will call Character::apply_mods. Both will call Character::reset_stats, but the stats do not get calculated correctly, so you need to wait till next turn to refresh the stats. For Character::apply_mods, if no debuff to stats exists, it seems to be working correctly, but when debuffs that reduce your stats exists, it just apply the debuffs ever time this function is called. Character::apply_mods is also called when you get or lose a mutation, as it does not work properly, mutations that should add stat to base stats instead give bonus stats now. Disabling the reset functions will solve this issue.

https://github.com/user-attachments/assets/d280bffa-c1c8-4e50-a9e0-b3724fdff0f4

osuphobia commented 2 days ago

but when debuffs that reduce your stats exists, it just apply the debuffs ever time this function is called.

So if I change reset_stats to reset in apply_mods, this will not happen. Pain penalties will be counted multiple times if you do not clear hardcoded effects first. It still make bonus stats ingnored though.

osuphobia commented 2 days ago

Ahh, get_mod apply_mods no longer work, as we already moved from stat mod to enchantment.