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(player_type *creature_ptr, MONSTER_IDX m_idx)
214 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
215 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
217 /* Monster must be alive */
218 if (!monster_is_valid(m_ptr)) return FALSE;
220 /* Hack -- no targeting hallucinations */
221 if (creature_ptr->image) return FALSE;
223 /* Monster must be visible */
224 if (!m_ptr->ml) return FALSE;
226 if (creature_ptr->riding && (creature_ptr->riding == m_idx)) return TRUE;
228 /* Monster must be projectable */
229 if (!projectable(creature_ptr, creature_ptr->y, creature_ptr->x, m_ptr->fy, m_ptr->fx)) return FALSE;
231 /* Hack -- Never target trappers */
232 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return FALSE; */
240 * Targetting variables
242 MONSTER_IDX target_who;
247 * Update (if necessary) and verify (if possible) the target.
249 * We return TRUE if the target is "okay" and FALSE otherwise.
251 bool target_okay(player_type *creature_ptr)
253 /* Accept stationary targets */
254 if (target_who < 0) return TRUE;
256 /* Check moving targets */
259 /* Accept reasonable targets */
260 if (target_able(creature_ptr, target_who))
262 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[target_who];
264 /* Acquire monster location */
265 target_row = m_ptr->fy;
266 target_col = m_ptr->fx;
273 /* Assume no target */
279 * Hack -- help "select" a location (see below)
281 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
284 POSITION x2, y2, x3, y3, x4, y4;
285 POSITION_IDX b_i = -1, b_v = 9999;
288 /* Scan the locations */
289 for (i = 0; i < tmp_pos.n; i++)
295 /* Directed distance */
299 /* Verify quadrant */
300 if (dx && (x3 * dx <= 0)) continue;
301 if (dy && (y3 * dy <= 0)) continue;
306 /* Verify quadrant */
307 if (dy && !dx && (x4 > y4)) continue;
308 if (dx && !dy && (y4 > x4)) continue;
310 /* Approximate Double Distance */
311 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
313 /* Penalize location */
314 if ((b_i >= 0) && (v >= b_v)) continue;
322 * Hack -- determine if a given location is "interesting"
324 static bool target_set_accept(POSITION y, POSITION x)
327 OBJECT_IDX this_o_idx, next_o_idx = 0;
329 if (!(in_bounds(p_ptr->current_floor_ptr, y, x))) return FALSE;
331 /* Player grid is always interesting */
332 if (player_bold(p_ptr, y, x)) return TRUE;
334 if (p_ptr->image) return FALSE;
336 g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
338 /* Visible monsters */
341 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
343 /* Visible monsters */
344 if (m_ptr->ml) return TRUE;
347 /* Scan all objects in the grid */
348 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
351 o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
352 next_o_idx = o_ptr->next_o_idx;
354 /* Memorized object */
355 if (o_ptr->marked & OM_FOUND) return TRUE;
358 /* Interesting memorized features */
359 if (g_ptr->info & (CAVE_MARK))
361 /* Notice object features */
362 if (g_ptr->info & CAVE_OBJECT) return TRUE;
364 /* Feature code (applying "mimic" field) */
365 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
373 * Prepare the "temp" array for "target_set"
375 * Return the number of target_able monsters in the set.
377 static void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
380 POSITION min_hgt, max_hgt, min_wid, max_wid;
382 if (mode & TARGET_KILL)
385 min_hgt = MAX((creature_ptr->y - MAX_RANGE), 0);
386 max_hgt = MIN((creature_ptr->y + MAX_RANGE), creature_ptr->current_floor_ptr->height - 1);
387 min_wid = MAX((creature_ptr->x - MAX_RANGE), 0);
388 max_wid = MIN((creature_ptr->x + MAX_RANGE), creature_ptr->current_floor_ptr->width - 1);
390 else /* not targetting */
393 min_hgt = panel_row_min;
394 max_hgt = panel_row_max;
395 min_wid = panel_col_min;
396 max_wid = panel_col_max;
399 /* Reset "temp" array */
402 /* Scan the current panel */
403 for (y = min_hgt; y <= max_hgt; y++)
405 for (x = min_wid; x <= max_wid; x++)
409 /* Require "interesting" contents */
410 if (!target_set_accept(y, x)) continue;
412 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
414 /* Require target_able monsters for "TARGET_KILL" */
415 if ((mode & (TARGET_KILL)) && !target_able(creature_ptr, g_ptr->m_idx)) continue;
417 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx])) continue;
419 /* Save the location */
420 tmp_pos.x[tmp_pos.n] = x;
421 tmp_pos.y[tmp_pos.n] = y;
426 /* Set the sort hooks */
427 if (mode & (TARGET_KILL))
429 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
433 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
436 if (creature_ptr->riding && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
441 tmp_pos.y[0] = tmp_pos.y[1];
444 tmp_pos.x[0] = tmp_pos.x[1];
449 void target_set_prepare_look(player_type *creature_ptr)
451 target_set_prepare(creature_ptr, TARGET_LOOK);
456 * Evaluate number of kill needed to gain level
458 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
460 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
462 s32b exp_mon, exp_adv;
463 u32b exp_mon_frac, exp_adv_frac;
465 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
470 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
472 if (!current_world_ptr->wizard)
480 /* The monster's experience point (assuming average monster speed) */
481 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
483 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
486 /* Total experience value for next level */
487 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
489 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
491 /* Experience value need to get */
492 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
495 /* You need to kill at least one monster to get any experience */
496 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
497 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
499 /* Extract number of monsters needed */
500 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
502 /* If 999 or more monsters needed, only display "999". */
503 num = MIN(999, exp_adv_frac);
505 /* Display the number */
506 sprintf(buf,"%03ld", (long int)num);
510 bool show_gold_on_floor = FALSE;
513 * Examine a grid, return a keypress.
515 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
516 * indicates that the "space" key should scan through the contents
517 * of the grid, instead of simply returning immediately. This lets
518 * the "look" command get complete information, without making the
519 * "target" command annoying.
521 * The "info" argument contains the "commands" which should be shown
522 * inside the "[xxx]" text. This string must never be empty, or grids
523 * containing monsters will be displayed with an extra comma.
525 * Note that if a monster is in the grid, we update both the monster
526 * recall info and the health bar info to track that monster.
528 * Eventually, we may allow multiple objects per grid, or objects
529 * and terrain features in the same grid.
531 * This function must handle blindness/hallucination.
533 static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
535 grid_type *g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
536 OBJECT_IDX this_o_idx, next_o_idx = 0;
537 concptr s1 = "", s2 = "", s3 = "", x_info = "";
542 char out_val[MAX_NLEN+80];
543 OBJECT_IDX floor_list[23];
544 ITEM_NUMBER floor_num = 0;
546 /* Scan all objects in the grid */
549 floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02);
553 x_info = _("x物 ", "x,");
557 /* Hack -- under the player */
558 if (player_bold(subject_ptr, y, x))
571 s1 = _("ターゲット:", "Target:");
574 /* Hack -- hallucination */
575 if (subject_ptr->image)
577 concptr name = _("何か奇妙な物", "something strange");
579 /* Display a message */
581 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
583 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
587 move_cursor_relative(y, x);
590 /* Stop on everything but "return" */
591 if ((query != '\r') && (query != '\n')) return query;
598 /* Actual monsters */
599 if (g_ptr->m_idx && subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)
601 monster_type *m_ptr = &subject_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
602 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
603 GAME_TEXT m_name[MAX_NLEN];
609 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
610 monster_race_track(subject_ptr, m_ptr->ap_r_idx);
611 health_track(subject_ptr, g_ptr->m_idx);
612 handle_stuff(subject_ptr);
623 /* Recall on screen */
624 screen_roff(m_ptr->ap_r_idx, 0);
626 /* Hack -- Complete the prompt (again) */
627 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
633 /* Normal commands */
634 if (query != 'r') break;
638 /* Cleare recall text and repeat */
644 /* Describe, and prompt for recall */
645 evaluate_monster_exp(acount, m_ptr);
648 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);
650 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);
656 move_cursor_relative(y, x);
660 /* Normal commands */
661 if (query != 'r') break;
666 /* Always stop at "normal" keys */
667 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
669 /* Sometimes stop at "space" key */
670 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
672 /* Change the intro */
673 s1 = _("それは", "It is ");
675 /* Hack -- take account of gender */
676 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
677 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
679 /* Use a preposition */
688 /* Scan all objects being carried */
689 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
691 GAME_TEXT o_name[MAX_NLEN];
694 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
695 next_o_idx = o_ptr->next_o_idx;
697 object_desc(o_name, o_ptr, 0);
700 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
702 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
706 move_cursor_relative(y, x);
709 /* Always stop at "normal" keys */
710 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
712 /* Sometimes stop at "space" key */
713 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
715 /* Change the intro */
716 s2 = _("をまた", "also carrying ");
719 /* Use a preposition */
736 GAME_TEXT o_name[MAX_NLEN];
739 o_ptr = &subject_ptr->current_floor_ptr->o_list[floor_list[0]];
741 object_desc(o_name, o_ptr, 0);
744 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
746 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
750 move_cursor_relative(y, x);
758 /* Provide one cushion before item listing */
761 /* Display rough information about items */
763 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
765 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
769 move_cursor_relative(y, x);
773 /* No request for listing */
774 if (query != 'x' && query != ' ') return query;
778 /** Display list of items **/
780 /* Continue scrolling list if requested */
788 show_gold_on_floor = TRUE;
789 (void)show_floor(subject_ptr, 0, y, x, &min_width);
790 show_gold_on_floor = FALSE;
794 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
796 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
803 /* Exit unless 'Enter' */
804 if (query != '\n' && query != '\r')
809 /* Get the object being moved. */
810 o_idx = g_ptr->o_idx;
812 /* Only rotate a pile of two or more objects. */
813 if (!(o_idx && subject_ptr->current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
815 /* Remove the first object from the list. */
816 excise_object_idx(subject_ptr->current_floor_ptr, o_idx);
818 /* Find end of the list. */
820 while (subject_ptr->current_floor_ptr->o_list[i].next_o_idx)
821 i = subject_ptr->current_floor_ptr->o_list[i].next_o_idx;
823 /* Add after the last object. */
824 subject_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
826 /* Loop and re-display the list */
833 /* Scan all objects in the grid */
834 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
837 o_ptr = &subject_ptr->current_floor_ptr->o_list[this_o_idx];
838 next_o_idx = o_ptr->next_o_idx;
840 if (o_ptr->marked & OM_FOUND)
842 GAME_TEXT o_name[MAX_NLEN];
847 object_desc(o_name, o_ptr, 0);
850 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
852 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
856 move_cursor_relative(y, x);
859 /* Always stop at "normal" keys */
860 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
862 /* Sometimes stop at "space" key */
863 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
865 /* Change the intro */
866 s1 = _("それは", "It is ");
869 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
883 /* Feature code (applying "mimic" field) */
884 feat = get_feat_mimic(g_ptr);
886 /* Require knowledge about grid, or ability to see grid */
887 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(subject_ptr, y, x))
893 f_ptr = &f_info[feat];
895 /* Terrain feature if needed */
896 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
900 /* Hack -- special handling for quest entrances */
901 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
903 /* Set the quest number temporary */
904 IDX old_quest = subject_ptr->current_floor_ptr->inside_quest;
908 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
911 subject_ptr->current_floor_ptr->inside_quest = g_ptr->special;
913 /* Get the quest text */
914 init_flags = INIT_NAME_ONLY;
916 process_dungeon_file(subject_ptr, "q_info.txt", 0, 0, 0, 0);
918 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
919 quest[g_ptr->special].name, quest[g_ptr->special].level);
921 /* Reset the old quest number */
922 subject_ptr->current_floor_ptr->inside_quest = old_quest;
925 /* Hack -- special handling for building doors */
926 else if (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena)
928 name = building[f_ptr->subtype].name;
930 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
932 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
934 else if (have_flag(f_ptr->flags, FF_TOWN))
936 name = town_info[g_ptr->special].name;
938 else if (subject_ptr->wild_mode && (feat == feat_floor))
940 name = _("道", "road");
944 name = f_name + f_ptr->name;
950 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
951 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
952 have_flag(f_ptr->flags, FF_TOWN)))
957 /* Hack -- special introduction for store & building doors -KMW- */
958 if (have_flag(f_ptr->flags, FF_STORE) ||
959 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
960 (have_flag(f_ptr->flags, FF_BLDG) && !subject_ptr->current_floor_ptr->inside_arena) ||
961 have_flag(f_ptr->flags, FF_ENTRANCE))
966 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
967 have_flag(f_ptr->flags, FF_TOWN) ||
968 have_flag(f_ptr->flags, FF_SHALLOW) ||
969 have_flag(f_ptr->flags, FF_DEEP))
975 /* Pick proper indefinite article */
976 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
980 /* Display a message */
981 if (current_world_ptr->wizard)
984 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
985 else sprintf(f_idx_str, "%d", g_ptr->feat);
987 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d) %d", s1, name, s2, s3, info, (unsigned int)g_ptr->info, f_idx_str, g_ptr->dist, g_ptr->cost, g_ptr->when, (int)y, (int)x, travel.cost[y][x]);
989 sprintf(out_val, "%s%s%s%s [%s] %x %s %d %d %d (%d,%d)", s1, s2, s3, name, info, g_ptr->info, f_idx_str, g_ptr->dist, g_ptr->cost, g_ptr->when, (int)y, (int)x);
994 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
996 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1000 move_cursor_relative(y, x);
1003 /* Always stop at "normal" keys */
1004 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1007 /* Stop on everything but "return" */
1008 if ((query != '\r') && (query != '\n')) return query;
1010 /* Repeat forever */
1016 * Handle "target" and "look".
1018 * Note that this code can be called from "get_aim_dir()".
1020 * All locations must be on the current panel. Consider the use of
1021 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1022 * some form of "scrolling" the map around the cursor.
1023 * That is, consider the possibility of "auto-scrolling" the screen
1024 * while the cursor moves around. This may require changes in the
1025 * "update_monster()" code to allow "visibility" even if off panel, and
1026 * may require dynamic recalculation of the "temp" grid set.
1028 * Hack -- targeting/observing an "outer border grid" may induce
1029 * problems, so this is not currently allowed.
1031 * The player can use the direction keys to move among "interesting"
1032 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1033 * move through the "interesting" grids in a sequential manner, or
1034 * can enter "location" mode, and use the direction keys to move one
1035 * grid at a time in any direction. The "t" (set target) command will
1036 * only target a monster (as opposed to a location) if the monster is
1037 * target_able and the "interesting" mode is being used.
1039 * The current grid is described using the "look" method above, and
1040 * a new command may be entered at any time, but note that if the
1041 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1042 * where "space" has no obvious meaning) then "space" will scan
1043 * through the description of the current grid until done, instead
1044 * of immediately jumping to the next "interesting" grid. This
1045 * allows the "target" command to retain its old semantics.
1047 * The "*", "+", and "-" keys may always be used to jump immediately
1048 * to the next (or previous) interesting grid, in the proper mode.
1050 * The "return" key may always be used to scan through a complete
1051 * grid description (forever).
1053 * This command will cancel any old target, even if used from
1054 * inside the "look" command.
1056 bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
1059 POSITION y = creature_ptr->y;
1060 POSITION x = creature_ptr->x;
1070 get_screen_size(&wid, &hgt);
1075 if (rogue_like_commands)
1084 /* Prepare the "temp" array */
1085 target_set_prepare(creature_ptr, mode);
1087 /* Start near the player */
1091 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1094 /* Interesting grids */
1095 if (flag && tmp_pos.n)
1101 change_panel_xy(creature_ptr, y, x);
1103 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1106 g_ptr = &floor_ptr->grid_array[y][x];
1109 if (target_able(creature_ptr, g_ptr->m_idx))
1111 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1114 /* Dis-allow target */
1117 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1123 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1124 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x));
1125 strcat(info, cheatinfo);
1128 /* Describe and Prompt */
1131 query = target_set_aux(creature_ptr, y, x, mode, info);
1135 /* Assume no "direction" */
1140 if (query == '\r') query = 't';
1158 if (target_able(creature_ptr, g_ptr->m_idx))
1160 health_track(creature_ptr, g_ptr->m_idx);
1161 target_who = g_ptr->m_idx;
1177 if (++m == tmp_pos.n)
1180 if (!expand_list) done = TRUE;
1190 if (!expand_list) done = TRUE;
1197 /* Recenter the map around the player */
1199 creature_ptr->update |= (PU_MONSTERS);
1200 creature_ptr->redraw |= (PR_MAP);
1201 creature_ptr->window |= (PW_OVERHEAD);
1202 handle_stuff(creature_ptr);
1204 /* Recalculate interesting grids */
1205 target_set_prepare(creature_ptr, mode);
1207 y = creature_ptr->y;
1208 x = creature_ptr->x;
1224 if(query == same_key)
1226 if (++m == tmp_pos.n)
1229 if (!expand_list) done = TRUE;
1234 /* Extract the action (if any) */
1235 d = get_keymap_dir(query);
1242 /* Hack -- move around */
1245 /* Modified to scroll to monster */
1246 POSITION y2 = panel_row_min;
1247 POSITION x2 = panel_col_min;
1249 /* Find a new monster */
1250 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1252 /* Request to target past last interesting grid */
1253 while (flag && (i < 0))
1255 /* Note the change */
1256 if (change_panel(creature_ptr, ddy[d], ddx[d]))
1258 int v = tmp_pos.y[m];
1259 int u = tmp_pos.x[m];
1261 /* Recalculate interesting grids */
1262 target_set_prepare(creature_ptr, mode);
1264 /* Look at interesting grids */
1267 /* Find a new monster */
1268 i = target_pick(v, u, ddy[d], ddx[d]);
1274 /* Nothing interesting */
1277 POSITION dx = ddx[d];
1278 POSITION dy = ddy[d];
1280 /* Restore previous position */
1283 panel_bounds_center();
1285 creature_ptr->update |= (PU_MONSTERS);
1286 creature_ptr->redraw |= (PR_MAP);
1287 creature_ptr->window |= (PW_OVERHEAD);
1288 handle_stuff(creature_ptr);
1290 /* Recalculate interesting grids */
1291 target_set_prepare(creature_ptr, mode);
1293 /* Look at boring grids */
1300 /* Do not move horizontally if unnecessary */
1301 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1302 ((x > panel_col_min + wid / 2) && (dx < 0)))
1307 /* Do not move vertically if unnecessary */
1308 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1309 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1314 /* Apply the motion */
1315 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1316 (x >= panel_col_min+wid) || (x < panel_col_min))
1318 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1321 /* Slide into legality */
1322 if (x >= floor_ptr->width-1) x = floor_ptr->width - 2;
1323 else if (x <= 0) x = 1;
1325 /* Slide into legality */
1326 if (y >= floor_ptr->height-1) y = floor_ptr->height- 2;
1327 else if (y <= 0) y = 1;
1336 /* Arbitrary grids */
1339 bool move_fast = FALSE;
1341 if (!(mode & TARGET_LOOK)) print_path(creature_ptr, y, x);
1344 g_ptr = &floor_ptr->grid_array[y][x];
1346 /* Default prompt */
1347 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1351 char cheatinfo[100];
1352 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d",
1353 los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x),
1354 projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special);
1355 strcat(info, cheatinfo);
1358 /* Describe and Prompt (enable "TARGET_LOOK") */
1359 while ((query = target_set_aux(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0);
1361 /* Assume no direction */
1366 if (query == '\r') query = 't';
1369 /* Analyze the keypress */
1393 /* Recenter the map around the player */
1395 creature_ptr->update |= (PU_MONSTERS);
1396 creature_ptr->redraw |= (PR_MAP);
1397 creature_ptr->window |= (PW_OVERHEAD);
1398 handle_stuff(creature_ptr);
1400 /* Recalculate interesting grids */
1401 target_set_prepare(creature_ptr, mode);
1403 y = creature_ptr->y;
1404 x = creature_ptr->x;
1423 /* Pick a nearby monster */
1424 for (i = 0; i < tmp_pos.n; i++)
1426 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1436 /* Nothing interesting */
1437 if (bd == 999) flag = FALSE;
1444 /* Extract the action (if any) */
1445 d = get_keymap_dir(query);
1447 /* XTRA HACK MOVEFAST */
1448 if (isupper(query)) move_fast = TRUE;
1455 /* Handle "direction" */
1458 POSITION dx = ddx[d];
1459 POSITION dy = ddy[d];
1461 /* XTRA HACK MOVEFAST */
1464 int mag = MIN(wid / 2, hgt / 2);
1474 /* Do not move horizontally if unnecessary */
1475 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1476 ((x > panel_col_min + wid / 2) && (dx < 0)))
1481 /* Do not move vertically if unnecessary */
1482 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1483 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1488 /* Apply the motion */
1489 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1490 (x >= panel_col_min + wid) || (x < panel_col_min))
1492 if (change_panel(creature_ptr, dy, dx)) target_set_prepare(creature_ptr, mode);
1495 /* Slide into legality */
1496 if (x >= floor_ptr->width-1) x = floor_ptr->width - 2;
1497 else if (x <= 0) x = 1;
1499 /* Slide into legality */
1500 if (y >= floor_ptr->height-1) y = floor_ptr->height- 2;
1501 else if (y <= 0) y = 1;
1509 /* Clear the top line */
1512 /* Recenter the map around the player */
1514 creature_ptr->update |= (PU_MONSTERS);
1515 creature_ptr->redraw |= (PR_MAP);
1516 creature_ptr->window |= (PW_OVERHEAD);
1517 handle_stuff(creature_ptr);
1519 if (!target_who) return FALSE;
1526 * Get an "aiming direction" from the user.
1528 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1529 * "0" for "current target", and "-1" for "entry aborted".
1531 * Note that "Force Target", if set, will pre-empt user interaction,
1532 * if there is a usable target already set.
1534 * Note that confusion over-rides any (explicit?) user choice.
1536 bool get_aim_dir(player_type *creature_ptr, DIRECTION *dp)
1545 /* Global direction */
1548 /* Hack -- auto-target if requested */
1549 if (use_old_target && target_okay(creature_ptr)) dir = 5;
1551 if (repeat_pull(&code))
1556 if (!(code == 5 && !target_okay(creature_ptr)))
1559 dir = (DIRECTION)code;
1562 *dp = (DIRECTION)code;
1564 /* Ask until satisfied */
1567 /* Choose a prompt */
1568 if (!target_okay(creature_ptr))
1570 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1574 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1577 /* Get a command (or Cancel) */
1578 if (!get_com(p, &command, TRUE)) break;
1582 if (command == '\r') command = 't';
1585 /* Convert various keys to "standard" keys */
1588 /* Use current target */
1599 /* Set new target */
1604 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
1610 /* Extract the action (if any) */
1611 dir = get_keymap_dir(command);
1617 /* Verify requested targets */
1618 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
1627 project_length = 0; /* reset to default */
1631 /* Save the direction */
1634 /* Check for confusion */
1635 if (creature_ptr->confused)
1637 /* Random direction */
1638 dir = ddd[randint0(8)];
1641 /* Notice confusion */
1642 if (command_dir != dir)
1645 msg_print(_("あなたは混乱している。", "You are confused."));
1648 /* Save direction */
1651 /* repeat_push(dir); */
1652 repeat_push((COMMAND_CODE)command_dir);
1654 /* A "valid" direction was entered */
1659 bool get_direction(player_type *creature_ptr, DIRECTION *dp, bool allow_under, bool with_steed)
1667 /* Global direction */
1670 if (repeat_pull(&code))
1672 dir = (DIRECTION)code;
1675 *dp = (DIRECTION)code;
1679 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1683 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1686 /* Get a direction */
1691 /* Get a command (or Cancel) */
1692 if (!get_com(prompt, &ch, TRUE)) break;
1695 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1701 /* Look up the direction */
1702 dir = get_keymap_dir(ch);
1708 /* Prevent weirdness */
1709 if ((dir == 5) && (!allow_under)) dir = 0;
1712 if (!dir) return FALSE;
1714 /* Save desired direction */
1717 /* Apply "confusion" */
1718 if (creature_ptr->confused)
1720 /* Standard confusion */
1721 if (randint0(100) < 75)
1723 /* Random direction */
1724 dir = ddd[randint0(8)];
1727 else if (creature_ptr->riding && with_steed)
1729 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1730 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1732 if (MON_CONFUSED(m_ptr))
1734 /* Standard confusion */
1735 if (randint0(100) < 75)
1737 /* Random direction */
1738 dir = ddd[randint0(8)];
1741 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1743 /* Random direction */
1744 dir = ddd[randint0(8)];
1746 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1748 /* Random direction */
1749 dir = ddd[randint0(8)];
1753 /* Notice confusion */
1754 if (command_dir != dir)
1756 if (creature_ptr->confused)
1759 msg_print(_("あなたは混乱している。", "You are confused."));
1763 GAME_TEXT m_name[MAX_NLEN];
1764 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
1766 monster_desc(m_name, m_ptr, 0);
1767 if (MON_CONFUSED(m_ptr))
1769 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1773 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1778 /* Save direction */
1781 /* repeat_push(dir); */
1782 repeat_push((COMMAND_CODE)command_dir);
1789 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
1790 * and place it into "command_dir", unless we already have one.
1792 * This function should be used for all "repeatable" commands, such as
1793 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
1794 * as all commands which must reference a grid adjacent to the player,
1795 * and which may not reference the grid under the player. Note that,
1796 * for example, it is no longer possible to "disarm" or "open" chests
1797 * in the same grid as the player.
1799 * Direction "5" is illegal and will (cleanly) abort the command.
1801 * This function tracks and uses the "global direction", and uses
1802 * that as the "desired direction", to which "confusion" is applied.
1804 bool get_rep_dir(DIRECTION *dp, bool under)
1812 /* Global direction */
1815 if (repeat_pull(&code))
1817 dir = (DIRECTION)code;
1820 *dp = (DIRECTION)code;
1824 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1828 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1831 /* Get a direction */
1836 /* Get a command (or Cancel) */
1837 if (!get_com(prompt, &ch, TRUE)) break;
1840 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1846 /* Look up the direction */
1847 dir = get_keymap_dir(ch);
1853 /* Prevent weirdness */
1854 if ((dir == 5) && (!under)) dir = 0;
1857 if (!dir) return FALSE;
1859 /* Save desired direction */
1862 /* Apply "confusion" */
1863 if (p_ptr->confused)
1865 /* Standard confusion */
1866 if (randint0(100) < 75)
1868 /* Random direction */
1869 dir = ddd[randint0(8)];
1872 else if (p_ptr->riding)
1874 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding];
1875 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1877 if (MON_CONFUSED(m_ptr))
1879 /* Standard confusion */
1880 if (randint0(100) < 75)
1882 /* Random direction */
1883 dir = ddd[randint0(8)];
1886 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1888 /* Random direction */
1889 dir = ddd[randint0(8)];
1891 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1893 /* Random direction */
1894 dir = ddd[randint0(8)];
1898 /* Notice confusion */
1899 if (command_dir != dir)
1901 if (p_ptr->confused)
1904 msg_print(_("あなたは混乱している。", "You are confused."));
1908 GAME_TEXT m_name[MAX_NLEN];
1909 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding];
1911 monster_desc(m_name, m_ptr, 0);
1912 if (MON_CONFUSED(m_ptr))
1914 msg_format(_("%sは混乱している。", "%^s is confused."), m_name);
1918 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1923 /* Save direction */
1926 /* repeat_push(dir); */
1927 repeat_push((COMMAND_CODE)command_dir);
1935 * XAngband: determine if a given location is "interesting"
1936 * based on target_set_accept function.
1938 static bool tgt_pt_accept(POSITION y, POSITION x)
1942 if (!(in_bounds(p_ptr->current_floor_ptr, y, x))) return FALSE;
1944 /* Player grid is always interesting */
1945 if ((y == p_ptr->y) && (x == p_ptr->x)) return TRUE;
1947 if (p_ptr->image) return FALSE;
1949 g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
1951 /* Interesting memorized features */
1952 if (g_ptr->info & (CAVE_MARK))
1955 if (cave_have_flag_grid(g_ptr, FF_LESS)) return TRUE;
1956 if (cave_have_flag_grid(g_ptr, FF_MORE)) return TRUE;
1958 /* Notice quest features */
1959 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return TRUE;
1960 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return TRUE;
1968 * XAngband: Prepare the "temp" array for "tget_pt"
1969 * based on target_set_prepare funciton.
1971 static void tgt_pt_prepare(void)
1975 /* Reset "temp" array */
1978 if (!expand_list) return;
1980 /* Scan the current panel */
1981 for (y = 1; y < p_ptr->current_floor_ptr->height; y++)
1983 for (x = 1; x < p_ptr->current_floor_ptr->width; x++)
1985 /* Require "interesting" contents */
1986 if (!tgt_pt_accept(y, x)) continue;
1988 /* Save the location */
1989 tmp_pos.x[tmp_pos.n] = x;
1990 tmp_pos.y[tmp_pos.n] = y;
1995 /* Sort the positions */
1996 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
2000 * old -- from PsiAngband.
2002 bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr)
2007 bool success = FALSE;
2011 get_screen_size(&wid, &hgt);
2013 x = creature_ptr->x;
2014 y = creature_ptr->y;
2021 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2022 msg_flag = FALSE; /* prevents "-more-" message. */
2024 while ((ch != ESCAPE) && !success)
2026 bool move_fast = FALSE;
2028 move_cursor_relative(y, x);
2040 if (player_bold(creature_ptr, y, x)) ch = 0;
2043 else success = TRUE;
2047 /* XAngband: Move cursor to stairs */
2050 if (expand_list && tmp_pos.n)
2053 int cx = (panel_col_min + panel_col_max) / 2;
2054 int cy = (panel_row_min + panel_row_max) / 2;
2058 /* Skip stairs which have defferent distance */
2059 for (; n < tmp_pos.n; ++ n)
2061 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2063 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2064 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2071 if (n == tmp_pos.n) /* Loop out taget list */
2074 y = creature_ptr->y;
2075 x = creature_ptr->x;
2076 verify_panel(); /* Move cursor to player */
2078 creature_ptr->update |= (PU_MONSTERS);
2080 creature_ptr->redraw |= (PR_MAP);
2082 creature_ptr->window |= (PW_OVERHEAD);
2083 handle_stuff(creature_ptr);
2085 else /* move cursor to next stair and change panel */
2090 dy = 2 * (y - cy) / hgt;
2091 dx = 2 * (x - cx) / wid;
2092 if (dy || dx) change_panel(creature_ptr, dy, dx);
2098 /* Look up the direction */
2099 d = get_keymap_dir(ch);
2101 /* XTRA HACK MOVEFAST */
2102 if (isupper(ch)) move_fast = TRUE;
2104 /* Handle "direction" */
2110 /* XTRA HACK MOVEFAST */
2113 int mag = MIN(wid / 2, hgt / 2);
2123 /* Do not move horizontally if unnecessary */
2124 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2125 ((x > panel_col_min + wid / 2) && (dx < 0)))
2130 /* Do not move vertically if unnecessary */
2131 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2132 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2137 /* Apply the motion */
2138 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2139 (x >= panel_col_min + wid) || (x < panel_col_min))
2141 change_panel(creature_ptr, dy, dx);
2144 /* Slide into legality */
2145 if (x >= creature_ptr->current_floor_ptr->width-1) x = creature_ptr->current_floor_ptr->width - 2;
2146 else if (x <= 0) x = 1;
2148 /* Slide into legality */
2149 if (y >= creature_ptr->current_floor_ptr->height-1) y = creature_ptr->current_floor_ptr->height- 2;
2150 else if (y <= 0) y = 1;
2157 /* Clear the top line */
2160 /* Recenter the map around the player */
2163 creature_ptr->update |= (PU_MONSTERS);
2165 creature_ptr->redraw |= (PR_MAP);
2167 creature_ptr->window |= (PW_OVERHEAD);
2168 handle_stuff(creature_ptr);
2176 bool get_hack_dir(player_type *creature_ptr, DIRECTION *dp)
2184 /* Global direction */
2187 /* (No auto-targeting) */
2189 /* Ask until satisfied */
2192 /* Choose a prompt */
2193 if (!target_okay(creature_ptr))
2195 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2199 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2202 /* Get a command (or Cancel) */
2203 if (!get_com(p, &command, TRUE)) break;
2207 if (command == '\r') command = 't';
2210 /* Convert various keys to "standard" keys */
2213 /* Use current target */
2224 /* Set new target */
2229 if (target_set(creature_ptr, TARGET_KILL)) dir = 5;
2235 /* Look up the direction */
2236 dir = get_keymap_dir(command);
2242 /* Verify requested targets */
2243 if ((dir == 5) && !target_okay(creature_ptr)) dir = 0;
2250 if (!dir) return FALSE;
2252 /* Save the direction */
2255 /* Check for confusion */
2256 if (creature_ptr->confused)
2258 /* Random direction */
2259 dir = ddd[randint0(8)];
2262 /* Notice confusion */
2263 if (command_dir != dir)
2266 msg_print(_("あなたは混乱している。", "You are confused."));
2269 /* Save direction */
2272 /* A "valid" direction was entered */