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

Function m_consume_obj

src/mon.c:1391–1453  ·  view source on GitHub ↗

Monster mtmp consumes an object. Monster may die, polymorph, grow up, heal, etc; meating is not changed. Object is extracted from any linked list and freed. */

Source from the content-addressed store, hash-verified

1389 Monster may die, polymorph, grow up, heal, etc; meating is not changed.
1390 Object is extracted from any linked list and freed. */
1391void
1392m_consume_obj(struct monst *mtmp, struct obj *otmp)
1393{
1394 boolean ispet = mtmp->mtame;
1395
1396 /* non-pet: Heal up to the object's weight in hp */
1397 if (!ispet && mtmp->mhp < mtmp->mhpmax) {
1398 healmon(mtmp, objects[otmp->otyp].oc_weight, 0);
1399 }
1400 if (Has_contents(otmp))
1401 meatbox(mtmp, otmp);
1402 if (otmp == uball) {
1403 unpunish();
1404 delobj(otmp);
1405 } else if (otmp == uchain) {
1406 unpunish(); /* frees uchain */
1407 } else {
1408 boolean deadmimic, slimer;
1409 int poly, grow, heal, eyes, mstone, vis = canseemon(mtmp);
1410 int corpsenm = (otmp->otyp == CORPSE ? otmp->corpsenm : NON_PM);
1411
1412 deadmimic = (otmp->otyp == CORPSE && (corpsenm == PM_SMALL_MIMIC
1413 || corpsenm == PM_LARGE_MIMIC
1414 || corpsenm == PM_GIANT_MIMIC));
1415 slimer = (otmp->otyp == GLOB_OF_GREEN_SLIME);
1416 poly = polyfood(otmp);
1417 grow = mlevelgain(otmp);
1418 heal = mhealup(otmp);
1419 eyes = (otmp->otyp == CARROT);
1420 mstone = mstoning(otmp);
1421 delobj(otmp); /* munch */
1422 if (poly || slimer) {
1423 struct permonst *ptr = slimer ? &mons[PM_GREEN_SLIME] : 0;
1424
1425 (void) newcham(mtmp, ptr, vis ? NC_SHOW_MSG : NO_NC_FLAGS);
1426 }
1427 if (grow) {
1428 if ((ispet && (int) mtmp->m_lev < (int) mtmp->data->mlevel + 15)
1429 || !ispet)
1430 (void) grow_up(mtmp, (struct monst *) 0);
1431 }
1432 if (mstone) {
1433 if (poly_when_stoned(mtmp->data)) {
1434 mon_to_stone(mtmp);
1435 } else if (!resists_ston(mtmp)) {
1436 if (vis)
1437 pline_mon(mtmp, "%s turns to stone!",
1438 Monnam(mtmp));
1439 monstone(mtmp);
1440 }
1441 }
1442 if (heal)
1443 healmon(mtmp, mtmp->mhpmax, 0);
1444 if ((eyes || heal) && !mtmp->mcansee)
1445 mcureblindness(mtmp, canseemon(mtmp));
1446 if (ispet && deadmimic)
1447 quickmimic(mtmp);
1448 if (otmp->otyp == EGG && corpsenm == PM_PYROLISK)

Callers 5

dog_eatFunction · 0.85
meatmetalFunction · 0.85
meatobjFunction · 0.85
meatcorpseFunction · 0.85
gelcube_digestsFunction · 0.85

Calls 15

healmonFunction · 0.85
meatboxFunction · 0.85
unpunishFunction · 0.85
delobjFunction · 0.85
canseemonFunction · 0.85
newchamFunction · 0.85
grow_upFunction · 0.85
poly_when_stonedFunction · 0.85
mon_to_stoneFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
monstoneFunction · 0.85

Tested by

no test coverage detected