From: Pasi Kallinen Date: Sat, 4 Mar 2023 17:06:13 +0000 (+0200) Subject: Spell of knock can knock back small monsters X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce0d25129efc7d8fa994466e29db5916ac9d8074;p=nethack Spell of knock can knock back small monsters Differentiates the spell from the wand of opening, and the spell name sounds like it should do that ... --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index ceada7cf0..427fbbc5d 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/include/extern.h b/include/extern.h index 743967d24..99ebfb42f 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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, diff --git a/src/uhitm.c b/src/uhitm.c index d79c7bdcd..7c65267a1 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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); diff --git a/src/zap.c b/src/zap.c index 259940189..22b1581ff 100644 --- 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 {