Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make monster::heal actually return amount healed #51183

Merged
merged 6 commits into from
Aug 29, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ int monster::heal( const int delta_hp, bool overheal )
if( hp > maxhp && !overheal ) {
hp = maxhp;
}
return maxhp - old_hp;
return hp - old_hp;
}

void monster::set_hp( const int hp )
Expand Down Expand Up @@ -3118,9 +3118,14 @@ void monster::on_load()
const int heal_amount = roll_remainder( regen * to_turns<int>( dt ) );
const int healed = heal( heal_amount );
int healed_speed = 0;
if( healed < heal_amount && get_speed_base() < type->speed ) {
if( get_speed_base() < type->speed ) {
int old_speed = get_speed_base();
actual-nh marked this conversation as resolved.
Show resolved Hide resolved
set_speed_base( std::min( get_speed_base() + heal_amount - healed, type->speed ) );
if( hp >= type->hp ) {
set_speed_base( type->speed );
} else {
set_speed_base( std::min( old_speed + std::ceil( heal_amount * type->speed / type->hp ),
actual-nh marked this conversation as resolved.
Show resolved Hide resolved
type->speed ) );
}
healed_speed = get_speed_base() - old_speed;
}

Expand Down