Describe the bug
The default HP value for 8 strength is 84, however, when you start character creation, and pick challenge-abandoned scenario and then pick anything else, your HP will be halved, as if frail trait was assigned to you.
P.S. Same bugs probably could apply to any other scenario with default traits at the start (e.g. prison break with psychopath)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
HP value must be reset to default number, when changing to scenario without "frail" trait at the start.
Versions and configuration(please complete the following information):
Testing revealed that selecting Challenge-abandoned scenario adds forced trait Frail, which in turn sets mutation_value( "hp_modifier" ) to -0.5 (which is responsible for halving the hp). Selecting any other scenario calls empty_traits() function, which calls my_traits.clear() and my_mutations.clear() functions that clear the whole traits list, but for some reason don't reset hp_modifier value. So this value stays even after resetting the scenario.
It's not just a bug with scenarios with forced traits.
Testing shows, it's a problem with the way reset_scenario() clears traits
Choose any scenario at all, then choose Frail trait, then change scenario
or choose frail trait manually, then choose any scenario.
it calls empty_traits() but HP is not recalculated.
This means you can also get free ADDITIONAL HP, by selecting tough trait, then choosing any scenario.
trait is gone, but hp remains.
empty_traits() calls on_mutation_loss() on all traits.
but it should be toggle_trait() - as toggle_trait seems to have the code to set the hp_modifier
or
unset_mutation( flag );
mutation_loss_effect( flag );
( which toggle_trait itself calls)
toggle_trait() is used when unselecting a trait manually, and that works correctly to recalculate hp.
using mutation_loss_effect in empty_traits() instead of on_mutation_loss() doesn't work either ( it looks like it should, but it doesn't)
so I suspect it needs to be toggle_trait() OR
at least both mutation_loss_effect() AND unset_mutation()
Beyond my ability to write the code to do so, but this is what I've found in investigations.
Most helpful comment
Testing revealed that selecting
Challenge-abandonedscenario adds forced traitFrail, which in turn setsmutation_value( "hp_modifier" )to -0.5 (which is responsible for halving the hp). Selecting any other scenario callsempty_traits()function, which callsmy_traits.clear()andmy_mutations.clear()functions that clear the whole traits list, but for some reason don't resethp_modifiervalue. So this value stays even after resetting the scenario.