Use DEADMONSTER instead of checking mhp

This commit is contained in:
Pasi Kallinen
2018-08-30 20:05:18 +03:00
parent f1d0636ba0
commit d2eba695c8
24 changed files with 125 additions and 125 deletions

View File

@@ -767,7 +767,7 @@ register xchar x, y;
corpse less likely to remain tame after revival */
xkilled(mtmp, XKILL_NOMSG);
/* life-saving doesn't ordinarily reset this */
if (mtmp->mhp > 0)
if (!DEADMONSTER(mtmp))
u.uconduct.killer = save_pacifism;
} else {
pline("%s is choked by the leash!", Monnam(mtmp));

View File

@@ -326,7 +326,7 @@ boolean devour;
/* turning into slime might be cureable */
if (slimer && munslime(mtmp, FALSE)) {
/* but the cure (fire directed at self) might be fatal */
if (mtmp->mhp < 1)
if (DEADMONSTER(mtmp))
return 2;
slimer = FALSE; /* sliming is avoided, skip polymorph */
}
@@ -370,7 +370,7 @@ struct edog *edog;
mtmp->mhpmax = newmhpmax;
if (mtmp->mhp > mtmp->mhpmax)
mtmp->mhp = mtmp->mhpmax;
if (mtmp->mhp < 1)
if (DEADMONSTER(mtmp))
goto dog_died;
if (cansee(mtmp->mx, mtmp->my))
pline("%s is confused from hunger.", Monnam(mtmp));
@@ -379,7 +379,7 @@ struct edog *edog;
else
You_feel("worried about %s.", y_monnam(mtmp));
stop_occupation();
} else if (monstermoves > edog->hungrytime + 750 || mtmp->mhp < 1) {
} else if (monstermoves > edog->hungrytime + 750 || DEADMONSTER(mtmp)) {
dog_died:
if (mtmp->mleashed && mtmp != u.usteed)
Your("leash goes slack.");

View File

@@ -97,7 +97,7 @@ register boolean clumsy;
dmg += u.udaminc; /* add ring(s) of increase damage */
if (dmg > 0)
mon->mhp -= dmg;
if (mon->mhp > 0 && martial() && !bigmonst(mon->data) && !rn2(3)
if (!DEADMONSTER(mon) && martial() && !bigmonst(mon->data) && !rn2(3)
&& mon->mcanmove && mon != u.ustuck && !mon->mtrapped) {
/* see if the monster has a place to move into */
mdx = mon->mx + u.dx;
@@ -116,8 +116,8 @@ register boolean clumsy;
}
}
(void) passive(mon, uarmf, TRUE, mon->mhp > 0, AT_KICK, FALSE);
if (mon->mhp <= 0 && !trapkilled)
(void) passive(mon, uarmf, TRUE, !DEADMONSTER(mon), AT_KICK, FALSE);
if (DEADMONSTER(mon) && !trapkilled)
killed(mon);
/* may bring up a dialog, so put this after all messages */
@@ -914,7 +914,7 @@ dokick()
kick_monster(mtmp, x, y);
glyph = glyph_at(x, y);
/* see comment in attack_checks() */
if (mtmp->mhp <= 0) { /* DEADMONSTER() */
if (DEADMONSTER(mtmp)) { /* DEADMONSTER() */
/* if we mapped an invisible monster and immediately
killed it, we don't want to forget what we thought
was there before the kick */

View File

@@ -525,7 +525,7 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */
if (visflag && canseemon(magr))
pline("%s turns to stone!", Monnam(magr));
monstone(magr);
if (magr->mhp > 0) {
if (!DEADMONSTER(magr)) {
/* life-saved; don't continue eating the brains */
return MM_MISS;
} else {
@@ -612,7 +612,7 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */
return MM_MISS;
} else if (is_rider(pd)) {
mondied(magr);
if (magr->mhp <= 0)
if (DEADMONSTER(magr))
result = MM_AGR_DIED;
/* Rider takes extra damage regardless of whether attacker dies */
*dmg_p += xtra_dmg;

View File

@@ -208,7 +208,7 @@ int expltype;
if (!mtmp && i + x - 1 == u.ux && j + y - 1 == u.uy)
mtmp = u.usteed;
if (mtmp) {
if (mtmp->mhp < 1)
if (DEADMONSTER(mtmp))
explmask[i][j] = 2;
else
switch (adtyp) {
@@ -444,7 +444,7 @@ int expltype;
mtmp->mhp -= mdam;
mtmp->mhp -= (idamres + idamnonres);
}
if (mtmp->mhp <= 0) {
if (DEADMONSTER(mtmp)) {
int xkflg = ((adtyp == AD_FIRE
&& completelyburns(mtmp->data))
? XKILL_NOCORPSE : 0);

View File

@@ -1751,7 +1751,7 @@ struct monst *mtmp, *victim;
/* monster died after killing enemy but before calling this function */
/* currently possible if killing a gas spore */
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
return (struct permonst *) 0;
/* note: none of the monsters with special hit point calculations

View File

@@ -247,7 +247,7 @@ boolean quietly;
if (!quietly && canspotmon(magr))
pline("%s turns to stone!", Monnam(magr));
monstone(magr);
if (magr->mhp > 0)
if (!DEADMONSTER(magr))
return MM_HIT; /* lifesaved */
else if (magr->mtame && !vis)
You(brief_feeling, "peculiarly sad");
@@ -633,7 +633,7 @@ struct attack *mattk;
if (canseemon(magr))
pline("%s is turned to stone!", Monnam(magr));
monstone(magr);
if (magr->mhp > 0)
if (!DEADMONSTER(magr))
return MM_MISS;
return MM_AGR_DIED;
}
@@ -782,7 +782,7 @@ struct attack *mattk;
/* Kill off aggressor if it didn't die. */
if (!(result & MM_AGR_DIED)) {
mondead(magr);
if (magr->mhp > 0)
if (!DEADMONSTER(magr))
return result; /* life saved */
result |= MM_AGR_DIED;
}
@@ -826,7 +826,7 @@ register struct attack *mattk;
if (vis && canspotmon(magr))
pline("%s turns to stone!", Monnam(magr));
monstone(magr);
if (magr->mhp > 0)
if (!DEADMONSTER(magr))
return MM_HIT; /* lifesaved */
else if (magr->mtame && !vis)
You(brief_feeling, "peculiarly sad");
@@ -850,7 +850,7 @@ register struct attack *mattk;
? "coughs spasmodically and collapses"
: "vomits violently and drops dead");
mondied(magr);
if (magr->mhp > 0)
if (!DEADMONSTER(magr))
return 0; /* lifesaved */
else if (magr->mtame && !vis)
You(brief_feeling, "queasy");
@@ -864,7 +864,7 @@ register struct attack *mattk;
m_useup(mdef, obj);
/* Is a corpse for nutrition possible? It may kill magr */
if (!corpse_chance(mdef, magr, TRUE) || magr->mhp < 1)
if (!corpse_chance(mdef, magr, TRUE) || DEADMONSTER(magr))
break;
/* Pets get nutrition from swallowing monster whole.
@@ -924,7 +924,7 @@ register struct attack *mattk;
tmp = 1;
if (otmp->oartifact) {
(void) artifact_hit(magr, mdef, otmp, &tmp, dieroll);
if (mdef->mhp <= 0)
if (DEADMONSTER(mdef))
return (MM_DEF_DIED
| (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
}
@@ -951,7 +951,7 @@ register struct attack *mattk;
if (vis && canseemon(mdef))
pline("%s burns completely!", Monnam(mdef));
mondead(mdef); /* was mondied() but that dropped paper scrolls */
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
pline("May %s roast in peace.", mon_nam(mdef));
@@ -1029,7 +1029,7 @@ register struct attack *mattk;
if (vis && canseemon(mdef))
pline("%s falls to pieces!", Monnam(mdef));
mondied(mdef);
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
pline("May %s rust in peace.", mon_nam(mdef));
@@ -1053,7 +1053,7 @@ register struct attack *mattk;
if (vis && canseemon(mdef))
pline("%s falls to pieces!", Monnam(mdef));
mondied(mdef);
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
pline("May %s rot in peace.", mon_nam(mdef));
@@ -1080,7 +1080,7 @@ register struct attack *mattk;
pline("%s turns to stone!", Monnam(mdef));
monstone(mdef);
post_stone:
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
You(brief_feeling, "peculiarly sad");
@@ -1184,7 +1184,7 @@ register struct attack *mattk;
pline("%s is destroyed!", Monnam(mdef));
}
mondied(mdef);
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
You(brief_feeling, "strangely sad");
@@ -1280,7 +1280,7 @@ register struct attack *mattk;
possibly_unwield(mdef, FALSE);
mdef->mstrategy &= ~STRAT_WAITFORU;
mselftouch(mdef, (const char *) 0, FALSE);
if (mdef->mhp <= 0)
if (DEADMONSTER(mdef))
return (MM_DEF_DIED
| (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
if (pa->mlet == S_NYMPH && !tele_restrict(magr)) {
@@ -1343,7 +1343,7 @@ register struct attack *mattk;
if (cancelled)
break; /* physical damage only */
if (!rn2(4) && !slimeproof(pd)) {
if (!munslime(mdef, FALSE) && mdef->mhp > 0) {
if (!munslime(mdef, FALSE) && !DEADMONSTER(mdef)) {
if (newcham(mdef, &mons[PM_GREEN_SLIME], FALSE, vis && canseemon(mdef)))
pd = mdef->data;
mdef->mstrategy &= ~STRAT_WAITFORU;
@@ -1351,9 +1351,9 @@ register struct attack *mattk;
}
/* munslime attempt could have been fatal,
potentially to multiple monsters (SCR_FIRE) */
if (magr->mhp < 1)
if (DEADMONSTER(magr))
res |= MM_AGR_DIED;
if (mdef->mhp < 1)
if (DEADMONSTER(mdef))
res |= MM_DEF_DIED;
tmp = 0;
}
@@ -1385,7 +1385,7 @@ register struct attack *mattk;
mdef->mhp = 0;
}
monkilled(mdef, "", (int) mattk->adtyp);
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return res; /* mdef lifesaved */
else if (res == MM_AGR_DIED)
return (MM_DEF_DIED | MM_AGR_DIED);
@@ -1400,7 +1400,7 @@ register struct attack *mattk;
} else if (pd == &mons[PM_WRAITH]) {
(void) grow_up(magr, (struct monst *) 0);
/* don't grow up twice */
return (MM_DEF_DIED | (magr->mhp > 0 ? 0 : MM_AGR_DIED));
return (MM_DEF_DIED | (!DEADMONSTER(magr) ? 0 : MM_AGR_DIED));
} else if (pd == &mons[PM_NURSE]) {
magr->mhp = magr->mhpmax;
}

View File

@@ -365,7 +365,7 @@ register struct monst *mtmp;
if (!ranged)
nomul(0);
if (mtmp->mhp <= 0 || (Underwater && !is_swimmer(mtmp->data)))
if (DEADMONSTER(mtmp) || (Underwater && !is_swimmer(mtmp->data)))
return 0;
/* If swallowed, can only be affected by u.ustuck */
@@ -1796,7 +1796,7 @@ struct attack *mattk;
if (Punished)
placebc();
u.ustuck = 0;
return (mtmp->mhp > 0) ? 0 : 2;
return (!DEADMONSTER(mtmp)) ? 0 : 2;
}
display_nhwindow(WIN_MESSAGE, FALSE);
@@ -2066,7 +2066,7 @@ boolean ufound;
if (kill_agr)
mondead(mtmp);
wake_nearto(mtmp->mx, mtmp->my, 7 * 7);
return (mtmp->mhp > 0) ? 0 : 2;
return (!DEADMONSTER(mtmp)) ? 0 : 2;
}
/* monster gazes at you */
@@ -2132,7 +2132,7 @@ struct attack *mattk;
stoned = TRUE;
killed(mtmp);
if (mtmp->mhp > 0)
if (!DEADMONSTER(mtmp))
break;
return 2;
}
@@ -2768,7 +2768,7 @@ struct attack *mattk;
pline("%s turns to stone!", Monnam(mtmp));
stoned = 1;
xkilled(mtmp, XKILL_NOMSG);
if (mtmp->mhp > 0)
if (!DEADMONSTER(mtmp))
return 1;
return 2;
}
@@ -2879,7 +2879,7 @@ assess_dmg:
if ((mtmp->mhp -= tmp) <= 0) {
pline("%s dies!", Monnam(mtmp));
xkilled(mtmp, XKILL_NOMSG);
if (mtmp->mhp > 0)
if (!DEADMONSTER(mtmp))
return 1;
return 2;
}

View File

@@ -1861,7 +1861,7 @@ discard_minvent(mtmp)
struct monst *mtmp;
{
struct obj *otmp, *mwep = MON_WEP(mtmp);
boolean keeping_mon = (mtmp->mhp > 0);
boolean keeping_mon = (!DEADMONSTER(mtmp));
while ((otmp = mtmp->minvent) != 0) {
/* this has now become very similar to m_useupall()... */

View File

@@ -509,9 +509,9 @@ register struct monst *mtmp;
mtmp->mhp -= dam;
if (mtmp->mhpmax > dam)
mtmp->mhpmax -= dam;
if (mtmp->mhp < 1) {
if (DEADMONSTER(mtmp)) {
mondead(mtmp);
if (mtmp->mhp < 1)
if (DEADMONSTER(mtmp))
return 1;
}
water_damage_chain(mtmp->minvent, FALSE);
@@ -538,14 +538,14 @@ register struct monst *mtmp;
mondead(mtmp);
} else {
mtmp->mhp -= 1;
if (mtmp->mhp < 1) {
if (DEADMONSTER(mtmp)) {
if (cansee(mtmp->mx, mtmp->my))
pline("%s surrenders to the fire.", Monnam(mtmp));
mondead(mtmp);
} else if (cansee(mtmp->mx, mtmp->my))
pline("%s burns slightly.", Monnam(mtmp));
}
if (mtmp->mhp > 0) {
if (!DEADMONSTER(mtmp)) {
(void) fire_damage_chain(mtmp->minvent, FALSE, FALSE,
mtmp->mx, mtmp->my);
(void) rloc(mtmp, FALSE);
@@ -570,7 +570,7 @@ register struct monst *mtmp;
Monnam(mtmp), hliquid("water"));
}
mondead(mtmp);
if (mtmp->mhp > 0) {
if (!DEADMONSTER(mtmp)) {
water_damage_chain(mtmp->minvent, FALSE);
(void) rloc(mtmp, FALSE);
return 0;
@@ -708,7 +708,7 @@ movemon()
nmtmp = mtmp->nmon;
/* one dead monster needs to perform a move after death:
vault guard whose temporary corridor is still on the map */
if (mtmp->isgd && !mtmp->mx && mtmp->mhp <= 0)
if (mtmp->isgd && !mtmp->mx && DEADMONSTER(mtmp))
(void) gd_move(mtmp);
if (DEADMONSTER(mtmp))
continue;
@@ -1536,7 +1536,7 @@ dmonsfree()
for (mtmp = &fmon; *mtmp;) {
freetmp = *mtmp;
if (freetmp->mhp <= 0 && !freetmp->isgd) {
if (DEADMONSTER(freetmp) && !freetmp->isgd) {
*mtmp = freetmp->nmon;
freetmp->nmon = NULL;
dealloc_monst(freetmp);
@@ -1825,7 +1825,7 @@ register struct monst *mtmp;
mtmp->mhp = 0; /* in case caller hasn't done this */
lifesaved_monster(mtmp);
if (mtmp->mhp > 0)
if (!DEADMONSTER(mtmp))
return;
if (is_vampshifter(mtmp)) {
@@ -1993,9 +1993,9 @@ boolean was_swallowed; /* digestion */
} else {
You_hear("an explosion.");
magr->mhp -= tmp;
if (magr->mhp < 1)
if (DEADMONSTER(magr))
mondied(magr);
if (magr->mhp < 1) { /* maybe lifesaved */
if (DEADMONSTER(magr)) { /* maybe lifesaved */
if (canspotmon(magr))
pline("%s rips open!", Monnam(magr));
} else if (canseemon(magr))
@@ -2033,7 +2033,7 @@ mondied(mdef)
register struct monst *mdef;
{
mondead(mdef);
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return; /* lifesaved */
if (corpse_chance(mdef, (struct monst *) 0, FALSE)
@@ -2083,7 +2083,7 @@ struct monst *mdef;
*/
mdef->mhp = 0; /* in case caller hasn't done this */
lifesaved_monster(mdef);
if (mdef->mhp > 0)
if (!DEADMONSTER(mdef))
return;
mdef->mtrapped = 0; /* (see m_detach) */
@@ -2176,7 +2176,7 @@ int how;
else
mondied(mdef);
if (be_sad && mdef->mhp <= 0)
if (be_sad && DEADMONSTER(mdef))
You("have a sad feeling for a moment, then it passes.");
}
@@ -2276,7 +2276,7 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */
mondead(mtmp);
disintegested = FALSE; /* reset */
if (mtmp->mhp > 0) { /* monster lifesaved */
if (!DEADMONSTER(mtmp)) { /* monster lifesaved */
/* Cannot put the non-visible lifesaving message in
* lifesaved_monster() since the message appears only when _you_
* kill it (as opposed to visible lifesaving which always appears).

View File

@@ -31,9 +31,9 @@ struct monst *mtmp;
wake_nearto(mtmp->mx, mtmp->my, 7 * 7);
mtmp->mstun = 1;
mtmp->mhp -= rnd(15);
if (mtmp->mhp <= 0) {
if (DEADMONSTER(mtmp)) {
mondied(mtmp);
if (mtmp->mhp > 0) /* lifesaved */
if (!DEADMONSTER(mtmp)) /* lifesaved */
return FALSE;
else
return TRUE;
@@ -413,7 +413,7 @@ register struct monst *mtmp;
m_respond(mtmp);
if (mdat == &mons[PM_MEDUSA] && couldsee(mtmp->mx, mtmp->my))
m_respond(mtmp);
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
return 1; /* m_respond gaze can kill medusa */
/* fleeing monsters might regain courage */
@@ -518,7 +518,7 @@ register struct monst *mtmp;
if (cansee(m2->mx, m2->my))
pline("It locks on to %s.", mon_nam(m2));
m2->mhp -= rnd(15);
if (m2->mhp <= 0)
if (DEADMONSTER(m2))
monkilled(m2, "", AD_DRIN);
else
m2->msleeping = 0;
@@ -590,7 +590,7 @@ toofar:
case 0: /* no movement, but it can still attack you */
case 3: /* absolutely no movement */
/* vault guard might have vanished */
if (mtmp->isgd && (mtmp->mhp < 1 || mtmp->mx == 0))
if (mtmp->isgd && (DEADMONSTER(mtmp) || mtmp->mx == 0))
return 1; /* behave as if it died */
/* During hallucination, monster appearance should
* still change - even if it doesn't move.

View File

@@ -285,7 +285,7 @@ struct obj *otmp, *mwep;
if mtmp gets killed (shot kills adjacent gas spore and
triggers explosion, perhaps), inventory will be dropped
and otmp might go away via merging into another stack */
if (mtmp->mhp <= 0 && m_shot.i < m_shot.n)
if (DEADMONSTER(mtmp) && m_shot.i < m_shot.n)
/* cancel pending shots (perhaps ought to give a message here
since we gave one above about throwing/shooting N missiles) */
break; /* endmultishot(FALSE); */
@@ -404,9 +404,9 @@ boolean verbose; /* give message(s) even when you can't see what happened */
damage = 0;
}
if (mtmp->mhp > 0) { /* might already be dead (if petrified) */
if (!DEADMONSTER(mtmp)) { /* might already be dead (if petrified) */
mtmp->mhp -= damage;
if (mtmp->mhp < 1) {
if (DEADMONSTER(mtmp)) {
if (vis || (verbose && !target))
pline("%s is %s!", Monnam(mtmp),
(nonliving(mtmp->data) || is_vampshifter(mtmp)
@@ -422,7 +422,7 @@ boolean verbose; /* give message(s) even when you can't see what happened */
/* blinding venom and cream pie do 0 damage, but verify
that the target is still alive anyway */
if (mtmp->mhp > 0
if (!DEADMONSTER(mtmp)
&& can_blnd((struct monst *) 0, mtmp,
(uchar) ((otmp->otyp == BLINDING_VENOM) ? AT_SPIT
: AT_WEAP),

View File

@@ -155,7 +155,7 @@ struct obj *obj;
}
m_useup(mon, obj);
mon->mhp -= dam;
if (mon->mhp <= 0) {
if (DEADMONSTER(mon)) {
monkilled(mon, "", AD_RBRE);
return 1;
}
@@ -1273,7 +1273,7 @@ register struct obj *otmp;
break;
}
if (reveal_invis) {
if (mtmp->mhp > 0 && cansee(bhitpos.x, bhitpos.y)
if (!DEADMONSTER(mtmp) && cansee(bhitpos.x, bhitpos.y)
&& !canspotmon(mtmp))
map_invisible(bhitpos.x, bhitpos.y);
}
@@ -1406,7 +1406,7 @@ struct monst *mtmp;
(otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my,
sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my));
m_using = FALSE;
return (mtmp->mhp <= 0) ? 1 : 2;
return (DEADMONSTER(mtmp)) ? 1 : 2;
case MUSE_FIRE_HORN:
case MUSE_FROST_HORN:
if (oseen) {
@@ -1420,7 +1420,7 @@ struct monst *mtmp;
rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
sgn(mtmp->muy - mtmp->my));
m_using = FALSE;
return (mtmp->mhp <= 0) ? 1 : 2;
return (DEADMONSTER(mtmp)) ? 1 : 2;
case MUSE_WAN_TELEPORTATION:
case MUSE_WAN_STRIKING:
zap_oseen = oseen;
@@ -1473,7 +1473,7 @@ struct monst *mtmp;
drop_boulder_on_player(confused, !is_cursed, FALSE, TRUE);
}
return (mtmp->mhp <= 0) ? 1 : 2;
return (DEADMONSTER(mtmp)) ? 1 : 2;
}
#if 0
case MUSE_SCR_FIRE: {
@@ -1513,7 +1513,7 @@ struct monst *mtmp;
mtmp2->mhp -= num;
if (resists_cold(mtmp2))
mtmp2->mhp -= 3 * num;
if (mtmp2->mhp < 1) {
if (DEADMONSTER(mtmp2)) {
mondied(mtmp2);
break;
}
@@ -2260,7 +2260,7 @@ boolean stoning; /* True: stop petrification, False: cure stun && confusion */
mon->mhp -= rnd(15);
if (vis)
pline("%s has a very bad case of stomach acid.", Monnam(mon));
if (mon->mhp <= 0) {
if (DEADMONSTER(mon)) {
pline("%s dies!", Monnam(mon));
if (by_you)
/* hero gets credit (experience) and blame (possible loss
@@ -2502,7 +2502,7 @@ boolean by_you; /* true: if mon kills itself, hero gets credit/blame */
for fire breath, dmg is going to be 0 (fire breathers are
immune to fire damage) but for wand of fire or fire horn,
'mon' could have taken damage so might die */
if (mon->mhp <= 0) {
if (DEADMONSTER(mon)) {
if (by_you) {
/* mon killed self but hero gets credit and blame (except
for pacifist conduct); xkilled()'s message would say
@@ -2520,7 +2520,7 @@ boolean by_you; /* true: if mon kills itself, hero gets credit/blame */
}
}
if (vis) {
if (res && mon->mhp > 0)
if (res && !DEADMONSTER(mon))
pline("%s slime is burned away!", s_suffix(Monnam(mon)));
if (otyp != STRANGE_OBJECT)
makeknown(otyp);

View File

@@ -354,9 +354,9 @@ int force;
/* Falling is okay for falling down
within a pit from jostling too */
mselftouch(mtmp, "Falling, ", TRUE);
if (mtmp->mhp > 0) {
if (!DEADMONSTER(mtmp)) {
mtmp->mhp -= rnd(m_already_trapped ? 4 : 6);
if (mtmp->mhp <= 0) {
if (DEADMONSTER(mtmp)) {
if (!cansee(x, y)) {
pline("It is destroyed!");
} else {

View File

@@ -1355,7 +1355,7 @@ dogaze()
(void) destroy_mitem(mtmp, SPBOOK_CLASS, AD_FIRE);
if (dmg)
mtmp->mhp -= dmg;
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
killed(mtmp);
}
/* For consistency with passive() in uhitm.c, this only
@@ -1517,7 +1517,7 @@ domindblast()
u_sen ? "telepathy"
: telepathic(mtmp->data) ? "latent telepathy" : "mind");
mtmp->mhp -= rnd(15);
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
killed(mtmp);
}
}

View File

@@ -1464,7 +1464,7 @@ int how;
wake_nearto(tx, ty, mon->data->mlevel * 10);
mon->mhp -= d(2, 6);
/* should only be by you */
if (mon->mhp < 1)
if (DEADMONSTER(mon))
killed(mon);
else if (is_were(mon->data) && !is_human(mon->data))
new_were(mon); /* revert to human */
@@ -1487,7 +1487,7 @@ int how;
pline("%s rusts.", Monnam(mon));
mon->mhp -= d(1, 6);
/* should only be by you */
if (mon->mhp < 1)
if (DEADMONSTER(mon))
killed(mon);
}
break;
@@ -1502,7 +1502,7 @@ int how;
if (!is_silent(mon->data))
wake_nearto(tx, ty, mon->data->mlevel * 10);
mon->mhp -= d(obj->cursed ? 2 : 1, obj->blessed ? 4 : 8);
if (mon->mhp < 1) {
if (DEADMONSTER(mon)) {
if (your_fault)
killed(mon);
else
@@ -1523,7 +1523,7 @@ int how;
*/
}
/* target might have been killed */
if (mon->mhp > 0) {
if (!DEADMONSTER(mon)) {
if (angermon)
wakeup(mon, TRUE);
else

View File

@@ -1814,7 +1814,7 @@ boolean confused, byu;
}
}
mtmp->mhp -= mdmg;
if (mtmp->mhp <= 0) {
if (DEADMONSTER(mtmp)) {
if (byu) {
killed(mtmp);
} else {

View File

@@ -408,7 +408,7 @@ run_regions()
struct monst *mtmp =
find_mid(regions[i]->monsters[j], FM_FMON);
if (!mtmp || mtmp->mhp <= 0
if (!mtmp || DEADMONSTER(mtmp)
|| (*callbacks[f_indx])(regions[i], mtmp)) {
/* The monster died, remove it from list */
k = (regions[i]->n_monst -= 1);
@@ -989,12 +989,12 @@ genericptr_t p2;
if (resists_poison(mtmp))
return FALSE;
mtmp->mhp -= rnd(dam) + 5;
if (mtmp->mhp <= 0) {
if (DEADMONSTER(mtmp)) {
if (heros_fault(reg))
killed(mtmp);
else
monkilled(mtmp, "gas cloud", AD_DRST);
if (mtmp->mhp <= 0) { /* not lifesaved */
if (DEADMONSTER(mtmp)) { /* not lifesaved */
return TRUE;
}
}

View File

@@ -645,7 +645,7 @@ boolean verbosely;
if (obj->owornmask) {
/* perform worn item handling if the monster is still alive */
if (mon->mhp > 0) {
if (!DEADMONSTER(mon)) {
mon->misc_worn_check &= ~obj->owornmask;
update_mon = TRUE;

View File

@@ -551,7 +551,7 @@ int reason; /* Player was thrown off etc. */
(void) rloc(mtmp, FALSE);
return;
}
if (mtmp->mhp > 0) {
if (!DEADMONSTER(mtmp)) {
place_monster(mtmp, u.ux, u.uy);
if (!u.uswallow && !u.ustuck && have_spot) {
struct permonst *mdat = mtmp->data;
@@ -594,7 +594,7 @@ int reason; /* Player was thrown off etc. */
* falling into the hole).
*/
/* [ALI] No need to move the player if the steed died. */
if (mtmp->mhp > 0) {
if (!DEADMONSTER(mtmp)) {
/* Keep steed here, move the player to cc;
* teleds() clears u.utrap
*/

View File

@@ -1568,7 +1568,7 @@ struct obj *otmp;
break;
case PIT:
case SPIKED_PIT:
trapkilled = (steed->mhp <= 0
trapkilled = (DEADMONSTER(steed)
|| thitm(0, steed, (struct obj *) 0,
rnd((tt == PIT) ? 6 : 10), FALSE));
steedhit = TRUE;
@@ -2311,7 +2311,7 @@ register struct monst *mtmp;
else if (mtmp->mtame)
pline("May %s rust in peace.", mon_nam(mtmp));
mondied(mtmp);
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
trapkilled = TRUE;
} else if (mptr == &mons[PM_GREMLIN] && rn2(3)) {
(void) split_mon(mtmp, (struct monst *) 0);
@@ -2408,7 +2408,7 @@ register struct monst *mtmp;
seetrap(trap);
}
mselftouch(mtmp, "Falling, ", FALSE);
if (mtmp->mhp <= 0 || thitm(0, mtmp, (struct obj *) 0,
if (DEADMONSTER(mtmp) || thitm(0, mtmp, (struct obj *) 0,
rnd((tt == PIT) ? 6 : 10), FALSE))
trapkilled = TRUE;
break;
@@ -2555,13 +2555,13 @@ register struct monst *mtmp;
if (in_sight)
seetrap(trap);
mtmp->mhp -= dmgval2;
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
monkilled(mtmp,
in_sight
? "compression from an anti-magic field"
: (const char *) 0,
-AD_MAGM);
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
trapkilled = TRUE;
if (see_it)
newsym(trap->tx, trap->ty);
@@ -2596,7 +2596,7 @@ register struct monst *mtmp;
blow_up_landmine(trap);
/* explosion might have destroyed a drawbridge; don't
dish out more damage if monster is already dead */
if (mtmp->mhp <= 0
if (DEADMONSTER(mtmp)
|| thitm(0, mtmp, (struct obj *) 0, rnd(16), FALSE)) {
trapkilled = TRUE;
} else {
@@ -2606,7 +2606,7 @@ register struct monst *mtmp;
}
/* a boulder may fill the new pit, crushing monster */
fill_pit(trap->tx, trap->ty);
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
trapkilled = TRUE;
if (unconscious()) {
multi = -1;
@@ -2636,7 +2636,7 @@ register struct monst *mtmp;
trap->launch2.x, trap->launch2.y, style)) {
if (in_sight)
trap->tseen = TRUE;
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
trapkilled = TRUE;
} else {
deltrap(trap);
@@ -2753,7 +2753,7 @@ boolean byplayer;
}
minstapetrify(mon, byplayer);
/* if life-saved, might not be able to continue wielding */
if (mon->mhp > 0 && !which_armor(mon, W_ARMG) && !resists_ston(mon))
if (!DEADMONSTER(mon) && !which_armor(mon, W_ARMG) && !resists_ston(mon))
mwepgone(mon);
}
}
@@ -3976,7 +3976,7 @@ boolean force_failure;
if (mtmp->mtame)
abuse_dog(mtmp);
mtmp->mhp -= rnd(4);
if (mtmp->mhp <= 0)
if (DEADMONSTER(mtmp))
killed(mtmp);
} else if (ttype == WEB) {
if (!webmaker(youmonst.data)) {
@@ -5063,11 +5063,11 @@ boolean nocorpse;
dam = 1;
}
mon->mhp -= dam;
if (mon->mhp <= 0) {
if (DEADMONSTER(mon)) {
int xx = mon->mx, yy = mon->my;
monkilled(mon, "", nocorpse ? -AD_RBRE : AD_PHYS);
if (mon->mhp <= 0) {
if (DEADMONSTER(mon)) {
newsym(xx, yy);
trapkilled = TRUE;
}

View File

@@ -429,7 +429,7 @@ atk_done:
* and it returned 0 (it's okay to attack), and the monster didn't
* evade.
*/
if (context.forcefight && mtmp->mhp > 0 && !canspotmon(mtmp)
if (context.forcefight && !DEADMONSTER(mtmp) && !canspotmon(mtmp)
&& !glyph_is_invisible(levl[u.ux + u.dx][u.uy + u.dy].glyph)
&& !(u.uswallow && mtmp == u.ustuck))
map_invisible(u.ux + u.dx, u.uy + u.dy);
@@ -792,7 +792,7 @@ int dieroll;
if (obj->oartifact
&& artifact_hit(&youmonst, mon, obj, &tmp, dieroll)) {
if (mon->mhp <= 0) /* artifact killed monster */
if (DEADMONSTER(mon)) /* artifact killed monster */
return FALSE;
if (tmp == 0)
return TRUE;
@@ -835,7 +835,7 @@ int dieroll;
freeinv(obj);
potionhit(mon, obj,
hand_to_hand ? POTHIT_HERO_BASH : POTHIT_HERO_THROW);
if (mon->mhp <= 0)
if (DEADMONSTER(mon))
return FALSE; /* killed */
hittxt = TRUE;
/* in case potion effect causes transformation */
@@ -884,7 +884,7 @@ int dieroll;
if (resists_ston(mon))
break;
/* note: hp may be <= 0 even if munstoned==TRUE */
return (boolean) (mon->mhp > 0);
return (boolean) (!DEADMONSTER(mon));
#if 0
} else if (touch_petrifies(mdat)) {
; /* maybe turn the corpse into a statue? */
@@ -933,7 +933,7 @@ int dieroll;
minstapetrify(mon, TRUE);
if (resists_ston(mon))
break;
return (boolean) (mon->mhp > 0);
return (boolean) (!DEADMONSTER(mon));
} else { /* ordinary egg(s) */
const char *eggp =
(obj->corpsenm != NON_PM && obj->known)
@@ -1176,7 +1176,7 @@ int dieroll;
a level draining artifact has already done to max HP */
if (mon->mhp > mon->mhpmax)
mon->mhp = mon->mhpmax;
if (mon->mhp < 1)
if (DEADMONSTER(mon))
destroyed = TRUE;
if (mon->mtame && tmp > 0) {
/* do this even if the pet is being killed (affects revival) */
@@ -1501,7 +1501,7 @@ struct attack *mattk;
possibly_unwield(mdef, FALSE);
} else if (unwornmask & W_ARMG) { /* stole worn gloves */
mselftouch(mdef, (const char *) 0, TRUE);
if (mdef->mhp <= 0) /* it's now a statue */
if (DEADMONSTER(mdef)) /* it's now a statue */
return; /* can't continue stealing */
}
@@ -1724,7 +1724,7 @@ register struct attack *mattk;
mdef->mhp -= xtmp;
/* !m_lev: level 0 monster is killed regardless of hit points
rather than drop to level -1 */
if (mdef->mhp <= 0 || !mdef->m_lev) {
if (DEADMONSTER(mdef) || !mdef->m_lev) {
pline("%s dies!", Monnam(mdef));
xkilled(mdef, XKILL_NOMSG);
} else
@@ -1848,7 +1848,7 @@ register struct attack *mattk;
if (negated)
break; /* physical damage only */
if (!rn2(4) && !slimeproof(pd)) {
if (!munslime(mdef, TRUE) && mdef->mhp > 0) {
if (!munslime(mdef, TRUE) && !DEADMONSTER(mdef)) {
/* this assumes newcham() won't fail; since hero has
a slime attack, green slimes haven't been geno'd */
You("turn %s into slime.", mon_nam(mdef));
@@ -1856,7 +1856,7 @@ register struct attack *mattk;
pd = mdef->data;
}
/* munslime attempt could have been fatal */
if (mdef->mhp < 1)
if (DEADMONSTER(mdef))
return 2; /* skip death message */
tmp = 0;
}
@@ -1888,7 +1888,7 @@ register struct attack *mattk;
mdef->mstrategy &= ~STRAT_WAITFORU; /* in case player is very fast */
mdef->mhp -= tmp;
if (mdef->mhp < 1) {
if (DEADMONSTER(mdef)) {
if (mdef->mtame && !cansee(mdef->mx, mdef->my)) {
You_feel("embarrassed for a moment.");
if (tmp)
@@ -1940,7 +1940,7 @@ register struct attack *mattk;
if (!resistance) {
pline("%s gets blasted!", Monnam(mdef));
mdef->mhp -= tmp;
if (mdef->mhp <= 0) {
if (DEADMONSTER(mdef)) {
killed(mdef);
return 2;
}
@@ -2074,7 +2074,7 @@ register struct attack *mattk;
several turns) but the level-gain message seems out of
order if the kill message is left implicit */
xkilled(mdef, XKILL_GIVEMSG | XKILL_NOCORPSE);
if (mdef->mhp > 0) { /* monster lifesaved */
if (!DEADMONSTER(mdef)) { /* monster lifesaved */
You("hurriedly regurgitate the sizzling in your %s.",
body_part(STOMACH));
} else {
@@ -2183,9 +2183,9 @@ register struct attack *mattk;
}
end_engulf();
mdef->mhp -= dam;
if (mdef->mhp <= 0) {
if (DEADMONSTER(mdef)) {
killed(mdef);
if (mdef->mhp <= 0) /* not lifesaved */
if (DEADMONSTER(mdef)) /* not lifesaved */
return 2;
}
You("%s %s!", is_animal(youmonst.data) ? "regurgitate" : "expel",
@@ -2832,7 +2832,7 @@ struct obj *otmp; /* source of flash */
: rn2(min(mtmp->mhp, 4));
light_hits_gremlin(mtmp, amt);
}
if (mtmp->mhp > 0) {
if (!DEADMONSTER(mtmp)) {
if (!context.mon_moving)
setmangry(mtmp, TRUE);
if (tmp < 9 && !mtmp->isshk && rn2(4))
@@ -2854,7 +2854,7 @@ int dmg;
(dmg > mon->mhp / 2) ? "wails in agony" : "cries out in pain");
mon->mhp -= dmg;
wake_nearto(mon->mx, mon->my, 30);
if (mon->mhp <= 0) {
if (DEADMONSTER(mon)) {
if (context.mon_moving)
monkilled(mon, (char *) 0, AD_BLND);
else

View File

@@ -55,9 +55,9 @@ boolean forceshow;
while ((fcbeg = egrd->fcbeg) < egrd->fcend) {
fcx = egrd->fakecorr[fcbeg].fx;
fcy = egrd->fakecorr[fcbeg].fy;
if ((grd->mhp <= 0 || !in_fcorridor(grd, u.ux, u.uy)) && egrd->gddone)
if ((DEADMONSTER(grd) || !in_fcorridor(grd, u.ux, u.uy)) && egrd->gddone)
forceshow = TRUE;
if ((u.ux == fcx && u.uy == fcy && grd->mhp > 0)
if ((u.ux == fcx && u.uy == fcy && !DEADMONSTER(grd))
|| (!forceshow && couldsee(fcx, fcy))
|| (Punished && !carried(uball) && uball->ox == fcx
&& uball->oy == fcy))
@@ -592,7 +592,7 @@ register struct monst *grd;
boolean goldincorridor = FALSE,
u_in_vault = vault_occupied(u.urooms) ? TRUE : FALSE,
grd_in_vault = *in_rooms(grd->mx, grd->my, VAULT) ? TRUE : FALSE;
boolean disappear_msg_seen = FALSE, semi_dead = (grd->mhp <= 0);
boolean disappear_msg_seen = FALSE, semi_dead = (DEADMONSTER(grd));
long umoney = money_cnt(invent);
register boolean u_carry_gold = ((umoney + hidden_gold()) > 0L);
boolean see_guard, newspot = FALSE;

View File

@@ -214,7 +214,7 @@ struct obj *otmp;
dmg = spell_damage_bonus(dmg);
context.bypasses = TRUE; /* for make_corpse() */
if (!resist(mtmp, otmp->oclass, dmg, NOTELL)) {
if (mtmp->mhp > 0)
if (!DEADMONSTER(mtmp))
monflee(mtmp, 0, FALSE, TRUE);
}
}
@@ -412,11 +412,11 @@ struct obj *otmp;
dmg = spell_damage_bonus(dmg);
if (resists_drli(mtmp)) {
shieldeff(mtmp->mx, mtmp->my);
} else if (!resist(mtmp, otmp->oclass, dmg, NOTELL) && mtmp->mhp > 0) {
} else if (!resist(mtmp, otmp->oclass, dmg, NOTELL) && !DEADMONSTER(mtmp)) {
mtmp->mhp -= dmg;
mtmp->mhpmax -= dmg;
/* die if already level 0, regardless of hit points */
if (mtmp->mhp <= 0 || mtmp->mhpmax <= 0 || mtmp->m_lev < 1) {
if (DEADMONSTER(mtmp) || mtmp->mhpmax <= 0 || mtmp->m_lev < 1) {
killed(mtmp);
} else {
mtmp->m_lev--;
@@ -433,7 +433,7 @@ struct obj *otmp;
break;
}
if (wake) {
if (mtmp->mhp > 0) {
if (!DEADMONSTER(mtmp)) {
wakeup(mtmp, helpful_gesture ? FALSE : TRUE);
m_respond(mtmp);
if (mtmp->isshk && !*u.ushops)
@@ -446,7 +446,7 @@ struct obj *otmp;
* might be an invisible worm hit on the tail.
*/
if (reveal_invis) {
if (mtmp->mhp > 0 && cansee(bhitpos.x, bhitpos.y)
if (!DEADMONSTER(mtmp) && cansee(bhitpos.x, bhitpos.y)
&& !canspotmon(mtmp))
map_invisible(bhitpos.x, bhitpos.y);
}
@@ -3956,7 +3956,7 @@ boolean say; /* Announce out of sight hit/miss events if true */
/* Using disintegration from the inside only makes a hole... */
if (tmp == MAGIC_COOKIE)
u.ustuck->mhp = 0;
if (u.ustuck->mhp < 1)
if (DEADMONSTER(u.ustuck))
killed(u.ustuck);
return;
}
@@ -4044,7 +4044,7 @@ boolean say; /* Announce out of sight hit/miss events if true */
if (tmp == MAGIC_COOKIE) { /* disintegration */
disintegrate_mon(mon, type, fltxt);
} else if (mon->mhp < 1) {
} else if (DEADMONSTER(mon)) {
if (type < 0) {
/* mon has just been killed by another monster */
monkilled(mon, fltxt, AD_RBRE);
@@ -4998,7 +4998,7 @@ int damage, tell;
if (damage) {
mtmp->mhp -= damage;
if (mtmp->mhp < 1) {
if (DEADMONSTER(mtmp)) {
if (m_using)
monkilled(mtmp, "", AD_RBRE);
else