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

Function do_vicinity_map

src/detect.c:1447–1585  ·  view source on GitHub ↗

clairvoyance */

Source from the content-addressed store, hash-verified

1445
1446/* clairvoyance */
1447void
1448do_vicinity_map(
1449 struct obj *sobj) /* scroll--actually fake spellbook--object */
1450{
1451 int zx, zy;
1452 struct monst *mtmp;
1453 struct obj *otmp;
1454 long save_EDetect_mons;
1455 char save_viz_uyux;
1456 boolean unconstrained, refresh = FALSE,
1457 mdetected = FALSE, odetected = FALSE,
1458 /* fake spellbook 'sobj' implies hero has cast the spell;
1459 when book is blessed, casting is skilled or expert level;
1460 if already clairvoyant, non-skilled spell acts like skilled */
1461 extended = (sobj && (sobj->blessed || Clairvoyant)),
1462 random_farsight = !sobj;
1463 int newglyph, oldglyph,
1464 lo_y = ((u.uy - 5 < 0) ? 0 : u.uy - 5),
1465 hi_y = ((u.uy + 6 >= ROWNO) ? ROWNO - 1 : u.uy + 6),
1466 lo_x = ((u.ux - 9 < 1) ? 1 : u.ux - 9), /* avoid column 0 */
1467 hi_x = ((u.ux + 10 >= COLNO) ? COLNO - 1 : u.ux + 10),
1468 ter_typ = TER_DETECT | TER_MAP | TER_TRP | TER_OBJ;
1469
1470 /*
1471 * 3.6.0 attempted to emphasize terrain over transient map
1472 * properties (monsters and objects) but that led to problems.
1473 * Notably, known trap would be displayed instead of a monster
1474 * on or in it and then the display remained that way after the
1475 * clairvoyant snapshot finished. That could have been fixed by
1476 * issuing --More-- and then regular vision update, but we want
1477 * to avoid that when having a clairvoyant episode every N turns
1478 * (from donating to a temple priest or by carrying the Amulet).
1479 * Unlike when casting the spell, it is much too intrusive when
1480 * in the midst of walking around or combatting monsters.
1481 *
1482 * As of 3.6.2, show terrain, then object, then monster like regular
1483 * map updating, except in this case the map locations get marked
1484 * as seen from every direction rather than just from direction of
1485 * hero. Skilled spell marks revealed objects as 'seen up close'
1486 * (but for piles, only the top item) and shows monsters as if
1487 * detected. Non-skilled and timed clairvoyance reveals non-visible
1488 * monsters as 'remembered, unseen'.
1489 */
1490
1491 /* if hero is engulfed, show engulfer at <u.ux,u.uy> */
1492 save_viz_uyux = gv.viz_array[u.uy][u.ux];
1493 if (u.uswallow)
1494 gv.viz_array[u.uy][u.ux] |= IN_SIGHT; /* <x,y> are reversed, [y][x] */
1495 save_EDetect_mons = EDetect_monsters;
1496 /* for skilled spell, getpos() scanning of the map will display all
1497 monsters within range; otherwise, "unseen creature" will be shown */
1498 EDetect_monsters |= I_SPECIAL;
1499 unconstrained = unconstrain_map();
1500 for (zx = lo_x; zx <= hi_x; zx++)
1501 for (zy = lo_y; zy <= hi_y; zy++) {
1502 oldglyph = glyph_at(zx, zy);
1503 /* this will remove 'remembered, unseen mon' (and objects) */
1504 show_map_spot(zx, zy, Confusion);

Callers 2

allmain.cFile · 0.85
spelleffectsFunction · 0.85

Calls 13

unconstrain_mapFunction · 0.85
glyph_atFunction · 0.85
show_map_spotFunction · 0.85
observe_objectFunction · 0.85
map_objectFunction · 0.85
map_invisibleFunction · 0.85
map_monstFunction · 0.85
flush_screenFunction · 0.85
YouFunction · 0.85
browse_mapFunction · 0.85
reconstrain_mapFunction · 0.85
see_monstersFunction · 0.85

Tested by

no test coverage detected