Skip to content

Commit c6e58fc

Browse files
authored
Enhance limb healing functionality (#55069)
1 parent 3f2ba3d commit c6e58fc

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

doc/JSON_FLAGS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ Some armor flags, such as `WATCH` and `ALARMCLOCK` are compatible with other ite
340340
## Bodyparts
341341

342342
- ```ALWAYS_BLOCK``` This nonstandard bodypart is always eligible to block in unarmed combat even if your martial arts don't allow such blocks.
343+
- ```ALWAYS_HEAL``` This bodypart regenerates every regen tick (5 minutes, currently) regardless if the part would have healed normally.
344+
- ```HEAL_OVERRIDE``` This bodypart will always regenerate its `heal_bonus` HP instead of it modifying the base healing step. Without `ALWAYS_HEAL` this still only happens when the part would have healed non-zero amount of damage.
343345
- ```IGNORE_TEMP``` This bodypart is ignored for temperature calculations
344346
- ```LIMB_LOWER``` This bodypart is close to the ground, and as such has a higher chance to be attacked by small monsters - hitsize is tripled for creatures that can't attack upper limbs.
345347
- ```LIMB_UPPER``` This bodypart is high off the ground, and as such can't be attacked by small monsters - unless they have the `FLIES` or have `ATTACK_UPPER` flags`

doc/JSON_INFO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ For information about tools with option to export ASCII art in format ready to b
649649
| `temp_mod` | (_optional array_) Intrinsic temperature modifier of the bodypart. The first value (in the same "temperature unit" as mutations' `bodytemp_modifier`) is always applied, the second value is apllied on top when the bodypart isn't overheated.
650650
| `env_protection` | (_optional_) Innate environmental protection of this part. (default: `0`)
651651
| `stat_hp_mods` | (_optional_) Values modifying hp_max of this part following this formula: `hp_max += int_mod*int_max + dex_mod*dex_max + str_mod*str_max + per_mod*per_max + health_mod*get_healthy()` with X_max being the unmodified value of the X stat and get_healthy() being the hidden health stat of the character.
652-
| `heal_bonus` | (_optional_) Innate amount of HP the bodypart heals every healing roll ( 5 minutes, currently ).
652+
| `heal_bonus` | (_optional_) Innate amount of HP the bodypart heals every successful healing roll. See the `ALWAYS_HEAL` and `HEAL_OVERRIDE` flags.
653653
| `mend_rate` | (_optional_) Innate mending rate of the limb, should it get broken. Default `1.0`, used as a multiplier on the healing factor after other factors are calculated.
654654
| `health_limit` | (_optional_) Amount of limb HP necessary for the limb to provide its melee `techniques` and `conditional_flags`. Defaults to 1, meaning broken limbs don't contribute.
655655
| `bionic_slots` | (_optional_) How many bionic slots does this part have.

src/character.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ static const itype_id itype_rm13_armor_on( "rm13_armor_on" );
277277

278278
static const json_character_flag json_flag_ACID_IMMUNE( "ACID_IMMUNE" );
279279
static const json_character_flag json_flag_ALARMCLOCK( "ALARMCLOCK" );
280+
static const json_character_flag json_flag_ALWAYS_HEAL( "ALWAYS_HEAL" );
280281
static const json_character_flag json_flag_BASH_IMMUNE( "BASH_IMMUNE" );
281282
static const json_character_flag json_flag_BIO_IMMUNE( "BIO_IMMUNE" );
282283
static const json_character_flag json_flag_BLIND( "BLIND" );
@@ -291,6 +292,7 @@ static const json_character_flag json_flag_ELECTRIC_IMMUNE( "ELECTRIC_IMMUNE" );
291292
static const json_character_flag json_flag_ENHANCED_VISION( "ENHANCED_VISION" );
292293
static const json_character_flag json_flag_EYE_MEMBRANE( "EYE_MEMBRANE" );
293294
static const json_character_flag json_flag_FEATHER_FALL( "FEATHER_FALL" );
295+
static const json_character_flag json_flag_HEAL_OVERRIDE( "HEAL_OVERRIDE" );
294296
static const json_character_flag json_flag_HEATPROOF( "HEATPROOF" );
295297
static const json_character_flag json_flag_HEATSINK( "HEATSINK" );
296298
static const json_character_flag json_flag_HYPEROPIC( "HYPEROPIC" );
@@ -7526,10 +7528,21 @@ void Character::heal_bp( bodypart_id bp, int dam )
75267528

75277529
void Character::heal( const bodypart_id &healed, int dam )
75287530
{
7529-
if( !is_limb_broken( healed ) ) {
7530-
int effective_heal = std::min( dam + healed->heal_bonus,
7531+
if( !is_limb_broken( healed ) && ( dam != 0 || healed->has_flag( json_flag_ALWAYS_HEAL ) ) ) {
7532+
add_msg_debug( debugmode::DF_CHAR_HEALTH, "Base healing of %s = %d", body_part_name( healed ),
7533+
dam );
7534+
if( healed->has_flag( json_flag_HEAL_OVERRIDE ) ) {
7535+
dam = healed->heal_bonus;
7536+
add_msg_debug( debugmode::DF_CHAR_HEALTH, "Heal override, new healing %d", dam );
7537+
} else {
7538+
dam += healed->heal_bonus;
7539+
add_msg_debug( debugmode::DF_CHAR_HEALTH, "Healing after bodypart heal bonus %d", dam );
7540+
}
7541+
int effective_heal = std::min( dam,
75317542
get_part_hp_max( healed ) - get_part_hp_cur( healed ) ) ;
75327543
mod_part_hp_cur( healed, effective_heal );
7544+
add_msg_debug( debugmode::DF_CHAR_HEALTH, "Final healing of %s = %d", body_part_name( healed ),
7545+
dam );
75337546
get_event_bus().send<event_type::character_heals_damage>( getID(), effective_heal );
75347547
}
75357548
}

0 commit comments

Comments
 (0)