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

Function lookat

src/pager.c:656–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654 * If not hallucinating and the glyph is a monster, also monster data.
655 */
656staticfn struct permonst *
657lookat(coordxy x, coordxy y, char *buf, char *monbuf)
658{
659 struct monst *mtmp = (struct monst *) 0;
660 struct permonst *pm = (struct permonst *) 0;
661 int glyph;
662
663 buf[0] = monbuf[0] = '\0';
664 glyph = glyph_at(x, y);
665 if (u_at(x, y) && canspotself()
666 && !(iflags.save_uswallow
667 && glyph == mon_to_glyph(u.ustuck, rn2_on_display_rng))
668 && (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0)) {
669 /* fill in buf[] */
670 (void) self_lookat(buf);
671
672 /* file lookup can't distinguish between "gnomish wizard" monster
673 and correspondingly named player character, always picking the
674 former; force it to find the general "wizard" entry instead */
675 if (Role_if(PM_WIZARD) && Race_if(PM_GNOME) && !Upolyd)
676 pm = &mons[PM_WIZARD];
677
678 /* When you see yourself normally, no explanation is appended
679 (even if you could also see yourself via other means).
680 Sensing self while blind or swallowed is treated as if it
681 were by normal vision (cf canseeself()). */
682 if ((Invisible || u.uundetected) && !Blind
683 && !(u.uswallow || iflags.save_uswallow)) {
684 unsigned how = 0;
685
686 if (Infravision)
687 how |= 1;
688 if (Unblind_telepat)
689 how |= 2;
690 if (Detect_monsters)
691 how |= 4;
692
693 if (how)
694 Sprintf(eos(buf), " [seen: %s%s%s%s%s]",
695 (how & 1) ? "infravision" : "",
696 /* add comma if telep and infrav */
697 ((how & 3) > 2) ? ", " : "",
698 (how & 2) ? "telepathy" : "",
699 /* add comma if detect and (infrav or telep or both) */
700 ((how & 7) > 4) ? ", " : "",
701 (how & 4) ? "monster detection" : "");
702 }
703 } else if (u.uswallow) {
704 /* when swallowed, we're only called for spots adjacent to hero,
705 and blindness doesn't prevent hero from feeling what holds him */
706 Sprintf(buf, "interior of %s", mon_nam(u.ustuck));
707 pm = u.ustuck->data;
708 } else if (glyph_is_monster(glyph)) {
709 if ((mtmp = m_at(x, y)) != 0) {
710 look_at_monster(buf, monbuf, mtmp, x, y);
711 pm = mtmp->data;
712 } else if (Hallucination) {
713 /* 'monster' must actually be a statue */

Callers 1

do_screen_descriptionFunction · 0.85

Calls 13

glyph_atFunction · 0.85
self_lookatFunction · 0.85
eosFunction · 0.85
mon_namFunction · 0.85
look_at_monsterFunction · 0.85
rndmonnamFunction · 0.85
look_at_objectFunction · 0.85
trap_descriptionFunction · 0.85
glyph_to_cmapFunction · 0.85
altarmask_atFunction · 0.85
align_strFunction · 0.85
is_drawbridge_wallFunction · 0.85

Tested by

no test coverage detected