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

Function meatobj

src/mon.c:1532–1649  ·  view source on GitHub ↗

monster eats a pile of objects */

Source from the content-addressed store, hash-verified

1530
1531/* monster eats a pile of objects */
1532int
1533meatobj(struct monst *mtmp) /* for gelatinous cubes */
1534{
1535 struct obj *otmp, *otmp2;
1536 struct permonst *ptr, *original_ptr = mtmp->data;
1537 int count = 0, ecount = 0;
1538 char buf[BUFSZ], *otmpname;
1539
1540 buf[0] = '\0';
1541 /* If a pet, eating is handled separately, in dog.c */
1542 if (mtmp->mtame)
1543 return 0;
1544
1545 /* eat organic objects, including cloth and wood, if present;
1546 engulf others, except huge rocks and metal attached to player
1547 [despite comment at top, doesn't assume that eater is a g-cube] */
1548 for (otmp = svl.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
1549 otmp2 = otmp->nexthere;
1550
1551 /* avoid special items; once hero picks them up, they'll cease
1552 being special, becoming eligible for engulf and devore if
1553 dropped again */
1554 if (is_mines_prize(otmp) || is_soko_prize(otmp))
1555 continue;
1556
1557 /* touch sensitive items */
1558 if (otmp->otyp == CORPSE && is_rider(&mons[otmp->corpsenm])) {
1559 int ox = otmp->ox, oy = otmp->oy;
1560 boolean revived_it = revive_corpse(otmp);
1561
1562 newsym(ox, oy);
1563 /* Rider corpse isn't just inedible; can't engulf it either */
1564 if (!revived_it)
1565 continue;
1566 /* [should check whether revival forced 'mtmp' off the level
1567 and return 3 in that situation (if possible...)] */
1568 break;
1569
1570 /* untouchable (or inaccessible) items */
1571 } else if ((otmp->otyp == CORPSE
1572 && touch_petrifies(&mons[otmp->corpsenm])
1573 && !resists_ston(mtmp))
1574 /* don't engulf boulders and statues or ball&chain */
1575 || otmp->oclass == ROCK_CLASS
1576 || otmp == uball || otmp == uchain
1577 /* normally mtmp won't have stepped onto scare monster
1578 scroll, but if it does, don't eat or engulf that
1579 (note: scrolls inside eaten containers will still
1580 become engulfed) */
1581 || otmp->otyp == SCR_SCARE_MONSTER) {
1582 /* do nothing--neither eaten nor engulfed */
1583 continue;
1584
1585 /* inedible items -- engulf these */
1586 } else if (!is_organic(otmp) || obj_resists(otmp, 5, 95)
1587 || !touch_artifact(otmp, mtmp)
1588 /* redundant due to non-organic composition but
1589 included for emphasis */

Callers 1

monmove.cFile · 0.85

Calls 13

revive_corpseFunction · 0.85
newsymFunction · 0.85
obj_resistsFunction · 0.85
touch_artifactFunction · 0.85
distant_nameFunction · 0.85
MonnamFunction · 0.85
obj_extract_selfFunction · 0.85
mpickobjFunction · 0.85
pline_monFunction · 0.85
objdescr_isFunction · 0.85
You_hearFunction · 0.85
m_consume_objFunction · 0.85

Tested by

no test coverage detected