From: Pasi Kallinen Date: Mon, 30 Nov 2020 20:55:26 +0000 (+0200) Subject: Unify ad_conf X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fda63d145b08425f14f4701210d1f913fd94c17c;p=nethack Unify ad_conf --- diff --git a/include/extern.h b/include/extern.h index 414e1d0f8..28292037c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2778,6 +2778,7 @@ E void FDECL(mhitm_ad_slee, (struct monst *, struct attack *, struct monst *, st E void FDECL(mhitm_ad_slim, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_ench, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_slow, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); +E void FDECL(mhitm_ad_conf, (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 ffb11fe1f..88a29c9a2 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1096,16 +1096,9 @@ int dieroll; return mhm.hitflags; break; case AD_CONF: - /* Since confusing another monster doesn't have a real time - * limit, setting spec_used would not really be right (though - * we still should check for it). - */ - if (!magr->mcan && !mdef->mconf && !magr->mspec_used) { - if (g.vis && canseemon(mdef)) - pline("%s looks confused.", Monnam(mdef)); - mdef->mconf = 1; - mdef->mstrategy &= ~STRAT_WAITFORU; - } + mhitm_ad_conf(magr, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_BLND: mhitm_ad_blnd(magr, mattk, mdef, &mhm); diff --git a/src/mhitu.c b/src/mhitu.c index dcee2988d..4213609b4 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1419,16 +1419,9 @@ register struct attack *mattk; return mhm.hitflags; break; case AD_CONF: - hitmsg(mtmp, mattk); - if (!mtmp->mcan && !rn2(4) && !mtmp->mspec_used) { - mtmp->mspec_used = mtmp->mspec_used + (mhm.damage + rn2(6)); - if (Confusion) - You("are getting even more confused."); - else - You("are getting confused."); - make_confused(HConfusion + mhm.damage, FALSE); - } - mhm.damage = 0; + mhitm_ad_conf(mtmp, mattk, &g.youmonst, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_DETH: pline("%s reaches out with its deadly touch.", Monnam(mtmp)); diff --git a/src/uhitm.c b/src/uhitm.c index 16bf66c34..2d745667e 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -3139,6 +3139,48 @@ struct mhitm_data *mhm; } } +void +mhitm_ad_conf(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 */ + if (!mdef->mconf) { + if (canseemon(mdef)) + pline("%s looks confused.", Monnam(mdef)); + mdef->mconf = 1; + } + } else if (mdef == &g.youmonst) { + /* mhitu */ + hitmsg(magr, mattk); + if (!magr->mcan && !rn2(4) && !magr->mspec_used) { + magr->mspec_used = magr->mspec_used + (mhm->damage + rn2(6)); + if (Confusion) + You("are getting even more confused."); + else + You("are getting confused."); + make_confused(HConfusion + mhm->damage, FALSE); + } + mhm->damage = 0; + } else { + /* mhitm */ + /* Since confusing another monster doesn't have a real time + * limit, setting spec_used would not really be right (though + * we still should check for it). + */ + if (!magr->mcan && !mdef->mconf && !magr->mspec_used) { + if (g.vis && canseemon(mdef)) + pline("%s looks confused.", Monnam(mdef)); + mdef->mconf = 1; + mdef->mstrategy &= ~STRAT_WAITFORU; + } + } +} /* Template for monster hits monster for AD_FOO. - replace "break" with return @@ -3372,11 +3414,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */ return mhm.hitflags; break; case AD_CONF: - if (!mdef->mconf) { - if (canseemon(mdef)) - pline("%s looks confused.", Monnam(mdef)); - mdef->mconf = 1; - } + mhitm_ad_conf(&g.youmonst, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_POLY: if (!negated && mhm.damage < mdef->mhp)