From: Pasi Kallinen Date: Mon, 30 Nov 2020 18:19:49 +0000 (+0200) Subject: Unify ad_acid X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7899ee014f8c3d39910d8c183cd513d59fb7afe;p=nethack Unify ad_acid --- diff --git a/include/extern.h b/include/extern.h index c899cdc18..7d9907bab 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2763,6 +2763,7 @@ E void FDECL(mhitm_ad_drli, (struct monst *, struct attack *, struct monst *, st 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 void FDECL(mhitm_ad_elec, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); +E void FDECL(mhitm_ad_acid, (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 f0f95fda8..f5e15a533 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1031,23 +1031,9 @@ int dieroll; return mhm.hitflags; break; case AD_ACID: - if (magr->mcan) { - mhm.damage = 0; - break; - } - if (resists_acid(mdef)) { - if (g.vis && canseemon(mdef)) - pline("%s is covered in %s, but it seems harmless.", - Monnam(mdef), hliquid("acid")); - mhm.damage = 0; - } else if (g.vis && canseemon(mdef)) { - pline("%s is covered in %s!", Monnam(mdef), hliquid("acid")); - pline("It burns %s!", mon_nam(mdef)); - } - if (!rn2(30)) - erode_armor(mdef, ERODE_CORRODE); - if (!rn2(6)) - acid_damage(MON_WEP(mdef)); + mhitm_ad_acid(magr, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_RUST: mhitm_ad_rust(magr, mattk, mdef, &mhm); diff --git a/src/mhitu.c b/src/mhitu.c index 3b146cd20..1e45dadcc 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1550,18 +1550,9 @@ register struct attack *mattk; } break; case AD_ACID: - hitmsg(mtmp, mattk); - if (!mtmp->mcan && !rn2(3)) - if (Acid_resistance) { - pline("You're covered in %s, but it seems harmless.", - hliquid("acid")); - mhm.damage = 0; - } else { - pline("You're covered in %s! It burns!", hliquid("acid")); - exercise(A_STR, FALSE); - } - else - mhm.damage = 0; + mhitm_ad_acid(mtmp, mattk, &g.youmonst, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_SLOW: hitmsg(mtmp, mattk); diff --git a/src/uhitm.c b/src/uhitm.c index 2d78004ed..330342f7e 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -2213,6 +2213,55 @@ struct mhitm_data *mhm; } } +void +mhitm_ad_acid(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 (resists_acid(mdef)) + mhm->damage = 0; + } else if (mdef == &g.youmonst) { + /* mhitu */ + hitmsg(magr, mattk); + if (!magr->mcan && !rn2(3)) + if (Acid_resistance) { + pline("You're covered in %s, but it seems harmless.", + hliquid("acid")); + mhm->damage = 0; + } else { + pline("You're covered in %s! It burns!", hliquid("acid")); + exercise(A_STR, FALSE); + } + else + mhm->damage = 0; + } else { + /* mhitm */ + if (magr->mcan) { + mhm->damage = 0; + return; + } + if (resists_acid(mdef)) { + if (g.vis && canseemon(mdef)) + pline("%s is covered in %s, but it seems harmless.", + Monnam(mdef), hliquid("acid")); + mhm->damage = 0; + } else if (g.vis && canseemon(mdef)) { + pline("%s is covered in %s!", Monnam(mdef), hliquid("acid")); + pline("It burns %s!", mon_nam(mdef)); + } + if (!rn2(30)) + erode_armor(mdef, ERODE_CORRODE); + if (!rn2(6)) + acid_damage(MON_WEP(mdef)); + } +} + /* Template for monster hits monster for AD_FOO. - replace "break" with return @@ -2329,8 +2378,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */ return mhm.hitflags; break; case AD_ACID: - if (resists_acid(mdef)) - mhm.damage = 0; + mhitm_ad_acid(&g.youmonst, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_STON: if (!munstone(mdef, TRUE))