]> granicus.if.org Git - nethack/commitdiff
tweak #wizkill
authorPatR <rankin@nethack.org>
Sun, 22 May 2022 07:21:58 +0000 (00:21 -0700)
committerPatR <rankin@nethack.org>
Sun, 22 May 2022 07:21:58 +0000 (00:21 -0700)
When using 'm #wizkill' to kill monster(s) off without giving the
hero any credit or blame, temporarily force context.mon_moving On
so that collateral damage (other monsters killed by targetted gas
spore's explosion) also don't give the hero any credit or blame.

Make sure that some message identifying the monster is given when
targetted monster is killed even if hero can't see or sense it.

src/cmd.c

index 2c203b435c34781c3a564a88f77e89b4dac2161e..b74e3a34805973c52f6e061b4bcc5c4662ac4cca 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1203,12 +1203,33 @@ wiz_kill(void)
         }
 
         if (mtmp) {
-            /* we don't require that monster be seen or sensed but when it
-               isn't, death message will be "You kill it" or "It is killed" */
-            if (!iflags.menu_requested)
-                killed(mtmp); /* normal case: hero is credited/blamed */
-            else
-                monkilled(mtmp, "", AD_PHYS); /* 'm'-prefix */
+            /* we don't require that the monster be seen or sensed so
+               we issue our own message in order to name it in case it
+               isn't; note that if it triggers other kills, those might
+               be referred to as "it" */
+            if (!iflags.menu_requested) {
+                boolean namedpet = has_mgivenname(mtmp) && !Hallucination;
+
+                /* normal case: hero is credited/blamed */
+                You("%s %s!", nonliving(mtmp->data) ? "destroy" : "kill",
+                    !mtmp->mtame ? noit_mon_nam(mtmp)
+                    : x_monnam(mtmp, ARTICLE_YOUR, "poor",
+                               SUPPRESS_IT | (namedpet ? SUPPRESS_SADDLE : 0),
+                               FALSE));
+                xkilled(mtmp, XKILL_NOMSG);
+            } else { /* 'm'-prefix */
+                /* we know that monsters aren't moving because player has
+                   just issued this #wizkill command, but if 'mtmp' is a
+                   gas spore whose explosion kills any other monsters we
+                   need to have the mon_moving flag be True in order to
+                   avoid blaming or crediting hero for their deaths */
+                g.context.mon_moving = TRUE;
+                pline("%s is %s.", noit_Monnam(mtmp),
+                      nonliving(mtmp->data) ? "destroyed" : "killed");
+                /* Null second arg suppresses message */
+                monkilled(mtmp, (char *) 0, AD_PHYS);
+                g.context.mon_moving = FALSE;
+            }
         } else {
             There("is no monster there.");
             break;