diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index f6ffcc5a9..85de14c5a 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1148,6 +1148,7 @@ prevent hug attacks and touch or engulf attacks for wrap, stick-to, and vortices, a few others) wand of speed gives temporary speed, potion gives intrinsic some monsters (riders, shopkeepers, priests, quest leader) can break boulders +corpse-eating monsters will go out of their way to eat corpses on the floor Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index 730ee3424..a41909a6a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1699,6 +1699,7 @@ extern int mstrength(struct permonst *); /* ### monmove.c ### */ extern boolean mon_would_take_item(struct monst *, struct obj *); +extern boolean mon_would_consume_item(struct monst *, struct obj *); extern boolean itsstuck(struct monst *); extern boolean mb_trapped(struct monst *, boolean); extern void mon_track_add(struct monst *, coordxy, coordxy); diff --git a/include/mondata.h b/include/mondata.h index 8db4b4249..04c9995c4 100644 --- a/include/mondata.h +++ b/include/mondata.h @@ -254,6 +254,12 @@ (vegan(ptr) \ || ((ptr)->mlet == S_PUDDING && (ptr) != &mons[PM_BLACK_PUDDING])) +#define corpse_eater(ptr) \ + (ptr == &mons[PM_PURPLE_WORM] \ + || ptr == &mons[PM_BABY_PURPLE_WORM] \ + || ptr == &mons[PM_GHOUL] \ + || ptr == &mons[PM_PIRANHA]) + /* monkeys are tamable via bananas but not pacifiable via food, otherwise their theft attack could be nullified too easily; dogs and cats can be tamed by anything they like to eat and are diff --git a/src/monmove.c b/src/monmove.c index f8f97c59d..45bc34e2c 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -910,6 +910,17 @@ mon_would_take_item(struct monst *mtmp, struct obj *otmp) return FALSE; } +/* monster mtmp would love to consume object otmp, without picking it up */ +boolean +mon_would_consume_item(struct monst *mtmp, struct obj *otmp) +{ + if (otmp->otyp == CORPSE && !touch_petrifies(&mons[otmp->corpsenm]) + && corpse_eater(mtmp->data)) + return TRUE; + + return FALSE; +} + boolean itsstuck(register struct monst* mtmp) { @@ -1224,8 +1235,9 @@ m_search_items(struct monst *mtmp, coordxy *ggx, coordxy *ggy, schar *mmoved, in if (costly && !otmp->no_charge) continue; - if (mon_would_take_item(mtmp, otmp) - && (can_carry(mtmp, otmp) > 0) + if (((mon_would_take_item(mtmp, otmp) + && (can_carry(mtmp, otmp) > 0)) + || mon_would_consume_item(mtmp, otmp)) && can_touch_safely(mtmp, otmp)) { minr = distmin(omx, omy, xx, yy); *ggx = otmp->ox; @@ -1794,9 +1806,7 @@ m_move(register struct monst* mtmp, register int after) return etmp; /* it died or got forced off the level */ } /* Maybe a purple worm ate a corpse */ - if (ptr == &mons[PM_PURPLE_WORM] - || ptr == &mons[PM_BABY_PURPLE_WORM] - || ptr == &mons[PM_PIRANHA]) { + if (corpse_eater(ptr)) { if ((etmp = meatcorpse(mtmp)) >= 2) return etmp; /* it died or got forced off the level */ }