From d2b7c2f5c52c554d63fc6b7c5974824e09452adc Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Wed, 18 Sep 2024 20:51:21 +0900 Subject: [PATCH] split "assess_dmg" on passiveum() into a separate function --- src/mhitu.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/mhitu.c b/src/mhitu.c index 38b765c9c..14b453147 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -19,6 +19,7 @@ staticfn int gulpmu(struct monst *, struct attack *); staticfn int explmu(struct monst *, struct attack *, boolean); staticfn void mayberem(struct monst *, const char *, struct obj *, const char *); +staticfn int assess_dmg(struct monst *, int); staticfn int passiveum(struct permonst *, struct monst *, struct attack *); #define ld() ((yyyymmdd((time_t) 0) - (getyear() * 10000L)) == 0xe5) @@ -2291,6 +2292,19 @@ mayberem(struct monst *mon, remove_worn_item(obj, TRUE); } +staticfn int +assess_dmg(struct monst *mtmp, int tmp) +{ + if ((mtmp->mhp -= tmp) <= 0) { + pline("%s dies!", Monnam(mtmp)); + xkilled(mtmp, XKILL_NOMSG); + if (!DEADMONSTER(mtmp)) + return M_ATTK_HIT; + return M_ATTK_AGR_DIED; + } + return M_ATTK_HIT; +} + /* FIXME: * sequencing issue: a monster's attack might cause poly'd hero * to revert to normal form. The messages for passive counterattack @@ -2345,7 +2359,7 @@ passiveum( erode_armor(mtmp, ERODE_CORRODE); if (!rn2(6)) acid_damage(MON_WEP(mtmp)); - goto assess_dmg; + return assess_dmg(mtmp, tmp); case AD_STON: /* cockatrice */ { long protector = attk_protection((int) mattk->aatyp), @@ -2394,7 +2408,7 @@ passiveum( You("explode!"); /* KMH, balance patch -- this is okay with unchanging */ rehumanize(); - goto assess_dmg; + return assess_dmg(mtmp, tmp); } break; case AD_PLYS: /* Floating eye */ @@ -2474,15 +2488,7 @@ passiveum( else tmp = 0; - assess_dmg: - if ((mtmp->mhp -= tmp) <= 0) { - pline("%s dies!", Monnam(mtmp)); - xkilled(mtmp, XKILL_NOMSG); - if (!DEADMONSTER(mtmp)) - return M_ATTK_HIT; - return M_ATTK_AGR_DIED; - } - return M_ATTK_HIT; + return assess_dmg(mtmp, tmp); } struct monst *