]> granicus.if.org Git - nethack/commitdiff
Unaware; fix #H202 and extend the fix for #H179 (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 2 Sep 2006 03:32:18 +0000 (03:32 +0000)
committernethack.rankin <nethack.rankin>
Sat, 2 Sep 2006 03:32:18 +0000 (03:32 +0000)
     Turn being unconscious (via several reasons, including fainted from
hunger) into a pseudo-property named `Unaware' and use it in several
places where only being asleep was checked.  #H202 was about a stunned
character who got the recovery message when it timed out while fainted.
This suppresses messages for several difficulties when they begin or end
while hero is Unaware.  Messages about fatal illness, sliming, or
petrification aren't suppressed; they're too important to hide from the
player.  "You feel ..." messages come out as "You dream that you feel ..."
when Unaware; fairly lame but hopefully adequate.

doc/fixes35.0
include/youprop.h
src/mhitm.c
src/mondata.c
src/monmove.c
src/pline.c
src/potion.c
src/trap.c

index 109a704c843a5df6b3639fbed9d454ece27af061..24c57f2b746fb56181277fec473c15b6d7f9ee0c 100644 (file)
@@ -157,6 +157,7 @@ if shopkeeper or priest gets teleported while inside his shop or temple,
        give locations inside that room preference when choosing destination
 tame/peaceful grabber/engulfer will release hero after conflict ends
 make changes in hallucination be reflected by changes in mimickery feedback
+add Unaware pseudo-property to suppress various messages while unconscious
 
 
 Platform- and/or Interface-Specific Fixes
index 11c98bc087e6bcb799d5159c3a4d625971aa7a67..6f6f59d807d7c72c1801da9e0455c13a5e8361c0 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)youprop.h  3.5     1999/07/02      */
+/*     SCCS Id: @(#)youprop.h  3.5     2006/09/01      */
 /* Copyright (c) 1989 Mike Threepoint                            */
 /* NetHack may be freely redistributed.  See license for details. */
 
 
 #define Lifesaved              u.uprops[LIFESAVED].extrinsic
 
+/* unconscious() includes u.usleep but not is_fainted(); the multi test is
+   redundant but allows the function calls to be skipped most of the time */
+#define Unaware                (multi < 0 && (unconscious() || is_fainted()))
 
 #endif /* YOUPROP_H */
index 37341a6f97c5586d3e4864840a08295c5800b1f1..702174c39ea457cc210441393883d0b6998e45ce 100644 (file)
@@ -327,7 +327,7 @@ mattackm(magr, mdef)
        mdef->mundetected = 0;
        newsym(mdef->mx, mdef->my);
        if(canseemon(mdef) && !sensemon(mdef)) {
-           if (u.usleep) You("dream of %s.",
+           if (Unaware) You("dream of %s.",
                                (mdef->data->geno & G_UNIQ) ?
                                a_monnam(mdef) : makeplural(m_monnam(mdef)));
            else pline("Suddenly, you notice %s.", a_monnam(mdef));
index 77040b2a9b12c611c6d255c198e9d94bf73c0010..dfbce3d5544484b36fcd879b9bd3ac48a09f0209 100644 (file)
@@ -119,7 +119,7 @@ struct monst *mon;
        boolean is_you = (mon == &youmonst);
        struct obj *o;
 
-       if (is_you ? (Blind || u.usleep || is_fainted()) :
+       if (is_you ? (Blind || Unaware) :
                (mon->mblinded || !mon->mcansee || !haseyes(ptr) ||
                    /* BUG: temporary sleep sets mfrozen, but since
                            paralysis does too, we can't check it */
@@ -185,7 +185,7 @@ struct obj *obj;            /* aatyp == AT_WEAP, AT_SPIT */
            break;
 
        case AT_ENGL:
-           if (is_you && (Blindfolded || u.usleep || u.ucreamed))
+           if (is_you && (Blindfolded || Unaware || u.ucreamed))
                return FALSE;
            if (!is_you && mdef->msleeping)
                return FALSE;
index f3aacb73fab70e5496617a50525e785271b3ca62..2deb551044e786836487e1734b0519c29885d77e 100644 (file)
@@ -21,7 +21,7 @@ mb_trapped(mtmp)
 register struct monst *mtmp;
 {
        if (flags.verbose) {
-           if (cansee(mtmp->mx, mtmp->my) && !u.usleep)
+           if (cansee(mtmp->mx, mtmp->my) && !Unaware)
                pline("KABOOM!!  You see a door explode.");
            else if (!Deaf)
                You_hear("a distant explosion.");
index a992836f45322dd6632e4a4fd29914bb5a78a99b..313d07bd6fd7b53d74c7b7e33f9178212223d68f 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pline.c    3.5     2006/02/20      */
+/*     SCCS Id: @(#)pline.c    3.5     2006/08/30      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -134,7 +134,11 @@ You_feel VA_DECL(const char *,line)
        char *tmp;
        VA_START(line);
        VA_INIT(line, const char *);
-       vpline(YouMessage(tmp, "You feel ", line), VA_ARGS);
+       if (Unaware)
+               YouPrefix(tmp, "You dream that you feel ", line);
+       else
+               YouPrefix(tmp, "You feel ", line);
+       vpline(strcat(tmp, line), VA_ARGS);
        VA_END();
 }
 
@@ -179,7 +183,7 @@ You_hear VA_DECL(const char *,line)
        VA_INIT(line, const char *);
        if (Underwater)
                YouPrefix(tmp, "You barely hear ", line);
-       else if (u.usleep)
+       else if (Unaware)
                YouPrefix(tmp, "You dream that you hear ", line);
        else
                YouPrefix(tmp, "You hear ", line);
@@ -194,7 +198,7 @@ You_see VA_DECL(const char *,line)
 
        VA_START(line);
        VA_INIT(line, const char *);
-       if (u.usleep)
+       if (Unaware)
                YouPrefix(tmp, "You dream that you see ", line);
        else if (Blind) /* caller should have caught this... */
                YouPrefix(tmp, "You sense ", line);
index 727c38a9812717b2f61eb521c0824732562d8c52..cbff9a0d7f8dfe21a3d1827fc3c4876acdc7a56a 100644 (file)
@@ -59,6 +59,8 @@ boolean talk;
 {
        long old = HConfusion;
 
+       if (Unaware) talk = FALSE;
+
        if (!xtime && old) {
                if (talk)
                    You_feel("less %s now.",
@@ -76,6 +78,8 @@ boolean talk;
 {
        long old = HStun;
 
+       if (Unaware) talk = FALSE;
+
        if (!xtime && old) {
                if (talk)
                    You_feel("%s now.",
@@ -105,6 +109,10 @@ int type;
 {
        long old = Sick;
 
+#if 0
+       if (Unaware) talk = FALSE;
+#endif
+
        if (xtime > 0L) {
            if (Sick_resistance) return;
            if (!old) {
@@ -125,7 +133,7 @@ int type;
                if (talk) You_feel("somewhat better.");
                set_itimeout(&Sick, Sick * 2); /* approximation */
            } else {
-               if (talk) pline("What a relief!");
+               if (talk) You_feel("cured.  What a relief!");
                Sick = 0L;              /* set_itimeout(&Sick, 0L) */
            }
            context.botl = TRUE;
@@ -145,6 +153,10 @@ const char *msg;
 {
        long old = Slimed;
 
+#if 0
+       if (Unaware) msg = 0;
+#endif
+
        if ((!xtime && old) || (xtime && !old)) {
            if (msg) pline("%s", msg);
            context.botl = 1;
@@ -163,6 +175,10 @@ const char *killername;
 {
        long old = Stoned;
 
+#if 0
+       if (Unaware) msg = 0;
+#endif
+
        if ((!xtime && old) || (xtime && !old)) {
            if (msg) pline("%s", msg);
         /* context.botl = 1;   --- Stoned is not a status line item */
@@ -179,6 +195,8 @@ boolean talk;
 {
        long old = Vomiting;
 
+       if (Unaware) talk = FALSE;
+
        if(!xtime && old)
            if(talk) You_feel("much less nauseated now.");
 
@@ -205,7 +223,7 @@ boolean talk;
        can_see_now = !Blind;
        Blinded = old;          /* restore */
 
-       if (u.usleep) talk = FALSE;
+       if (Unaware) talk = FALSE;
 
        if (can_see_now && !u_could_see) {      /* regaining sight */
            if (talk) {
@@ -283,6 +301,8 @@ long mask;  /* nonzero if resistance status should change by mask */
        boolean changed = 0;
        const char *message, *verb;
 
+       if (Unaware) talk = FALSE;
+
        message = (!xtime) ? "Everything %s SO boring now." :
                             "Oh wow!  Everything %s so cosmic!";
        verb = (!Blind) ? "looks" : "feels";
@@ -1431,12 +1451,12 @@ register struct obj *obj;
                exercise(A_DEX, TRUE);
                break;
        case POT_BLINDNESS:
-               if (!Blind && !u.usleep) {
+               if (!Blind && !Unaware) {
                    kn++;
                    pline("It suddenly gets dark.");
                }
                make_blinded(itimeout_incr(Blinded, rnd(5)), FALSE);
-               if (!Blind && !u.usleep) Your(vision_clears);
+               if (!Blind && !Unaware) Your(vision_clears);
                break;
        case POT_WATER:
                if(u.umonnum == PM_GREMLIN) {
index 2b4dea11387210f643f535615051381d45b9482e..8813f457c17f5f80eefafb4a92701f410e8350bf 100644 (file)
@@ -3092,7 +3092,7 @@ drown()
                return(FALSE);
        }
        if ((Teleportation || can_teleport(youmonst.data)) &&
-                   !u.usleep && (Teleport_control || rn2(3) < Luck+2)) {
+                   !Unaware && (Teleport_control || rn2(3) < Luck+2)) {
                You("attempt a teleport spell.");       /* utcsri!carroll */
                if (!level.flags.noteleport) {
                        (void) dotele();
@@ -3113,6 +3113,8 @@ drown()
           while still asleep; we can't do that the same way that waking
           due to combat is handled; note unmul() clears u.usleep */
        if (u.usleep) unmul("Suddenly you wake up!");
+       /* being doused will revive from fainting */
+       if (is_fainted()) reset_faint();
        /* can't crawl if unable to move (crawl_ok flag stays false) */
        if (multi < 0 || (Upolyd && !youmonst.data->mmove)) goto crawl;
        /* look around for a place to crawl to */