From dcf18b2b69aceda9b123bfefe0f11f75cd652ffc Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 3 Oct 2024 12:50:10 -0700 Subject: [PATCH] fix #K4292 - tame hider-under vs cursed object A pet with the hides-under attribute could hide under cursed objects if it first moved reluctantly to their location. Also, the messages seem contradictory: | The cobra slithers reluctantly over a scroll labeled DUAM XNAHT. | You see your cobra slither under a scroll labeled DUAM XNAHT. First over, then under, but that was actually accurate; the monster moved, then after it was on the pile it hid underneath. Change hideunder() to not let pets hide under an object if it is cursed or any object in its pile is cursed. Initially I was just going to check the top item and the item directly beneath it, but reluctance to move there extends to the whole pile so I made hiding do so too. Change the first message to move reluctantly "onto" an object since "over" suggests that it has continued past the item, unless it is actually flying or levitating so truly "over" the pile. --- doc/fixes3-7-0.txt | 2 ++ src/dogmove.c | 7 +++++-- src/mon.c | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 6dd35d38e..b30fbb712 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1471,6 +1471,8 @@ interactively setting a status highlight for hunger with 'O' and choosing 'text match' could crash while setting up the menu of hunger status value strings; happened for curses or if the program was built to use C++ regex processing but not for tty+posixregex +a pet with the hides-under attribute could "move reluctantly over" a cursed + object and then hide under it Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/dogmove.c b/src/dogmove.c index f35a873b7..6e25c39c2 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -1270,8 +1270,11 @@ dog_move( ? vobj_at(nix, niy) : 0; const char *what = o ? distant_name(o, doname) : something; - pline("%s %s reluctantly over %s.", noit_Monnam(mtmp), - vtense((char *) 0, locomotion(mtmp->data, "step")), what); + pline("%s %s reluctantly %s %s.", noit_Monnam(mtmp), + vtense((char *) 0, locomotion(mtmp->data, "step")), + (is_flyer(mtmp->data) || is_floater(mtmp->data)) ? "over" + : "onto", + what); } mon_track_add(mtmp, omx, omy); /* We have to know if the pet's going to do a combined eat and diff --git a/src/mon.c b/src/mon.c index a52f9a051..5d7ed1eea 100644 --- a/src/mon.c +++ b/src/mon.c @@ -4555,6 +4555,9 @@ hideunder(struct monst *mtmp) && (otmp = svl.level.objects[x][y]) != 0 /* most things can be hidden under, but not all */ && can_hide_under_obj(otmp) + /* pets won't hide under a cursed item or an item of any BUC + state that shares a pile with one or more cursed items */ + && (!mtmp->mtame || !cursed_object_at(x, y)) /* aquatic creatures don't reach here; other swimmers shouldn't hide beneath underwater objects */ && !is_pool_or_lava(x, y)) {