Fix: m-prefix looting a container

Using #loot with the 'm' prefix would claim there was nothing to loot
even if the hero was standing on a box, as long as there was no adjacent
monster.  'm' prefix is an explicit request to select a direction so
make it work regardless of whether a monster is there.  Once I did that
I noticed that it was providing no feedback for using '.' or '>' as the
direction if no container was available, so adjust that to give the
"there is nothing here to loot" feedback.
This commit is contained in:
Michael Meyer
2022-08-10 19:55:42 +03:00
committed by Pasi Kallinen
parent 121d79ab6b
commit 9c9a8ff797
+8 -6
View File
@@ -2091,7 +2091,8 @@ doloot_core(void)
* 3.3.1 introduced directional looting for some things. * 3.3.1 introduced directional looting for some things.
*/ */
lootmon: lootmon:
if (c != 'y' && mon_beside(u.ux, u.uy)) { if (c != 'y' && (mon_beside(u.ux, u.uy) || iflags.menu_requested)) {
boolean looted_mon = FALSE;
if (!get_adjacent_loc("Loot in what direction?", if (!get_adjacent_loc("Loot in what direction?",
"Invalid loot location", u.ux, u.uy, &cc)) "Invalid loot location", u.ux, u.uy, &cc))
return ECMD_OK; return ECMD_OK;
@@ -2107,7 +2108,7 @@ doloot_core(void)
if (mtmp) { if (mtmp) {
timepassed = loot_mon(mtmp, &prev_inquiry, &prev_loot); timepassed = loot_mon(mtmp, &prev_inquiry, &prev_loot);
if (timepassed) if (timepassed)
underfoot = 1; /* not true but skips dont_find_anything */ looted_mon = TRUE;
} }
/* always use a turn when choosing a direction is impaired, /* always use a turn when choosing a direction is impaired,
even if you've successfully targetted a saddled creature even if you've successfully targetted a saddled creature
@@ -2119,8 +2120,8 @@ doloot_core(void)
* Adjust this if-block to allow container looting * Adjust this if-block to allow container looting
* from one square away to change that in the future. * from one square away to change that in the future.
*/ */
if (!underfoot) { if (!looted_mon) {
if (container_at(cc.x, cc.y, FALSE)) { if (!underfoot && container_at(cc.x, cc.y, FALSE)) {
if (mtmp) { if (mtmp) {
You_cant("loot anything %sthere with %s in the way.", You_cant("loot anything %sthere with %s in the way.",
prev_inquiry ? "else " : "", mon_nam(mtmp)); prev_inquiry ? "else " : "", mon_nam(mtmp));
@@ -2129,8 +2130,9 @@ doloot_core(void)
You("have to be at a container to loot it."); You("have to be at a container to loot it.");
} }
} else { } else {
You("%s %sthere to loot.", dont_find_anything, You("%s %s%shere to loot.", dont_find_anything,
(prev_inquiry || prev_loot) ? "else " : ""); (prev_inquiry || prev_loot) ? "else " : "",
!underfoot ? "t" : "");
return (timepassed ? ECMD_TIME : ECMD_OK); return (timepassed ? ECMD_TIME : ECMD_OK);
} }
} }