Unify ad_stck

This commit is contained in:
Pasi Kallinen
2020-11-30 22:00:35 +02:00
parent b4ed25da46
commit bfb8931188
4 changed files with 46 additions and 8 deletions

View File

@@ -2771,6 +2771,7 @@ E void FDECL(mhitm_ad_blnd, (struct monst *, struct attack *, struct monst *, st
E void FDECL(mhitm_ad_curs, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_drst, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_drin, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_stck, (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

@@ -1246,8 +1246,9 @@ int dieroll;
}
break;
case AD_STCK:
if (cancelled)
mhm.damage = 0;
mhitm_ad_stck(magr, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_WRAP: /* monsters cannot grab one another, it's too hard */
if (magr->mcan)

View File

@@ -1234,10 +1234,9 @@ register struct attack *mattk;
}
break;
case AD_STCK:
hitmsg(mtmp, mattk);
if (uncancelled && !u.ustuck && !sticks(g.youmonst.data)) {
set_ustuck(mtmp);
}
mhitm_ad_stck(mtmp, mattk, &g.youmonst, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_WRAP:
if ((!mtmp->mcan || u.ustuck == mtmp) && !sticks(g.youmonst.data)) {

View File

@@ -2739,6 +2739,42 @@ struct mhitm_data *mhm;
}
}
void
mhitm_ad_stck(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 */
int armpro = magic_negation(mdef);
/* since hero can't be cancelled, only defender's armor applies */
boolean negated = !(rn2(10) >= 3 * armpro);
if (!negated && !sticks(pd) && distu(mdef->mx, mdef->my) <= 2)
u.ustuck = mdef; /* it's now stuck to you */
} else if (mdef == &g.youmonst) {
/* mhitu */
int armpro = magic_negation(mdef);
boolean uncancelled = !magr->mcan && (rn2(10) >= 3 * armpro);
hitmsg(magr, mattk);
if (uncancelled && !u.ustuck && !sticks(pd)) {
set_ustuck(magr);
}
} else {
/* mhitm */
int armpro = magic_negation(mdef);
boolean cancelled = magr->mcan || !(rn2(10) >= 3 * armpro);
if (cancelled)
mhm->damage = 0;
}
}
/* Template for monster hits monster for AD_FOO.
- replace "break" with return
@@ -2927,8 +2963,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */
return mhm.hitflags;
break;
case AD_STCK:
if (!negated && !sticks(pd) && distu(mdef->mx, mdef->my) <= 2)
u.ustuck = mdef; /* it's now stuck to you */
mhitm_ad_stck(&g.youmonst, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_WRAP:
if (!sticks(pd)) {