2 * @brief 雑多なその他の処理2 / effects of various "objects"
5 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
6 * This software may be copied and distributed for educational, research, and\n
7 * not for profit purposes provided that this copyright and statement are\n
8 * included in all such copies.\n
9 * 2014 Deskull rearranged comment for Doxygen.
12 #include "io/targeting.h"
13 #include "cmd-action/cmd-pet.h"
14 #include "cmd-building/cmd-building.h"
15 #include "core/sort.h"
16 #include "core/stuff-handler.h"
17 #include "info-reader/fixed-map-parser.h"
18 #include "dungeon/dungeon.h"
19 #include "dungeon/quest.h"
20 #include "effect/spells-effect-util.h"
21 #include "floor/floor-events.h"
22 #include "floor/floor-object.h"
23 #include "floor/floor-town.h"
24 #include "floor/floor.h"
25 #include "game-option/cheat-options.h"
26 #include "game-option/disturbance-options.h"
27 #include "game-option/game-play-options.h"
28 #include "game-option/input-options.h"
29 #include "game-option/map-screen-options.h"
30 #include "grid/feature.h"
31 #include "grid/grid.h"
32 #include "inventory/player-inventory.h"
33 #include "io/input-key-acceptor.h"
34 #include "main/sound-of-music.h"
35 #include "monster-race/race-flags1.h"
36 #include "monster-race/monster-race-hook.h"
37 #include "monster/monster-describer.h"
38 #include "monster/monster-description-types.h"
39 #include "monster/monster-flag-types.h"
40 #include "monster/monster-info.h"
41 #include "monster/monster-status.h"
42 #include "monster/monster-update.h"
43 #include "monster/smart-learn-types.h"
44 #include "object-enchant/object-curse.h"
45 #include "object/object-flavor.h"
46 #include "object/object-kind-hook.h"
47 #include "object/object-mark-types.h"
48 #include "player/player-move.h"
49 #include "player/player-race-types.h"
50 #include "player/player-status.h"
51 #include "spell/spells-summon.h"
52 #include "system/building-type-definition.h"
53 #include "system/system-variables.h"
54 #include "term/term-color-types.h"
55 #include "view/display-main-window.h"
56 #include "view/display-messages.h"
57 #include "view/display-lore.h"
58 #include "view/display-monster-status.h"
59 #include "world/world.h"
62 * @brief コンソール上におけるマップ表示の左上位置を返す /
63 * Calculates current boundaries Called below and from "do_cmd_locate()".
66 void panel_bounds_center(void)
70 get_screen_size(&wid, &hgt);
72 panel_row_max = panel_row_min + hgt - 1;
73 panel_row_prt = panel_row_min - 1;
74 panel_col_max = panel_col_min + wid - 1;
75 panel_col_prt = panel_col_min - 13;
79 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
80 * @param creature_ptr プレーヤーへの参照ポインタ
84 * Handle a request to change the current panel
85 * Return TRUE if the panel was changed.
86 * Also used in do_cmd_locate
87 * @return 実際に再描画が必要だった場合TRUEを返す
89 static bool change_panel_xy(player_type *creature_ptr, POSITION y, POSITION x)
91 POSITION dy = 0, dx = 0;
93 get_screen_size(&wid, &hgt);
95 if (y < panel_row_min) dy = -1;
96 if (y > panel_row_max) dy = 1;
97 if (x < panel_col_min) dx = -1;
98 if (x > panel_col_max) dx = 1;
100 if (!dy && !dx) return FALSE;
102 return change_panel(creature_ptr, dy, dx);
107 * @brief マップ描画のフォーカスを当てるべき座標を更新する
108 * @param creature_ptr プレーヤーへの参照ポインタ
110 * Given an row (y) and col (x), this routine detects when a move
111 * off the screen has occurred and figures new borders. -RAK-
112 * "Update" forces a "full update" to take place.
113 * The map is reprinted if necessary, and "TRUE" is returned.
114 * @return 実際に再描画が必要だった場合TRUEを返す
116 void verify_panel(player_type *creature_ptr)
118 POSITION y = creature_ptr->y;
119 POSITION x = creature_ptr->x;
122 get_screen_size(&wid, &hgt);
124 int max_prow_min = creature_ptr->current_floor_ptr->height - hgt;
125 int max_pcol_min = creature_ptr->current_floor_ptr->width - wid;
127 /* Bounds checking */
130 if (max_prow_min < 0) max_prow_min = 0;
131 if (max_pcol_min < 0) max_pcol_min = 0;
133 /* Center on player */
134 if (center_player && (center_running || !creature_ptr->running))
136 /* Center vertically */
137 prow_min = y - hgt / 2;
138 if (prow_min < 0) prow_min = 0;
139 else if (prow_min > max_prow_min) prow_min = max_prow_min;
141 /* Center horizontally */
142 pcol_min = x - wid / 2;
143 if (pcol_min < 0) pcol_min = 0;
144 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
148 prow_min = panel_row_min;
149 pcol_min = panel_col_min;
151 /* Scroll screen when 2 grids from top/bottom edge */
152 if (y > panel_row_max - 2)
154 while (y > prow_min + hgt - 1 - 2)
156 prow_min += (hgt / 2);
160 if (y < panel_row_min + 2)
162 while (y < prow_min + 2)
164 prow_min -= (hgt / 2);
168 if (prow_min > max_prow_min) prow_min = max_prow_min;
169 if (prow_min < 0) prow_min = 0;
171 /* Scroll screen when 4 grids from left/right edge */
172 if (x > panel_col_max - 4)
174 while (x > pcol_min + wid - 1 - 4)
176 pcol_min += (wid / 2);
180 if (x < panel_col_min + 4)
182 while (x < pcol_min + 4)
184 pcol_min -= (wid / 2);
188 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
189 if (pcol_min < 0) pcol_min = 0;
192 /* Check for "no change" */
193 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
195 /* Save the new panel info */
196 panel_row_min = prow_min;
197 panel_col_min = pcol_min;
199 /* Hack -- optional disturb on "panel change" */
200 if (disturb_panel && !center_player) disturb(creature_ptr, FALSE, FALSE);
202 panel_bounds_center();
204 creature_ptr->update |= (PU_MONSTERS);
205 creature_ptr->redraw |= (PR_MAP);
206 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
211 * Determine is a monster makes a reasonable target
213 * The concept of "targeting" was stolen from "Morgul" (?)
215 * The player can target any location, or any "target-able" monster.
217 * Currently, a monster is "target_able" if it is visible, and if
218 * the player can hit it with a projection, and the player is not
219 * hallucinating. This allows use of "use closest target" macros.
221 * Future versions may restrict the ability to target "trappers"
222 * and "mimics", but the semantics is a little bit weird.
224 bool target_able(player_type *creature_ptr, MONSTER_IDX m_idx)
226 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
227 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
229 /* Monster must be alive */
230 if (!monster_is_valid(m_ptr)) return FALSE;
232 /* Hack -- no targeting hallucinations */
233 if (creature_ptr->image) return FALSE;
235 /* Monster must be visible */
236 if (!m_ptr->ml) return FALSE;
238 if (creature_ptr->riding && (creature_ptr->riding == m_idx)) return TRUE;
240 /* Monster must be projectable */
241 if (!projectable(creature_ptr, creature_ptr->y, creature_ptr->x, m_ptr->fy, m_ptr->fx)) return FALSE;
243 /* Hack -- Never target trappers */
244 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return FALSE; */
252 * Targetting variables
254 MONSTER_IDX target_who;
259 * Update (if necessary) and verify (if possible) the target.
261 * We return TRUE if the target is "okay" and FALSE otherwise.
263 bool target_okay(player_type *creature_ptr)
265 /* Accept stationary targets */
266 if (target_who < 0) return TRUE;
268 /* Check moving targets */
269 if (target_who <= 0) return FALSE;
271 /* Accept reasonable targets */
272 if (!target_able(creature_ptr, target_who)) return FALSE;
274 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[target_who];
276 /* Acquire monster location */
277 target_row = m_ptr->fy;
278 target_col = m_ptr->fx;
286 * Hack -- help "select" a location (see below)
288 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
290 /* Scan the locations */
291 POSITION_IDX b_i = -1, b_v = 9999;
292 for (POSITION_IDX i = 0; i < tmp_pos.n; i++)
295 POSITION x2 = tmp_pos.x[i];
296 POSITION y2 = tmp_pos.y[i];
298 /* Directed distance */
299 POSITION x3 = (x2 - x1);
300 POSITION y3 = (y2 - y1);
302 /* Verify quadrant */
303 if (dx && (x3 * dx <= 0)) continue;
304 if (dy && (y3 * dy <= 0)) continue;
306 POSITION x4 = ABS(x3);
307 POSITION y4 = ABS(y3);
309 /* Verify quadrant */
310 if (dy && !dx && (x4 > y4)) continue;
311 if (dx && !dy && (y4 > x4)) continue;
313 /* Approximate Double Distance */
314 POSITION_IDX v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
316 /* Penalize location */
317 if ((b_i >= 0) && (v >= b_v)) continue;
326 * Hack -- determine if a given location is "interesting"
328 static bool target_set_accept(player_type *creature_ptr, POSITION y, POSITION x)
330 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
331 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
333 /* Player grid is always interesting */
334 if (player_bold(creature_ptr, y, x)) return TRUE;
336 if (creature_ptr->image) return FALSE;
339 g_ptr = &floor_ptr->grid_array[y][x];
341 /* Visible monsters */
344 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
346 /* Visible monsters */
347 if (m_ptr->ml) return TRUE;
350 /* Scan all objects in the grid */
351 OBJECT_IDX next_o_idx = 0;
352 for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
355 o_ptr = &floor_ptr->o_list[this_o_idx];
356 next_o_idx = o_ptr->next_o_idx;
358 /* Memorized object */
359 if (o_ptr->marked & OM_FOUND) return TRUE;
362 /* Interesting memorized features */
363 if (g_ptr->info & (CAVE_MARK))
365 /* Notice object features */
366 if (g_ptr->info & CAVE_OBJECT) return TRUE;
368 /* Feature code (applying "mimic" field) */
369 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
377 * Prepare the "temp" array for "target_set"
379 * Return the number of target_able monsters in the set.
381 static void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
383 POSITION min_hgt, max_hgt, min_wid, max_wid;
384 if (mode & TARGET_KILL)
387 min_hgt = MAX((creature_ptr->y - MAX_RANGE), 0);
388 max_hgt = MIN((creature_ptr->y + MAX_RANGE), creature_ptr->current_floor_ptr->height - 1);
389 min_wid = MAX((creature_ptr->x - MAX_RANGE), 0);
390 max_wid = MIN((creature_ptr->x + MAX_RANGE), creature_ptr->current_floor_ptr->width - 1);
392 else /* not targetting */
395 min_hgt = panel_row_min;
396 max_hgt = panel_row_max;
397 min_wid = panel_col_min;
398 max_wid = panel_col_max;
401 /* Reset "temp" array */
404 /* Scan the current panel */
405 for (POSITION y = min_hgt; y <= max_hgt; y++)
407 for (POSITION x = min_wid; x <= max_wid; x++)
411 /* Require "interesting" contents */
412 if (!target_set_accept(creature_ptr, y, x)) continue;
414 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
416 /* Require target_able monsters for "TARGET_KILL" */
417 if ((mode & (TARGET_KILL)) && !target_able(creature_ptr, g_ptr->m_idx)) continue;
419 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx])) continue;
421 /* Save the location */
422 tmp_pos.x[tmp_pos.n] = x;
423 tmp_pos.y[tmp_pos.n] = y;
428 /* Set the sort hooks */
429 if (mode & (TARGET_KILL))
431 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
435 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
438 if (creature_ptr->riding == 0 || !target_pet || (tmp_pos.n <= 1) || !(mode & (TARGET_KILL)))
441 POSITION tmp = tmp_pos.y[0];
442 tmp_pos.y[0] = tmp_pos.y[1];
445 tmp_pos.x[0] = tmp_pos.x[1];
450 void target_set_prepare_look(player_type *creature_ptr)
452 target_set_prepare(creature_ptr, TARGET_LOOK);
457 * Evaluate number of kill needed to gain level
459 static void evaluate_monster_exp(player_type *creature_ptr, char *buf, monster_type *m_ptr)
461 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
463 s32b exp_mon, exp_adv;
464 u32b exp_mon_frac, exp_adv_frac;
466 if ((creature_ptr->lev >= PY_MAX_LEVEL) || (creature_ptr->prace == RACE_ANDROID))
471 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
473 if (!current_world_ptr->wizard)
480 /* The monster's experience point (assuming average monster speed) */
481 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
483 s64b_div(&exp_mon, &exp_mon_frac, 0, (creature_ptr->max_plv + 2));
486 /* Total experience value for next level */
487 exp_adv = player_exp[creature_ptr->lev - 1] * creature_ptr->expfact;
489 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
491 /* Experience value need to get */
492 s64b_sub(&exp_adv, &exp_adv_frac, creature_ptr->exp, creature_ptr->exp_frac);
495 /* You need to kill at least one monster to get any experience */
496 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
497 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
499 /* Extract number of monsters needed */
500 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
502 /* If 999 or more monsters needed, only display "999". */
503 num = MIN(999, exp_adv_frac);
505 /* Display the number */
506 sprintf(buf, "%03ld", (long int)num);
510 bool show_gold_on_floor = FALSE;
513 * Examine a grid, return a keypress.
515 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
516 * indicates that the "space" key should scan through the contents
517 * of the grid, instead of simply returning immediately. This lets
518 * the "look" command get complete information, without making the
519 * "target" command annoying.
521 * The "info" argument contains the "commands" which should be shown
522 * inside the "[xxx]" text. This string must never be empty, or grids
523 * containing monsters will be displayed with an extra comma.
525 * Note that if a monster is in the grid, we update both the monster
526 * recall info and the health bar info to track that monster.
528 * Eventually, we may allow multiple objects per grid, or objects
529 * and terrain features in the same grid.
531 * This function must handle blindness/hallucination.
533 static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
535 OBJECT_IDX next_o_idx = 0;
536 concptr s1 = "", s2 = "", s3 = "", x_info = "";
541 char out_val[MAX_NLEN + 80];
542 OBJECT_IDX floor_list[23];
543 ITEM_NUMBER floor_num = 0;
545 /* Scan all objects in the grid */
548 floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02, 0);
552 x_info = _("x物 ", "x,");
556 /* Hack -- under the player */
557 if (player_bold(subject_ptr, y, x))
570 s1 = _("ターゲット:", "Target:");
573 /* Hack -- hallucination */
574 if (subject_ptr->image)
576 concptr name = _("何か奇妙な物", "something strange");
578 /* Display a message */
580 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
582 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
586 move_cursor_relative(y, x);
589 /* Stop on everything but "return" */
590 if ((query != '\r') && (query != '\n')) return query;
596 /* Actual monsters */
597 grid_type *g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
598 if (g_ptr->m_idx && subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)
600 monster_type *m_ptr = &subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
601 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
602 GAME_TEXT m_name[MAX_NLEN];
608 monster_desc(subject_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
609 monster_race_track(subject_ptr, m_ptr->ap_r_idx);
610 health_track(subject_ptr, g_ptr->m_idx);
611 handle_stuff(subject_ptr);
622 /* Recall on screen */
623 screen_roff(subject_ptr, m_ptr->ap_r_idx, 0);
625 /* Hack -- Complete the prompt (again) */
626 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
632 /* Normal commands */
633 if (query != 'r') break;
637 /* Cleare recall text and repeat */
643 /* Describe, and prompt for recall */
644 evaluate_monster_exp(subject_ptr, acount, m_ptr);
647 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);
649 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);
655 move_cursor_relative(y, x);
659 /* Normal commands */
660 if (query != 'r') break;
665 /* Always stop at "normal" keys */
666 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
668 /* Sometimes stop at "space" key */
669 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
671 /* Change the intro */
672 s1 = _("それは", "It is ");
674 /* Hack -- take account of gender */
675 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
676 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
678 /* Use a preposition */
686 /* Scan all objects being carried */
687 for (OBJECT_IDX this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
689 GAME_TEXT o_name[MAX_NLEN];
692 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
693 next_o_idx = o_ptr->next_o_idx;
695 object_desc(subject_ptr, o_name, o_ptr, 0);
698 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
700 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
704 move_cursor_relative(y, x);
707 /* Always stop at "normal" keys */
708 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
710 /* Sometimes stop at "space" key */
711 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
713 /* Change the intro */
714 s2 = _("をまた", "also carrying ");
717 /* Use a preposition */
734 GAME_TEXT o_name[MAX_NLEN];
737 o_ptr = &subject_ptr->current_floor_ptr->o_list[floor_list[0]];
739 object_desc(subject_ptr, o_name, o_ptr, 0);
742 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
744 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
748 move_cursor_relative(y, x);
756 /* Provide one cushion before item listing */
759 /* Display rough information about items */
761 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
763 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
767 move_cursor_relative(y, x);
771 /* No request for listing */
772 if (query != 'x' && query != ' ') return query;
776 /** Display list of items **/
778 /* Continue scrolling list if requested */
786 show_gold_on_floor = TRUE;
787 (void)show_floor(subject_ptr, 0, y, x, &min_width, 0);
788 show_gold_on_floor = FALSE;
792 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
794 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
801 /* Exit unless 'Enter' */
802 if (query != '\n' && query != '\r')
807 /* Get the object being moved. */
808 o_idx = g_ptr->o_idx;
810 /* Only rotate a pile of two or more objects. */
811 if (!(o_idx && subject_ptr->current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
813 /* Remove the first object from the list. */
814 excise_object_idx(subject_ptr->current_floor_ptr, o_idx);
816 /* Find end of the list. */
818 while (subject_ptr->current_floor_ptr->o_list[i].next_o_idx)
819 i = subject_ptr->current_floor_ptr->o_list[i].next_o_idx;
821 /* Add after the last object. */
822 subject_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
824 /* Loop and re-display the list */
831 /* Scan all objects in the grid */
832 for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
835 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
836 next_o_idx = o_ptr->next_o_idx;
838 if (o_ptr->marked & OM_FOUND)
840 GAME_TEXT o_name[MAX_NLEN];
845 object_desc(subject_ptr, o_name, o_ptr, 0);
848 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
850 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
854 move_cursor_relative(y, x);
857 /* Always stop at "normal" keys */
858 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
860 /* Sometimes stop at "space" key */
861 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
863 /* Change the intro */
864 s1 = _("それは", "It is ");
867 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(subject_ptr, y, x))
890 f_ptr = &f_info[feat];
892 /* Terrain feature if needed */
893 if (!boring && !have_flag(f_ptr->flags, FF_REMEMBER))
895 if ((query != '\r') && (query != '\n')) return query;
899 /* Hack -- special handling for quest entrances */
901 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
903 /* Set the quest number temporary */
904 IDX old_quest = subject_ptr->current_floor_ptr->inside_quest;
908 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
911 subject_ptr->current_floor_ptr->inside_quest = g_ptr->special;
913 /* Get the quest text */
914 init_flags = INIT_NAME_ONLY;
916 parse_fixed_map(subject_ptr, "q_info.txt", 0, 0, 0, 0);
918 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
919 quest[g_ptr->special].name, quest[g_ptr->special].level);
921 /* Reset the old quest number */
922 subject_ptr->current_floor_ptr->inside_quest = old_quest;
925 /* Hack -- special handling for building doors */
926 else if (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena)
928 name = building[f_ptr->subtype].name;
930 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
932 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
934 else if (have_flag(f_ptr->flags, FF_TOWN))
936 name = town_info[g_ptr->special].name;
938 else if (subject_ptr->wild_mode && (feat == feat_floor))
940 name = _("道", "road");
944 name = f_name + f_ptr->name;
949 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
950 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
951 have_flag(f_ptr->flags, FF_TOWN)))
956 /* Hack -- special introduction for store & building doors -KMW- */
957 if (have_flag(f_ptr->flags, FF_STORE) ||
958 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
959 (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena) ||
960 have_flag(f_ptr->flags, FF_ENTRANCE))
966 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
967 have_flag(f_ptr->flags, FF_TOWN) ||
968 have_flag(f_ptr->flags, FF_SHALLOW) ||
969 have_flag(f_ptr->flags, FF_DEEP))
975 /* Pick proper indefinite article */
976 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
980 /* Display a message */
981 if (current_world_ptr->wizard)
984 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
985 else sprintf(f_idx_str, "%d", g_ptr->feat);
987 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]);
989 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);
994 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
996 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1000 move_cursor_relative(y, x);
1003 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1009 * Handle "target" and "look".
1011 * Note that this code can be called from "get_aim_dir()".
1013 * All locations must be on the current panel. Consider the use of
1014 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1015 * some form of "scrolling" the map around the cursor.
1016 * That is, consider the possibility of "auto-scrolling" the screen
1017 * while the cursor moves around. This may require changes in the
1018 * "update_monster()" code to allow "visibility" even if off panel, and
1019 * may require dynamic recalculation of the "temp" grid set.
1021 * Hack -- targeting/observing an "outer border grid" may induce
1022 * problems, so this is not currently allowed.
1024 * The player can use the direction keys to move among "interesting"
1025 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1026 * move through the "interesting" grids in a sequential manner, or
1027 * can enter "location" mode, and use the direction keys to move one
1028 * grid at a time in any direction. The "t" (set target) command will
1029 * only target a monster (as opposed to a location) if the monster is
1030 * target_able and the "interesting" mode is being used.
1032 * The current grid is described using the "look" method above, and
1033 * a new command may be entered at any time, but note that if the
1034 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1035 * where "space" has no obvious meaning) then "space" will scan
1036 * through the description of the current grid until done, instead
1037 * of immediately jumping to the next "interesting" grid. This
1038 * allows the "target" command to retain its old semantics.
1040 * The "*", "+", and "-" keys may always be used to jump immediately
1041 * to the next (or previous) interesting grid, in the proper mode.
1043 * The "return" key may always be used to scan through a complete
1044 * grid description (forever).
1046 * This command will cancel any old target, even if used from
1047 * inside the "look" command.
1049 bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
1052 POSITION y = creature_ptr->y;
1053 POSITION x = creature_ptr->x;
1063 get_screen_size(&wid, &hgt);
1068 if (rogue_like_commands)
1077 /* Prepare the "temp" array */
1078 target_set_prepare(creature_ptr, mode);
1080 /* Start near the player */
1084 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1087 /* Interesting grids */
1088 if (flag && tmp_pos.n)
1094 change_panel_xy(creature_ptr, y, x);
1096 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1099 g_ptr = &floor_ptr->grid_array[y][x];
1102 if (target_able(creature_ptr, g_ptr->m_idx))
1104 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1107 /* Dis-allow target */
1110 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1116 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1117 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x));
1118 strcat(info, cheatinfo);
1121 /* Describe and Prompt */
1124 query = target_set_aux(creature_ptr, y, x, mode, info);
1128 /* Assume no "direction" */
1133 if (query == '\r') query = 't';
1151 if (target_able(creature_ptr, g_ptr->m_idx))
1153 health_track(creature_ptr, g_ptr->m_idx);
1154 target_who = g_ptr->m_idx;
1170 if (++m == tmp_pos.n)
1173 if (!expand_list) done = TRUE;
1183 if (!expand_list) done = TRUE;
1190 /* Recenter the map around the player */
1191 verify_panel(creature_ptr);
1192 creature_ptr->update |= (PU_MONSTERS);
1193 creature_ptr->redraw |= (PR_MAP);
1194 creature_ptr->window |= (PW_OVERHEAD);
1195 handle_stuff(creature_ptr);
1197 /* Recalculate interesting grids */
1198 target_set_prepare(creature_ptr, mode);
1200 y = creature_ptr->y;
1201 x = creature_ptr->x;
1218 if (query == same_key)
1220 if (++m == tmp_pos.n)
1223 if (!expand_list) done = TRUE;
1228 /* Extract the action (if any) */
1229 d = get_keymap_dir(query);
1236 /* Hack -- move around */
1239 /* Modified to scroll to monster */
1240 POSITION y2 = panel_row_min;
1241 POSITION x2 = panel_col_min;
1243 /* Find a new monster */
1244 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1246 /* Request to target past last interesting grid */
1247 while (flag && (i < 0))
1249 /* Note the change */
1250 if (change_panel(creature_ptr, ddy[d], ddx[d]))
1252 int v = tmp_pos.y[m];
1253 int u = tmp_pos.x[m];
1255 /* Recalculate interesting grids */
1256 target_set_prepare(creature_ptr, mode);
1258 /* Look at interesting grids */
1261 /* Find a new monster */
1262 i = target_pick(v, u, ddy[d], ddx[d]);
1269 /* Nothing interesting */
1270 POSITION dx = ddx[d];
1271 POSITION dy = ddy[d];
1273 /* Restore previous position */
1276 panel_bounds_center();
1278 creature_ptr->update |= (PU_MONSTERS);
1279 creature_ptr->redraw |= (PR_MAP);
1280 creature_ptr->window |= (PW_OVERHEAD);
1281 handle_stuff(creature_ptr);
1283 /* Recalculate interesting grids */
1284 target_set_prepare(creature_ptr, mode);
1286 /* Look at boring grids */
1293 /* Do not move horizontally if unnecessary */
1294 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1295 ((x > panel_col_min + wid / 2) && (dx < 0)))
1300 /* Do not move vertically if unnecessary */
1301 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1302 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1307 /* Apply the motion */
1308 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1309 (x >= panel_col_min + wid) || (x < panel_col_min))
1311 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1314 /* Slide into legality */
1315 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1316 else if (x <= 0) x = 1;
1318 /* Slide into legality */
1319 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1320 else if (y <= 0) y = 1;
1330 /* Arbitrary grids */
1332 bool move_fast = FALSE;
1334 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1337 g_ptr = &floor_ptr->grid_array[y][x];
1339 /* Default prompt */
1340 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1344 char cheatinfo[100];
1345 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d",
1346 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x),
1347 projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special);
1348 strcat(info, cheatinfo);
1351 /* Describe and Prompt (enable "TARGET_LOOK") */
1352 while ((query = target_set_aux(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0);
1354 /* Assume no direction */
1359 if (query == '\r') query = 't';
1362 /* Analyze the keypress */
1386 /* Recenter the map around the player */
1387 verify_panel(creature_ptr);
1388 creature_ptr->update |= (PU_MONSTERS);
1389 creature_ptr->redraw |= (PR_MAP);
1390 creature_ptr->window |= (PW_OVERHEAD);
1391 handle_stuff(creature_ptr);
1393 /* Recalculate interesting grids */
1394 target_set_prepare(creature_ptr, mode);
1396 y = creature_ptr->y;
1397 x = creature_ptr->x;
1416 /* Pick a nearby monster */
1417 for (i = 0; i < tmp_pos.n; i++)
1419 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1429 /* Nothing interesting */
1430 if (bd == 999) flag = FALSE;
1437 /* Extract the action (if any) */
1438 d = get_keymap_dir(query);
1440 /* XTRA HACK MOVEFAST */
1441 if (isupper(query)) move_fast = TRUE;
1448 /* Handle "direction" */
1451 POSITION dx = ddx[d];
1452 POSITION dy = ddy[d];
1454 /* XTRA HACK MOVEFAST */
1457 int mag = MIN(wid / 2, hgt / 2);
1467 /* Do not move horizontally if unnecessary */
1468 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1469 ((x > panel_col_min + wid / 2) && (dx < 0)))
1474 /* Do not move vertically if unnecessary */
1475 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1476 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1481 /* Apply the motion */
1482 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1483 (x >= panel_col_min + wid) || (x < panel_col_min))
1485 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1488 /* Slide into legality */
1489 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1490 else if (x <= 0) x = 1;
1492 /* Slide into legality */
1493 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1494 else if (y <= 0) y = 1;
1501 /* Clear the top line */
1504 /* Recenter the map around the player */
1505 verify_panel(creature_ptr);
1506 creature_ptr->update |= (PU_MONSTERS);
1507 creature_ptr->redraw |= (PR_MAP);
1508 creature_ptr->window |= (PW_OVERHEAD);
1509 handle_stuff(creature_ptr);
1511 return target_who != 0;
1516 * Get an "aiming direction" from the user.
1518 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1519 * "0" for "current target", and "-1" for "entry aborted".
1521 * Note that "Force Target", if set, will pre-empt user interaction,
1522 * if there is a usable target already set.
1524 * Note that confusion over-rides any (explicit?) user choice.
1526 bool get_aim_dir(player_type *creature_ptr, DIRECTION *dp)
1528 /* Global direction */
1529 DIRECTION dir = command_dir;
1531 /* Hack -- auto-target if requested */
1532 if (use_old_target && target_okay(creature_ptr)) dir = 5;
1535 if (repeat_pull(&code))
1540 if (!(code == 5 && !target_okay(creature_ptr)))
1543 dir = (DIRECTION)code;
1547 *dp = (DIRECTION)code;
1549 /* Ask until satisfied */
1553 /* Choose a prompt */
1555 if (!target_okay(creature_ptr))
1557 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1561 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1564 /* Get a command (or Cancel) */
1565 if (!get_com(p, &command, TRUE)) break;
1569 if (command == '\r') command = 't';
1572 /* Convert various keys to "standard" keys */
1575 /* Use current target */
1586 /* Set new target */
1591 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
1597 /* Extract the action (if any) */
1598 dir = get_keymap_dir(command);
1604 /* Verify requested targets */
1605 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
1614 project_length = 0; /* reset to default */
1618 /* Save the direction */
1621 /* Check for confusion */
1622 if (creature_ptr->confused)
1624 /* Random direction */
1625 dir = ddd[randint0(8)];
1628 /* Notice confusion */
1629 if (command_dir != dir)
1632 msg_print(_("あなたは混乱している。", "You are confused."));
1635 /* Save direction */
1638 repeat_push((COMMAND_CODE)command_dir);
1643 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed)
1645 /* Global direction */
1646 DIRECTION dir = command_dir;
1649 if (repeat_pull(&code))
1651 dir = (DIRECTION)code;
1655 *dp = (DIRECTION)code;
1660 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1664 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1667 /* Get a direction */
1672 /* Get a command (or Cancel) */
1673 if (!get_com(prompt, &ch, TRUE)) break;
1676 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1682 /* Look up the direction */
1683 dir = get_keymap_dir(ch);
1689 /* Prevent weirdness */
1690 if ((dir == 5) && (!allow_under)) dir = 0;
1693 if (!dir) return FALSE;
1695 /* Save desired direction */
1698 /* Apply "confusion" */
1699 if (creature_ptr->confused)
1701 /* Standard confusion */
1702 if (randint0(100) < 75)
1704 /* Random direction */
1705 dir = ddd[randint0(8)];
1708 else if (creature_ptr->riding && with_steed)
1710 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1711 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1713 if (monster_confused_remaining(m_ptr))
1715 /* Standard confusion */
1716 if (randint0(100) < 75)
1718 /* Random direction */
1719 dir = ddd[randint0(8)];
1722 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1724 /* Random direction */
1725 dir = ddd[randint0(8)];
1727 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1729 /* Random direction */
1730 dir = ddd[randint0(8)];
1734 /* Notice confusion */
1735 if (command_dir != dir)
1737 if (creature_ptr->confused)
1740 msg_print(_("あなたは混乱している。", "You are confused."));
1744 GAME_TEXT m_name[MAX_NLEN];
1745 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1747 monster_desc(creature_ptr, m_name, m_ptr, 0);
1748 if (monster_confused_remaining(m_ptr))
1750 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1754 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1760 repeat_push((COMMAND_CODE)command_dir);
1766 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1767 * and place it into "command_dir", unless we already have one.
1769 * This function should be used for all "repeatable" commands, such as
1770 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1771 * as all commands which must reference a grid adjacent to the player,
1772 * and which may not reference the grid under the player. Note that,
1773 * for example, it is no longer possible to "disarm" or "open" chests
1774 * in the same grid as the player.
1776 * Direction "5" is illegal and will (cleanly) abort the command.
1778 * This function tracks and uses the "global direction", and uses
1779 * that as the "desired direction", to which "confusion" is applied.
1781 bool get_rep_dir(player_type *creature_ptr, DIRECTION *dp, bool under)
1783 /* Global direction */
1784 DIRECTION dir = command_dir;
1787 if (repeat_pull(&code))
1789 dir = (DIRECTION)code;
1793 *dp = (DIRECTION)code;
1798 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1802 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1805 /* Get a direction */
1810 /* Get a command (or Cancel) */
1811 if (!get_com(prompt, &ch, TRUE)) break;
1814 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1820 /* Look up the direction */
1821 dir = get_keymap_dir(ch);
1827 /* Prevent weirdness */
1828 if ((dir == 5) && (!under)) dir = 0;
1831 if (!dir) return FALSE;
1833 /* Save desired direction */
1836 /* Apply "confusion" */
1837 if (creature_ptr->confused)
1839 /* Standard confusion */
1840 if (randint0(100) < 75)
1842 /* Random direction */
1843 dir = ddd[randint0(8)];
1846 else if (creature_ptr->riding)
1848 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1849 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1851 if (monster_confused_remaining(m_ptr))
1853 /* Standard confusion */
1854 if (randint0(100) < 75)
1856 /* Random direction */
1857 dir = ddd[randint0(8)];
1860 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1862 /* Random direction */
1863 dir = ddd[randint0(8)];
1865 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1867 /* Random direction */
1868 dir = ddd[randint0(8)];
1872 /* Notice confusion */
1873 if (command_dir != dir)
1875 if (creature_ptr->confused)
1878 msg_print(_("あなたは混乱している。", "You are confused."));
1882 GAME_TEXT m_name[MAX_NLEN];
1883 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1885 monster_desc(creature_ptr, m_name, m_ptr, 0);
1886 if (monster_confused_remaining(m_ptr))
1888 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1892 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1898 repeat_push((COMMAND_CODE)command_dir);
1904 * XAngband: determine if a given location is "interesting"
1905 * based on target_set_accept function.
1907 static bool tgt_pt_accept(player_type *creature_ptr, POSITION y, POSITION x)
1909 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1910 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
1912 /* Player grid is always interesting */
1913 if ((y == creature_ptr->y) && (x == creature_ptr->x)) return TRUE;
1915 if (creature_ptr->image) return FALSE;
1918 g_ptr = &floor_ptr->grid_array[y][x];
1920 /* Interesting memorized features */
1921 if (!(g_ptr->info & (CAVE_MARK))) return FALSE;
1924 if (cave_have_flag_grid(g_ptr, FF_LESS)) return TRUE;
1925 if (cave_have_flag_grid(g_ptr, FF_MORE)) return TRUE;
1927 /* Notice quest features */
1928 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return TRUE;
1929 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return TRUE;
1936 * XAngband: Prepare the "temp" array for "tget_pt"
1937 * based on target_set_prepare funciton.
1939 static void tgt_pt_prepare(player_type *creature_ptr)
1943 if (!expand_list) return;
1945 /* Scan the current panel */
1946 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1947 for (POSITION y = 1; y < floor_ptr->height; y++)
1949 for (POSITION x = 1; x < floor_ptr->width; x++)
1951 /* Require "interesting" contents */
1952 if (!tgt_pt_accept(creature_ptr, y, x)) continue;
1954 /* Save the location */
1955 tmp_pos.x[tmp_pos.n] = x;
1956 tmp_pos.y[tmp_pos.n] = y;
1961 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
1966 * old -- from PsiAngband.
1968 bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr)
1971 get_screen_size(&wid, &hgt);
1973 POSITION x = creature_ptr->x;
1974 POSITION y = creature_ptr->y;
1976 if (expand_list) tgt_pt_prepare(creature_ptr);
1978 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
1979 msg_flag = FALSE; /* prevents "-more-" message. */
1983 bool success = FALSE;
1984 while ((ch != ESCAPE) && !success)
1986 bool move_fast = FALSE;
1988 move_cursor_relative(y, x);
2000 if (player_bold(creature_ptr, y, x)) ch = 0;
2003 else success = TRUE;
2007 /* XAngband: Move cursor to stairs */
2011 if (!expand_list || !tmp_pos.n) break;
2014 int cx = (panel_col_min + panel_col_max) / 2;
2015 int cy = (panel_row_min + panel_row_max) / 2;
2019 /* Skip stairs which have defferent distance */
2020 for (; n < tmp_pos.n; ++n)
2022 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2024 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2025 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2032 if (n == tmp_pos.n) /* Loop out taget list */
2035 y = creature_ptr->y;
2036 x = creature_ptr->x;
2037 verify_panel(creature_ptr); /* Move cursor to player */
2039 creature_ptr->update |= (PU_MONSTERS);
2041 creature_ptr->redraw |= (PR_MAP);
2043 creature_ptr->window |= (PW_OVERHEAD);
2044 handle_stuff(creature_ptr);
2046 else /* move cursor to next stair and change panel */
2051 dy = 2 * (y - cy) / hgt;
2052 dx = 2 * (x - cx) / wid;
2053 if (dy || dx) change_panel(creature_ptr, dy, dx);
2061 /* Look up the direction */
2062 int d = get_keymap_dir(ch);
2064 /* XTRA HACK MOVEFAST */
2065 if (isupper(ch)) move_fast = TRUE;
2067 /* Handle "direction" */
2073 /* XTRA HACK MOVEFAST */
2076 int mag = MIN(wid / 2, hgt / 2);
2086 /* Do not move horizontally if unnecessary */
2087 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2088 ((x > panel_col_min + wid / 2) && (dx < 0)))
2093 /* Do not move vertically if unnecessary */
2094 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2095 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2100 /* Apply the motion */
2101 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2102 (x >= panel_col_min + wid) || (x < panel_col_min))
2104 change_panel(creature_ptr, dy, dx);
2107 /* Slide into legality */
2108 if (x >= creature_ptr->current_floor_ptr->width - 1) x = creature_ptr->current_floor_ptr->width - 2;
2109 else if (x <= 0) x = 1;
2111 /* Slide into legality */
2112 if (y >= creature_ptr->current_floor_ptr->height - 1) y = creature_ptr->current_floor_ptr->height - 2;
2113 else if (y <= 0) y = 1;
2121 verify_panel(creature_ptr);
2122 creature_ptr->update |= (PU_MONSTERS);
2123 creature_ptr->redraw |= (PR_MAP);
2124 creature_ptr->window |= (PW_OVERHEAD);
2125 handle_stuff(creature_ptr);
2133 bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
2137 /* Ask until satisfied */
2142 /* Choose a prompt */
2144 if (!target_okay(creature_ptr))
2146 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2150 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2153 /* Get a command (or Cancel) */
2154 if (!get_com(p, &command, TRUE)) break;
2158 if (command == '\r') command = 't';
2161 /* Convert various keys to "standard" keys */
2164 /* Use current target */
2175 /* Set new target */
2180 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
2186 /* Look up the direction */
2187 dir = get_keymap_dir(command);
2193 /* Verify requested targets */
2194 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
2200 if (!dir) return FALSE;
2202 /* Save the direction */
2205 /* Check for confusion */
2206 if (creature_ptr->confused)
2208 /* Random direction */
2209 dir = ddd[randint0(8)];
2212 /* Notice confusion */
2213 if (command_dir != dir)
2216 msg_print(_("あなたは混乱している。", "You are confused."));