MCPcopy Create free account
hub / github.com/NetHack/NetHack / display_monster

Function display_monster

src/display.c:513–622  ·  view source on GitHub ↗

* display_monster() * * Note that this is *not* a map_XXXX() function! Monsters sort of float * above everything. * * Yuck. Display body parts by recognizing that the display position is * not the same as the monster position. Currently the only body part is * a worm tail. * */

Source from the content-addressed store, hash-verified

511 *
512 */
513staticfn void
514display_monster(
515 coordxy x, coordxy y, /* display position */
516 struct monst *mon, /* monster to display */
517 int sightflags, /* 1 if the monster is physically seen;
518 * 2 if detected using Detect_monsters */
519 boolean worm_tail) /* mon is actually a worm tail */
520{
521 boolean mon_mimic = (M_AP_TYPE(mon) != M_AP_NOTHING);
522 int sensed = (mon_mimic && (Protection_from_shape_changers
523 || sensemon(mon))),
524 mgendercode = mon->female ? FEMALE : MALE;
525
526 /*
527 * We must do the mimic check first. If the mimic is mimicking something,
528 * and the location is in sight, we have to change the hero's memory
529 * so that when the position is out of sight, the hero remembers what
530 * the mimic was mimicking.
531 */
532 if (mon_mimic && (sightflags == PHYSICALLY_SEEN)) {
533 switch (M_AP_TYPE(mon)) {
534 default:
535 impossible("display_monster: bad m_ap_type value [ = %d ]",
536 (int) mon->m_ap_type);
537 FALLTHROUGH;
538 /*FALLTHRU*/
539 case M_AP_NOTHING:
540 show_glyph(x, y, mon_to_glyph(mon, newsym_rn2));
541 break;
542
543 case M_AP_FURNITURE: {
544 /*
545 * This is a poor man's version of map_background(). I can't
546 * use map_background() because we are overriding what is in
547 * the 'typ' field. Maybe have map_background()'s parameters
548 * be (x,y,glyph) instead of just (x,y).
549 *
550 * mappearance is currently set to an S_ index value in
551 * makemon.c.
552 */
553 int sym = mon->mappearance, glyph = cmap_to_glyph(sym);
554
555 levl[x][y].glyph = glyph;
556 if (!sensed) {
557 show_glyph(x, y, glyph);
558 /* override real topology with mimic's fake one */
559 svl.lastseentyp[x][y] = cmap_to_type(sym);
560 }
561 break;
562 }
563
564 case M_AP_OBJECT: {
565 /* Make a fake object to send to map_object(). */
566 struct obj obj;
567
568 obj = cg.zeroobj;
569 obj.ox = x;
570 obj.oy = y;

Callers 2

feel_locationFunction · 0.85
newsymFunction · 0.85

Calls 6

sensemonFunction · 0.85
show_glyphFunction · 0.85
cmap_to_typeFunction · 0.85
map_objectFunction · 0.85
show_mon_or_warnFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected