]> granicus.if.org Git - nethack/commitdiff
Spell of knock can knock back small monsters
authorPasi Kallinen <paxed@alt.org>
Sat, 4 Mar 2023 17:06:13 +0000 (19:06 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 4 Mar 2023 17:07:34 +0000 (19:07 +0200)
Differentiates the spell from the wand of opening,
and the spell name sounds like it should do that ...

doc/fixes3-7-0.txt
include/extern.h
src/uhitm.c
src/zap.c

index ceada7cf01cde0b1d62b29ffc79e16878ff12ac6..427fbbc5d866b3cf804fbb1136a0de7e415a25a7 100644 (file)
@@ -1116,6 +1116,7 @@ feedback if a named, shape-shifted vampire reverted to original shape rather
        than dying when engulfed could say "Dracula turns into Dracula"
 adjust archeologist and valkyrie starting intrinsics
 once per game if receiving killing blow from near-full hp, leave 1 hp
+spell of knock can knock back small monsters
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 743967d2486f64c320a57607b460f7790da810e5..99ebfb42f185cc75b1e2d3a1195e9fa6a5ef18ee 100644 (file)
@@ -3031,6 +3031,7 @@ extern void do_stone_mon(struct monst *, struct attack *, struct monst *,
 extern int damageum(struct monst *, struct attack *, int);
 extern int explum(struct monst *, struct attack *);
 extern void missum(struct monst *, struct attack *, boolean);
+extern boolean m_is_steadfast(struct monst *);
 extern boolean mhitm_knockback(struct monst *, struct monst *,struct attack *,
                                int *, boolean);
 extern int passive(struct monst *, struct obj *, boolean, boolean, uchar,
index d79c7bdcd8bb813521a9db2c90a3ca81bf51017d..7c65267a13ad78c3679145cfd1f8fbdb3f6712a7 100644 (file)
@@ -52,7 +52,6 @@ static boolean m_slips_free(struct monst *, struct attack *);
 static void start_engulf(struct monst *);
 static void end_engulf(void);
 static int gulpum(struct monst *, struct attack *);
-static boolean m_is_steadfast(struct monst *);
 static boolean hmonas(struct monst *);
 static void nohandglow(struct monst *);
 static boolean mhurtle_to_doom(struct monst *, int, struct permonst **);
@@ -4803,7 +4802,7 @@ missum(
 }
 
 /* check whether equipment protects against knockback */
-static boolean
+boolean
 m_is_steadfast(struct monst *mtmp)
 {
     boolean is_u = (mtmp == &gy.youmonst);
index 259940189f7a49d61c3f68a14a2e3484129aa1ef..22b1581ffa5ea850edc3b20aa1b88030868f2488 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -132,6 +132,7 @@ learnwand(struct obj *obj)
 int
 bhitm(struct monst *mtmp, struct obj *otmp)
 {
+    int ret = 0;
     boolean wake = TRUE; /* Most 'zaps' should wake monster */
     boolean reveal_invis = FALSE, learn_it = FALSE;
     boolean dbldam = Role_if(PM_KNIGHT) && u.uhave.questart;
@@ -344,6 +345,22 @@ bhitm(struct monst *mtmp, struct obj *otmp)
         } else if (openfallingtrap(mtmp, TRUE, &learn_it)) {
             /* mtmp might now be on the migrating monsters list */
             break;
+        } else if (otyp == SPE_KNOCK) {
+            wake = TRUE;
+            ret = 1;
+            if (mtmp->data->msize < MZ_HUMAN && !m_is_steadfast(mtmp)) {
+                if (canseemon(mtmp))
+                    pline("%s is knocked back!",
+                          Monnam(mtmp));
+                mhurtle(mtmp, mtmp->mx - u.ux, mtmp->my - u.uy, rnd(2));
+            } else {
+                if (canseemon(mtmp))
+                    pline("%s doesn't budge.", Monnam(mtmp));
+            }
+            if (!DEADMONSTER(mtmp)) {
+                wakeup(mtmp, !mindless(mtmp->data));
+                abuse_dog(mtmp);
+            }
         } else if ((obj = which_armor(mtmp, W_SADDLE)) != 0) {
             char buf[BUFSZ];
 
@@ -478,7 +495,7 @@ bhitm(struct monst *mtmp, struct obj *otmp)
        that the wand itself has been seen */
     if (learn_it)
         learnwand(otmp);
-    return 0;
+    return ret;
 }
 
 /* hero is held by a monster or engulfed or holding a monster and has zapped
@@ -3458,6 +3475,8 @@ maybe_explode_trap(struct trap *ttmp, struct obj *otmp)
  *  This function reveals the absence of a remembered invisible monster in
  *  necessary cases (throwing or kicking weapons).  The presence of a real
  *  one is revealed for a weapon, but if not a weapon is left up to fhitm().
+ *
+ *  If fhitm returns non-zero value, stops the beam and returns the monster
  */
 struct monst *
 bhit(coordxy ddx, coordxy ddy, int range,  /* direction and range */
@@ -3673,7 +3692,10 @@ bhit(coordxy ddx, coordxy ddy, int range,  /* direction and range */
                 goto bhit_done;
             } else {
                 /* ZAPPED_WAND */
-                (*fhitm)(mtmp, obj);
+                if ((*fhitm)(mtmp, obj)) {
+                    result = mtmp;
+                    goto bhit_done;
+                }
                 range -= 3;
             }
         } else {