diff --git a/src/character.cpp b/src/character.cpp index b5c11820f157c..3c5280dedb2bc 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -7287,7 +7287,7 @@ int Character::heartrate_bpm() const //This function returns heartrate in BPM basing of health, physical state, tiredness, moral effects, stimulators and anything that should fit here. //Some values are picked to make sense from math point of view and seem correct but effects may vary in real life //This needs more attention from experienced contributors to work more smooth - //Average healthy is 60-80. That's a simple imitation of mormal distribution. There's probably a better way to do that. Possibly this value should be generated with player creation. + //Average healthy bpm is 60-80. That's a simple imitation of mormal distribution. There's probably a better way to do that. Possibly this value should be generated with player creation. int average_heartbeat = 70 + rng( -5, 5 ) + rng( -5, 5 ); float stamina_level = float(get_stamina()) / float( get_stamina_max() ); int stamina_effect = 0; @@ -7305,18 +7305,6 @@ int Character::heartrate_bpm() const stamina_effect = 2; } int heartbeat = average_heartbeat * ( 1 + stamina_effect );//can triple heartrate - int healthy = get_healthy();//already has over/underweight conditions factored - - float healthy_modifier = 0; - healthy_modifier = -0.05 * round( healthy / 20 );//a bit arbitary formula that can use some love - /*if ( healthy > 10 ) - { - healthy_modifier = -0.05 * ( healthy - 10 ) / 20;//5 percent per 20 health above 10. Might think of better way - } else if ( healthy < -10 ) { - { - healthy_modifier = 0.05 * ( healthy + 10 ) / 20;//-5 percent per 20 health above 10. Might think of better way - }*/ - heartbeat *= 1 + healthy_modifier;//probably a single clamp in the end should be enough int stim_level = get_stim(); int stim_modifer = 0; if ( stim_level > 0 ) @@ -7326,6 +7314,13 @@ int Character::heartrate_bpm() const } heartbeat *= 1 + stim_modifer; //add morale effects, mutations, fear(?), medication effects + //health effect that can make things better or worse is applied in the end. Based on get_max_healthy that already has bmi factored + int healthy = get_max_healthy(); + float healthy_modifier = 0; + //a bit arbitary formula that can use some love + healthy_modifier = -0.05 * round( healthy / 20 ); + heartbeat *= 1 + healthy_modifier; + //A single clamp in the end should be enough heartbeat = clamp( heartbeat, average_heartbeat, 250 ); return heartbeat; }