]> granicus.if.org Git - nethack/commitdiff
fix github issue #614 - applying polearm at doors
authorPatR <rankin@nethack.org>
Sun, 24 Oct 2021 17:06:30 +0000 (10:06 -0700)
committerPatR <rankin@nethack.org>
Sun, 24 Oct 2021 17:06:30 +0000 (10:06 -0700)
Reported by G7Nation; attacking walls and such with a polearm just
gave lackluster "you miss; nobody's there" feedback.

Make applying a polearm at some non-monster locations give feedback
similar to using 'F'orcefight with melee weapons.  Was
|You miss; there is no one there to hit.
now
|You uselessly attack the closed door.

Also, extend the supported locations to include dungeon furniture.
Was
|You attack thin air. ('F')
now
|You harmlessly attack the throne. ('F')
|You uselessly attack the throne. ('a')

This doesn't address #613:  attempting to hit non-visible locations
with an applied polearm.

Closes #614

doc/fixes37.0
src/apply.c
src/hack.c

index fb630797617baf94e7e0d81d9f77f3a645a02c61..07329f960b6b622742c33473287f528e820203b1 100644 (file)
@@ -658,6 +658,8 @@ melting ice timer could persist after the ice was gone from digging or from an
 using 'F'orcefight against iron bars while wielding something breakable could
        yield erratic outcome because non-deterministic breaktest() was being
        called twice and could yield results that conflicted
+have applying a polearm give feedback similar to 'F' for melee weapon when
+       attacking a wall or boulder
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 24f8d67ad0963a94287700d3fce883bf08e1a07b..98794aff77d00102c4f4bfd3c3a1f27e678973b5 100644 (file)
@@ -3054,6 +3054,7 @@ display_polearm_positions(int state)
 static int
 use_pole(struct obj *obj)
 {
+    const char thump[] = "Thump!  Your blow bounces harmlessly off the %s.";
     int res = 0, typ, max_range, min_range, glyph;
     coord cc;
     struct monst *mtmp;
@@ -3067,8 +3068,7 @@ use_pole(struct obj *obj)
     if (obj != uwep) {
         if (!wield_tool(obj, "swing"))
             return 0;
-        else
-            res = 1;
+        res = 1;
     }
     /* assert(obj == uwep); */
 
@@ -3158,13 +3158,31 @@ use_pole(struct obj *obj)
                Note:  we only do this when a statue is displayed here,
                because the player is probably attempting to attack it;
                other statues obscured by anything are just ignored. */
-            pline("Thump!  Your blow bounces harmlessly off the statue.");
+            pline(thump, "statue");
             wake_nearto(g.bhitpos.x, g.bhitpos.y, 25);
         }
     } else {
         /* no monster here and no statue seen or remembered here */
         (void) unmap_invisible(g.bhitpos.x, g.bhitpos.y);
-        You("miss; there is no one there to hit.");
+
+        if (glyph_to_obj(glyph) == BOULDER
+            && sobj_at(BOULDER, g.bhitpos.x, g.bhitpos.y)) {
+            pline(thump, "boulder");
+            wake_nearto(g.bhitpos.x, g.bhitpos.y, 25);
+        } else if (!accessible(g.bhitpos.x, g.bhitpos.y)
+                   || IS_FURNITURE(levl[g.bhitpos.x][g.bhitpos.y].typ)) {
+            /* similar to 'F'orcefight with a melee weapon; we know that
+               the spot can be seen or we wouldn't have gotten this far */
+            You("uselessly attack %s.",
+                (levl[g.bhitpos.x][g.bhitpos.y].typ == STONE
+                 || levl[g.bhitpos.x][g.bhitpos.y].typ == SCORR)
+                ? "stone"
+                : glyph_is_cmap(glyph)
+                  ? the(defsyms[glyph_to_cmap(glyph)].explanation)
+                  : (const char *) "an unknown obstacle");
+        } else {
+            You("miss; there is no one there to hit.");
+        }
     }
     u_wipe_engr(2); /* same as for melee or throwing */
     return 1;
index 410c69d0c15b6256d3421d1635ea43c4bb0192a6..fb04501e0445271fd29d081670edbcb768ecfa40 100644 (file)
@@ -1815,7 +1815,7 @@ domove_core(void)
         || (glyph_is_invisible(glyph) && !g.context.nopick)) {
         struct obj *boulder = 0;
         boolean explo = (Upolyd && attacktype(g.youmonst.data, AT_EXPL)),
-                solid = !accessible(x, y);
+                solid = (!accessible(x, y) || IS_FURNITURE(levl[x][y].typ));
         char buf[BUFSZ];
 
         if (!Underwater) {
@@ -1859,15 +1859,17 @@ domove_core(void)
                          : "nothing");
         } else if (solid) {
             /* glyph might indicate unseen terrain if hero is blind;
-               unlike searching, this won't reveal what that terrain is
-               (except for solid rock, where the glyph would otherwise
-               yield ludicrous "dark part of a room") */
-            Strcpy(buf, (levl[x][y].typ == STONE) ? "solid rock"
+               unlike searching, this won't reveal what that terrain is;
+               3.7: used to say "solid rock" for the stone case, but that
+               made it be different from unmapped walls outside of rooms */
+            Strcpy(buf, (levl[x][y].typ == STONE || levl[x][y].typ == SCORR)
+                         ? "stone"
                          : glyph_is_cmap(glyph)
                             ? the(defsyms[glyph_to_cmap(glyph)].explanation)
                             : (const char *) "an unknown obstacle");
             /* note: 'solid' is misleadingly named and catches pools
-               of water and lava as well as rock and walls */
+               of water and lava as well as rock and walls;
+               3.7: furniture too */
         } else {
             Strcpy(buf, "thin air");
         }