diff --git a/include/display.h b/include/display.h index ef7bd362a..92c201a2a 100644 --- a/include/display.h +++ b/include/display.h @@ -215,13 +215,13 @@ #define display_self() \ show_glyph(u.ux, u.uy, \ - maybe_display_usteed((g.youmonst.m_ap_type == M_AP_NOTHING) \ + maybe_display_usteed((U_AP_TYPE == M_AP_NOTHING) \ ? hero_glyph \ - : (g.youmonst.m_ap_type == M_AP_FURNITURE) \ + : (U_AP_TYPE == M_AP_FURNITURE) \ ? cmap_to_glyph(g.youmonst.mappearance) \ - : (g.youmonst.m_ap_type == M_AP_OBJECT) \ + : (U_AP_TYPE == M_AP_OBJECT) \ ? objnum_to_glyph(g.youmonst.mappearance) \ - /* else M_AP_MONSTER */ \ + /* else U_AP_TYPE == M_AP_MONSTER */ \ : monnum_to_glyph(g.youmonst.mappearance))) /* diff --git a/include/monst.h b/include/monst.h index 0b82ab55b..91844448b 100644 --- a/include/monst.h +++ b/include/monst.h @@ -50,6 +50,13 @@ enum m_ap_types { M_AP_MONSTER = 3 /* a monster; mostly used for cloned Wizard */ }; +#define M_AP_TYPMASK 0x7 +#define M_AP_F_DKNOWN 0x8 +#define U_AP_TYPE (g.youmonst.m_ap_type & M_AP_TYPMASK) +#define U_AP_FLAG (g.youmonst.m_ap_type & ~M_AP_TYPMASK) +#define M_AP_TYPE(m) ((m)->m_ap_type & M_AP_TYPMASK) +#define M_AP_FLAG(m) ((m)->m_ap_type & ~M_AP_TYPMASK) + struct monst { struct monst *nmon; struct permonst *data; @@ -170,15 +177,15 @@ struct monst { /* mimic appearances that block vision/light */ #define is_lightblocker_mappear(mon) \ (is_obj_mappear(mon, BOULDER) \ - || ((mon)->m_ap_type == M_AP_FURNITURE \ + || (M_AP_TYPE(mon) == M_AP_FURNITURE \ && ((mon)->mappearance == S_hcdoor \ || (mon)->mappearance == S_vcdoor \ || (mon)->mappearance < S_ndoor /* = walls */ \ || (mon)->mappearance == S_tree))) -#define is_door_mappear(mon) ((mon)->m_ap_type == M_AP_FURNITURE \ +#define is_door_mappear(mon) (M_AP_TYPE(mon) == M_AP_FURNITURE \ && ((mon)->mappearance == S_hcdoor \ || (mon)->mappearance == S_vcdoor)) -#define is_obj_mappear(mon,otyp) ((mon)->m_ap_type == M_AP_OBJECT \ +#define is_obj_mappear(mon,otyp) (M_AP_TYPE(mon) == M_AP_OBJECT \ && (mon)->mappearance == (otyp)) #endif /* MONST_H */ diff --git a/src/apply.c b/src/apply.c index 29c2b4df7..ed54d4f13 100644 --- a/src/apply.c +++ b/src/apply.c @@ -382,7 +382,7 @@ register struct obj *obj; } else if (mtmp->mappearance) { const char *what = "thing"; - switch (mtmp->m_ap_type) { + switch (M_AP_TYPE(mtmp)) { case M_AP_OBJECT: what = simple_typename(mtmp->mappearance); break; @@ -484,7 +484,7 @@ struct obj *obj; } /* mimic must be revealed before we know whether it actually moves because line-of-sight may change */ - if (mtmp->m_ap_type) + if (M_AP_TYPE(mtmp)) seemimic(mtmp); omx = mtmp->mx, omy = mtmp->my; mnexto(mtmp); @@ -2105,7 +2105,7 @@ long timeout; and_vanish[0] = '\0'; if ((mtmp->minvis && !See_invisible) || (mtmp->data->mlet == S_MIMIC - && mtmp->m_ap_type != M_AP_NOTHING)) + && M_AP_TYPE(mtmp) != M_AP_NOTHING)) suppress_see = TRUE; if (mtmp->mundetected) { @@ -2830,7 +2830,7 @@ struct obj *obj; } wakeup(mtmp, TRUE); } else { - if (mtmp->m_ap_type && !Protection_from_shape_changers + if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers && !sensemon(mtmp)) stumble_onto_mimic(mtmp); else diff --git a/src/cmd.c b/src/cmd.c index 827509750..61e90a1b2 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -2257,7 +2257,7 @@ int final; : surface(u.ux, u.uy)); /* catchall; shouldn't happen */ you_are(buf, from_what(WWALKING)); } - if (Upolyd && (u.uundetected || g.youmonst.m_ap_type != M_AP_NOTHING)) + if (Upolyd && (u.uundetected || U_AP_TYPE != M_AP_NOTHING)) youhiding(TRUE, final); /* internal troubles, mostly in the order that prayer ranks them */ @@ -3079,16 +3079,16 @@ int msgflag; /* for variant message phrasing */ char *bp, buf[BUFSZ]; Strcpy(buf, "hiding"); - if (g.youmonst.m_ap_type != M_AP_NOTHING) { + if (U_AP_TYPE != M_AP_NOTHING) { /* mimic; hero is only able to mimic a strange object or gold or hallucinatory alternative to gold, so we skip the details for the hypothetical furniture and monster cases */ bp = eos(strcpy(buf, "mimicking")); - if (g.youmonst.m_ap_type == M_AP_OBJECT) { + if (U_AP_TYPE == M_AP_OBJECT) { Sprintf(bp, " %s", an(simple_typename(g.youmonst.mappearance))); - } else if (g.youmonst.m_ap_type == M_AP_FURNITURE) { + } else if (U_AP_TYPE == M_AP_FURNITURE) { Strcpy(bp, " something"); - } else if (g.youmonst.m_ap_type == M_AP_MONSTER) { + } else if (U_AP_TYPE == M_AP_MONSTER) { Strcpy(bp, " someone"); } else { ; /* something unexpected; leave 'buf' as-is */ diff --git a/src/detect.c b/src/detect.c index d0969b8d1..750bbd240 100644 --- a/src/detect.c +++ b/src/detect.c @@ -653,7 +653,7 @@ int class; /* an object class, 0 for all */ if (do_dknown) do_dknown_of(obj); } - if ((is_cursed && mtmp->m_ap_type == M_AP_OBJECT + if ((is_cursed && M_AP_TYPE(mtmp) == M_AP_OBJECT && (!class || class == objects[mtmp->mappearance].oc_class)) || (findgold(mtmp->minvent) && (!class || class == COIN_CLASS))) { ct++; @@ -728,7 +728,7 @@ int class; /* an object class, 0 for all */ break; } /* Allow a mimic to override the detected objects it is carrying. */ - if (is_cursed && mtmp->m_ap_type == M_AP_OBJECT + if (is_cursed && M_AP_TYPE(mtmp) == M_AP_OBJECT && (!class || class == objects[mtmp->mappearance].oc_class)) { struct obj temp; @@ -1467,7 +1467,7 @@ genericptr_t num; (*(int *) num)++; } } else if ((mtmp = m_at(zx, zy)) != 0) { - if (mtmp->m_ap_type) { + if (M_AP_TYPE(mtmp)) { seemimic(mtmp); (*(int *) num)++; } @@ -1631,7 +1631,7 @@ boolean via_warning; if (via_warning && !warning_of(mtmp)) return -1; - if (mtmp->m_ap_type) { + if (M_AP_TYPE(mtmp)) { seemimic(mtmp); found_something = TRUE; } else if (!canspotmon(mtmp)) { @@ -1860,7 +1860,7 @@ int default_glyph, which_subset; /* look for a mimic here posing as furniture; if we don't find one, we'll have to fake it */ if ((mtmp = m_at(x, y)) != 0 - && mtmp->m_ap_type == M_AP_FURNITURE) { + && M_AP_TYPE(mtmp) == M_AP_FURNITURE) { glyph = cmap_to_glyph(mtmp->mappearance); } else { /* we have a topology type but we want a screen diff --git a/src/display.c b/src/display.c index dfb379789..6d72d1d70 100644 --- a/src/display.c +++ b/src/display.c @@ -377,7 +377,7 @@ int sightflags; /* 1 if the monster is physically seen; 2 if detected using Detect_monsters */ xchar worm_tail; /* mon is actually a worm tail */ { - boolean mon_mimic = (mon->m_ap_type != M_AP_NOTHING); + boolean mon_mimic = (M_AP_TYPE(mon) != M_AP_NOTHING); int sensed = (mon_mimic && (Protection_from_shape_changers || sensemon(mon))); /* @@ -388,7 +388,7 @@ xchar worm_tail; /* mon is actually a worm tail */ */ if (mon_mimic && (sightflags == PHYSICALLY_SEEN)) { - switch (mon->m_ap_type) { + switch (M_AP_TYPE(mon)) { default: impossible("display_monster: bad m_ap_type value [ = %d ]", (int) mon->m_ap_type); diff --git a/src/do_name.c b/src/do_name.c index 25abdf5ee..0d59a32f7 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1146,8 +1146,8 @@ do_mname() if (!mtmp || (!sensemon(mtmp) && (!(cansee(cx, cy) || see_with_infrared(mtmp)) - || mtmp->mundetected || mtmp->m_ap_type == M_AP_FURNITURE - || mtmp->m_ap_type == M_AP_OBJECT + || mtmp->mundetected || M_AP_TYPE(mtmp) == M_AP_FURNITURE + || M_AP_TYPE(mtmp) == M_AP_OBJECT || (mtmp->minvis && !See_invisible)))) { pline("I see no monster there."); return; diff --git a/src/dogmove.c b/src/dogmove.c index 4831e03be..c6919458d 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -1364,7 +1364,7 @@ finish_meating(mtmp) struct monst *mtmp; { mtmp->meating = 0; - if (mtmp->m_ap_type && mtmp->mappearance && mtmp->cham == NON_PM) { + if (M_AP_TYPE(mtmp) && mtmp->mappearance && mtmp->cham == NON_PM) { /* was eating a mimic and now appearance needs resetting */ mtmp->m_ap_type = 0; mtmp->mappearance = 0; @@ -1418,15 +1418,15 @@ struct monst *mtmp; newsym(mtmp->mx, mtmp->my); You("%s %s %sappear%s where %s was!", cansee(mtmp->mx, mtmp->my) ? "see" : "sense that", - (mtmp->m_ap_type == M_AP_FURNITURE) + (M_AP_TYPE(mtmp) == M_AP_FURNITURE) ? an(defsyms[mtmp->mappearance].explanation) - : (mtmp->m_ap_type == M_AP_OBJECT + : (M_AP_TYPE(mtmp) == M_AP_OBJECT && OBJ_DESCR(objects[mtmp->mappearance])) ? an(OBJ_DESCR(objects[mtmp->mappearance])) - : (mtmp->m_ap_type == M_AP_OBJECT + : (M_AP_TYPE(mtmp) == M_AP_OBJECT && OBJ_NAME(objects[mtmp->mappearance])) ? an(OBJ_NAME(objects[mtmp->mappearance])) - : (mtmp->m_ap_type == M_AP_MONSTER) + : (M_AP_TYPE(mtmp) == M_AP_MONSTER) ? an(mons[mtmp->mappearance].mname) : something, cansee(mtmp->mx, mtmp->my) ? "" : "has ", diff --git a/src/dokick.c b/src/dokick.c index e98ad57bc..19a2a588b 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -58,7 +58,7 @@ boolean clumsy; return; } - if (mon->m_ap_type) + if (M_AP_TYPE(mon)) seemimic(mon); check_caitiff(mon); @@ -161,8 +161,8 @@ xchar x, y; /* reveal hidden target even if kick ends up missing (note: being hidden doesn't affect chance to hit so neither does this reveal) */ if (mon->mundetected - || (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER)) { - if (mon->m_ap_type) + || (M_AP_TYPE(mon) && M_AP_TYPE(mon) != M_AP_MONSTER)) { + if (M_AP_TYPE(mon)) seemimic(mon); mon->mundetected = 0; if (!canspotmon(mon)) diff --git a/src/dothrow.c b/src/dothrow.c index aad6ed8f6..3ddd65ff0 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -1485,7 +1485,7 @@ boolean maybe_wakeup; An attentive player will still notice that this is different from an arrow just landing short of any target (no message in that case), so will realize that there is a valid target here anyway. */ - if (!canseemon(mon) || (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER)) + if (!canseemon(mon) || (M_AP_TYPE(mon) && M_AP_TYPE(mon) != M_AP_MONSTER)) pline("%s %s.", The(missile), otense(obj, "miss")); else miss(missile, mon); diff --git a/src/dungeon.c b/src/dungeon.c index e740cea20..275bd14ea 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -2511,7 +2511,7 @@ recalc_mapseen() if (ltyp == DRAWBRIDGE_UP) ltyp = db_under_typ(levl[x][y].drawbridgemask); if ((mtmp = m_at(x, y)) != 0 - && mtmp->m_ap_type == M_AP_FURNITURE && canseemon(mtmp)) + && M_AP_TYPE(mtmp) == M_AP_FURNITURE && canseemon(mtmp)) ltyp = cmap_to_type(mtmp->mappearance); g.lastseentyp[x][y] = ltyp; } diff --git a/src/eat.c b/src/eat.c index 675b3ec43..fb14f1fc2 100644 --- a/src/eat.c +++ b/src/eat.c @@ -155,7 +155,7 @@ eatmdone(VOID_ARGS) free((genericptr_t) g.eatmbuf), g.eatmbuf = 0; } /* update display */ - if (g.youmonst.m_ap_type) { + if (U_AP_TYPE) { g.youmonst.m_ap_type = M_AP_NOTHING; newsym(u.ux, u.uy); } diff --git a/src/end.c b/src/end.c index cc801609a..d8637eba0 100644 --- a/src/end.c +++ b/src/end.c @@ -400,7 +400,7 @@ int how; ? &mons[mtmp->cham] : mptr); boolean distorted = (boolean) (Hallucination && canspotmon(mtmp)), - mimicker = (mtmp->m_ap_type == M_AP_MONSTER), + mimicker = (M_AP_TYPE(mtmp) == M_AP_MONSTER), imitator = (mptr != champtr || mimicker); You((how == STONING) ? "turn to stone..." : "die..."); diff --git a/src/hack.c b/src/hack.c index e6f332a22..18709fcb4 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1531,8 +1531,8 @@ domove_core() /* It's fine to displace pets, though */ /* We should never get here if forcefight */ if (g.context.run && ((!Blind && mon_visible(mtmp) - && ((mtmp->m_ap_type != M_AP_FURNITURE - && mtmp->m_ap_type != M_AP_OBJECT) + && ((M_AP_TYPE(mtmp) != M_AP_FURNITURE + && M_AP_TYPE(mtmp) != M_AP_OBJECT) || Protection_from_shape_changers)) || sensemon(mtmp))) { nomul(0); @@ -1572,7 +1572,7 @@ domove_core() */ if (g.context.nopick && !g.context.travel && (canspotmon(mtmp) || glyph_is_invisible(levl[x][y].glyph))) { - if (mtmp->m_ap_type && !Protection_from_shape_changers + if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers && !sensemon(mtmp)) stumble_onto_mimic(mtmp); else if (mtmp->mpeaceful && !Hallucination) @@ -1760,7 +1760,7 @@ domove_core() cancel the swap below (we can ignore steed mx,my here) */ u.ux = u.ux0, u.uy = u.uy0; mtmp->mundetected = 0; - if (mtmp->m_ap_type) + if (M_AP_TYPE(mtmp)) seemimic(mtmp); else if (!mtmp->mtame) newsym(mtmp->mx, mtmp->my); @@ -1864,8 +1864,8 @@ domove_core() * imitating something that doesn't move. We could extend this * to non-moving monsters... */ - if ((u.dx || u.dy) && (g.youmonst.m_ap_type == M_AP_OBJECT - || g.youmonst.m_ap_type == M_AP_FURNITURE)) + if ((u.dx || u.dy) && (U_AP_TYPE == M_AP_OBJECT + || U_AP_TYPE == M_AP_FURNITURE)) g.youmonst.m_ap_type = M_AP_NOTHING; check_leash(u.ux0, u.uy0); @@ -2654,8 +2654,8 @@ lookaround() continue; if ((mtmp = m_at(x, y)) != 0 - && mtmp->m_ap_type != M_AP_FURNITURE - && mtmp->m_ap_type != M_AP_OBJECT + && M_AP_TYPE(mtmp) != M_AP_FURNITURE + && M_AP_TYPE(mtmp) != M_AP_OBJECT && (!mtmp->minvis || See_invisible) && !mtmp->mundetected) { if ((g.context.run != 1 && !mtmp->mtame) || (x == u.ux + u.dx && y == u.uy + u.dy @@ -2837,8 +2837,8 @@ monster_nearby() for (y = u.uy - 1; y <= u.uy + 1; y++) { if (!isok(x, y) || (x == u.ux && y == u.uy)) continue; - if ((mtmp = m_at(x, y)) && mtmp->m_ap_type != M_AP_FURNITURE - && mtmp->m_ap_type != M_AP_OBJECT + if ((mtmp = m_at(x, y)) && M_AP_TYPE(mtmp) != M_AP_FURNITURE + && M_AP_TYPE(mtmp) != M_AP_OBJECT && (!mtmp->mpeaceful || Hallucination) && (!is_hider(mtmp->data) || !mtmp->mundetected) && !noattacks(mtmp->data) && mtmp->mcanmove diff --git a/src/lock.c b/src/lock.c index f84dd6bd7..6dbc39287 100644 --- a/src/lock.c +++ b/src/lock.c @@ -444,8 +444,8 @@ struct obj *pick; door = &levl[cc.x][cc.y]; mtmp = m_at(cc.x, cc.y); - if (mtmp && canseemon(mtmp) && mtmp->m_ap_type != M_AP_FURNITURE - && mtmp->m_ap_type != M_AP_OBJECT) { + if (mtmp && canseemon(mtmp) && M_AP_TYPE(mtmp) != M_AP_FURNITURE + && M_AP_TYPE(mtmp) != M_AP_OBJECT) { if (picktyp == CREDIT_CARD && (mtmp->isshk || mtmp->data == &mons[PM_ORACLE])) verbalize("No checks, no credit, no problem."); @@ -736,8 +736,8 @@ boolean quietly; { register struct monst *mtmp = m_at(x, y); - if (mtmp && mtmp->m_ap_type != M_AP_FURNITURE) { - if (mtmp->m_ap_type == M_AP_OBJECT) + if (mtmp && M_AP_TYPE(mtmp) != M_AP_FURNITURE) { + if (M_AP_TYPE(mtmp) == M_AP_OBJECT) goto objhere; if (!quietly) { if ((mtmp->mx != x) || (mtmp->my != y)) { diff --git a/src/mhitm.c b/src/mhitm.c index d5435961f..a7ec76da7 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -83,9 +83,9 @@ struct attack *mattk; map_invisible(magr->mx, magr->my); if (!canspotmon(mdef)) map_invisible(mdef->mx, mdef->my); - if (mdef->m_ap_type) + if (M_AP_TYPE(mdef)) seemimic(mdef); - if (magr->m_ap_type) + if (M_AP_TYPE(magr)) seemimic(magr); fmt = (could_seduce(magr, mdef, mattk) && !magr->mcan) ? "%s pretends to be friendly to" @@ -214,7 +214,7 @@ boolean quietly; /* undetected monster becomes un-hidden if it is displaced */ if (mdef->mundetected) mdef->mundetected = 0; - if (mdef->m_ap_type && mdef->m_ap_type != M_AP_MONSTER) + if (M_AP_TYPE(mdef) && M_AP_TYPE(mdef) != M_AP_MONSTER) seemimic(mdef); /* wake up the displaced defender */ mdef->msleeping = 0; @@ -532,9 +532,9 @@ struct attack *mattk; map_invisible(magr->mx, magr->my); if (!canspotmon(mdef)) map_invisible(mdef->mx, mdef->my); - if (mdef->m_ap_type) + if (M_AP_TYPE(mdef)) seemimic(mdef); - if (magr->m_ap_type) + if (M_AP_TYPE(magr)) seemimic(magr); if ((compat = could_seduce(magr, mdef, mattk)) && !magr->mcan) { Sprintf(buf, "%s %s", Monnam(magr), @@ -588,7 +588,7 @@ struct attack *mattk; if (g.vis) { if (mdef->data->mlet == S_MIMIC - && mdef->m_ap_type != M_AP_NOTHING) + && M_AP_TYPE(mdef) != M_AP_NOTHING) seemimic(mdef); Sprintf(buf, "%s gazes at", Monnam(magr)); pline("%s %s...", buf, diff --git a/src/mhitu.c b/src/mhitu.c index a70bc70b6..55efd9d92 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -521,7 +521,7 @@ register struct monst *mtmp; } /* hero might be a mimic, concealed via #monster */ - if (g.youmonst.data->mlet == S_MIMIC && g.youmonst.m_ap_type && !range2 + if (youmonst.data->mlet == S_MIMIC && U_AP_TYPE && !range2 && foundyou && !u.uswallow) { boolean sticky = sticks(g.youmonst.data); @@ -541,7 +541,7 @@ register struct monst *mtmp; } /* non-mimic hero might be mimicking an object after eating m corpse */ - if (g.youmonst.m_ap_type == M_AP_OBJECT && !range2 && foundyou + if (U_AP_TYPE == M_AP_OBJECT && !range2 && foundyou && !u.uswallow) { if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); diff --git a/src/mon.c b/src/mon.c index 406136bd9..c0cb31941 100644 --- a/src/mon.c +++ b/src/mon.c @@ -797,8 +797,8 @@ movemon() /* unwatched mimics and piercers may hide again [MRS] */ if (restrap(mtmp)) continue; - if (mtmp->m_ap_type == M_AP_FURNITURE - || mtmp->m_ap_type == M_AP_OBJECT) + if (M_AP_TYPE(mtmp) == M_AP_FURNITURE + || M_AP_TYPE(mtmp) == M_AP_OBJECT) continue; if (mtmp->mundetected) continue; @@ -1680,7 +1680,7 @@ struct monst **monst_list; /* &g.migrating_mons or &g.mydogs or null */ clone can continue imitating some other monster form); also, might be imitating a boulder so need line-of-sight unblocking */ mon->mundetected = 0; - if (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER) + if (M_AP_TYPE(mon) && M_AP_TYPE(mon) != M_AP_MONSTER) seemimic(mon); } @@ -1819,7 +1819,7 @@ struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */ } if (emits_light(mptr)) del_light_source(LS_MONSTER, monst_to_any(mtmp)); - if (mtmp->m_ap_type) + if (M_AP_TYPE(mtmp)) seemimic(mtmp); if (onmap) newsym(mtmp->mx, mtmp->my); @@ -2868,7 +2868,7 @@ register struct monst *mtmp; boolean via_attack; { mtmp->msleeping = 0; - if (mtmp->m_ap_type) { + if (M_AP_TYPE(mtmp)) { seemimic(mtmp); } else if (g.context.forcefight && !g.context.mon_moving && mtmp->mundetected) { @@ -2956,7 +2956,7 @@ rescham() } if (is_were(mtmp->data) && mtmp->data->mlet != S_HUMAN) new_were(mtmp); - if (mtmp->m_ap_type && cansee(mtmp->mx, mtmp->my)) { + if (M_AP_TYPE(mtmp) && cansee(mtmp->mx, mtmp->my)) { seemimic(mtmp); /* we pretend that the mimic doesn't know that it has been unmasked */ @@ -3013,7 +3013,7 @@ register struct monst *mtmp; { struct trap *t; - if (mtmp->mcan || mtmp->m_ap_type || cansee(mtmp->mx, mtmp->my) + if (mtmp->mcan || M_AP_TYPE(mtmp) || cansee(mtmp->mx, mtmp->my) || rn2(3) || mtmp == u.ustuck /* can't hide while trapped except in pits */ || (mtmp->mtrapped && (t = t_at(mtmp->mx, mtmp->my)) != 0 @@ -3074,7 +3074,7 @@ struct monst *mon; boolean hider_under = hides_under(mon->data) || mon->data->mlet == S_EEL; if ((is_hider(mon->data) || hider_under) - && !(mon->mundetected || mon->m_ap_type)) { + && !(mon->mundetected || M_AP_TYPE(mon))) { xchar x = mon->mx, y = mon->my; char save_viz = g.viz_array[y][x]; @@ -3083,7 +3083,7 @@ struct monst *mon; 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) + if (mon->data->mlet == S_MIMIC && !M_AP_TYPE(mon)) (void) restrap(mon); if (hider_under) (void) hideunder(mon); @@ -3546,7 +3546,7 @@ boolean msg; /* "The oldmon turns into a newmon!" */ wormgone(mtmp); place_monster(mtmp, mtmp->mx, mtmp->my); } - if (mtmp->m_ap_type && mdat->mlet != S_MIMIC) + if (M_AP_TYPE(mtmp) && mdat->mlet != S_MIMIC) seemimic(mtmp); /* revert to normal monster */ /* (this code used to try to adjust the monster's health based on @@ -3935,7 +3935,7 @@ short otyp; { short ap = mtmp->mappearance; - switch (mtmp->m_ap_type) { + switch (M_AP_TYPE(mtmp)) { case M_AP_NOTHING: case M_AP_FURNITURE: case M_AP_MONSTER: diff --git a/src/monmove.c b/src/monmove.c index b4636bb5c..9bbf10cfb 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -229,8 +229,8 @@ register struct monst *mtmp; || mtmp->data->mlet == S_LEPRECHAUN) || !rn2(50)) && (Aggravate_monster || (mtmp->data->mlet == S_DOG || mtmp->data->mlet == S_HUMAN) - || (!rn2(7) && mtmp->m_ap_type != M_AP_FURNITURE - && mtmp->m_ap_type != M_AP_OBJECT))) { + || (!rn2(7) && M_AP_TYPE(mtmp) != M_AP_FURNITURE + && M_AP_TYPE(mtmp) != M_AP_OBJECT))) { mtmp->msleeping = 0; return 1; } @@ -329,8 +329,8 @@ boolean fleemsg; mtmp->mfleetim = (unsigned) min(fleetime, 127); } if (!mtmp->mflee && fleemsg && canseemon(mtmp) - && mtmp->m_ap_type != M_AP_FURNITURE - && mtmp->m_ap_type != M_AP_OBJECT) { + && M_AP_TYPE(mtmp) != M_AP_FURNITURE + && M_AP_TYPE(mtmp) != M_AP_OBJECT) { /* unfortunately we can't distinguish between temporary sleep and temporary paralysis, so both conditions receive the same alternate message */ diff --git a/src/mthrowu.c b/src/mthrowu.c index a4e30760d..aa01fc7a7 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -305,7 +305,7 @@ boolean verbose; /* give message(s) even when you can't see what happened */ struct obj *mon_launcher = g.marcher ? MON_WEP(g.marcher) : NULL; g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); - ismimic = mtmp->m_ap_type && mtmp->m_ap_type != M_AP_MONSTER; + ismimic = M_AP_TYPE(mtmp) && M_AP_TYPE(mtmp) != M_AP_MONSTER; vis = cansee(g.bhitpos.x, g.bhitpos.y); tmp = 5 + find_mac(mtmp) + omon_adj(mtmp, otmp, FALSE); @@ -1065,8 +1065,8 @@ register struct monst *mtmp; /* hero concealment usually trumps monst awareness of being lined up */ if (Upolyd && rn2(25) - && (u.uundetected || (g.youmonst.m_ap_type != M_AP_NOTHING - && g.youmonst.m_ap_type != M_AP_MONSTER))) + && (u.uundetected || (U_AP_TYPE != M_AP_NOTHING + && U_AP_TYPE != M_AP_MONSTER))) return FALSE; ignore_boulders = (throws_rocks(mtmp->data) diff --git a/src/objnam.c b/src/objnam.c index a88a390e6..ea28a3289 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -4106,7 +4106,7 @@ const char * mimic_obj_name(mtmp) struct monst *mtmp; { - if (mtmp->m_ap_type == M_AP_OBJECT) { + if (M_AP_TYPE(mtmp) == M_AP_OBJECT) { if (mtmp->mappearance == GOLD_PIECE) return "gold"; if (mtmp->mappearance != STRANGE_OBJECT) diff --git a/src/pager.c b/src/pager.c index 3475ccf4b..e0058371b 100644 --- a/src/pager.c +++ b/src/pager.c @@ -89,7 +89,7 @@ char *outbuf; mons[u.umonnum].mname, g.plname); if (u.usteed) Sprintf(eos(outbuf), ", mounted on %s", y_monnam(u.usteed)); - if (u.uundetected || (Upolyd && g.youmonst.m_ap_type)) + if (u.uundetected || (Upolyd && U_AP_TYPE)) mhidden_description(&g.youmonst, FALSE, eos(outbuf)); return outbuf; } @@ -109,12 +109,12 @@ char *outbuf; : glyph_at(x, y); *outbuf = '\0'; - if (mon->m_ap_type == M_AP_FURNITURE - || mon->m_ap_type == M_AP_OBJECT) { + if (M_AP_TYPE(mon) == M_AP_FURNITURE + || M_AP_TYPE(mon) == M_AP_OBJECT) { Strcpy(outbuf, ", mimicking "); - if (mon->m_ap_type == M_AP_FURNITURE) { + if (M_AP_TYPE(mon) == M_AP_FURNITURE) { Strcat(outbuf, an(defsyms[mon->mappearance].explanation)); - } else if (mon->m_ap_type == M_AP_OBJECT + } else if (M_AP_TYPE(mon) == M_AP_OBJECT /* remembered glyph, not glyph_at() which is 'mon' */ && glyph_is_object(glyph)) { objfrommap: @@ -130,7 +130,7 @@ char *outbuf; } else { Strcat(outbuf, something); } - } else if (mon->m_ap_type == M_AP_MONSTER) { + } else if (M_AP_TYPE(mon) == M_AP_MONSTER) { if (altmon) Sprintf(outbuf, ", masquerading as %s", an(mons[mon->mappearance].mname)); @@ -160,7 +160,7 @@ object_from_map(glyph, x, y, obj_p) int glyph, x, y; struct obj **obj_p; { - boolean fakeobj = FALSE; + boolean fakeobj = FALSE, mimic_obj = FALSE; struct monst *mtmp; struct obj *otmp; int glyphotyp = glyph_to_obj(glyph); @@ -174,9 +174,10 @@ struct obj **obj_p; /* there might be a mimic here posing as an object */ mtmp = m_at(x, y); - if (mtmp && is_obj_mappear(mtmp, (unsigned) glyphotyp)) + if (mtmp && is_obj_mappear(mtmp, (unsigned) glyphotyp)) { otmp = 0; - else + mimic_obj = TRUE; + } else mtmp = 0; if (!otmp || otmp->otyp != glyphotyp) { @@ -214,7 +215,11 @@ struct obj **obj_p; /* terrain mode views what's already known, doesn't learn new stuff */ && !iflags.terrainmode) /* so don't set dknown when in terrain mode */ otmp->dknown = 1; /* if a pile, clearly see the top item only */ - + if (fakeobj && mtmp && mimic_obj && + (otmp->dknown || (M_AP_FLAG(mtmp) & M_AP_F_DKNOWN))) { + mtmp->m_ap_type |= M_AP_F_DKNOWN; + otmp->dknown = 1; + } *obj_p = otmp; return fakeobj; /* when True, caller needs to dealloc *obj_p */ } @@ -299,7 +304,7 @@ int x, y; /* we know the hero sees a monster at this location, but if it's shown due to persistant monster detection he might remember something else */ - if (mtmp->mundetected || mtmp->m_ap_type) + if (mtmp->mundetected || M_AP_TYPE(mtmp)) mhidden_description(mtmp, FALSE, eos(buf)); if (monbuf) { diff --git a/src/polyself.c b/src/polyself.c index d48b07c54..1d623bdd9 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -158,7 +158,7 @@ polyman(fmt, arg) const char *fmt, *arg; { boolean sticky = (sticks(g.youmonst.data) && u.ustuck && !u.uswallow), - was_mimicking = (g.youmonst.m_ap_type == M_AP_OBJECT); + was_mimicking = (U_AP_TYPE == M_AP_OBJECT); boolean was_blind = !!Blind; if (Upolyd) { @@ -621,7 +621,7 @@ int mntmp; } /* if stuck mimicking gold, stop immediately */ - if (g.multi < 0 && g.youmonst.m_ap_type == M_AP_OBJECT + if (multi < 0 && U_AP_TYPE == M_AP_OBJECT && g.youmonst.data->mlet != S_MIMIC) unmul(""); /* if becoming a non-mimic, stop mimicking anything */ @@ -1319,8 +1319,8 @@ dogaze() pline("%s seems not to notice your gaze.", Monnam(mtmp)); } else if (mtmp->minvis && !See_invisible) { You_cant("see where to gaze at %s.", Monnam(mtmp)); - } else if (mtmp->m_ap_type == M_AP_FURNITURE - || mtmp->m_ap_type == M_AP_OBJECT) { + } else if (M_AP_TYPE(mtmp) == M_AP_FURNITURE + || M_AP_TYPE(mtmp) == M_AP_OBJECT) { looked--; continue; } else if (flags.safe_dog && mtmp->mtame && !Confusion) { @@ -1428,7 +1428,7 @@ dohide() : (humanoid(u.ustuck->data) ? "holding someone" : "holding that creature")); if (u.uundetected - || (ismimic && g.youmonst.m_ap_type != M_AP_NOTHING)) { + || (ismimic && U_AP_TYPE != M_AP_NOTHING)) { u.uundetected = 0; g.youmonst.m_ap_type = M_AP_NOTHING; newsym(u.ux, u.uy); @@ -1466,7 +1466,7 @@ dohide() * else make youhiding() give smarter messages at such spots. */ - if (u.uundetected || (ismimic && g.youmonst.m_ap_type != M_AP_NOTHING)) { + if (u.uundetected || (ismimic && U_AP_TYPE != M_AP_NOTHING)) { youhiding(FALSE, 1); /* "you are already hiding" */ return 0; } diff --git a/src/shk.c b/src/shk.c index a9daacd50..0eab496c1 100644 --- a/src/shk.c +++ b/src/shk.c @@ -516,8 +516,8 @@ deserted_shop(enterstring) continue; if ((mtmp = m_at(x, y)) != 0) { ++n; - if (sensemon(mtmp) || ((mtmp->m_ap_type == M_AP_NOTHING - || mtmp->m_ap_type == M_AP_MONSTER) + if (sensemon(mtmp) || ((M_AP_TYPE(mtmp) == M_AP_NOTHING + || M_AP_TYPE(mtmp) == M_AP_MONSTER) && canseemon(mtmp))) ++m; } diff --git a/src/sounds.c b/src/sounds.c index 95b81e4d1..83c1e121a 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1059,8 +1059,8 @@ dochat() return 0; } - if (!mtmp || mtmp->mundetected || mtmp->m_ap_type == M_AP_FURNITURE - || mtmp->m_ap_type == M_AP_OBJECT) + if (!mtmp || mtmp->mundetected || M_AP_TYPE(mtmp) == M_AP_FURNITURE + || M_AP_TYPE(mtmp) == M_AP_OBJECT) return 0; /* sleeping monsters won't talk, except priests (who wake up) */ diff --git a/src/steed.c b/src/steed.c index 5059fcb5d..2186030ba 100644 --- a/src/steed.c +++ b/src/steed.c @@ -238,8 +238,8 @@ boolean force; /* Quietly force this animal */ /* Can the player reach and see the monster? */ if (!mtmp || (!force && ((Blind && !Blind_telepat) || mtmp->mundetected - || mtmp->m_ap_type == M_AP_FURNITURE - || mtmp->m_ap_type == M_AP_OBJECT))) { + || M_AP_TYPE(mtmp) == M_AP_FURNITURE + || M_AP_TYPE(mtmp) == M_AP_OBJECT))) { pline("I see nobody there."); return (FALSE); } diff --git a/src/trap.c b/src/trap.c index 67dc4ed6c..6ad7667cb 100644 --- a/src/trap.c +++ b/src/trap.c @@ -629,7 +629,7 @@ int *fail_reason; if (has_oname(statue) && !unique_corpstat(mon->data)) mon = christen_monst(mon, ONAME(statue)); /* mimic statue becomes seen mimic; other hiders won't be hidden */ - if (mon->m_ap_type) + if (M_AP_TYPE(mon)) seemimic(mon); else mon->mundetected = FALSE; @@ -4423,8 +4423,8 @@ boolean force; return 1; } if ((mtmp = m_at(x, y)) != 0 - && (mtmp->m_ap_type == M_AP_FURNITURE - || mtmp->m_ap_type == M_AP_OBJECT)) { + && (M_AP_TYPE(mtmp) == M_AP_FURNITURE + || M_AP_TYPE(mtmp) == M_AP_OBJECT)) { stumble_onto_mimic(mtmp); return 1; } diff --git a/src/uhitm.c b/src/uhitm.c index 63e43d1ed..da9893206 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -141,7 +141,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ /* if it was an invisible mimic, treat it as if we stumbled * onto a visible mimic */ - if (mtmp->m_ap_type && !Protection_from_shape_changers + if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers /* applied pole-arm attack is too far to get stuck */ && distu(mtmp->mx, mtmp->my) <= 2) { if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK)) @@ -157,7 +157,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ return TRUE; } - if (mtmp->m_ap_type && !Protection_from_shape_changers && !sensemon(mtmp) + if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers && !sensemon(mtmp) && !glyph_is_warning(glyph)) { /* If a hidden mimic was in a square where a player remembers * some (probably different) unseen monster, the player is in @@ -199,7 +199,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ * make sure to wake up a monster from the above cases if the * hero can sense that the monster is there. */ - if ((mtmp->mundetected || mtmp->m_ap_type) && sensemon(mtmp)) { + if ((mtmp->mundetected || M_AP_TYPE(mtmp)) && sensemon(mtmp)) { mtmp->mundetected = 0; wakeup(mtmp, TRUE); } @@ -2988,7 +2988,7 @@ struct monst *mtmp; if (Blind) { if (!Blind_telepat) what = generic; /* with default fmt */ - else if (mtmp->m_ap_type == M_AP_MONSTER) + else if (M_AP_TYPE(mtmp) == M_AP_MONSTER) what = a_monnam(mtmp); /* differs from what was sensed */ } else { int glyph = levl[u.ux + u.dx][u.uy + u.dy].glyph; diff --git a/src/vault.c b/src/vault.c index 91b8d8e9b..6362b9c34 100644 --- a/src/vault.c +++ b/src/vault.c @@ -412,8 +412,8 @@ invault() mongone(guard); return; } - if (g.youmonst.m_ap_type == M_AP_OBJECT || u.uundetected) { - if (g.youmonst.m_ap_type == M_AP_OBJECT + if (U_AP_TYPE == M_AP_OBJECT || u.uundetected) { + if (U_AP_TYPE == M_AP_OBJECT && g.youmonst.mappearance != GOLD_PIECE) if (!Deaf) verbalize("Hey! Who left that %s in here?", diff --git a/src/zap.c b/src/zap.c index 053d377fc..755fcc4d2 100644 --- a/src/zap.c +++ b/src/zap.c @@ -136,7 +136,7 @@ struct obj *otmp; const char *zap_type_text = "spell"; struct obj *obj; boolean disguised_mimic = (mtmp->data->mlet == S_MIMIC - && mtmp->m_ap_type != M_AP_NOTHING); + && M_AP_TYPE(mtmp) != M_AP_NOTHING); if (u.uswallow && mtmp == u.ustuck) reveal_invis = FALSE; @@ -453,7 +453,7 @@ struct obj *otmp; m_respond(mtmp); if (mtmp->isshk && !*u.ushops) hot_pursuit(mtmp); - } else if (mtmp->m_ap_type) + } else if (M_AP_TYPE(mtmp)) seemimic(mtmp); /* might unblock if mimicing a boulder/door */ } /* note: g.bhitpos won't be set if swallowed, but that's okay since @@ -818,7 +818,7 @@ boolean by_hero; mtmp->mundetected = 0; newsym(mtmp->mx, mtmp->my); } - if (mtmp->m_ap_type) + if (M_AP_TYPE(mtmp)) seemimic(mtmp); one_of = (corpse->quan > 1L); @@ -2747,7 +2747,7 @@ boolean youattack, allow_cancel_kill, self_cancel; } else { mdef->mcan = 1; /* force shapeshifter into its base form */ - if (mdef->m_ap_type != M_AP_NOTHING) + if (M_AP_TYPE(mdef) != M_AP_NOTHING) seemimic(mdef); /* [not 'else if'; chameleon might have been hiding as a mimic] */ if (mdef->cham >= LOW_PM) {