/* Max HP the same, but current HP halved for both. The caller
* might want to override this by halving the max HP also.
* When current HP is odd, the original keeps the extra point.
+ * We know original has more than 1 HP, so both end up with at least 1.
*/
m2->mhpmax = mon->mhpmax;
m2->mhp = mon->mhp / 2;
*/
if (!is_clinger(mtmp->data) && !likes_lava(mtmp->data)) {
if (!resists_fire(mtmp)) {
- if (cansee(mtmp->mx, mtmp->my))
+ if (cansee(mtmp->mx, mtmp->my)) {
+ struct attack *dummy = &mtmp->data->mattk[0];
+ const char *how = on_fire(mtmp->data, dummy);
+
pline("%s %s.", Monnam(mtmp),
- mtmp->data == &mons[PM_WATER_ELEMENTAL]
- ? "boils away"
- : "burns to a crisp");
+ !strcmp(how, "boiling") ? "boils away"
+ : !strcmp(how, "melting") ? "melts away"
+ : "burns to a crisp");
+ }
mondead(mtmp);
} else {
- if (--mtmp->mhp < 1) {
+ mtmp->mhp -= 1;
+ if (mtmp->mhp < 1) {
if (cansee(mtmp->mx, mtmp->my))
pline("%s surrenders to the fire.", Monnam(mtmp));
mondead(mtmp);
/* genocided monster can't be life-saved */
if (cansee(mtmp->mx, mtmp->my))
pline("Unfortunately, %s is still genocided...", mon_nam(mtmp));
+ mtmp->mhp = 0;
}
- mtmp->mhp = 0;
}
void
struct permonst *mptr;
int tmp;
+ mtmp->mhp = 0; /* in case caller hasn't done this */
lifesaved_monster(mtmp);
if (mtmp->mhp > 0)
return;
* put inventory in it, and we have to check for lifesaving before
* making the statue....
*/
+ mdef->mhp = 0; /* in case caller hasn't done this */
lifesaved_monster(mdef);
if (mdef->mhp > 0)
return;
nocorpse = (xkill_flags & XKILL_NOCORPSE) != 0,
noconduct = (xkill_flags & XKILL_NOCONDUCT) != 0;
+ mtmp->mhp = 0; /* caller will usually have already done this */
if (!noconduct) /* KMH, conduct */
u.uconduct.killer++;
int dam = d(obj->spe + 2, 6);
/* 3.6.1: no Deaf filter; 'if' message doesn't warrant it, 'else'
- message doesn't need it since Your_hear() has one of its own */
+ message doesn't need it since You_hear() has one of its own */
if (vis) {
pline("%s zaps %s, which suddenly explodes!", Monnam(mon),
an(xname(obj)));
? "nearby" : "in the distance");
}
m_useup(mon, obj);
- if (mon->mhp <= dam) {
+ mon->mhp -= dam;
+ if (mon->mhp <= 0) {
monkilled(mon, "", AD_RBRE);
return 1;
- } else
- mon->mhp -= dam;
+ }
m.has_defense = m.has_offense = m.has_misc = 0;
/* Only one needed to be set to 0 but the others are harmless */
}
else
losehp(num, "scroll of fire", KILLED_BY_AN);
for (mtmp2 = fmon; mtmp2; mtmp2 = mtmp2->nmon) {
- if (DEADMONSTER(mtmp2)) continue;
- if (mtmp == mtmp2) continue;
+ if (DEADMONSTER(mtmp2))
+ continue;
+ if (mtmp == mtmp2)
+ continue;
if (dist2(mtmp2->mx, mtmp2->my, mtmp->mx, mtmp->my) < 3) {
- if (resists_fire(mtmp2)) continue;
+ if (resists_fire(mtmp2))
+ continue;
mtmp2->mhp -= num;
if (resists_cold(mtmp2))
mtmp2->mhp -= 3 * num;
/* Falling is okay for falling down
within a pit from jostling too */
mselftouch(mtmp, "Falling, ", TRUE);
- if (mtmp->mhp > 0)
- if ((mtmp->mhp -=
- rnd(m_already_trapped ? 4 : 6)) <= 0) {
- if (!cansee(x, y))
+ if (mtmp->mhp > 0) {
+ mtmp->mhp -= rnd(m_already_trapped ? 4 : 6);
+ if (mtmp->mhp <= 0) {
+ if (!cansee(x, y)) {
pline("It is destroyed!");
- else {
+ } else {
You("destroy %s!",
mtmp->mtame
? x_monnam(mtmp, ARTICLE_THE,
}
xkilled(mtmp, XKILL_NOMSG);
}
+ }
}
} else if (x == u.ux && y == u.uy) {
if (Levitation || Flying
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"
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)) {
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) {
pline("%s suddenly seems weaker!", Monnam(mdef));
mdef->mhpmax -= xtmp;
- if ((mdef->mhp -= xtmp) <= 0 || !mdef->m_lev) {
+ mdef->mhp -= xtmp;
+ /* !m_lev: level 0 monster is killed rather than drop to -1 */
+ if (mdef->mhp <= 0 && !mdef->m_lev) {
pline("%s dies!", Monnam(mdef));
xkilled(mdef, XKILL_NOMSG);
} else
}
mdef->mstrategy &= ~STRAT_WAITFORU; /* in case player is very fast */
- if ((mdef->mhp -= tmp) < 1) {
+ mdef->mhp -= tmp;
+ if (mdef->mhp < 1) {
if (mdef->mtame && !cansee(mdef->mx, mdef->my)) {
You_feel("embarrassed for a moment.");
if (tmp)
break;
}
end_engulf();
- if ((mdef->mhp -= dam) <= 0) {
+ mdef->mhp -= dam;
+ if (mdef->mhp <= 0) {
killed(mdef);
if (mdef->mhp <= 0) /* not lifesaved */
return 2;
{
pline("%s %s!", Monnam(mon),
(dmg > mon->mhp / 2) ? "wails in agony" : "cries out in pain");
- if ((mon->mhp -= dmg) <= 0) {
+ mon->mhp -= dmg;
+ if (mon->mhp <= 0) {
if (context.mon_moving)
monkilled(mon, (char *) 0, AD_BLND);
else
return (struct monst *) 0;
}
-/* used by buzz(); also used by munslime(muse.c); returns damage to mon */
+/* used by buzz(); also used by munslime(muse.c); returns damage applied
+ to mon; note: caller is responsible for killing mon if damage is fatal */
int
zhitm(mon, type, nd, ootmp)
register struct monst *mon;