From 35cf7139885b3e4f98160e4491b27c089d2a7f59 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 12 Oct 2024 14:39:48 -0700 Subject: [PATCH] fix part of #S11588 - mons eating poisoned items Prevent non-poison resistant monsters that eat items from eating poisoned items. --- src/dog.c | 2 ++ src/mon.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dog.c b/src/dog.c index 11d13dcbd..deade5f5e 100644 --- a/src/dog.c +++ b/src/dog.c @@ -943,6 +943,8 @@ dogfood(struct monst *mon, struct obj *obj) starving, mblind; int fx; + if (obj->opoisoned && !resists_poison(mon)) + return POISON; if (is_quest_artifact(obj) || obj_resists(obj, 0, 95)) return obj->cursed ? TABU : APPORT; diff --git a/src/mon.c b/src/mon.c index 5d7ed1eea..fbf3bde86 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1435,8 +1435,9 @@ meatmetal(struct monst *mtmp) otmp = otmp->nexthere) { /* Don't eat indigestible/choking/inappropriate objects */ if ((mtmp->data == &mons[PM_RUST_MONSTER] && !is_rustprone(otmp)) - || (otmp->otyp == AMULET_OF_STRANGULATION) - || (otmp->otyp == RIN_SLOW_DIGESTION)) + || (otmp->otyp == AMULET_OF_STRANGULATION + || otmp->otyp == RIN_SLOW_DIGESTION) + || (otmp->opoisoned && !resists_poison(mtmp))) continue; if (is_metallic(otmp) && !obj_resists(otmp, 5, 95) && touch_artifact(otmp, mtmp)) { @@ -1548,6 +1549,7 @@ meatobj(struct monst* mtmp) /* for gelatinous cubes */ included for emphasis */ || (otmp->otyp == AMULET_OF_STRANGULATION || otmp->otyp == RIN_SLOW_DIGESTION) + || (otmp->opoisoned && !resists_poison(mtmp)) /* cockatrice corpses handled above; this touch_petrifies() check catches eggs */ || (mstoning(otmp) && !resists_ston(mtmp))