From: Pasi Kallinen Date: Tue, 1 Dec 2020 08:51:19 +0000 (+0200) Subject: Unify ad_were X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4901c8027c88cd94f0e10f3747dc4424a16640c3;p=nethack Unify ad_were --- diff --git a/include/extern.h b/include/extern.h index 4de281ec0..70d8298d9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2787,6 +2787,7 @@ E void FDECL(mhitm_ad_deth, (struct monst *, struct attack *, struct monst *, st E void FDECL(mhitm_ad_halu, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_phys, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_ston, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); +E void FDECL(mhitm_ad_were, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E boolean FDECL(do_stone_u, (struct monst *)); E void FDECL(do_stone_mon, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E int FDECL(damageum, (struct monst *, struct attack *, int)); diff --git a/src/mhitm.c b/src/mhitm.c index 236e4d83a..b743a2fe3 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -964,6 +964,10 @@ int dieroll; } goto physical; case AD_WERE: + mhitm_ad_were(magr, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; + break; case AD_HEAL: case AD_PHYS: physical: diff --git a/src/mhitu.c b/src/mhitu.c index a08ce6ce7..8000454e3 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1129,14 +1129,9 @@ register struct attack *mattk; return mhm.hitflags; break; case AD_WERE: - hitmsg(mtmp, mattk); - if (uncancelled && !rn2(4) && u.ulycn == NON_PM - && !Protection_from_shape_changers && !defends(AD_WERE, uwep)) { - You_feel("feverish."); - exercise(A_CON, FALSE); - set_ulycn(monsndx(mdat)); - retouch_equipment(2); - } + mhitm_ad_were(mtmp, mattk, &g.youmonst, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_SGLD: mhitm_ad_sgld(mtmp, mattk, &g.youmonst, &mhm); diff --git a/src/uhitm.c b/src/uhitm.c index e0d1d30d0..d4281ac2f 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -3644,6 +3644,42 @@ struct mhitm_data *mhm; } } +void +mhitm_ad_were(magr, mattk, mdef, mhm) +struct monst *magr; +struct attack *mattk; +struct monst *mdef; +struct mhitm_data *mhm; +{ + struct permonst *pa = magr->data; + struct permonst *pd = mdef->data; + + if (magr == &g.youmonst) { + /* uhitm */ + mhitm_ad_phys(&g.youmonst, mattk, mdef, mhm); + if (mhm->done) + return; + } else if (mdef == &g.youmonst) { + /* mhitu */ + int armpro = magic_negation(mdef); + boolean uncancelled = !magr->mcan && (rn2(10) >= 3 * armpro); + + hitmsg(magr, mattk); + if (uncancelled && !rn2(4) && u.ulycn == NON_PM + && !Protection_from_shape_changers && !defends(AD_WERE, uwep)) { + You_feel("feverish."); + exercise(A_CON, FALSE); + set_ulycn(monsndx(pa)); + retouch_equipment(2); + } + } else { + /* mhitm */ + mhitm_ad_phys(&g.youmonst, mattk, mdef, mhm); + if (mhm->done) + return; + } +} + /* Template for monster hits monster for AD_FOO. - replace "break" with return - replace "return" with mhm->done = TRUE @@ -3719,7 +3755,11 @@ int specialdmg; /* blessed and/or silver bonus against various things */ } #endif goto physical; - case AD_WERE: /* no special effect on monsters */ + case AD_WERE: + mhitm_ad_were(&g.youmonst, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; + break; case AD_HEAL: /* likewise */ case AD_PHYS: physical: