Gelatinous cubes eat organic objects inside them

This commit is contained in:
Pasi Kallinen
2024-12-08 17:57:59 +02:00
parent 78289a7f83
commit dafd854993
2 changed files with 31 additions and 0 deletions

View File

@@ -409,6 +409,32 @@ bee_eat_jelly(struct monst *mon, struct obj *obj)
return -1; /* a queen is already present; ordinary bee hasn't moved yet */
}
/* gelatinous cube eats something from its inventory */
static int
gelcube_digests(struct monst *mtmp)
{
struct obj *otmp = mtmp->minvent;
if (mtmp->meating || !mtmp->minvent)
return -1;
while (otmp) {
if (is_organic(otmp) && !otmp->oartifact
&& !is_mines_prize(otmp) && !is_soko_prize(otmp))
break;
otmp = otmp->nobj;
}
if (!otmp)
return -1;
mtmp->meating = eaten_stat(mtmp->meating, otmp);
extract_from_minvent(mtmp, otmp, TRUE, TRUE);
m_consume_obj(mtmp, otmp);
return 0; /* used a move */
}
/* FIXME: gremlins don't flee from monsters wielding Sunsword or wearing
gold dragon scales/mail, nor from gold dragons, only from the hero */
#define flees_light(mon) \
@@ -846,6 +872,10 @@ dochug(struct monst *mtmp)
&& (res = bee_eat_jelly(mtmp, otmp)) >= 0)
return res;
if (mdat == &mons[PM_GELATINOUS_CUBE]
&& (res = gelcube_digests(mtmp)) >= 0)
return res;
/* A monster that passes the following checks has the opportunity
to move. Movement itself is handled by the m_move() function. */
if (!nearby || mtmp->mflee || scared || mtmp->mconf || mtmp->mstun