From f63d9f07b7fe2cdc7dc4e81fced8c2d1fa78d778 Mon Sep 17 00:00:00 2001 From: anothersimulacrum Date: Wed, 12 Feb 2020 21:12:44 -0800 Subject: [PATCH] JSONize mending modifier from mutations 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. --- data/json/mutations/mutations.json | 21 ++++++++++++++------- doc/JSON_INFO.md | 1 + src/character.cpp | 1 + src/mutation.h | 2 ++ src/mutation_data.cpp | 1 + src/suffer.cpp | 12 +++--------- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/data/json/mutations/mutations.json b/data/json/mutations/mutations.json index 84f23be115f71..66519572df66b 100644 --- a/data/json/mutations/mutations.json +++ b/data/json/mutations/mutations.json @@ -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", @@ -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", @@ -785,7 +787,8 @@ "valid": false, "purifiable": false, "types": [ "HEALING" ], - "healing_resting": -0.66 + "healing_resting": -0.66, + "mending_modifier": 0.33 }, { "type": "mutation", @@ -797,7 +800,8 @@ "valid": false, "purifiable": false, "types": [ "HEALING" ], - "healing_resting": -0.9 + "healing_resting": -0.9, + "mending_modifier": 0.1 }, { "type": "mutation", @@ -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", @@ -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", @@ -1559,7 +1565,8 @@ "cancels": [ "ROT1", "ROT2", "ROT3" ], "prereqs": [ "FASTHEALER" ], "threshreq": [ "THRESH_LIZARD" ], - "category": [ "LIZARD" ] + "category": [ "LIZARD" ], + "mending_modifier": 20.0 }, { "type": "mutation", diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 804972bcb18ce..30127bc070186 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -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 you heal - This value would make you heal 20% faster ``` ### Vehicle Groups diff --git a/src/character.cpp b/src/character.cpp index a829eef142034..4da1afba5ef4a 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -5953,6 +5953,7 @@ static const std::map }, { "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> }, diff --git a/src/mutation.h b/src/mutation.h index 0c5c2f2430b68..363e751363194 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -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. diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index a3299bbc75d1a..82556b03d1e48 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -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 ); diff --git a/src/suffer.cpp b/src/suffer.cpp index 5bc3468735fad..04a9ba7fe63e1 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -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 );