Sleeping vs Sleepy (trunk only)

While looking at fixing the mfrozen issue for monsters (there's no
way to tell whether it's been caused by sleep or paralysis, necessitating
that some messages be vague or suppressed when actions impact monsters
who can't move), I noticed a drawbridge bug for the hero.  It was using
the misleadingly named Sleeping intrinsic incorrectly.  When that is
nonzero, the hero is prone to falling asleep at random intervals, not
necessarily asleep right now.  I've always intended to rename it to
something that's not misleading, but hadn't ever gotten around to doing
so, until now:  change the SLEEPING property to SLEEPY and the Sleeping
intrinsic/attribute to Sleepy.

     This may be moot for the drawbridge.  I can't remember any hero ever
jumping to safety instead of being crushed by either the bridge or its
portcullis, and I'm sure sleepiness hasn't been a factor.  So I haven't
included any fixes entry about misusing Sleeping when it meant u.usleep
(or better yet, unconscious(); or even better, Unaware [a post-3.4.3
pseudo-property that tests both unconscious() and fainted() when checking
whether hero is incapacitated]).
This commit is contained in:
nethack.rankin
2011-07-28 04:00:21 +00:00
parent 164f498a41
commit 28ab93325e
9 changed files with 28 additions and 31 deletions

View File

@@ -1544,11 +1544,11 @@ int final;
if (magic || cause_known(FUMBLING))
enl_msg(You_, "fumble", "fumbled", "", from_what(FUMBLING));
}
if (Sleeping) {
if (magic || cause_known(SLEEPING)) {
Strcpy(buf, from_what(SLEEPING));
if (Sleepy) {
if (magic || cause_known(SLEEPY)) {
Strcpy(buf, from_what(SLEEPY));
#ifdef WIZARD
if (wizard) Sprintf(eos(buf), " (%ld)", (HSleeping & TIMEOUT));
if (wizard) Sprintf(eos(buf), " (%ld)", (HSleepy & TIMEOUT));
#endif
enl_msg("You ", "fall", "fell", " asleep uncontrollably", buf);
}

View File

@@ -1,5 +1,4 @@
/* NetHack 3.5 dbridge.c $Date$ $Revision$ */
/* SCCS Id: @(#)dbridge.c 3.5 2007/02/19 */
/* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */
@@ -463,8 +462,8 @@ boolean chunks;
return(TRUE);
if (is_flyer(etmp->edata) &&
(is_u(etmp)? !Sleeping :
(etmp->emon->mcanmove && !etmp->emon->msleeping)))
(is_u(etmp)? !Unaware :
(etmp->emon->mcanmove && !etmp->emon->msleeping)))
/* flying requires mobility */
misses = 5; /* out of 8 */
else if (is_floater(etmp->edata) ||
@@ -495,9 +494,9 @@ struct entity *etmp;
{
int tmp = 4; /* out of 10 */
if (is_u(etmp)? (Sleeping || Fumbling) :
(!etmp->emon->mcanmove || etmp->emon->msleeping ||
!etmp->edata->mmove || etmp->emon->wormno))
if (is_u(etmp) ? (Unaware || Fumbling) :
(!etmp->emon->mcanmove || etmp->emon->msleeping ||
!etmp->edata->mmove || etmp->emon->wormno))
return(FALSE);
if (is_u(etmp)? Confusion : etmp->emon->mconf)

View File

@@ -712,12 +712,12 @@ Amulet_on()
break;
case AMULET_OF_RESTFUL_SLEEP:
{
long newnap = (long)rnd(100), oldnap = (HSleeping & TIMEOUT);
long newnap = (long)rnd(100), oldnap = (HSleepy & TIMEOUT);
/* avoid clobbering FROMOUTSIDE bit, which might have
gotten set by previously eating one of these amulets */
if (newnap < oldnap || oldnap == 0L)
HSleeping = (HSleeping & ~TIMEOUT) | newnap;
HSleepy = (HSleepy & ~TIMEOUT) | newnap;
}
break;
case AMULET_OF_YENDOR:
@@ -767,9 +767,9 @@ Amulet_off()
break;
case AMULET_OF_RESTFUL_SLEEP:
setworn((struct obj *)0, W_AMUL);
/* HSleeping = 0L; -- avoid clobbering FROMOUTSIDE bit */
if (!ESleeping && !(HSleeping & ~TIMEOUT))
HSleeping &= ~TIMEOUT; /* clear timeout bits */
/* HSleepy = 0L; -- avoid clobbering FROMOUTSIDE bit */
if (!ESleepy && !(HSleepy & ~TIMEOUT))
HSleepy &= ~TIMEOUT; /* clear timeout bits */
return;
case AMULET_OF_YENDOR:
break;

View File

@@ -1953,14 +1953,14 @@ struct obj *otmp;
break;
case AMULET_OF_RESTFUL_SLEEP: /* another bad idea! */
{
long newnap = (long)rnd(100), oldnap = (HSleeping & TIMEOUT);
long newnap = (long)rnd(100), oldnap = (HSleepy & TIMEOUT);
if (!(HSleeping & FROMOUTSIDE))
if (!(HSleepy & FROMOUTSIDE))
accessory_has_effect(otmp);
HSleeping |= FROMOUTSIDE;
HSleepy |= FROMOUTSIDE;
/* might also be wearing one; use shorter of two timeouts */
if (newnap < oldnap || oldnap == 0L)
HSleeping = (HSleeping & ~TIMEOUT) | newnap;
HSleepy = (HSleepy & ~TIMEOUT) | newnap;
}
break;
case RIN_SUSTAIN_ABILITY:

View File

@@ -548,7 +548,7 @@ RING("protection from shape changers", PROT_FROM_SHAPE_CHANGERS, "shiny",
AMULET("amulet of ESP", "circular", TELEPAT, 175),
AMULET("amulet of life saving", "spherical", LIFESAVED, 75),
AMULET("amulet of strangulation", "oval", STRANGLED, 135),
AMULET("amulet of restful sleep", "triangular", SLEEPING, 135),
AMULET("amulet of restful sleep", "triangular", SLEEPY, 135),
AMULET("amulet versus poison", "pyramidal", POISON_RES, 165),
AMULET("amulet of change", "square", 0, 130),
/* POLYMORPH */

View File

@@ -1,5 +1,4 @@
/* NetHack 3.5 timeout.c $Date$ $Revision$ */
/* SCCS Id: @(#)timeout.c 3.5 2009/01/20 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -337,14 +336,14 @@ nh_timeout()
(void) make_hallucinated(0L, TRUE, 0L);
stop_occupation();
break;
case SLEEPING:
case SLEEPY:
if (unconscious() || Sleep_resistance)
HSleeping += rnd(100);
else if (Sleeping) {
HSleepy += rnd(100);
else if (Sleepy) {
You("fall asleep.");
sleeptime = rnd(20);
fall_asleep(-sleeptime, TRUE);
HSleeping += sleeptime + rnd(100);
HSleepy += sleeptime + rnd(100);
}
break;
case LEVITATION: