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.
This commit is contained in:
PatR
2024-10-03 12:50:10 -07:00
parent 5653da2c54
commit dcf18b2b69
3 changed files with 10 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)) {