fix github issue #1072 - pets pick up cursed items

Issue reported by vultur-cadens:  tame monsters capable of using items
would pick up cursed ones and even wear cursed armor.

The report cites commit 6c9700ab25 but
I don't see any reason why it would be the cause.  However, I was able
to reproduce the misbehavior and this commit seems to fix it.

Fixes #1072
This commit is contained in:
PatR
2023-07-08 15:24:40 -07:00
parent 8948ad0327
commit 7b32ce02ea
2 changed files with 18 additions and 2 deletions

View File

@@ -1644,6 +1644,7 @@ hero might not be credited with "entered Mine Town" achievement for the town
entered via falling or level teleport
in the theme room "water-surrounded vault", guarantee an item which can be
be used to escape from the room in one of the four chests
pets capable of using items would pick up and wear cursed armor
Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository

View File

@@ -885,6 +885,8 @@ mon_would_take_item(struct monst *mtmp, struct obj *otmp)
if (otmp == uball || otmp == uchain)
return FALSE;
if (mtmp->mtame && otmp->cursed)
return FALSE; /* note: will get overridden if mtmp will eat otmp */
if (is_unicorn(mtmp->data) && objects[otmp->otyp].oc_material != GEMSTONE)
return FALSE;
if (!mindless(mtmp->data) && !is_animal(mtmp->data) && pctload < 75
@@ -916,10 +918,17 @@ mon_would_take_item(struct monst *mtmp, struct obj *otmp)
boolean
mon_would_consume_item(struct monst *mtmp, struct obj *otmp)
{
int ftyp;
if (otmp->otyp == CORPSE && !touch_petrifies(&mons[otmp->corpsenm])
&& corpse_eater(mtmp->data))
return TRUE;
if (mtmp->mtame && has_edog(mtmp) /* has_edog(): not guardian angel */
&& (ftyp = dogfood(mtmp, otmp)) < MANFOOD
&& (ftyp < ACCFOOD || EDOG(mtmp)->hungrytime <= gm.moves))
return TRUE;
return FALSE;
}
@@ -1148,7 +1157,11 @@ maybe_spin_web(struct monst *mtmp)
/* monster looks for items it wants nearby */
static boolean
m_search_items(struct monst *mtmp, coordxy *ggx, coordxy *ggy, schar *mmoved, int *appr)
m_search_items(
struct monst *mtmp,
coordxy *ggx, coordxy *ggy,
schar *mmoved,
int *appr)
{
register int minr = SQSRCHRADIUS; /* not too far away */
register struct obj *otmp;
@@ -1802,8 +1815,10 @@ m_move(register struct monst *mtmp, int after)
u.ux = mtmp->mx;
u.uy = mtmp->my;
swallowed(0);
} else
} else {
newsym(mtmp->mx, mtmp->my);
}
#undef UnblockDoor
}
if (OBJ_AT(mtmp->mx, mtmp->my) && mtmp->mcanmove) {