Unify ad_stun

This commit is contained in:
Pasi Kallinen
2020-12-01 11:05:14 +02:00
parent 12ee144936
commit 337e7da049
4 changed files with 51 additions and 17 deletions

View File

@@ -2789,6 +2789,7 @@ E void FDECL(mhitm_ad_phys, (struct monst *, struct attack *, struct monst *, st
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 void FDECL(mhitm_ad_heal, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_stun, (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));

View File

@@ -950,13 +950,10 @@ int dieroll;
}
break;
case AD_STUN:
if (magr->mcan)
break;
if (canseemon(mdef))
pline("%s %s for a moment.", Monnam(mdef),
makeplural(stagger(pd, "stagger")));
mdef->mstun = 1;
goto physical;
mhitm_ad_stun(magr, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_LEGS:
if (magr->mcan) {
mhm.damage = 0;

View File

@@ -1239,11 +1239,9 @@ register struct attack *mattk;
return mhm.hitflags;
break;
case AD_STUN:
hitmsg(mtmp, mattk);
if (!mtmp->mcan && !rn2(4)) {
make_stunned((HStun & TIMEOUT) + (long) mhm.damage, TRUE);
mhm.damage /= 2;
}
mhitm_ad_stun(mtmp, mattk, &g.youmonst, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_ACID:
mhitm_ad_acid(mtmp, mattk, &g.youmonst, &mhm);

View File

@@ -3771,6 +3771,45 @@ struct mhitm_data *mhm;
}
}
void
mhitm_ad_stun(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 (!Blind)
pline("%s %s for a moment.", Monnam(mdef),
makeplural(stagger(pd, "stagger")));
mdef->mstun = 1;
mhitm_ad_phys(magr, mattk, mdef, mhm);
if (mhm->done)
return;
} else if (mdef == &g.youmonst) {
/* mhitu */
hitmsg(magr, mattk);
if (!magr->mcan && !rn2(4)) {
make_stunned((HStun & TIMEOUT) + (long) mhm->damage, TRUE);
mhm->damage /= 2;
}
} else {
/* mhitm */
if (magr->mcan)
return;
if (canseemon(mdef))
pline("%s %s for a moment.", Monnam(mdef),
makeplural(stagger(pd, "stagger")));
mdef->mstun = 1;
mhitm_ad_phys(magr, 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
@@ -3833,11 +3872,10 @@ int specialdmg; /* blessed and/or silver bonus against various things */
}
switch (mattk->adtyp) {
case AD_STUN:
if (!Blind)
pline("%s %s for a moment.", Monnam(mdef),
makeplural(stagger(pd, "stagger")));
mdef->mstun = 1;
goto physical;
mhitm_ad_stun(&g.youmonst, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_LEGS:
#if 0
if (u.ucancelled) {