Unify ad_poly
This commit is contained in:
@@ -2779,6 +2779,7 @@ E void FDECL(mhitm_ad_slim, (struct monst *, struct attack *, struct monst *, st
|
||||
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 void FDECL(mhitm_ad_poly, (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,
|
||||
|
||||
@@ -1224,8 +1224,9 @@ int dieroll;
|
||||
return mhm.hitflags;
|
||||
break;
|
||||
case AD_POLY:
|
||||
if (!magr->mcan && mhm.damage < mdef->mhp)
|
||||
mhm.damage = mon_poly(magr, mdef, mhm.damage);
|
||||
mhitm_ad_poly(magr, mattk, mdef, &mhm);
|
||||
if (mhm.done)
|
||||
return mhm.hitflags;
|
||||
break;
|
||||
default:
|
||||
mhm.damage = 0;
|
||||
|
||||
@@ -1480,8 +1480,9 @@ register struct attack *mattk;
|
||||
return mhm.hitflags;
|
||||
break;
|
||||
case AD_POLY:
|
||||
if (uncancelled && Maybe_Half_Phys(mhm.damage) < (Upolyd ? u.mh : u.uhp))
|
||||
mhm.damage = mon_poly(mtmp, &g.youmonst, mhm.damage);
|
||||
mhitm_ad_poly(mtmp, mattk, &g.youmonst, &mhm);
|
||||
if (mhm.done)
|
||||
return mhm.hitflags;
|
||||
break;
|
||||
default:
|
||||
mhm.damage = 0;
|
||||
|
||||
39
src/uhitm.c
39
src/uhitm.c
@@ -3182,6 +3182,40 @@ struct mhitm_data *mhm;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mhitm_ad_poly(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 && mhm->damage < mdef->mhp)
|
||||
mhm->damage = mon_poly(magr, mdef, mhm->damage);
|
||||
} else if (mdef == &g.youmonst) {
|
||||
/* mhitu */
|
||||
int armpro = magic_negation(mdef);
|
||||
boolean uncancelled = !magr->mcan && (rn2(10) >= 3 * armpro);
|
||||
|
||||
if (uncancelled && Maybe_Half_Phys(mhm->damage) < (Upolyd ? u.mh : u.uhp))
|
||||
mhm->damage = mon_poly(magr, mdef, mhm->damage);
|
||||
} else {
|
||||
/* mhitm */
|
||||
int armpro = magic_negation(mdef);
|
||||
boolean cancelled = magr->mcan || !(rn2(10) >= 3 * armpro);
|
||||
|
||||
if (!magr->mcan && mhm->damage < mdef->mhp)
|
||||
mhm->damage = mon_poly(magr, mdef, mhm->damage);
|
||||
}
|
||||
}
|
||||
|
||||
/* Template for monster hits monster for AD_FOO.
|
||||
- replace "break" with return
|
||||
- replace "return" with mhm->done = TRUE
|
||||
@@ -3419,8 +3453,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */
|
||||
return mhm.hitflags;
|
||||
break;
|
||||
case AD_POLY:
|
||||
if (!negated && mhm.damage < mdef->mhp)
|
||||
mhm.damage = mon_poly(&g.youmonst, mdef, mhm.damage);
|
||||
mhitm_ad_poly(&g.youmonst, mattk, mdef, &mhm);
|
||||
if (mhm.done)
|
||||
return mhm.hitflags;
|
||||
break;
|
||||
default:
|
||||
mhm.damage = 0;
|
||||
|
||||
Reference in New Issue
Block a user