From aaf16a3e24787f5858391a60f164f040b9feb509 Mon Sep 17 00:00:00 2001 From: iks Date: Fri, 1 Feb 2013 17:47:34 +0000 Subject: [PATCH] Enable to open chests or disarm traps at player's feet when there are chests and/or traps on neighboring floors. --- src/cmd2.c | 17 +++++++++++------ src/xtra2.c | 33 +++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/cmd2.c b/src/cmd2.c index 251a555e7..03b9b041e 100644 --- a/src/cmd2.c +++ b/src/cmd2.c @@ -438,7 +438,7 @@ void do_cmd_search(void) /* * Determine if a grid contains a chest */ -static s16b chest_check(int y, int x) +static s16b chest_check(int y, int x, bool trapped) { cave_type *c_ptr = &cave[y][x]; @@ -459,8 +459,13 @@ static s16b chest_check(int y, int x) /* Skip unknown chests XXX XXX */ /* if (!(o_ptr->marked & OM_FOUND)) continue; */ - /* Check for chest */ - if (o_ptr->tval == TV_CHEST) return (this_o_idx); + /* Check for non empty chest */ + if ((o_ptr->tval == TV_CHEST) && + (((!trapped) && (o_ptr->pval)) || /* non empty */ + ((trapped) && (o_ptr->pval > 0)))) /* trapped only */ + { + return (this_o_idx); + } } /* No chest */ @@ -1032,7 +1037,7 @@ static int count_chests(int *y, int *x, bool trapped) int xx = px + ddx_ddd[d]; /* No (visible) chest is there */ - if ((o_idx = chest_check(yy, xx)) == 0) continue; + if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue; /* Grab the object */ o_ptr = &o_list[o_idx]; @@ -1261,7 +1266,7 @@ void do_cmd_open(void) feat = get_feat_mimic(c_ptr); /* Check for chest */ - o_idx = chest_check(y, x); + o_idx = chest_check(y, x, FALSE); /* Nothing useful */ if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx) @@ -2198,7 +2203,7 @@ void do_cmd_disarm(void) feat = get_feat_mimic(c_ptr); /* Check for chests */ - o_idx = chest_check(y, x); + o_idx = chest_check(y, x, TRUE); /* Disarm a trap */ if (!is_trap(feat) && !o_idx) diff --git a/src/xtra2.c b/src/xtra2.c index 4d20c82d4..76d95ebec 100644 --- a/src/xtra2.c +++ b/src/xtra2.c @@ -4510,6 +4510,7 @@ msg_print(" bool get_rep_dir(int *dp, bool under) { int dir; + cptr prompt; /* Initialize */ (*dp) = 0; @@ -4527,24 +4528,36 @@ bool get_rep_dir(int *dp, bool under) #endif /* ALLOW_REPEAT -- TNB */ + if (under) + { + prompt = _("Êý¸þ ('.'­¸µ, ESC¤ÇÃæÃÇ)? ", "Direction ('.' at feet, Escape to cancel)? "); + } + else + { + prompt = _("Êý¸þ (ESC¤ÇÃæÃÇ)? ", "Direction (Escape to cancel)? "); + } + /* Get a direction */ while (!dir) { char ch; /* Get a command (or Cancel) */ -#ifdef JP -if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break; -#else - if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break; -#endif + if (!get_com(prompt, &ch, TRUE)) break; + /* Look down */ + if ((under) && ((ch == '5') || (ch == '-') || (ch == '.'))) + { + dir = 5; + } + else + { + /* Look up the direction */ + dir = get_keymap_dir(ch); - /* Look up the direction */ - dir = get_keymap_dir(ch); - - /* Oops */ - if (!dir) bell(); + /* Oops */ + if (!dir) bell(); + } } /* Prevent weirdness */ -- 2.11.0