From: PatR Date: Thu, 3 Mar 2016 08:07:57 +0000 (-0800) Subject: fix #H4262 - mon weapon attacks for non-weapon dmg X-Git-Tag: NetHack-3.6.1_RC01~890 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db9dddc535347c372d28d8a5a3e23442950a47e8;p=nethack fix #H4262 - mon weapon attacks for non-weapon dmg Let monsters who have a weapon attack for non-physical damage dish out physical damage instead of doing the drain life or drain strength they usually do if they happen to be wielding cockatrice corpses or a couple of particular aritfacts that do more harm than just level drain. (Other artifacts are candidates, but I don't think it's worth checking for them since the monsters involved have such a small chance of acquiring and wielding them.) Also switch to physical if monster's ability has been cancelled. Only barrow wight, Nazgul, and erinys are affected. Yeenoghu and the Master Assassin have a weapon attack for physical damage and another one for non-physical damage (not necessarily delivered in that order). They haven't been changed--only the physical damage attack has a chance to apply their weapon's special damage. --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 2f3314620..02618470f 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -172,6 +172,9 @@ if a long worm inherited inventory from a previous shape, and if an egg or Wizard will now steal any quest artifact from hero, not just own role's prevent a hostile renegade Angel of from delivering taunt messages which mention threats of retribution from that god +a few types of monster (barrow wight, Nazgul, erinys) have weapon attacks that + don't deal physical damage, so special damage like stoning via wielded + cockatrice corpse wouldn't be inflicted Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index 34d200bba..4277d3b63 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1456528594 2016/02/26 23:16:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.549 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1456992437 2016/03/03 08:07:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.550 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1136,8 +1136,8 @@ E const char *FDECL(mpoisons_subj, (struct monst *, struct attack *)); E void NDECL(u_slow_down); E struct monst *NDECL(cloneu); E void FDECL(expels, (struct monst *, struct permonst *, BOOLEAN_P)); -E struct attack *FDECL(getmattk, - (struct permonst *, int, int *, struct attack *)); +E struct attack *FDECL(getmattk, (struct monst *, struct monst *, + int, int *, struct attack *)); E int FDECL(mattacku, (struct monst *)); E int FDECL(magic_negation, (struct monst *)); E boolean NDECL(gulp_blnd_check); diff --git a/src/mhitm.c b/src/mhitm.c index 533527cca..b52c6f226 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhitm.c $NHDT-Date: 1446854229 2015/11/06 23:57:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.83 $ */ +/* NetHack 3.6 mhitm.c $NHDT-Date: 1456992461 2016/03/03 08:07:41 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.86 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -351,7 +351,7 @@ register struct monst *magr, *mdef; /* Now perform all attacks for the monster. */ for (i = 0; i < NATTK; i++) { res[i] = MM_MISS; - mattk = getmattk(pa, i, res, &alt_attk); + mattk = getmattk(magr, mdef, i, res, &alt_attk); otmp = (struct obj *) 0; attk = 1; switch (mattk->aatyp) { diff --git a/src/mhitu.c b/src/mhitu.c index 872ef8a17..f7f0afde2 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhitu.c $NHDT-Date: 1456618997 2016/02/28 00:23:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.135 $ */ +/* NetHack 3.6 mhitu.c $NHDT-Date: 1456992469 2016/03/03 08:07:49 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.136 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -256,12 +256,14 @@ boolean message; /* select a monster's next attack, possibly substituting for its usual one */ struct attack * -getmattk(mptr, indx, prev_result, alt_attk_buf) -struct permonst *mptr; +getmattk(magr, mdef, indx, prev_result, alt_attk_buf) +struct monst *magr, *mdef; int indx, prev_result[]; struct attack *alt_attk_buf; { + struct permonst *mptr = magr->data; struct attack *attk = &mptr->mattk[indx]; + struct obj *weap = (magr == &youmonst) ? uwep : MON_WEP(magr); /* prevent a monster with two consecutive disease or hunger attacks from hitting with both of them on the same turn; if the first has @@ -275,7 +277,7 @@ struct attack *alt_attk_buf; attk->adtyp = AD_STUN; /* make drain-energy damage be somewhat in proportion to energy */ - } else if (attk->adtyp == AD_DREN) { + } else if (attk->adtyp == AD_DREN && mdef == &youmonst) { int ulev = max(u.ulevel, 6); *alt_attk_buf = *attk; @@ -293,6 +295,25 @@ struct attack *alt_attk_buf; attk->damd += 3; /* very high energy: 3d6 -> 3d9 */ /* note: 3d9 is slightly higher than previous 4d6 */ } + + /* barrow wight, Nazgul, erinys have weapon attack for non-physical + damage; force physical damage if attacker has been cancelled or + if weapon is sufficiently interesting; a few unique creatures + have two weapon attacks where one does physical damage and other + doesn't--avoid forcing physical damage for those */ + } else if (indx == 0 && magr != &youmonst + && attk->aatyp == AT_WEAP && attk->adtyp != AD_PHYS + && !(mptr->mattk[1].aatyp == AT_WEAP + && mptr->mattk[1].adtyp == AD_PHYS) + && (magr->mcan + || (weap + && ((weap->otyp == CORPSE + && touch_petrifies(&mons[weap->corpsenm])) + || weap->oartifact == ART_STORMBRINGER + || weap->oartifact == ART_VORPAL_BLADE)))) { + *alt_attk_buf = *attk; + attk = alt_attk_buf; + attk->adtyp = AD_PHYS; } return attk; } @@ -608,7 +629,7 @@ register struct monst *mtmp; for (i = 0; i < NATTK; i++) { sum[i] = 0; - mattk = getmattk(mdat, i, sum, &alt_attk); + mattk = getmattk(mtmp, &youmonst, i, sum, &alt_attk); if ((u.uswallow && mattk->aatyp != AT_ENGL) || (skipnonmagc && mattk->aatyp != AT_MAGC)) continue; @@ -1373,9 +1394,10 @@ register struct attack *mattk; hitmsg(mtmp, mattk); break; } - if (!uwep && !uarmu && !uarm && !uarmh && !uarms && !uarmg && !uarmc - && !uarmf) { + if (!uwep && !uarmu && !uarm && !uarmc + && !uarms && !uarmg && !uarmf && !uarmh) { boolean goaway = FALSE; + pline("%s hits! (I hope you don't mind.)", Monnam(mtmp)); if (Upolyd) { u.mh += rnd(7); diff --git a/src/uhitm.c b/src/uhitm.c index a35802029..1b3bb84ea 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 uhitm.c $NHDT-Date: 1454664302 2016/02/05 09:25:02 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.154 $ */ +/* NetHack 3.6 uhitm.c $NHDT-Date: 1456992470 2016/03/03 08:07:50 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.155 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2085,7 +2085,7 @@ register struct monst *mon; for (i = 0; i < NATTK; i++) { sum[i] = 0; - mattk = getmattk(youmonst.data, i, sum, &alt_attk); + mattk = getmattk(&youmonst, mon, i, sum, &alt_attk); switch (mattk->aatyp) { case AT_WEAP: use_weapon: