MCPcopy Create free account
hub / github.com/NetHack/NetHack / healmon

Function healmon

src/mon.c:4595–4614  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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. */
4595int
4596healmon(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

Callers 15

potionhitFunction · 0.85
passiveFunction · 0.85
m_cure_selfFunction · 0.85
engulfer_digests_foodFunction · 0.85
new_wereFunction · 0.85
artifact_hitFunction · 0.85
tacticsFunction · 0.85
mdamagemFunction · 0.85
passivemmFunction · 0.85
mon_catchup_elapsed_timeFunction · 0.85
m_consume_objFunction · 0.85
golemeffectsFunction · 0.85

Calls 1

healupFunction · 0.85

Tested by

no test coverage detected