Corpse-eating monsters will home in on corpses

Also allow non-tame ghouls to eat corpses.
This commit is contained in:
Pasi Kallinen
2023-04-20 18:49:29 +03:00
parent 8293251224
commit a725447d65
4 changed files with 23 additions and 5 deletions

View File

@@ -1148,6 +1148,7 @@ prevent hug attacks and touch or engulf attacks for wrap, stick-to, and
vortices, a few others) vortices, a few others)
wand of speed gives temporary speed, potion gives intrinsic wand of speed gives temporary speed, potion gives intrinsic
some monsters (riders, shopkeepers, priests, quest leader) can break boulders 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 Fixes to 3.7.0-x General Problems Exposed Via git Repository

View File

@@ -1699,6 +1699,7 @@ extern int mstrength(struct permonst *);
/* ### monmove.c ### */ /* ### monmove.c ### */
extern boolean mon_would_take_item(struct monst *, struct obj *); 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 itsstuck(struct monst *);
extern boolean mb_trapped(struct monst *, boolean); extern boolean mb_trapped(struct monst *, boolean);
extern void mon_track_add(struct monst *, coordxy, coordxy); extern void mon_track_add(struct monst *, coordxy, coordxy);

View File

@@ -254,6 +254,12 @@
(vegan(ptr) \ (vegan(ptr) \
|| ((ptr)->mlet == S_PUDDING && (ptr) != &mons[PM_BLACK_PUDDING])) || ((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, /* monkeys are tamable via bananas but not pacifiable via food,
otherwise their theft attack could be nullified too easily; otherwise their theft attack could be nullified too easily;
dogs and cats can be tamed by anything they like to eat and are dogs and cats can be tamed by anything they like to eat and are

View File

@@ -910,6 +910,17 @@ mon_would_take_item(struct monst *mtmp, struct obj *otmp)
return FALSE; 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 boolean
itsstuck(register struct monst* mtmp) 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) if (costly && !otmp->no_charge)
continue; continue;
if (mon_would_take_item(mtmp, otmp) if (((mon_would_take_item(mtmp, otmp)
&& (can_carry(mtmp, otmp) > 0) && (can_carry(mtmp, otmp) > 0))
|| mon_would_consume_item(mtmp, otmp))
&& can_touch_safely(mtmp, otmp)) { && can_touch_safely(mtmp, otmp)) {
minr = distmin(omx, omy, xx, yy); minr = distmin(omx, omy, xx, yy);
*ggx = otmp->ox; *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 */ return etmp; /* it died or got forced off the level */
} }
/* Maybe a purple worm ate a corpse */ /* Maybe a purple worm ate a corpse */
if (ptr == &mons[PM_PURPLE_WORM] if (corpse_eater(ptr)) {
|| ptr == &mons[PM_BABY_PURPLE_WORM]
|| ptr == &mons[PM_PIRANHA]) {
if ((etmp = meatcorpse(mtmp)) >= 2) if ((etmp = meatcorpse(mtmp)) >= 2)
return etmp; /* it died or got forced off the level */ return etmp; /* it died or got forced off the level */
} }