Fix monster trapped state being wrong

When cloning a monster, clear the clone trapped and hiding states.
When splitting a monster (eg. a black pudding), the clone could
be placed on a trap, so do mintrap.
When removing a monster from the map, clear the trapped state.
This commit is contained in:
Pasi Kallinen
2019-05-05 22:49:21 +03:00
parent f55e9ddd7c
commit bed2c2307e
5 changed files with 11 additions and 2 deletions

View File

@@ -842,6 +842,8 @@ xchar x, y; /* clone's preferred location or 0 (near mon) */
m2->mx = mm.x;
m2->my = mm.y;
m2->mundetected = 0;
m2->mtrapped = 0;
m2->mcloned = 1;
m2->minvent = (struct obj *) 0; /* objects don't clone */
m2->mleashed = FALSE;

View File

@@ -419,7 +419,8 @@ register struct monst *magr, *mdef;
|| objects[otmp->otyp].oc_material == METAL))
&& mdef->mhp > 1
&& !mdef->mcan) {
if (clone_mon(mdef, 0, 0)) {
struct monst *mclone;
if ((mclone = clone_mon(mdef, 0, 0)) != 0) {
if (vis && canspotmon(mdef)) {
char buf[BUFSZ];
@@ -427,6 +428,7 @@ register struct monst *magr, *mdef;
pline("%s divides as %s hits it!", buf,
mon_nam(magr));
}
mintrap(mclone);
}
}
} else

View File

@@ -1687,6 +1687,7 @@ struct monst **monst_list; /* &migrating_mons or &mydogs or null */
}
if (on_map) {
mon->mtrapped = 0;
if (mon->wormno)
remove_worm(mon);
else

View File

@@ -1227,7 +1227,8 @@ int dieroll;
/* but not bashing with darts, arrows or ya */
&& !(is_ammo(obj) || is_missile(obj)))
&& hand_to_hand) {
if (clone_mon(mon, 0, 0)) {
struct monst *mclone;
if ((mclone = clone_mon(mon, 0, 0)) != 0) {
char withwhat[BUFSZ];
withwhat[0] = '\0';
@@ -1235,6 +1236,7 @@ int dieroll;
Sprintf(withwhat, " with %s", yname(obj));
pline("%s divides as you hit it%s!", Monnam(mon), withwhat);
hittxt = TRUE;
mintrap(mclone);
}
}