diff --git a/include/extern.h b/include/extern.h index 51a1544d6..7e6fa7acf 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2761,6 +2761,7 @@ E void FDECL(mhitm_ad_dcay, (struct monst *, struct attack *, struct monst *, st E void FDECL(mhitm_ad_dren, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_drli, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_fire, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); +E void FDECL(mhitm_ad_cold, (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, diff --git a/src/mhitm.c b/src/mhitm.c index 5448e1359..f6c4b3abc 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1021,20 +1021,9 @@ int dieroll; return mhm.hitflags; break; case AD_COLD: - if (cancelled) { - mhm.damage = 0; - break; - } - if (g.vis && canseemon(mdef)) - pline("%s is covered in frost!", Monnam(mdef)); - if (resists_cold(mdef)) { - if (g.vis && canseemon(mdef)) - pline_The("frost doesn't seem to chill %s!", mon_nam(mdef)); - shieldeff(mdef->mx, mdef->my); - golemeffects(mdef, AD_COLD, mhm.damage); - mhm.damage = 0; - } - mhm.damage += destroy_mitem(mdef, POTION_CLASS, AD_COLD); + mhitm_ad_cold(magr, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_ELEC: if (cancelled) { diff --git a/src/mhitu.c b/src/mhitu.c index 5430d9f12..be4fb308b 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1103,17 +1103,9 @@ register struct attack *mattk; return mhm.hitflags; break; case AD_COLD: - hitmsg(mtmp, mattk); - if (uncancelled) { - pline("You're covered in frost!"); - if (Cold_resistance) { - pline_The("frost doesn't seem cold!"); - mhm.damage = 0; - } - if ((int) mtmp->m_lev > rn2(20)) - destroy_item(POTION_CLASS, AD_COLD); - } else - mhm.damage = 0; + mhitm_ad_cold(mtmp, mattk, &g.youmonst, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_ELEC: hitmsg(mtmp, mattk); diff --git a/src/uhitm.c b/src/uhitm.c index f1d64f07e..c3e2fdff5 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -2073,6 +2073,73 @@ struct mhitm_data *mhm; } } +void +mhitm_ad_cold(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 = 0; + return; + } + if (!Blind) + pline("%s is covered in frost!", Monnam(mdef)); + if (resists_cold(mdef)) { + shieldeff(mdef->mx, mdef->my); + if (!Blind) + pline_The("frost doesn't chill %s!", mon_nam(mdef)); + golemeffects(mdef, AD_COLD, mhm->damage); + mhm->damage = 0; + } + mhm->damage += destroy_mitem(mdef, POTION_CLASS, AD_COLD); + } else if (mdef == &g.youmonst) { + /* mhitu */ + int armpro = magic_negation(mdef); + boolean uncancelled = !magr->mcan && (rn2(10) >= 3 * armpro); + + hitmsg(magr, mattk); + if (uncancelled) { + pline("You're covered in frost!"); + if (Cold_resistance) { + pline_The("frost doesn't seem cold!"); + mhm->damage = 0; + } + if ((int) magr->m_lev > rn2(20)) + destroy_item(POTION_CLASS, AD_COLD); + } else + mhm->damage = 0; + } else { + /* mhitm */ + int armpro = magic_negation(mdef); + boolean cancelled = magr->mcan || !(rn2(10) >= 3 * armpro); + + if (cancelled) { + mhm->damage = 0; + return; + } + if (g.vis && canseemon(mdef)) + pline("%s is covered in frost!", Monnam(mdef)); + if (resists_cold(mdef)) { + if (g.vis && canseemon(mdef)) + pline_The("frost doesn't seem to chill %s!", mon_nam(mdef)); + shieldeff(mdef->mx, mdef->my); + golemeffects(mdef, AD_COLD, mhm->damage); + mhm->damage = 0; + } + mhm->damage += destroy_mitem(mdef, POTION_CLASS, AD_COLD); + } +} + /* Template for monster hits monster for AD_FOO. - replace "break" with return @@ -2179,20 +2246,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */ return mhm.hitflags; break; case AD_COLD: - if (negated) { - mhm.damage = 0; - break; - } - if (!Blind) - pline("%s is covered in frost!", Monnam(mdef)); - if (resists_cold(mdef)) { - shieldeff(mdef->mx, mdef->my); - if (!Blind) - pline_The("frost doesn't chill %s!", mon_nam(mdef)); - golemeffects(mdef, AD_COLD, mhm.damage); - mhm.damage = 0; - } - mhm.damage += destroy_mitem(mdef, POTION_CLASS, AD_COLD); + mhitm_ad_cold(&g.youmonst, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_ELEC: if (negated) {