montraits of weapon-wielding monsters

Have save_mtraits() clear wielded weapon when attaching monster
attributes to a corpse object.

And have monster sanity check verify that wielded weapon is in the
monster's inventory.
This commit is contained in:
PatR
2025-05-31 16:41:43 -07:00
parent 468be966fe
commit 79be47b1ad
2 changed files with 14 additions and 0 deletions
+1
View File
@@ -2154,6 +2154,7 @@ save_mtraits(struct obj *obj, struct monst *mtmp)
mtmp2->nmon = (struct monst *) 0; mtmp2->nmon = (struct monst *) 0;
mtmp2->data = (struct permonst *) 0; mtmp2->data = (struct permonst *) 0;
mtmp2->minvent = (struct obj *) 0; mtmp2->minvent = (struct obj *) 0;
MON_NOWEP(mtmp2); /* mtmp2->mw = (struct obj *) 0; */
if (mtmp->mextra) if (mtmp->mextra)
copy_mextra(mtmp2, mtmp); copy_mextra(mtmp2, mtmp);
/* if mtmp is a long worm with segments, its saved traits will /* if mtmp is a long worm with segments, its saved traits will
+13
View File
@@ -233,6 +233,19 @@ sanity_check_single_mon(
mtmp->m_id, distu(mtmp->mx, mtmp->my)); mtmp->m_id, distu(mtmp->mx, mtmp->my));
#endif #endif
} }
if (MON_WEP(mtmp)) { /* mtmp->mw */
struct obj *o;
for (o = mtmp->minvent; o; o = o->nobj)
if (o == MON_WEP(mtmp))
break;
if (!o) {
o = MON_WEP(mtmp);
impossible("monst (%s: %u) wielding %s (%u) not in inventory",
pmname(mtmp->data, Mgender(mtmp)), mtmp->m_id,
safe_typename(o->otyp), o->o_id);
}
}
} }
void void