From: Pasi Kallinen Date: Mon, 30 Nov 2020 21:28:13 +0000 (+0200) Subject: Unify ad_halu X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac5822fe69f83da0634fd6709f603ec66fe7b3ca;p=nethack Unify ad_halu --- diff --git a/include/extern.h b/include/extern.h index 6082a1537..4f4b9a2a3 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2784,6 +2784,7 @@ E void FDECL(mhitm_ad_poly, (struct monst *, struct attack *, struct monst *, st E void FDECL(mhitm_ad_famn, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_pest, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_deth, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); +E void FDECL(mhitm_ad_halu, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E int FDECL(damageum, (struct monst *, struct attack *, int)); E void FDECL(missum, (struct monst *, struct attack *, BOOLEAN_P)); E int FDECL(passive, (struct monst *, struct obj *, BOOLEAN_P, int, diff --git a/src/mhitm.c b/src/mhitm.c index 9d35199a6..9c9e89bec 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1107,14 +1107,9 @@ int dieroll; return mhm.hitflags; break; case AD_HALU: - if (!magr->mcan && haseyes(pd) && mdef->mcansee) { - if (g.vis && canseemon(mdef)) - pline("%s looks %sconfused.", Monnam(mdef), - mdef->mconf ? "more " : ""); - mdef->mconf = 1; - mdef->mstrategy &= ~STRAT_WAITFORU; - } - mhm.damage = 0; + mhitm_ad_halu(magr, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_CURS: mhitm_ad_curs(magr, mattk, mdef, &mhm); diff --git a/src/uhitm.c b/src/uhitm.c index 4f5ead337..3213c8ff5 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -3317,6 +3317,36 @@ struct mhitm_data *mhm; } } +void +mhitm_ad_halu(magr, mattk, mdef, mhm) +struct monst *magr; +struct attack *mattk; +struct monst *mdef; +struct mhitm_data *mhm; +{ + struct permonst *pd = mdef->data; + + if (magr == &g.youmonst) { + /* uhitm */ + mhm->damage = 0; + } else if (mdef == &g.youmonst) { + /* mhitu */ + mhm->damage = 0; + } else { + /* mhitm */ + int armpro = magic_negation(mdef); + boolean cancelled = magr->mcan || !(rn2(10) >= 3 * armpro); + + if (!magr->mcan && haseyes(pd) && mdef->mcansee) { + if (g.vis && canseemon(mdef)) + pline("%s looks %sconfused.", Monnam(mdef), + mdef->mconf ? "more " : ""); + mdef->mconf = 1; + mdef->mstrategy &= ~STRAT_WAITFORU; + } + mhm->damage = 0; + } +} /* Template for monster hits monster for AD_FOO. - replace "break" with return