]> granicus.if.org Git - nethack/commitdiff
feedback for monster jumping onto polymorph trap
authorPatR <rankin@nethack.org>
Thu, 21 Oct 2021 19:07:19 +0000 (12:07 -0700)
committerPatR <rankin@nethack.org>
Thu, 21 Oct 2021 19:07:19 +0000 (12:07 -0700)
Give feedback for "<Mon> jumps onto a polymorph trap" in more
circumstances.  It used to give the message if the monster could
be seen, and it would map the trap if the monster's location could
be seen.  That led to some confusion when an infra-visible monster
was at a spot in the dark so the trap was accurately described but
didn't get mapped.

Map the trap if either the monster's or the trap's location can be
seen.  If it isn't already known and isn't becoming known (the
infravision case), say "hidden trap" instead of "polymorph trap"
in the message.  Give the "jumps onto trap" message if either the
monster can be seen or the trap's spot can be seen.  When monster
can't be seen, it would normally be described as "It"; switch to
"Someone" (when humanoid) or "Something" (non-humanoid) instead.

Minor unrelated bit:  the use-container action was between the 2nd
and 3rd polymorph cases.  Move it, after the third one.

src/muse.c

index 4a268ddb613e9928dbc4e84056fa50dd1fade9e0..2c8e8f456b532cd72d79948a0919fcf7169ecf41 100644 (file)
@@ -2048,10 +2048,11 @@ DISABLE_WARNING_UNREACHABLE_CODE
 int
 use_misc(struct monst* mtmp)
 {
+    char nambuf[BUFSZ];
+    boolean vis, vismon, vistrapspot, oseen;
     int i;
+    struct trap *t;
     struct obj *otmp = g.m.misc;
-    boolean vis, vismon, oseen;
-    char nambuf[BUFSZ];
 
     if ((i = precheck(mtmp, otmp)) != 0)
         return i;
@@ -2159,17 +2160,28 @@ use_misc(struct monst* mtmp)
         if (oseen)
             makeknown(POT_POLYMORPH);
         return 2;
-    case MUSE_BAG:
-        return mloot_container(mtmp, otmp, vismon);
     case MUSE_POLY_TRAP:
-        if (vismon) {
+        t = t_at(g.trapx, g.trapy);
+        vistrapspot = cansee(t->tx, t->ty);
+        if (vis || vistrapspot)
+            seetrap(t);
+        if (vismon || vistrapspot) {
             const char *Mnam = Monnam(mtmp);
 
-            pline("%s deliberately %s onto a polymorph trap!", Mnam,
-                  vtense(fakename[0], locomotion(mtmp->data, "jump")));
+            /* when the trap is seen but the monster isn't, Monnam()
+               will yield "It"; change that to "Someone" or "Something";
+               the canspotmon() check is to avoid making the change if
+               mtmp has been explicitly named "It" */
+            if (!strcmp(Mnam, "It") && !canspotmon(mtmp))
+                Mnam = humanoid(mtmp->data) ? "Someone" : "Something";
+            pline("%s deliberately %s onto a %s trap!", Mnam,
+                  vtense(fakename[0], locomotion(mtmp->data, "jump")),
+                  t->tseen ? "polymorph" : "hidden");
+            /* note: if mtmp is unseen because it is invisible, its new
+               shape will also be invisible and could produce "Its armor
+               falls off" messages during the transformation; those make
+               more sense after we've given "Someone jumps onto a trap." */
         }
-        if (vis)
-            seetrap(t_at(g.trapx, g.trapy));
 
         /*  don't use rloc() due to worms */
         remove_monster(mtmp->mx, mtmp->my);
@@ -2181,6 +2193,8 @@ use_misc(struct monst* mtmp)
 
         (void) newcham(mtmp, (struct permonst *) 0, FALSE, FALSE);
         return 2;
+    case MUSE_BAG:
+        return mloot_container(mtmp, otmp, vismon);
     case MUSE_BULLWHIP:
         /* attempt to disarm hero */
         {