fix #H285 - hiders not hiding while hero is on another level (trunk only)

From a bug report, mimics
which were exposed at the time the hero leaves a level remain unhidden
upon return no matter how long the hero is away.  It was actually expected
behavior since the old level is stuck in stasis and hiders only hide when
it's their turn to move, but it was noticeably odd.  This makes unhidden
hiders attempt to hide when hero returns to a previous level or enters a
bones level.  I reorganized the monster handling in getlev() because the
relevant part was taking place before floor objects got restored, so
hidesunder() monsters had nothing to hide under at the time.
This commit is contained in:
nethack.rankin
2007-04-22 01:01:22 +00:00
parent a1a4a45033
commit 62a33d981a
4 changed files with 49 additions and 33 deletions

View File

@@ -2467,6 +2467,26 @@ struct monst *mtmp;
return undetected;
}
/* called when returning to a previously visited level */
void
hide_monst(mon)
struct monst *mon;
{
if ((is_hider(mon->data) || hides_under(mon->data)) &&
!(mon->mundetected || mon->m_ap_type)) {
xchar x = mon->mx, y = mon->my;
char save_viz = viz_array[y][x];
/* override vision, forcing hero to be unable to see monster's spot */
viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE);
if (is_hider(mon->data)) (void)restrap(mon);
/* try again if mimic missed its 1/3 chance to hide */
if (mon->data->mlet == S_MIMIC && !mon->m_ap_type) (void)restrap(mon);
if (hides_under(mon->data)) (void)hideunder(mon);
viz_array[y][x] = save_viz;
}
}
short *animal_list = 0; /* list of PM values for animal monsters */
int animal_list_count;