diff --git a/include/monst.h b/include/monst.h index 0e686e07b..3c88d0172 100644 --- a/include/monst.h +++ b/include/monst.h @@ -159,4 +159,8 @@ struct monst { #define is_vampshifter(mon) \ ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LORD \ || (mon)->cham == PM_VLAD_THE_IMPALER) +#define is_door_mappear(mon) ((mon)->m_ap_type == M_AP_FURNITURE \ + && ((mon)->mappearance == S_hcdoor || (mon)->mappearance == S_vcdoor)) +#define is_obj_mappear(mon,otyp) ((mon)->m_ap_type == M_AP_OBJECT \ + && (mon)->mappearance == (otyp)) #endif /* MONST_H */ diff --git a/src/display.c b/src/display.c index 000900efe..84f895494 100644 --- a/src/display.c +++ b/src/display.c @@ -1179,11 +1179,8 @@ set_mimic_blocking() for (mon = fmon; mon; mon = mon->nmon) { if (DEADMONSTER(mon)) continue; - if (mon->minvis && ((mon->m_ap_type == M_AP_FURNITURE - && (mon->mappearance == S_vcdoor - || mon->mappearance == S_hcdoor)) - || (mon->m_ap_type == M_AP_OBJECT - && mon->mappearance == BOULDER))) { + if (mon->minvis && (is_door_mappear(mon) + || is_obj_mappear(mon,BOULDER))) { if (See_invisible) block_point(mon->mx, mon->my); else diff --git a/src/eat.c b/src/eat.c index 4367e6528..8bf0653b9 100644 --- a/src/eat.c +++ b/src/eat.c @@ -161,13 +161,11 @@ eatmupdate() if (!eatmbuf || nomovemsg != eatmbuf) return; - if (youmonst.m_ap_type == M_AP_OBJECT && youmonst.mappearance == ORANGE - && !Hallucination) { + if (is_obj_mappear(&youmonst,ORANGE) && !Hallucination) { /* revert from hallucinatory to "normal" mimicking */ altmsg = "You now prefer mimicking yourself."; altapp = GOLD_PIECE; - } else if (youmonst.m_ap_type == M_AP_OBJECT - && youmonst.mappearance == GOLD_PIECE && Hallucination) { + } else if (is_obj_mappear(&youmonst,GOLD_PIECE) && Hallucination) { /* won't happen; anything which might make immobilized hero begin hallucinating (black light attack, theft of Grayswandir) will terminate the mimicry first */ diff --git a/src/hack.c b/src/hack.c index a94ed9183..bbe6df83f 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2416,9 +2416,7 @@ lookaround() || IS_AIR(levl[x][y].typ)) continue; else if (closed_door(x, y) - || (mtmp && mtmp->m_ap_type == M_AP_FURNITURE - && (mtmp->mappearance == S_hcdoor - || mtmp->mappearance == S_vcdoor))) { + || (mtmp && is_door_mappear(mtmp))) { if (x != u.ux && y != u.uy) continue; if (context.run != 1) diff --git a/src/lock.c b/src/lock.c index c2c06067a..869860fec 100644 --- a/src/lock.c +++ b/src/lock.c @@ -389,11 +389,7 @@ register struct obj *pick; pline("I don't think %s would appreciate that.", mon_nam(mtmp)); return PICKLOCK_LEARNED_SOMETHING; - } else if (mtmp && mtmp->m_ap_type == M_AP_FURNITURE && - /* not IS_DOOR() here; for M_AP_FURNITURE, mappearance - holds a map symbol rather than a topology type */ - (mtmp->mappearance == S_vcdoor - || mtmp->mappearance == S_hcdoor)) { + } else if (mtmp && is_door_mappear(mtmp)) { /* "The door actually was a !" */ stumble_onto_mimic(mtmp); /* mimic might keep the key (50% chance, 10% for PYEC) */ @@ -539,8 +535,7 @@ stumble_on_door_mimic(x, y) int x, y; { struct monst *mtmp; - if ((mtmp = m_at(x, y)) && mtmp->m_ap_type == M_AP_FURNITURE - && (mtmp->mappearance == S_hcdoor || mtmp->mappearance == S_vcdoor) + if ((mtmp = m_at(x, y)) && is_door_mappear(mtmp) && !Protection_from_shape_changers) { stumble_onto_mimic(mtmp); return TRUE; diff --git a/src/mcastu.c b/src/mcastu.c index 94a4d97e3..3b3c03286 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -55,8 +55,7 @@ boolean undirected; point_msg = "all around, then curses"; else if ((Invis && !perceives(mtmp->data) && (mtmp->mux != u.ux || mtmp->muy != u.uy)) - || (youmonst.m_ap_type == M_AP_OBJECT - && youmonst.mappearance == STRANGE_OBJECT) + || is_obj_mappear(&youmonst, STRANGE_OBJECT) || u.uundetected) point_msg = "and curses in your general direction"; else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy)) diff --git a/src/mon.c b/src/mon.c index 786471e34..a620fb592 100644 --- a/src/mon.c +++ b/src/mon.c @@ -2531,8 +2531,8 @@ void seemimic(mtmp) register struct monst *mtmp; { - unsigned old_app = mtmp->mappearance; - uchar old_ap_type = mtmp->m_ap_type; + boolean is_blocker_appear = is_door_mappear(mtmp) || + is_obj_mappear(mtmp, BOULDER); if (has_mcorpsenm(mtmp)) freemcorpsenm(mtmp); @@ -2543,9 +2543,7 @@ register struct monst *mtmp; /* * Discovered mimics don't block light. */ - if (((old_ap_type == M_AP_FURNITURE - && (old_app == S_hcdoor || old_app == S_vcdoor)) - || (old_ap_type == M_AP_OBJECT && old_app == BOULDER)) + if (is_blocker_appear && !does_block(mtmp->mx, mtmp->my, &levl[mtmp->mx][mtmp->my])) unblock_point(mtmp->mx, mtmp->my); diff --git a/src/monmove.c b/src/monmove.c index 92baf26a0..e9e14cd8e 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -845,10 +845,8 @@ not_special: if (!mtmp->mcansee || (should_see && Invis && !perceives(ptr) && rn2(11)) - || (youmonst.m_ap_type == M_AP_OBJECT - && youmonst.mappearance == STRANGE_OBJECT) || u.uundetected - || (youmonst.m_ap_type == M_AP_OBJECT - && youmonst.mappearance == GOLD_PIECE && !likes_gold(ptr)) + || is_obj_mappear(&youmonst,STRANGE_OBJECT) || u.uundetected + || (is_obj_mappear(&youmonst,GOLD_PIECE) && !likes_gold(ptr)) || (mtmp->mpeaceful && !mtmp->isshk) || /* allow shks to follow */ ((monsndx(ptr) == PM_STALKER || ptr->mlet == S_BAT || ptr->mlet == S_LIGHT) && !rn2(3))) diff --git a/src/pager.c b/src/pager.c index 1138c06ac..94ffcd18a 100644 --- a/src/pager.c +++ b/src/pager.c @@ -89,8 +89,7 @@ struct obj **obj_p; *obj_p = (struct obj *) 0; /* there might be a mimic here posing as an object */ mtmp = m_at(x, y); - if (mtmp && mtmp->m_ap_type == M_AP_OBJECT - && mtmp->mappearance == (unsigned) glyphotyp) + if (mtmp && is_obj_mappear(mtmp, (unsigned) glyphotyp)) otmp = 0; else mtmp = 0; diff --git a/src/vision.c b/src/vision.c index 10e01abec..c3e072ab2 100644 --- a/src/vision.c +++ b/src/vision.c @@ -178,11 +178,7 @@ register struct rm *lev; /* Mimics mimicing a door or boulder block light. */ if ((mon = m_at(x, y)) && (!mon->minvis || See_invisible) - && ((mon->m_ap_type == M_AP_FURNITURE - && (mon->mappearance == S_hcdoor - || mon->mappearance == S_vcdoor)) - || (mon->m_ap_type == M_AP_OBJECT - && mon->mappearance == BOULDER))) + && (is_door_mappear(mon) || is_obj_mappear(mon,BOULDER))) return 1; return 0; diff --git a/src/zap.c b/src/zap.c index 9ed99017d..106f9bfc2 100644 --- a/src/zap.c +++ b/src/zap.c @@ -320,8 +320,7 @@ struct obj *otmp; } if (canseemon(mtmp)) { if (disguised_mimic) { - if (mtmp->m_ap_type == M_AP_OBJECT - && mtmp->mappearance == STRANGE_OBJECT) { + if (is_obj_mappear(mtmp,STRANGE_OBJECT)) { /* it can do better now */ set_mimic_sym(mtmp); newsym(mtmp->mx, mtmp->my);