MCPcopy Index your code
hub / github.com/NetHack/NetHack / restrap

Function restrap

src/mon.c:4661–4693  ·  view source on GitHub ↗

unwatched hiders may hide again; if so, returns True */

Source from the content-addressed store, hash-verified

4659
4660/* unwatched hiders may hide again; if so, returns True */
4661staticfn boolean
4662restrap(struct monst *mtmp)
4663{
4664 struct trap *t;
4665
4666 if (mtmp->mcan || M_AP_TYPE(mtmp) || cansee(mtmp->mx, mtmp->my)
4667 || rn2(3) || mtmp == u.ustuck
4668 /* can't hide while trapped except in pits */
4669 || (mtmp->mtrapped && (t = t_at(mtmp->mx, mtmp->my)) != 0
4670 && !is_pit(t->ttyp))
4671 /* can't hide on ceiling if there isn't one */
4672 || (ceiling_hider(mtmp->data) && !has_ceiling(&u.uz))
4673 /* won't hide when adjacent to hero */
4674 || (sensemon(mtmp) && m_next2u(mtmp)))
4675 return FALSE;
4676
4677 if (mtmp->data->mlet == S_MIMIC) {
4678 if (mtmp->msleeping || mtmp->mfrozen) {
4679 /*
4680 * The mimic needs to be awake to disguise itself
4681 * as something else.
4682 */
4683 return FALSE;
4684 }
4685 set_mimic_sym(mtmp);
4686 return TRUE;
4687 } else if (levl[mtmp->mx][mtmp->my].typ == ROOM) {
4688 mtmp->mundetected = 1;
4689 return TRUE;
4690 }
4691
4692 return FALSE;
4693}
4694
4695/* reveal a hiding monster at x,y, either under nonexistent object,
4696 or an eel out of water. */

Callers 2

movemon_singlemonFunction · 0.85
hide_monstFunction · 0.85

Calls 5

rn2Function · 0.85
t_atFunction · 0.85
has_ceilingFunction · 0.85
sensemonFunction · 0.85
set_mimic_symFunction · 0.85

Tested by

no test coverage detected