Fix knockbacked monster migrating or killed

Fix a case where a monster knocked back another monster into a trap,
and the trap either killed or migrated the monster, then the actual
damage dealing later could try to detach the already detached monster.

If the monster migrated, the monster is gone before the damage from
the hit is dealt to the monster.
This commit is contained in:
Pasi Kallinen
2022-07-26 23:17:54 +03:00
parent f0774e0da4
commit 810744a27d

View File

@@ -947,7 +947,11 @@ mdamagem(struct monst *magr, struct monst *mdef,
mhitm_adtyping(magr, mattk, mdef, &mhm);
(void) mhitm_knockback(magr, mdef, mattk, &mhm.hitflags, (MON_WEP(magr) != 0));
if (mhitm_knockback(magr, mdef, mattk, &mhm.hitflags,
(MON_WEP(magr) != 0))
&& ((mhm.hitflags & MM_DEF_DIED) != 0
|| (mdef->mstate & (MON_DETACH|MON_MIGRATING|MON_LIMBO)) != 0))
return mhm.hitflags;
if (mhm.done)
return mhm.hitflags;