From: Pasi Kallinen Date: Tue, 1 Dec 2020 09:28:41 +0000 (+0200) Subject: Unify ad_samu X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4118a7ea44cb927df983674bd24374c7cc07b0bf;p=nethack Unify ad_samu --- diff --git a/include/extern.h b/include/extern.h index 97fdb46e3..914265912 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2792,6 +2792,7 @@ E void FDECL(mhitm_ad_heal, (struct monst *, struct attack *, struct monst *, st E void FDECL(mhitm_ad_stun, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_legs, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_dgst, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); +E void FDECL(mhitm_ad_samu, (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/mhitu.c b/src/mhitu.c index 030c98ee9..d061dd9b1 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1165,14 +1165,10 @@ register struct attack *mattk; break; case AD_SAMU: - hitmsg(mtmp, mattk); - /* when the Wizard or quest nemesis hits, there's a 1/20 chance - to steal a quest artifact (any, not just the one for the hero's - own role) or the Amulet or one of the invocation tools */ - if (!rn2(20)) - stealamulet(mtmp); + mhitm_ad_samu(mtmp, mattk, &g.youmonst, &mhm); + if (mhm.done) + return mhm.hitflags; break; - case AD_TLPT: mhitm_ad_tlpt(mtmp, mattk, &g.youmonst, &mhm); if (mhm.done) diff --git a/src/uhitm.c b/src/uhitm.c index 57bced509..59362b6bb 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -3959,6 +3959,33 @@ struct mhitm_data *mhm; } } +void +mhitm_ad_samu(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 */ + mhm->damage = 0; + } else if (mdef == &g.youmonst) { + /* mhitu */ + hitmsg(magr, mattk); + /* when the Wizard or quest nemesis hits, there's a 1/20 chance + to steal a quest artifact (any, not just the one for the hero's + own role) or the Amulet or one of the invocation tools */ + if (!rn2(20)) + stealamulet(magr); + } else { + /* mhitm */ + mhm->damage = 0; + } +} + + /* Template for monster hits monster for AD_FOO. - replace "break" with return - replace "return" with mhm->done = TRUE