Unify ad_ench

This commit is contained in:
Pasi Kallinen
2020-11-30 22:46:59 +02:00
parent 96a4d14a36
commit b80c30bcf1
4 changed files with 63 additions and 35 deletions

View File

@@ -2776,6 +2776,7 @@ E void FDECL(mhitm_ad_wrap, (struct monst *, struct attack *, struct monst *, st
E void FDECL(mhitm_ad_plys, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_slee, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
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 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

@@ -1231,8 +1231,9 @@ int dieroll;
return mhm.hitflags;
break;
case AD_ENCH:
/* there's no msomearmor() function, so just do damage */
/* if (cancelled) break; */
mhitm_ad_ench(magr, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_POLY:
if (!magr->mcan && mhm.damage < mdef->mhp)

View File

@@ -1482,36 +1482,9 @@ register struct attack *mattk;
return mhm.hitflags;
break;
case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
hitmsg(mtmp, mattk);
/* uncancelled is sufficient enough; please
don't make this attack less frequent */
if (uncancelled) {
struct obj *obj = some_armor(&g.youmonst);
if (!obj) {
/* some rings are susceptible;
amulets and blindfolds aren't (at present) */
switch (rn2(5)) {
case 0:
break;
case 1:
obj = uright;
break;
case 2:
obj = uleft;
break;
case 3:
obj = uamul;
break;
case 4:
obj = ublindf;
break;
}
}
if (drain_item(obj, FALSE)) {
pline("%s less effective.", Yobjnam2(obj, "seem"));
}
}
mhitm_ad_ench(mtmp, mattk, &g.youmonst, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_POLY:
if (uncancelled && Maybe_Half_Phys(mhm.damage) < (Upolyd ? u.mh : u.uhp))

View File

@@ -3040,6 +3040,58 @@ struct mhitm_data *mhm;
}
}
void
mhitm_ad_ench(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 */
/* there's no msomearmor() function, so just do damage */
} else if (mdef == &g.youmonst) {
/* mhitu */
int armpro = magic_negation(mdef);
boolean uncancelled = !magr->mcan && (rn2(10) >= 3 * armpro);
hitmsg(magr, mattk);
/* uncancelled is sufficient enough; please
don't make this attack less frequent */
if (uncancelled) {
struct obj *obj = some_armor(mdef);
if (!obj) {
/* some rings are susceptible;
amulets and blindfolds aren't (at present) */
switch (rn2(5)) {
case 0:
break;
case 1:
obj = uright;
break;
case 2:
obj = uleft;
break;
case 3:
obj = uamul;
break;
case 4:
obj = ublindf;
break;
}
}
if (drain_item(obj, FALSE)) {
pline("%s less effective.", Yobjnam2(obj, "seem"));
}
}
} else {
/* mhitm */
/* there's no msomearmor() function, so just do damage */
}
}
/* Template for monster hits monster for AD_FOO.
- replace "break" with return
@@ -3262,9 +3314,10 @@ int specialdmg; /* blessed and/or silver bonus against various things */
if (mhm.done)
return mhm.hitflags;
break;
case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
/* there's no msomearmor() function, so just do damage */
/* if (negated) break; */
case AD_ENCH:
mhitm_ad_ench(&g.youmonst, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_SLOW:
if (!negated && mdef->mspeed != MSLOW) {