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

Function digactualhole

src/dig.c:639–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637}
638
639void
640digactualhole(coordxy x, coordxy y, struct monst *madeby, int ttyp)
641{
642 struct obj *oldobjs, *newobjs;
643 struct trap *ttmp;
644 const char *surface_type, *tname, *in_thru;
645 char furniture[BUFSZ];
646 struct rm *lev = &levl[x][y];
647 struct monst *mtmp = m_at(x, y); /* may be madeby */
648 boolean madeby_u = (madeby == BY_YOU), madeby_obj = (madeby == BY_OBJECT),
649 /* BY_OBJECT means the hero broke a wand, so blame her for it */
650 heros_fault = (madeby_u || madeby_obj);
651 boolean shopdoor, at_u = u_at(x, y), wont_fall = Levitation || Flying;
652 int old_typ, old_aligntyp = A_NONE;
653
654 if (at_u && u.utrap) {
655 if (u.utraptype == TT_BURIEDBALL)
656 buried_ball_to_punishment();
657 else if (u.utraptype == TT_INFLOOR)
658 reset_utrap(FALSE);
659 }
660
661 if (furniture_handled(x, y, madeby_u))
662 return;
663
664 if (ttyp != PIT && (!Can_dig_down(&u.uz) && !lev->candig)) {
665 impossible("digactualhole: can't dig %s on this level.",
666 trapname(ttyp, TRUE));
667 ttyp = PIT;
668 }
669
670 /* maketrap() might change terrain type but we deliver messages after
671 that, so prepare in advance */
672 old_typ = lev->typ;
673 furniture[0] = '\0';
674 if (IS_FURNITURE(lev->typ)) {
675 /* should mirror the word used by surface() for normal floor */
676 surface_type = (IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz)
677 ? "floor" : "ground");
678 if (IS_ALTAR(lev->typ)) {
679 old_aligntyp = Amask2align(levl[x][y].altarmask & AM_MASK);
680 Strcpy(furniture, align_str(old_aligntyp));
681 Strcat(furniture, " ");
682 }
683 Strcat(furniture, surface(x, y));
684 } else {
685 surface_type = surface(x, y);
686 }
687 shopdoor = IS_DOOR(lev->typ) && *in_rooms(x, y, SHOPBASE);
688 oldobjs = svl.level.objects[x][y];
689
690 ttmp = maketrap(x, y, ttyp);
691 if (!ttmp)
692 return;
693 newobjs = svl.level.objects[x][y];
694 ttmp->madeby_u = heros_fault;
695 ttmp->tseen = 0;
696 if (cansee(x, y))

Callers 2

digholeFunction · 0.85
do_break_wandFunction · 0.85

Calls 15

reset_utrapFunction · 0.85
furniture_handledFunction · 0.85
Can_dig_downFunction · 0.85
trapnameFunction · 0.85
align_strFunction · 0.85
surfaceFunction · 0.85
in_roomsFunction · 0.85
maketrapFunction · 0.85
seetrapFunction · 0.85
feeltrapFunction · 0.85
YouFunction · 0.85

Tested by

no test coverage detected