-/* NetHack 3.7 dog.c $NHDT-Date: 1652524227 2022/05/14 10:30:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.119 $ */
+/* NetHack 3.7 dog.c $NHDT-Date: 1652577033 2022/05/15 01:10:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.120 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
more segments than can fit in that field gets truncated */
num_segs = min(cnt, MAX_NUM_WORMS - 1);
wormgone(mtmp); /* discard tail segments, take head off map */
- /* this used to be place_monster() but relmon() doesn't
- need that as long as coordinates reflect actual state */
- mtmp->mx = mtmp->my = 0; /* off normal map */
+ /* mtmp->mx,mtmp->my is now 0,0 */
}
return num_segs;
xchar xyflags, mx = mtmp->mx, my = mtmp->my; /* <mx,my> needed below */
int num_segs; /* count of worm segments */
- /* prepare to take mtmp off the map */
- num_segs = mon_leave(mtmp);
-
if (mtmp->mleashed) {
mtmp->mtame--;
m_unleash(mtmp, TRUE);
}
+ /* prepare to take mtmp off the map */
+ num_segs = mon_leave(mtmp);
/* take off map and move mtmp from fmon list to migrating_mons */
relmon(mtmp, &g.migrating_mons); /* mtmp->mx,my get changed to 0,0 */
mtmp->mstate |= MON_MIGRATING;
-/* NetHack 3.7 worm.c $NHDT-Date: 1608236444 2020/12/17 20:20:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.49 $ */
+/* NetHack 3.7 worm.c $NHDT-Date: 1652577033 2022/05/15 01:10:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.55 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2009. */
/* NetHack may be freely redistributed. See license for details. */
/*
* wormgone()
*
- * Check for mon->wormno before calling this function!
+ * Kill a worm tail. Also takes the head off the map. Caller needs to
+ * keep track of what its coordinates were if planning to put it back.
*
- * Kill a worm tail.
+ * Should only be called when mon->wormno is non-zero.
*/
void
wormgone(struct monst *worm)
{
int wnum = worm->wormno;
- worm->wormno = 0;
- /* This will also remove the real monster (ie 'w') from the its
- * position in level.monsters[][].
+ if (!wnum) /* note: continuing with wnum==0 runs to completion */
+ impossible("wormgone: wormno is 0");
+
+ worm->wormno = 0; /* still a long worm but doesn't grow/shrink anymore */
+ /*
+ * This will also remove the real monster (ie 'w') from the its
+ * position in level.monsters[][]. (That happens when removing
+ * the hidden tail segment which is co-located with the head.)
*/
toss_wsegs(wtails[wnum], TRUE);
+ worm->mx = worm->my = 0; /* 'worm' is no longer on map but has not
+ * been killed off; caller might put it back */
wheads[wnum] = wtails[wnum] = (struct wseg *) 0;
wgrowtime[wnum] = 0L;
+
+ /* we don't expect to encounter this here but check for it anyway;
+ when a long worm gets created by a polymorph zap, it gets flagged
+ with MCORPSENM()==PM_LONG_WORM so that the same zap won't trigger
+ another polymorph if it hits the new tail */
+ if (worm->data == &mons[PM_LONG_WORM] && has_mcorpsenm(worm))
+ MCORPSENM(worm) = NON_PM; /* not polymorph-proof */
}
/*
-/* NetHack 3.7 worn.c $NHDT-Date: 1649529637 2022/04/09 18:40:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.82 $ */
+/* NetHack 3.7 worn.c $NHDT-Date: 1652577035 2022/05/15 01:10:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.84 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
/* set or clear the bypass bit in a list of objects */
void
-bypass_objlist(struct obj *objchain,
- boolean on) /* TRUE => set, FALSE => clear */
+bypass_objlist(
+ struct obj *objchain,
+ boolean on) /* TRUE => set, FALSE => clear */
{
if (on && objchain)
g.context.bypasses = TRUE;