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.
16 #include "core/stuff-handler.h"
18 #include "targeting.h"
20 #include "market/building.h"
22 #include "dungeon/dungeon-file.h"
23 #include "object-curse.h"
24 #include "object-flavor.h"
26 #include "monsterrace-hook.h"
27 #include "object/object-kind-hook.h"
29 #include "spells-summon.h"
32 #include "floor-events.h"
33 #include "floor-town.h"
34 #include "player-inventory.h"
35 #include "player-move.h"
36 #include "player-status.h"
37 #include "monster-status.h"
38 #include "view/display-main-window.h"
41 #include "dungeon/dungeon.h"
42 #include "world/world.h"
43 #include "effect/spells-effect-util.h"
46 * @brief コンソール上におけるマップ表示の左上位置を返す /
47 * Calculates current boundaries Called below and from "do_cmd_locate()".
50 void panel_bounds_center(void)
54 get_screen_size(&wid, &hgt);
56 panel_row_max = panel_row_min + hgt - 1;
57 panel_row_prt = panel_row_min - 1;
58 panel_col_max = panel_col_min + wid - 1;
59 panel_col_prt = panel_col_min - 13;
63 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
64 * @param creature_ptr プレーヤーへの参照ポインタ
68 * Handle a request to change the current panel
69 * Return TRUE if the panel was changed.
70 * Also used in do_cmd_locate
71 * @return 実際に再描画が必要だった場合TRUEを返す
73 static bool change_panel_xy(player_type *creature_ptr, POSITION y, POSITION x)
75 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;
106 get_screen_size(&wid, &hgt);
108 int max_prow_min = creature_ptr->current_floor_ptr->height - hgt;
109 int max_pcol_min = creature_ptr->current_floor_ptr->width - wid;
111 /* Bounds checking */
114 if (max_prow_min < 0) max_prow_min = 0;
115 if (max_pcol_min < 0) max_pcol_min = 0;
117 /* Center on player */
118 if (center_player && (center_running || !creature_ptr->running))
120 /* Center vertically */
121 prow_min = y - hgt / 2;
122 if (prow_min < 0) prow_min = 0;
123 else if (prow_min > max_prow_min) prow_min = max_prow_min;
125 /* Center horizontally */
126 pcol_min = x - wid / 2;
127 if (pcol_min < 0) pcol_min = 0;
128 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
132 prow_min = panel_row_min;
133 pcol_min = panel_col_min;
135 /* Scroll screen when 2 grids from top/bottom edge */
136 if (y > panel_row_max - 2)
138 while (y > prow_min + hgt - 1 - 2)
140 prow_min += (hgt / 2);
144 if (y < panel_row_min + 2)
146 while (y < prow_min + 2)
148 prow_min -= (hgt / 2);
152 if (prow_min > max_prow_min) prow_min = max_prow_min;
153 if (prow_min < 0) prow_min = 0;
155 /* Scroll screen when 4 grids from left/right edge */
156 if (x > panel_col_max - 4)
158 while (x > pcol_min + wid - 1 - 4)
160 pcol_min += (wid / 2);
164 if (x < panel_col_min + 4)
166 while (x < pcol_min + 4)
168 pcol_min -= (wid / 2);
172 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
173 if (pcol_min < 0) pcol_min = 0;
176 /* Check for "no change" */
177 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
179 /* Save the new panel info */
180 panel_row_min = prow_min;
181 panel_col_min = pcol_min;
183 /* Hack -- optional disturb on "panel change" */
184 if (disturb_panel && !center_player) disturb(creature_ptr, FALSE, FALSE);
186 panel_bounds_center();
188 creature_ptr->update |= (PU_MONSTERS);
189 creature_ptr->redraw |= (PR_MAP);
190 creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
195 * Determine is a monster makes a reasonable target
197 * The concept of "targeting" was stolen from "Morgul" (?)
199 * The player can target any location, or any "target-able" monster.
201 * Currently, a monster is "target_able" if it is visible, and if
202 * the player can hit it with a projection, and the player is not
203 * hallucinating. This allows use of "use closest target" macros.
205 * Future versions may restrict the ability to target "trappers"
206 * and "mimics", but the semantics is a little bit weird.
208 bool target_able(player_type *creature_ptr, MONSTER_IDX m_idx)
210 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
211 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
213 /* Monster must be alive */
214 if (!monster_is_valid(m_ptr)) return FALSE;
216 /* Hack -- no targeting hallucinations */
217 if (creature_ptr->image) return FALSE;
219 /* Monster must be visible */
220 if (!m_ptr->ml) return FALSE;
222 if (creature_ptr->riding && (creature_ptr->riding == m_idx)) return TRUE;
224 /* Monster must be projectable */
225 if (!projectable(creature_ptr, creature_ptr->y, creature_ptr->x, m_ptr->fy, m_ptr->fx)) return FALSE;
227 /* Hack -- Never target trappers */
228 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return FALSE; */
236 * Targetting variables
238 MONSTER_IDX target_who;
243 * Update (if necessary) and verify (if possible) the target.
245 * We return TRUE if the target is "okay" and FALSE otherwise.
247 bool target_okay(player_type *creature_ptr)
249 /* Accept stationary targets */
250 if (target_who < 0) return TRUE;
252 /* Check moving targets */
253 if (target_who <= 0) return FALSE;
255 /* Accept reasonable targets */
256 if (!target_able(creature_ptr, target_who)) return FALSE;
258 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[target_who];
260 /* Acquire monster location */
261 target_row = m_ptr->fy;
262 target_col = m_ptr->fx;
270 * Hack -- help "select" a location (see below)
272 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
274 /* Scan the locations */
275 POSITION_IDX b_i = -1, b_v = 9999;
276 for (POSITION_IDX i = 0; i < tmp_pos.n; i++)
279 POSITION x2 = tmp_pos.x[i];
280 POSITION y2 = tmp_pos.y[i];
282 /* Directed distance */
283 POSITION x3 = (x2 - x1);
284 POSITION y3 = (y2 - y1);
286 /* Verify quadrant */
287 if (dx && (x3 * dx <= 0)) continue;
288 if (dy && (y3 * dy <= 0)) continue;
290 POSITION x4 = ABS(x3);
291 POSITION y4 = ABS(y3);
293 /* Verify quadrant */
294 if (dy && !dx && (x4 > y4)) continue;
295 if (dx && !dy && (y4 > x4)) continue;
297 /* Approximate Double Distance */
298 POSITION_IDX v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
300 /* Penalize location */
301 if ((b_i >= 0) && (v >= b_v)) continue;
310 * Hack -- determine if a given location is "interesting"
312 static bool target_set_accept(player_type *creature_ptr, POSITION y, POSITION x)
314 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
315 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
317 /* Player grid is always interesting */
318 if (player_bold(creature_ptr, y, x)) return TRUE;
320 if (creature_ptr->image) return FALSE;
323 g_ptr = &floor_ptr->grid_array[y][x];
325 /* Visible monsters */
328 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
330 /* Visible monsters */
331 if (m_ptr->ml) return TRUE;
334 /* Scan all objects in the grid */
335 OBJECT_IDX next_o_idx = 0;
336 for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
339 o_ptr = &floor_ptr->o_list[this_o_idx];
340 next_o_idx = o_ptr->next_o_idx;
342 /* Memorized object */
343 if (o_ptr->marked & OM_FOUND) return TRUE;
346 /* Interesting memorized features */
347 if (g_ptr->info & (CAVE_MARK))
349 /* Notice object features */
350 if (g_ptr->info & CAVE_OBJECT) return TRUE;
352 /* Feature code (applying "mimic" field) */
353 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
361 * Prepare the "temp" array for "target_set"
363 * Return the number of target_able monsters in the set.
365 static void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
367 POSITION min_hgt, max_hgt, min_wid, max_wid;
368 if (mode & TARGET_KILL)
371 min_hgt = MAX((creature_ptr->y - MAX_RANGE), 0);
372 max_hgt = MIN((creature_ptr->y + MAX_RANGE), creature_ptr->current_floor_ptr->height - 1);
373 min_wid = MAX((creature_ptr->x - MAX_RANGE), 0);
374 max_wid = MIN((creature_ptr->x + MAX_RANGE), creature_ptr->current_floor_ptr->width - 1);
376 else /* not targetting */
379 min_hgt = panel_row_min;
380 max_hgt = panel_row_max;
381 min_wid = panel_col_min;
382 max_wid = panel_col_max;
385 /* Reset "temp" array */
388 /* Scan the current panel */
389 for (POSITION y = min_hgt; y <= max_hgt; y++)
391 for (POSITION x = min_wid; x <= max_wid; x++)
395 /* Require "interesting" contents */
396 if (!target_set_accept(creature_ptr, y, x)) continue;
398 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
400 /* Require target_able monsters for "TARGET_KILL" */
401 if ((mode & (TARGET_KILL)) && !target_able(creature_ptr, g_ptr->m_idx)) continue;
403 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx])) continue;
405 /* Save the location */
406 tmp_pos.x[tmp_pos.n] = x;
407 tmp_pos.y[tmp_pos.n] = y;
412 /* Set the sort hooks */
413 if (mode & (TARGET_KILL))
415 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
419 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
422 if (creature_ptr->riding == 0 || !target_pet || (tmp_pos.n <= 1) || !(mode & (TARGET_KILL)))
425 POSITION tmp = tmp_pos.y[0];
426 tmp_pos.y[0] = tmp_pos.y[1];
429 tmp_pos.x[0] = tmp_pos.x[1];
434 void target_set_prepare_look(player_type *creature_ptr)
436 target_set_prepare(creature_ptr, TARGET_LOOK);
441 * Evaluate number of kill needed to gain level
443 static void evaluate_monster_exp(player_type *creature_ptr, char *buf, monster_type *m_ptr)
445 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
447 s32b exp_mon, exp_adv;
448 u32b exp_mon_frac, exp_adv_frac;
450 if ((creature_ptr->lev >= PY_MAX_LEVEL) || (creature_ptr->prace == RACE_ANDROID))
455 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
457 if (!current_world_ptr->wizard)
464 /* The monster's experience point (assuming average monster speed) */
465 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
467 s64b_div(&exp_mon, &exp_mon_frac, 0, (creature_ptr->max_plv + 2));
470 /* Total experience value for next level */
471 exp_adv = player_exp[creature_ptr->lev - 1] * creature_ptr->expfact;
473 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
475 /* Experience value need to get */
476 s64b_sub(&exp_adv, &exp_adv_frac, creature_ptr->exp, creature_ptr->exp_frac);
479 /* You need to kill at least one monster to get any experience */
480 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
481 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
483 /* Extract number of monsters needed */
484 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
486 /* If 999 or more monsters needed, only display "999". */
487 num = MIN(999, exp_adv_frac);
489 /* Display the number */
490 sprintf(buf, "%03ld", (long int)num);
494 bool show_gold_on_floor = FALSE;
497 * Examine a grid, return a keypress.
499 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
500 * indicates that the "space" key should scan through the contents
501 * of the grid, instead of simply returning immediately. This lets
502 * the "look" command get complete information, without making the
503 * "target" command annoying.
505 * The "info" argument contains the "commands" which should be shown
506 * inside the "[xxx]" text. This string must never be empty, or grids
507 * containing monsters will be displayed with an extra comma.
509 * Note that if a monster is in the grid, we update both the monster
510 * recall info and the health bar info to track that monster.
512 * Eventually, we may allow multiple objects per grid, or objects
513 * and terrain features in the same grid.
515 * This function must handle blindness/hallucination.
517 static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
519 OBJECT_IDX next_o_idx = 0;
520 concptr s1 = "", s2 = "", s3 = "", x_info = "";
525 char out_val[MAX_NLEN + 80];
526 OBJECT_IDX floor_list[23];
527 ITEM_NUMBER floor_num = 0;
529 /* Scan all objects in the grid */
532 floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02, 0);
536 x_info = _("x物 ", "x,");
540 /* Hack -- under the player */
541 if (player_bold(subject_ptr, y, x))
554 s1 = _("ターゲット:", "Target:");
557 /* Hack -- hallucination */
558 if (subject_ptr->image)
560 concptr name = _("何か奇妙な物", "something strange");
562 /* Display a message */
564 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
566 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
570 move_cursor_relative(y, x);
573 /* Stop on everything but "return" */
574 if ((query != '\r') && (query != '\n')) return query;
580 /* Actual monsters */
581 grid_type *g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
582 if (g_ptr->m_idx && subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)
584 monster_type *m_ptr = &subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
585 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
586 GAME_TEXT m_name[MAX_NLEN];
592 monster_desc(subject_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
593 monster_race_track(subject_ptr, m_ptr->ap_r_idx);
594 health_track(subject_ptr, g_ptr->m_idx);
595 handle_stuff(subject_ptr);
606 /* Recall on screen */
607 screen_roff(subject_ptr, m_ptr->ap_r_idx, 0);
609 /* Hack -- Complete the prompt (again) */
610 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
616 /* Normal commands */
617 if (query != 'r') break;
621 /* Cleare recall text and repeat */
627 /* Describe, and prompt for recall */
628 evaluate_monster_exp(subject_ptr, acount, m_ptr);
631 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);
633 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);
639 move_cursor_relative(y, x);
643 /* Normal commands */
644 if (query != 'r') break;
649 /* Always stop at "normal" keys */
650 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
652 /* Sometimes stop at "space" key */
653 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
655 /* Change the intro */
656 s1 = _("それは", "It is ");
658 /* Hack -- take account of gender */
659 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
660 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
662 /* Use a preposition */
670 /* Scan all objects being carried */
671 for (OBJECT_IDX this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
673 GAME_TEXT o_name[MAX_NLEN];
676 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
677 next_o_idx = o_ptr->next_o_idx;
679 object_desc(subject_ptr, o_name, o_ptr, 0);
682 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
684 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
688 move_cursor_relative(y, x);
691 /* Always stop at "normal" keys */
692 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
694 /* Sometimes stop at "space" key */
695 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
697 /* Change the intro */
698 s2 = _("をまた", "also carrying ");
701 /* Use a preposition */
718 GAME_TEXT o_name[MAX_NLEN];
721 o_ptr = &subject_ptr->current_floor_ptr->o_list[floor_list[0]];
723 object_desc(subject_ptr, o_name, o_ptr, 0);
726 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
728 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
732 move_cursor_relative(y, x);
740 /* Provide one cushion before item listing */
743 /* Display rough information about items */
745 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
747 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
751 move_cursor_relative(y, x);
755 /* No request for listing */
756 if (query != 'x' && query != ' ') return query;
760 /** Display list of items **/
762 /* Continue scrolling list if requested */
770 show_gold_on_floor = TRUE;
771 (void)show_floor(subject_ptr, 0, y, x, &min_width, 0);
772 show_gold_on_floor = FALSE;
776 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
778 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
785 /* Exit unless 'Enter' */
786 if (query != '\n' && query != '\r')
791 /* Get the object being moved. */
792 o_idx = g_ptr->o_idx;
794 /* Only rotate a pile of two or more objects. */
795 if (!(o_idx && subject_ptr->current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
797 /* Remove the first object from the list. */
798 excise_object_idx(subject_ptr->current_floor_ptr, o_idx);
800 /* Find end of the list. */
802 while (subject_ptr->current_floor_ptr->o_list[i].next_o_idx)
803 i = subject_ptr->current_floor_ptr->o_list[i].next_o_idx;
805 /* Add after the last object. */
806 subject_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
808 /* Loop and re-display the list */
815 /* Scan all objects in the grid */
816 for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
819 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
820 next_o_idx = o_ptr->next_o_idx;
822 if (o_ptr->marked & OM_FOUND)
824 GAME_TEXT o_name[MAX_NLEN];
829 object_desc(subject_ptr, o_name, o_ptr, 0);
832 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
834 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
838 move_cursor_relative(y, x);
841 /* Always stop at "normal" keys */
842 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
844 /* Sometimes stop at "space" key */
845 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
847 /* Change the intro */
848 s1 = _("それは", "It is ");
851 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
864 /* Feature code (applying "mimic" field) */
865 feat = get_feat_mimic(g_ptr);
867 /* Require knowledge about grid, or ability to see grid */
868 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(subject_ptr, y, x))
874 f_ptr = &f_info[feat];
876 /* Terrain feature if needed */
877 if (!boring && !have_flag(f_ptr->flags, FF_REMEMBER))
879 if ((query != '\r') && (query != '\n')) return query;
883 /* Hack -- special handling for quest entrances */
885 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
887 /* Set the quest number temporary */
888 IDX old_quest = subject_ptr->current_floor_ptr->inside_quest;
892 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
895 subject_ptr->current_floor_ptr->inside_quest = g_ptr->special;
897 /* Get the quest text */
898 init_flags = INIT_NAME_ONLY;
900 process_dungeon_file(subject_ptr, "q_info.txt", 0, 0, 0, 0);
902 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
903 quest[g_ptr->special].name, quest[g_ptr->special].level);
905 /* Reset the old quest number */
906 subject_ptr->current_floor_ptr->inside_quest = old_quest;
909 /* Hack -- special handling for building doors */
910 else if (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena)
912 name = building[f_ptr->subtype].name;
914 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
916 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
918 else if (have_flag(f_ptr->flags, FF_TOWN))
920 name = town_info[g_ptr->special].name;
922 else if (subject_ptr->wild_mode && (feat == feat_floor))
924 name = _("道", "road");
928 name = f_name + f_ptr->name;
933 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
934 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
935 have_flag(f_ptr->flags, FF_TOWN)))
940 /* Hack -- special introduction for store & building doors -KMW- */
941 if (have_flag(f_ptr->flags, FF_STORE) ||
942 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
943 (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena) ||
944 have_flag(f_ptr->flags, FF_ENTRANCE))
950 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
951 have_flag(f_ptr->flags, FF_TOWN) ||
952 have_flag(f_ptr->flags, FF_SHALLOW) ||
953 have_flag(f_ptr->flags, FF_DEEP))
959 /* Pick proper indefinite article */
960 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
964 /* Display a message */
965 if (current_world_ptr->wizard)
968 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
969 else sprintf(f_idx_str, "%d", g_ptr->feat);
971 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]);
973 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);
978 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
980 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
984 move_cursor_relative(y, x);
987 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
993 * Handle "target" and "look".
995 * Note that this code can be called from "get_aim_dir()".
997 * All locations must be on the current panel. Consider the use of
998 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
999 * some form of "scrolling" the map around the cursor.
1000 * That is, consider the possibility of "auto-scrolling" the screen
1001 * while the cursor moves around. This may require changes in the
1002 * "update_monster()" code to allow "visibility" even if off panel, and
1003 * may require dynamic recalculation of the "temp" grid set.
1005 * Hack -- targeting/observing an "outer border grid" may induce
1006 * problems, so this is not currently allowed.
1008 * The player can use the direction keys to move among "interesting"
1009 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1010 * move through the "interesting" grids in a sequential manner, or
1011 * can enter "location" mode, and use the direction keys to move one
1012 * grid at a time in any direction. The "t" (set target) command will
1013 * only target a monster (as opposed to a location) if the monster is
1014 * target_able and the "interesting" mode is being used.
1016 * The current grid is described using the "look" method above, and
1017 * a new command may be entered at any time, but note that if the
1018 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1019 * where "space" has no obvious meaning) then "space" will scan
1020 * through the description of the current grid until done, instead
1021 * of immediately jumping to the next "interesting" grid. This
1022 * allows the "target" command to retain its old semantics.
1024 * The "*", "+", and "-" keys may always be used to jump immediately
1025 * to the next (or previous) interesting grid, in the proper mode.
1027 * The "return" key may always be used to scan through a complete
1028 * grid description (forever).
1030 * This command will cancel any old target, even if used from
1031 * inside the "look" command.
1033 bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
1036 POSITION y = creature_ptr->y;
1037 POSITION x = creature_ptr->x;
1047 get_screen_size(&wid, &hgt);
1052 if (rogue_like_commands)
1061 /* Prepare the "temp" array */
1062 target_set_prepare(creature_ptr, mode);
1064 /* Start near the player */
1068 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1071 /* Interesting grids */
1072 if (flag && tmp_pos.n)
1078 change_panel_xy(creature_ptr, y, x);
1080 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1083 g_ptr = &floor_ptr->grid_array[y][x];
1086 if (target_able(creature_ptr, g_ptr->m_idx))
1088 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1091 /* Dis-allow target */
1094 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1100 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1101 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x));
1102 strcat(info, cheatinfo);
1105 /* Describe and Prompt */
1108 query = target_set_aux(creature_ptr, y, x, mode, info);
1112 /* Assume no "direction" */
1117 if (query == '\r') query = 't';
1135 if (target_able(creature_ptr, g_ptr->m_idx))
1137 health_track(creature_ptr, g_ptr->m_idx);
1138 target_who = g_ptr->m_idx;
1154 if (++m == tmp_pos.n)
1157 if (!expand_list) done = TRUE;
1167 if (!expand_list) done = TRUE;
1174 /* Recenter the map around the player */
1175 verify_panel(creature_ptr);
1176 creature_ptr->update |= (PU_MONSTERS);
1177 creature_ptr->redraw |= (PR_MAP);
1178 creature_ptr->window |= (PW_OVERHEAD);
1179 handle_stuff(creature_ptr);
1181 /* Recalculate interesting grids */
1182 target_set_prepare(creature_ptr, mode);
1184 y = creature_ptr->y;
1185 x = creature_ptr->x;
1202 if (query == same_key)
1204 if (++m == tmp_pos.n)
1207 if (!expand_list) done = TRUE;
1212 /* Extract the action (if any) */
1213 d = get_keymap_dir(query);
1220 /* Hack -- move around */
1223 /* Modified to scroll to monster */
1224 POSITION y2 = panel_row_min;
1225 POSITION x2 = panel_col_min;
1227 /* Find a new monster */
1228 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1230 /* Request to target past last interesting grid */
1231 while (flag && (i < 0))
1233 /* Note the change */
1234 if (change_panel(creature_ptr, ddy[d], ddx[d]))
1236 int v = tmp_pos.y[m];
1237 int u = tmp_pos.x[m];
1239 /* Recalculate interesting grids */
1240 target_set_prepare(creature_ptr, mode);
1242 /* Look at interesting grids */
1245 /* Find a new monster */
1246 i = target_pick(v, u, ddy[d], ddx[d]);
1253 /* Nothing interesting */
1254 POSITION dx = ddx[d];
1255 POSITION dy = ddy[d];
1257 /* Restore previous position */
1260 panel_bounds_center();
1262 creature_ptr->update |= (PU_MONSTERS);
1263 creature_ptr->redraw |= (PR_MAP);
1264 creature_ptr->window |= (PW_OVERHEAD);
1265 handle_stuff(creature_ptr);
1267 /* Recalculate interesting grids */
1268 target_set_prepare(creature_ptr, mode);
1270 /* Look at boring grids */
1277 /* Do not move horizontally if unnecessary */
1278 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1279 ((x > panel_col_min + wid / 2) && (dx < 0)))
1284 /* Do not move vertically if unnecessary */
1285 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1286 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1291 /* Apply the motion */
1292 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1293 (x >= panel_col_min + wid) || (x < panel_col_min))
1295 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1298 /* Slide into legality */
1299 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1300 else if (x <= 0) x = 1;
1302 /* Slide into legality */
1303 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1304 else if (y <= 0) y = 1;
1314 /* Arbitrary grids */
1316 bool move_fast = FALSE;
1318 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1321 g_ptr = &floor_ptr->grid_array[y][x];
1323 /* Default prompt */
1324 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1328 char cheatinfo[100];
1329 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d",
1330 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x),
1331 projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special);
1332 strcat(info, cheatinfo);
1335 /* Describe and Prompt (enable "TARGET_LOOK") */
1336 while ((query = target_set_aux(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0);
1338 /* Assume no direction */
1343 if (query == '\r') query = 't';
1346 /* Analyze the keypress */
1370 /* Recenter the map around the player */
1371 verify_panel(creature_ptr);
1372 creature_ptr->update |= (PU_MONSTERS);
1373 creature_ptr->redraw |= (PR_MAP);
1374 creature_ptr->window |= (PW_OVERHEAD);
1375 handle_stuff(creature_ptr);
1377 /* Recalculate interesting grids */
1378 target_set_prepare(creature_ptr, mode);
1380 y = creature_ptr->y;
1381 x = creature_ptr->x;
1400 /* Pick a nearby monster */
1401 for (i = 0; i < tmp_pos.n; i++)
1403 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1413 /* Nothing interesting */
1414 if (bd == 999) flag = FALSE;
1421 /* Extract the action (if any) */
1422 d = get_keymap_dir(query);
1424 /* XTRA HACK MOVEFAST */
1425 if (isupper(query)) move_fast = TRUE;
1432 /* Handle "direction" */
1435 POSITION dx = ddx[d];
1436 POSITION dy = ddy[d];
1438 /* XTRA HACK MOVEFAST */
1441 int mag = MIN(wid / 2, hgt / 2);
1451 /* Do not move horizontally if unnecessary */
1452 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1453 ((x > panel_col_min + wid / 2) && (dx < 0)))
1458 /* Do not move vertically if unnecessary */
1459 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1460 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1465 /* Apply the motion */
1466 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1467 (x >= panel_col_min + wid) || (x < panel_col_min))
1469 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1472 /* Slide into legality */
1473 if (x >= floor_ptr->width - 1) x = floor_ptr->width - 2;
1474 else if (x <= 0) x = 1;
1476 /* Slide into legality */
1477 if (y >= floor_ptr->height - 1) y = floor_ptr->height - 2;
1478 else if (y <= 0) y = 1;
1485 /* Clear the top line */
1488 /* Recenter the map around the player */
1489 verify_panel(creature_ptr);
1490 creature_ptr->update |= (PU_MONSTERS);
1491 creature_ptr->redraw |= (PR_MAP);
1492 creature_ptr->window |= (PW_OVERHEAD);
1493 handle_stuff(creature_ptr);
1495 return target_who != 0;
1500 * Get an "aiming direction" from the user.
1502 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1503 * "0" for "current target", and "-1" for "entry aborted".
1505 * Note that "Force Target", if set, will pre-empt user interaction,
1506 * if there is a usable target already set.
1508 * Note that confusion over-rides any (explicit?) user choice.
1510 bool get_aim_dir(player_type *creature_ptr, DIRECTION *dp)
1512 /* Global direction */
1513 DIRECTION dir = command_dir;
1515 /* Hack -- auto-target if requested */
1516 if (use_old_target && target_okay(creature_ptr)) dir = 5;
1519 if (repeat_pull(&code))
1524 if (!(code == 5 && !target_okay(creature_ptr)))
1527 dir = (DIRECTION)code;
1531 *dp = (DIRECTION)code;
1533 /* Ask until satisfied */
1537 /* Choose a prompt */
1539 if (!target_okay(creature_ptr))
1541 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1545 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1548 /* Get a command (or Cancel) */
1549 if (!get_com(p, &command, TRUE)) break;
1553 if (command == '\r') command = 't';
1556 /* Convert various keys to "standard" keys */
1559 /* Use current target */
1570 /* Set new target */
1575 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
1581 /* Extract the action (if any) */
1582 dir = get_keymap_dir(command);
1588 /* Verify requested targets */
1589 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
1598 project_length = 0; /* reset to default */
1602 /* Save the direction */
1605 /* Check for confusion */
1606 if (creature_ptr->confused)
1608 /* Random direction */
1609 dir = ddd[randint0(8)];
1612 /* Notice confusion */
1613 if (command_dir != dir)
1616 msg_print(_("あなたは混乱している。", "You are confused."));
1619 /* Save direction */
1622 repeat_push((COMMAND_CODE)command_dir);
1627 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed)
1629 /* Global direction */
1630 DIRECTION dir = command_dir;
1633 if (repeat_pull(&code))
1635 dir = (DIRECTION)code;
1639 *dp = (DIRECTION)code;
1644 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1648 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1651 /* Get a direction */
1656 /* Get a command (or Cancel) */
1657 if (!get_com(prompt, &ch, TRUE)) break;
1660 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1666 /* Look up the direction */
1667 dir = get_keymap_dir(ch);
1673 /* Prevent weirdness */
1674 if ((dir == 5) && (!allow_under)) dir = 0;
1677 if (!dir) return FALSE;
1679 /* Save desired direction */
1682 /* Apply "confusion" */
1683 if (creature_ptr->confused)
1685 /* Standard confusion */
1686 if (randint0(100) < 75)
1688 /* Random direction */
1689 dir = ddd[randint0(8)];
1692 else if (creature_ptr->riding && with_steed)
1694 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1695 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1697 if (MON_CONFUSED(m_ptr))
1699 /* Standard confusion */
1700 if (randint0(100) < 75)
1702 /* Random direction */
1703 dir = ddd[randint0(8)];
1706 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1708 /* Random direction */
1709 dir = ddd[randint0(8)];
1711 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1713 /* Random direction */
1714 dir = ddd[randint0(8)];
1718 /* Notice confusion */
1719 if (command_dir != dir)
1721 if (creature_ptr->confused)
1724 msg_print(_("あなたは混乱している。", "You are confused."));
1728 GAME_TEXT m_name[MAX_NLEN];
1729 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1731 monster_desc(creature_ptr, m_name, m_ptr, 0);
1732 if (MON_CONFUSED(m_ptr))
1734 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1738 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1744 repeat_push((COMMAND_CODE)command_dir);
1750 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1751 * and place it into "command_dir", unless we already have one.
1753 * This function should be used for all "repeatable" commands, such as
1754 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1755 * as all commands which must reference a grid adjacent to the player,
1756 * and which may not reference the grid under the player. Note that,
1757 * for example, it is no longer possible to "disarm" or "open" chests
1758 * in the same grid as the player.
1760 * Direction "5" is illegal and will (cleanly) abort the command.
1762 * This function tracks and uses the "global direction", and uses
1763 * that as the "desired direction", to which "confusion" is applied.
1765 bool get_rep_dir(player_type *creature_ptr, DIRECTION *dp, bool under)
1767 /* Global direction */
1768 DIRECTION dir = command_dir;
1771 if (repeat_pull(&code))
1773 dir = (DIRECTION)code;
1777 *dp = (DIRECTION)code;
1782 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1786 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1789 /* Get a direction */
1794 /* Get a command (or Cancel) */
1795 if (!get_com(prompt, &ch, TRUE)) break;
1798 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1804 /* Look up the direction */
1805 dir = get_keymap_dir(ch);
1811 /* Prevent weirdness */
1812 if ((dir == 5) && (!under)) dir = 0;
1815 if (!dir) return FALSE;
1817 /* Save desired direction */
1820 /* Apply "confusion" */
1821 if (creature_ptr->confused)
1823 /* Standard confusion */
1824 if (randint0(100) < 75)
1826 /* Random direction */
1827 dir = ddd[randint0(8)];
1830 else if (creature_ptr->riding)
1832 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1833 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1835 if (MON_CONFUSED(m_ptr))
1837 /* Standard confusion */
1838 if (randint0(100) < 75)
1840 /* Random direction */
1841 dir = ddd[randint0(8)];
1844 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1846 /* Random direction */
1847 dir = ddd[randint0(8)];
1849 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1851 /* Random direction */
1852 dir = ddd[randint0(8)];
1856 /* Notice confusion */
1857 if (command_dir != dir)
1859 if (creature_ptr->confused)
1862 msg_print(_("あなたは混乱している。", "You are confused."));
1866 GAME_TEXT m_name[MAX_NLEN];
1867 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1869 monster_desc(creature_ptr, m_name, m_ptr, 0);
1870 if (MON_CONFUSED(m_ptr))
1872 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1876 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1882 repeat_push((COMMAND_CODE)command_dir);
1888 * XAngband: determine if a given location is "interesting"
1889 * based on target_set_accept function.
1891 static bool tgt_pt_accept(player_type *creature_ptr, POSITION y, POSITION x)
1893 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1894 if (!(in_bounds(floor_ptr, y, x))) return FALSE;
1896 /* Player grid is always interesting */
1897 if ((y == creature_ptr->y) && (x == creature_ptr->x)) return TRUE;
1899 if (creature_ptr->image) return FALSE;
1902 g_ptr = &floor_ptr->grid_array[y][x];
1904 /* Interesting memorized features */
1905 if (!(g_ptr->info & (CAVE_MARK))) return FALSE;
1908 if (cave_have_flag_grid(g_ptr, FF_LESS)) return TRUE;
1909 if (cave_have_flag_grid(g_ptr, FF_MORE)) return TRUE;
1911 /* Notice quest features */
1912 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return TRUE;
1913 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return TRUE;
1920 * XAngband: Prepare the "temp" array for "tget_pt"
1921 * based on target_set_prepare funciton.
1923 static void tgt_pt_prepare(player_type *creature_ptr)
1927 if (!expand_list) return;
1929 /* Scan the current panel */
1930 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1931 for (POSITION y = 1; y < floor_ptr->height; y++)
1933 for (POSITION x = 1; x < floor_ptr->width; x++)
1935 /* Require "interesting" contents */
1936 if (!tgt_pt_accept(creature_ptr, y, x)) continue;
1938 /* Save the location */
1939 tmp_pos.x[tmp_pos.n] = x;
1940 tmp_pos.y[tmp_pos.n] = y;
1945 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
1950 * old -- from PsiAngband.
1952 bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr)
1955 get_screen_size(&wid, &hgt);
1957 POSITION x = creature_ptr->x;
1958 POSITION y = creature_ptr->y;
1960 if (expand_list) tgt_pt_prepare(creature_ptr);
1962 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
1963 msg_flag = FALSE; /* prevents "-more-" message. */
1967 bool success = FALSE;
1968 while ((ch != ESCAPE) && !success)
1970 bool move_fast = FALSE;
1972 move_cursor_relative(y, x);
1984 if (player_bold(creature_ptr, y, x)) ch = 0;
1987 else success = TRUE;
1991 /* XAngband: Move cursor to stairs */
1995 if (!expand_list || !tmp_pos.n) break;
1998 int cx = (panel_col_min + panel_col_max) / 2;
1999 int cy = (panel_row_min + panel_row_max) / 2;
2003 /* Skip stairs which have defferent distance */
2004 for (; n < tmp_pos.n; ++n)
2006 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2008 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2009 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2016 if (n == tmp_pos.n) /* Loop out taget list */
2019 y = creature_ptr->y;
2020 x = creature_ptr->x;
2021 verify_panel(creature_ptr); /* Move cursor to player */
2023 creature_ptr->update |= (PU_MONSTERS);
2025 creature_ptr->redraw |= (PR_MAP);
2027 creature_ptr->window |= (PW_OVERHEAD);
2028 handle_stuff(creature_ptr);
2030 else /* move cursor to next stair and change panel */
2035 dy = 2 * (y - cy) / hgt;
2036 dx = 2 * (x - cx) / wid;
2037 if (dy || dx) change_panel(creature_ptr, dy, dx);
2045 /* Look up the direction */
2046 int d = get_keymap_dir(ch);
2048 /* XTRA HACK MOVEFAST */
2049 if (isupper(ch)) move_fast = TRUE;
2051 /* Handle "direction" */
2057 /* XTRA HACK MOVEFAST */
2060 int mag = MIN(wid / 2, hgt / 2);
2070 /* Do not move horizontally if unnecessary */
2071 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2072 ((x > panel_col_min + wid / 2) && (dx < 0)))
2077 /* Do not move vertically if unnecessary */
2078 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2079 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2084 /* Apply the motion */
2085 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2086 (x >= panel_col_min + wid) || (x < panel_col_min))
2088 change_panel(creature_ptr, dy, dx);
2091 /* Slide into legality */
2092 if (x >= creature_ptr->current_floor_ptr->width - 1) x = creature_ptr->current_floor_ptr->width - 2;
2093 else if (x <= 0) x = 1;
2095 /* Slide into legality */
2096 if (y >= creature_ptr->current_floor_ptr->height - 1) y = creature_ptr->current_floor_ptr->height - 2;
2097 else if (y <= 0) y = 1;
2105 verify_panel(creature_ptr);
2106 creature_ptr->update |= (PU_MONSTERS);
2107 creature_ptr->redraw |= (PR_MAP);
2108 creature_ptr->window |= (PW_OVERHEAD);
2109 handle_stuff(creature_ptr);
2117 bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
2121 /* Ask until satisfied */
2126 /* Choose a prompt */
2128 if (!target_okay(creature_ptr))
2130 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2134 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2137 /* Get a command (or Cancel) */
2138 if (!get_com(p, &command, TRUE)) break;
2142 if (command == '\r') command = 't';
2145 /* Convert various keys to "standard" keys */
2148 /* Use current target */
2159 /* Set new target */
2164 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
2170 /* Look up the direction */
2171 dir = get_keymap_dir(command);
2177 /* Verify requested targets */
2178 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
2184 if (!dir) return FALSE;
2186 /* Save the direction */
2189 /* Check for confusion */
2190 if (creature_ptr->confused)
2192 /* Random direction */
2193 dir = ddd[randint0(8)];
2196 /* Notice confusion */
2197 if (command_dir != dir)
2200 msg_print(_("あなたは混乱している。", "You are confused."));