split "assess_dmg" on passiveum() into a separate function

This commit is contained in:
SHIRAKATA Kentaro
2024-10-15 03:21:08 +09:00
parent 546c1101b0
commit d2b7c2f5c5
+17 -11
View File
@@ -19,6 +19,7 @@ staticfn int gulpmu(struct monst *, struct attack *);
staticfn int explmu(struct monst *, struct attack *, boolean); staticfn int explmu(struct monst *, struct attack *, boolean);
staticfn void mayberem(struct monst *, const char *, struct obj *, staticfn void mayberem(struct monst *, const char *, struct obj *,
const char *); const char *);
staticfn int assess_dmg(struct monst *, int);
staticfn int passiveum(struct permonst *, struct monst *, struct attack *); staticfn int passiveum(struct permonst *, struct monst *, struct attack *);
#define ld() ((yyyymmdd((time_t) 0) - (getyear() * 10000L)) == 0xe5) #define ld() ((yyyymmdd((time_t) 0) - (getyear() * 10000L)) == 0xe5)
@@ -2291,6 +2292,19 @@ mayberem(struct monst *mon,
remove_worn_item(obj, TRUE); 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: /* FIXME:
* sequencing issue: a monster's attack might cause poly'd hero * sequencing issue: a monster's attack might cause poly'd hero
* to revert to normal form. The messages for passive counterattack * to revert to normal form. The messages for passive counterattack
@@ -2345,7 +2359,7 @@ passiveum(
erode_armor(mtmp, ERODE_CORRODE); erode_armor(mtmp, ERODE_CORRODE);
if (!rn2(6)) if (!rn2(6))
acid_damage(MON_WEP(mtmp)); acid_damage(MON_WEP(mtmp));
goto assess_dmg; return assess_dmg(mtmp, tmp);
case AD_STON: /* cockatrice */ case AD_STON: /* cockatrice */
{ {
long protector = attk_protection((int) mattk->aatyp), long protector = attk_protection((int) mattk->aatyp),
@@ -2394,7 +2408,7 @@ passiveum(
You("explode!"); You("explode!");
/* KMH, balance patch -- this is okay with unchanging */ /* KMH, balance patch -- this is okay with unchanging */
rehumanize(); rehumanize();
goto assess_dmg; return assess_dmg(mtmp, tmp);
} }
break; break;
case AD_PLYS: /* Floating eye */ case AD_PLYS: /* Floating eye */
@@ -2474,15 +2488,7 @@ passiveum(
else else
tmp = 0; tmp = 0;
assess_dmg: return assess_dmg(mtmp, 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;
} }
struct monst * struct monst *