fix #K3656 - chest in pit

Using #loot while in a pit allows looting containers in that pit.
Using open and specifying the hero's spot when not in a pit allows
looting containers at hero's spot.  But using open while in a pit
complained about not being able to reach out of the pit before player
had a chance to give hero's spot at the place of interest, so did not
allow looting any container there.

Get a target spot before rejecting use of 'open' while in a pit.
The alternate prompt might be tty-centric.
This commit is contained in:
PatR
2022-08-07 16:02:44 -07:00
parent b635160297
commit 4e6d3aba4f
3 changed files with 22 additions and 7 deletions

View File

@@ -756,6 +756,7 @@ doopen_indir(coordxy x, coordxy y)
coord cc;
register struct rm *door;
boolean portcullis;
const char *dirprompt;
int res = ECMD_OK;
if (nohands(g.youmonst.data)) {
@@ -763,21 +764,32 @@ doopen_indir(coordxy x, coordxy y)
return ECMD_OK;
}
if (u.utrap && u.utraptype == TT_PIT) {
You_cant("reach over the edge of the pit.");
return ECMD_OK;
}
dirprompt = NULL; /* have get_adjacent_loc() -> getdir() use default */
if (u.utrap && u.utraptype == TT_PIT && container_at(u.ux, u.uy, FALSE))
dirprompt = "Open where? [.>]";
if (x > 0 && y > 0) {
if (x > 0 && y >= 0) {
/* nonzero <x,y> is used when hero in amorphous form tries to
flow under a closed door at <x,y>; the test here was using
'y > 0' but that would give incorrect results if doors are
ever allowed to be placed on the top row of the map */
cc.x = x;
cc.y = y;
} else if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc))
} else if (!get_adjacent_loc(dirprompt, (char *) 0, u.ux, u.uy, &cc)) {
return ECMD_OK;
}
/* open at yourself/up/down */
if (u_at(cc.x, cc.y))
return doloot();
/* this used to be done prior to get_adjacent_loc() but doing so was
incorrect once open at hero's spot became an alternate way to loot */
if (u.utrap && u.utraptype == TT_PIT) {
You_cant("reach over the edge of the pit.");
return ECMD_OK;
}
if (stumble_on_door_mimic(cc.x, cc.y))
return ECMD_TIME;