mhpmax of life-drained monsters

The report about problems after stone-to-flesh on a petrified
long worm included stethoscope feedback of 0(-1) hit points, after
life-draining.  I was unable to reproduce a maximum hp of -1 and hope
that it was a side-effect of the [already fixed] stale mon->wormno
value used when resurrecting the long worm.  Anyway, this changes
life-draining to never take mon->hpmax below mon->m_lev + 1 (the +1
is needed to cope with m_lev==0 monsters).  The same limit is also
applied to monster life-saving but more to avoid replicating the
arbitrary minimum of 10 (four instances) then because it might be
less than m_lev+1 somehow.

Sanity checking now tests whether a monster's max HP is less than
its level + 1 so if there are ways other than life-drain attacks for
it to drop that low, the fuzzer will choke.  The new check also tests
whether a monster's current HP is greater than max HP.

Polymophred hero killing a golem or vortex by vampire bite reported
"<Mon> dies."  Give an alternate message since those aren't alive.
This commit is contained in:
PatR
2020-06-27 18:15:19 -07:00
parent 30b19a3891
commit 7d7b98f0ae
7 changed files with 134 additions and 48 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 zap.c $NHDT-Date: 1591219976 2020/06/03 21:32:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.342 $ */
/* NetHack 3.6 zap.c $NHDT-Date: 1593306912 2020/06/28 01:15:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.343 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -600,8 +600,23 @@ boolean adjacentok; /* False: at obj's spot only, True: nearby is allowed */
return (struct monst *) 0;
}
/* heal the monster */
if (mtmp->mhpmax > mtmp2->mhpmax && is_rider(mtmp2->data))
/* heal the monster; lower than normal level might come from
adj_lev() but we assume it has come from 'mtmp' being level
drained before finally killed; give a chance to restore
some levels so that trolls and Riders can't be drained to
level 0 and then trivially killed repeatedly */
if ((int) mtmp->m_lev < mtmp->data->mlevel) {
int ltmp = rnd(mtmp->data->mlevel + 1);
if (ltmp > (int) mtmp->m_lev) {
while ((int) mtmp->m_lev < ltmp) {
mtmp->m_lev++;
mtmp->mhpmax += monhp_per_lvl(mtmp);
}
mtmp2->m_lev = mtmp->m_lev;
}
}
if (mtmp->mhpmax > mtmp2->mhpmax) /* &&is_rider(mtmp2->data)*/
mtmp2->mhpmax = mtmp->mhpmax;
mtmp2->mhp = mtmp2->mhpmax;
/* Get these ones from mtmp */