]> granicus.if.org Git - nethack/commitdiff
more PR #906 - steadfastness
authorPatR <rankin@nethack.org>
Mon, 24 Oct 2022 17:32:17 +0000 (10:32 -0700)
committerPatR <rankin@nethack.org>
Mon, 24 Oct 2022 17:32:17 +0000 (10:32 -0700)
If someone gets hit for a knockback effect but resists it due to
wielding Giantslayer or carrying a loadstone, give feedback saying
so, otherwise the lack of knockback is indistinguishable from an
ordinary hit.

The message is not likely to appear for non-hero target since that
target needs to have special equipment.  A hero wielding Giantslayer
might see it enough for the player to become annoyed; if so,
MSGTYPE=hide could be used to suppress it.

src/uhitm.c

index 2180dfd13147dfc545f6db76b94d0b9bdc9d4a80..b34797dbff75bbd9e8375b528c0c084b2dba9c33 100644 (file)
@@ -4625,10 +4625,14 @@ m_is_steadfast(struct monst *mtmp)
     if (is_art(otmp, ART_GIANTSLAYER))
         return TRUE;
 
-    /* steadfast if carrying any loadstone (and not floating or flying) */
+    /* steadfast if carrying any loadstone (and not floating or flying);
+       when mounted and steed is target of knockback, check the rider
+       for a loadstone too */
     for (otmp = is_u ? g.invent : mtmp->minvent; otmp; otmp = otmp->nobj)
         if (otmp->otyp == LOADSTONE)
             return TRUE;
+    if (u.usteed && mtmp == u.usteed && carrying(LOADSTONE))
+        return TRUE;
 
     return FALSE;
 }
@@ -4642,6 +4646,7 @@ mhitm_knockback(
     int *hitflags,        /* modified if magr or mdef dies */
     boolean weapon_used)  /* True: via weapon hit */
 {
+    char magrbuf[BUFSZ], mdefbuf[BUFSZ];
     struct obj *otmp;
     boolean u_agr = (magr == &g.youmonst);
     boolean u_def = (mdef == &g.youmonst);
@@ -4686,12 +4691,21 @@ mhitm_knockback(
         return FALSE;
 
     /* steadfast defender cannot be pushed around */
-    if (m_is_steadfast(mdef))
+    if (m_is_steadfast(mdef)) {
+        if (u_def || (u.usteed && mdef == u.usteed)) {
+            mdefbuf[0] = '\0';
+            if (u.usteed)
+                Snprintf(mdefbuf, sizeof mdefbuf, "and %s ",
+                         y_monnam(u.usteed));
+            You("%sdon't budge.", mdefbuf);
+        } else if (canseemon(mdef)) {
+            pline("%s doesn't budge.", Monnam(mdef));
+        }
         return FALSE;
+    }
 
     /* give the message */
     if (u_def || canseemon(mdef)) {
-        char magrbuf[BUFSZ], mdefbuf[BUFSZ];
         boolean dosteed = u_def && u.usteed;
 
         Strcpy(magrbuf, u_agr ? "You" : Monnam(magr));