]> granicus.if.org Git - nethack/commitdiff
hallucinatory water and lava terrain
authorPatR <rankin@nethack.org>
Sat, 11 Jan 2020 17:34:01 +0000 (09:34 -0800)
committerPatR <rankin@nethack.org>
Sat, 11 Jan 2020 17:34:01 +0000 (09:34 -0800)
When browsing the map while hallucinating and looking at a pool, a
moat, or 'other' water or at molten lava, report with hallucinatory
liquids rather than the ordinary substance.  Likewise when browsing
self on map or using ^X would report "sinking into lava".

doc/fixes37.0
include/extern.h
src/cmd.c
src/do_name.c
src/pager.c

index 3443d41c8fe4f65b699f3657301d3934c4d2150d..83b7c194ed809da9a94d6be6314fc30e9b90f6ff 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.61 $ $NHDT-Date: 1578761136 2020/01/11 16:45:36 $
+$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.62 $ $NHDT-Date: 1578764038 2020/01/11 17:33:58 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -98,6 +98,8 @@ add 'quick_farsight' option to provide some control over random clairvoyance
        revealed map can seem intrusive; doesn't affect clairvoyance spell
 replace "money" in in-game texts with "gold"
 when hallucinating, see hallucinated currencies instead of bits for an ale
+when hallucinating, see hallucinated liquids when looking at water or lava
+       on the map
 applying a spellbook hints about read charges left
 wizard mode wishing for level topology can now create hidden doors (ask for
        "secret door" when at a door or wall location) and hidden corridor
index 6df34ea7116cacd8822d7f1af175eb0044302c9d..da0edbb6535c1c2e8eca05ff88866fa68168dfcf 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1578668018 2020/01/10 14:53:38 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.782 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1578764033 2020/01/11 17:33:53 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.783 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -231,7 +231,7 @@ E void FDECL(rhack, (char *));
 E int NDECL(doextlist);
 E int NDECL(extcmd_via_menu);
 E int NDECL(enter_explore_mode);
-E char *FDECL(trap_predicament, (char *, BOOLEAN_P));
+E char *FDECL(trap_predicament, (char *, int, BOOLEAN_P));
 E void FDECL(enlightenment, (int, int));
 E void FDECL(youhiding, (BOOLEAN_P, int));
 E void FDECL(show_conduct, (int));
index b6c0e80e8793e8f299cba08a6c46f5303edac06e..11eb394b23025dbb859f5739c3bcd687bc72d3e0 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 cmd.c   $NHDT-Date: 1578668021 2020/01/10 14:53:41 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.390 $ */
+/* NetHack 3.6 cmd.c   $NHDT-Date: 1578764033 2020/01/11 17:33:53 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.391 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1813,8 +1813,9 @@ walking_on_water()
 
 /* describe u.utraptype; used by status_enlightenment() and self_lookat() */
 char *
-trap_predicament(outbuf, wizxtra)
+trap_predicament(outbuf, final, wizxtra)
 char *outbuf;
+int final;
 boolean wizxtra;
 {
     struct trap *t;
@@ -1826,9 +1827,7 @@ boolean wizxtra;
         Strcpy(outbuf, "tethered to something buried");
         break;
     case TT_LAVA:
-        /* surface() should always yield "lava" here unless hallucinatory
-           surfaces get added someday [please don't...] */
-        Sprintf(outbuf, "sinking into %s", surface(u.ux, u.uy));
+        Sprintf(outbuf, "sinking into %s", final ? "lava" : hliquid("lava"));
         break;
     case TT_INFLOOR:
         Sprintf(outbuf, "stuck in %s", the(surface(u.ux, u.uy)));
@@ -2547,7 +2546,7 @@ int final;
         char predicament[BUFSZ];
         boolean anchored = (u.utraptype == TT_BURIEDBALL);
 
-        (void) trap_predicament(predicament, wizard);
+        (void) trap_predicament(predicament, final, wizard);
         if (u.usteed) { /* not `Riding' here */
             Sprintf(buf, "%s%s ", anchored ? "you and " : "", steedname);
             *buf = highc(*buf);
index 57cb551c8f6a0d022a97287107ccbc75225b9aca..31574603fca742c2a463613963709bd47d6f400a 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 do_name.c       $NHDT-Date: 1574648939 2019/11/25 02:28:59 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.167 $ */
+/* NetHack 3.6 do_name.c       $NHDT-Date: 1578764034 2020/01/11 17:33:54 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.169 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2161,14 +2161,26 @@ static NEARDATA const char *const hliquids[] = {
     "caramel sauce", "ink", "aqueous humour", "milk substitute",
     "fruit juice", "glowing lava", "gastric acid", "mineral water",
     "cough syrup", "quicksilver", "sweet vitriol", "grey goo", "pink slime",
+    /* "new coke (tm)", --better not */
 };
 
+/* if hallucinating, return a random liquid instead of 'liquidpref' */
 const char *
 hliquid(liquidpref)
-const char *liquidpref;
+const char *liquidpref; /* use as-is when not hallucinating (unless empty) */
 {
-    return (Hallucination || !liquidpref) ? hliquids[rn2(SIZE(hliquids))]
-                                          : liquidpref;
+    if (Hallucination || !liquidpref || !*liquidpref) {
+        int indx, count = SIZE(hliquids);
+
+        /* if we have a non-hallucinatory default value, include it
+           among the choices */
+        if (liquidpref && *liquidpref)
+            ++count;
+        indx = rn2_on_display_rng(count);
+        if (indx < SIZE(hliquids))
+            return hliquids[indx];
+    }
+    return liquidpref;
 }
 
 /* Aliases for road-runner nemesis
index 35548e6bd47a62ddc2ccf0c947374d445059d308..63f0619818c09a78c808bb6e6ffe3f2c8123c081 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 pager.c $NHDT-Date: 1578761137 2020/01/11 16:45:37 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.182 $ */
+/* NetHack 3.6 pager.c $NHDT-Date: 1578764034 2020/01/11 17:33:54 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.183 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -95,7 +95,7 @@ char *outbuf;
         Sprintf(eos(outbuf), ", chained to %s",
                 uball ? ansimpleoname(uball) : "nothing?");
     if (u.utrap) /* bear trap, pit, web, in-floor, in-lava, tethered */
-        Sprintf(eos(outbuf), ", %s", trap_predicament(trapbuf, FALSE));
+        Sprintf(eos(outbuf), ", %s", trap_predicament(trapbuf, 0, FALSE));
     return outbuf;
 }
 
@@ -842,14 +842,16 @@ struct permonst **for_supplement;
     static const char mon_interior[] = "the interior of a monster",
                       unreconnoitered[] = "unreconnoitered";
     static char look_buf[BUFSZ];
-    char prefix[BUFSZ];
+    char prefix[BUFSZ], gobbledygook[33];
     int i, alt_i, j, glyph = NO_GLYPH,
         skipped_venom = 0, found = 0; /* count of matching syms found */
     boolean hit_trap, need_to_look = FALSE,
-            submerged = (Underwater && !Is_waterlevel(&u.uz));
+            submerged = (Underwater && !Is_waterlevel(&u.uz)),
+            hallucinate = (Hallucination && !g.program_state.gameover);
     const char *x_str;
     nhsym tmpsym;
 
+    gobbledygook[0] = '\0'; /* no hallucinatory liquid (yet) */
     if (looked) {
         int oc;
         unsigned os;
@@ -916,7 +918,8 @@ struct permonst **for_supplement;
     /* Check for monsters */
     if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) {
         for (i = 1; i < MAXMCLASSES; i++) {
-            if (sym == (looked ? g.showsyms[i + SYM_OFF_M] : def_monsyms[i].sym)
+            if (sym == (looked ? g.showsyms[i + SYM_OFF_M]
+                               : def_monsyms[i].sym)
                 && def_monsyms[i].explain && *def_monsyms[i].explain) {
                 need_to_look = TRUE;
                 if (!found) {
@@ -995,14 +998,26 @@ struct permonst **for_supplement;
             /* alt_i is now 3 or more and no longer of interest */
         }
         if (sym == (looked ? g.showsyms[i] : defsyms[i].sym) && *x_str) {
+            /* POOL, MOAT, and WATER are "water", LAVAPOOL is "molten lava" */
+            boolean water_or_lava = (!strcmp(x_str, "water")
+                                     || !strcmp(x_str, "molten lava"));
             /* avoid "an unexplored", "an stone", "an air", "a water",
-               "a floor of a room", "a dark part of a room";
+               "a molten lava", "a floor of a room", "a dark part of a room";
                article==2 => "the", 1 => "an", 0 => (none) */
             int article = strstri(x_str, " of a room") ? 2
                           : !(alt_i <= 2
                               || strcmp(x_str, "air") == 0
                               || strcmp(x_str, "land") == 0
-                              || strcmp(x_str, "water") == 0);
+                              || water_or_lava);
+
+            /* substitute for "water" and "molten lava" when hallucinating */
+            if (water_or_lava && hallucinate) {
+                if (*gobbledygook)
+                    continue; /* just 1 or player could tell h2o from lava */
+                x_str = strncpy(gobbledygook, hliquid(x_str),
+                                (int) sizeof gobbledygook - 1);
+                gobbledygook[sizeof gobbledygook - 1] = '\0';
+            }
 
             if (!found) {
                 if (is_cmap_trap(i)) {
@@ -1135,6 +1150,11 @@ struct permonst **for_supplement;
             pm = lookat(cc.x, cc.y, look_buf, monbuf);
             if (pm && for_supplement)
                 *for_supplement = pm;
+            /* lookat() doesn't hallucinate liquids; substitute ours */
+            if (*gobbledygook && (!strcmp(look_buf, "water")
+                                  || !strcmp(look_buf, "molten lava")))
+                Strcpy(look_buf, gobbledygook);
+
             *firstmatch = look_buf;
             if (*(*firstmatch)) {
                 Sprintf(temp_buf, " (%s)", *firstmatch);
@@ -1149,6 +1169,8 @@ struct permonst **for_supplement;
             }
         }
     }
+    if (*firstmatch == gobbledygook) /* fixup for 'found==1' */
+        *firstmatch = strcpy(look_buf, gobbledygook);
 
     return found;
 }