forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make nanobot work regardless of splint
- Loading branch information
Showing
6 changed files
with
85 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "regen.h" | ||
#include "character.h" | ||
#include "rng.h" | ||
|
||
const flag_id flag_SPLINT( "SPLINT" ); | ||
|
||
namespace | ||
{ | ||
|
||
/// Limb is broken without splint | ||
auto has_broken_limb_penalty( const Character &c, const bodypart_id &bp ) -> bool | ||
{ | ||
return c.is_limb_broken( bp ) | ||
&& !c.worn_with_flag( flag_SPLINT, bp ); | ||
} | ||
|
||
/// Broken limbs without splint heal slower up to 25% | ||
auto mending_modifier( const Character &c ) -> float | ||
{ | ||
return clamp( c.mutation_value( "mending_modifier" ), 0.25f, 1.0f ); | ||
} | ||
|
||
} // namespace | ||
|
||
auto heal_adjusted( Character &c, const bodypart_id &bp, const int heal ) -> int | ||
{ | ||
const float broken_regen_mod = mending_modifier( c ); | ||
const int broken_heal = roll_remainder( heal * broken_regen_mod ); | ||
const bool is_broken = has_broken_limb_penalty( c, bp ); | ||
const int actual_heal = is_broken ? broken_heal : heal; | ||
|
||
c.heal( bp, actual_heal ); | ||
|
||
return actual_heal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
#ifndef CATA_SRC_REGEN_H | ||
#define CATA_SRC_REGEN_H | ||
|
||
#include "type_id.h" | ||
|
||
class Character; | ||
|
||
/// like heal, but actually takes account of | ||
/// - whether limb suffers from being broken without splint | ||
/// - `mending_modifier` | ||
/// | ||
/// @return actually healed amount. used for `mod_part_healed_total` | ||
/// | ||
/// TODO: merge into `Character::heal`? | ||
auto heal_adjusted( Character &c, const bodypart_id &bp, const int heal ) -> int; | ||
|
||
#endif // CATA_SRC_REGEN_H |