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.
17 #include "targeting.h"
21 #include "dungeon-file.h"
22 #include "object-curse.h"
23 #include "object-flavor.h"
25 #include "monsterrace-hook.h"
26 #include "objectkind-hook.h"
28 #include "spells-summon.h"
31 #include "floor-events.h"
32 #include "floor-town.h"
33 #include "player-inventory.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 フォーカスを当てるべきマップ描画の基準座標を指定する
63 * @param creature_ptr プレーヤーへの参照ポインタ
67 * Handle a request to change the current panel
68 * Return TRUE if the panel was changed.
69 * Also used in do_cmd_locate
70 * @return 実際に再描画が必要だった場合TRUEを返す
72 static bool change_panel_xy(player_type *creature_ptr, POSITION y, POSITION x)
74 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(creature_ptr, dy, dx);
90 * @brief マップ描画のフォーカスを当てるべき座標を更新する
91 * @param creature_ptr プレーヤーへの参照ポインタ
93 * Given an row (y) and col (x), this routine detects when a move
94 * off the screen has occurred and figures new borders. -RAK-
95 * "Update" forces a "full update" to take place.
96 * The map is reprinted if necessary, and "TRUE" is returned.
97 * @return 実際に再描画が必要だった場合TRUEを返す
99 void verify_panel(player_type *creature_ptr)
101 POSITION y = creature_ptr->y;
102 POSITION x = creature_ptr->x;
105 get_screen_size(&wid, &hgt);
107 int max_prow_min = creature_ptr->current_floor_ptr->height - hgt;
108 int max_pcol_min = creature_ptr->current_floor_ptr->width - wid;
110 /* Bounds checking */
113 if (max_prow_min < 0) max_prow_min = 0;
114 if (max_pcol_min < 0) max_pcol_min = 0;
116 /* Center on player */
117 if (center_player && (center_running || !creature_ptr->running))
119 /* Center vertically */
120 prow_min = y - hgt / 2;
121 if (prow_min < 0) prow_min = 0;
122 else if (prow_min > max_prow_min) prow_min = max_prow_min;
124 /* Center horizontally */
125 pcol_min = x - wid / 2;
126 if (pcol_min < 0) pcol_min = 0;
127 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
131 prow_min = panel_row_min;
132 pcol_min = panel_col_min;
134 /* Scroll screen when 2 grids from top/bottom edge */
135 if (y > panel_row_max - 2)
137 while (y > prow_min + hgt - 1 - 2)
139 prow_min += (hgt / 2);
143 if (y < panel_row_min + 2)
145 while (y < prow_min + 2)
147 prow_min -= (hgt / 2);
151 if (prow_min > max_prow_min) prow_min = max_prow_min;
152 if (prow_min < 0) prow_min = 0;
154 /* Scroll screen when 4 grids from left/right edge */
155 if (x > panel_col_max - 4)
157 while (x > pcol_min + wid - 1 - 4)
159 pcol_min += (wid / 2);
163 if (x < panel_col_min + 4)
165 while (x < pcol_min + 4)
167 pcol_min -= (wid / 2);
171 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
172 if (pcol_min < 0) pcol_min = 0;
175 /* Check for "no change" */
176 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
178 /* Save the new panel info */
179 panel_row_min = prow_min;
180 panel_col_min = pcol_min;
182 /* Hack -- optional disturb on "panel change" */
183 if (disturb_panel && !center_player) disturb(creature_ptr, FALSE, FALSE);
185 panel_bounds_center();
187 creature_ptr->update |= (PU_MONSTERS);
188 creature_ptr->redraw |= (PR_MAP);
189 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
194 * Determine is a monster makes a reasonable target
196 * The concept of "targeting" was stolen from "Morgul" (?)
198 * The player can target any location, or any "target-able" monster.
200 * Currently, a monster is "target_able" if it is visible, and if
201 * the player can hit it with a projection, and the player is not
202 * hallucinating. This allows use of "use closest target" macros.
204 * Future versions may restrict the ability to target "trappers"
205 * and "mimics", but the semantics is a little bit weird.
207 bool target_able(player_type *creature_ptr, MONSTER_IDX m_idx)
209 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
210 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
212 /* Monster must be alive */
213 if (!monster_is_valid(m_ptr)) return FALSE;
215 /* Hack -- no targeting hallucinations */
216 if (creature_ptr->image) return FALSE;
218 /* Monster must be visible */
219 if (!m_ptr->ml) return FALSE;
221 if (creature_ptr->riding && (creature_ptr->riding == m_idx)) return TRUE;
223 /* Monster must be projectable */
224 if (!projectable(creature_ptr, creature_ptr->y, creature_ptr->x, m_ptr->fy, m_ptr->fx)) return FALSE;
226 /* Hack -- Never target trappers */
227 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return FALSE; */
235 * Targetting variables
237 MONSTER_IDX target_who;
242 * Update (if necessary) and verify (if possible) the target.
244 * We return TRUE if the target is "okay" and FALSE otherwise.
246 bool target_okay(player_type *creature_ptr)
248 /* Accept stationary targets */
249 if (target_who < 0) return TRUE;
251 /* Check moving targets */
252 if (target_who <= 0) return FALSE;
254 /* Accept reasonable targets */
255 if (!target_able(creature_ptr, target_who)) return FALSE;
257 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[target_who];
259 /* Acquire monster location */
260 target_row = m_ptr->fy;
261 target_col = m_ptr->fx;
269 * Hack -- help "select" a location (see below)
271 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
273 /* Scan the locations */
274 POSITION_IDX b_i = -1, b_v = 9999;
275 for (POSITION_IDX i = 0; i < tmp_pos.n; i++)
278 POSITION x2 = tmp_pos.x[i];
279 POSITION y2 = tmp_pos.y[i];
281 /* Directed distance */
282 POSITION x3 = (x2 - x1);
283 POSITION y3 = (y2 - y1);
285 /* Verify quadrant */
286 if (dx && (x3 * dx <= 0)) continue;
287 if (dy && (y3 * dy <= 0)) continue;
289 POSITION x4 = ABS(x3);
290 POSITION y4 = ABS(y3);
292 /* Verify quadrant */
293 if (dy && !dx && (x4 > y4)) continue;
294 if (dx && !dy && (y4 > x4)) continue;
296 /* Approximate Double Distance */
297 POSITION_IDX v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
299 /* Penalize location */
300 if ((b_i >= 0) && (v >= b_v)) continue;
309 * Hack -- determine if a given location is "interesting"
311 static bool target_set_accept(player_type *creature_ptr, POSITION y, POSITION x)
313 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
314 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
316 /* Player grid is always interesting */
317 if (player_bold(creature_ptr, y, x)) return TRUE;
319 if (creature_ptr->image) return FALSE;
322 g_ptr = &floor_ptr->grid_array[y][x];
324 /* Visible monsters */
327 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
329 /* Visible monsters */
330 if (m_ptr->ml) return TRUE;
333 /* Scan all objects in the grid */
334 OBJECT_IDX next_o_idx = 0;
335 for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
338 o_ptr = &floor_ptr->o_list[this_o_idx];
339 next_o_idx = o_ptr->next_o_idx;
341 /* Memorized object */
342 if (o_ptr->marked & OM_FOUND) return TRUE;
345 /* Interesting memorized features */
346 if (g_ptr->info & (CAVE_MARK))
348 /* Notice object features */
349 if (g_ptr->info & CAVE_OBJECT) return TRUE;
351 /* Feature code (applying "mimic" field) */
352 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
360 * Prepare the "temp" array for "target_set"
362 * Return the number of target_able monsters in the set.
364 static void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
366 POSITION min_hgt, max_hgt, min_wid, max_wid;
367 if (mode & TARGET_KILL)
370 min_hgt = MAX((creature_ptr->y - MAX_RANGE), 0);
371 max_hgt = MIN((creature_ptr->y + MAX_RANGE), creature_ptr->current_floor_ptr->height - 1);
372 min_wid = MAX((creature_ptr->x - MAX_RANGE), 0);
373 max_wid = MIN((creature_ptr->x + MAX_RANGE), creature_ptr->current_floor_ptr->width - 1);
375 else /* not targetting */
378 min_hgt = panel_row_min;
379 max_hgt = panel_row_max;
380 min_wid = panel_col_min;
381 max_wid = panel_col_max;
384 /* Reset "temp" array */
387 /* Scan the current panel */
388 for (POSITION y = min_hgt; y <= max_hgt; y++)
390 for (POSITION x = min_wid; x <= max_wid; x++)
394 /* Require "interesting" contents */
395 if (!target_set_accept(creature_ptr, y, x)) continue;
397 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
399 /* Require target_able monsters for "TARGET_KILL" */
400 if ((mode & (TARGET_KILL)) && !target_able(creature_ptr, g_ptr->m_idx)) continue;
402 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx])) continue;
404 /* Save the location */
405 tmp_pos.x[tmp_pos.n] = x;
406 tmp_pos.y[tmp_pos.n] = y;
411 /* Set the sort hooks */
412 if (mode & (TARGET_KILL))
414 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
418 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
421 if (creature_ptr->riding == 0 || !target_pet || (tmp_pos.n <= 1) || !(mode & (TARGET_KILL)))
424 POSITION tmp = tmp_pos.y[0];
425 tmp_pos.y[0] = tmp_pos.y[1];
428 tmp_pos.x[0] = tmp_pos.x[1];
433 void target_set_prepare_look(player_type *creature_ptr)
435 target_set_prepare(creature_ptr, TARGET_LOOK);
440 * Evaluate number of kill needed to gain level
442 static void evaluate_monster_exp(player_type *creature_ptr, char *buf, monster_type *m_ptr)
444 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
446 s32b exp_mon, exp_adv;
447 u32b exp_mon_frac, exp_adv_frac;
449 if ((creature_ptr->lev >= PY_MAX_LEVEL) || (creature_ptr->prace == RACE_ANDROID))
454 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
456 if (!current_world_ptr->wizard)
463 /* The monster's experience point (assuming average monster speed) */
464 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
466 s64b_div(&exp_mon, &exp_mon_frac, 0, (creature_ptr->max_plv + 2));
469 /* Total experience value for next level */
470 exp_adv = player_exp[creature_ptr->lev - 1] * creature_ptr->expfact;
472 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
474 /* Experience value need to get */
475 s64b_sub(&exp_adv, &exp_adv_frac, creature_ptr->exp, creature_ptr->exp_frac);
478 /* You need to kill at least one monster to get any experience */
479 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
480 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
482 /* Extract number of monsters needed */
483 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
485 /* If 999 or more monsters needed, only display "999". */
486 num = MIN(999, exp_adv_frac);
488 /* Display the number */
489 sprintf(buf, "%03ld", (long int)num);
493 bool show_gold_on_floor = FALSE;
496 * Examine a grid, return a keypress.
498 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
499 * indicates that the "space" key should scan through the contents
500 * of the grid, instead of simply returning immediately. This lets
501 * the "look" command get complete information, without making the
502 * "target" command annoying.
504 * The "info" argument contains the "commands" which should be shown
505 * inside the "[xxx]" text. This string must never be empty, or grids
506 * containing monsters will be displayed with an extra comma.
508 * Note that if a monster is in the grid, we update both the monster
509 * recall info and the health bar info to track that monster.
511 * Eventually, we may allow multiple objects per grid, or objects
512 * and terrain features in the same grid.
514 * This function must handle blindness/hallucination.
516 static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
518 OBJECT_IDX next_o_idx = 0;
519 concptr s1 = "", s2 = "", s3 = "", x_info = "";
524 char out_val[MAX_NLEN + 80];
525 OBJECT_IDX floor_list[23];
526 ITEM_NUMBER floor_num = 0;
528 /* Scan all objects in the grid */
531 floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02);
535 x_info = _("x物 ", "x,");
539 /* Hack -- under the player */
540 if (player_bold(subject_ptr, y, x))
553 s1 = _("ターゲット:", "Target:");
556 /* Hack -- hallucination */
557 if (subject_ptr->image)
559 concptr name = _("何か奇妙な物", "something strange");
561 /* Display a message */
563 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
565 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
569 move_cursor_relative(y, x);
572 /* Stop on everything but "return" */
573 if ((query != '\r') && (query != '\n')) return query;
579 /* Actual monsters */
580 grid_type *g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
581 if (g_ptr->m_idx && subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)
583 monster_type *m_ptr = &subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
584 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
585 GAME_TEXT m_name[MAX_NLEN];
591 monster_desc(subject_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
592 monster_race_track(subject_ptr, m_ptr->ap_r_idx);
593 health_track(subject_ptr, g_ptr->m_idx);
594 handle_stuff(subject_ptr);
605 /* Recall on screen */
606 screen_roff(subject_ptr, m_ptr->ap_r_idx, 0);
608 /* Hack -- Complete the prompt (again) */
609 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
615 /* Normal commands */
616 if (query != 'r') break;
620 /* Cleare recall text and repeat */
626 /* Describe, and prompt for recall */
627 evaluate_monster_exp(subject_ptr, acount, m_ptr);
630 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);
632 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);
638 move_cursor_relative(y, x);
642 /* Normal commands */
643 if (query != 'r') break;
648 /* Always stop at "normal" keys */
649 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
651 /* Sometimes stop at "space" key */
652 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
654 /* Change the intro */
655 s1 = _("それは", "It is ");
657 /* Hack -- take account of gender */
658 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
659 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
661 /* Use a preposition */
669 /* Scan all objects being carried */
670 for (OBJECT_IDX this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
672 GAME_TEXT o_name[MAX_NLEN];
675 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
676 next_o_idx = o_ptr->next_o_idx;
678 object_desc(subject_ptr, o_name, o_ptr, 0);
681 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
683 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
687 move_cursor_relative(y, x);
690 /* Always stop at "normal" keys */
691 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
693 /* Sometimes stop at "space" key */
694 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
696 /* Change the intro */
697 s2 = _("をまた", "also carrying ");
700 /* Use a preposition */
717 GAME_TEXT o_name[MAX_NLEN];
720 o_ptr = &subject_ptr->current_floor_ptr->o_list[floor_list[0]];
722 object_desc(subject_ptr, o_name, o_ptr, 0);
725 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
727 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
731 move_cursor_relative(y, x);
739 /* Provide one cushion before item listing */
742 /* Display rough information about items */
744 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
746 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
750 move_cursor_relative(y, x);
754 /* No request for listing */
755 if (query != 'x' && query != ' ') return query;
759 /** Display list of items **/
761 /* Continue scrolling list if requested */
769 show_gold_on_floor = TRUE;
770 (void)show_floor(subject_ptr, 0, y, x, &min_width);
771 show_gold_on_floor = FALSE;
775 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
777 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
784 /* Exit unless 'Enter' */
785 if (query != '\n' && query != '\r')
790 /* Get the object being moved. */
791 o_idx = g_ptr->o_idx;
793 /* Only rotate a pile of two or more objects. */
794 if (!(o_idx && subject_ptr->current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
796 /* Remove the first object from the list. */
797 excise_object_idx(subject_ptr->current_floor_ptr, o_idx);
799 /* Find end of the list. */
801 while (subject_ptr->current_floor_ptr->o_list[i].next_o_idx)
802 i = subject_ptr->current_floor_ptr->o_list[i].next_o_idx;
804 /* Add after the last object. */
805 subject_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
807 /* Loop and re-display the list */
814 /* Scan all objects in the grid */
815 for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
818 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
819 next_o_idx = o_ptr->next_o_idx;
821 if (o_ptr->marked & OM_FOUND)
823 GAME_TEXT o_name[MAX_NLEN];
828 object_desc(subject_ptr, o_name, o_ptr, 0);
831 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
833 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
837 move_cursor_relative(y, x);
840 /* Always stop at "normal" keys */
841 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
843 /* Sometimes stop at "space" key */
844 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
846 /* Change the intro */
847 s1 = _("それは", "It is ");
850 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
863 /* Feature code (applying "mimic" field) */
864 feat = get_feat_mimic(g_ptr);
866 /* Require knowledge about grid, or ability to see grid */
867 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(subject_ptr, y, x))
873 f_ptr = &f_info[feat];
875 /* Terrain feature if needed */
876 if (!boring && !have_flag(f_ptr->flags, FF_REMEMBER))
878 if ((query != '\r') && (query != '\n')) return query;
882 /* Hack -- special handling for quest entrances */
884 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
886 /* Set the quest number temporary */
887 IDX old_quest = subject_ptr->current_floor_ptr->inside_quest;
891 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
894 subject_ptr->current_floor_ptr->inside_quest = g_ptr->special;
896 /* Get the quest text */
897 init_flags = INIT_NAME_ONLY;
899 process_dungeon_file(subject_ptr, "q_info.txt", 0, 0, 0, 0);
901 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
902 quest[g_ptr->special].name, quest[g_ptr->special].level);
904 /* Reset the old quest number */
905 subject_ptr->current_floor_ptr->inside_quest = old_quest;
908 /* Hack -- special handling for building doors */
909 else if (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena)
911 name = building[f_ptr->subtype].name;
913 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
915 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
917 else if (have_flag(f_ptr->flags, FF_TOWN))
919 name = town_info[g_ptr->special].name;
921 else if (subject_ptr->wild_mode && (feat == feat_floor))
923 name = _("道", "road");
927 name = f_name + f_ptr->name;
932 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
933 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
934 have_flag(f_ptr->flags, FF_TOWN)))
939 /* Hack -- special introduction for store & building doors -KMW- */
940 if (have_flag(f_ptr->flags, FF_STORE) ||
941 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
942 (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena) ||
943 have_flag(f_ptr->flags, FF_ENTRANCE))
949 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
950 have_flag(f_ptr->flags, FF_TOWN) ||
951 have_flag(f_ptr->flags, FF_SHALLOW) ||
952 have_flag(f_ptr->flags, FF_DEEP))
958 /* Pick proper indefinite article */
959 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
963 /* Display a message */
964 if (current_world_ptr->wizard)
967 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
968 else sprintf(f_idx_str, "%d", g_ptr->feat);
970 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]);
972 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);
977 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
979 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
983 move_cursor_relative(y, x);
986 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
992 * Handle "target" and "look".
994 * Note that this code can be called from "get_aim_dir()".
996 * All locations must be on the current panel. Consider the use of
997 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
998 * some form of "scrolling" the map around the cursor.
999 * That is, consider the possibility of "auto-scrolling" the screen
1000 * while the cursor moves around. This may require changes in the
1001 * "update_monster()" code to allow "visibility" even if off panel, and
1002 * may require dynamic recalculation of the "temp" grid set.
1004 * Hack -- targeting/observing an "outer border grid" may induce
1005 * problems, so this is not currently allowed.
1007 * The player can use the direction keys to move among "interesting"
1008 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1009 * move through the "interesting" grids in a sequential manner, or
1010 * can enter "location" mode, and use the direction keys to move one
1011 * grid at a time in any direction. The "t" (set target) command will
1012 * only target a monster (as opposed to a location) if the monster is
1013 * target_able and the "interesting" mode is being used.
1015 * The current grid is described using the "look" method above, and
1016 * a new command may be entered at any time, but note that if the
1017 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1018 * where "space" has no obvious meaning) then "space" will scan
1019 * through the description of the current grid until done, instead
1020 * of immediately jumping to the next "interesting" grid. This
1021 * allows the "target" command to retain its old semantics.
1023 * The "*", "+", and "-" keys may always be used to jump immediately
1024 * to the next (or previous) interesting grid, in the proper mode.
1026 * The "return" key may always be used to scan through a complete
1027 * grid description (forever).
1029 * This command will cancel any old target, even if used from
1030 * inside the "look" command.
1032 bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
1035 POSITION y = creature_ptr->y;
1036 POSITION x = creature_ptr->x;
1046 get_screen_size(&wid, &hgt);
1051 if (rogue_like_commands)
1060 /* Prepare the "temp" array */
1061 target_set_prepare(creature_ptr, mode);
1063 /* Start near the player */
1067 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1070 /* Interesting grids */
1071 if (flag && tmp_pos.n)
1077 change_panel_xy(creature_ptr, y, x);
1079 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1082 g_ptr = &floor_ptr->grid_array[y][x];
1085 if (target_able(creature_ptr, g_ptr->m_idx))
1087 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1090 /* Dis-allow target */
1093 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1099 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1100 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x));
1101 strcat(info, cheatinfo);
1104 /* Describe and Prompt */
1107 query = target_set_aux(creature_ptr, y, x, mode, info);
1111 /* Assume no "direction" */
1116 if (query == '\r') query = 't';
1134 if (target_able(creature_ptr, g_ptr->m_idx))
1136 health_track(creature_ptr, g_ptr->m_idx);
1137 target_who = g_ptr->m_idx;
1153 if (++m == tmp_pos.n)
1156 if (!expand_list) done = TRUE;
1166 if (!expand_list) done = TRUE;
1173 /* Recenter the map around the player */
1174 verify_panel(creature_ptr);
1175 creature_ptr->update |= (PU_MONSTERS);
1176 creature_ptr->redraw |= (PR_MAP);
1177 creature_ptr->window |= (PW_OVERHEAD);
1178 handle_stuff(creature_ptr);
1180 /* Recalculate interesting grids */
1181 target_set_prepare(creature_ptr, mode);
1183 y = creature_ptr->y;
1184 x = creature_ptr->x;
1201 if (query == same_key)
1203 if (++m == tmp_pos.n)
1206 if (!expand_list) done = TRUE;
1211 /* Extract the action (if any) */
1212 d = get_keymap_dir(query);
1219 /* Hack -- move around */
1222 /* Modified to scroll to monster */
1223 POSITION y2 = panel_row_min;
1224 POSITION x2 = panel_col_min;
1226 /* Find a new monster */
1227 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1229 /* Request to target past last interesting grid */
1230 while (flag && (i < 0))
1232 /* Note the change */
1233 if (change_panel(creature_ptr, ddy[d], ddx[d]))
1235 int v = tmp_pos.y[m];
1236 int u = tmp_pos.x[m];
1238 /* Recalculate interesting grids */
1239 target_set_prepare(creature_ptr, mode);
1241 /* Look at interesting grids */
1244 /* Find a new monster */
1245 i = target_pick(v, u, ddy[d], ddx[d]);
1252 /* Nothing interesting */
1253 POSITION dx = ddx[d];
1254 POSITION dy = ddy[d];
1256 /* Restore previous position */
1259 panel_bounds_center();
1261 creature_ptr->update |= (PU_MONSTERS);
1262 creature_ptr->redraw |= (PR_MAP);
1263 creature_ptr->window |= (PW_OVERHEAD);
1264 handle_stuff(creature_ptr);
1266 /* Recalculate interesting grids */
1267 target_set_prepare(creature_ptr, mode);
1269 /* Look at boring grids */
1276 /* Do not move horizontally if unnecessary */
1277 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1278 ((x > panel_col_min + wid / 2) && (dx < 0)))
1283 /* Do not move vertically if unnecessary */
1284 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1285 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1290 /* Apply the motion */
1291 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1292 (x >= panel_col_min + wid) || (x < panel_col_min))
1294 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1297 /* Slide into legality */
1298 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1299 else if (x <= 0) x = 1;
1301 /* Slide into legality */
1302 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1303 else if (y <= 0) y = 1;
1313 /* Arbitrary grids */
1315 bool move_fast = FALSE;
1317 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1320 g_ptr = &floor_ptr->grid_array[y][x];
1322 /* Default prompt */
1323 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1327 char cheatinfo[100];
1328 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d",
1329 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x),
1330 projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special);
1331 strcat(info, cheatinfo);
1334 /* Describe and Prompt (enable "TARGET_LOOK") */
1335 while ((query = target_set_aux(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0);
1337 /* Assume no direction */
1342 if (query == '\r') query = 't';
1345 /* Analyze the keypress */
1369 /* Recenter the map around the player */
1370 verify_panel(creature_ptr);
1371 creature_ptr->update |= (PU_MONSTERS);
1372 creature_ptr->redraw |= (PR_MAP);
1373 creature_ptr->window |= (PW_OVERHEAD);
1374 handle_stuff(creature_ptr);
1376 /* Recalculate interesting grids */
1377 target_set_prepare(creature_ptr, mode);
1379 y = creature_ptr->y;
1380 x = creature_ptr->x;
1399 /* Pick a nearby monster */
1400 for (i = 0; i < tmp_pos.n; i++)
1402 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1412 /* Nothing interesting */
1413 if (bd == 999) flag = FALSE;
1420 /* Extract the action (if any) */
1421 d = get_keymap_dir(query);
1423 /* XTRA HACK MOVEFAST */
1424 if (isupper(query)) move_fast = TRUE;
1431 /* Handle "direction" */
1434 POSITION dx = ddx[d];
1435 POSITION dy = ddy[d];
1437 /* XTRA HACK MOVEFAST */
1440 int mag = MIN(wid / 2, hgt / 2);
1450 /* Do not move horizontally if unnecessary */
1451 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1452 ((x > panel_col_min + wid / 2) && (dx < 0)))
1457 /* Do not move vertically if unnecessary */
1458 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1459 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1464 /* Apply the motion */
1465 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1466 (x >= panel_col_min + wid) || (x < panel_col_min))
1468 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1471 /* Slide into legality */
1472 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1473 else if (x <= 0) x = 1;
1475 /* Slide into legality */
1476 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1477 else if (y <= 0) y = 1;
1484 /* Clear the top line */
1487 /* Recenter the map around the player */
1488 verify_panel(creature_ptr);
1489 creature_ptr->update |= (PU_MONSTERS);
1490 creature_ptr->redraw |= (PR_MAP);
1491 creature_ptr->window |= (PW_OVERHEAD);
1492 handle_stuff(creature_ptr);
1494 return target_who > 0;
1499 * Get an "aiming direction" from the user.
1501 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1502 * "0" for "current target", and "-1" for "entry aborted".
1504 * Note that "Force Target", if set, will pre-empt user interaction,
1505 * if there is a usable target already set.
1507 * Note that confusion over-rides any (explicit?) user choice.
1509 bool get_aim_dir(player_type *creature_ptr, DIRECTION *dp)
1511 /* Global direction */
1512 DIRECTION dir = command_dir;
1514 /* Hack -- auto-target if requested */
1515 if (use_old_target && target_okay(creature_ptr)) dir = 5;
1518 if (repeat_pull(&code))
1523 if (!(code == 5 && !target_okay(creature_ptr)))
1526 dir = (DIRECTION)code;
1530 *dp = (DIRECTION)code;
1532 /* Ask until satisfied */
1536 /* Choose a prompt */
1538 if (!target_okay(creature_ptr))
1540 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1544 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1547 /* Get a command (or Cancel) */
1548 if (!get_com(p, &command, TRUE)) break;
1552 if (command == '\r') command = 't';
1555 /* Convert various keys to "standard" keys */
1558 /* Use current target */
1569 /* Set new target */
1574 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
1580 /* Extract the action (if any) */
1581 dir = get_keymap_dir(command);
1587 /* Verify requested targets */
1588 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
1597 project_length = 0; /* reset to default */
1601 /* Save the direction */
1604 /* Check for confusion */
1605 if (creature_ptr->confused)
1607 /* Random direction */
1608 dir = ddd[randint0(8)];
1611 /* Notice confusion */
1612 if (command_dir != dir)
1615 msg_print(_("あなたは混乱している。", "You are confused."));
1618 /* Save direction */
1621 repeat_push((COMMAND_CODE)command_dir);
1626 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed)
1628 /* Global direction */
1629 DIRECTION dir = command_dir;
1632 if (repeat_pull(&code))
1634 dir = (DIRECTION)code;
1638 *dp = (DIRECTION)code;
1643 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1647 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1650 /* Get a direction */
1655 /* Get a command (or Cancel) */
1656 if (!get_com(prompt, &ch, TRUE)) break;
1659 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1665 /* Look up the direction */
1666 dir = get_keymap_dir(ch);
1672 /* Prevent weirdness */
1673 if ((dir == 5) && (!allow_under)) dir = 0;
1676 if (!dir) return FALSE;
1678 /* Save desired direction */
1681 /* Apply "confusion" */
1682 if (creature_ptr->confused)
1684 /* Standard confusion */
1685 if (randint0(100) < 75)
1687 /* Random direction */
1688 dir = ddd[randint0(8)];
1691 else if (creature_ptr->riding && with_steed)
1693 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1694 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1696 if (MON_CONFUSED(m_ptr))
1698 /* Standard confusion */
1699 if (randint0(100) < 75)
1701 /* Random direction */
1702 dir = ddd[randint0(8)];
1705 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1707 /* Random direction */
1708 dir = ddd[randint0(8)];
1710 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1712 /* Random direction */
1713 dir = ddd[randint0(8)];
1717 /* Notice confusion */
1718 if (command_dir != dir)
1720 if (creature_ptr->confused)
1723 msg_print(_("あなたは混乱している。", "You are confused."));
1727 GAME_TEXT m_name[MAX_NLEN];
1728 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1730 monster_desc(creature_ptr, m_name, m_ptr, 0);
1731 if (MON_CONFUSED(m_ptr))
1733 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1737 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1743 repeat_push((COMMAND_CODE)command_dir);
1749 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1750 * and place it into "command_dir", unless we already have one.
1752 * This function should be used for all "repeatable" commands, such as
1753 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1754 * as all commands which must reference a grid adjacent to the player,
1755 * and which may not reference the grid under the player. Note that,
1756 * for example, it is no longer possible to "disarm" or "open" chests
1757 * in the same grid as the player.
1759 * Direction "5" is illegal and will (cleanly) abort the command.
1761 * This function tracks and uses the "global direction", and uses
1762 * that as the "desired direction", to which "confusion" is applied.
1764 bool get_rep_dir(player_type *creature_ptr, DIRECTION *dp, bool under)
1766 /* Global direction */
1767 DIRECTION dir = command_dir;
1770 if (repeat_pull(&code))
1772 dir = (DIRECTION)code;
1776 *dp = (DIRECTION)code;
1781 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1785 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1788 /* Get a direction */
1793 /* Get a command (or Cancel) */
1794 if (!get_com(prompt, &ch, TRUE)) break;
1797 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1803 /* Look up the direction */
1804 dir = get_keymap_dir(ch);
1810 /* Prevent weirdness */
1811 if ((dir == 5) && (!under)) dir = 0;
1814 if (!dir) return FALSE;
1816 /* Save desired direction */
1819 /* Apply "confusion" */
1820 if (creature_ptr->confused)
1822 /* Standard confusion */
1823 if (randint0(100) < 75)
1825 /* Random direction */
1826 dir = ddd[randint0(8)];
1829 else if (creature_ptr->riding)
1831 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1832 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1834 if (MON_CONFUSED(m_ptr))
1836 /* Standard confusion */
1837 if (randint0(100) < 75)
1839 /* Random direction */
1840 dir = ddd[randint0(8)];
1843 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1845 /* Random direction */
1846 dir = ddd[randint0(8)];
1848 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1850 /* Random direction */
1851 dir = ddd[randint0(8)];
1855 /* Notice confusion */
1856 if (command_dir != dir)
1858 if (creature_ptr->confused)
1861 msg_print(_("あなたは混乱している。", "You are confused."));
1865 GAME_TEXT m_name[MAX_NLEN];
1866 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1868 monster_desc(creature_ptr, m_name, m_ptr, 0);
1869 if (MON_CONFUSED(m_ptr))
1871 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1875 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1881 repeat_push((COMMAND_CODE)command_dir);
1887 * XAngband: determine if a given location is "interesting"
1888 * based on target_set_accept function.
1890 static bool tgt_pt_accept(player_type *creature_ptr, POSITION y, POSITION x)
1892 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1893 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
1895 /* Player grid is always interesting */
1896 if ((y == creature_ptr->y) && (x == creature_ptr->x)) return TRUE;
1898 if (creature_ptr->image) return FALSE;
1901 g_ptr = &floor_ptr->grid_array[y][x];
1903 /* Interesting memorized features */
1904 if (!(g_ptr->info & (CAVE_MARK))) return FALSE;
1907 if (cave_have_flag_grid(g_ptr, FF_LESS)) return TRUE;
1908 if (cave_have_flag_grid(g_ptr, FF_MORE)) return TRUE;
1910 /* Notice quest features */
1911 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return TRUE;
1912 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return TRUE;
1919 * XAngband: Prepare the "temp" array for "tget_pt"
1920 * based on target_set_prepare funciton.
1922 static void tgt_pt_prepare(player_type *creature_ptr)
1926 if (!expand_list) return;
1928 /* Scan the current panel */
1929 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1930 for (POSITION y = 1; y < floor_ptr->height; y++)
1932 for (POSITION x = 1; x < floor_ptr->width; x++)
1934 /* Require "interesting" contents */
1935 if (!tgt_pt_accept(creature_ptr, y, x)) continue;
1937 /* Save the location */
1938 tmp_pos.x[tmp_pos.n] = x;
1939 tmp_pos.y[tmp_pos.n] = y;
1944 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
1949 * old -- from PsiAngband.
1951 bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr)
1954 get_screen_size(&wid, &hgt);
1956 POSITION x = creature_ptr->x;
1957 POSITION y = creature_ptr->y;
1959 if (expand_list) tgt_pt_prepare(creature_ptr);
1961 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
1962 msg_flag = FALSE; /* prevents "-more-" message. */
1966 bool success = FALSE;
1967 while ((ch != ESCAPE) && !success)
1969 bool move_fast = FALSE;
1971 move_cursor_relative(y, x);
1983 if (player_bold(creature_ptr, y, x)) ch = 0;
1986 else success = TRUE;
1990 /* XAngband: Move cursor to stairs */
1994 if (!expand_list || !tmp_pos.n) break;
1997 int cx = (panel_col_min + panel_col_max) / 2;
1998 int cy = (panel_row_min + panel_row_max) / 2;
2002 /* Skip stairs which have defferent distance */
2003 for (; n < tmp_pos.n; ++n)
2005 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2007 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2008 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2015 if (n == tmp_pos.n) /* Loop out taget list */
2018 y = creature_ptr->y;
2019 x = creature_ptr->x;
2020 verify_panel(creature_ptr); /* Move cursor to player */
2022 creature_ptr->update |= (PU_MONSTERS);
2024 creature_ptr->redraw |= (PR_MAP);
2026 creature_ptr->window |= (PW_OVERHEAD);
2027 handle_stuff(creature_ptr);
2029 else /* move cursor to next stair and change panel */
2034 dy = 2 * (y - cy) / hgt;
2035 dx = 2 * (x - cx) / wid;
2036 if (dy || dx) change_panel(creature_ptr, dy, dx);
2044 /* Look up the direction */
2045 int d = get_keymap_dir(ch);
2047 /* XTRA HACK MOVEFAST */
2048 if (isupper(ch)) move_fast = TRUE;
2050 /* Handle "direction" */
2056 /* XTRA HACK MOVEFAST */
2059 int mag = MIN(wid / 2, hgt / 2);
2069 /* Do not move horizontally if unnecessary */
2070 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2071 ((x > panel_col_min + wid / 2) && (dx < 0)))
2076 /* Do not move vertically if unnecessary */
2077 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2078 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2083 /* Apply the motion */
2084 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2085 (x >= panel_col_min + wid) || (x < panel_col_min))
2087 change_panel(creature_ptr, dy, dx);
2090 /* Slide into legality */
2091 if (x >= creature_ptr->current_floor_ptr->width - 1) x = creature_ptr->current_floor_ptr->width - 2;
2092 else if (x <= 0) x = 1;
2094 /* Slide into legality */
2095 if (y >= creature_ptr->current_floor_ptr->height - 1) y = creature_ptr->current_floor_ptr->height - 2;
2096 else if (y <= 0) y = 1;
2104 verify_panel(creature_ptr);
2105 creature_ptr->update |= (PU_MONSTERS);
2106 creature_ptr->redraw |= (PR_MAP);
2107 creature_ptr->window |= (PW_OVERHEAD);
2108 handle_stuff(creature_ptr);
2116 bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
2120 /* Ask until satisfied */
2125 /* Choose a prompt */
2127 if (!target_okay(creature_ptr))
2129 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2133 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2136 /* Get a command (or Cancel) */
2137 if (!get_com(p, &command, TRUE)) break;
2141 if (command == '\r') command = 't';
2144 /* Convert various keys to "standard" keys */
2147 /* Use current target */
2158 /* Set new target */
2163 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
2169 /* Look up the direction */
2170 dir = get_keymap_dir(command);
2176 /* Verify requested targets */
2177 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
2183 if (!dir) return FALSE;
2185 /* Save the direction */
2188 /* Check for confusion */
2189 if (creature_ptr->confused)
2191 /* Random direction */
2192 dir = ddd[randint0(8)];
2195 /* Notice confusion */
2196 if (command_dir != dir)
2199 msg_print(_("あなたは混乱している。", "You are confused."));