]> granicus.if.org Git - nethack/commitdiff
hurtling into unseen monsters
authorPatR <rankin@nethack.org>
Tue, 10 Oct 2017 00:34:02 +0000 (17:34 -0700)
committerPatR <rankin@nethack.org>
Tue, 10 Oct 2017 00:34:02 +0000 (17:34 -0700)
Expand "You bump into it." into something more comprehensive when
encountering an unseen monster while hurtling.  Tested with jumping
but other forms of hurtling should behave the same.

src/dothrow.c

index 9918e5e778b17bb52e3f727c84d0d7216dcd8ccb..0b153945484e4618713f04482eb27a99459da621 100644 (file)
@@ -625,8 +625,8 @@ int x, y;
         }
         if ((u.ux - x) && (u.uy - y) && bad_rock(youmonst.data, u.ux, y)
             && bad_rock(youmonst.data, x, u.uy)) {
-            boolean too_much =
-                (invent && (inv_weight() + weight_cap() > 600));
+            boolean too_much = (invent && (inv_weight() + weight_cap() > 600));
+
             /* Move at a diagonal. */
             if (bigmonst(youmonst.data) || too_much) {
                 You("%sget forcefully wedged into a crevice.",
@@ -640,14 +640,43 @@ int x, y;
         }
     }
 
-    if ((mon = m_at(x, y)) != 0) {
-        You("bump into %s.", a_monnam(mon));
+    if ((mon = m_at(x, y)) != 0
+#if 0   /* we can't include these two exceptions unless we know we're
+         * going to end up past the current spot rather than on it;
+         * for that, we need to know that the range is not exhausted
+         * and also that the next spot doesn't contain an obstacle */
+        && !(mon->mundetected && hides_under(mon) && (Flying || Levitation))
+        && !(mon->mundetected && mon->data->mlet == S_EEL
+             && (Flying || Levitation || Wwalking))
+#endif
+        ) {
+        const char *mnam, *pronoun;
+        int glyph = glyph_at(x, y);
+
+        mon->mundetected = 0; /* wakeup() will handle mimic */
+        mnam = a_monnam(mon); /* after unhiding */
+        pronoun = mhim(mon);
+        if (!strcmp(mnam, "it")) {
+            /* mhim() uses pronoun_gender() which forces neuter if monster
+               can't be seen; we want him/her for humanoid sensed by touch */
+            if (!strcmp(pronoun, "it") && humanoid(mon->data))
+                pronoun = genders[mon->female].him;
+            mnam = !strcmp(pronoun, "it") ? "something" : "someone";
+        }
+        if (!glyph_is_monster(glyph) && !glyph_is_invisible(glyph))
+            You("find %s by bumping into %s.", mnam, pronoun);
+        else
+            You("bump into %s.", mnam);
         wakeup(mon, FALSE);
+        if (!canspotmon(mon))
+            map_invisible(mon->mx, mon->my);
         setmangry(mon, FALSE);
-        wake_nearto(x,y, 10);
+        wake_nearto(x, y, 10);
         return FALSE;
     }
-    if ((u.ux - x) && (u.uy - y) && bad_rock(youmonst.data, u.ux, y)
+
+    if ((u.ux - x) && (u.uy - y)
+        && bad_rock(youmonst.data, u.ux, y)
         && bad_rock(youmonst.data, x, u.uy)) {
         /* Move at a diagonal. */
         if (Sokoban) {