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. */
| 1389 | Monster may die, polymorph, grow up, heal, etc; meating is not changed. |
| 1390 | Object is extracted from any linked list and freed. */ |
| 1391 | void |
| 1392 | m_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) |
no test coverage detected