1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
---
src/monster.cpp | 34 +++---
13 files changed, 184 insertions(+), 44 deletions(-)
diff --git a/src/monster.cpp b/src/monster.cpp
index 665d82321e8..c8c7d4d1c2b 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -2819,25 +2825,23 @@ void monster::process_effects_internal()
regeneration_amount = 0;
}
const int healed_amount = heal( round( regeneration_amount ) );
- if( healed_amount > 0 && one_in( 2 ) && g->u.sees( *this ) ) {
- add_msg( m_debug, ( "Regen: %s" ), healed_amount );
- std::string healing_format_string;
- if( healed_amount >= 50 ) {
- healing_format_string = _( "The %s is visibly regenerating!" );
- } else if( healed_amount >= 10 ) {
- healing_format_string = _( "The %s seems a little healthier." );
- } else {
- healing_format_string = _( "The %s is healing slowly." );
- }
- add_msg( m_warning, healing_format_string, name() );
+ if( healed_amount > 0 && g->u.sees( *this ) ) {
+ add_msg( m_warning, _( "The %1$s regenerates %2$s damage." ), name(), healed_amount );
}
if( type->regenerates_in_dark ) {
const float light = g->m.ambient_light_at( pos() );
- // Magic number 10000 was chosen so that a floodlight prevents regeneration in a range of 20 tiles
- if( heal( static_cast<int>( 50.0 * std::exp( - light * light / 10000 ) ) > 0 && one_in( 2 ) &&
- g->u.sees( *this ) ) ) {
- add_msg( m_warning, _( "The %s uses the darkness to regenerate." ), name() );
+ add_msg( m_debug, _( "%1$s local light level: %2$s" ), name(), light );
+ // Requires standing in a properly dark tile, scales as it gets darker
+ if( light < 11.0f && one_in( 2 ) && hp < type->hp ) {
+ // Regen will max out at 50 at 6.0 light (barely able to craft), or top off to max HP
+ int dark_regen_amount = std::min( static_cast<int>( 110.0f - ( light * 10.0f ) ), type->hp - hp );
+ dark_regen_amount = std::min( dark_regen_amount, 50 );
+ heal( round( dark_regen_amount ) );
+ if( dark_regen_amount > 0 && g->u.sees( *this ) ) {
+ add_msg( m_warning, _( "The %1$s uses the darkness to regenerate %2$s damage." ), name(),
+ dark_regen_amount );
+ }
}
}
--
2.43.0
|