3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
18 #include "monsterrace-hook.h"
19 #include "objectkind-hook.h"
21 #include "projection.h"
22 #include "spells-summon.h"
23 #include "floor-events.h"
24 #include "player-move.h"
25 #include "monster-status.h"
27 #define REWARD_CHANCE 10
32 * @brief コンソール上におけるマップ表示の左上位置を返す /
33 * Calculates current boundaries Called below and from "do_cmd_locate()".
36 void panel_bounds_center(void)
40 get_screen_size(&wid, &hgt);
42 panel_row_max = panel_row_min + hgt - 1;
43 panel_row_prt = panel_row_min - 1;
44 panel_col_max = panel_col_min + wid - 1;
45 panel_col_prt = panel_col_min - 13;
49 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
53 * Handle a request to change the current panel
54 * Return TRUE if the panel was changed.
55 * Also used in do_cmd_locate
56 * @return 実際に再描画が必要だった場合TRUEを返す
58 static bool change_panel_xy(POSITION y, POSITION x)
60 POSITION dy = 0, dx = 0;
63 get_screen_size(&wid, &hgt);
65 if (y < panel_row_min) dy = -1;
66 if (y > panel_row_max) dy = 1;
67 if (x < panel_col_min) dx = -1;
68 if (x > panel_col_max) dx = 1;
70 if (!dy && !dx) return (FALSE);
72 return change_panel(dy, dx);
77 * @brief マップ描画のフォーカスを当てるべき座標を更新する
79 * Given an row (y) and col (x), this routine detects when a move
80 * off the screen has occurred and figures new borders. -RAK-
81 * "Update" forces a "full update" to take place.
82 * The map is reprinted if necessary, and "TRUE" is returned.
83 * @return 実際に再描画が必要だった場合TRUEを返す
85 void verify_panel(void)
87 POSITION y = p_ptr->y;
88 POSITION x = p_ptr->x;
96 get_screen_size(&wid, &hgt);
98 max_prow_min = current_floor_ptr->height - hgt;
99 max_pcol_min = current_floor_ptr->width - wid;
101 /* Bounds checking */
102 if (max_prow_min < 0) max_prow_min = 0;
103 if (max_pcol_min < 0) max_pcol_min = 0;
105 /* Center on player */
106 if (center_player && (center_running || !running))
108 /* Center vertically */
109 prow_min = y - hgt / 2;
110 if (prow_min < 0) prow_min = 0;
111 else if (prow_min > max_prow_min) prow_min = max_prow_min;
113 /* Center horizontally */
114 pcol_min = x - wid / 2;
115 if (pcol_min < 0) pcol_min = 0;
116 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
120 prow_min = panel_row_min;
121 pcol_min = panel_col_min;
123 /* Scroll screen when 2 grids from top/bottom edge */
124 if (y > panel_row_max - 2)
126 while (y > prow_min + hgt-1 - 2)
128 prow_min += (hgt / 2);
132 if (y < panel_row_min + 2)
134 while (y < prow_min + 2)
136 prow_min -= (hgt / 2);
140 if (prow_min > max_prow_min) prow_min = max_prow_min;
141 if (prow_min < 0) prow_min = 0;
143 /* Scroll screen when 4 grids from left/right edge */
144 if (x > panel_col_max - 4)
146 while (x > pcol_min + wid-1 - 4)
148 pcol_min += (wid / 2);
152 if (x < panel_col_min + 4)
154 while (x < pcol_min + 4)
156 pcol_min -= (wid / 2);
160 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
161 if (pcol_min < 0) pcol_min = 0;
164 /* Check for "no change" */
165 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
167 /* Save the new panel info */
168 panel_row_min = prow_min;
169 panel_col_min = pcol_min;
171 /* Hack -- optional disturb on "panel change" */
172 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
174 /* Recalculate the boundaries */
175 panel_bounds_center();
177 p_ptr->update |= (PU_MONSTERS);
178 p_ptr->redraw |= (PR_MAP);
179 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
185 /*** Targeting Code ***/
189 * Determine is a monster makes a reasonable target
191 * The concept of "targeting" was stolen from "Morgul" (?)
193 * The player can target any location, or any "target-able" monster.
195 * Currently, a monster is "target_able" if it is visible, and if
196 * the player can hit it with a projection, and the player is not
197 * hallucinating. This allows use of "use closest target" macros.
199 * Future versions may restrict the ability to target "trappers"
200 * and "mimics", but the semantics is a little bit weird.
202 bool target_able(MONSTER_IDX m_idx)
204 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
206 /* Monster must be alive */
207 if (!monster_is_valid(m_ptr)) return (FALSE);
209 /* Hack -- no targeting hallucinations */
210 if (p_ptr->image) return (FALSE);
212 /* Monster must be visible */
213 if (!m_ptr->ml) return (FALSE);
215 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
217 /* Monster must be projectable */
218 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
220 /* Hack -- Never target trappers */
221 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
231 * Update (if necessary) and verify (if possible) the target.
233 * We return TRUE if the target is "okay" and FALSE otherwise.
235 bool target_okay(void)
237 /* Accept stationary targets */
238 if (target_who < 0) return (TRUE);
240 /* Check moving targets */
243 /* Accept reasonable targets */
244 if (target_able(target_who))
246 monster_type *m_ptr = ¤t_floor_ptr->m_list[target_who];
248 /* Acquire monster location */
249 target_row = m_ptr->fy;
250 target_col = m_ptr->fx;
257 /* Assume no target */
263 * Hack -- help "select" a location (see below)
265 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
268 POSITION x2, y2, x3, y3, x4, y4;
269 POSITION_IDX b_i = -1, b_v = 9999;
272 /* Scan the locations */
273 for (i = 0; i < tmp_pos.n; i++)
279 /* Directed distance */
283 /* Verify quadrant */
284 if (dx && (x3 * dx <= 0)) continue;
285 if (dy && (y3 * dy <= 0)) continue;
287 /* Absolute distance */
291 /* Verify quadrant */
292 if (dy && !dx && (x4 > y4)) continue;
293 if (dx && !dy && (y4 > x4)) continue;
295 /* Approximate Double Distance */
296 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
298 /* Penalize location */
301 if ((b_i >= 0) && (v >= b_v)) continue;
311 * Hack -- determine if a given location is "interesting"
313 static bool target_set_accept(POSITION y, POSITION x)
316 OBJECT_IDX this_o_idx, next_o_idx = 0;
319 if (!(in_bounds(y, x))) return (FALSE);
321 /* Player grid is always interesting */
322 if (player_bold(y, x)) return (TRUE);
324 /* Handle hallucination */
325 if (p_ptr->image) return (FALSE);
327 /* Examine the grid */
328 g_ptr = ¤t_floor_ptr->grid_array[y][x];
330 /* Visible monsters */
333 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
335 /* Visible monsters */
336 if (m_ptr->ml) return (TRUE);
339 /* Scan all objects in the grid */
340 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
343 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
344 next_o_idx = o_ptr->next_o_idx;
346 /* Memorized object */
347 if (o_ptr->marked & OM_FOUND) return (TRUE);
350 /* Interesting memorized features */
351 if (g_ptr->info & (CAVE_MARK))
353 /* Notice object features */
354 if (g_ptr->info & CAVE_OBJECT) return (TRUE);
356 /* Feature code (applying "mimic" field) */
357 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
365 * Prepare the "temp" array for "target_set"
367 * Return the number of target_able monsters in the set.
369 static void target_set_prepare(BIT_FLAGS mode)
372 POSITION min_hgt, max_hgt, min_wid, max_wid;
374 if (mode & TARGET_KILL)
377 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
378 max_hgt = MIN((p_ptr->y + MAX_RANGE), current_floor_ptr->height - 1);
379 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
380 max_wid = MIN((p_ptr->x + MAX_RANGE), current_floor_ptr->width - 1);
382 else /* not targetting */
385 min_hgt = panel_row_min;
386 max_hgt = panel_row_max;
387 min_wid = panel_col_min;
388 max_wid = panel_col_max;
391 /* Reset "temp" array */
394 /* Scan the current panel */
395 for (y = min_hgt; y <= max_hgt; y++)
397 for (x = min_wid; x <= max_wid; x++)
401 /* Require "interesting" contents */
402 if (!target_set_accept(y, x)) continue;
404 g_ptr = ¤t_floor_ptr->grid_array[y][x];
406 /* Require target_able monsters for "TARGET_KILL" */
407 if ((mode & (TARGET_KILL)) && !target_able(g_ptr->m_idx)) continue;
409 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(¤t_floor_ptr->m_list[g_ptr->m_idx])) continue;
411 /* Save the location */
412 tmp_pos.x[tmp_pos.n] = x;
413 tmp_pos.y[tmp_pos.n] = y;
418 /* Set the sort hooks */
419 if (mode & (TARGET_KILL))
421 /* Target the nearest monster for shooting */
422 ang_sort_comp = ang_sort_comp_distance;
423 ang_sort_swap = ang_sort_swap_distance;
427 /* Look important grids first in Look command */
428 ang_sort_comp = ang_sort_comp_importance;
429 ang_sort_swap = ang_sort_swap_distance;
432 /* Sort the positions */
433 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
435 if (p_ptr->riding && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
440 tmp_pos.y[0] = tmp_pos.y[1];
443 tmp_pos.x[0] = tmp_pos.x[1];
448 void target_set_prepare_look(void){
449 target_set_prepare(TARGET_LOOK);
454 * Evaluate number of kill needed to gain level
456 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
458 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
460 s32b exp_mon, exp_adv;
461 u32b exp_mon_frac, exp_adv_frac;
463 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
468 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
478 /* The monster's experience point (assuming average monster speed) */
479 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
481 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
484 /* Total experience value for next level */
485 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
487 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
489 /* Experience value need to get */
490 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
493 /* You need to kill at least one monster to get any experience */
494 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
495 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
497 /* Extract number of monsters needed */
498 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
500 /* If 999 or more monsters needed, only display "999". */
501 num = MIN(999, exp_adv_frac);
503 /* Display the number */
504 sprintf(buf,"%03ld", (long int)num);
508 bool show_gold_on_floor = FALSE;
511 * Examine a grid, return a keypress.
513 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
514 * indicates that the "space" key should scan through the contents
515 * of the grid, instead of simply returning immediately. This lets
516 * the "look" command get complete information, without making the
517 * "target" command annoying.
519 * The "info" argument contains the "commands" which should be shown
520 * inside the "[xxx]" text. This string must never be empty, or grids
521 * containing monsters will be displayed with an extra comma.
523 * Note that if a monster is in the grid, we update both the monster
524 * recall info and the health bar info to track that monster.
526 * Eventually, we may allow multiple objects per grid, or objects
527 * and terrain features in the same grid.
529 * This function must handle blindness/hallucination.
531 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
533 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
534 OBJECT_IDX this_o_idx, next_o_idx = 0;
535 concptr s1 = "", s2 = "", s3 = "", x_info = "";
540 char out_val[MAX_NLEN+80];
541 OBJECT_IDX floor_list[23];
542 ITEM_NUMBER floor_num = 0;
544 /* Scan all objects in the grid */
547 floor_num = scan_floor(floor_list, y, x, 0x02);
551 x_info = _("x物 ", "x,");
555 /* Hack -- under the player */
556 if (player_bold(y, x))
569 s1 = _("ターゲット:", "Target:");
572 /* Hack -- hallucination */
575 concptr name = _("何か奇妙な物", "something strange");
577 /* Display a message */
579 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
581 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
585 move_cursor_relative(y, x);
588 /* Stop on everything but "return" */
589 if ((query != '\r') && (query != '\n')) return query;
596 /* Actual monsters */
597 if (g_ptr->m_idx && current_floor_ptr->m_list[g_ptr->m_idx].ml)
599 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
600 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
601 GAME_TEXT m_name[MAX_NLEN];
607 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
608 monster_race_track(m_ptr->ap_r_idx);
609 health_track(g_ptr->m_idx);
622 /* Recall on screen */
623 screen_roff(m_ptr->ap_r_idx, 0);
625 /* Hack -- Complete the prompt (again) */
626 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
633 /* Normal commands */
634 if (query != 'r') break;
639 /* Cleare recall text and repeat */
645 /* Describe, and prompt for recall */
646 evaluate_monster_exp(acount, m_ptr);
649 sprintf(out_val, "[%s]%s%s(%s)%s%s [r思 %s%s]", acount, s1, m_name, look_mon_desc(m_ptr, 0x01), s2, s3, x_info, info);
651 sprintf(out_val, "[%s]%s%s%s%s(%s) [r, %s%s]", acount, s1, s2, s3, m_name, look_mon_desc(m_ptr, 0x01), x_info, info);
657 move_cursor_relative(y, x);
662 /* Normal commands */
663 if (query != 'r') break;
669 /* Always stop at "normal" keys */
670 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
672 /* Sometimes stop at "space" key */
673 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
675 /* Change the intro */
676 s1 = _("それは", "It is ");
678 /* Hack -- take account of gender */
679 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
680 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
682 /* Use a preposition */
691 /* Scan all objects being carried */
692 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
694 GAME_TEXT o_name[MAX_NLEN];
697 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
698 next_o_idx = o_ptr->next_o_idx;
700 /* Obtain an object description */
701 object_desc(o_name, o_ptr, 0);
704 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
706 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
710 move_cursor_relative(y, x);
713 /* Always stop at "normal" keys */
714 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
716 /* Sometimes stop at "space" key */
717 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
719 /* Change the intro */
720 s2 = _("をまた", "also carrying ");
723 /* Use a preposition */
740 GAME_TEXT o_name[MAX_NLEN];
743 o_ptr = ¤t_floor_ptr->o_list[floor_list[0]];
745 object_desc(o_name, o_ptr, 0);
748 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
750 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
754 move_cursor_relative(y, x);
763 /* Provide one cushion before item listing */
766 /* Display rough information about items */
768 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
770 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
774 move_cursor_relative(y, x);
779 /* No request for listing */
780 if (query != 'x' && query != ' ') return query;
784 /** Display list of items **/
786 /* Continue scrolling list if requested */
794 show_gold_on_floor = TRUE;
795 (void)show_floor(0, y, x, &min_width);
796 show_gold_on_floor = FALSE;
800 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
802 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
809 /* Exit unless 'Enter' */
810 if (query != '\n' && query != '\r')
815 /* Get the object being moved. */
816 o_idx = g_ptr->o_idx;
818 /* Only rotate a pile of two or more objects. */
819 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
821 /* Remove the first object from the list. */
822 excise_object_idx(o_idx);
824 /* Find end of the list. */
826 while (current_floor_ptr->o_list[i].next_o_idx)
827 i = current_floor_ptr->o_list[i].next_o_idx;
829 /* Add after the last object. */
830 current_floor_ptr->o_list[i].next_o_idx = o_idx;
832 /* Loop and re-display the list */
839 /* Scan all objects in the grid */
840 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
843 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
844 next_o_idx = o_ptr->next_o_idx;
846 if (o_ptr->marked & OM_FOUND)
848 GAME_TEXT o_name[MAX_NLEN];
853 /* Obtain an object description */
854 object_desc(o_name, o_ptr, 0);
857 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
859 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
863 move_cursor_relative(y, x);
866 /* Always stop at "normal" keys */
867 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
869 /* Sometimes stop at "space" key */
870 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
872 /* Change the intro */
873 s1 = _("それは", "It is ");
876 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
890 /* Feature code (applying "mimic" field) */
891 feat = get_feat_mimic(g_ptr);
893 /* Require knowledge about grid, or ability to see grid */
894 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
900 f_ptr = &f_info[feat];
902 /* Terrain feature if needed */
903 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
907 /* Hack -- special handling for quest entrances */
908 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
910 /* Set the quest number temporary */
911 IDX old_quest = p_ptr->inside_quest;
915 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
918 p_ptr->inside_quest = g_ptr->special;
920 /* Get the quest text */
921 init_flags = INIT_NAME_ONLY;
923 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
925 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
926 quest[g_ptr->special].name, quest[g_ptr->special].level);
928 /* Reset the old quest number */
929 p_ptr->inside_quest = old_quest;
932 /* Hack -- special handling for building doors */
933 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
935 name = building[f_ptr->subtype].name;
937 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
939 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
941 else if (have_flag(f_ptr->flags, FF_TOWN))
943 name = town_info[g_ptr->special].name;
945 else if (p_ptr->wild_mode && (feat == feat_floor))
947 name = _("道", "road");
951 name = f_name + f_ptr->name;
957 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
958 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
959 have_flag(f_ptr->flags, FF_TOWN)))
964 /* Hack -- special introduction for store & building doors -KMW- */
965 if (have_flag(f_ptr->flags, FF_STORE) ||
966 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
967 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
968 have_flag(f_ptr->flags, FF_ENTRANCE))
973 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
974 have_flag(f_ptr->flags, FF_TOWN) ||
975 have_flag(f_ptr->flags, FF_SHALLOW) ||
976 have_flag(f_ptr->flags, FF_DEEP))
982 /* Pick proper indefinite article */
983 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
987 /* Display a message */
991 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
992 else sprintf(f_idx_str, "%d", g_ptr->feat);
994 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d) %d", s1, name, s2, s3, info, (unsigned int)g_ptr->info, f_idx_str, g_ptr->dist, g_ptr->cost, g_ptr->when, (int)y, (int)x, travel.cost[y][x]);
996 sprintf(out_val, "%s%s%s%s [%s] %x %s %d %d %d (%d,%d)", s1, s2, s3, name, info, g_ptr->info, f_idx_str, g_ptr->dist, g_ptr->cost, g_ptr->when, (int)y, (int)x);
1001 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
1003 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1007 move_cursor_relative(y, x);
1010 /* Always stop at "normal" keys */
1011 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1014 /* Stop on everything but "return" */
1015 if ((query != '\r') && (query != '\n')) return query;
1017 /* Repeat forever */
1023 * Handle "target" and "look".
1025 * Note that this code can be called from "get_aim_dir()".
1027 * All locations must be on the current panel. Consider the use of
1028 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1029 * some form of "scrolling" the map around the cursor.
1030 * That is, consider the possibility of "auto-scrolling" the screen
1031 * while the cursor moves around. This may require changes in the
1032 * "update_monster()" code to allow "visibility" even if off panel, and
1033 * may require dynamic recalculation of the "temp" grid set.
1035 * Hack -- targeting/observing an "outer border grid" may induce
1036 * problems, so this is not currently allowed.
1038 * The player can use the direction keys to move among "interesting"
1039 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1040 * move through the "interesting" grids in a sequential manner, or
1041 * can enter "location" mode, and use the direction keys to move one
1042 * grid at a time in any direction. The "t" (set target) command will
1043 * only target a monster (as opposed to a location) if the monster is
1044 * target_able and the "interesting" mode is being used.
1046 * The current grid is described using the "look" method above, and
1047 * a new command may be entered at any time, but note that if the
1048 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1049 * where "space" has no obvious meaning) then "space" will scan
1050 * through the description of the current grid until done, instead
1051 * of immediately jumping to the next "interesting" grid. This
1052 * allows the "target" command to retain its old semantics.
1054 * The "*", "+", and "-" keys may always be used to jump immediately
1055 * to the next (or previous) interesting grid, in the proper mode.
1057 * The "return" key may always be used to scan through a complete
1058 * grid description (forever).
1060 * This command will cancel any old target, even if used from
1061 * inside the "look" command.
1063 bool target_set(BIT_FLAGS mode)
1066 POSITION y = p_ptr->y;
1067 POSITION x = p_ptr->x;
1077 get_screen_size(&wid, &hgt);
1082 if (rogue_like_commands)
1091 /* Prepare the "temp" array */
1092 target_set_prepare(mode);
1094 /* Start near the player */
1100 /* Interesting grids */
1101 if (flag && tmp_pos.n)
1107 change_panel_xy(y, x);
1109 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1112 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1115 if (target_able(g_ptr->m_idx))
1117 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1120 /* Dis-allow target */
1123 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1129 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1130 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
1131 strcat(info, cheatinfo);
1134 /* Describe and Prompt */
1136 query = target_set_aux(y, x, mode, info);
1140 /* Assume no "direction" */
1145 if (query == '\r') query = 't';
1163 if (target_able(g_ptr->m_idx))
1165 health_track(g_ptr->m_idx);
1166 target_who = g_ptr->m_idx;
1182 if (++m == tmp_pos.n)
1185 if (!expand_list) done = TRUE;
1195 if (!expand_list) done = TRUE;
1202 /* Recenter the map around the player */
1204 p_ptr->update |= (PU_MONSTERS);
1205 p_ptr->redraw |= (PR_MAP);
1206 p_ptr->window |= (PW_OVERHEAD);
1209 /* Recalculate interesting grids */
1210 target_set_prepare(mode);
1229 if(query == same_key)
1231 if (++m == tmp_pos.n)
1234 if (!expand_list) done = TRUE;
1239 /* Extract the action (if any) */
1240 d = get_keymap_dir(query);
1247 /* Hack -- move around */
1250 /* Modified to scroll to monster */
1251 POSITION y2 = panel_row_min;
1252 POSITION x2 = panel_col_min;
1254 /* Find a new monster */
1255 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1257 /* Request to target past last interesting grid */
1258 while (flag && (i < 0))
1260 /* Note the change */
1261 if (change_panel(ddy[d], ddx[d]))
1263 int v = tmp_pos.y[m];
1264 int u = tmp_pos.x[m];
1266 /* Recalculate interesting grids */
1267 target_set_prepare(mode);
1269 /* Look at interesting grids */
1272 /* Find a new monster */
1273 i = target_pick(v, u, ddy[d], ddx[d]);
1279 /* Nothing interesting */
1282 POSITION dx = ddx[d];
1283 POSITION dy = ddy[d];
1285 /* Restore previous position */
1288 panel_bounds_center();
1290 p_ptr->update |= (PU_MONSTERS);
1291 p_ptr->redraw |= (PR_MAP);
1292 p_ptr->window |= (PW_OVERHEAD);
1295 /* Recalculate interesting grids */
1296 target_set_prepare(mode);
1298 /* Look at boring grids */
1305 /* Do not move horizontally if unnecessary */
1306 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1307 ((x > panel_col_min + wid / 2) && (dx < 0)))
1312 /* Do not move vertically if unnecessary */
1313 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1314 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1319 /* Apply the motion */
1320 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1321 (x >= panel_col_min+wid) || (x < panel_col_min))
1323 if (change_panel(dy, dx)) target_set_prepare(mode);
1326 /* Slide into legality */
1327 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1328 else if (x <= 0) x = 1;
1330 /* Slide into legality */
1331 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1332 else if (y <= 0) y = 1;
1341 /* Arbitrary grids */
1344 bool move_fast = FALSE;
1346 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1349 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1351 /* Default prompt */
1352 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1357 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1358 los(p_ptr->y, p_ptr->x, y, x),
1359 projectable(p_ptr->y, p_ptr->x, y, x));
1360 strcat(info, cheatinfo);
1363 /* Describe and Prompt (enable "TARGET_LOOK") */
1364 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
1366 /* Assume no direction */
1371 if (query == '\r') query = 't';
1374 /* Analyze the keypress */
1398 /* Recenter the map around the player */
1400 p_ptr->update |= (PU_MONSTERS);
1401 p_ptr->redraw |= (PR_MAP);
1402 p_ptr->window |= (PW_OVERHEAD);
1405 /* Recalculate interesting grids */
1406 target_set_prepare(mode);
1428 /* Pick a nearby monster */
1429 for (i = 0; i < tmp_pos.n; i++)
1431 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1441 /* Nothing interesting */
1442 if (bd == 999) flag = FALSE;
1449 /* Extract the action (if any) */
1450 d = get_keymap_dir(query);
1452 /* XTRA HACK MOVEFAST */
1453 if (isupper(query)) move_fast = TRUE;
1460 /* Handle "direction" */
1463 POSITION dx = ddx[d];
1464 POSITION dy = ddy[d];
1466 /* XTRA HACK MOVEFAST */
1469 int mag = MIN(wid / 2, hgt / 2);
1479 /* Do not move horizontally if unnecessary */
1480 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1481 ((x > panel_col_min + wid / 2) && (dx < 0)))
1486 /* Do not move vertically if unnecessary */
1487 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1488 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1493 /* Apply the motion */
1494 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1495 (x >= panel_col_min + wid) || (x < panel_col_min))
1497 if (change_panel(dy, dx)) target_set_prepare(mode);
1500 /* Slide into legality */
1501 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1502 else if (x <= 0) x = 1;
1504 /* Slide into legality */
1505 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1506 else if (y <= 0) y = 1;
1514 /* Clear the top line */
1517 /* Recenter the map around the player */
1519 p_ptr->update |= (PU_MONSTERS);
1520 p_ptr->redraw |= (PR_MAP);
1521 p_ptr->window |= (PW_OVERHEAD);
1524 /* Failure to set target */
1525 if (!target_who) return (FALSE);
1533 * Get an "aiming direction" from the user.
1535 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1536 * "0" for "current target", and "-1" for "entry aborted".
1538 * Note that "Force Target", if set, will pre-empt user interaction,
1539 * if there is a usable target already set.
1541 * Note that confusion over-rides any (explicit?) user choice.
1543 bool get_aim_dir(DIRECTION *dp)
1552 /* Global direction */
1555 /* Hack -- auto-target if requested */
1556 if (use_old_target && target_okay()) dir = 5;
1558 if (repeat_pull(&code))
1563 if (!(code == 5 && !target_okay()))
1565 /* return (TRUE); */
1566 dir = (DIRECTION)code;
1569 *dp = (DIRECTION)code;
1571 /* Ask until satisfied */
1574 /* Choose a prompt */
1577 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1581 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1584 /* Get a command (or Cancel) */
1585 if (!get_com(p, &command, TRUE)) break;
1589 if (command == '\r') command = 't';
1592 /* Convert various keys to "standard" keys */
1595 /* Use current target */
1606 /* Set new target */
1611 if (target_set(TARGET_KILL)) dir = 5;
1617 /* Extract the action (if any) */
1618 dir = get_keymap_dir(command);
1624 /* Verify requested targets */
1625 if ((dir == 5) && !target_okay()) dir = 0;
1634 project_length = 0; /* reset to default */
1638 /* Save the direction */
1641 /* Check for confusion */
1642 if (p_ptr->confused)
1644 /* Random direction */
1645 dir = ddd[randint0(8)];
1648 /* Notice confusion */
1649 if (command_dir != dir)
1652 msg_print(_("あなたは混乱している。", "You are confused."));
1655 /* Save direction */
1658 /* repeat_push(dir); */
1659 repeat_push((COMMAND_CODE)command_dir);
1661 /* A "valid" direction was entered */
1666 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
1674 /* Global direction */
1677 if (repeat_pull(&code))
1679 dir = (DIRECTION)code;
1680 /* return (TRUE); */
1682 *dp = (DIRECTION)code;
1686 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1690 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1693 /* Get a direction */
1698 /* Get a command (or Cancel) */
1699 if (!get_com(prompt, &ch, TRUE)) break;
1702 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1708 /* Look up the direction */
1709 dir = get_keymap_dir(ch);
1715 /* Prevent weirdness */
1716 if ((dir == 5) && (!allow_under)) dir = 0;
1719 if (!dir) return (FALSE);
1721 /* Save desired direction */
1724 /* Apply "confusion" */
1725 if (p_ptr->confused)
1727 /* Standard confusion */
1728 if (randint0(100) < 75)
1730 /* Random direction */
1731 dir = ddd[randint0(8)];
1734 else if (p_ptr->riding && with_steed)
1736 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1737 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1739 if (MON_CONFUSED(m_ptr))
1741 /* Standard confusion */
1742 if (randint0(100) < 75)
1744 /* Random direction */
1745 dir = ddd[randint0(8)];
1748 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1750 /* Random direction */
1751 dir = ddd[randint0(8)];
1753 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1755 /* Random direction */
1756 dir = ddd[randint0(8)];
1760 /* Notice confusion */
1761 if (command_dir != dir)
1763 if (p_ptr->confused)
1766 msg_print(_("あなたは混乱している。", "You are confused."));
1770 GAME_TEXT m_name[MAX_NLEN];
1771 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1773 monster_desc(m_name, m_ptr, 0);
1774 if (MON_CONFUSED(m_ptr))
1776 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
1780 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1785 /* Save direction */
1788 /* repeat_push(dir); */
1789 repeat_push((COMMAND_CODE)command_dir);
1796 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1797 * and place it into "command_dir", unless we already have one.
1799 * This function should be used for all "repeatable" commands, such as
1800 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1801 * as all commands which must reference a grid adjacent to the player,
1802 * and which may not reference the grid under the player. Note that,
1803 * for example, it is no longer possible to "disarm" or "open" chests
1804 * in the same grid as the player.
1806 * Direction "5" is illegal and will (cleanly) abort the command.
1808 * This function tracks and uses the "global direction", and uses
1809 * that as the "desired direction", to which "confusion" is applied.
1811 bool get_rep_dir(DIRECTION *dp, bool under)
1819 /* Global direction */
1822 if (repeat_pull(&code))
1824 dir = (DIRECTION)code;
1825 /* return (TRUE); */
1827 *dp = (DIRECTION)code;
1831 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1835 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1838 /* Get a direction */
1843 /* Get a command (or Cancel) */
1844 if (!get_com(prompt, &ch, TRUE)) break;
1847 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1853 /* Look up the direction */
1854 dir = get_keymap_dir(ch);
1860 /* Prevent weirdness */
1861 if ((dir == 5) && (!under)) dir = 0;
1864 if (!dir) return (FALSE);
1866 /* Save desired direction */
1869 /* Apply "confusion" */
1870 if (p_ptr->confused)
1872 /* Standard confusion */
1873 if (randint0(100) < 75)
1875 /* Random direction */
1876 dir = ddd[randint0(8)];
1879 else if (p_ptr->riding)
1881 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1882 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1884 if (MON_CONFUSED(m_ptr))
1886 /* Standard confusion */
1887 if (randint0(100) < 75)
1889 /* Random direction */
1890 dir = ddd[randint0(8)];
1893 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1895 /* Random direction */
1896 dir = ddd[randint0(8)];
1898 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1900 /* Random direction */
1901 dir = ddd[randint0(8)];
1905 /* Notice confusion */
1906 if (command_dir != dir)
1908 if (p_ptr->confused)
1911 msg_print(_("あなたは混乱している。", "You are confused."));
1915 GAME_TEXT m_name[MAX_NLEN];
1916 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1918 monster_desc(m_name, m_ptr, 0);
1919 if (MON_CONFUSED(m_ptr))
1921 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
1925 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1930 /* Save direction */
1933 /* repeat_push(dir); */
1934 repeat_push((COMMAND_CODE)command_dir);
1942 * XAngband: determine if a given location is "interesting"
1943 * based on target_set_accept function.
1945 static bool tgt_pt_accept(POSITION y, POSITION x)
1950 if (!(in_bounds(y, x))) return (FALSE);
1952 /* Player grid is always interesting */
1953 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
1955 /* Handle hallucination */
1956 if (p_ptr->image) return (FALSE);
1958 /* Examine the grid */
1959 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1961 /* Interesting memorized features */
1962 if (g_ptr->info & (CAVE_MARK))
1965 if (cave_have_flag_grid(g_ptr, FF_LESS)) return (TRUE);
1966 if (cave_have_flag_grid(g_ptr, FF_MORE)) return (TRUE);
1968 /* Notice quest features */
1969 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return (TRUE);
1970 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return (TRUE);
1978 * XAngband: Prepare the "temp" array for "tget_pt"
1979 * based on target_set_prepare funciton.
1981 static void tgt_pt_prepare(void)
1985 /* Reset "temp" array */
1988 if (!expand_list) return;
1990 /* Scan the current panel */
1991 for (y = 1; y < current_floor_ptr->height; y++)
1993 for (x = 1; x < current_floor_ptr->width; x++)
1995 /* Require "interesting" contents */
1996 if (!tgt_pt_accept(y, x)) continue;
1998 /* Save the location */
1999 tmp_pos.x[tmp_pos.n] = x;
2000 tmp_pos.y[tmp_pos.n] = y;
2005 /* Target the nearest monster for shooting */
2006 ang_sort_comp = ang_sort_comp_distance;
2007 ang_sort_swap = ang_sort_swap_distance;
2009 /* Sort the positions */
2010 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
2014 * old -- from PsiAngband.
2016 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
2021 bool success = FALSE;
2025 get_screen_size(&wid, &hgt);
2035 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2036 msg_flag = FALSE; /* prevents "-more-" message. */
2038 while ((ch != ESCAPE) && !success)
2040 bool move_fast = FALSE;
2042 move_cursor_relative(y, x);
2054 if (player_bold(y, x)) ch = 0;
2057 else success = TRUE;
2061 /* XAngband: Move cursor to stairs */
2064 if (expand_list && tmp_pos.n)
2067 int cx = (panel_col_min + panel_col_max) / 2;
2068 int cy = (panel_row_min + panel_row_max) / 2;
2072 /* Skip stairs which have defferent distance */
2073 for (; n < tmp_pos.n; ++ n)
2075 grid_type *g_ptr = ¤t_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2077 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2078 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2085 if (n == tmp_pos.n) /* Loop out taget list */
2090 verify_panel(); /* Move cursor to player */
2092 p_ptr->update |= (PU_MONSTERS);
2094 p_ptr->redraw |= (PR_MAP);
2096 p_ptr->window |= (PW_OVERHEAD);
2099 else /* move cursor to next stair and change panel */
2104 dy = 2 * (y - cy) / hgt;
2105 dx = 2 * (x - cx) / wid;
2106 if (dy || dx) change_panel(dy, dx);
2112 /* Look up the direction */
2113 d = get_keymap_dir(ch);
2115 /* XTRA HACK MOVEFAST */
2116 if (isupper(ch)) move_fast = TRUE;
2118 /* Handle "direction" */
2124 /* XTRA HACK MOVEFAST */
2127 int mag = MIN(wid / 2, hgt / 2);
2137 /* Do not move horizontally if unnecessary */
2138 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2139 ((x > panel_col_min + wid / 2) && (dx < 0)))
2144 /* Do not move vertically if unnecessary */
2145 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2146 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2151 /* Apply the motion */
2152 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2153 (x >= panel_col_min + wid) || (x < panel_col_min))
2155 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
2156 change_panel(dy, dx);
2159 /* Slide into legality */
2160 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
2161 else if (x <= 0) x = 1;
2163 /* Slide into legality */
2164 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
2165 else if (y <= 0) y = 1;
2172 /* Clear the top line */
2175 /* Recenter the map around the player */
2178 p_ptr->update |= (PU_MONSTERS);
2180 p_ptr->redraw |= (PR_MAP);
2182 p_ptr->window |= (PW_OVERHEAD);
2191 bool get_hack_dir(DIRECTION *dp)
2199 /* Global direction */
2202 /* (No auto-targeting) */
2204 /* Ask until satisfied */
2207 /* Choose a prompt */
2210 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2214 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2217 /* Get a command (or Cancel) */
2218 if (!get_com(p, &command, TRUE)) break;
2222 if (command == '\r') command = 't';
2225 /* Convert various keys to "standard" keys */
2228 /* Use current target */
2239 /* Set new target */
2244 if (target_set(TARGET_KILL)) dir = 5;
2250 /* Look up the direction */
2251 dir = get_keymap_dir(command);
2257 /* Verify requested targets */
2258 if ((dir == 5) && !target_okay()) dir = 0;
2265 if (!dir) return (FALSE);
2267 /* Save the direction */
2270 /* Check for confusion */
2271 if (p_ptr->confused)
2273 /* Random direction */
2274 dir = ddd[randint0(8)];
2277 /* Notice confusion */
2278 if (command_dir != dir)
2281 msg_print(_("あなたは混乱している。", "You are confused."));
2284 /* Save direction */
2287 /* A "valid" direction was entered */