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 マップ描画のフォーカスを当てるべき座標を更新する
92 * @param creature_ptr プレーヤーへの参照ポインタ
94 * Given an row (y) and col (x), this routine detects when a move
95 * off the screen has occurred and figures new borders. -RAK-
96 * "Update" forces a "full update" to take place.
97 * The map is reprinted if necessary, and "TRUE" is returned.
98 * @return 実際に再描画が必要だった場合TRUEを返す
100 void verify_panel(player_type *creature_ptr)
102 POSITION y = creature_ptr->y;
103 POSITION x = creature_ptr->x;
111 get_screen_size(&wid, &hgt);
113 max_prow_min = creature_ptr->current_floor_ptr->height - hgt;
114 max_pcol_min = creature_ptr->current_floor_ptr->width - wid;
116 /* Bounds checking */
117 if (max_prow_min < 0) max_prow_min = 0;
118 if (max_pcol_min < 0) max_pcol_min = 0;
120 /* Center on player */
121 if (center_player && (center_running || !creature_ptr->running))
123 /* Center vertically */
124 prow_min = y - hgt / 2;
125 if (prow_min < 0) prow_min = 0;
126 else if (prow_min > max_prow_min) prow_min = max_prow_min;
128 /* Center horizontally */
129 pcol_min = x - wid / 2;
130 if (pcol_min < 0) pcol_min = 0;
131 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
135 prow_min = panel_row_min;
136 pcol_min = panel_col_min;
138 /* Scroll screen when 2 grids from top/bottom edge */
139 if (y > panel_row_max - 2)
141 while (y > prow_min + hgt-1 - 2)
143 prow_min += (hgt / 2);
147 if (y < panel_row_min + 2)
149 while (y < prow_min + 2)
151 prow_min -= (hgt / 2);
155 if (prow_min > max_prow_min) prow_min = max_prow_min;
156 if (prow_min < 0) prow_min = 0;
158 /* Scroll screen when 4 grids from left/right edge */
159 if (x > panel_col_max - 4)
161 while (x > pcol_min + wid-1 - 4)
163 pcol_min += (wid / 2);
167 if (x < panel_col_min + 4)
169 while (x < pcol_min + 4)
171 pcol_min -= (wid / 2);
175 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
176 if (pcol_min < 0) pcol_min = 0;
179 /* Check for "no change" */
180 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
182 /* Save the new panel info */
183 panel_row_min = prow_min;
184 panel_col_min = pcol_min;
186 /* Hack -- optional disturb on "panel change" */
187 if (disturb_panel && !center_player) disturb(creature_ptr, FALSE, FALSE);
189 panel_bounds_center();
191 creature_ptr->update |= (PU_MONSTERS);
192 creature_ptr->redraw |= (PR_MAP);
193 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
197 /*** Targeting Code ***/
200 * Determine is a monster makes a reasonable target
202 * The concept of "targeting" was stolen from "Morgul" (?)
204 * The player can target any location, or any "target-able" monster.
206 * Currently, a monster is "target_able" if it is visible, and if
207 * the player can hit it with a projection, and the player is not
208 * hallucinating. This allows use of "use closest target" macros.
210 * Future versions may restrict the ability to target "trappers"
211 * and "mimics", but the semantics is a little bit weird.
213 bool target_able(player_type *creature_ptr, MONSTER_IDX m_idx)
215 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
216 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
218 /* Monster must be alive */
219 if (!monster_is_valid(m_ptr)) return FALSE;
221 /* Hack -- no targeting hallucinations */
222 if (creature_ptr->image) return FALSE;
224 /* Monster must be visible */
225 if (!m_ptr->ml) return FALSE;
227 if (creature_ptr->riding && (creature_ptr->riding == m_idx)) return TRUE;
229 /* Monster must be projectable */
230 if (!projectable(creature_ptr, creature_ptr->y, creature_ptr->x, m_ptr->fy, m_ptr->fx)) return FALSE;
232 /* Hack -- Never target trappers */
233 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return FALSE; */
241 * Targetting variables
243 MONSTER_IDX target_who;
248 * Update (if necessary) and verify (if possible) the target.
250 * We return TRUE if the target is "okay" and FALSE otherwise.
252 bool target_okay(player_type *creature_ptr)
254 /* Accept stationary targets */
255 if (target_who < 0) return TRUE;
257 /* Check moving targets */
260 /* Accept reasonable targets */
261 if (target_able(creature_ptr, target_who))
263 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[target_who];
265 /* Acquire monster location */
266 target_row = m_ptr->fy;
267 target_col = m_ptr->fx;
274 /* Assume no target */
280 * Hack -- help "select" a location (see below)
282 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
285 POSITION x2, y2, x3, y3, x4, y4;
286 POSITION_IDX b_i = -1, b_v = 9999;
289 /* Scan the locations */
290 for (i = 0; i < tmp_pos.n; i++)
296 /* Directed distance */
300 /* Verify quadrant */
301 if (dx && (x3 * dx <= 0)) continue;
302 if (dy && (y3 * dy <= 0)) continue;
307 /* Verify quadrant */
308 if (dy && !dx && (x4 > y4)) continue;
309 if (dx && !dy && (y4 > x4)) continue;
311 /* Approximate Double Distance */
312 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
314 /* Penalize location */
315 if ((b_i >= 0) && (v >= b_v)) continue;
323 * Hack -- determine if a given location is "interesting"
325 static bool target_set_accept(player_type *creature_ptr, POSITION y, POSITION x)
328 OBJECT_IDX this_o_idx, next_o_idx = 0;
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;
338 g_ptr = &floor_ptr->grid_array[y][x];
340 /* Visible monsters */
343 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
345 /* Visible monsters */
346 if (m_ptr->ml) return TRUE;
349 /* Scan all objects in the grid */
350 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
353 o_ptr = &floor_ptr->o_list[this_o_idx];
354 next_o_idx = o_ptr->next_o_idx;
356 /* Memorized object */
357 if (o_ptr->marked & OM_FOUND) return TRUE;
360 /* Interesting memorized features */
361 if (g_ptr->info & (CAVE_MARK))
363 /* Notice object features */
364 if (g_ptr->info & CAVE_OBJECT) return TRUE;
366 /* Feature code (applying "mimic" field) */
367 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
375 * Prepare the "temp" array for "target_set"
377 * Return the number of target_able monsters in the set.
379 static void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
382 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 (y = min_hgt; y <= max_hgt; y++)
407 for (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 && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
443 tmp_pos.y[0] = tmp_pos.y[1];
446 tmp_pos.x[0] = tmp_pos.x[1];
451 void target_set_prepare_look(player_type *creature_ptr)
453 target_set_prepare(creature_ptr, TARGET_LOOK);
458 * Evaluate number of kill needed to gain level
460 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
462 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
464 s32b exp_mon, exp_adv;
465 u32b exp_mon_frac, exp_adv_frac;
467 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
472 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
474 if (!current_world_ptr->wizard)
482 /* The monster's experience point (assuming average monster speed) */
483 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
485 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
488 /* Total experience value for next level */
489 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
491 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
493 /* Experience value need to get */
494 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
497 /* You need to kill at least one monster to get any experience */
498 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
499 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
501 /* Extract number of monsters needed */
502 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
504 /* If 999 or more monsters needed, only display "999". */
505 num = MIN(999, exp_adv_frac);
507 /* Display the number */
508 sprintf(buf,"%03ld", (long int)num);
512 bool show_gold_on_floor = FALSE;
515 * Examine a grid, return a keypress.
517 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
518 * indicates that the "space" key should scan through the contents
519 * of the grid, instead of simply returning immediately. This lets
520 * the "look" command get complete information, without making the
521 * "target" command annoying.
523 * The "info" argument contains the "commands" which should be shown
524 * inside the "[xxx]" text. This string must never be empty, or grids
525 * containing monsters will be displayed with an extra comma.
527 * Note that if a monster is in the grid, we update both the monster
528 * recall info and the health bar info to track that monster.
530 * Eventually, we may allow multiple objects per grid, or objects
531 * and terrain features in the same grid.
533 * This function must handle blindness/hallucination.
535 static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
537 grid_type *g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
538 OBJECT_IDX this_o_idx, next_o_idx = 0;
539 concptr s1 = "", s2 = "", s3 = "", x_info = "";
544 char out_val[MAX_NLEN+80];
545 OBJECT_IDX floor_list[23];
546 ITEM_NUMBER floor_num = 0;
548 /* Scan all objects in the grid */
551 floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02);
555 x_info = _("x物 ", "x,");
559 /* Hack -- under the player */
560 if (player_bold(subject_ptr, y, x))
573 s1 = _("ターゲット:", "Target:");
576 /* Hack -- hallucination */
577 if (subject_ptr->image)
579 concptr name = _("何か奇妙な物", "something strange");
581 /* Display a message */
583 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
585 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
589 move_cursor_relative(y, x);
592 /* Stop on everything but "return" */
593 if ((query != '\r') && (query != '\n')) return query;
600 /* Actual monsters */
601 if (g_ptr->m_idx && subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)
603 monster_type *m_ptr = &subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
604 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
605 GAME_TEXT m_name[MAX_NLEN];
611 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
612 monster_race_track(subject_ptr, m_ptr->ap_r_idx);
613 health_track(subject_ptr, g_ptr->m_idx);
614 handle_stuff(subject_ptr);
625 /* Recall on screen */
626 screen_roff(m_ptr->ap_r_idx, 0);
628 /* Hack -- Complete the prompt (again) */
629 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
635 /* Normal commands */
636 if (query != 'r') break;
640 /* Cleare recall text and repeat */
646 /* Describe, and prompt for recall */
647 evaluate_monster_exp(acount, m_ptr);
650 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);
652 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);
658 move_cursor_relative(y, x);
662 /* Normal commands */
663 if (query != 'r') break;
668 /* Always stop at "normal" keys */
669 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
671 /* Sometimes stop at "space" key */
672 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
674 /* Change the intro */
675 s1 = _("それは", "It is ");
677 /* Hack -- take account of gender */
678 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
679 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
681 /* Use a preposition */
690 /* Scan all objects being carried */
691 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
693 GAME_TEXT o_name[MAX_NLEN];
696 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
697 next_o_idx = o_ptr->next_o_idx;
699 object_desc(o_name, o_ptr, 0);
702 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
704 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
708 move_cursor_relative(y, x);
711 /* Always stop at "normal" keys */
712 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
714 /* Sometimes stop at "space" key */
715 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
717 /* Change the intro */
718 s2 = _("をまた", "also carrying ");
721 /* Use a preposition */
738 GAME_TEXT o_name[MAX_NLEN];
741 o_ptr = &subject_ptr->current_floor_ptr->o_list[floor_list[0]];
743 object_desc(o_name, o_ptr, 0);
746 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
748 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
752 move_cursor_relative(y, x);
760 /* Provide one cushion before item listing */
763 /* Display rough information about items */
765 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
767 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
771 move_cursor_relative(y, x);
775 /* No request for listing */
776 if (query != 'x' && query != ' ') return query;
780 /** Display list of items **/
782 /* Continue scrolling list if requested */
790 show_gold_on_floor = TRUE;
791 (void)show_floor(subject_ptr, 0, y, x, &min_width);
792 show_gold_on_floor = FALSE;
796 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
798 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
805 /* Exit unless 'Enter' */
806 if (query != '\n' && query != '\r')
811 /* Get the object being moved. */
812 o_idx = g_ptr->o_idx;
814 /* Only rotate a pile of two or more objects. */
815 if (!(o_idx && subject_ptr->current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
817 /* Remove the first object from the list. */
818 excise_object_idx(subject_ptr->current_floor_ptr, o_idx);
820 /* Find end of the list. */
822 while (subject_ptr->current_floor_ptr->o_list[i].next_o_idx)
823 i = subject_ptr->current_floor_ptr->o_list[i].next_o_idx;
825 /* Add after the last object. */
826 subject_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
828 /* Loop and re-display the list */
835 /* Scan all objects in the grid */
836 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
839 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
840 next_o_idx = o_ptr->next_o_idx;
842 if (o_ptr->marked & OM_FOUND)
844 GAME_TEXT o_name[MAX_NLEN];
849 object_desc(o_name, o_ptr, 0);
852 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
854 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
858 move_cursor_relative(y, x);
861 /* Always stop at "normal" keys */
862 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
864 /* Sometimes stop at "space" key */
865 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
867 /* Change the intro */
868 s1 = _("それは", "It is ");
871 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
885 /* Feature code (applying "mimic" field) */
886 feat = get_feat_mimic(g_ptr);
888 /* Require knowledge about grid, or ability to see grid */
889 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(subject_ptr, y, x))
895 f_ptr = &f_info[feat];
897 /* Terrain feature if needed */
898 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
902 /* Hack -- special handling for quest entrances */
903 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
905 /* Set the quest number temporary */
906 IDX old_quest = subject_ptr->current_floor_ptr->inside_quest;
910 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
913 subject_ptr->current_floor_ptr->inside_quest = g_ptr->special;
915 /* Get the quest text */
916 init_flags = INIT_NAME_ONLY;
918 process_dungeon_file(subject_ptr, "q_info.txt", 0, 0, 0, 0);
920 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
921 quest[g_ptr->special].name, quest[g_ptr->special].level);
923 /* Reset the old quest number */
924 subject_ptr->current_floor_ptr->inside_quest = old_quest;
927 /* Hack -- special handling for building doors */
928 else if (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena)
930 name = building[f_ptr->subtype].name;
932 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
934 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
936 else if (have_flag(f_ptr->flags, FF_TOWN))
938 name = town_info[g_ptr->special].name;
940 else if (subject_ptr->wild_mode && (feat == feat_floor))
942 name = _("道", "road");
946 name = f_name + f_ptr->name;
952 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
953 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
954 have_flag(f_ptr->flags, FF_TOWN)))
959 /* Hack -- special introduction for store & building doors -KMW- */
960 if (have_flag(f_ptr->flags, FF_STORE) ||
961 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
962 (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena) ||
963 have_flag(f_ptr->flags, FF_ENTRANCE))
968 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
969 have_flag(f_ptr->flags, FF_TOWN) ||
970 have_flag(f_ptr->flags, FF_SHALLOW) ||
971 have_flag(f_ptr->flags, FF_DEEP))
977 /* Pick proper indefinite article */
978 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
982 /* Display a message */
983 if (current_world_ptr->wizard)
986 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
987 else sprintf(f_idx_str, "%d", g_ptr->feat);
989 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]);
991 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);
996 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
998 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1002 move_cursor_relative(y, x);
1005 /* Always stop at "normal" keys */
1006 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1009 /* Stop on everything but "return" */
1010 if ((query != '\r') && (query != '\n')) return query;
1012 /* Repeat forever */
1018 * Handle "target" and "look".
1020 * Note that this code can be called from "get_aim_dir()".
1022 * All locations must be on the current panel. Consider the use of
1023 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1024 * some form of "scrolling" the map around the cursor.
1025 * That is, consider the possibility of "auto-scrolling" the screen
1026 * while the cursor moves around. This may require changes in the
1027 * "update_monster()" code to allow "visibility" even if off panel, and
1028 * may require dynamic recalculation of the "temp" grid set.
1030 * Hack -- targeting/observing an "outer border grid" may induce
1031 * problems, so this is not currently allowed.
1033 * The player can use the direction keys to move among "interesting"
1034 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1035 * move through the "interesting" grids in a sequential manner, or
1036 * can enter "location" mode, and use the direction keys to move one
1037 * grid at a time in any direction. The "t" (set target) command will
1038 * only target a monster (as opposed to a location) if the monster is
1039 * target_able and the "interesting" mode is being used.
1041 * The current grid is described using the "look" method above, and
1042 * a new command may be entered at any time, but note that if the
1043 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1044 * where "space" has no obvious meaning) then "space" will scan
1045 * through the description of the current grid until done, instead
1046 * of immediately jumping to the next "interesting" grid. This
1047 * allows the "target" command to retain its old semantics.
1049 * The "*", "+", and "-" keys may always be used to jump immediately
1050 * to the next (or previous) interesting grid, in the proper mode.
1052 * The "return" key may always be used to scan through a complete
1053 * grid description (forever).
1055 * This command will cancel any old target, even if used from
1056 * inside the "look" command.
1058 bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
1061 POSITION y = creature_ptr->y;
1062 POSITION x = creature_ptr->x;
1072 get_screen_size(&wid, &hgt);
1077 if (rogue_like_commands)
1086 /* Prepare the "temp" array */
1087 target_set_prepare(creature_ptr, mode);
1089 /* Start near the player */
1093 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1096 /* Interesting grids */
1097 if (flag && tmp_pos.n)
1103 change_panel_xy(creature_ptr, y, x);
1105 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1108 g_ptr = &floor_ptr->grid_array[y][x];
1111 if (target_able(creature_ptr, g_ptr->m_idx))
1113 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1116 /* Dis-allow target */
1119 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1125 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1126 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x));
1127 strcat(info, cheatinfo);
1130 /* Describe and Prompt */
1133 query = target_set_aux(creature_ptr, y, x, mode, info);
1137 /* Assume no "direction" */
1142 if (query == '\r') query = 't';
1160 if (target_able(creature_ptr, g_ptr->m_idx))
1162 health_track(creature_ptr, g_ptr->m_idx);
1163 target_who = g_ptr->m_idx;
1179 if (++m == tmp_pos.n)
1182 if (!expand_list) done = TRUE;
1192 if (!expand_list) done = TRUE;
1199 /* Recenter the map around the player */
1200 verify_panel(creature_ptr);
1201 creature_ptr->update |= (PU_MONSTERS);
1202 creature_ptr->redraw |= (PR_MAP);
1203 creature_ptr->window |= (PW_OVERHEAD);
1204 handle_stuff(creature_ptr);
1206 /* Recalculate interesting grids */
1207 target_set_prepare(creature_ptr, mode);
1209 y = creature_ptr->y;
1210 x = creature_ptr->x;
1226 if(query == same_key)
1228 if (++m == tmp_pos.n)
1231 if (!expand_list) done = TRUE;
1236 /* Extract the action (if any) */
1237 d = get_keymap_dir(query);
1244 /* Hack -- move around */
1247 /* Modified to scroll to monster */
1248 POSITION y2 = panel_row_min;
1249 POSITION x2 = panel_col_min;
1251 /* Find a new monster */
1252 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1254 /* Request to target past last interesting grid */
1255 while (flag && (i < 0))
1257 /* Note the change */
1258 if (change_panel(creature_ptr, ddy[d], ddx[d]))
1260 int v = tmp_pos.y[m];
1261 int u = tmp_pos.x[m];
1263 /* Recalculate interesting grids */
1264 target_set_prepare(creature_ptr, mode);
1266 /* Look at interesting grids */
1269 /* Find a new monster */
1270 i = target_pick(v, u, ddy[d], ddx[d]);
1276 /* Nothing interesting */
1279 POSITION dx = ddx[d];
1280 POSITION dy = ddy[d];
1282 /* Restore previous position */
1285 panel_bounds_center();
1287 creature_ptr->update |= (PU_MONSTERS);
1288 creature_ptr->redraw |= (PR_MAP);
1289 creature_ptr->window |= (PW_OVERHEAD);
1290 handle_stuff(creature_ptr);
1292 /* Recalculate interesting grids */
1293 target_set_prepare(creature_ptr, mode);
1295 /* Look at boring grids */
1302 /* Do not move horizontally if unnecessary */
1303 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1304 ((x > panel_col_min + wid / 2) && (dx < 0)))
1309 /* Do not move vertically if unnecessary */
1310 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1311 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1316 /* Apply the motion */
1317 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1318 (x >= panel_col_min+wid) || (x < panel_col_min))
1320 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1323 /* Slide into legality */
1324 if (x >= floor_ptr->width-1) x = floor_ptr->width - 2;
1325 else if (x <= 0) x = 1;
1327 /* Slide into legality */
1328 if (y >= floor_ptr->height-1) y = floor_ptr->height- 2;
1329 else if (y <= 0) y = 1;
1338 /* Arbitrary grids */
1341 bool move_fast = FALSE;
1343 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1346 g_ptr = &floor_ptr->grid_array[y][x];
1348 /* Default prompt */
1349 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1353 char cheatinfo[100];
1354 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d",
1355 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x),
1356 projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special);
1357 strcat(info, cheatinfo);
1360 /* Describe and Prompt (enable "TARGET_LOOK") */
1361 while ((query = target_set_aux(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0);
1363 /* Assume no direction */
1368 if (query == '\r') query = 't';
1371 /* Analyze the keypress */
1395 /* Recenter the map around the player */
1396 verify_panel(creature_ptr);
1397 creature_ptr->update |= (PU_MONSTERS);
1398 creature_ptr->redraw |= (PR_MAP);
1399 creature_ptr->window |= (PW_OVERHEAD);
1400 handle_stuff(creature_ptr);
1402 /* Recalculate interesting grids */
1403 target_set_prepare(creature_ptr, mode);
1405 y = creature_ptr->y;
1406 x = creature_ptr->x;
1425 /* Pick a nearby monster */
1426 for (i = 0; i < tmp_pos.n; i++)
1428 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1438 /* Nothing interesting */
1439 if (bd == 999) flag = FALSE;
1446 /* Extract the action (if any) */
1447 d = get_keymap_dir(query);
1449 /* XTRA HACK MOVEFAST */
1450 if (isupper(query)) move_fast = TRUE;
1457 /* Handle "direction" */
1460 POSITION dx = ddx[d];
1461 POSITION dy = ddy[d];
1463 /* XTRA HACK MOVEFAST */
1466 int mag = MIN(wid / 2, hgt / 2);
1476 /* Do not move horizontally if unnecessary */
1477 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1478 ((x > panel_col_min + wid / 2) && (dx < 0)))
1483 /* Do not move vertically if unnecessary */
1484 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1485 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1490 /* Apply the motion */
1491 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1492 (x >= panel_col_min + wid) || (x < panel_col_min))
1494 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1497 /* Slide into legality */
1498 if (x >= floor_ptr->width-1) x = floor_ptr->width - 2;
1499 else if (x <= 0) x = 1;
1501 /* Slide into legality */
1502 if (y >= floor_ptr->height-1) y = floor_ptr->height- 2;
1503 else if (y <= 0) y = 1;
1511 /* Clear the top line */
1514 /* Recenter the map around the player */
1515 verify_panel(creature_ptr);
1516 creature_ptr->update |= (PU_MONSTERS);
1517 creature_ptr->redraw |= (PR_MAP);
1518 creature_ptr->window |= (PW_OVERHEAD);
1519 handle_stuff(creature_ptr);
1521 if (!target_who) return FALSE;
1528 * Get an "aiming direction" from the user.
1530 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1531 * "0" for "current target", and "-1" for "entry aborted".
1533 * Note that "Force Target", if set, will pre-empt user interaction,
1534 * if there is a usable target already set.
1536 * Note that confusion over-rides any (explicit?) user choice.
1538 bool get_aim_dir(player_type *creature_ptr, DIRECTION *dp)
1547 /* Global direction */
1550 /* Hack -- auto-target if requested */
1551 if (use_old_target && target_okay(creature_ptr)) dir = 5;
1553 if (repeat_pull(&code))
1558 if (!(code == 5 && !target_okay(creature_ptr)))
1561 dir = (DIRECTION)code;
1564 *dp = (DIRECTION)code;
1566 /* Ask until satisfied */
1569 /* Choose a prompt */
1570 if (!target_okay(creature_ptr))
1572 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1576 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1579 /* Get a command (or Cancel) */
1580 if (!get_com(p, &command, TRUE)) break;
1584 if (command == '\r') command = 't';
1587 /* Convert various keys to "standard" keys */
1590 /* Use current target */
1601 /* Set new target */
1606 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
1612 /* Extract the action (if any) */
1613 dir = get_keymap_dir(command);
1619 /* Verify requested targets */
1620 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
1629 project_length = 0; /* reset to default */
1633 /* Save the direction */
1636 /* Check for confusion */
1637 if (creature_ptr->confused)
1639 /* Random direction */
1640 dir = ddd[randint0(8)];
1643 /* Notice confusion */
1644 if (command_dir != dir)
1647 msg_print(_("あなたは混乱している。", "You are confused."));
1650 /* Save direction */
1653 /* repeat_push(dir); */
1654 repeat_push((COMMAND_CODE)command_dir);
1656 /* A "valid" direction was entered */
1661 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed)
1669 /* Global direction */
1672 if (repeat_pull(&code))
1674 dir = (DIRECTION)code;
1677 *dp = (DIRECTION)code;
1681 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1685 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1688 /* Get a direction */
1693 /* Get a command (or Cancel) */
1694 if (!get_com(prompt, &ch, TRUE)) break;
1697 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1703 /* Look up the direction */
1704 dir = get_keymap_dir(ch);
1710 /* Prevent weirdness */
1711 if ((dir == 5) && (!allow_under)) dir = 0;
1714 if (!dir) return FALSE;
1716 /* Save desired direction */
1719 /* Apply "confusion" */
1720 if (creature_ptr->confused)
1722 /* Standard confusion */
1723 if (randint0(100) < 75)
1725 /* Random direction */
1726 dir = ddd[randint0(8)];
1729 else if (creature_ptr->riding && with_steed)
1731 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1732 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1734 if (MON_CONFUSED(m_ptr))
1736 /* Standard confusion */
1737 if (randint0(100) < 75)
1739 /* Random direction */
1740 dir = ddd[randint0(8)];
1743 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1745 /* Random direction */
1746 dir = ddd[randint0(8)];
1748 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1750 /* Random direction */
1751 dir = ddd[randint0(8)];
1755 /* Notice confusion */
1756 if (command_dir != dir)
1758 if (creature_ptr->confused)
1761 msg_print(_("あなたは混乱している。", "You are confused."));
1765 GAME_TEXT m_name[MAX_NLEN];
1766 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1768 monster_desc(m_name, m_ptr, 0);
1769 if (MON_CONFUSED(m_ptr))
1771 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1775 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1780 /* Save direction */
1783 /* repeat_push(dir); */
1784 repeat_push((COMMAND_CODE)command_dir);
1791 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1792 * and place it into "command_dir", unless we already have one.
1794 * This function should be used for all "repeatable" commands, such as
1795 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1796 * as all commands which must reference a grid adjacent to the player,
1797 * and which may not reference the grid under the player. Note that,
1798 * for example, it is no longer possible to "disarm" or "open" chests
1799 * in the same grid as the player.
1801 * Direction "5" is illegal and will (cleanly) abort the command.
1803 * This function tracks and uses the "global direction", and uses
1804 * that as the "desired direction", to which "confusion" is applied.
1806 bool get_rep_dir(DIRECTION *dp, bool under)
1814 /* Global direction */
1817 if (repeat_pull(&code))
1819 dir = (DIRECTION)code;
1822 *dp = (DIRECTION)code;
1826 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1830 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1833 /* Get a direction */
1838 /* Get a command (or Cancel) */
1839 if (!get_com(prompt, &ch, TRUE)) break;
1842 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1848 /* Look up the direction */
1849 dir = get_keymap_dir(ch);
1855 /* Prevent weirdness */
1856 if ((dir == 5) && (!under)) dir = 0;
1859 if (!dir) return FALSE;
1861 /* Save desired direction */
1864 /* Apply "confusion" */
1865 if (p_ptr->confused)
1867 /* Standard confusion */
1868 if (randint0(100) < 75)
1870 /* Random direction */
1871 dir = ddd[randint0(8)];
1874 else if (p_ptr->riding)
1876 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding];
1877 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1879 if (MON_CONFUSED(m_ptr))
1881 /* Standard confusion */
1882 if (randint0(100) < 75)
1884 /* Random direction */
1885 dir = ddd[randint0(8)];
1888 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1890 /* Random direction */
1891 dir = ddd[randint0(8)];
1893 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1895 /* Random direction */
1896 dir = ddd[randint0(8)];
1900 /* Notice confusion */
1901 if (command_dir != dir)
1903 if (p_ptr->confused)
1906 msg_print(_("あなたは混乱している。", "You are confused."));
1910 GAME_TEXT m_name[MAX_NLEN];
1911 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding];
1913 monster_desc(m_name, m_ptr, 0);
1914 if (MON_CONFUSED(m_ptr))
1916 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1920 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1925 /* Save direction */
1928 /* repeat_push(dir); */
1929 repeat_push((COMMAND_CODE)command_dir);
1937 * XAngband: determine if a given location is "interesting"
1938 * based on target_set_accept function.
1940 static bool tgt_pt_accept(player_type *creature_ptr, POSITION y, POSITION x)
1944 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1945 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
1947 /* Player grid is always interesting */
1948 if ((y == creature_ptr->y) && (x == creature_ptr->x)) return TRUE;
1950 if (creature_ptr->image) return FALSE;
1952 g_ptr = &floor_ptr->grid_array[y][x];
1954 /* Interesting memorized features */
1955 if (g_ptr->info & (CAVE_MARK))
1958 if (cave_have_flag_grid(g_ptr, FF_LESS)) return TRUE;
1959 if (cave_have_flag_grid(g_ptr, FF_MORE)) return TRUE;
1961 /* Notice quest features */
1962 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return TRUE;
1963 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return TRUE;
1971 * XAngband: Prepare the "temp" array for "tget_pt"
1972 * based on target_set_prepare funciton.
1974 static void tgt_pt_prepare(player_type *creature_ptr)
1978 /* Reset "temp" array */
1981 if (!expand_list) return;
1983 /* Scan the current panel */
1984 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1985 for (y = 1; y < floor_ptr->height; y++)
1987 for (x = 1; x < floor_ptr->width; x++)
1989 /* Require "interesting" contents */
1990 if (!tgt_pt_accept(creature_ptr, y, x)) continue;
1992 /* Save the location */
1993 tmp_pos.x[tmp_pos.n] = x;
1994 tmp_pos.y[tmp_pos.n] = y;
1999 /* Sort the positions */
2000 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
2005 * old -- from PsiAngband.
2007 bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr)
2012 bool success = FALSE;
2016 get_screen_size(&wid, &hgt);
2018 x = creature_ptr->x;
2019 y = creature_ptr->y;
2023 tgt_pt_prepare(creature_ptr);
2026 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2027 msg_flag = FALSE; /* prevents "-more-" message. */
2029 while ((ch != ESCAPE) && !success)
2031 bool move_fast = FALSE;
2033 move_cursor_relative(y, x);
2045 if (player_bold(creature_ptr, y, x)) ch = 0;
2048 else success = TRUE;
2052 /* XAngband: Move cursor to stairs */
2055 if (expand_list && tmp_pos.n)
2058 int cx = (panel_col_min + panel_col_max) / 2;
2059 int cy = (panel_row_min + panel_row_max) / 2;
2063 /* Skip stairs which have defferent distance */
2064 for (; n < tmp_pos.n; ++ n)
2066 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2068 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2069 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2076 if (n == tmp_pos.n) /* Loop out taget list */
2079 y = creature_ptr->y;
2080 x = creature_ptr->x;
2081 verify_panel(creature_ptr); /* Move cursor to player */
2083 creature_ptr->update |= (PU_MONSTERS);
2085 creature_ptr->redraw |= (PR_MAP);
2087 creature_ptr->window |= (PW_OVERHEAD);
2088 handle_stuff(creature_ptr);
2090 else /* move cursor to next stair and change panel */
2095 dy = 2 * (y - cy) / hgt;
2096 dx = 2 * (x - cx) / wid;
2097 if (dy || dx) change_panel(creature_ptr, dy, dx);
2103 /* Look up the direction */
2104 d = get_keymap_dir(ch);
2106 /* XTRA HACK MOVEFAST */
2107 if (isupper(ch)) move_fast = TRUE;
2109 /* Handle "direction" */
2115 /* XTRA HACK MOVEFAST */
2118 int mag = MIN(wid / 2, hgt / 2);
2128 /* Do not move horizontally if unnecessary */
2129 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2130 ((x > panel_col_min + wid / 2) && (dx < 0)))
2135 /* Do not move vertically if unnecessary */
2136 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2137 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2142 /* Apply the motion */
2143 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2144 (x >= panel_col_min + wid) || (x < panel_col_min))
2146 change_panel(creature_ptr, dy, dx);
2149 /* Slide into legality */
2150 if (x >= creature_ptr->current_floor_ptr->width-1) x = creature_ptr->current_floor_ptr->width - 2;
2151 else if (x <= 0) x = 1;
2153 /* Slide into legality */
2154 if (y >= creature_ptr->current_floor_ptr->height-1) y = creature_ptr->current_floor_ptr->height- 2;
2155 else if (y <= 0) y = 1;
2162 /* Clear the top line */
2165 /* Recenter the map around the player */
2166 verify_panel(creature_ptr);
2168 creature_ptr->update |= (PU_MONSTERS);
2170 creature_ptr->redraw |= (PR_MAP);
2172 creature_ptr->window |= (PW_OVERHEAD);
2173 handle_stuff(creature_ptr);
2181 bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
2189 /* Global direction */
2192 /* (No auto-targeting) */
2194 /* Ask until satisfied */
2197 /* Choose a prompt */
2198 if (!target_okay(creature_ptr))
2200 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2204 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2207 /* Get a command (or Cancel) */
2208 if (!get_com(p, &command, TRUE)) break;
2212 if (command == '\r') command = 't';
2215 /* Convert various keys to "standard" keys */
2218 /* Use current target */
2229 /* Set new target */
2234 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
2240 /* Look up the direction */
2241 dir = get_keymap_dir(command);
2247 /* Verify requested targets */
2248 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
2255 if (!dir) return FALSE;
2257 /* Save the direction */
2260 /* Check for confusion */
2261 if (creature_ptr->confused)
2263 /* Random direction */
2264 dir = ddd[randint0(8)];
2267 /* Notice confusion */
2268 if (command_dir != dir)
2271 msg_print(_("あなたは混乱している。", "You are confused."));
2274 /* Save direction */
2277 /* A "valid" direction was entered */