Skip to content

Commit

Permalink
JSONize mending modifier from mutations (#37987)
Browse files Browse the repository at this point in the history
The effect mutations have on limb mending was hardcoded in a if/else
ladder. Yuck! Also, some of the slow healer mutations were not having
an impact on mending speed, so add that.
  • Loading branch information
anothersimulacrum authored Feb 13, 2020
1 parent 90419bd commit c2a9cde
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
21 changes: 14 additions & 7 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
"changes_to": [ "FASTHEALER2", "REGEN_LIZ" ],
"category": [ "MEDICAL" ],
"healing_awake": 0.2,
"healing_resting": 0.5
"healing_resting": 0.5,
"mending_modifier": 2.0
},
{
"type": "mutation",
Expand Down Expand Up @@ -773,7 +774,8 @@
"description": "You heal a little slower than most; sleeping will heal less HP.",
"starting_trait": true,
"types": [ "HEALING" ],
"healing_resting": -0.25
"healing_resting": -0.25,
"mending_modifier": 0.5
},
{
"type": "mutation",
Expand All @@ -785,7 +787,8 @@
"valid": false,
"purifiable": false,
"types": [ "HEALING" ],
"healing_resting": -0.66
"healing_resting": -0.66,
"mending_modifier": 0.33
},
{
"type": "mutation",
Expand All @@ -797,7 +800,8 @@
"valid": false,
"purifiable": false,
"types": [ "HEALING" ],
"healing_resting": -0.9
"healing_resting": -0.9,
"mending_modifier": 0.1
},
{
"type": "mutation",
Expand Down Expand Up @@ -1534,7 +1538,8 @@
"changes_to": [ "REGEN" ],
"category": [ "PLANT" ],
"healing_awake": 0.66,
"healing_resting": 0.5
"healing_resting": 0.5,
"mending_modifier": 4.0
},
{
"type": "mutation",
Expand All @@ -1546,7 +1551,8 @@
"prereqs": [ "FASTHEALER2" ],
"category": [ "SLIME", "TROGLOBITE" ],
"healing_awake": 2.0,
"healing_resting": 1.5
"healing_resting": 1.5,
"mending_modifier": 16.0
},
{
"type": "mutation",
Expand All @@ -1559,7 +1565,8 @@
"cancels": [ "ROT1", "ROT2", "ROT3" ],
"prereqs": [ "FASTHEALER" ],
"threshreq": [ "THRESH_LIZARD" ],
"category": [ "LIZARD" ]
"category": [ "LIZARD" ],
"mending_modifier": 20.0
},
{
"type": "mutation",
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ Note that even though most statistics yield an integer, you should still use
"fatigue_regen_modifier": 0.333, // Modifier for the rate at which fatigue and sleep deprivation drops when resting.
"healing_awake": 1.0, // Healing rate per turn while awake.
"healing_resting": 0.5, // Healing rate per turn while resting.
"mending_modifier": 1.2 // Multiplier on how fast your limbs mend - This value would make your limbs mend 20% faster
```
### Vehicle Groups
Expand Down
1 change: 1 addition & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5953,6 +5953,7 @@ static const std::map<std::string, std::function <float( std::vector<const mutat
mutation_value_map = {
{ "healing_awake", calc_mutation_value<&mutation_branch::healing_awake> },
{ "healing_resting", calc_mutation_value<&mutation_branch::healing_resting> },
{ "mending_modifier", calc_mutation_value<&mutation_branch::mending_modifier> },
{ "hp_modifier", calc_mutation_value<&mutation_branch::hp_modifier> },
{ "hp_modifier_secondary", calc_mutation_value<&mutation_branch::hp_modifier_secondary> },
{ "hp_adjustment", calc_mutation_value<&mutation_branch::hp_adjustment> },
Expand Down
2 changes: 2 additions & 0 deletions src/mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ struct mutation_branch {
// Healing per turn
float healing_awake = 0.0f;
float healing_resting = 0.0f;
// Limb mending bonus
float mending_modifier = 1.0f;
// Bonus HP multiplier. That is, 1.0 doubles hp, -0.5 halves it.
float hp_modifier = 0.0f;
// Second HP modifier that stacks with first but is otherwise identical.
Expand Down
1 change: 1 addition & 0 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ void mutation_branch::load( const JsonObject &jo, const std::string & )

optional( jo, was_loaded, "healing_awake", healing_awake, 0.0f );
optional( jo, was_loaded, "healing_resting", healing_resting, 0.0f );
optional( jo, was_loaded, "mending_modifier", mending_modifier, 1.0f );
optional( jo, was_loaded, "hp_modifier", hp_modifier, 0.0f );
optional( jo, was_loaded, "hp_modifier_secondary", hp_modifier_secondary, 0.0f );
optional( jo, was_loaded, "hp_adjustment", hp_adjustment, 0.0f );
Expand Down
12 changes: 3 additions & 9 deletions src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,17 +1604,11 @@ void Character::mend( int rate_multiplier )

// Mutagenic healing factor!
bool needs_splint = true;

healing_factor *= mutation_value( "mending_modifier" );

if( has_trait( trait_REGEN_LIZ ) ) {
healing_factor *= 20.0;
needs_splint = false;
} else if( has_trait( trait_REGEN ) ) {
healing_factor *= 16.0;
} else if( has_trait( trait_FASTHEALER2 ) ) {
healing_factor *= 4.0;
} else if( has_trait( trait_FASTHEALER ) ) {
healing_factor *= 2.0;
} else if( has_trait( trait_SLOWHEALER ) ) {
healing_factor *= 0.5;
}

add_msg( m_debug, "Limb mend healing factor: %.2f", healing_factor );
Expand Down

0 comments on commit c2a9cde

Please sign in to comment.