3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
18 #include "targeting.h"
22 #include "dungeon-file.h"
23 #include "object-curse.h"
24 #include "object-flavor.h"
26 #include "monsterrace-hook.h"
27 #include "objectkind-hook.h"
29 #include "spells-summon.h"
32 #include "floor-events.h"
33 #include "floor-town.h"
34 #include "player-move.h"
35 #include "player-status.h"
36 #include "monster-status.h"
37 #include "view-mainwindow.h"
45 * @brief コンソール上におけるマップ表示の左上位置を返す /
46 * Calculates current boundaries Called below and from "do_cmd_locate()".
49 void panel_bounds_center(void)
53 get_screen_size(&wid, &hgt);
55 panel_row_max = panel_row_min + hgt - 1;
56 panel_row_prt = panel_row_min - 1;
57 panel_col_max = panel_col_min + wid - 1;
58 panel_col_prt = panel_col_min - 13;
62 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
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;
77 get_screen_size(&wid, &hgt);
79 if (y < panel_row_min) dy = -1;
80 if (y > panel_row_max) dy = 1;
81 if (x < panel_col_min) dx = -1;
82 if (x > panel_col_max) dx = 1;
84 if (!dy && !dx) return FALSE;
86 return change_panel(creature_ptr, dy, dx);
91 * @brief マップ描画のフォーカスを当てるべき座標を更新する
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(void)
101 POSITION y = p_ptr->y;
102 POSITION x = p_ptr->x;
110 get_screen_size(&wid, &hgt);
112 max_prow_min = p_ptr->current_floor_ptr->height - hgt;
113 max_pcol_min = p_ptr->current_floor_ptr->width - wid;
115 /* Bounds checking */
116 if (max_prow_min < 0) max_prow_min = 0;
117 if (max_pcol_min < 0) max_pcol_min = 0;
119 /* Center on player */
120 if (center_player && (center_running || !p_ptr->running))
122 /* Center vertically */
123 prow_min = y - hgt / 2;
124 if (prow_min < 0) prow_min = 0;
125 else if (prow_min > max_prow_min) prow_min = max_prow_min;
127 /* Center horizontally */
128 pcol_min = x - wid / 2;
129 if (pcol_min < 0) pcol_min = 0;
130 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
134 prow_min = panel_row_min;
135 pcol_min = panel_col_min;
137 /* Scroll screen when 2 grids from top/bottom edge */
138 if (y > panel_row_max - 2)
140 while (y > prow_min + hgt-1 - 2)
142 prow_min += (hgt / 2);
146 if (y < panel_row_min + 2)
148 while (y < prow_min + 2)
150 prow_min -= (hgt / 2);
154 if (prow_min > max_prow_min) prow_min = max_prow_min;
155 if (prow_min < 0) prow_min = 0;
157 /* Scroll screen when 4 grids from left/right edge */
158 if (x > panel_col_max - 4)
160 while (x > pcol_min + wid-1 - 4)
162 pcol_min += (wid / 2);
166 if (x < panel_col_min + 4)
168 while (x < pcol_min + 4)
170 pcol_min -= (wid / 2);
174 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
175 if (pcol_min < 0) pcol_min = 0;
178 /* Check for "no change" */
179 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
181 /* Save the new panel info */
182 panel_row_min = prow_min;
183 panel_col_min = pcol_min;
185 /* Hack -- optional disturb on "panel change" */
186 if (disturb_panel && !center_player) disturb(p_ptr, FALSE, FALSE);
188 panel_bounds_center();
190 p_ptr->update |= (PU_MONSTERS);
191 p_ptr->redraw |= (PR_MAP);
192 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
196 /*** Targeting Code ***/
199 * Determine is a monster makes a reasonable target
201 * The concept of "targeting" was stolen from "Morgul" (?)
203 * The player can target any location, or any "target-able" monster.
205 * Currently, a monster is "target_able" if it is visible, and if
206 * the player can hit it with a projection, and the player is not
207 * hallucinating. This allows use of "use closest target" macros.
209 * Future versions may restrict the ability to target "trappers"
210 * and "mimics", but the semantics is a little bit weird.
212 bool target_able(MONSTER_IDX m_idx)
214 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
216 /* Monster must be alive */
217 if (!monster_is_valid(m_ptr)) return FALSE;
219 /* Hack -- no targeting hallucinations */
220 if (p_ptr->image) return FALSE;
222 /* Monster must be visible */
223 if (!m_ptr->ml) return FALSE;
225 if (p_ptr->riding && (p_ptr->riding == m_idx)) return TRUE;
227 /* Monster must be projectable */
228 if (!projectable(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return FALSE;
230 /* Hack -- Never target trappers */
231 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return FALSE; */
239 * Targetting variables
241 MONSTER_IDX target_who;
246 * Update (if necessary) and verify (if possible) the target.
248 * We return TRUE if the target is "okay" and FALSE otherwise.
250 bool target_okay(void)
252 /* Accept stationary targets */
253 if (target_who < 0) return TRUE;
255 /* Check moving targets */
258 /* Accept reasonable targets */
259 if (target_able(target_who))
261 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[target_who];
263 /* Acquire monster location */
264 target_row = m_ptr->fy;
265 target_col = m_ptr->fx;
272 /* Assume no target */
278 * Hack -- help "select" a location (see below)
280 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
283 POSITION x2, y2, x3, y3, x4, y4;
284 POSITION_IDX b_i = -1, b_v = 9999;
287 /* Scan the locations */
288 for (i = 0; i < tmp_pos.n; i++)
294 /* Directed distance */
298 /* Verify quadrant */
299 if (dx && (x3 * dx <= 0)) continue;
300 if (dy && (y3 * dy <= 0)) continue;
305 /* Verify quadrant */
306 if (dy && !dx && (x4 > y4)) continue;
307 if (dx && !dy && (y4 > x4)) continue;
309 /* Approximate Double Distance */
310 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
312 /* Penalize location */
313 if ((b_i >= 0) && (v >= b_v)) continue;
321 * Hack -- determine if a given location is "interesting"
323 static bool target_set_accept(POSITION y, POSITION x)
326 OBJECT_IDX this_o_idx, next_o_idx = 0;
328 if (!(in_bounds(p_ptr->current_floor_ptr, y, x))) return FALSE;
330 /* Player grid is always interesting */
331 if (player_bold(p_ptr, y, x)) return TRUE;
333 if (p_ptr->image) return FALSE;
335 g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
337 /* Visible monsters */
340 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
342 /* Visible monsters */
343 if (m_ptr->ml) return TRUE;
346 /* Scan all objects in the grid */
347 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
350 o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
351 next_o_idx = o_ptr->next_o_idx;
353 /* Memorized object */
354 if (o_ptr->marked & OM_FOUND) return TRUE;
357 /* Interesting memorized features */
358 if (g_ptr->info & (CAVE_MARK))
360 /* Notice object features */
361 if (g_ptr->info & CAVE_OBJECT) return TRUE;
363 /* Feature code (applying "mimic" field) */
364 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
372 * Prepare the "temp" array for "target_set"
374 * Return the number of target_able monsters in the set.
376 static void target_set_prepare(BIT_FLAGS mode)
379 POSITION min_hgt, max_hgt, min_wid, max_wid;
381 if (mode & TARGET_KILL)
384 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
385 max_hgt = MIN((p_ptr->y + MAX_RANGE), p_ptr->current_floor_ptr->height - 1);
386 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
387 max_wid = MIN((p_ptr->x + MAX_RANGE), p_ptr->current_floor_ptr->width - 1);
389 else /* not targetting */
392 min_hgt = panel_row_min;
393 max_hgt = panel_row_max;
394 min_wid = panel_col_min;
395 max_wid = panel_col_max;
398 /* Reset "temp" array */
401 /* Scan the current panel */
402 for (y = min_hgt; y <= max_hgt; y++)
404 for (x = min_wid; x <= max_wid; x++)
408 /* Require "interesting" contents */
409 if (!target_set_accept(y, x)) continue;
411 g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
413 /* Require target_able monsters for "TARGET_KILL" */
414 if ((mode & (TARGET_KILL)) && !target_able(g_ptr->m_idx)) continue;
416 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&p_ptr->current_floor_ptr->m_list[g_ptr->m_idx])) continue;
418 /* Save the location */
419 tmp_pos.x[tmp_pos.n] = x;
420 tmp_pos.y[tmp_pos.n] = y;
425 /* Set the sort hooks */
426 if (mode & (TARGET_KILL))
428 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
432 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
435 if (p_ptr->riding && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
440 tmp_pos.y[0] = tmp_pos.y[1];
443 tmp_pos.x[0] = tmp_pos.x[1];
448 void target_set_prepare_look(void){
449 target_set_prepare(TARGET_LOOK);
454 * Evaluate number of kill needed to gain level
456 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
458 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
460 s32b exp_mon, exp_adv;
461 u32b exp_mon_frac, exp_adv_frac;
463 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
468 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
470 if (!current_world_ptr->wizard)
478 /* The monster's experience point (assuming average monster speed) */
479 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
481 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
484 /* Total experience value for next level */
485 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
487 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
489 /* Experience value need to get */
490 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
493 /* You need to kill at least one monster to get any experience */
494 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
495 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
497 /* Extract number of monsters needed */
498 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
500 /* If 999 or more monsters needed, only display "999". */
501 num = MIN(999, exp_adv_frac);
503 /* Display the number */
504 sprintf(buf,"%03ld", (long int)num);
508 bool show_gold_on_floor = FALSE;
511 * Examine a grid, return a keypress.
513 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
514 * indicates that the "space" key should scan through the contents
515 * of the grid, instead of simply returning immediately. This lets
516 * the "look" command get complete information, without making the
517 * "target" command annoying.
519 * The "info" argument contains the "commands" which should be shown
520 * inside the "[xxx]" text. This string must never be empty, or grids
521 * containing monsters will be displayed with an extra comma.
523 * Note that if a monster is in the grid, we update both the monster
524 * recall info and the health bar info to track that monster.
526 * Eventually, we may allow multiple objects per grid, or objects
527 * and terrain features in the same grid.
529 * This function must handle blindness/hallucination.
531 static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
533 grid_type *g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
534 OBJECT_IDX this_o_idx, next_o_idx = 0;
535 concptr s1 = "", s2 = "", s3 = "", x_info = "";
540 char out_val[MAX_NLEN+80];
541 OBJECT_IDX floor_list[23];
542 ITEM_NUMBER floor_num = 0;
544 /* Scan all objects in the grid */
547 floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02);
551 x_info = _("x物 ", "x,");
555 /* Hack -- under the player */
556 if (player_bold(subject_ptr, y, x))
569 s1 = _("ターゲット:", "Target:");
572 /* Hack -- hallucination */
573 if (subject_ptr->image)
575 concptr name = _("何か奇妙な物", "something strange");
577 /* Display a message */
579 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
581 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
585 move_cursor_relative(y, x);
588 /* Stop on everything but "return" */
589 if ((query != '\r') && (query != '\n')) return query;
596 /* Actual monsters */
597 if (g_ptr->m_idx && subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)
599 monster_type *m_ptr = &subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
600 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
601 GAME_TEXT m_name[MAX_NLEN];
607 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
608 monster_race_track(m_ptr->ap_r_idx);
609 health_track(subject_ptr, g_ptr->m_idx);
610 handle_stuff(subject_ptr);
621 /* Recall on screen */
622 screen_roff(m_ptr->ap_r_idx, 0);
624 /* Hack -- Complete the prompt (again) */
625 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
631 /* Normal commands */
632 if (query != 'r') break;
636 /* Cleare recall text and repeat */
642 /* Describe, and prompt for recall */
643 evaluate_monster_exp(acount, m_ptr);
646 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);
648 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);
654 move_cursor_relative(y, x);
658 /* Normal commands */
659 if (query != 'r') break;
664 /* Always stop at "normal" keys */
665 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
667 /* Sometimes stop at "space" key */
668 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
670 /* Change the intro */
671 s1 = _("それは", "It is ");
673 /* Hack -- take account of gender */
674 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
675 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
677 /* Use a preposition */
686 /* Scan all objects being carried */
687 for (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(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(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);
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 (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(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 ");
881 /* Feature code (applying "mimic" field) */
882 feat = get_feat_mimic(g_ptr);
884 /* Require knowledge about grid, or ability to see grid */
885 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(subject_ptr, y, x))
891 f_ptr = &f_info[feat];
893 /* Terrain feature if needed */
894 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
898 /* Hack -- special handling for quest entrances */
899 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
901 /* Set the quest number temporary */
902 IDX old_quest = subject_ptr->current_floor_ptr->inside_quest;
906 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
909 subject_ptr->current_floor_ptr->inside_quest = g_ptr->special;
911 /* Get the quest text */
912 init_flags = INIT_NAME_ONLY;
914 process_dungeon_file(subject_ptr, "q_info.txt", 0, 0, 0, 0);
916 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
917 quest[g_ptr->special].name, quest[g_ptr->special].level);
919 /* Reset the old quest number */
920 subject_ptr->current_floor_ptr->inside_quest = old_quest;
923 /* Hack -- special handling for building doors */
924 else if (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena)
926 name = building[f_ptr->subtype].name;
928 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
930 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
932 else if (have_flag(f_ptr->flags, FF_TOWN))
934 name = town_info[g_ptr->special].name;
936 else if (subject_ptr->wild_mode && (feat == feat_floor))
938 name = _("道", "road");
942 name = f_name + f_ptr->name;
948 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
949 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
950 have_flag(f_ptr->flags, FF_TOWN)))
955 /* Hack -- special introduction for store & building doors -KMW- */
956 if (have_flag(f_ptr->flags, FF_STORE) ||
957 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
958 (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena) ||
959 have_flag(f_ptr->flags, FF_ENTRANCE))
964 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
965 have_flag(f_ptr->flags, FF_TOWN) ||
966 have_flag(f_ptr->flags, FF_SHALLOW) ||
967 have_flag(f_ptr->flags, FF_DEEP))
973 /* Pick proper indefinite article */
974 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
978 /* Display a message */
979 if (current_world_ptr->wizard)
982 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
983 else sprintf(f_idx_str, "%d", g_ptr->feat);
985 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]);
987 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);
992 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
994 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
998 move_cursor_relative(y, x);
1001 /* Always stop at "normal" keys */
1002 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1005 /* Stop on everything but "return" */
1006 if ((query != '\r') && (query != '\n')) return query;
1008 /* Repeat forever */
1014 * Handle "target" and "look".
1016 * Note that this code can be called from "get_aim_dir()".
1018 * All locations must be on the current panel. Consider the use of
1019 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1020 * some form of "scrolling" the map around the cursor.
1021 * That is, consider the possibility of "auto-scrolling" the screen
1022 * while the cursor moves around. This may require changes in the
1023 * "update_monster()" code to allow "visibility" even if off panel, and
1024 * may require dynamic recalculation of the "temp" grid set.
1026 * Hack -- targeting/observing an "outer border grid" may induce
1027 * problems, so this is not currently allowed.
1029 * The player can use the direction keys to move among "interesting"
1030 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1031 * move through the "interesting" grids in a sequential manner, or
1032 * can enter "location" mode, and use the direction keys to move one
1033 * grid at a time in any direction. The "t" (set target) command will
1034 * only target a monster (as opposed to a location) if the monster is
1035 * target_able and the "interesting" mode is being used.
1037 * The current grid is described using the "look" method above, and
1038 * a new command may be entered at any time, but note that if the
1039 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1040 * where "space" has no obvious meaning) then "space" will scan
1041 * through the description of the current grid until done, instead
1042 * of immediately jumping to the next "interesting" grid. This
1043 * allows the "target" command to retain its old semantics.
1045 * The "*", "+", and "-" keys may always be used to jump immediately
1046 * to the next (or previous) interesting grid, in the proper mode.
1048 * The "return" key may always be used to scan through a complete
1049 * grid description (forever).
1051 * This command will cancel any old target, even if used from
1052 * inside the "look" command.
1054 bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
1057 POSITION y = creature_ptr->y;
1058 POSITION x = creature_ptr->x;
1068 get_screen_size(&wid, &hgt);
1073 if (rogue_like_commands)
1082 /* Prepare the "temp" array */
1083 target_set_prepare(mode);
1085 /* Start near the player */
1089 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1092 /* Interesting grids */
1093 if (flag && tmp_pos.n)
1099 change_panel_xy(creature_ptr, y, x);
1101 if (!(mode & TARGET_LOOK)) print_path(floor_ptr, y, x);
1104 g_ptr = &floor_ptr->grid_array[y][x];
1107 if (target_able(g_ptr->m_idx))
1109 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1112 /* Dis-allow target */
1115 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1121 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1122 los(floor_ptr, creature_ptr->y, creature_ptr->x, y, x), projectable(floor_ptr, creature_ptr->y, creature_ptr->x, y, x));
1123 strcat(info, cheatinfo);
1126 /* Describe and Prompt */
1129 query = target_set_aux(creature_ptr, y, x, mode, info);
1133 /* Assume no "direction" */
1138 if (query == '\r') query = 't';
1156 if (target_able(g_ptr->m_idx))
1158 health_track(creature_ptr, g_ptr->m_idx);
1159 target_who = g_ptr->m_idx;
1175 if (++m == tmp_pos.n)
1178 if (!expand_list) done = TRUE;
1188 if (!expand_list) done = TRUE;
1195 /* Recenter the map around the player */
1197 creature_ptr->update |= (PU_MONSTERS);
1198 creature_ptr->redraw |= (PR_MAP);
1199 creature_ptr->window |= (PW_OVERHEAD);
1200 handle_stuff(creature_ptr);
1202 /* Recalculate interesting grids */
1203 target_set_prepare(mode);
1205 y = creature_ptr->y;
1206 x = creature_ptr->x;
1222 if(query == same_key)
1224 if (++m == tmp_pos.n)
1227 if (!expand_list) done = TRUE;
1232 /* Extract the action (if any) */
1233 d = get_keymap_dir(query);
1240 /* Hack -- move around */
1243 /* Modified to scroll to monster */
1244 POSITION y2 = panel_row_min;
1245 POSITION x2 = panel_col_min;
1247 /* Find a new monster */
1248 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1250 /* Request to target past last interesting grid */
1251 while (flag && (i < 0))
1253 /* Note the change */
1254 if (change_panel(creature_ptr, ddy[d], ddx[d]))
1256 int v = tmp_pos.y[m];
1257 int u = tmp_pos.x[m];
1259 /* Recalculate interesting grids */
1260 target_set_prepare(mode);
1262 /* Look at interesting grids */
1265 /* Find a new monster */
1266 i = target_pick(v, u, ddy[d], ddx[d]);
1272 /* Nothing interesting */
1275 POSITION dx = ddx[d];
1276 POSITION dy = ddy[d];
1278 /* Restore previous position */
1281 panel_bounds_center();
1283 creature_ptr->update |= (PU_MONSTERS);
1284 creature_ptr->redraw |= (PR_MAP);
1285 creature_ptr->window |= (PW_OVERHEAD);
1286 handle_stuff(creature_ptr);
1288 /* Recalculate interesting grids */
1289 target_set_prepare(mode);
1291 /* Look at boring grids */
1298 /* Do not move horizontally if unnecessary */
1299 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1300 ((x > panel_col_min + wid / 2) && (dx < 0)))
1305 /* Do not move vertically if unnecessary */
1306 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1307 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1312 /* Apply the motion */
1313 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1314 (x >= panel_col_min+wid) || (x < panel_col_min))
1316 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(mode);
1319 /* Slide into legality */
1320 if (x >= floor_ptr->width-1) x = floor_ptr->width - 2;
1321 else if (x <= 0) x = 1;
1323 /* Slide into legality */
1324 if (y >= floor_ptr->height-1) y = floor_ptr->height- 2;
1325 else if (y <= 0) y = 1;
1334 /* Arbitrary grids */
1337 bool move_fast = FALSE;
1339 if (!(mode & TARGET_LOOK)) print_path(floor_ptr, y, x);
1342 g_ptr = &floor_ptr->grid_array[y][x];
1344 /* Default prompt */
1345 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1349 char cheatinfo[100];
1350 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d",
1351 los(floor_ptr, creature_ptr->y, creature_ptr->x, y, x),
1352 projectable(floor_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special);
1353 strcat(info, cheatinfo);
1356 /* Describe and Prompt (enable "TARGET_LOOK") */
1357 while ((query = target_set_aux(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0);
1359 /* Assume no direction */
1364 if (query == '\r') query = 't';
1367 /* Analyze the keypress */
1391 /* Recenter the map around the player */
1393 creature_ptr->update |= (PU_MONSTERS);
1394 creature_ptr->redraw |= (PR_MAP);
1395 creature_ptr->window |= (PW_OVERHEAD);
1396 handle_stuff(creature_ptr);
1398 /* Recalculate interesting grids */
1399 target_set_prepare(mode);
1401 y = creature_ptr->y;
1402 x = creature_ptr->x;
1421 /* Pick a nearby monster */
1422 for (i = 0; i < tmp_pos.n; i++)
1424 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1434 /* Nothing interesting */
1435 if (bd == 999) flag = FALSE;
1442 /* Extract the action (if any) */
1443 d = get_keymap_dir(query);
1445 /* XTRA HACK MOVEFAST */
1446 if (isupper(query)) move_fast = TRUE;
1453 /* Handle "direction" */
1456 POSITION dx = ddx[d];
1457 POSITION dy = ddy[d];
1459 /* XTRA HACK MOVEFAST */
1462 int mag = MIN(wid / 2, hgt / 2);
1472 /* Do not move horizontally if unnecessary */
1473 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1474 ((x > panel_col_min + wid / 2) && (dx < 0)))
1479 /* Do not move vertically if unnecessary */
1480 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1481 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1486 /* Apply the motion */
1487 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1488 (x >= panel_col_min + wid) || (x < panel_col_min))
1490 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(mode);
1493 /* Slide into legality */
1494 if (x >= floor_ptr->width-1) x = floor_ptr->width - 2;
1495 else if (x <= 0) x = 1;
1497 /* Slide into legality */
1498 if (y >= floor_ptr->height-1) y = floor_ptr->height- 2;
1499 else if (y <= 0) y = 1;
1507 /* Clear the top line */
1510 /* Recenter the map around the player */
1512 creature_ptr->update |= (PU_MONSTERS);
1513 creature_ptr->redraw |= (PR_MAP);
1514 creature_ptr->window |= (PW_OVERHEAD);
1515 handle_stuff(creature_ptr);
1517 if (!target_who) return FALSE;
1524 * Get an "aiming direction" from the user.
1526 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1527 * "0" for "current target", and "-1" for "entry aborted".
1529 * Note that "Force Target", if set, will pre-empt user interaction,
1530 * if there is a usable target already set.
1532 * Note that confusion over-rides any (explicit?) user choice.
1534 bool get_aim_dir(DIRECTION *dp)
1543 /* Global direction */
1546 /* Hack -- auto-target if requested */
1547 if (use_old_target && target_okay()) dir = 5;
1549 if (repeat_pull(&code))
1554 if (!(code == 5 && !target_okay()))
1557 dir = (DIRECTION)code;
1560 *dp = (DIRECTION)code;
1562 /* Ask until satisfied */
1565 /* Choose a prompt */
1568 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1572 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1575 /* Get a command (or Cancel) */
1576 if (!get_com(p, &command, TRUE)) break;
1580 if (command == '\r') command = 't';
1583 /* Convert various keys to "standard" keys */
1586 /* Use current target */
1597 /* Set new target */
1602 if (target_set(p_ptr, TARGET_KILL)) dir = 5;
1608 /* Extract the action (if any) */
1609 dir = get_keymap_dir(command);
1615 /* Verify requested targets */
1616 if ((dir == 5) && !target_okay()) dir = 0;
1625 project_length = 0; /* reset to default */
1629 /* Save the direction */
1632 /* Check for confusion */
1633 if (p_ptr->confused)
1635 /* Random direction */
1636 dir = ddd[randint0(8)];
1639 /* Notice confusion */
1640 if (command_dir != dir)
1643 msg_print(_("あなたは混乱している。", "You are confused."));
1646 /* Save direction */
1649 /* repeat_push(dir); */
1650 repeat_push((COMMAND_CODE)command_dir);
1652 /* A "valid" direction was entered */
1657 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed)
1665 /* Global direction */
1668 if (repeat_pull(&code))
1670 dir = (DIRECTION)code;
1673 *dp = (DIRECTION)code;
1677 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1681 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1684 /* Get a direction */
1689 /* Get a command (or Cancel) */
1690 if (!get_com(prompt, &ch, TRUE)) break;
1693 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1699 /* Look up the direction */
1700 dir = get_keymap_dir(ch);
1706 /* Prevent weirdness */
1707 if ((dir == 5) && (!allow_under)) dir = 0;
1710 if (!dir) return FALSE;
1712 /* Save desired direction */
1715 /* Apply "confusion" */
1716 if (creature_ptr->confused)
1718 /* Standard confusion */
1719 if (randint0(100) < 75)
1721 /* Random direction */
1722 dir = ddd[randint0(8)];
1725 else if (creature_ptr->riding && with_steed)
1727 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1728 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1730 if (MON_CONFUSED(m_ptr))
1732 /* Standard confusion */
1733 if (randint0(100) < 75)
1735 /* Random direction */
1736 dir = ddd[randint0(8)];
1739 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1741 /* Random direction */
1742 dir = ddd[randint0(8)];
1744 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1746 /* Random direction */
1747 dir = ddd[randint0(8)];
1751 /* Notice confusion */
1752 if (command_dir != dir)
1754 if (creature_ptr->confused)
1757 msg_print(_("あなたは混乱している。", "You are confused."));
1761 GAME_TEXT m_name[MAX_NLEN];
1762 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1764 monster_desc(m_name, m_ptr, 0);
1765 if (MON_CONFUSED(m_ptr))
1767 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1771 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1776 /* Save direction */
1779 /* repeat_push(dir); */
1780 repeat_push((COMMAND_CODE)command_dir);
1787 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1788 * and place it into "command_dir", unless we already have one.
1790 * This function should be used for all "repeatable" commands, such as
1791 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1792 * as all commands which must reference a grid adjacent to the player,
1793 * and which may not reference the grid under the player. Note that,
1794 * for example, it is no longer possible to "disarm" or "open" chests
1795 * in the same grid as the player.
1797 * Direction "5" is illegal and will (cleanly) abort the command.
1799 * This function tracks and uses the "global direction", and uses
1800 * that as the "desired direction", to which "confusion" is applied.
1802 bool get_rep_dir(DIRECTION *dp, bool under)
1810 /* Global direction */
1813 if (repeat_pull(&code))
1815 dir = (DIRECTION)code;
1818 *dp = (DIRECTION)code;
1822 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1826 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1829 /* Get a direction */
1834 /* Get a command (or Cancel) */
1835 if (!get_com(prompt, &ch, TRUE)) break;
1838 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1844 /* Look up the direction */
1845 dir = get_keymap_dir(ch);
1851 /* Prevent weirdness */
1852 if ((dir == 5) && (!under)) dir = 0;
1855 if (!dir) return FALSE;
1857 /* Save desired direction */
1860 /* Apply "confusion" */
1861 if (p_ptr->confused)
1863 /* Standard confusion */
1864 if (randint0(100) < 75)
1866 /* Random direction */
1867 dir = ddd[randint0(8)];
1870 else if (p_ptr->riding)
1872 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding];
1873 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1875 if (MON_CONFUSED(m_ptr))
1877 /* Standard confusion */
1878 if (randint0(100) < 75)
1880 /* Random direction */
1881 dir = ddd[randint0(8)];
1884 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1886 /* Random direction */
1887 dir = ddd[randint0(8)];
1889 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1891 /* Random direction */
1892 dir = ddd[randint0(8)];
1896 /* Notice confusion */
1897 if (command_dir != dir)
1899 if (p_ptr->confused)
1902 msg_print(_("あなたは混乱している。", "You are confused."));
1906 GAME_TEXT m_name[MAX_NLEN];
1907 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding];
1909 monster_desc(m_name, m_ptr, 0);
1910 if (MON_CONFUSED(m_ptr))
1912 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1916 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1921 /* Save direction */
1924 /* repeat_push(dir); */
1925 repeat_push((COMMAND_CODE)command_dir);
1933 * XAngband: determine if a given location is "interesting"
1934 * based on target_set_accept function.
1936 static bool tgt_pt_accept(POSITION y, POSITION x)
1940 if (!(in_bounds(p_ptr->current_floor_ptr, y, x))) return FALSE;
1942 /* Player grid is always interesting */
1943 if ((y == p_ptr->y) && (x == p_ptr->x)) return TRUE;
1945 if (p_ptr->image) return FALSE;
1947 g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
1949 /* Interesting memorized features */
1950 if (g_ptr->info & (CAVE_MARK))
1953 if (cave_have_flag_grid(g_ptr, FF_LESS)) return TRUE;
1954 if (cave_have_flag_grid(g_ptr, FF_MORE)) return TRUE;
1956 /* Notice quest features */
1957 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return TRUE;
1958 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return TRUE;
1966 * XAngband: Prepare the "temp" array for "tget_pt"
1967 * based on target_set_prepare funciton.
1969 static void tgt_pt_prepare(void)
1973 /* Reset "temp" array */
1976 if (!expand_list) return;
1978 /* Scan the current panel */
1979 for (y = 1; y < p_ptr->current_floor_ptr->height; y++)
1981 for (x = 1; x < p_ptr->current_floor_ptr->width; x++)
1983 /* Require "interesting" contents */
1984 if (!tgt_pt_accept(y, x)) continue;
1986 /* Save the location */
1987 tmp_pos.x[tmp_pos.n] = x;
1988 tmp_pos.y[tmp_pos.n] = y;
1993 /* Sort the positions */
1994 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
1998 * old -- from PsiAngband.
2000 bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr)
2005 bool success = FALSE;
2009 get_screen_size(&wid, &hgt);
2011 x = creature_ptr->x;
2012 y = creature_ptr->y;
2019 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2020 msg_flag = FALSE; /* prevents "-more-" message. */
2022 while ((ch != ESCAPE) && !success)
2024 bool move_fast = FALSE;
2026 move_cursor_relative(y, x);
2038 if (player_bold(creature_ptr, y, x)) ch = 0;
2041 else success = TRUE;
2045 /* XAngband: Move cursor to stairs */
2048 if (expand_list && tmp_pos.n)
2051 int cx = (panel_col_min + panel_col_max) / 2;
2052 int cy = (panel_row_min + panel_row_max) / 2;
2056 /* Skip stairs which have defferent distance */
2057 for (; n < tmp_pos.n; ++ n)
2059 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2061 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2062 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2069 if (n == tmp_pos.n) /* Loop out taget list */
2072 y = creature_ptr->y;
2073 x = creature_ptr->x;
2074 verify_panel(); /* Move cursor to player */
2076 creature_ptr->update |= (PU_MONSTERS);
2078 creature_ptr->redraw |= (PR_MAP);
2080 creature_ptr->window |= (PW_OVERHEAD);
2081 handle_stuff(creature_ptr);
2083 else /* move cursor to next stair and change panel */
2088 dy = 2 * (y - cy) / hgt;
2089 dx = 2 * (x - cx) / wid;
2090 if (dy || dx) change_panel(creature_ptr, dy, dx);
2096 /* Look up the direction */
2097 d = get_keymap_dir(ch);
2099 /* XTRA HACK MOVEFAST */
2100 if (isupper(ch)) move_fast = TRUE;
2102 /* Handle "direction" */
2108 /* XTRA HACK MOVEFAST */
2111 int mag = MIN(wid / 2, hgt / 2);
2121 /* Do not move horizontally if unnecessary */
2122 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2123 ((x > panel_col_min + wid / 2) && (dx < 0)))
2128 /* Do not move vertically if unnecessary */
2129 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2130 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2135 /* Apply the motion */
2136 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2137 (x >= panel_col_min + wid) || (x < panel_col_min))
2139 change_panel(creature_ptr, dy, dx);
2142 /* Slide into legality */
2143 if (x >= creature_ptr->current_floor_ptr->width-1) x = creature_ptr->current_floor_ptr->width - 2;
2144 else if (x <= 0) x = 1;
2146 /* Slide into legality */
2147 if (y >= creature_ptr->current_floor_ptr->height-1) y = creature_ptr->current_floor_ptr->height- 2;
2148 else if (y <= 0) y = 1;
2155 /* Clear the top line */
2158 /* Recenter the map around the player */
2161 creature_ptr->update |= (PU_MONSTERS);
2163 creature_ptr->redraw |= (PR_MAP);
2165 creature_ptr->window |= (PW_OVERHEAD);
2166 handle_stuff(creature_ptr);
2174 bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
2182 /* Global direction */
2185 /* (No auto-targeting) */
2187 /* Ask until satisfied */
2190 /* Choose a prompt */
2193 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2197 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2200 /* Get a command (or Cancel) */
2201 if (!get_com(p, &command, TRUE)) break;
2205 if (command == '\r') command = 't';
2208 /* Convert various keys to "standard" keys */
2211 /* Use current target */
2222 /* Set new target */
2227 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
2233 /* Look up the direction */
2234 dir = get_keymap_dir(command);
2240 /* Verify requested targets */
2241 if ((dir == 5) && !target_okay()) dir = 0;
2248 if (!dir) return FALSE;
2250 /* Save the direction */
2253 /* Check for confusion */
2254 if (p_ptr->confused)
2256 /* Random direction */
2257 dir = ddd[randint0(8)];
2260 /* Notice confusion */
2261 if (command_dir != dir)
2264 msg_print(_("あなたは混乱している。", "You are confused."));
2267 /* Save direction */
2270 /* A "valid" direction was entered */