From: Pasi Kallinen Date: Tue, 1 Dec 2020 08:44:15 +0000 (+0200) Subject: Unify ad_ston X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6a676f720b979356e7bb7b6d46a995eb2c8a752;p=nethack Unify ad_ston --- diff --git a/include/extern.h b/include/extern.h index 59982f230..4de281ec0 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2786,6 +2786,7 @@ E void FDECL(mhitm_ad_pest, (struct monst *, struct attack *, struct monst *, st E void FDECL(mhitm_ad_deth, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_halu, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_phys, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); +E void FDECL(mhitm_ad_ston, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E boolean FDECL(do_stone_u, (struct monst *)); E void FDECL(do_stone_mon, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E int FDECL(damageum, (struct monst *, struct attack *, int)); diff --git a/src/mhitm.c b/src/mhitm.c index d7f9a6dbe..236e4d83a 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1007,9 +1007,7 @@ int dieroll; return mhm.hitflags; break; case AD_STON: - if (magr->mcan) - break; - do_stone_mon(magr, mattk, mdef, &mhm); + mhitm_ad_ston(magr, mattk, mdef, &mhm); if (mhm.done) return mhm.hitflags; break; diff --git a/src/mhitu.c b/src/mhitu.c index 5a3e69e42..a08ce6ce7 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1113,22 +1113,10 @@ register struct attack *mattk; } break; } - case AD_STON: /* cockatrice */ - hitmsg(mtmp, mattk); - if (!rn2(3)) { - if (mtmp->mcan) { - if (!Deaf) - You_hear("a cough from %s!", mon_nam(mtmp)); - } else { - if (!Deaf) - You_hear("%s hissing!", s_suffix(mon_nam(mtmp))); - if (!rn2(10) - || (flags.moonphase == NEW_MOON && !have_lizard())) { - if (do_stone_u(mtmp)) - return MM_HIT; - } - } - } + case AD_STON: + mhitm_ad_ston(mtmp, mattk, &g.youmonst, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_STCK: mhitm_ad_stck(mtmp, mattk, &g.youmonst, &mhm); diff --git a/src/uhitm.c b/src/uhitm.c index b377a5f35..e0d1d30d0 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -3600,6 +3600,50 @@ struct mhitm_data *mhm; } } +void +mhitm_ad_ston(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 (!munstone(mdef, TRUE)) + minstapetrify(mdef, TRUE); + mhm->damage = 0; + } else if (mdef == &g.youmonst) { + /* mhitu */ + hitmsg(magr, mattk); + if (!rn2(3)) { + if (magr->mcan) { + if (!Deaf) + You_hear("a cough from %s!", mon_nam(magr)); + } else { + if (!Deaf) + You_hear("%s hissing!", s_suffix(mon_nam(magr))); + if (!rn2(10) + || (flags.moonphase == NEW_MOON && !have_lizard())) { + if (do_stone_u(magr)) { + mhm->hitflags = MM_HIT; + mhm->done = TRUE; + return; + } + } + } + } + } else { + /* mhitm */ + if (magr->mcan) + return; + do_stone_mon(magr, mattk, mdef, mhm); + if (mhm->done) + return; + } +} + /* Template for monster hits monster for AD_FOO. - replace "break" with return - replace "return" with mhm->done = TRUE @@ -3704,9 +3748,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */ return mhm.hitflags; break; case AD_STON: - if (!munstone(mdef, TRUE)) - minstapetrify(mdef, TRUE); - mhm.damage = 0; + mhitm_ad_ston(&g.youmonst, mattk, mdef, &mhm); + if (mhm.done) + return mhm.hitflags; break; case AD_SSEX: case AD_SEDU: