mon->mhp manipulation
I've hunted for other instances where monster hit points were set to zero or less without calling the routine that kills off the monster (see recent mon_unslime() vs zhitm()) and didn't find any for mhp subtraction. I haven't checked for direct assignment yet. For a while I thought I'd found several cases where a monster was intended to be killed but got left with positive hit points, but it turned out that lifesaved_monster(), of all places, was setting them to zero. I've moved that to its callers so that it isn't so well hidden. And changed several ''if ((mon->mhp -= dmg) <= 0)'' into separate subtraction and 'if' just so the mhp manipulation is a bit more visible. I think the only actual change here is the message for monster being killed by lava, where glass golems now melt instead of burn.
This commit is contained in:
13
src/uhitm.c
13
src/uhitm.c
@@ -1604,7 +1604,9 @@ register struct attack *mattk;
|
||||
|
||||
pline("%s suddenly seems weaker!", Monnam(mdef));
|
||||
mdef->mhpmax -= xtmp;
|
||||
if ((mdef->mhp -= xtmp) <= 0 || !mdef->m_lev) {
|
||||
mdef->mhp -= xtmp;
|
||||
/* !m_lev: level 0 monster is killed rather than drop to -1 */
|
||||
if (mdef->mhp <= 0 && !mdef->m_lev) {
|
||||
pline("%s dies!", Monnam(mdef));
|
||||
xkilled(mdef, XKILL_NOMSG);
|
||||
} else
|
||||
@@ -1767,7 +1769,8 @@ register struct attack *mattk;
|
||||
}
|
||||
|
||||
mdef->mstrategy &= ~STRAT_WAITFORU; /* in case player is very fast */
|
||||
if ((mdef->mhp -= tmp) < 1) {
|
||||
mdef->mhp -= tmp;
|
||||
if (mdef->mhp < 1) {
|
||||
if (mdef->mtame && !cansee(mdef->mx, mdef->my)) {
|
||||
You_feel("embarrassed for a moment.");
|
||||
if (tmp)
|
||||
@@ -2043,7 +2046,8 @@ register struct attack *mattk;
|
||||
break;
|
||||
}
|
||||
end_engulf();
|
||||
if ((mdef->mhp -= dam) <= 0) {
|
||||
mdef->mhp -= dam;
|
||||
if (mdef->mhp <= 0) {
|
||||
killed(mdef);
|
||||
if (mdef->mhp <= 0) /* not lifesaved */
|
||||
return 2;
|
||||
@@ -2690,7 +2694,8 @@ int dmg;
|
||||
{
|
||||
pline("%s %s!", Monnam(mon),
|
||||
(dmg > mon->mhp / 2) ? "wails in agony" : "cries out in pain");
|
||||
if ((mon->mhp -= dmg) <= 0) {
|
||||
mon->mhp -= dmg;
|
||||
if (mon->mhp <= 0) {
|
||||
if (context.mon_moving)
|
||||
monkilled(mon, (char *) 0, AD_BLND);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user