#terrain update
Make the post-3.4.3 '#terrain' command be more versatile by allowing the player to choose between floor-only, floor+traps, and floor+traps+objects so that it is possible to view known traps covered by objects or monsters and remembered objects covered by monsters. The extra explore mode and wizard mode choices aren't affected.
This commit is contained in:
111
src/detect.c
111
src/detect.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 detect.c $NHDT-Date: 1431472031 2015/05/12 23:07:11 $ $NHDT-Branch: master $:$NHDT-Revision: 1.56 $ */
|
||||
/* NetHack 3.6 detect.c $NHDT-Date: 1432252377 2015/05/21 23:52:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.57 $ */
|
||||
/* NetHack 3.6 detect.c $Date: 2012/04/16 02:05:40 $ $Revision: 1.47 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1469,50 +1469,113 @@ sokoban_detect()
|
||||
/* idea from crawl; show known portion of map without any monsters,
|
||||
objects, or traps occluding the view of the underlying terrain */
|
||||
void
|
||||
reveal_terrain(full)
|
||||
boolean full; /* wizard|explore modes allow player to request full map */
|
||||
reveal_terrain(full, which_subset)
|
||||
int full; /* wizard|explore modes allow player to request full map */
|
||||
int which_subset; /* when not full, whether to suppress objs and/or traps */
|
||||
{
|
||||
int x, y, glyph, S_stone_glyph;
|
||||
uchar seenv;
|
||||
unsigned save_swallowed;
|
||||
struct monst *mtmp;
|
||||
|
||||
if ((Hallucination || Stunned || Confusion) && !full) {
|
||||
You("are too disoriented for this.");
|
||||
} else {
|
||||
int x, y, glyph, levl_glyph, default_glyph;
|
||||
uchar seenv;
|
||||
unsigned save_swallowed;
|
||||
struct monst *mtmp;
|
||||
struct trap *t;
|
||||
char buf[BUFSZ];
|
||||
boolean keep_traps = (which_subset & 1) !=0,
|
||||
keep_objs = (which_subset & 2) != 0,
|
||||
keep_mons = (which_subset & 4) != 0; /* actually always 0 */
|
||||
|
||||
save_swallowed = u.uswallow;
|
||||
iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
|
||||
u.uinwater = u.uburied = 0;
|
||||
u.uswallow = 0;
|
||||
S_stone_glyph = cmap_to_glyph(S_stone);
|
||||
/* rewrite the map, displaying map background for seen spots
|
||||
(all spots seen if 'full') and stone everywhere else */
|
||||
default_glyph = cmap_to_glyph(level.flags.arboreal ? S_tree : S_stone);
|
||||
/* for 'full', show the actual terrain for the entire level,
|
||||
otherwise what the hero remembers for seen locations with
|
||||
monsters, objects, and/or traps removed as caller dictates */
|
||||
for (x = 1; x < COLNO; x++)
|
||||
for (y = 0; y < ROWNO; y++) {
|
||||
seenv = levl[x][y].seenv;
|
||||
seenv = (full || level.flags.hero_memory)
|
||||
? levl[x][y].seenv : cansee(x, y) ? SVALL : 0;
|
||||
if (full) {
|
||||
levl[x][y].seenv = SVALL;
|
||||
glyph = back_to_glyph(x, y);
|
||||
levl[x][y].seenv = seenv;
|
||||
} else {
|
||||
if (!level.flags.hero_memory && !cansee(x, y))
|
||||
seenv = 0;
|
||||
glyph = seenv ? back_to_glyph(x, y) : S_stone_glyph;
|
||||
/* need to show mimic-as-furniture so that #terrain can't
|
||||
be used to spot mimics, but this is only approximate;
|
||||
mimic might have moved and hid here after the player
|
||||
last saw this spot as some other type of terrain */
|
||||
if (seenv && (mtmp = m_at(x, y)) != 0
|
||||
&& mtmp->m_ap_type == M_AP_FURNITURE)
|
||||
glyph = cmap_to_glyph(mtmp->mappearance);
|
||||
levl_glyph = level.flags.hero_memory ? levl[x][y].glyph
|
||||
: seenv ? back_to_glyph(x, y) : default_glyph;
|
||||
/* glyph_at() returns the displayed glyph, which might
|
||||
be a monster. levl[][].glyph contains the remembered
|
||||
glyph, which will never be a monster (unless it is
|
||||
the invisible monster glyph, which is handled like
|
||||
an object, replacing any object or trap at its spot) */
|
||||
glyph = !save_swallowed ? glyph_at(x, y) : levl_glyph;
|
||||
if (keep_mons && x == u.ux && y == u.uy && save_swallowed)
|
||||
glyph = mon_to_glyph(u.ustuck);
|
||||
else if (((glyph_is_monster(glyph)
|
||||
|| glyph_is_warning(glyph)) && !keep_mons)
|
||||
|| glyph_is_swallow(glyph))
|
||||
glyph = levl_glyph;
|
||||
if (((glyph_is_object(glyph) && !keep_objs)
|
||||
|| glyph_is_invisible(glyph))
|
||||
&& keep_traps && !covers_traps(x, y)) {
|
||||
if ((t = t_at(x, y)) != 0 && t->tseen)
|
||||
glyph = trap_to_glyph(t);
|
||||
}
|
||||
if ((glyph_is_object(glyph) && !keep_objs)
|
||||
|| (glyph_is_trap(glyph) && !keep_traps)
|
||||
|| glyph_is_invisible(glyph)) {
|
||||
if (!seenv) {
|
||||
glyph = default_glyph;
|
||||
} else if (lastseentyp[x][y] == levl[x][y].typ) {
|
||||
glyph = back_to_glyph(x, y);
|
||||
} else {
|
||||
/* 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) {
|
||||
glyph = cmap_to_glyph(mtmp->mappearance);
|
||||
} else {
|
||||
/* we have a topology type but we want a
|
||||
screen symbol in order to derive a glyph;
|
||||
some screen symbols need the flags field
|
||||
of levl[][] in addition to the type
|
||||
(to disambiguate STAIRS to S_upstair or
|
||||
S_dnstair, for example; current flags
|
||||
might not be intended for remembered
|
||||
type, but we've got no other choice) */
|
||||
schar save_typ = levl[x][y].typ;
|
||||
|
||||
levl[x][y].typ = lastseentyp[x][y];
|
||||
glyph = back_to_glyph(x, y);
|
||||
levl[x][y].typ = save_typ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
show_glyph(x, y, glyph);
|
||||
}
|
||||
/* [TODO: highlight hero's location somehow] */
|
||||
u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
|
||||
u.uswallow = save_swallowed;
|
||||
if (save_swallowed) u.uswallow = 1;
|
||||
flush_screen(1);
|
||||
pline("Showing underlying terrain only...");
|
||||
if (full) {
|
||||
Strcpy(buf, "underlying terrain");
|
||||
} else {
|
||||
Strcpy(buf, "known terrain");
|
||||
if (keep_traps)
|
||||
Sprintf(eos(buf), "%s traps",
|
||||
(keep_objs || keep_mons) ? "," : " and");
|
||||
if (keep_objs)
|
||||
Sprintf(eos(buf), "%s%s objects",
|
||||
(keep_traps || keep_mons) ? "," : "",
|
||||
keep_mons ? "" : " and");
|
||||
if (keep_mons)
|
||||
Sprintf(eos(buf), "%s and monsters",
|
||||
(keep_traps || keep_objs) ? "," : "");
|
||||
}
|
||||
pline("Showing %s only...", buf);
|
||||
display_nhwindow(WIN_MAP, TRUE); /* give "--More--" prompt */
|
||||
docrt(); /* redraw the screen, restoring regular map */
|
||||
if (Underwater)
|
||||
|
||||
Reference in New Issue
Block a user