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;
1200 if (query == same_key)
1202 if (++m == tmp_pos.n)
1205 if (!expand_list) done = TRUE;
1210 /* Extract the action (if any) */
1211 d = get_keymap_dir(query);
1218 /* Hack -- move around */
1221 /* Modified to scroll to monster */
1222 POSITION y2 = panel_row_min;
1223 POSITION x2 = panel_col_min;
1225 /* Find a new monster */
1226 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1228 /* Request to target past last interesting grid */
1229 while (flag && (i < 0))
1231 /* Note the change */
1232 if (change_panel(creature_ptr, ddy[d], ddx[d]))
1234 int v = tmp_pos.y[m];
1235 int u = tmp_pos.x[m];
1237 /* Recalculate interesting grids */
1238 target_set_prepare(creature_ptr, mode);
1240 /* Look at interesting grids */
1243 /* Find a new monster */
1244 i = target_pick(v, u, ddy[d], ddx[d]);
1251 /* Nothing interesting */
1252 POSITION dx = ddx[d];
1253 POSITION dy = ddy[d];
1255 /* Restore previous position */
1258 panel_bounds_center();
1260 creature_ptr->update |= (PU_MONSTERS);
1261 creature_ptr->redraw |= (PR_MAP);
1262 creature_ptr->window |= (PW_OVERHEAD);
1263 handle_stuff(creature_ptr);
1265 /* Recalculate interesting grids */
1266 target_set_prepare(creature_ptr, mode);
1268 /* Look at boring grids */
1275 /* Do not move horizontally if unnecessary */
1276 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1277 ((x > panel_col_min + wid / 2) && (dx < 0)))
1282 /* Do not move vertically if unnecessary */
1283 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1284 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1289 /* Apply the motion */
1290 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1291 (x >= panel_col_min + wid) || (x < panel_col_min))
1293 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1296 /* Slide into legality */
1297 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1298 else if (x <= 0) x = 1;
1300 /* Slide into legality */
1301 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1302 else if (y <= 0) y = 1;
1312 /* Arbitrary grids */
1314 bool move_fast = FALSE;
1316 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1319 g_ptr = &floor_ptr->grid_array[y][x];
1321 /* Default prompt */
1322 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1326 char cheatinfo[100];
1327 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d",
1328 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x),
1329 projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special);
1330 strcat(info, cheatinfo);
1333 /* Describe and Prompt (enable "TARGET_LOOK") */
1334 while ((query = target_set_aux(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0);
1336 /* Assume no direction */
1341 if (query == '\r') query = 't';
1344 /* Analyze the keypress */
1368 /* Recenter the map around the player */
1369 verify_panel(creature_ptr);
1370 creature_ptr->update |= (PU_MONSTERS);
1371 creature_ptr->redraw |= (PR_MAP);
1372 creature_ptr->window |= (PW_OVERHEAD);
1373 handle_stuff(creature_ptr);
1375 /* Recalculate interesting grids */
1376 target_set_prepare(creature_ptr, mode);
1378 y = creature_ptr->y;
1379 x = creature_ptr->x;
1398 /* Pick a nearby monster */
1399 for (i = 0; i < tmp_pos.n; i++)
1401 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1411 /* Nothing interesting */
1412 if (bd == 999) flag = FALSE;
1419 /* Extract the action (if any) */
1420 d = get_keymap_dir(query);
1422 /* XTRA HACK MOVEFAST */
1423 if (isupper(query)) move_fast = TRUE;
1430 /* Handle "direction" */
1433 POSITION dx = ddx[d];
1434 POSITION dy = ddy[d];
1436 /* XTRA HACK MOVEFAST */
1439 int mag = MIN(wid / 2, hgt / 2);
1449 /* Do not move horizontally if unnecessary */
1450 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1451 ((x > panel_col_min + wid / 2) && (dx < 0)))
1456 /* Do not move vertically if unnecessary */
1457 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1458 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1463 /* Apply the motion */
1464 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1465 (x >= panel_col_min + wid) || (x < panel_col_min))
1467 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1470 /* Slide into legality */
1471 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1472 else if (x <= 0) x = 1;
1474 /* Slide into legality */
1475 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1476 else if (y <= 0) y = 1;
1483 /* Clear the top line */
1486 /* Recenter the map around the player */
1487 verify_panel(creature_ptr);
1488 creature_ptr->update |= (PU_MONSTERS);
1489 creature_ptr->redraw |= (PR_MAP);
1490 creature_ptr->window |= (PW_OVERHEAD);
1491 handle_stuff(creature_ptr);
1493 return target_who > 0;
1498 * Get an "aiming direction" from the user.
1500 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1501 * "0" for "current target", and "-1" for "entry aborted".
1503 * Note that "Force Target", if set, will pre-empt user interaction,
1504 * if there is a usable target already set.
1506 * Note that confusion over-rides any (explicit?) user choice.
1508 bool get_aim_dir(player_type *creature_ptr, DIRECTION *dp)
1510 /* Global direction */
1511 DIRECTION dir = command_dir;
1513 /* Hack -- auto-target if requested */
1514 if (use_old_target && target_okay(creature_ptr)) dir = 5;
1517 if (repeat_pull(&code))
1522 if (!(code == 5 && !target_okay(creature_ptr)))
1525 dir = (DIRECTION)code;
1529 *dp = (DIRECTION)code;
1531 /* Ask until satisfied */
1535 /* Choose a prompt */
1537 if (!target_okay(creature_ptr))
1539 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1543 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1546 /* Get a command (or Cancel) */
1547 if (!get_com(p, &command, TRUE)) break;
1551 if (command == '\r') command = 't';
1554 /* Convert various keys to "standard" keys */
1557 /* Use current target */
1568 /* Set new target */
1573 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
1579 /* Extract the action (if any) */
1580 dir = get_keymap_dir(command);
1586 /* Verify requested targets */
1587 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
1596 project_length = 0; /* reset to default */
1600 /* Save the direction */
1603 /* Check for confusion */
1604 if (creature_ptr->confused)
1606 /* Random direction */
1607 dir = ddd[randint0(8)];
1610 /* Notice confusion */
1611 if (command_dir != dir)
1614 msg_print(_("あなたは混乱している。", "You are confused."));
1617 /* Save direction */
1620 repeat_push((COMMAND_CODE)command_dir);
1625 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed)
1627 /* Global direction */
1628 DIRECTION dir = command_dir;
1631 if (repeat_pull(&code))
1633 dir = (DIRECTION)code;
1637 *dp = (DIRECTION)code;
1642 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1646 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1649 /* Get a direction */
1654 /* Get a command (or Cancel) */
1655 if (!get_com(prompt, &ch, TRUE)) break;
1658 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1664 /* Look up the direction */
1665 dir = get_keymap_dir(ch);
1671 /* Prevent weirdness */
1672 if ((dir == 5) && (!allow_under)) dir = 0;
1675 if (!dir) return FALSE;
1677 /* Save desired direction */
1680 /* Apply "confusion" */
1681 if (creature_ptr->confused)
1683 /* Standard confusion */
1684 if (randint0(100) < 75)
1686 /* Random direction */
1687 dir = ddd[randint0(8)];
1690 else if (creature_ptr->riding && with_steed)
1692 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1693 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1695 if (MON_CONFUSED(m_ptr))
1697 /* Standard confusion */
1698 if (randint0(100) < 75)
1700 /* Random direction */
1701 dir = ddd[randint0(8)];
1704 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1706 /* Random direction */
1707 dir = ddd[randint0(8)];
1709 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1711 /* Random direction */
1712 dir = ddd[randint0(8)];
1716 /* Notice confusion */
1717 if (command_dir != dir)
1719 if (creature_ptr->confused)
1722 msg_print(_("あなたは混乱している。", "You are confused."));
1726 GAME_TEXT m_name[MAX_NLEN];
1727 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1729 monster_desc(creature_ptr, m_name, m_ptr, 0);
1730 if (MON_CONFUSED(m_ptr))
1732 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1736 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1742 repeat_push((COMMAND_CODE)command_dir);
1748 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1749 * and place it into "command_dir", unless we already have one.
1751 * This function should be used for all "repeatable" commands, such as
1752 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1753 * as all commands which must reference a grid adjacent to the player,
1754 * and which may not reference the grid under the player. Note that,
1755 * for example, it is no longer possible to "disarm" or "open" chests
1756 * in the same grid as the player.
1758 * Direction "5" is illegal and will (cleanly) abort the command.
1760 * This function tracks and uses the "global direction", and uses
1761 * that as the "desired direction", to which "confusion" is applied.
1763 bool get_rep_dir(player_type *creature_ptr, DIRECTION *dp, bool under)
1765 /* Global direction */
1766 DIRECTION dir = command_dir;
1769 if (repeat_pull(&code))
1771 dir = (DIRECTION)code;
1775 *dp = (DIRECTION)code;
1780 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1784 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1787 /* Get a direction */
1792 /* Get a command (or Cancel) */
1793 if (!get_com(prompt, &ch, TRUE)) break;
1796 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1802 /* Look up the direction */
1803 dir = get_keymap_dir(ch);
1809 /* Prevent weirdness */
1810 if ((dir == 5) && (!under)) dir = 0;
1813 if (!dir) return FALSE;
1815 /* Save desired direction */
1818 /* Apply "confusion" */
1819 if (creature_ptr->confused)
1821 /* Standard confusion */
1822 if (randint0(100) < 75)
1824 /* Random direction */
1825 dir = ddd[randint0(8)];
1828 else if (creature_ptr->riding)
1830 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1831 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1833 if (MON_CONFUSED(m_ptr))
1835 /* Standard confusion */
1836 if (randint0(100) < 75)
1838 /* Random direction */
1839 dir = ddd[randint0(8)];
1842 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1844 /* Random direction */
1845 dir = ddd[randint0(8)];
1847 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1849 /* Random direction */
1850 dir = ddd[randint0(8)];
1854 /* Notice confusion */
1855 if (command_dir != dir)
1857 if (creature_ptr->confused)
1860 msg_print(_("あなたは混乱している。", "You are confused."));
1864 GAME_TEXT m_name[MAX_NLEN];
1865 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1867 monster_desc(creature_ptr, m_name, m_ptr, 0);
1868 if (MON_CONFUSED(m_ptr))
1870 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1874 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1880 repeat_push((COMMAND_CODE)command_dir);
1886 * XAngband: determine if a given location is "interesting"
1887 * based on target_set_accept function.
1889 static bool tgt_pt_accept(player_type *creature_ptr, POSITION y, POSITION x)
1891 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1892 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
1894 /* Player grid is always interesting */
1895 if ((y == creature_ptr->y) && (x == creature_ptr->x)) return TRUE;
1897 if (creature_ptr->image) return FALSE;
1900 g_ptr = &floor_ptr->grid_array[y][x];
1902 /* Interesting memorized features */
1903 if (!(g_ptr->info & (CAVE_MARK))) return FALSE;
1906 if (cave_have_flag_grid(g_ptr, FF_LESS)) return TRUE;
1907 if (cave_have_flag_grid(g_ptr, FF_MORE)) return TRUE;
1909 /* Notice quest features */
1910 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return TRUE;
1911 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return TRUE;
1918 * XAngband: Prepare the "temp" array for "tget_pt"
1919 * based on target_set_prepare funciton.
1921 static void tgt_pt_prepare(player_type *creature_ptr)
1925 if (!expand_list) return;
1927 /* Scan the current panel */
1928 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1929 for (POSITION y = 1; y < floor_ptr->height; y++)
1931 for (POSITION x = 1; x < floor_ptr->width; x++)
1933 /* Require "interesting" contents */
1934 if (!tgt_pt_accept(creature_ptr, y, x)) continue;
1936 /* Save the location */
1937 tmp_pos.x[tmp_pos.n] = x;
1938 tmp_pos.y[tmp_pos.n] = y;
1943 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
1948 * old -- from PsiAngband.
1950 bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr)
1953 get_screen_size(&wid, &hgt);
1955 POSITION x = creature_ptr->x;
1956 POSITION y = creature_ptr->y;
1958 if (expand_list) tgt_pt_prepare(creature_ptr);
1960 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
1961 msg_flag = FALSE; /* prevents "-more-" message. */
1965 bool success = FALSE;
1966 while ((ch != ESCAPE) && !success)
1968 bool move_fast = FALSE;
1970 move_cursor_relative(y, x);
1982 if (player_bold(creature_ptr, y, x)) ch = 0;
1985 else success = TRUE;
1989 /* XAngband: Move cursor to stairs */
1993 if (!expand_list || !tmp_pos.n) break;
1996 int cx = (panel_col_min + panel_col_max) / 2;
1997 int cy = (panel_row_min + panel_row_max) / 2;
2001 /* Skip stairs which have defferent distance */
2002 for (; n < tmp_pos.n; ++n)
2004 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2006 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2007 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2014 if (n == tmp_pos.n) /* Loop out taget list */
2017 y = creature_ptr->y;
2018 x = creature_ptr->x;
2019 verify_panel(creature_ptr); /* Move cursor to player */
2021 creature_ptr->update |= (PU_MONSTERS);
2023 creature_ptr->redraw |= (PR_MAP);
2025 creature_ptr->window |= (PW_OVERHEAD);
2026 handle_stuff(creature_ptr);
2028 else /* move cursor to next stair and change panel */
2033 dy = 2 * (y - cy) / hgt;
2034 dx = 2 * (x - cx) / wid;
2035 if (dy || dx) change_panel(creature_ptr, dy, dx);
2043 /* Look up the direction */
2044 int d = get_keymap_dir(ch);
2046 /* XTRA HACK MOVEFAST */
2047 if (isupper(ch)) move_fast = TRUE;
2049 /* Handle "direction" */
2055 /* XTRA HACK MOVEFAST */
2058 int mag = MIN(wid / 2, hgt / 2);
2068 /* Do not move horizontally if unnecessary */
2069 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2070 ((x > panel_col_min + wid / 2) && (dx < 0)))
2075 /* Do not move vertically if unnecessary */
2076 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2077 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2082 /* Apply the motion */
2083 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2084 (x >= panel_col_min + wid) || (x < panel_col_min))
2086 change_panel(creature_ptr, dy, dx);
2089 /* Slide into legality */
2090 if (x >= creature_ptr->current_floor_ptr->width - 1) x = creature_ptr->current_floor_ptr->width - 2;
2091 else if (x <= 0) x = 1;
2093 /* Slide into legality */
2094 if (y >= creature_ptr->current_floor_ptr->height - 1) y = creature_ptr->current_floor_ptr->height - 2;
2095 else if (y <= 0) y = 1;
2103 verify_panel(creature_ptr);
2104 creature_ptr->update |= (PU_MONSTERS);
2105 creature_ptr->redraw |= (PR_MAP);
2106 creature_ptr->window |= (PW_OVERHEAD);
2107 handle_stuff(creature_ptr);
2115 bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
2119 /* Ask until satisfied */
2124 /* Choose a prompt */
2126 if (!target_okay(creature_ptr))
2128 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2132 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2135 /* Get a command (or Cancel) */
2136 if (!get_com(p, &command, TRUE)) break;
2140 if (command == '\r') command = 't';
2143 /* Convert various keys to "standard" keys */
2146 /* Use current target */
2157 /* Set new target */
2162 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
2168 /* Look up the direction */
2169 dir = get_keymap_dir(command);
2175 /* Verify requested targets */
2176 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
2182 if (!dir) return FALSE;
2184 /* Save the direction */
2187 /* Check for confusion */
2188 if (creature_ptr->confused)
2190 /* Random direction */
2191 dir = ddd[randint0(8)];
2194 /* Notice confusion */
2195 if (command_dir != dir)
2198 msg_print(_("あなたは混乱している。", "You are confused."));