Skip to content

Commit

Permalink
Merge pull request #72892 from RenechCDDA/fix_negative_rest_V2
Browse files Browse the repository at this point in the history
Fix negative rest quality
  • Loading branch information
RenechCDDA authored and Procyonae committed May 24, 2024
1 parent 2a8906d commit 7592161
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3019,7 +3019,7 @@ See [MUTATIONS.md](MUTATIONS.md)
"always_invisible": true, // Super well hidden traps the player can never detect
"funnel_radius": 200, // millimeters. The higher the more rain it will capture.
"comfort": 0, // Same property affecting furniture and terrain
"floor_bedding_warmth": -500, // Same property affecting furniture and terrain
"floor_bedding_warmth": -500, // Same property affecting furniture and terrain. Also affects how comfortable a resting place this is(affects healing). Vanilla values should not exceed 1000.
"spell_data": { "id": "bear_trap" }, // data required for trapfunc::spell()
"trigger_weight": "200 g", // If an item with this weight or more is thrown onto the trap, it triggers. Defaults to 500 grams.
"drops": [ "beartrap" ], // ID of item spawned when disassembled
Expand Down Expand Up @@ -3249,7 +3249,7 @@ These values apply to crafting tasks performed at the WORKBENCH.
#### The following optional fields are specific to SEATs.
```c++
"comfort": 3, // (Optional, default=0). Sleeping comfort as for terrain/furniture.
"floor_bedding_warmth": 300, // (Optional, default=0). Bonus warmth as for terrain/furniture.
"floor_bedding_warmth": 300, // (Optional, default=0). Bonus warmth as for terrain/furniture. Also affects how comfortable a resting place this is(affects healing). Vanilla values should not exceed 1000.
"bonus_fire_warmth_feet": 200,// (Optional, default=0). Bonus fire warmth as for terrain/furniture.
```

Expand Down Expand Up @@ -5482,7 +5482,7 @@ How comfortable this terrain/furniture is. Impact ability to fall asleep on it.

#### `floor_bedding_warmth`

Bonus warmth offered by this terrain/furniture when used to sleep.
Bonus warmth offered by this terrain/furniture when used to sleep. Also affects how comfortable a resting place this is(affects healing). Vanilla values should not exceed 1000.

#### `bonus_fire_warmth_feet`

Expand Down
15 changes: 9 additions & 6 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6165,6 +6165,7 @@ float Character::rest_quality() const
map &here = get_map();
const tripoint your_pos = pos();
float rest = 0.0f;
const float ur_act_level = instantaneous_activity_level();
// Negative morales are penalties
int cold_penalty = -has_morale( morale_cold );
int heat_penalty = -has_morale( morale_hot );
Expand All @@ -6182,7 +6183,7 @@ float Character::rest_quality() const
}
const optional_vpart_position veh_part = here.veh_at( your_pos );
bool has_vehicle_seat = !!veh_part.part_with_feature( "SEAT", true );
if( activity_level() <= LIGHT_EXERCISE ) {
if( ur_act_level <= LIGHT_EXERCISE ) {
rest += 0.1f;
if( here.has_flag_ter_or_furn( "CAN_SIT", your_pos.xy() ) || has_vehicle_seat ) {
// If not performing any real exercise (not even moving around), chairs allow you to rest a little bit.
Expand All @@ -6191,20 +6192,21 @@ float Character::rest_quality() const
// Any comfortable bed can substitute for a chair, but only if you don't have one.
rest += 0.2f * ( units::to_celsius_delta( floor_bedding_warmth( your_pos ) ) / 2.0f );
}
if( activity_level() <= NO_EXERCISE ) {
if( ur_act_level <= NO_EXERCISE ) {
rest += 0.2f;
}
}
// These stack!
if( activity_level() >= BRISK_EXERCISE ) {
if( ur_act_level >= BRISK_EXERCISE ) {
rest -= 0.1f;
}
if( activity_level() >= ACTIVE_EXERCISE ) {
if( ur_act_level >= ACTIVE_EXERCISE ) {
rest -= 0.2f;
}
if( activity_level() >= EXTRA_EXERCISE ) {
if( ur_act_level >= EXTRA_EXERCISE ) {
rest -= 0.3f;
}
add_msg_debug( debugmode::DF_CHAR_HEALTH, "%s resting quality: %.6f", get_name(), rest );
return rest;
}

Expand Down Expand Up @@ -6437,7 +6439,8 @@ float Character::healing_rate_medicine( float at_rest_quality, const bodypart_id
}

rate_medicine *= mutation_value( "healing_multiplier" );
rate_medicine *= 1.0f + clamp( at_rest_quality, 0.0f, 1.0f );
// Sufficiently negative rest quality can completely eliminate your healing, but never turn it negative.
rate_medicine *= 1.0f + std::max( at_rest_quality, -1.0f );

// increase healing if character has both effects
if( has_effect( effect_bandaged ) && has_effect( effect_disinfected ) ) {
Expand Down

0 comments on commit 7592161

Please sign in to comment.