preserve dknown field between fakeobj instances

Preserve temporary fake object's previous dknown value by storing it
as a flag value within the m_ap_type field of the posing monster, and
recalling it when it is needed.

This is intended to help eliminate observable differences in price display
between real objects and mimics posing as objects.

98% of this is just switching the code to utilize macro M_AP_TYPE(mon)
everywhere to ensure that the flag bits are stripped off when needed.
This commit is contained in:
nhmall
2019-04-22 14:17:18 -04:00
parent cd6b5ef933
commit dcf4da2150
30 changed files with 127 additions and 115 deletions
+4 -4
View File
@@ -215,13 +215,13 @@
#define display_self() \
show_glyph(u.ux, u.uy, \
maybe_display_usteed((youmonst.m_ap_type == M_AP_NOTHING) \
maybe_display_usteed((U_AP_TYPE == M_AP_NOTHING) \
? hero_glyph \
: (youmonst.m_ap_type == M_AP_FURNITURE) \
: (U_AP_TYPE == M_AP_FURNITURE) \
? cmap_to_glyph(youmonst.mappearance) \
: (youmonst.m_ap_type == M_AP_OBJECT) \
: (U_AP_TYPE == M_AP_OBJECT) \
? objnum_to_glyph(youmonst.mappearance) \
/* else M_AP_MONSTER */ \
/* else U_AP_TYPE == M_AP_MONSTER */ \
: monnum_to_glyph(youmonst.mappearance)))
/*
+11 -4
View File
@@ -47,9 +47,16 @@ enum m_ap_types {
M_AP_NOTHING = 0, /* mappearance unused--monster appears as itself */
M_AP_FURNITURE = 1, /* stairs, a door, an altar, etc. */
M_AP_OBJECT = 2, /* an object */
M_AP_MONSTER = 3 /* a monster; mostly used for cloned Wizard */
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 (youmonst.m_ap_type & M_AP_TYPMASK)
#define U_AP_FLAG (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 */
+4 -4
View File
@@ -384,7 +384,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;
@@ -486,7 +486,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);
@@ -2109,7 +2109,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) {
@@ -2840,7 +2840,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
+5 -5
View File
@@ -2272,7 +2272,7 @@ int final;
: surface(u.ux, u.uy)); /* catchall; shouldn't happen */
you_are(buf, from_what(WWALKING));
}
if (Upolyd && (u.uundetected || 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 */
@@ -3094,16 +3094,16 @@ int msgflag; /* for variant message phrasing */
char *bp, buf[BUFSZ];
Strcpy(buf, "hiding");
if (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 (youmonst.m_ap_type == M_AP_OBJECT) {
if (U_AP_TYPE == M_AP_OBJECT) {
Sprintf(bp, " %s", an(simple_typename(youmonst.mappearance)));
} else if (youmonst.m_ap_type == M_AP_FURNITURE) {
} else if (U_AP_TYPE == M_AP_FURNITURE) {
Strcpy(bp, " something");
} else if (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 */
+5 -5
View File
@@ -655,7 +655,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++;
@@ -730,7 +730,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;
@@ -1469,7 +1469,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)++;
}
@@ -1633,7 +1633,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)) {
@@ -1862,7 +1862,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
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -1149,8 +1149,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;
+5 -5
View File
@@ -1361,7 +1361,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;
@@ -1415,15 +1415,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 ",
+3 -3
View File
@@ -63,7 +63,7 @@ boolean clumsy;
return;
}
if (mon->m_ap_type)
if (M_AP_TYPE(mon))
seemimic(mon);
check_caitiff(mon);
@@ -166,8 +166,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))
+1 -1
View File
@@ -1487,7 +1487,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);
+1 -1
View File
@@ -2516,7 +2516,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);
lastseentyp[x][y] = ltyp;
}
+1 -1
View File
@@ -161,7 +161,7 @@ eatmdone(VOID_ARGS)
free((genericptr_t) eatmbuf), eatmbuf = 0;
}
/* update display */
if (youmonst.m_ap_type) {
if (U_AP_TYPE) {
youmonst.m_ap_type = M_AP_NOTHING;
newsym(u.ux, u.uy);
}
+1 -1
View File
@@ -421,7 +421,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...");
+10 -10
View File
@@ -1533,8 +1533,8 @@ domove_core()
/* It's fine to displace pets, though */
/* We should never get here if forcefight */
if (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);
@@ -1574,7 +1574,7 @@ domove_core()
*/
if (context.nopick && !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)
@@ -1762,7 +1762,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);
@@ -1866,8 +1866,8 @@ domove_core()
* imitating something that doesn't move. We could extend this
* to non-moving monsters...
*/
if ((u.dx || u.dy) && (youmonst.m_ap_type == M_AP_OBJECT
|| youmonst.m_ap_type == M_AP_FURNITURE))
if ((u.dx || u.dy) && (U_AP_TYPE == M_AP_OBJECT
|| U_AP_TYPE == M_AP_FURNITURE))
youmonst.m_ap_type = M_AP_NOTHING;
check_leash(u.ux0, u.uy0);
@@ -2655,8 +2655,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 ((context.run != 1 && !mtmp->mtame)
|| (x == u.ux + u.dx && y == u.uy + u.dy
@@ -2838,8 +2838,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
+4 -4
View File
@@ -453,8 +453,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.");
@@ -745,8 +745,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)) {
+6 -6
View File
@@ -94,9 +94,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"
@@ -225,7 +225,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;
@@ -543,9 +543,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),
@@ -599,7 +599,7 @@ struct attack *mattk;
if (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,
+2 -2
View File
@@ -525,7 +525,7 @@ register struct monst *mtmp;
}
/* hero might be a mimic, concealed via #monster */
if (youmonst.data->mlet == S_MIMIC && youmonst.m_ap_type && !range2
if (youmonst.data->mlet == S_MIMIC && U_AP_TYPE && !range2
&& foundyou && !u.uswallow) {
boolean sticky = sticks(youmonst.data);
@@ -545,7 +545,7 @@ register struct monst *mtmp;
}
/* non-mimic hero might be mimicking an object after eating m corpse */
if (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);
+11 -11
View File
@@ -799,8 +799,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;
@@ -1682,7 +1682,7 @@ struct monst **monst_list; /* &migrating_mons or &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);
}
@@ -1821,7 +1821,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);
@@ -2870,7 +2870,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 (context.forcefight && !context.mon_moving
&& mtmp->mundetected) {
@@ -2958,7 +2958,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 */
@@ -3015,7 +3015,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
@@ -3076,7 +3076,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 = viz_array[y][x];
@@ -3085,7 +3085,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);
@@ -3551,7 +3551,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
@@ -3940,7 +3940,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:
+4 -4
View File
@@ -231,8 +231,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;
}
@@ -289,8 +289,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 */
+3 -3
View File
@@ -313,7 +313,7 @@ boolean verbose; /* give message(s) even when you can't see what happened */
struct obj *mon_launcher = archer ? MON_WEP(archer) : NULL;
notonhead = (bhitpos.x != mtmp->mx || 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(bhitpos.x, bhitpos.y);
tmp = 5 + find_mac(mtmp) + omon_adj(mtmp, otmp, FALSE);
@@ -1073,8 +1073,8 @@ register struct monst *mtmp;
/* hero concealment usually trumps monst awareness of being lined up */
if (Upolyd && rn2(25)
&& (u.uundetected || (youmonst.m_ap_type != M_AP_NOTHING
&& 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)
+1 -1
View File
@@ -4111,7 +4111,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)
+16 -11
View File
@@ -89,7 +89,7 @@ char *outbuf;
mons[u.umonnum].mname, plname);
if (u.usteed)
Sprintf(eos(outbuf), ", mounted on %s", y_monnam(u.usteed));
if (u.uundetected || (Upolyd && youmonst.m_ap_type))
if (u.uundetected || (Upolyd && U_AP_TYPE))
mhidden_description(&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) {
+6 -6
View File
@@ -162,7 +162,7 @@ polyman(fmt, arg)
const char *fmt, *arg;
{
boolean sticky = (sticks(youmonst.data) && u.ustuck && !u.uswallow),
was_mimicking = (youmonst.m_ap_type == M_AP_OBJECT);
was_mimicking = (U_AP_TYPE == M_AP_OBJECT);
boolean was_blind = !!Blind;
if (Upolyd) {
@@ -625,7 +625,7 @@ int mntmp;
}
/* if stuck mimicking gold, stop immediately */
if (multi < 0 && youmonst.m_ap_type == M_AP_OBJECT
if (multi < 0 && U_AP_TYPE == M_AP_OBJECT
&& youmonst.data->mlet != S_MIMIC)
unmul("");
/* if becoming a non-mimic, stop mimicking anything */
@@ -1323,8 +1323,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) {
@@ -1432,7 +1432,7 @@ dohide()
: (humanoid(u.ustuck->data) ? "holding someone"
: "holding that creature"));
if (u.uundetected
|| (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) {
|| (ismimic && U_AP_TYPE != M_AP_NOTHING)) {
u.uundetected = 0;
youmonst.m_ap_type = M_AP_NOTHING;
newsym(u.ux, u.uy);
@@ -1470,7 +1470,7 @@ dohide()
* else make youhiding() give smarter messages at such spots.
*/
if (u.uundetected || (ismimic && 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;
}
+2 -2
View File
@@ -517,8 +517,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;
}
+2 -2
View File
@@ -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) */
+2 -2
View File
@@ -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);
}
+3 -3
View File
@@ -632,7 +632,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;
@@ -4444,8 +4444,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;
}
+4 -4
View File
@@ -146,7 +146,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))
@@ -162,7 +162,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
@@ -204,7 +204,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);
}
@@ -2993,7 +2993,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;
+2 -2
View File
@@ -412,8 +412,8 @@ invault()
mongone(guard);
return;
}
if (youmonst.m_ap_type == M_AP_OBJECT || u.uundetected) {
if (youmonst.m_ap_type == M_AP_OBJECT
if (U_AP_TYPE == M_AP_OBJECT || u.uundetected) {
if (U_AP_TYPE == M_AP_OBJECT
&& youmonst.mappearance != GOLD_PIECE)
if (!Deaf)
verbalize("Hey! Who left that %s in here?",
+4 -4
View File
@@ -144,7 +144,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;
@@ -461,7 +461,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: bhitpos won't be set if swallowed, but that's okay since
@@ -826,7 +826,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);
@@ -2755,7 +2755,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) {