-/* NetHack 3.6 mhitm.c $NHDT-Date: 1513297346 2017/12/15 00:22:26 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.99 $ */
+/* NetHack 3.6 mhitm.c $NHDT-Date: 1555720096 2019/04/20 00:28:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.113 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
char *outbuf;
struct monst *mon, *other_mon;
{
- Strcpy(outbuf, mon_nam(mon));
- if (mon == other_mon)
+ if (mon != other_mon)
+ Strcpy(outbuf, mon_nam(mon));
+ else
#if 0 /*JP*/
- switch (pronoun_gender(mon)) {
+ switch (pronoun_gender(mon, FALSE)) {
case 0:
Strcpy(outbuf, "himself");
break;
map_invisible(magr->mx, magr->my);
if (!canspotmon(mdef))
map_invisible(mdef->mx, mdef->my);
- if (mdef->m_ap_type)
+ if (M_AP_TYPE(mdef))
seemimic(mdef);
- if (magr->m_ap_type)
+ if (M_AP_TYPE(magr))
seemimic(magr);
#if 0 /*JP*/
fmt = (could_seduce(magr, mdef, mattk) && !magr->mcan)
/* undetected monster becomes un-hidden if it is displaced */
if (mdef->mundetected)
mdef->mundetected = 0;
- if (mdef->m_ap_type && mdef->m_ap_type != M_AP_MONSTER)
+ if (M_AP_TYPE(mdef) && M_AP_TYPE(mdef) != M_AP_MONSTER)
seemimic(mdef);
/* wake up the displaced defender */
mdef->msleeping = 0;
*/
pline("%s\82Í\90Î\82É\82È\82Á\82½\81I", Monnam(magr));
monstone(magr);
- if (magr->mhp > 0)
+ if (!DEADMONSTER(magr))
return MM_HIT; /* lifesaved */
else if (magr->mtame && !vis)
/*JP
|| objects[otmp->otyp].oc_material == METAL))
&& mdef->mhp > 1
&& !mdef->mcan) {
- if (clone_mon(mdef, 0, 0)) {
+ struct monst *mclone;
+ if ((mclone = clone_mon(mdef, 0, 0)) != 0) {
if (vis && canspotmon(mdef)) {
char buf[BUFSZ];
mon_nam(magr), buf);
#endif
}
+ mintrap(mclone);
}
}
} else
map_invisible(magr->mx, magr->my);
if (!canspotmon(mdef))
map_invisible(mdef->mx, mdef->my);
- if (mdef->m_ap_type)
+ if (M_AP_TYPE(mdef))
seemimic(mdef);
- if (magr->m_ap_type)
+ if (M_AP_TYPE(magr))
seemimic(magr);
if ((compat = could_seduce(magr, mdef, mattk)) && !magr->mcan) {
#if 0 /*JP*/
if (vis) {
if (mdef->data->mlet == S_MIMIC
- && mdef->m_ap_type != M_AP_NOTHING)
+ && M_AP_TYPE(mdef) != M_AP_NOTHING)
seemimic(mdef);
#if 0 /*JP*/
Sprintf(buf, "%s gazes at", Monnam(magr));
*/
pline("%s\82Í\90Î\82É\82È\82Á\82½\81I", Monnam(magr));
monstone(magr);
- if (magr->mhp > 0)
+ if (!DEADMONSTER(magr))
return MM_MISS;
return MM_AGR_DIED;
}
* but don't leave it on the screen. Move the aggressor to the
* defender's position.
*/
+ remove_monster(dx, dy);
remove_monster(ax, ay);
place_monster(magr, dx, dy);
newsym(ax, ay); /* erase old position */
/* Kill off aggressor if it didn't die. */
if (!(result & MM_AGR_DIED)) {
+ boolean was_leashed = (magr->mleashed != 0);
+
mondead(magr);
- if (magr->mhp > 0)
+ if (!DEADMONSTER(magr))
return result; /* life saved */
result |= MM_AGR_DIED;
+
+ /* mondead() -> m_detach() -> m_unleash() always suppresses
+ the m_unleash() slack message, so deliver it here instead */
+ if (was_leashed)
+ Your("leash falls slack.");
}
if (magr->mtame) /* give this one even if it was visible */
/*JP
*/
pline("%s\82Í\90Î\82É\82È\82Á\82½\81I", Monnam(magr));
monstone(magr);
- if (magr->mhp > 0)
+ if (!DEADMONSTER(magr))
return MM_HIT; /* lifesaved */
else if (magr->mtame && !vis)
/*JP
: "\8c\83\82µ\82\9aq\93f\82µ\8e\80\82ñ\82¾");
#endif
mondied(magr);
- if (magr->mhp > 0)
+ if (!DEADMONSTER(magr))
return 0; /* lifesaved */
else if (magr->mtame && !vis)
/*JP
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.
case AD_WERE:
case AD_HEAL:
case AD_PHYS:
- physical:
+ physical:
if (mattk->aatyp == AT_KICK && thick_skinned(pd)) {
tmp = 0;
} else if (mattk->aatyp == AT_WEAP) {
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));
}
*/
pline("%s\82Í\8aD\82É\82È\82Á\82½\81I", 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)
/*JP
*/
pline("%s\82Í\83o\83\89\83o\83\89\82É\82È\82Á\82½\81I", Monnam(mdef));
mondied(mdef);
- if (mdef->mhp > 0)
+ if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
/*JP
*/
pline("%s\82Í\83o\83\89\83o\83\89\82É\82È\82Á\82½\81I", Monnam(mdef));
mondied(mdef);
- if (mdef->mhp > 0)
+ if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
/*JP
case AD_STON:
if (magr->mcan)
break;
- do_stone:
+ do_stone:
/* may die from the acid if it eats a stone-curing corpse */
if (munstone(mdef, FALSE))
goto post_stone;
*/
pline("%s\82Í\90Î\82É\82È\82Á\82½\81I", Monnam(mdef));
monstone(mdef);
- post_stone:
- if (mdef->mhp > 0)
+ post_stone:
+ if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
/*JP
if (!cancelled && tmp < mdef->mhp && !tele_restrict(mdef)) {
char mdef_Monnam[BUFSZ];
boolean wasseen = canspotmon(mdef);
+
/* save the name before monster teleports, otherwise
we'll get "it" in the suddenly disappears message */
if (vis && wasseen)
pline("%s suddenly disappears!", mdef_Monnam);
*/
pline("%s\82Í\93Ë\91R\8fÁ\82¦\82½\81I", mdef_Monnam);
+ if (tmp >= mdef->mhp) { /* see hitmu(mhitu.c) */
+ if (mdef->mhp == 1)
+ ++mdef->mhp;
+ tmp = mdef->mhp - 1;
+ }
}
break;
case AD_SLEE:
pline("%s\82Í\94j\89ó\82³\82ê\82½\81I", Monnam(mdef));
}
mondied(mdef);
- if (mdef->mhp > 0)
+ if (!DEADMONSTER(mdef))
return 0;
else if (mdef->mtame && !vis)
/*JP
mwepgone(mdef);
otmp->owornmask = 0L;
update_mon_intrinsics(mdef, otmp, FALSE, FALSE);
+ /* give monster a chance to wear other equipment on its next
+ move instead of waiting until it picks something up */
+ mdef->misc_worn_check |= I_SPECIAL;
}
/* add_to_minv() might free otmp [if it merges] */
if (vis)
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)) {
if (cancelled)
break; /* physical damage only */
if (!rn2(4) && !slimeproof(pd)) {
- if (!munslime(mdef, FALSE) && mdef->mhp > 0) {
- if (newcham(mdef, &mons[PM_GREEN_SLIME], FALSE, vis && canseemon(mdef)))
+ if (!munslime(mdef, FALSE) && !DEADMONSTER(mdef)) {
+ if (newcham(mdef, &mons[PM_GREEN_SLIME], FALSE,
+ (boolean) (vis && canseemon(mdef))))
pd = mdef->data;
mdef->mstrategy &= ~STRAT_WAITFORU;
res = MM_HIT;
}
/* 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;
}
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);
} 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;
}
else
tmp = 0;
-assess_dmg:
+ assess_dmg:
if ((magr->mhp -= tmp) <= 0) {
monkilled(magr, "", (int) mddat->mattk[i].adtyp);
return (mdead | mhit | MM_AGR_DIED);