1 /* NetHack 3.6 detect.c $NHDT-Date: 1446369464 2015/11/01 09:17:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.61 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
6 * Detection routines, including crystal ball, magic mapping, and search
10 /* JNetHack Copyright */
11 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
12 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */
13 /* JNetHack may be freely redistributed. See license for details. */
18 extern boolean known; /* from read.c */
20 STATIC_DCL void FDECL(do_dknown_of, (struct obj *));
21 STATIC_DCL boolean FDECL(check_map_spot, (int, int, CHAR_P, unsigned));
22 STATIC_DCL boolean FDECL(clear_stale_map, (CHAR_P, unsigned));
23 STATIC_DCL void FDECL(sense_trap, (struct trap *, XCHAR_P, XCHAR_P, int));
24 STATIC_DCL int FDECL(detect_obj_traps, (struct obj *, BOOLEAN_P, int));
25 STATIC_DCL void FDECL(show_map_spot, (int, int));
26 STATIC_PTR void FDECL(findone, (int, int, genericptr_t));
27 STATIC_PTR void FDECL(openone, (int, int, genericptr_t));
29 /* Recursively search obj for an object in class oclass and return 1st found
36 register struct obj *otmp;
39 if (obj->oclass == oclass)
42 if (Has_contents(obj)) {
43 for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
44 if (otmp->oclass == oclass)
46 else if (Has_contents(otmp) && (temp = o_in(otmp, oclass)))
49 return (struct obj *) 0;
52 /* Recursively search obj for an object made of specified material.
56 o_material(obj, material)
60 register struct obj *otmp;
63 if (objects[obj->otyp].oc_material == material)
66 if (Has_contents(obj)) {
67 for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
68 if (objects[otmp->otyp].oc_material == material)
70 else if (Has_contents(otmp)
71 && (temp = o_material(otmp, material)))
74 return (struct obj *) 0;
84 if (Has_contents(obj)) {
85 for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
90 /* Check whether the location has an outdated object displayed on it. */
92 check_map_spot(x, y, oclass, material)
98 register struct obj *otmp;
99 register struct monst *mtmp;
101 glyph = glyph_at(x, y);
102 if (glyph_is_object(glyph)) {
103 /* there's some object shown here */
104 if (oclass == ALL_CLASSES) {
105 return (boolean) !(level.objects[x][y] /* stale if nothing here */
106 || ((mtmp = m_at(x, y)) != 0 && mtmp->minvent));
109 && objects[glyph_to_obj(glyph)].oc_material == material) {
110 /* object shown here is of interest because material matches */
111 for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
112 if (o_material(otmp, GOLD))
114 /* didn't find it; perhaps a monster is carrying it */
115 if ((mtmp = m_at(x, y)) != 0) {
116 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
117 if (o_material(otmp, GOLD))
120 /* detection indicates removal of this object from the map */
123 if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) {
124 /* obj shown here is of interest because its class matches */
125 for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
126 if (o_in(otmp, oclass))
128 /* didn't find it; perhaps a monster is carrying it */
129 if ((mtmp = m_at(x, y)) != 0) {
130 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
131 if (o_in(otmp, oclass))
134 /* detection indicates removal of this object from the map */
143 * When doing detection, remove stale data from the map display (corpses
144 * rotted away, objects carried away by monsters, etc) so that it won't
145 * reappear after the detection has completed. Return true if noticeable
149 clear_stale_map(oclass, material)
154 boolean change_made = FALSE;
156 for (zx = 1; zx < COLNO; zx++)
157 for (zy = 0; zy < ROWNO; zy++)
158 if (check_map_spot(zx, zy, oclass, material)) {
159 unmap_object(zx, zy);
166 /* look for gold, on the floor or in monsters' possession */
169 register struct obj *sobj;
171 register struct obj *obj;
172 register struct monst *mtmp;
177 clear_stale_map(COIN_CLASS, (unsigned) (sobj->blessed ? GOLD : 0));
179 /* look for gold carried by monsters (might be in a container) */
180 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
181 if (DEADMONSTER(mtmp))
182 continue; /* probably not needed in this case but... */
183 if (findgold(mtmp->minvent) || monsndx(mtmp->data) == PM_GOLD_GOLEM) {
185 goto outgoldmap; /* skip further searching */
187 for (obj = mtmp->minvent; obj; obj = obj->nobj)
188 if (sobj->blessed && o_material(obj, GOLD)) {
191 } else if (o_in(obj, COIN_CLASS)) {
193 goto outgoldmap; /* skip further searching */
197 /* look for gold objects */
198 for (obj = fobj; obj; obj = obj->nobj) {
199 if (sobj->blessed && o_material(obj, GOLD)) {
201 if (obj->ox != u.ux || obj->oy != u.uy)
203 } else if (o_in(obj, COIN_CLASS)) {
205 if (obj->ox != u.ux || obj->oy != u.uy)
211 /* no gold found on floor or monster's inventory.
212 adjust message if you have gold in your inventory */
215 if (youmonst.data == &mons[PM_GOLD_GOLEM]) {
217 Sprintf(buf, "You feel like a million %s!", currency(2L));
219 Strcpy(buf, "
\82 \82È
\82½
\82Í
\8bà
\8e\9d\82¿
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82É
\8a´
\82¶
\82½
\81I");
220 } else if (hidden_gold() || money_cnt(invent))
223 "You feel worried about your future financial situation.");
225 "
\82 \82È
\82½
\82Í
\8f«
\97\88\82Ì
\8co
\8dÏ
\8fó
\8bµ
\82ª
\90S
\94z
\82É
\82È
\82Á
\82½
\81D");
228 Strcpy(buf, "You feel materially poor.");
230 Strcpy(buf, "
\82 \82È
\82½
\82Í
\82Ð
\82à
\82¶
\82³
\82ð
\8a´
\82¶
\82½
\81D");
231 strange_feeling(sobj, buf);
235 /* only under me - no separate display required */
239 You("notice some gold between your %s.", makeplural(body_part(FOOT)));
241 You("%s
\82Ì
\8aÔ
\82É
\8bà
\89Ý
\82ª
\97\8e\82¿
\82Ä
\82¢
\82é
\82±
\82Æ
\82É
\8bC
\82ª
\82Â
\82¢
\82½
\81D", body_part(FOOT));
247 iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
248 u.uinwater = u.uburied = 0;
249 /* Discover gold locations. */
250 for (obj = fobj; obj; obj = obj->nobj) {
251 if (sobj->blessed && (temp = o_material(obj, GOLD))) {
257 } else if ((temp = o_in(obj, COIN_CLASS))) {
265 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
266 if (DEADMONSTER(mtmp))
267 continue; /* probably overkill here */
268 if (findgold(mtmp->minvent) || monsndx(mtmp->data) == PM_GOLD_GOLEM) {
270 gold = zeroobj; /* ensure oextra is cleared too */
271 gold.otyp = GOLD_PIECE;
274 map_object(&gold, 1);
276 for (obj = mtmp->minvent; obj; obj = obj->nobj)
277 if (sobj->blessed && (temp = o_material(obj, GOLD))) {
282 } else if ((temp = o_in(obj, COIN_CLASS))) {
290 u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
292 You_feel("very greedy, and sense gold!");
294 You("
\82Ç
\82ñ
\97~
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82È
\8bC
\82ª
\82µ
\82½
\81C
\82»
\82µ
\82Ä
\8bà
\89Ý
\82Ì
\88Ê
\92u
\82ð
\8a´
\92m
\82µ
\82½
\81I");
295 exercise(A_WIS, TRUE);
296 display_nhwindow(WIN_MAP, TRUE);
305 /* returns 1 if nothing was detected */
306 /* returns 0 if something was detected */
309 register struct obj *sobj;
311 register struct obj *obj;
312 register struct monst *mtmp;
313 register int ct = 0, ctu = 0;
314 boolean confused = (Confusion || (sobj && sobj->cursed)), stale;
315 char oclass = confused ? POTION_CLASS : FOOD_CLASS;
317 const char *what = confused ? something : "food";
319 const char *what = confused ? "
\83n
\83\89\83w
\83\8a" : "
\90H
\82×
\95¨";
321 stale = clear_stale_map(oclass, 0);
323 for (obj = fobj; obj; obj = obj->nobj)
324 if (o_in(obj, oclass)) {
325 if (obj->ox == u.ux && obj->oy == u.uy)
330 for (mtmp = fmon; mtmp && !ct; mtmp = mtmp->nmon) {
331 /* no DEADMONSTER(mtmp) check needed since dmons never have inventory
333 for (obj = mtmp->minvent; obj; obj = obj->nobj)
334 if (o_in(obj, oclass)) {
341 known = stale && !confused;
345 You("sense a lack of %s nearby.", what);
347 You("%s
\82ª
\8c¸
\82Á
\82Ä
\82¢
\82é
\82Ì
\82É
\8bC
\82ª
\82Â
\82¢
\82½
\81D",what);
348 if (sobj && sobj->blessed) {
351 Your("%s starts to tingle.", body_part(NOSE));
353 Your("%s
\82ª
\82Ò
\82
\82Á
\82Æ
\93®
\82¢
\82½
\81D", body_part(NOSE));
359 Sprintf(buf, "Your %s twitches%s.", body_part(NOSE),
360 (sobj->blessed && !u.uedibility)
361 ? " then starts to tingle"
364 Sprintf(buf, "
\82 \82È
\82½
\82Ì%s
\82ª
\82Ð
\82
\82Ð
\82
\82Æ
\93®
\82¢%s
\81D", body_part(NOSE),
365 (sobj->blessed && !u.uedibility)
366 ? "
\82Ä
\81C
\82¤
\82¸
\82¤
\82¸
\82µ
\82¾
\82µ
\82½"
369 if (sobj->blessed && !u.uedibility) {
370 boolean savebeginner = flags.beginner;
372 flags.beginner = FALSE; /* prevent non-delivery of message */
373 strange_feeling(sobj, buf);
374 flags.beginner = savebeginner;
377 strange_feeling(sobj, buf);
382 You("%s %s nearby.", sobj ? "smell" : "sense", what);
383 if (sobj && sobj->blessed) {
385 pline("Your %s starts to tingle.", body_part(NOSE));
392 iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
393 u.uinwater = u.uburied = 0;
394 for (obj = fobj; obj; obj = obj->nobj)
395 if ((temp = o_in(obj, oclass)) != 0) {
402 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
403 /* no DEADMONSTER(mtmp) check needed since dmons never have
405 for (obj = mtmp->minvent; obj; obj = obj->nobj)
406 if ((temp = o_in(obj, oclass)) != 0) {
410 break; /* skip rest of this monster's inventory */
413 u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
417 Your("%s %s to tingle and you smell %s.", body_part(NOSE),
418 u.uedibility ? "continues" : "starts", what);
420 Your("%s
\82Í
\82¤
\82¸
\82¤
\82¸
\82µ%s
\81C%s
\82Ì
\93õ
\82¢
\82ð
\9ak
\82¬
\82Æ
\82Á
\82½
\81D", body_part(NOSE),
421 u.uedibility ? "
\91±
\82¯" : "
\8en
\82ß", what);
426 Your("%s tingles and you smell %s.", body_part(NOSE), what);
428 Your("%s
\82Í
\82¤
\82¸
\82¤
\82¸
\82µ
\81C%s
\82Ì
\93õ
\82¢
\82ð
\9ak
\82¬
\82Æ
\82Á
\82½
\81D", body_part(NOSE), what);
431 You("sense %s.", what);
433 You("%s
\82ð
\8a´
\92m
\82µ
\82½
\81D", what);
434 display_nhwindow(WIN_MAP, TRUE);
435 exercise(A_WIS, TRUE);
446 * Used for scrolls, potions, spells, and crystal balls. Returns:
448 * 1 - nothing was detected
449 * 0 - something was detected
452 object_detect(detector, class)
453 struct obj *detector; /* object doing the detecting */
454 int class; /* an object class, 0 for all */
458 int is_cursed = (detector && detector->cursed);
459 int do_dknown = (detector && (detector->oclass == POTION_CLASS
460 || detector->oclass == SPBOOK_CLASS)
461 && detector->blessed);
463 register struct obj *obj, *otmp = (struct obj *) 0;
464 register struct monst *mtmp;
465 int sym, boulder = 0;
467 if (class < 0 || class >= MAXOCLASSES) {
468 impossible("object_detect: illegal class %d", class);
472 /* Special boulder symbol check - does the class symbol happen
473 * to match iflags.bouldersym which is a user-defined?
474 * If so, that means we aren't sure what they really wanted to
475 * detect. Rather than trump anything, show both possibilities.
476 * We can exclude checking the buried obj chain for boulders below.
478 sym = class ? def_oc_syms[class].sym : 0;
479 if (sym && iflags.bouldersym && sym == iflags.bouldersym)
480 boulder = ROCK_CLASS;
482 if (Hallucination || (Confusion && class == SCROLL_CLASS))
483 Strcpy(stuff, something);
486 Strcpy(stuff, class ? def_oc_syms[class].name : "objects");
488 Strcpy(stuff, class ? def_oc_syms[class].name : "
\95¨
\91Ì");
489 if (boulder && class != ROCK_CLASS)
491 Strcat(stuff, " and/or large stones");
493 Strcat(stuff, "
\82Æ
\8b\90\8aâ");
496 for (obj = invent; obj; obj = obj->nobj)
499 for (obj = fobj; obj; obj = obj->nobj) {
500 if ((!class && !boulder) || o_in(obj, class) || o_in(obj, boulder)) {
501 if (obj->ox == u.ux && obj->oy == u.uy)
510 for (obj = level.buriedobjlist; obj; obj = obj->nobj) {
511 if (!class || o_in(obj, class)) {
512 if (obj->ox == u.ux && obj->oy == u.uy)
521 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
522 if (DEADMONSTER(mtmp))
524 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
525 if ((!class && !boulder) || o_in(obj, class)
526 || o_in(obj, boulder))
531 if ((is_cursed && mtmp->m_ap_type == M_AP_OBJECT
532 && (!class || class == objects[mtmp->mappearance].oc_class))
533 || (findgold(mtmp->minvent) && (!class || class == COIN_CLASS))) {
539 if (!clear_stale_map(!class ? ALL_CLASSES : class, 0) && !ct) {
543 strange_feeling(detector, "You feel a lack of something.");
545 strange_feeling(detector, "
\82 \82È
\82½
\82Í
\89½
\82©
\82ª
\8c\87\96R
\82µ
\82Ä
\82¢
\82é
\82æ
\82¤
\82È
\8bC
\82ª
\82µ
\82½
\81D");
550 You("sense %s nearby.", stuff);
552 You("
\8bß
\82
\82Ì%s
\82ð
\8a´
\92m
\82µ
\82½
\81D", stuff);
558 iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
559 u.uinwater = u.uburied = 0;
561 * Map all buried objects first.
563 for (obj = level.buriedobjlist; obj; obj = obj->nobj)
564 if (!class || (otmp = o_in(obj, class))) {
575 * If we are mapping all objects, map only the top object of a pile or
576 * the first object in a monster's inventory. Otherwise, go looking
577 * for a matching object class and display the first one encountered
580 * Objects on the floor override buried objects.
582 for (x = 1; x < COLNO; x++)
583 for (y = 0; y < ROWNO; y++)
584 for (obj = level.objects[x][y]; obj; obj = obj->nexthere)
585 if ((!class && !boulder) || (otmp = o_in(obj, class))
586 || (otmp = o_in(obj, boulder))) {
587 if (class || boulder) {
598 /* Objects in the monster's inventory override floor objects. */
599 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
600 if (DEADMONSTER(mtmp))
602 for (obj = mtmp->minvent; obj; obj = obj->nobj)
603 if ((!class && !boulder) || (otmp = o_in(obj, class))
604 || (otmp = o_in(obj, boulder))) {
605 if (!class && !boulder)
607 otmp->ox = mtmp->mx; /* at monster location */
612 /* Allow a mimic to override the detected objects it is carrying. */
613 if (is_cursed && mtmp->m_ap_type == M_AP_OBJECT
614 && (!class || class == objects[mtmp->mappearance].oc_class)) {
617 temp.oextra = (struct oextra *) 0;
618 temp.otyp = mtmp->mappearance; /* needed for obj_to_glyph() */
621 temp.corpsenm = PM_TENGU; /* if mimicing a corpse */
622 map_object(&temp, 1);
623 } else if (findgold(mtmp->minvent)
624 && (!class || class == COIN_CLASS)) {
626 gold = zeroobj; /* ensure oextra is cleared too */
627 gold.otyp = GOLD_PIECE;
630 map_object(&gold, 1);
635 u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
637 You("detect the %s of %s.", ct ? "presence" : "absence", stuff);
639 You("%s%s
\81D", stuff, ct ? "
\82ð
\94
\8c©
\82µ
\82½" : "
\82Í
\89½
\82à
\82È
\82¢
\82±
\82Æ
\82ª
\82í
\82©
\82Á
\82½" );
640 display_nhwindow(WIN_MAP, TRUE);
642 * What are we going to do when the hero does an object detect while blind
643 * and the detected object covers a known pool?
645 docrt(); /* this will correctly reset vision */
655 * Used by: crystal balls, potions, fountains
657 * Returns 1 if nothing was detected.
658 * Returns 0 if something was detected.
661 monster_detect(otmp, mclass)
662 register struct obj *otmp; /* detecting object (if any) */
663 int mclass; /* monster class, 0 for all */
665 register struct monst *mtmp;
668 /* Note: This used to just check fmon for a non-zero value
669 * but in versions since 3.3.0 fmon can test TRUE due to the
670 * presence of dmons, so we have to find at least one
671 * with positive hit-points to know for sure.
673 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
674 if (!DEADMONSTER(mtmp)) {
681 strange_feeling(otmp, Hallucination
683 ? "You get the heebie jeebies."
685 ? "
\82 \82È
\82½
\82Í
\8bà
\92¹
\82Ì
\89Ä
\82Å
\83L
\83\93\83`
\83\87\81[
\82µ
\82½
\81D"
687 : "You feel threatened.");
689 : "
\82 \82È
\82½
\82Í
\8b°
\95|
\82Å
\82¼
\82
\82¼
\82
\82µ
\82½
\81D");
692 boolean woken = FALSE;
695 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
696 if (DEADMONSTER(mtmp))
698 if (!mclass || mtmp->data->mlet == mclass
699 || (mtmp->data == &mons[PM_LONG_WORM]
700 && mclass == S_WORM_TAIL))
702 if (mclass && def_monsyms[mclass].sym == ' ')
703 show_glyph(mtmp->mx, mtmp->my,
704 detected_mon_to_glyph(mtmp));
706 show_glyph(mtmp->mx, mtmp->my,
707 mtmp->mtame ? pet_to_glyph(mtmp) : mon_to_glyph(mtmp));
708 /* don't be stingy - display entire worm */
709 if (mtmp->data == &mons[PM_LONG_WORM])
710 detect_wsegs(mtmp, 0);
712 if (otmp && otmp->cursed
713 && (mtmp->msleeping || !mtmp->mcanmove)) {
714 mtmp->msleeping = mtmp->mfrozen = 0;
721 You("sense the presence of monsters.");
723 You("
\89ö
\95¨
\82Ì
\91¶
\8dÝ
\82ð
\9ak
\82¬
\82Â
\82¯
\82½
\81D");
726 pline("Monsters sense the presence of you.");
728 pline("
\89ö
\95¨
\82Í
\82 \82È
\82½
\82Ì
\91¶
\8dÝ
\82ð
\9ak
\82¬
\82Â
\82¯
\82½
\81D");
729 display_nhwindow(WIN_MAP, TRUE);
740 sense_trap(trap, x, y, src_cursed)
745 if (Hallucination || src_cursed) {
746 struct obj obj; /* fake object */
748 obj.oextra = (struct oextra *) 0;
756 obj.otyp = (src_cursed) ? GOLD_PIECE : random_object();
757 obj.corpsenm = random_monster(); /* if otyp == CORPSE */
763 struct trap temp_trap; /* fake trap */
766 temp_trap.ttyp = BEAR_TRAP; /* some kind of trap */
767 map_trap(&temp_trap, 1);
771 #define OTRAP_NONE 0 /* nothing found */
772 #define OTRAP_HERE 1 /* found at hero's location */
773 #define OTRAP_THERE 2 /* found at any other location */
775 /* check a list of objects for chest traps; return 1 if found at <ux,uy>,
776 2 if found at some other spot, 3 if both, 0 otherwise; optionally
777 update the map to show where such traps were found */
779 detect_obj_traps(objlist, show_them, how)
782 int how; /* 1 for misleading map feedback */
786 int result = OTRAP_NONE;
788 for (otmp = objlist; otmp; otmp = otmp->nobj) {
789 if (Is_box(otmp) && otmp->otrapped
790 && get_obj_location(otmp, &x, &y, BURIED_TOO | CONTAINED_TOO)) {
791 result |= (x == u.ux && y == u.uy) ? OTRAP_HERE : OTRAP_THERE;
793 sense_trap((struct trap *) 0, x, y, how);
795 if (Has_contents(otmp))
796 result |= detect_obj_traps(otmp->cobj, show_them, how);
801 /* the detections are pulled out so they can
802 * also be used in the crystal ball routine
803 * returns 1 if nothing was detected
804 * returns 0 if something was detected
808 register struct obj *sobj;
809 /* sobj is null if crystal ball, *scroll if gold detection scroll */
811 register struct trap *ttmp;
814 int cursed_src = sobj && sobj->cursed;
815 boolean found = FALSE;
818 /* floor/ceiling traps */
819 for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) {
820 if (ttmp->tx != u.ux || ttmp->ty != u.uy)
825 /* chest traps (might be buried or carried) */
826 if ((tr = detect_obj_traps(fobj, FALSE, 0)) != OTRAP_NONE) {
827 if (tr & OTRAP_THERE)
832 if ((tr = detect_obj_traps(level.buriedobjlist, FALSE, 0))
834 if (tr & OTRAP_THERE)
839 for (mon = fmon; mon; mon = mon->nmon) {
840 if (DEADMONSTER(mon))
842 if ((tr = detect_obj_traps(mon->minvent, FALSE, 0)) != OTRAP_NONE) {
843 if (tr & OTRAP_THERE)
849 if (detect_obj_traps(invent, FALSE, 0) != OTRAP_NONE)
852 for (door = 0; door < doorindex; door++) {
854 if (levl[cc.x][cc.y].doormask & D_TRAPPED) {
855 if (cc.x != u.ux || cc.y != u.uy)
865 Sprintf(buf, "Your %s stop itching.", makeplural(body_part(TOE)));
867 Sprintf(buf, "
\82 \82È
\82½
\82Ì%s
\82Ì
\82Þ
\82¸
\82Þ
\82¸
\82Í
\82¨
\82³
\82Ü
\82Á
\82½
\81D", makeplural(body_part(TOE)));
868 strange_feeling(sobj, buf);
871 /* traps exist, but only under me - no separate display required */
873 Your("%s itch.", makeplural(body_part(TOE)));
875 Your("%s
\82Í
\82Þ
\82¸
\82Þ
\82¸
\82µ
\82½
\81D", makeplural(body_part(TOE)));
880 iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
881 u.uinwater = u.uburied = 0;
883 /* show chest traps first, so that subsequent floor trap display
884 will override if both types are present at the same location */
885 (void) detect_obj_traps(fobj, TRUE, cursed_src);
886 (void) detect_obj_traps(level.buriedobjlist, TRUE, cursed_src);
887 for (mon = fmon; mon; mon = mon->nmon) {
888 if (DEADMONSTER(mon))
890 (void) detect_obj_traps(mon->minvent, TRUE, cursed_src);
892 (void) detect_obj_traps(invent, TRUE, cursed_src);
894 for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap)
895 sense_trap(ttmp, 0, 0, cursed_src);
897 for (door = 0; door < doorindex; door++) {
899 if (levl[cc.x][cc.y].doormask & D_TRAPPED)
900 sense_trap((struct trap *) 0, cc.x, cc.y, cursed_src);
903 /* redisplay hero unless sense_trap() revealed something at <ux,uy> */
904 glyph = glyph_at(u.ux, u.uy);
905 if (!(glyph_is_trap(glyph) || glyph_is_object(glyph)))
907 u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
910 You_feel("%s.", cursed_src ? "very greedy" : "entrapped");
912 You("%s
\8bC
\8e\9d\82É
\82È
\82Á
\82½
\81D", cursed_src ? "
\82Æ
\82Ä
\82à
\82Ç
\82ñ
\97~
\82È" : "
\82¾
\82Ü
\82³
\82ê
\82Ä
\82¢
\82é
\82æ
\82¤
\82È");
913 /* wait for user to respond, then reset map display to normal */
914 display_nhwindow(WIN_MAP, TRUE);
924 level_distance(where)
927 register schar ll = depth(&u.uz) - depth(where);
928 register boolean indun = (u.uz.dnum == where->dnum);
931 if (ll < (-8 - rn2(3)))
936 return "
\82Í
\82é
\82©
\94Þ
\95û
\82É";
941 return "
\82Í
\82é
\82©
\89º
\95û
\82É";
945 return "away below you";
947 return "
\82¸
\82Á
\82Æ
\89º
\95û
\82É";
952 return "
\89º
\95û
\82É";
955 return "in the distance";
957 return "
\89\93\82
\82É";
962 return "
\90^
\89º
\82É";
964 if (ll > (8 + rn2(3)))
969 return "
\82Í
\82é
\82©
\94Þ
\95û
\82É";
974 return "
\82Í
\82é
\82©
\8fã
\95û
\82É";
978 return "away above you";
980 return "
\82¸
\82Á
\82Æ
\8fã
\95û
\82É";
985 return "
\8fã
\95û
\82É";
988 return "in the distance";
990 return "
\89\93\82
\82É";
995 return "
\90^
\8fã
\82É";
998 return "in the distance";
1000 return "
\89\93\82
\82É";
1005 return "
\8bß
\82
\82É";
1008 static const struct {
1011 } level_detects[] = {
1013 { "Delphi", &oracle_level },
1015 { "
\83f
\83\8b\83t
\83@
\83C", &oracle_level },
1017 { "Medusa's lair", &medusa_level },
1019 { "
\83\81\83f
\83\85\81[
\83T
\82Ì
\8fZ
\82Ý
\82©", &medusa_level },
1021 { "a castle", &stronghold_level },
1023 { "
\8fé", &stronghold_level },
1025 { "the Wizard of Yendor's tower", &wiz1_level },
1027 { "
\83C
\83F
\83\93\83_
\81[
\82Ì
\96\82\96@
\8eg
\82¢
\82Ì
\93\83", &wiz1_level },
1031 use_crystal_ball(optr)
1036 struct obj *obj = *optr;
1040 pline("Too bad you can't see %s.", the(xname(obj)));
1042 pline("
\82È
\82ñ
\82Ä
\82±
\82Æ
\82¾
\81D%s
\82ð
\8c©
\82é
\82±
\82Æ
\82ª
\82Å
\82«
\82È
\82¢
\81D", the(xname(obj)));
1045 oops = (rnd(20) > ACURR(A_INT) || obj->cursed);
1046 if (oops && (obj->spe > 0)) {
1047 switch (rnd(obj->oartifact ? 4 : 5)) {
1050 pline("%s too much to comprehend!", Tobjnam(obj, "are"));
1052 pline("%s
\82ð
\94`
\82¢
\82½
\82ª
\89½
\82Ì
\82±
\82Æ
\82¾
\82©
\82³
\82Á
\82Ï
\82è
\82í
\82©
\82ç
\82È
\82©
\82Á
\82½
\81I", xname(obj));
1056 pline("%s you!", Tobjnam(obj, "confuse"));
1058 pline("%s
\82ð
\94`
\82¢
\82Ä
\82é
\82Æ
\82Ó
\82ç
\82Â
\82¢
\82Ä
\82«
\82½
\81I", xname(obj));
1059 make_confused((HConfusion & TIMEOUT) + (long) rnd(100), FALSE);
1062 if (!resists_blnd(&youmonst)) {
1064 pline("%s your vision!", Tobjnam(obj, "damage"));
1066 pline("%s
\82ð
\94`
\82¢
\82Ä
\82¢
\82é
\82Æ
\8e\8b\8ao
\82ª
\82¨
\82©
\82µ
\82
\82È
\82Á
\82Ä
\82«
\82½
\81I", xname(obj));
1067 make_blinded((Blinded & TIMEOUT) + (long) rnd(100), FALSE);
1069 Your1(vision_clears);
1072 pline("%s your vision.", Tobjnam(obj, "assault"));
1074 pline("%s
\82ª
\82 \82È
\82½
\82Ì
\8e\8b\8aE
\82É
\94\97\82Á
\82Ä
\82«
\82½
\81D", xname(obj));
1076 You("are unaffected!");
1078 pline("
\82µ
\82©
\82µ
\81C
\82 \82È
\82½
\82Í
\89e
\8b¿
\82ð
\8eó
\82¯
\82È
\82©
\82Á
\82½
\81I");
1083 pline("%s your mind!", Tobjnam(obj, "zap"));
1085 pline("%s
\82ð
\94`
\82¢
\82Ä
\82¢
\82é
\82Æ
\8cÜ
\8a´
\82ª
\82¨
\82©
\82µ
\82
\82È
\82Á
\82Ä
\82«
\82½
\81I", xname(obj));
1086 (void) make_hallucinated(
1087 (HHallucination & TIMEOUT) + (long) rnd(100), FALSE, 0L);
1091 pline("%s!", Tobjnam(obj, "explode"));
1093 pline("%s
\82Í
\94\9a\94
\82µ
\82½
\81I", xname(obj));
1095 *optr = obj = 0; /* it's gone */
1096 /* physical damage cause by the shards and force */
1098 losehp(Maybe_Half_Phys(rnd(30)), "exploding crystal ball",
1100 losehp(Maybe_Half_Phys(rnd(30)), "
\90\85\8f»
\8bÊ
\82Ì
\94\9a\94
\82Å",
1105 consume_obj_charge(obj, TRUE);
1109 if (Hallucination) {
1112 pline("All you see is funky %s haze.", hcolor((char *) 0));
1114 pline("
\82¨
\82¨
\81I
\83t
\83@
\83\93\83L
\81[
\83\82\83\93\83L
\81[
\82È%s
\82à
\82â
\82ª
\8c©
\82¦
\82é
\81D", hcolor((char *)0));
1119 You("grok some groovy globs of incandescent lava.");
1121 You("
\90\85\96å
\82Ì
\8c®
\82ð
\82à
\82Á
\82½
\90\85\8cË
\89©
\96å
\82ª
\95Ç
\82Ì
\89e
\82É
\89B
\82ê
\82Ä
\82¢
\82é
\82Ì
\82ª
\8c©
\82¦
\82½
\81D");
1125 pline("Whoa! Psychedelic colors, %s!",
1126 poly_gender() == 1 ? "babe" : "dude");
1128 pline("
\83\8f\81[
\83I
\81I
\83\89\83\8a\82Á
\82Ä
\82é
\82©
\82¢
\81H%s
\81I",
1129 poly_gender() == 1 ? "
\83x
\83C
\83r
\81[" : "
\83\86\81[");
1134 pline_The("crystal pulses with sinister %s light!",
1136 pline("
\90\85\8f»
\82Í
\95s
\8bg
\82È%s
\83p
\83\8b\83X
\82ð
\94
\82µ
\82½
\81I",
1137 hcolor((char *) 0));
1141 You_see("goldfish swimming above fluorescent rocks.");
1143 You("
\8cu
\8cõ
\8aâ
\82Ì
\8fã
\82ð
\8bà
\8b\9b\82ª
\89j
\82¢
\82Å
\82¢
\82é
\82Ì
\82ð
\8c©
\82½
\81D");
1148 "tiny snowflakes spinning around a miniature farmhouse.");
1150 You("
\8f¬
\82³
\82¢
\90á
\95Ð
\82ª
\83~
\83j
\83`
\83\85\83A
\82Ì
\94_
\89Æ
\82Ì
\89Æ
\82Ì
\82Ü
\82í
\82è
\82ð
\95\91\82Á
\82Ä
\82é
\82Ì
\82ð
\8c©
\82½
\81D");
1155 pline("Oh wow... like a kaleidoscope!");
1157 pline("
\83\8f\81[
\83I
\81D
\96\9c\89Ø
\8b¾
\82Ì
\82æ
\82¤
\82¾
\81I");
1160 consume_obj_charge(obj, TRUE);
1165 /* read a single character */
1168 You("may look for an object or monster symbol.");
1170 You("
\95¨
\91Ì
\82â
\89ö
\95¨
\82Ì
\8bL
\8d\86\82ð
\92T
\82¹
\82é
\81D");
1172 ch = yn_function("What do you look for?", (char *) 0, '\0');
1174 ch = yn_function("
\89½
\82ð
\92T
\82µ
\82Ü
\82·
\82©
\81H", (char *)0, '\0');
1175 /* Don't filter out ' ' here; it has a use */
1176 if ((ch != def_monsyms[S_GHOST].sym) && index(quitchars, ch)) {
1182 You("peer into %s...", the(xname(obj)));
1184 You("%s
\82ð
\94`
\82«
\82±
\82ñ
\82¾
\81D
\81D
\81D", the(xname(obj)));
1186 multi_reason = "gazing into a crystal ball";
1190 pline_The("vision is unclear.");
1192 pline("
\89f
\91\9c\82Í
\95s
\91N
\96¾
\82¾
\82Á
\82½
\81D");
1197 makeknown(CRYSTAL_BALL);
1198 consume_obj_charge(obj, TRUE);
1200 /* special case: accept ']' as synonym for mimic
1201 * we have to do this before the def_char_to_objclass check
1203 if (ch == DEF_MIMIC_DEF)
1206 if ((class = def_char_to_objclass(ch)) != MAXOCLASSES)
1207 ret = object_detect((struct obj *) 0, class);
1208 else if ((class = def_char_to_monclass(ch)) != MAXMCLASSES)
1209 ret = monster_detect((struct obj *) 0, class);
1210 else if (iflags.bouldersym && (ch == iflags.bouldersym))
1211 ret = object_detect((struct obj *) 0, ROCK_CLASS);
1215 ret = trap_detect((struct obj *) 0);
1218 int i = rn2(SIZE(level_detects));
1220 You_see("%s, %s.", level_detects[i].what,
1221 level_distance(level_detects[i].where));
1223 You_see("%s
\82ð%s
\8c©
\82½
\81D", level_detects[i].what,
1224 level_distance(level_detects[i].where));
1232 if (!rn2(100)) /* make them nervous */
1234 You_see("the Wizard of Yendor gazing out at you.");
1236 You("
\83C
\83F
\83\93\83_
\81[
\82Ì
\96\82\96@
\8eg
\82¢
\82ª
\82 \82È
\82½
\82ð
\82É
\82ç
\82ñ
\82Å
\82¢
\82é
\82Ì
\82ð
\8c©
\82½
\81D");
1239 pline_The("vision is unclear.");
1241 pline("
\89f
\91\9c\82Í
\95s
\91N
\96¾
\82É
\82È
\82Á
\82½
\81D");
1255 if (Confusion && rn2(7))
1261 /* Secret corridors are found, but not secret doors. */
1262 if (lev->typ == SCORR) {
1264 unblock_point(x, y);
1268 * Force the real background, then if it's not furniture and there's
1269 * a known trap there, display the trap, else if there was an object
1270 * shown there, redisplay the object. So during mapping, furniture
1271 * takes precedence over traps, which take precedence over objects,
1272 * opposite to how normal vision behaves.
1274 oldglyph = glyph_at(x, y);
1275 if (level.flags.hero_memory) {
1276 magic_map_background(x, y, 0);
1277 newsym(x, y); /* show it, if not blocked */
1279 magic_map_background(x, y, 1); /* display it */
1281 if (!IS_FURNITURE(lev->typ)) {
1282 if ((t = t_at(x, y)) != 0 && t->tseen) {
1284 } else if (glyph_is_trap(oldglyph) || glyph_is_object(oldglyph)) {
1285 show_glyph(x, y, oldglyph);
1286 if (level.flags.hero_memory)
1287 lev->glyph = oldglyph;
1295 register int zx, zy;
1297 iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
1298 u.uinwater = u.uburied = 0;
1299 for (zx = 1; zx < COLNO; zx++)
1300 for (zy = 0; zy < ROWNO; zy++)
1301 show_map_spot(zx, zy);
1302 u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
1303 if (!level.flags.hero_memory || Underwater) {
1304 flush_screen(1); /* flush temp screen */
1305 display_nhwindow(WIN_MAP, TRUE); /* wait */
1308 exercise(A_WIS, TRUE);
1314 register int zx, zy;
1315 int lo_y = (u.uy - 5 < 0 ? 0 : u.uy - 5),
1316 hi_y = (u.uy + 6 > ROWNO ? ROWNO : u.uy + 6),
1317 lo_x = (u.ux - 9 < 1 ? 1 : u.ux - 9), /* avoid column 0 */
1318 hi_x = (u.ux + 10 > COLNO ? COLNO : u.ux + 10);
1320 for (zx = lo_x; zx < hi_x; zx++)
1321 for (zy = lo_y; zy < hi_y; zy++)
1322 show_map_spot(zx, zy);
1324 if (!level.flags.hero_memory || Underwater) {
1325 flush_screen(1); /* flush temp screen */
1326 display_nhwindow(WIN_MAP, TRUE); /* wait */
1331 /* convert a secret door into a normal door */
1333 cvt_sdoor_to_door(lev)
1336 int newmask = lev->doormask & ~WM_MASK;
1338 if (Is_rogue_level(&u.uz))
1339 /* rogue didn't have doors, only doorways */
1342 /* newly exposed door is closed */
1343 if (!(newmask & D_LOCKED))
1344 newmask |= D_CLOSED;
1347 lev->doormask = newmask;
1351 findone(zx, zy, num)
1355 register struct trap *ttmp;
1356 register struct monst *mtmp;
1358 if (levl[zx][zy].typ == SDOOR) {
1359 cvt_sdoor_to_door(&levl[zx][zy]); /* .typ = DOOR */
1360 magic_map_background(zx, zy, 0);
1363 } else if (levl[zx][zy].typ == SCORR) {
1364 levl[zx][zy].typ = CORR;
1365 unblock_point(zx, zy);
1366 magic_map_background(zx, zy, 0);
1369 } else if ((ttmp = t_at(zx, zy)) != 0) {
1370 if (!ttmp->tseen && ttmp->ttyp != STATUE_TRAP) {
1375 } else if ((mtmp = m_at(zx, zy)) != 0) {
1376 if (mtmp->m_ap_type) {
1380 if (mtmp->mundetected
1381 && (is_hider(mtmp->data) || mtmp->data->mlet == S_EEL)) {
1382 mtmp->mundetected = 0;
1386 if (!canspotmon(mtmp) && !glyph_is_invisible(levl[zx][zy].glyph))
1387 map_invisible(zx, zy);
1388 } else if (glyph_is_invisible(levl[zx][zy].glyph)) {
1389 unmap_object(zx, zy);
1396 openone(zx, zy, num)
1400 register struct trap *ttmp;
1401 register struct obj *otmp;
1402 int *num_p = (int *) num;
1404 if (OBJ_AT(zx, zy)) {
1405 for (otmp = level.objects[zx][zy]; otmp; otmp = otmp->nexthere) {
1406 if (Is_box(otmp) && otmp->olocked) {
1411 /* let it fall to the next cases. could be on trap. */
1413 if (levl[zx][zy].typ == SDOOR
1414 || (levl[zx][zy].typ == DOOR
1415 && (levl[zx][zy].doormask & (D_CLOSED | D_LOCKED)))) {
1416 if (levl[zx][zy].typ == SDOOR)
1417 cvt_sdoor_to_door(&levl[zx][zy]); /* .typ = DOOR */
1418 if (levl[zx][zy].doormask & D_TRAPPED) {
1419 if (distu(zx, zy) < 3)
1421 b_trapped("door", 0);
1423 b_trapped("
\94à", 0);
1426 Norep("You %s an explosion!",
1427 cansee(zx, zy) ? "see" : (!Deaf ? "hear"
1428 : "feel the shock of"));
1430 Norep("
\82 \82È
\82½
\82Í
\94\9a\94%s
\81I",
1431 cansee(zx, zy) ? "
\82ð
\8c©
\82½" : (!Deaf ? "
\89¹
\82ð
\95·
\82¢
\82½"
1432 : "
\82Ì
\8fÕ
\8c\82\82ð
\8a´
\82¶
\82½"));
1434 wake_nearto(zx, zy, 11 * 11);
1435 levl[zx][zy].doormask = D_NODOOR;
1437 levl[zx][zy].doormask = D_ISOPEN;
1438 unblock_point(zx, zy);
1441 } else if (levl[zx][zy].typ == SCORR) {
1442 levl[zx][zy].typ = CORR;
1443 unblock_point(zx, zy);
1446 } else if ((ttmp = t_at(zx, zy)) != 0) {
1448 boolean dummy; /* unneeded "you notice it arg" */
1450 if (!ttmp->tseen && ttmp->ttyp != STATUE_TRAP) {
1455 mon = (zx == u.ux && zy == u.uy) ? &youmonst : m_at(zx, zy);
1456 if (openholdingtrap(mon, &dummy)
1457 || openfallingtrap(mon, TRUE, &dummy))
1459 } else if (find_drawbridge(&zx, &zy)) {
1460 /* make sure it isn't an open drawbridge */
1461 open_drawbridge(zx, zy);
1466 /* returns number of things found */
1474 do_clear_area(u.ux, u.uy, BOLT_LIM, findone, (genericptr_t) &num);
1478 /* returns number of things found and opened */
1485 if (is_animal(u.ustuck->data)) {
1488 pline("Its mouth opens!");
1490 pline("
\89½
\8eÒ
\82©
\82Ì
\8cû
\82ª
\8aJ
\82¢
\82½
\81I");
1493 pline("%s opens its mouth!", Monnam(u.ustuck));
1495 pline("%s
\82Í
\8cû
\82ð
\8aJ
\82¢
\82½
\81I", Monnam(u.ustuck));
1497 expels(u.ustuck, u.ustuck->data, TRUE);
1501 do_clear_area(u.ux, u.uy, BOLT_LIM, openone, (genericptr_t) &num);
1505 /* callback hack for overriding vision in do_clear_area() */
1508 void FDECL((*func), (int, int, genericptr_t));
1510 return (func == findone || func == openone);
1517 int tt = what_trap(trap->ttyp);
1518 boolean cleared = FALSE;
1521 exercise(A_WIS, TRUE);
1522 feel_newsym(trap->tx, trap->ty);
1524 if (levl[trap->tx][trap->ty].glyph != trap_to_glyph(trap)) {
1525 /* There's too much clutter to see your find otherwise */
1533 You("find %s.", an(defsyms[trap_to_defsym(tt)].explanation));
1535 You("%s
\82ð
\8c©
\82Â
\82¯
\82½
\81D", defsyms[trap_to_defsym(tt)].explanation);
1538 display_nhwindow(WIN_MAP, TRUE); /* wait */
1545 register int aflag; /* intrinsic autosearch vs explicit searching */
1548 /* some versions of gcc seriously muck up nested loops. if you get strange
1549 crashes while searching in a version compiled with gcc, try putting
1550 #define GCC_BUG in *conf.h (or adding -DGCC_BUG to CFLAGS in the
1553 volatile xchar x, y;
1555 register xchar x, y;
1557 register struct trap *trap;
1558 register struct monst *mtmp;
1563 pline("What are you looking for? The exit?");
1565 pline("
\89½
\82ð
\92T
\82·
\82ñ
\82¾
\82¢
\81H
\94ñ
\8fí
\8cû
\81H");
1567 int fund = (uwep && uwep->oartifact
1568 && spec_ability(uwep, SPFX_SEARCH)) ? uwep->spe : 0;
1570 if (ublindf && ublindf->otyp == LENSES && !Blind)
1571 fund += 2; /* JDS: lenses help searching */
1574 for (x = u.ux - 1; x < u.ux + 2; x++)
1575 for (y = u.uy - 1; y < u.uy + 2; y++) {
1578 if (x == u.ux && y == u.uy)
1581 if (Blind && !aflag)
1582 feel_location(x, y);
1583 if (levl[x][y].typ == SDOOR) {
1586 cvt_sdoor_to_door(&levl[x][y]); /* .typ = DOOR */
1587 exercise(A_WIS, TRUE);
1589 feel_location(x, y); /* make sure it shows up */
1590 You("find a hidden door.");
1591 } else if (levl[x][y].typ == SCORR) {
1594 levl[x][y].typ = CORR;
1595 unblock_point(x, y); /* vision */
1596 exercise(A_WIS, TRUE);
1598 feel_location(x, y); /* make sure it shows up */
1599 You("find a hidden passage.");
1601 /* Be careful not to find anything in an SCORR or SDOOR */
1602 if ((mtmp = m_at(x, y)) != 0 && !aflag) {
1603 if (mtmp->m_ap_type) {
1606 exercise(A_WIS, TRUE);
1607 if (!canspotmon(mtmp)) {
1608 if (glyph_is_invisible(levl[x][y].glyph)) {
1609 /* found invisible monster in a square
1610 * which already has an 'I' in it.
1611 * Logically, this should still take
1612 * time and lead to a return(1), but
1613 * if we did that the player would keep
1614 * finding the same monster every turn.
1619 You_feel("an unseen monster!");
1621 You("
\8c©
\82¦
\82È
\82¢
\89ö
\95¨
\82Ì
\8bC
\94z
\82ð
\8a´
\82¶
\82½
\81I");
1622 map_invisible(x, y);
1624 } else if (!sensemon(mtmp))
1626 You("find %s.", mtmp->mtame
1628 You("%s
\82ð
\8c©
\82Â
\82¯
\82½
\81D", mtmp->mtame
1633 if (!canspotmon(mtmp)) {
1634 if (mtmp->mundetected
1635 && (is_hider(mtmp->data)
1636 || mtmp->data->mlet == S_EEL))
1637 mtmp->mundetected = 0;
1643 /* see if an invisible monster has moved--if Blind,
1644 * feel_location() already did it
1646 if (!aflag && !mtmp && !Blind
1647 && glyph_is_invisible(levl[x][y].glyph)) {
1652 if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) {
1654 if (trap->ttyp == STATUE_TRAP) {
1655 if (activate_statue_trap(trap, x, y, FALSE))
1656 exercise(A_WIS, TRUE);
1668 /* the 's' command -- explicit searching */
1672 return dosearch0(0);
1675 /* Pre-map the sokoban levels */
1680 register struct trap *ttmp;
1681 register struct obj *obj;
1683 /* Map the background and boulders */
1684 for (x = 1; x < COLNO; x++)
1685 for (y = 0; y < ROWNO; y++) {
1686 levl[x][y].seenv = SVALL;
1687 levl[x][y].waslit = TRUE;
1688 map_background(x, y, 1);
1689 if ((obj = sobj_at(BOULDER, x, y)) != 0)
1694 for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) {
1697 /* set sokoban_rules when there is at least one pit or hole */
1698 if (ttmp->ttyp == PIT || ttmp->ttyp == HOLE)
1703 /* idea from crawl; show known portion of map without any monsters,
1704 objects, or traps occluding the view of the underlying terrain */
1706 reveal_terrain(full, which_subset)
1707 int full; /* wizard|explore modes allow player to request full map */
1708 int which_subset; /* when not full, whether to suppress objs and/or traps */
1710 if ((Hallucination || Stunned || Confusion) && !full) {
1711 You("are too disoriented for this.");
1713 int x, y, glyph, levl_glyph, default_glyph;
1715 unsigned save_swallowed;
1719 boolean keep_traps = (which_subset & 1) !=0,
1720 keep_objs = (which_subset & 2) != 0,
1721 keep_mons = (which_subset & 4) != 0; /* actually always 0 */
1723 save_swallowed = u.uswallow;
1724 iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
1725 u.uinwater = u.uburied = 0;
1727 default_glyph = cmap_to_glyph(level.flags.arboreal ? S_tree : S_stone);
1728 /* for 'full', show the actual terrain for the entire level,
1729 otherwise what the hero remembers for seen locations with
1730 monsters, objects, and/or traps removed as caller dictates */
1731 for (x = 1; x < COLNO; x++)
1732 for (y = 0; y < ROWNO; y++) {
1733 seenv = (full || level.flags.hero_memory)
1734 ? levl[x][y].seenv : cansee(x, y) ? SVALL : 0;
1736 levl[x][y].seenv = SVALL;
1737 glyph = back_to_glyph(x, y);
1738 levl[x][y].seenv = seenv;
1740 levl_glyph = level.flags.hero_memory
1743 ? back_to_glyph(x, y)
1745 /* glyph_at() returns the displayed glyph, which might
1746 be a monster. levl[][].glyph contains the remembered
1747 glyph, which will never be a monster (unless it is
1748 the invisible monster glyph, which is handled like
1749 an object, replacing any object or trap at its spot) */
1750 glyph = !save_swallowed ? glyph_at(x, y) : levl_glyph;
1751 if (keep_mons && x == u.ux && y == u.uy && save_swallowed)
1752 glyph = mon_to_glyph(u.ustuck);
1753 else if (((glyph_is_monster(glyph)
1754 || glyph_is_warning(glyph)) && !keep_mons)
1755 || glyph_is_swallow(glyph))
1757 if (((glyph_is_object(glyph) && !keep_objs)
1758 || glyph_is_invisible(glyph))
1759 && keep_traps && !covers_traps(x, y)) {
1760 if ((t = t_at(x, y)) != 0 && t->tseen)
1761 glyph = trap_to_glyph(t);
1763 if ((glyph_is_object(glyph) && !keep_objs)
1764 || (glyph_is_trap(glyph) && !keep_traps)
1765 || glyph_is_invisible(glyph)) {
1767 glyph = default_glyph;
1768 } else if (lastseentyp[x][y] == levl[x][y].typ) {
1769 glyph = back_to_glyph(x, y);
1771 /* look for a mimic here posing as furniture;
1772 if we don't find one, we'll have to fake it */
1773 if ((mtmp = m_at(x, y)) != 0
1774 && mtmp->m_ap_type == M_AP_FURNITURE) {
1775 glyph = cmap_to_glyph(mtmp->mappearance);
1777 /* we have a topology type but we want a
1778 screen symbol in order to derive a glyph;
1779 some screen symbols need the flags field
1780 of levl[][] in addition to the type
1781 (to disambiguate STAIRS to S_upstair or
1782 S_dnstair, for example; current flags
1783 might not be intended for remembered
1784 type, but we've got no other choice) */
1785 schar save_typ = levl[x][y].typ;
1787 levl[x][y].typ = lastseentyp[x][y];
1788 glyph = back_to_glyph(x, y);
1789 levl[x][y].typ = save_typ;
1794 show_glyph(x, y, glyph);
1797 /* [TODO: highlight hero's location somehow] */
1798 u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
1803 Strcpy(buf, "underlying terrain");
1805 Strcpy(buf, "known terrain");
1807 Sprintf(eos(buf), "%s traps",
1808 (keep_objs || keep_mons) ? "," : " and");
1810 Sprintf(eos(buf), "%s%s objects",
1811 (keep_traps || keep_mons) ? "," : "",
1812 keep_mons ? "" : " and");
1814 Sprintf(eos(buf), "%s and monsters",
1815 (keep_traps || keep_objs) ? "," : "");
1817 pline("Showing %s only...", buf);
1818 display_nhwindow(WIN_MAP, TRUE); /* give "--More--" prompt */
1819 docrt(); /* redraw the screen, restoring regular map */