Heal the given monster by amt hitpoints, unless it is somehow prevented from healing. "overheal" is the maximum amount by which the max HP will increase to allow for the healing (the resulting HP caps at max HP + overheal, and the max HP stays the some unless it needs to increase to accommodate the new HP). Overhealing the player is not currently implemented by this method. This
| 4593 | amt and overheal must not be negative (0 is allowed, and a very common |
| 4594 | amount for overheal). Returns the number of hitpoints healed. */ |
| 4595 | int |
| 4596 | healmon(struct monst *mtmp, int amt, int overheal) |
| 4597 | { |
| 4598 | if (mtmp == &gy.youmonst) { |
| 4599 | int oldhp = Upolyd ? u.mh : u.uhp; |
| 4600 | healup(amt, 0, 0, 0); |
| 4601 | return (Upolyd ? u.mh : u.uhp) - oldhp; |
| 4602 | } else { |
| 4603 | int oldhp = mtmp->mhp; |
| 4604 | if (mtmp->mhp + amt > mtmp->mhpmax + overheal) { |
| 4605 | mtmp->mhpmax += overheal; |
| 4606 | mtmp->mhp = mtmp->mhpmax; |
| 4607 | } else { |
| 4608 | mtmp->mhp += amt; |
| 4609 | if (mtmp->mhp > mtmp->mhpmax) |
| 4610 | mtmp->mhpmax = mtmp->mhp; |
| 4611 | } |
| 4612 | return mtmp->mhp - oldhp; |
| 4613 | } |
| 4614 | } |
| 4615 | |
| 4616 | |
| 4617 | /* force all chameleons and mimics to become themselves and werecreatures |
no test coverage detected