unseen pet drowning

The "you have a sad feeling for a moment" message was only given when
one monster kills another (and the latter is an unseen pet).  Give it
for drowning too.  There are probably a bunch of other circumstances
which warrant it as well but I've settled for handling minliquid().
This commit is contained in:
PatR
2020-02-13 15:38:59 -08:00
parent 878ec6ee2a
commit cbe27c7702
3 changed files with 40 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mon.c $NHDT-Date: 1581322664 2020/02/10 08:17:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.321 $ */
/* NetHack 3.6 mon.c $NHDT-Date: 1581637127 2020/02/13 23:38:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.322 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -24,6 +24,7 @@ static boolean FDECL(isspecmon, (struct monst *));
static boolean FDECL(validspecmon, (struct monst *, int));
static struct permonst *FDECL(accept_newcham_form, (struct monst *, int));
static struct obj *FDECL(make_corpse, (struct monst *, unsigned));
static int FDECL(minliquid_core, (struct monst *));
static void FDECL(m_detach, (struct monst *, struct permonst *));
static void FDECL(lifesaved_monster, (struct monst *));
static void FDECL(migrate_mon, (struct monst *, XCHAR_P, XCHAR_P));
@@ -436,8 +437,8 @@ unsigned corpseflags;
}
free_mname(mtmp);
return obj;
default_1:
default:
default_1:
if (g.mvitals[mndx].mvflags & G_NOCORPSE) {
return (struct obj *) 0;
} else {
@@ -487,7 +488,22 @@ unsigned corpseflags;
/* check mtmp and water/lava for compatibility, 0 (survived), 1 (died) */
int
minliquid(mtmp)
register struct monst *mtmp;
struct monst *mtmp;
{
int res;
/* set up flag for mondead() and xkilled() */
iflags.sad_feeling = (mtmp->mtame && !canseemon(mtmp));
res = minliquid_core(mtmp);
/* always clear the flag */
iflags.sad_feeling = FALSE;
return res;
}
/* guts of minliquid() */
static int
minliquid_core(mtmp)
struct monst *mtmp;
{
boolean inpool, inlava, infountain;
@@ -1930,8 +1946,13 @@ mondead(mtmp)
register struct monst *mtmp;
{
struct permonst *mptr;
boolean be_sad;
int tmp;
/* potential pet message; always clear global flag */
be_sad = iflags.sad_feeling;
iflags.sad_feeling = FALSE;
mtmp->mhp = 0; /* in case caller hasn't done this */
lifesaved_monster(mtmp);
if (!DEADMONSTER(mtmp))
@@ -2002,6 +2023,9 @@ register struct monst *mtmp;
}
}
if (be_sad)
You("have a sad feeling for a moment, then it passes.");
/* dead vault guard is actually kept at coordinate <0,0> until
his temporary corridor to/from the vault has been removed;
need to do this after life-saving and before m_detach() */
@@ -2274,15 +2298,13 @@ struct monst *mdef;
const char *fltxt;
int how;
{
boolean be_sad = FALSE; /* true if unseen pet is killed */
if ((mdef->wormno ? worm_known(mdef) : cansee(mdef->mx, mdef->my))
&& fltxt)
pline("%s is %s%s%s!", Monnam(mdef),
nonliving(mdef->data) ? "destroyed" : "killed",
*fltxt ? " by the " : "", fltxt);
else
be_sad = (mdef->mtame != 0);
iflags.sad_feeling = (mdef->mtame != 0);
/* no corpses if digested or disintegrated */
g.disintegested = (how == AD_DGST || how == -AD_RBRE);
@@ -2290,9 +2312,6 @@ int how;
mondead(mdef);
else
mondied(mdef);
if (be_sad && DEADMONSTER(mdef))
You("have a sad feeling for a moment, then it passes.");
}
void
@@ -2335,12 +2354,17 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */
struct permonst *mdat;
struct obj *otmp;
struct trap *t;
boolean be_sad;
boolean wasinside = u.uswallow && (u.ustuck == mtmp),
burycorpse = FALSE,
nomsg = (xkill_flags & XKILL_NOMSG) != 0,
nocorpse = (xkill_flags & XKILL_NOCORPSE) != 0,
noconduct = (xkill_flags & XKILL_NOCONDUCT) != 0;
/* potential pet message; always clear global flag */
be_sad = iflags.sad_feeling;
iflags.sad_feeling = FALSE;
mtmp->mhp = 0; /* caller will usually have already done this */
if (!noconduct) /* KMH, conduct */
u.uconduct.killer++;
@@ -2403,6 +2427,9 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */
return;
}
if (be_sad)
You("have a sad feeling for a moment, then it passes.");
mdat = mtmp->data; /* note: mondead can change mtmp->data */
mndx = monsndx(mdat);