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.
18 #include "targeting.h"
22 #include "dungeon-file.h"
23 #include "object-curse.h"
24 #include "object-flavor.h"
26 #include "monsterrace-hook.h"
27 #include "objectkind-hook.h"
29 #include "spells-summon.h"
32 #include "floor-events.h"
33 #include "floor-town.h"
34 #include "player-move.h"
35 #include "player-status.h"
36 #include "monster-status.h"
37 #include "view-mainwindow.h"
45 * @brief コンソール上におけるマップ表示の左上位置を返す /
46 * Calculates current boundaries Called below and from "do_cmd_locate()".
49 void panel_bounds_center(void)
53 get_screen_size(&wid, &hgt);
55 panel_row_max = panel_row_min + hgt - 1;
56 panel_row_prt = panel_row_min - 1;
57 panel_col_max = panel_col_min + wid - 1;
58 panel_col_prt = panel_col_min - 13;
62 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
66 * Handle a request to change the current panel
67 * Return TRUE if the panel was changed.
68 * Also used in do_cmd_locate
69 * @return 実際に再描画が必要だった場合TRUEを返す
71 static bool change_panel_xy(POSITION y, POSITION x)
73 POSITION dy = 0, dx = 0;
76 get_screen_size(&wid, &hgt);
78 if (y < panel_row_min) dy = -1;
79 if (y > panel_row_max) dy = 1;
80 if (x < panel_col_min) dx = -1;
81 if (x > panel_col_max) dx = 1;
83 if (!dy && !dx) return (FALSE);
85 return change_panel(dy, dx);
90 * @brief マップ描画のフォーカスを当てるべき座標を更新する
92 * Given an row (y) and col (x), this routine detects when a move
93 * off the screen has occurred and figures new borders. -RAK-
94 * "Update" forces a "full update" to take place.
95 * The map is reprinted if necessary, and "TRUE" is returned.
96 * @return 実際に再描画が必要だった場合TRUEを返す
98 void verify_panel(void)
100 POSITION y = p_ptr->y;
101 POSITION x = p_ptr->x;
109 get_screen_size(&wid, &hgt);
111 max_prow_min = current_floor_ptr->height - hgt;
112 max_pcol_min = current_floor_ptr->width - wid;
114 /* Bounds checking */
115 if (max_prow_min < 0) max_prow_min = 0;
116 if (max_pcol_min < 0) max_pcol_min = 0;
118 /* Center on player */
119 if (center_player && (center_running || !p_ptr->running))
121 /* Center vertically */
122 prow_min = y - hgt / 2;
123 if (prow_min < 0) prow_min = 0;
124 else if (prow_min > max_prow_min) prow_min = max_prow_min;
126 /* Center horizontally */
127 pcol_min = x - wid / 2;
128 if (pcol_min < 0) pcol_min = 0;
129 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
133 prow_min = panel_row_min;
134 pcol_min = panel_col_min;
136 /* Scroll screen when 2 grids from top/bottom edge */
137 if (y > panel_row_max - 2)
139 while (y > prow_min + hgt-1 - 2)
141 prow_min += (hgt / 2);
145 if (y < panel_row_min + 2)
147 while (y < prow_min + 2)
149 prow_min -= (hgt / 2);
153 if (prow_min > max_prow_min) prow_min = max_prow_min;
154 if (prow_min < 0) prow_min = 0;
156 /* Scroll screen when 4 grids from left/right edge */
157 if (x > panel_col_max - 4)
159 while (x > pcol_min + wid-1 - 4)
161 pcol_min += (wid / 2);
165 if (x < panel_col_min + 4)
167 while (x < pcol_min + 4)
169 pcol_min -= (wid / 2);
173 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
174 if (pcol_min < 0) pcol_min = 0;
177 /* Check for "no change" */
178 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
180 /* Save the new panel info */
181 panel_row_min = prow_min;
182 panel_col_min = pcol_min;
184 /* Hack -- optional disturb on "panel change" */
185 if (disturb_panel && !center_player) disturb(p_ptr, FALSE, FALSE);
187 panel_bounds_center();
189 p_ptr->update |= (PU_MONSTERS);
190 p_ptr->redraw |= (PR_MAP);
191 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
195 /*** Targeting Code ***/
198 * Determine is a monster makes a reasonable target
200 * The concept of "targeting" was stolen from "Morgul" (?)
202 * The player can target any location, or any "target-able" monster.
204 * Currently, a monster is "target_able" if it is visible, and if
205 * the player can hit it with a projection, and the player is not
206 * hallucinating. This allows use of "use closest target" macros.
208 * Future versions may restrict the ability to target "trappers"
209 * and "mimics", but the semantics is a little bit weird.
211 bool target_able(MONSTER_IDX m_idx)
213 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
215 /* Monster must be alive */
216 if (!monster_is_valid(m_ptr)) return (FALSE);
218 /* Hack -- no targeting hallucinations */
219 if (p_ptr->image) return (FALSE);
221 /* Monster must be visible */
222 if (!m_ptr->ml) return (FALSE);
224 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
226 /* Monster must be projectable */
227 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
229 /* Hack -- Never target trappers */
230 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
238 * Targetting variables
240 MONSTER_IDX target_who;
245 * Update (if necessary) and verify (if possible) the target.
247 * We return TRUE if the target is "okay" and FALSE otherwise.
249 bool target_okay(void)
251 /* Accept stationary targets */
252 if (target_who < 0) return (TRUE);
254 /* Check moving targets */
257 /* Accept reasonable targets */
258 if (target_able(target_who))
260 monster_type *m_ptr = ¤t_floor_ptr->m_list[target_who];
262 /* Acquire monster location */
263 target_row = m_ptr->fy;
264 target_col = m_ptr->fx;
271 /* Assume no target */
277 * Hack -- help "select" a location (see below)
279 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
282 POSITION x2, y2, x3, y3, x4, y4;
283 POSITION_IDX b_i = -1, b_v = 9999;
286 /* Scan the locations */
287 for (i = 0; i < tmp_pos.n; i++)
293 /* Directed distance */
297 /* Verify quadrant */
298 if (dx && (x3 * dx <= 0)) continue;
299 if (dy && (y3 * dy <= 0)) continue;
304 /* Verify quadrant */
305 if (dy && !dx && (x4 > y4)) continue;
306 if (dx && !dy && (y4 > x4)) continue;
308 /* Approximate Double Distance */
309 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
311 /* Penalize location */
312 if ((b_i >= 0) && (v >= b_v)) continue;
320 * Hack -- determine if a given location is "interesting"
322 static bool target_set_accept(POSITION y, POSITION x)
325 OBJECT_IDX this_o_idx, next_o_idx = 0;
327 if (!(in_bounds(current_floor_ptr, y, x))) return (FALSE);
329 /* Player grid is always interesting */
330 if (player_bold(y, x)) return (TRUE);
332 if (p_ptr->image) return (FALSE);
334 g_ptr = ¤t_floor_ptr->grid_array[y][x];
336 /* Visible monsters */
339 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
341 /* Visible monsters */
342 if (m_ptr->ml) return (TRUE);
345 /* Scan all objects in the grid */
346 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
349 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
350 next_o_idx = o_ptr->next_o_idx;
352 /* Memorized object */
353 if (o_ptr->marked & OM_FOUND) return (TRUE);
356 /* Interesting memorized features */
357 if (g_ptr->info & (CAVE_MARK))
359 /* Notice object features */
360 if (g_ptr->info & CAVE_OBJECT) return (TRUE);
362 /* Feature code (applying "mimic" field) */
363 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
371 * Prepare the "temp" array for "target_set"
373 * Return the number of target_able monsters in the set.
375 static void target_set_prepare(BIT_FLAGS mode)
378 POSITION min_hgt, max_hgt, min_wid, max_wid;
380 if (mode & TARGET_KILL)
383 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
384 max_hgt = MIN((p_ptr->y + MAX_RANGE), current_floor_ptr->height - 1);
385 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
386 max_wid = MIN((p_ptr->x + MAX_RANGE), current_floor_ptr->width - 1);
388 else /* not targetting */
391 min_hgt = panel_row_min;
392 max_hgt = panel_row_max;
393 min_wid = panel_col_min;
394 max_wid = panel_col_max;
397 /* Reset "temp" array */
400 /* Scan the current panel */
401 for (y = min_hgt; y <= max_hgt; y++)
403 for (x = min_wid; x <= max_wid; x++)
407 /* Require "interesting" contents */
408 if (!target_set_accept(y, x)) continue;
410 g_ptr = ¤t_floor_ptr->grid_array[y][x];
412 /* Require target_able monsters for "TARGET_KILL" */
413 if ((mode & (TARGET_KILL)) && !target_able(g_ptr->m_idx)) continue;
415 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(¤t_floor_ptr->m_list[g_ptr->m_idx])) continue;
417 /* Save the location */
418 tmp_pos.x[tmp_pos.n] = x;
419 tmp_pos.y[tmp_pos.n] = y;
424 /* Set the sort hooks */
425 if (mode & (TARGET_KILL))
427 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
431 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
434 if (p_ptr->riding && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
439 tmp_pos.y[0] = tmp_pos.y[1];
442 tmp_pos.x[0] = tmp_pos.x[1];
447 void target_set_prepare_look(void){
448 target_set_prepare(TARGET_LOOK);
453 * Evaluate number of kill needed to gain level
455 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
457 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
459 s32b exp_mon, exp_adv;
460 u32b exp_mon_frac, exp_adv_frac;
462 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
467 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
469 if (!current_world_ptr->wizard)
477 /* The monster's experience point (assuming average monster speed) */
478 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
480 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
483 /* Total experience value for next level */
484 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
486 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
488 /* Experience value need to get */
489 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
492 /* You need to kill at least one monster to get any experience */
493 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
494 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
496 /* Extract number of monsters needed */
497 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
499 /* If 999 or more monsters needed, only display "999". */
500 num = MIN(999, exp_adv_frac);
502 /* Display the number */
503 sprintf(buf,"%03ld", (long int)num);
507 bool show_gold_on_floor = FALSE;
510 * Examine a grid, return a keypress.
512 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
513 * indicates that the "space" key should scan through the contents
514 * of the grid, instead of simply returning immediately. This lets
515 * the "look" command get complete information, without making the
516 * "target" command annoying.
518 * The "info" argument contains the "commands" which should be shown
519 * inside the "[xxx]" text. This string must never be empty, or grids
520 * containing monsters will be displayed with an extra comma.
522 * Note that if a monster is in the grid, we update both the monster
523 * recall info and the health bar info to track that monster.
525 * Eventually, we may allow multiple objects per grid, or objects
526 * and terrain features in the same grid.
528 * This function must handle blindness/hallucination.
530 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
532 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
533 OBJECT_IDX this_o_idx, next_o_idx = 0;
534 concptr s1 = "", s2 = "", s3 = "", x_info = "";
539 char out_val[MAX_NLEN+80];
540 OBJECT_IDX floor_list[23];
541 ITEM_NUMBER floor_num = 0;
543 /* Scan all objects in the grid */
546 floor_num = scan_floor(floor_list, y, x, 0x02);
550 x_info = _("x物 ", "x,");
554 /* Hack -- under the player */
555 if (player_bold(y, x))
568 s1 = _("ターゲット:", "Target:");
571 /* Hack -- hallucination */
574 concptr name = _("何か奇妙な物", "something strange");
576 /* Display a message */
578 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
580 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
584 move_cursor_relative(y, x);
587 /* Stop on everything but "return" */
588 if ((query != '\r') && (query != '\n')) return query;
595 /* Actual monsters */
596 if (g_ptr->m_idx && current_floor_ptr->m_list[g_ptr->m_idx].ml)
598 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
599 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
600 GAME_TEXT m_name[MAX_NLEN];
606 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
607 monster_race_track(m_ptr->ap_r_idx);
608 health_track(g_ptr->m_idx);
620 /* Recall on screen */
621 screen_roff(m_ptr->ap_r_idx, 0);
623 /* Hack -- Complete the prompt (again) */
624 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
630 /* Normal commands */
631 if (query != 'r') break;
635 /* Cleare recall text and repeat */
641 /* Describe, and prompt for recall */
642 evaluate_monster_exp(acount, m_ptr);
645 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);
647 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);
653 move_cursor_relative(y, x);
657 /* Normal commands */
658 if (query != 'r') break;
663 /* Always stop at "normal" keys */
664 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
666 /* Sometimes stop at "space" key */
667 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
669 /* Change the intro */
670 s1 = _("それは", "It is ");
672 /* Hack -- take account of gender */
673 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
674 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
676 /* Use a preposition */
685 /* Scan all objects being carried */
686 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
688 GAME_TEXT o_name[MAX_NLEN];
691 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
692 next_o_idx = o_ptr->next_o_idx;
694 object_desc(o_name, o_ptr, 0);
697 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
699 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
703 move_cursor_relative(y, x);
706 /* Always stop at "normal" keys */
707 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
709 /* Sometimes stop at "space" key */
710 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
712 /* Change the intro */
713 s2 = _("をまた", "also carrying ");
716 /* Use a preposition */
733 GAME_TEXT o_name[MAX_NLEN];
736 o_ptr = ¤t_floor_ptr->o_list[floor_list[0]];
738 object_desc(o_name, o_ptr, 0);
741 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
743 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
747 move_cursor_relative(y, x);
755 /* Provide one cushion before item listing */
758 /* Display rough information about items */
760 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
762 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
766 move_cursor_relative(y, x);
770 /* No request for listing */
771 if (query != 'x' && query != ' ') return query;
775 /** Display list of items **/
777 /* Continue scrolling list if requested */
785 show_gold_on_floor = TRUE;
786 (void)show_floor(0, y, x, &min_width);
787 show_gold_on_floor = FALSE;
791 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
793 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
800 /* Exit unless 'Enter' */
801 if (query != '\n' && query != '\r')
806 /* Get the object being moved. */
807 o_idx = g_ptr->o_idx;
809 /* Only rotate a pile of two or more objects. */
810 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
812 /* Remove the first object from the list. */
813 excise_object_idx(o_idx);
815 /* Find end of the list. */
817 while (current_floor_ptr->o_list[i].next_o_idx)
818 i = current_floor_ptr->o_list[i].next_o_idx;
820 /* Add after the last object. */
821 current_floor_ptr->o_list[i].next_o_idx = o_idx;
823 /* Loop and re-display the list */
830 /* Scan all objects in the grid */
831 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
834 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
835 next_o_idx = o_ptr->next_o_idx;
837 if (o_ptr->marked & OM_FOUND)
839 GAME_TEXT o_name[MAX_NLEN];
844 object_desc(o_name, o_ptr, 0);
847 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
849 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
853 move_cursor_relative(y, x);
856 /* Always stop at "normal" keys */
857 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
859 /* Sometimes stop at "space" key */
860 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
862 /* Change the intro */
863 s1 = _("それは", "It is ");
866 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
880 /* Feature code (applying "mimic" field) */
881 feat = get_feat_mimic(g_ptr);
883 /* Require knowledge about grid, or ability to see grid */
884 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
890 f_ptr = &f_info[feat];
892 /* Terrain feature if needed */
893 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
897 /* Hack -- special handling for quest entrances */
898 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
900 /* Set the quest number temporary */
901 IDX old_quest = p_ptr->inside_quest;
905 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
908 p_ptr->inside_quest = g_ptr->special;
910 /* Get the quest text */
911 init_flags = INIT_NAME_ONLY;
913 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
915 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
916 quest[g_ptr->special].name, quest[g_ptr->special].level);
918 /* Reset the old quest number */
919 p_ptr->inside_quest = old_quest;
922 /* Hack -- special handling for building doors */
923 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
925 name = building[f_ptr->subtype].name;
927 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
929 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
931 else if (have_flag(f_ptr->flags, FF_TOWN))
933 name = town_info[g_ptr->special].name;
935 else if (p_ptr->wild_mode && (feat == feat_floor))
937 name = _("道", "road");
941 name = f_name + f_ptr->name;
947 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
948 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
949 have_flag(f_ptr->flags, FF_TOWN)))
954 /* Hack -- special introduction for store & building doors -KMW- */
955 if (have_flag(f_ptr->flags, FF_STORE) ||
956 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
957 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
958 have_flag(f_ptr->flags, FF_ENTRANCE))
963 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
964 have_flag(f_ptr->flags, FF_TOWN) ||
965 have_flag(f_ptr->flags, FF_SHALLOW) ||
966 have_flag(f_ptr->flags, FF_DEEP))
972 /* Pick proper indefinite article */
973 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
977 /* Display a message */
978 if (current_world_ptr->wizard)
981 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
982 else sprintf(f_idx_str, "%d", g_ptr->feat);
984 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]);
986 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);
991 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
993 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
997 move_cursor_relative(y, x);
1000 /* Always stop at "normal" keys */
1001 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1004 /* Stop on everything but "return" */
1005 if ((query != '\r') && (query != '\n')) return query;
1007 /* Repeat forever */
1013 * Handle "target" and "look".
1015 * Note that this code can be called from "get_aim_dir()".
1017 * All locations must be on the current panel. Consider the use of
1018 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1019 * some form of "scrolling" the map around the cursor.
1020 * That is, consider the possibility of "auto-scrolling" the screen
1021 * while the cursor moves around. This may require changes in the
1022 * "update_monster()" code to allow "visibility" even if off panel, and
1023 * may require dynamic recalculation of the "temp" grid set.
1025 * Hack -- targeting/observing an "outer border grid" may induce
1026 * problems, so this is not currently allowed.
1028 * The player can use the direction keys to move among "interesting"
1029 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1030 * move through the "interesting" grids in a sequential manner, or
1031 * can enter "location" mode, and use the direction keys to move one
1032 * grid at a time in any direction. The "t" (set target) command will
1033 * only target a monster (as opposed to a location) if the monster is
1034 * target_able and the "interesting" mode is being used.
1036 * The current grid is described using the "look" method above, and
1037 * a new command may be entered at any time, but note that if the
1038 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1039 * where "space" has no obvious meaning) then "space" will scan
1040 * through the description of the current grid until done, instead
1041 * of immediately jumping to the next "interesting" grid. This
1042 * allows the "target" command to retain its old semantics.
1044 * The "*", "+", and "-" keys may always be used to jump immediately
1045 * to the next (or previous) interesting grid, in the proper mode.
1047 * The "return" key may always be used to scan through a complete
1048 * grid description (forever).
1050 * This command will cancel any old target, even if used from
1051 * inside the "look" command.
1053 bool target_set(BIT_FLAGS mode)
1056 POSITION y = p_ptr->y;
1057 POSITION x = p_ptr->x;
1067 get_screen_size(&wid, &hgt);
1072 if (rogue_like_commands)
1081 /* Prepare the "temp" array */
1082 target_set_prepare(mode);
1084 /* Start near the player */
1090 /* Interesting grids */
1091 if (flag && tmp_pos.n)
1097 change_panel_xy(y, x);
1099 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1102 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1105 if (target_able(g_ptr->m_idx))
1107 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1110 /* Dis-allow target */
1113 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1119 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1120 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
1121 strcat(info, cheatinfo);
1124 /* Describe and Prompt */
1126 query = target_set_aux(y, x, mode, info);
1130 /* Assume no "direction" */
1135 if (query == '\r') query = 't';
1153 if (target_able(g_ptr->m_idx))
1155 health_track(g_ptr->m_idx);
1156 target_who = g_ptr->m_idx;
1172 if (++m == tmp_pos.n)
1175 if (!expand_list) done = TRUE;
1185 if (!expand_list) done = TRUE;
1192 /* Recenter the map around the player */
1194 p_ptr->update |= (PU_MONSTERS);
1195 p_ptr->redraw |= (PR_MAP);
1196 p_ptr->window |= (PW_OVERHEAD);
1199 /* Recalculate interesting grids */
1200 target_set_prepare(mode);
1219 if(query == same_key)
1221 if (++m == tmp_pos.n)
1224 if (!expand_list) done = TRUE;
1229 /* Extract the action (if any) */
1230 d = get_keymap_dir(query);
1237 /* Hack -- move around */
1240 /* Modified to scroll to monster */
1241 POSITION y2 = panel_row_min;
1242 POSITION x2 = panel_col_min;
1244 /* Find a new monster */
1245 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1247 /* Request to target past last interesting grid */
1248 while (flag && (i < 0))
1250 /* Note the change */
1251 if (change_panel(ddy[d], ddx[d]))
1253 int v = tmp_pos.y[m];
1254 int u = tmp_pos.x[m];
1256 /* Recalculate interesting grids */
1257 target_set_prepare(mode);
1259 /* Look at interesting grids */
1262 /* Find a new monster */
1263 i = target_pick(v, u, ddy[d], ddx[d]);
1269 /* Nothing interesting */
1272 POSITION dx = ddx[d];
1273 POSITION dy = ddy[d];
1275 /* Restore previous position */
1278 panel_bounds_center();
1280 p_ptr->update |= (PU_MONSTERS);
1281 p_ptr->redraw |= (PR_MAP);
1282 p_ptr->window |= (PW_OVERHEAD);
1285 /* Recalculate interesting grids */
1286 target_set_prepare(mode);
1288 /* Look at boring grids */
1295 /* Do not move horizontally if unnecessary */
1296 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1297 ((x > panel_col_min + wid / 2) && (dx < 0)))
1302 /* Do not move vertically if unnecessary */
1303 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1304 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1309 /* Apply the motion */
1310 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1311 (x >= panel_col_min+wid) || (x < panel_col_min))
1313 if (change_panel(dy, dx)) target_set_prepare(mode);
1316 /* Slide into legality */
1317 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1318 else if (x <= 0) x = 1;
1320 /* Slide into legality */
1321 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1322 else if (y <= 0) y = 1;
1331 /* Arbitrary grids */
1334 bool move_fast = FALSE;
1336 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1339 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1341 /* Default prompt */
1342 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1347 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1348 los(p_ptr->y, p_ptr->x, y, x),
1349 projectable(p_ptr->y, p_ptr->x, y, x));
1350 strcat(info, cheatinfo);
1353 /* Describe and Prompt (enable "TARGET_LOOK") */
1354 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
1356 /* Assume no direction */
1361 if (query == '\r') query = 't';
1364 /* Analyze the keypress */
1388 /* Recenter the map around the player */
1390 p_ptr->update |= (PU_MONSTERS);
1391 p_ptr->redraw |= (PR_MAP);
1392 p_ptr->window |= (PW_OVERHEAD);
1395 /* Recalculate interesting grids */
1396 target_set_prepare(mode);
1418 /* Pick a nearby monster */
1419 for (i = 0; i < tmp_pos.n; i++)
1421 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1431 /* Nothing interesting */
1432 if (bd == 999) flag = FALSE;
1439 /* Extract the action (if any) */
1440 d = get_keymap_dir(query);
1442 /* XTRA HACK MOVEFAST */
1443 if (isupper(query)) move_fast = TRUE;
1450 /* Handle "direction" */
1453 POSITION dx = ddx[d];
1454 POSITION dy = ddy[d];
1456 /* XTRA HACK MOVEFAST */
1459 int mag = MIN(wid / 2, hgt / 2);
1469 /* Do not move horizontally if unnecessary */
1470 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1471 ((x > panel_col_min + wid / 2) && (dx < 0)))
1476 /* Do not move vertically if unnecessary */
1477 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1478 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1483 /* Apply the motion */
1484 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1485 (x >= panel_col_min + wid) || (x < panel_col_min))
1487 if (change_panel(dy, dx)) target_set_prepare(mode);
1490 /* Slide into legality */
1491 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1492 else if (x <= 0) x = 1;
1494 /* Slide into legality */
1495 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1496 else if (y <= 0) y = 1;
1504 /* Clear the top line */
1507 /* Recenter the map around the player */
1509 p_ptr->update |= (PU_MONSTERS);
1510 p_ptr->redraw |= (PR_MAP);
1511 p_ptr->window |= (PW_OVERHEAD);
1514 /* Failure to set target */
1515 if (!target_who) return (FALSE);
1523 * Get an "aiming direction" from the user.
1525 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1526 * "0" for "current target", and "-1" for "entry aborted".
1528 * Note that "Force Target", if set, will pre-empt user interaction,
1529 * if there is a usable target already set.
1531 * Note that confusion over-rides any (explicit?) user choice.
1533 bool get_aim_dir(DIRECTION *dp)
1542 /* Global direction */
1545 /* Hack -- auto-target if requested */
1546 if (use_old_target && target_okay()) dir = 5;
1548 if (repeat_pull(&code))
1553 if (!(code == 5 && !target_okay()))
1555 /* return (TRUE); */
1556 dir = (DIRECTION)code;
1559 *dp = (DIRECTION)code;
1561 /* Ask until satisfied */
1564 /* Choose a prompt */
1567 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1571 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1574 /* Get a command (or Cancel) */
1575 if (!get_com(p, &command, TRUE)) break;
1579 if (command == '\r') command = 't';
1582 /* Convert various keys to "standard" keys */
1585 /* Use current target */
1596 /* Set new target */
1601 if (target_set(TARGET_KILL)) dir = 5;
1607 /* Extract the action (if any) */
1608 dir = get_keymap_dir(command);
1614 /* Verify requested targets */
1615 if ((dir == 5) && !target_okay()) dir = 0;
1624 project_length = 0; /* reset to default */
1628 /* Save the direction */
1631 /* Check for confusion */
1632 if (p_ptr->confused)
1634 /* Random direction */
1635 dir = ddd[randint0(8)];
1638 /* Notice confusion */
1639 if (command_dir != dir)
1642 msg_print(_("あなたは混乱している。", "You are confused."));
1645 /* Save direction */
1648 /* repeat_push(dir); */
1649 repeat_push((COMMAND_CODE)command_dir);
1651 /* A "valid" direction was entered */
1656 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
1664 /* Global direction */
1667 if (repeat_pull(&code))
1669 dir = (DIRECTION)code;
1670 /* return (TRUE); */
1672 *dp = (DIRECTION)code;
1676 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1680 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1683 /* Get a direction */
1688 /* Get a command (or Cancel) */
1689 if (!get_com(prompt, &ch, TRUE)) break;
1692 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1698 /* Look up the direction */
1699 dir = get_keymap_dir(ch);
1705 /* Prevent weirdness */
1706 if ((dir == 5) && (!allow_under)) dir = 0;
1709 if (!dir) return (FALSE);
1711 /* Save desired direction */
1714 /* Apply "confusion" */
1715 if (p_ptr->confused)
1717 /* Standard confusion */
1718 if (randint0(100) < 75)
1720 /* Random direction */
1721 dir = ddd[randint0(8)];
1724 else if (p_ptr->riding && with_steed)
1726 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1727 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1729 if (MON_CONFUSED(m_ptr))
1731 /* Standard confusion */
1732 if (randint0(100) < 75)
1734 /* Random direction */
1735 dir = ddd[randint0(8)];
1738 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1740 /* Random direction */
1741 dir = ddd[randint0(8)];
1743 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1745 /* Random direction */
1746 dir = ddd[randint0(8)];
1750 /* Notice confusion */
1751 if (command_dir != dir)
1753 if (p_ptr->confused)
1756 msg_print(_("あなたは混乱している。", "You are confused."));
1760 GAME_TEXT m_name[MAX_NLEN];
1761 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1763 monster_desc(m_name, m_ptr, 0);
1764 if (MON_CONFUSED(m_ptr))
1766 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
1770 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1775 /* Save direction */
1778 /* repeat_push(dir); */
1779 repeat_push((COMMAND_CODE)command_dir);
1786 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1787 * and place it into "command_dir", unless we already have one.
1789 * This function should be used for all "repeatable" commands, such as
1790 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1791 * as all commands which must reference a grid adjacent to the player,
1792 * and which may not reference the grid under the player. Note that,
1793 * for example, it is no longer possible to "disarm" or "open" chests
1794 * in the same grid as the player.
1796 * Direction "5" is illegal and will (cleanly) abort the command.
1798 * This function tracks and uses the "global direction", and uses
1799 * that as the "desired direction", to which "confusion" is applied.
1801 bool get_rep_dir(DIRECTION *dp, bool under)
1809 /* Global direction */
1812 if (repeat_pull(&code))
1814 dir = (DIRECTION)code;
1815 /* return (TRUE); */
1817 *dp = (DIRECTION)code;
1821 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1825 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1828 /* Get a direction */
1833 /* Get a command (or Cancel) */
1834 if (!get_com(prompt, &ch, TRUE)) break;
1837 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1843 /* Look up the direction */
1844 dir = get_keymap_dir(ch);
1850 /* Prevent weirdness */
1851 if ((dir == 5) && (!under)) dir = 0;
1854 if (!dir) return (FALSE);
1856 /* Save desired direction */
1859 /* Apply "confusion" */
1860 if (p_ptr->confused)
1862 /* Standard confusion */
1863 if (randint0(100) < 75)
1865 /* Random direction */
1866 dir = ddd[randint0(8)];
1869 else if (p_ptr->riding)
1871 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1872 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1874 if (MON_CONFUSED(m_ptr))
1876 /* Standard confusion */
1877 if (randint0(100) < 75)
1879 /* Random direction */
1880 dir = ddd[randint0(8)];
1883 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1885 /* Random direction */
1886 dir = ddd[randint0(8)];
1888 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1890 /* Random direction */
1891 dir = ddd[randint0(8)];
1895 /* Notice confusion */
1896 if (command_dir != dir)
1898 if (p_ptr->confused)
1901 msg_print(_("あなたは混乱している。", "You are confused."));
1905 GAME_TEXT m_name[MAX_NLEN];
1906 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1908 monster_desc(m_name, m_ptr, 0);
1909 if (MON_CONFUSED(m_ptr))
1911 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
1915 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1920 /* Save direction */
1923 /* repeat_push(dir); */
1924 repeat_push((COMMAND_CODE)command_dir);
1932 * XAngband: determine if a given location is "interesting"
1933 * based on target_set_accept function.
1935 static bool tgt_pt_accept(POSITION y, POSITION x)
1939 if (!(in_bounds(current_floor_ptr, y, x))) return (FALSE);
1941 /* Player grid is always interesting */
1942 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
1944 if (p_ptr->image) return (FALSE);
1946 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1948 /* Interesting memorized features */
1949 if (g_ptr->info & (CAVE_MARK))
1952 if (cave_have_flag_grid(g_ptr, FF_LESS)) return (TRUE);
1953 if (cave_have_flag_grid(g_ptr, FF_MORE)) return (TRUE);
1955 /* Notice quest features */
1956 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return (TRUE);
1957 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return (TRUE);
1965 * XAngband: Prepare the "temp" array for "tget_pt"
1966 * based on target_set_prepare funciton.
1968 static void tgt_pt_prepare(void)
1972 /* Reset "temp" array */
1975 if (!expand_list) return;
1977 /* Scan the current panel */
1978 for (y = 1; y < current_floor_ptr->height; y++)
1980 for (x = 1; x < current_floor_ptr->width; x++)
1982 /* Require "interesting" contents */
1983 if (!tgt_pt_accept(y, x)) continue;
1985 /* Save the location */
1986 tmp_pos.x[tmp_pos.n] = x;
1987 tmp_pos.y[tmp_pos.n] = y;
1992 /* Sort the positions */
1993 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
1997 * old -- from PsiAngband.
1999 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
2004 bool success = FALSE;
2008 get_screen_size(&wid, &hgt);
2018 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2019 msg_flag = FALSE; /* prevents "-more-" message. */
2021 while ((ch != ESCAPE) && !success)
2023 bool move_fast = FALSE;
2025 move_cursor_relative(y, x);
2037 if (player_bold(y, x)) ch = 0;
2040 else success = TRUE;
2044 /* XAngband: Move cursor to stairs */
2047 if (expand_list && tmp_pos.n)
2050 int cx = (panel_col_min + panel_col_max) / 2;
2051 int cy = (panel_row_min + panel_row_max) / 2;
2055 /* Skip stairs which have defferent distance */
2056 for (; n < tmp_pos.n; ++ n)
2058 grid_type *g_ptr = ¤t_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2060 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2061 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2068 if (n == tmp_pos.n) /* Loop out taget list */
2073 verify_panel(); /* Move cursor to player */
2075 p_ptr->update |= (PU_MONSTERS);
2077 p_ptr->redraw |= (PR_MAP);
2079 p_ptr->window |= (PW_OVERHEAD);
2082 else /* move cursor to next stair and change panel */
2087 dy = 2 * (y - cy) / hgt;
2088 dx = 2 * (x - cx) / wid;
2089 if (dy || dx) change_panel(dy, dx);
2095 /* Look up the direction */
2096 d = get_keymap_dir(ch);
2098 /* XTRA HACK MOVEFAST */
2099 if (isupper(ch)) move_fast = TRUE;
2101 /* Handle "direction" */
2107 /* XTRA HACK MOVEFAST */
2110 int mag = MIN(wid / 2, hgt / 2);
2120 /* Do not move horizontally if unnecessary */
2121 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2122 ((x > panel_col_min + wid / 2) && (dx < 0)))
2127 /* Do not move vertically if unnecessary */
2128 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2129 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2134 /* Apply the motion */
2135 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2136 (x >= panel_col_min + wid) || (x < panel_col_min))
2138 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
2139 change_panel(dy, dx);
2142 /* Slide into legality */
2143 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
2144 else if (x <= 0) x = 1;
2146 /* Slide into legality */
2147 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
2148 else if (y <= 0) y = 1;
2155 /* Clear the top line */
2158 /* Recenter the map around the player */
2161 p_ptr->update |= (PU_MONSTERS);
2163 p_ptr->redraw |= (PR_MAP);
2165 p_ptr->window |= (PW_OVERHEAD);
2174 bool get_hack_dir(DIRECTION *dp)
2182 /* Global direction */
2185 /* (No auto-targeting) */
2187 /* Ask until satisfied */
2190 /* Choose a prompt */
2193 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2197 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2200 /* Get a command (or Cancel) */
2201 if (!get_com(p, &command, TRUE)) break;
2205 if (command == '\r') command = 't';
2208 /* Convert various keys to "standard" keys */
2211 /* Use current target */
2222 /* Set new target */
2227 if (target_set(TARGET_KILL)) dir = 5;
2233 /* Look up the direction */
2234 dir = get_keymap_dir(command);
2240 /* Verify requested targets */
2241 if ((dir == 5) && !target_okay()) dir = 0;
2248 if (!dir) return (FALSE);
2250 /* Save the direction */
2253 /* Check for confusion */
2254 if (p_ptr->confused)
2256 /* Random direction */
2257 dir = ddd[randint0(8)];
2260 /* Notice confusion */
2261 if (command_dir != dir)
2264 msg_print(_("あなたは混乱している。", "You are confused."));
2267 /* Save direction */
2270 /* A "valid" direction was entered */