Unify ad_conf

This commit is contained in:
Pasi Kallinen
2020-11-30 22:55:26 +02:00
parent 558ec78b3a
commit fda63d145b
4 changed files with 52 additions and 25 deletions

View File

@@ -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,

View File

@@ -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);

View File

@@ -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));

View File

@@ -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)