mon->mhp manipulation

I've hunted for other instances where monster hit points were set
to zero or less without calling the routine that kills off the
monster (see recent mon_unslime() vs zhitm()) and didn't find any
for mhp subtraction.  I haven't checked for direct assignment yet.

For a while I thought I'd found several cases where a monster was
intended to be killed but got left with positive hit points, but
it turned out that lifesaved_monster(), of all places, was setting
them to zero.  I've moved that to its callers so that it isn't so
well hidden.  And changed several ''if ((mon->mhp -= dmg) <= 0)''
into separate subtraction and 'if' just so the mhp manipulation is
a bit more visible.

I think the only actual change here is the message for monster
being killed by lava, where glass golems now melt instead of burn.
This commit is contained in:
PatR
2016-05-21 18:25:16 -07:00
parent 29e9179ca5
commit c1bfa1360f
7 changed files with 49 additions and 28 deletions

View File

@@ -2531,7 +2531,8 @@ register struct monst *mtmp;
if (in_sight)
seetrap(trap);
if ((mtmp->mhp -= dmgval2) <= 0)
mtmp->mhp -= dmgval2;
if (mtmp->mhp <= 0)
monkilled(mtmp,
in_sight
? "compression from an anti-magic field"
@@ -3885,7 +3886,8 @@ boolean force_failure;
if (ttype == BEAR_TRAP) {
if (mtmp->mtame)
abuse_dog(mtmp);
if ((mtmp->mhp -= rnd(4)) <= 0)
mtmp->mhp -= rnd(4);
if (mtmp->mhp <= 0)
killed(mtmp);
} else if (ttype == WEB) {
if (!webmaker(youmonst.data)) {
@@ -4941,9 +4943,9 @@ boolean nocorpse;
if (dam < 1)
dam = 1;
}
if ((mon->mhp -= dam) <= 0) {
int xx = mon->mx;
int yy = mon->my;
mon->mhp -= dam;
if (mon->mhp <= 0) {
int xx = mon->mx, yy = mon->my;
monkilled(mon, "", nocorpse ? -AD_RBRE : AD_PHYS);
if (mon->mhp <= 0) {