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

Function still_chewing

src/hack.c:646–822  ·  view source on GitHub ↗

* still_chewing() * * Chew on a wall, door, or boulder. [What about statues?] * Returns TRUE if still eating, FALSE when done. */

Source from the content-addressed store, hash-verified

644 * Returns TRUE if still eating, FALSE when done.
645 */
646int
647still_chewing(coordxy x, coordxy y)
648{
649 struct rm *lev = &levl[x][y];
650 struct obj *boulder = sobj_at(BOULDER, x, y);
651 const char *digtxt = (char *) 0, *dmgtxt = (char *) 0;
652
653 if (svc.context.digging.down) /* not continuing prev dig (w/ pick-axe) */
654 (void) memset((genericptr_t) &svc.context.digging, 0,
655 sizeof (struct dig_info));
656
657 if (!boulder
658 && ((IS_OBSTRUCTED(lev->typ) && !may_dig(x, y))
659 /* may_dig() checks W_NONDIGGABLE but doesn't handle iron bars */
660 || (lev->typ == IRONBARS && (lev->wall_info & W_NONDIGGABLE)))) {
661 You("hurt your teeth on the %s.",
662 (lev->typ == IRONBARS)
663 ? "bars"
664 : IS_TREE(lev->typ)
665 ? "tree"
666 : "hard stone");
667 nomul(0);
668 return 1;
669 } else if (lev->typ == IRONBARS
670 && metallivorous(gy.youmonst.data) && u.uhunger > 1500) {
671 /* finishing eating via 'morehungry()' doesn't handle choking */
672 You("are too full to eat the bars.");
673 nomul(0);
674 return 1;
675 } else if (!svc.context.digging.chew
676 || svc.context.digging.pos.x != x
677 || svc.context.digging.pos.y != y
678 || !on_level(&svc.context.digging.level, &u.uz)) {
679 svc.context.digging.down = FALSE;
680 svc.context.digging.chew = TRUE;
681 svc.context.digging.warned = FALSE;
682 svc.context.digging.pos.x = x;
683 svc.context.digging.pos.y = y;
684 assign_level(&svc.context.digging.level, &u.uz);
685 /* solid rock takes more work & time to dig through */
686 svc.context.digging.effort =
687 (IS_OBSTRUCTED(lev->typ) && !IS_TREE(lev->typ) ? 30 : 60) + u.udaminc;
688 You("start chewing %s %s.",
689 (boulder || IS_TREE(lev->typ) || lev->typ == IRONBARS)
690 ? "on a"
691 : "a hole in the",
692 boulder
693 ? "boulder"
694 : IS_TREE(lev->typ)
695 ? "tree"
696 : IS_OBSTRUCTED(lev->typ)
697 ? "rock"
698 : (lev->typ == IRONBARS)
699 ? "bar"
700 : "door");
701 watch_dig((struct monst *) 0, x, y, FALSE);
702 return 1;
703 } else if ((svc.context.digging.effort += (30 + u.udaminc)) <= 100) {

Callers 2

test_moveFunction · 0.85
doeatFunction · 0.85

Calls 15

sobj_atFunction · 0.85
may_digFunction · 0.85
YouFunction · 0.85
nomulFunction · 0.85
on_levelFunction · 0.85
assign_levelFunction · 0.85
watch_digFunction · 0.85
livelog_printfFunction · 0.85
rndFunction · 0.85
delobjFunction · 0.85
closed_doorFunction · 0.85
block_pointFunction · 0.85

Tested by 1

test_moveFunction · 0.68