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 "object-curse.h"
18 #include "monsterrace-hook.h"
19 #include "objectkind-hook.h"
21 #include "projection.h"
22 #include "spells-summon.h"
23 #include "floor-events.h"
24 #include "player-move.h"
25 #include "monster-status.h"
27 #define REWARD_CHANCE 10
32 * @brief 現在のコンソール表示の縦横を返す。 /
33 * Get term size and calculate screen size
34 * @param wid_p コンソールの表示幅文字数を返す
35 * @param hgt_p コンソールの表示行数を返す
38 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
40 Term_get_size(wid_p, hgt_p);
41 *hgt_p -= ROW_MAP + 2;
42 *wid_p -= COL_MAP + 2;
43 if (use_bigtile) *wid_p /= 2;
48 * @brief コンソール上におけるマップ表示の左上位置を返す /
49 * Calculates current boundaries Called below and from "do_cmd_locate()".
52 void panel_bounds_center(void)
56 get_screen_size(&wid, &hgt);
58 panel_row_max = panel_row_min + hgt - 1;
59 panel_row_prt = panel_row_min - 1;
60 panel_col_max = panel_col_min + wid - 1;
61 panel_col_prt = panel_col_min - 13;
65 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
69 * Handle a request to change the current panel
70 * Return TRUE if the panel was changed.
71 * Also used in do_cmd_locate
72 * @return 実際に再描画が必要だった場合TRUEを返す
74 static bool change_panel_xy(POSITION y, POSITION x)
76 POSITION dy = 0, dx = 0;
79 get_screen_size(&wid, &hgt);
81 if (y < panel_row_min) dy = -1;
82 if (y > panel_row_max) dy = 1;
83 if (x < panel_col_min) dx = -1;
84 if (x > panel_col_max) dx = 1;
86 if (!dy && !dx) return (FALSE);
88 return change_panel(dy, dx);
93 * @brief マップ描画のフォーカスを当てるべき座標を更新する
95 * Given an row (y) and col (x), this routine detects when a move
96 * off the screen has occurred and figures new borders. -RAK-
97 * "Update" forces a "full update" to take place.
98 * The map is reprinted if necessary, and "TRUE" is returned.
99 * @return 実際に再描画が必要だった場合TRUEを返す
101 void verify_panel(void)
103 POSITION y = p_ptr->y;
104 POSITION x = p_ptr->x;
112 get_screen_size(&wid, &hgt);
114 max_prow_min = current_floor_ptr->height - hgt;
115 max_pcol_min = current_floor_ptr->width - wid;
117 /* Bounds checking */
118 if (max_prow_min < 0) max_prow_min = 0;
119 if (max_pcol_min < 0) max_pcol_min = 0;
121 /* Center on player */
122 if (center_player && (center_running || !running))
124 /* Center vertically */
125 prow_min = y - hgt / 2;
126 if (prow_min < 0) prow_min = 0;
127 else if (prow_min > max_prow_min) prow_min = max_prow_min;
129 /* Center horizontally */
130 pcol_min = x - wid / 2;
131 if (pcol_min < 0) pcol_min = 0;
132 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
136 prow_min = panel_row_min;
137 pcol_min = panel_col_min;
139 /* Scroll screen when 2 grids from top/bottom edge */
140 if (y > panel_row_max - 2)
142 while (y > prow_min + hgt-1 - 2)
144 prow_min += (hgt / 2);
148 if (y < panel_row_min + 2)
150 while (y < prow_min + 2)
152 prow_min -= (hgt / 2);
156 if (prow_min > max_prow_min) prow_min = max_prow_min;
157 if (prow_min < 0) prow_min = 0;
159 /* Scroll screen when 4 grids from left/right edge */
160 if (x > panel_col_max - 4)
162 while (x > pcol_min + wid-1 - 4)
164 pcol_min += (wid / 2);
168 if (x < panel_col_min + 4)
170 while (x < pcol_min + 4)
172 pcol_min -= (wid / 2);
176 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
177 if (pcol_min < 0) pcol_min = 0;
180 /* Check for "no change" */
181 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
183 /* Save the new panel info */
184 panel_row_min = prow_min;
185 panel_col_min = pcol_min;
187 /* Hack -- optional disturb on "panel change" */
188 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
190 /* Recalculate the boundaries */
191 panel_bounds_center();
193 p_ptr->update |= (PU_MONSTERS);
194 p_ptr->redraw |= (PR_MAP);
195 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
200 * Monster health description
202 concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
204 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
211 /* Determine if the monster is "living" */
212 living = monster_living(m_ptr->ap_r_idx);
214 /* Calculate a health "percentage" */
215 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
217 /* Healthy monsters */
218 if (m_ptr->hp >= m_ptr->maxhp)
220 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
225 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
230 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
235 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
240 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
243 /* Need attitude information? */
246 /* Full information is not needed */
249 else if (is_pet(m_ptr))
251 attitude = _(", ペット", ", pet");
253 else if (is_friendly(m_ptr))
255 attitude = _(", 友好的", ", friendly");
259 attitude = _("", "");
263 if (m_ptr->smart & SM_CLONED)
272 /* Display monster's level --- idea borrowed from ToME */
273 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
275 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
279 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
286 /*** Targeting Code ***/
290 * Determine is a monster makes a reasonable target
292 * The concept of "targeting" was stolen from "Morgul" (?)
294 * The player can target any location, or any "target-able" monster.
296 * Currently, a monster is "target_able" if it is visible, and if
297 * the player can hit it with a projection, and the player is not
298 * hallucinating. This allows use of "use closest target" macros.
300 * Future versions may restrict the ability to target "trappers"
301 * and "mimics", but the semantics is a little bit weird.
303 bool target_able(MONSTER_IDX m_idx)
305 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
307 /* Monster must be alive */
308 if (!monster_is_valid(m_ptr)) return (FALSE);
310 /* Hack -- no targeting hallucinations */
311 if (p_ptr->image) return (FALSE);
313 /* Monster must be visible */
314 if (!m_ptr->ml) return (FALSE);
316 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
318 /* Monster must be projectable */
319 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
321 /* Hack -- Never target trappers */
322 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
332 * Update (if necessary) and verify (if possible) the target.
334 * We return TRUE if the target is "okay" and FALSE otherwise.
336 bool target_okay(void)
338 /* Accept stationary targets */
339 if (target_who < 0) return (TRUE);
341 /* Check moving targets */
344 /* Accept reasonable targets */
345 if (target_able(target_who))
347 monster_type *m_ptr = ¤t_floor_ptr->m_list[target_who];
349 /* Acquire monster location */
350 target_row = m_ptr->fy;
351 target_col = m_ptr->fx;
358 /* Assume no target */
364 * Sorting hook -- comp function -- by "distance to player"
366 * We use "u" and "v" to point to arrays of "x" and "y" positions,
367 * and sort the arrays by double-distance to the player.
369 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
371 POSITION *x = (POSITION*)(u);
372 POSITION *y = (POSITION*)(v);
374 POSITION da, db, kx, ky;
376 /* Absolute distance components */
377 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
378 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
380 /* Approximate Double Distance to the first point */
381 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
383 /* Absolute distance components */
384 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
385 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
387 /* Approximate Double Distance to the first point */
388 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
390 /* Compare the distances */
396 * Sorting hook -- comp function -- by importance level of grids
398 * We use "u" and "v" to point to arrays of "x" and "y" positions,
399 * and sort the arrays by level of monster
401 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
403 POSITION *x = (POSITION*)(u);
404 POSITION *y = (POSITION*)(v);
405 grid_type *ca_ptr = ¤t_floor_ptr->grid_array[y[a]][x[a]];
406 grid_type *cb_ptr = ¤t_floor_ptr->grid_array[y[b]][x[b]];
407 monster_type *ma_ptr = ¤t_floor_ptr->m_list[ca_ptr->m_idx];
408 monster_type *mb_ptr = ¤t_floor_ptr->m_list[cb_ptr->m_idx];
409 monster_race *ap_ra_ptr, *ap_rb_ptr;
411 /* The player grid */
412 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
413 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
415 /* Extract monster race */
416 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
417 else ap_ra_ptr = NULL;
418 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
419 else ap_rb_ptr = NULL;
421 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
422 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
424 /* Compare two monsters */
425 if (ap_ra_ptr && ap_rb_ptr)
427 /* Unique monsters first */
428 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
429 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
431 /* Shadowers first (あやしい影) */
432 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
433 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
435 /* Unknown monsters first */
436 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
437 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
439 /* Higher level monsters first (if known) */
440 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
442 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
443 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
446 /* Sort by index if all conditions are same */
447 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
448 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
451 /* An object get higher priority */
452 if (current_floor_ptr->grid_array[y[a]][x[a]].o_idx && !current_floor_ptr->grid_array[y[b]][x[b]].o_idx) return TRUE;
453 if (!current_floor_ptr->grid_array[y[a]][x[a]].o_idx && current_floor_ptr->grid_array[y[b]][x[b]].o_idx) return FALSE;
455 /* Priority from the terrain */
456 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
457 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
459 /* If all conditions are same, compare distance */
460 return ang_sort_comp_distance(u, v, a, b);
465 * Sorting hook -- swap function -- by "distance to player"
467 * We use "u" and "v" to point to arrays of "x" and "y" positions,
468 * and sort the arrays by distance to the player.
470 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
472 POSITION *x = (POSITION*)(u);
473 POSITION *y = (POSITION*)(v);
491 * Hack -- help "select" a location (see below)
493 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
496 POSITION x2, y2, x3, y3, x4, y4;
497 POSITION_IDX b_i = -1, b_v = 9999;
500 /* Scan the locations */
501 for (i = 0; i < tmp_pos.n; i++)
507 /* Directed distance */
511 /* Verify quadrant */
512 if (dx && (x3 * dx <= 0)) continue;
513 if (dy && (y3 * dy <= 0)) continue;
515 /* Absolute distance */
519 /* Verify quadrant */
520 if (dy && !dx && (x4 > y4)) continue;
521 if (dx && !dy && (y4 > x4)) continue;
523 /* Approximate Double Distance */
524 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
526 /* Penalize location */
529 if ((b_i >= 0) && (v >= b_v)) continue;
539 * Hack -- determine if a given location is "interesting"
541 static bool target_set_accept(POSITION y, POSITION x)
544 OBJECT_IDX this_o_idx, next_o_idx = 0;
547 if (!(in_bounds(y, x))) return (FALSE);
549 /* Player grid is always interesting */
550 if (player_bold(y, x)) return (TRUE);
552 /* Handle hallucination */
553 if (p_ptr->image) return (FALSE);
555 /* Examine the grid */
556 g_ptr = ¤t_floor_ptr->grid_array[y][x];
558 /* Visible monsters */
561 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
563 /* Visible monsters */
564 if (m_ptr->ml) return (TRUE);
567 /* Scan all objects in the grid */
568 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
571 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
572 next_o_idx = o_ptr->next_o_idx;
574 /* Memorized object */
575 if (o_ptr->marked & OM_FOUND) return (TRUE);
578 /* Interesting memorized features */
579 if (g_ptr->info & (CAVE_MARK))
581 /* Notice object features */
582 if (g_ptr->info & CAVE_OBJECT) return (TRUE);
584 /* Feature code (applying "mimic" field) */
585 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
593 * Prepare the "temp" array for "target_set"
595 * Return the number of target_able monsters in the set.
597 static void target_set_prepare(BIT_FLAGS mode)
600 POSITION min_hgt, max_hgt, min_wid, max_wid;
602 if (mode & TARGET_KILL)
605 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
606 max_hgt = MIN((p_ptr->y + MAX_RANGE), current_floor_ptr->height - 1);
607 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
608 max_wid = MIN((p_ptr->x + MAX_RANGE), current_floor_ptr->width - 1);
610 else /* not targetting */
613 min_hgt = panel_row_min;
614 max_hgt = panel_row_max;
615 min_wid = panel_col_min;
616 max_wid = panel_col_max;
619 /* Reset "temp" array */
622 /* Scan the current panel */
623 for (y = min_hgt; y <= max_hgt; y++)
625 for (x = min_wid; x <= max_wid; x++)
629 /* Require "interesting" contents */
630 if (!target_set_accept(y, x)) continue;
632 g_ptr = ¤t_floor_ptr->grid_array[y][x];
634 /* Require target_able monsters for "TARGET_KILL" */
635 if ((mode & (TARGET_KILL)) && !target_able(g_ptr->m_idx)) continue;
637 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(¤t_floor_ptr->m_list[g_ptr->m_idx])) continue;
639 /* Save the location */
640 tmp_pos.x[tmp_pos.n] = x;
641 tmp_pos.y[tmp_pos.n] = y;
646 /* Set the sort hooks */
647 if (mode & (TARGET_KILL))
649 /* Target the nearest monster for shooting */
650 ang_sort_comp = ang_sort_comp_distance;
651 ang_sort_swap = ang_sort_swap_distance;
655 /* Look important grids first in Look command */
656 ang_sort_comp = ang_sort_comp_importance;
657 ang_sort_swap = ang_sort_swap_distance;
660 /* Sort the positions */
661 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
663 if (p_ptr->riding && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
668 tmp_pos.y[0] = tmp_pos.y[1];
671 tmp_pos.x[0] = tmp_pos.x[1];
676 void target_set_prepare_look(void){
677 target_set_prepare(TARGET_LOOK);
682 * Evaluate number of kill needed to gain level
684 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
686 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
688 s32b exp_mon, exp_adv;
689 u32b exp_mon_frac, exp_adv_frac;
691 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
696 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
706 /* The monster's experience point (assuming average monster speed) */
707 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
709 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
712 /* Total experience value for next level */
713 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
715 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
717 /* Experience value need to get */
718 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
721 /* You need to kill at least one monster to get any experience */
722 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
723 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
725 /* Extract number of monsters needed */
726 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
728 /* If 999 or more monsters needed, only display "999". */
729 num = MIN(999, exp_adv_frac);
731 /* Display the number */
732 sprintf(buf,"%03ld", (long int)num);
736 bool show_gold_on_floor = FALSE;
739 * Examine a grid, return a keypress.
741 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
742 * indicates that the "space" key should scan through the contents
743 * of the grid, instead of simply returning immediately. This lets
744 * the "look" command get complete information, without making the
745 * "target" command annoying.
747 * The "info" argument contains the "commands" which should be shown
748 * inside the "[xxx]" text. This string must never be empty, or grids
749 * containing monsters will be displayed with an extra comma.
751 * Note that if a monster is in the grid, we update both the monster
752 * recall info and the health bar info to track that monster.
754 * Eventually, we may allow multiple objects per grid, or objects
755 * and terrain features in the same grid.
757 * This function must handle blindness/hallucination.
759 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
761 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
762 OBJECT_IDX this_o_idx, next_o_idx = 0;
763 concptr s1 = "", s2 = "", s3 = "", x_info = "";
768 char out_val[MAX_NLEN+80];
769 OBJECT_IDX floor_list[23];
770 ITEM_NUMBER floor_num = 0;
772 /* Scan all objects in the grid */
775 floor_num = scan_floor(floor_list, y, x, 0x02);
779 x_info = _("x物 ", "x,");
783 /* Hack -- under the player */
784 if (player_bold(y, x))
797 s1 = _("ターゲット:", "Target:");
800 /* Hack -- hallucination */
803 concptr name = _("何か奇妙な物", "something strange");
805 /* Display a message */
807 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
809 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
813 move_cursor_relative(y, x);
816 /* Stop on everything but "return" */
817 if ((query != '\r') && (query != '\n')) return query;
824 /* Actual monsters */
825 if (g_ptr->m_idx && current_floor_ptr->m_list[g_ptr->m_idx].ml)
827 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
828 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
829 GAME_TEXT m_name[MAX_NLEN];
835 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
836 monster_race_track(m_ptr->ap_r_idx);
837 health_track(g_ptr->m_idx);
850 /* Recall on screen */
851 screen_roff(m_ptr->ap_r_idx, 0);
853 /* Hack -- Complete the prompt (again) */
854 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
861 /* Normal commands */
862 if (query != 'r') break;
867 /* Cleare recall text and repeat */
873 /* Describe, and prompt for recall */
874 evaluate_monster_exp(acount, m_ptr);
877 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);
879 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);
885 move_cursor_relative(y, x);
890 /* Normal commands */
891 if (query != 'r') break;
897 /* Always stop at "normal" keys */
898 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
900 /* Sometimes stop at "space" key */
901 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
903 /* Change the intro */
904 s1 = _("それは", "It is ");
906 /* Hack -- take account of gender */
907 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
908 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
910 /* Use a preposition */
919 /* Scan all objects being carried */
920 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
922 GAME_TEXT o_name[MAX_NLEN];
925 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
926 next_o_idx = o_ptr->next_o_idx;
928 /* Obtain an object description */
929 object_desc(o_name, o_ptr, 0);
932 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
934 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
938 move_cursor_relative(y, x);
941 /* Always stop at "normal" keys */
942 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
944 /* Sometimes stop at "space" key */
945 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
947 /* Change the intro */
948 s2 = _("をまた", "also carrying ");
951 /* Use a preposition */
968 GAME_TEXT o_name[MAX_NLEN];
971 o_ptr = ¤t_floor_ptr->o_list[floor_list[0]];
973 object_desc(o_name, o_ptr, 0);
976 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
978 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
982 move_cursor_relative(y, x);
991 /* Provide one cushion before item listing */
994 /* Display rough information about items */
996 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
998 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
1002 move_cursor_relative(y, x);
1007 /* No request for listing */
1008 if (query != 'x' && query != ' ') return query;
1012 /** Display list of items **/
1014 /* Continue scrolling list if requested */
1022 show_gold_on_floor = TRUE;
1023 (void)show_floor(0, y, x, &min_width);
1024 show_gold_on_floor = FALSE;
1028 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
1030 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
1037 /* Exit unless 'Enter' */
1038 if (query != '\n' && query != '\r')
1043 /* Get the object being moved. */
1044 o_idx = g_ptr->o_idx;
1046 /* Only rotate a pile of two or more objects. */
1047 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
1049 /* Remove the first object from the list. */
1050 excise_object_idx(o_idx);
1052 /* Find end of the list. */
1054 while (current_floor_ptr->o_list[i].next_o_idx)
1055 i = current_floor_ptr->o_list[i].next_o_idx;
1057 /* Add after the last object. */
1058 current_floor_ptr->o_list[i].next_o_idx = o_idx;
1060 /* Loop and re-display the list */
1067 /* Scan all objects in the grid */
1068 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1071 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
1072 next_o_idx = o_ptr->next_o_idx;
1074 if (o_ptr->marked & OM_FOUND)
1076 GAME_TEXT o_name[MAX_NLEN];
1081 /* Obtain an object description */
1082 object_desc(o_name, o_ptr, 0);
1085 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1087 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1091 move_cursor_relative(y, x);
1094 /* Always stop at "normal" keys */
1095 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1097 /* Sometimes stop at "space" key */
1098 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
1100 /* Change the intro */
1101 s1 = _("それは", "It is ");
1104 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
1118 /* Feature code (applying "mimic" field) */
1119 feat = get_feat_mimic(g_ptr);
1121 /* Require knowledge about grid, or ability to see grid */
1122 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
1124 /* Forget feature */
1128 f_ptr = &f_info[feat];
1130 /* Terrain feature if needed */
1131 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
1135 /* Hack -- special handling for quest entrances */
1136 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
1138 /* Set the quest number temporary */
1139 IDX old_quest = p_ptr->inside_quest;
1142 /* Clear the text */
1143 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
1144 quest_text_line = 0;
1146 p_ptr->inside_quest = g_ptr->special;
1148 /* Get the quest text */
1149 init_flags = INIT_NAME_ONLY;
1151 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
1153 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
1154 quest[g_ptr->special].name, quest[g_ptr->special].level);
1156 /* Reset the old quest number */
1157 p_ptr->inside_quest = old_quest;
1160 /* Hack -- special handling for building doors */
1161 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
1163 name = building[f_ptr->subtype].name;
1165 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
1167 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
1169 else if (have_flag(f_ptr->flags, FF_TOWN))
1171 name = town_info[g_ptr->special].name;
1173 else if (p_ptr->wild_mode && (feat == feat_floor))
1175 name = _("道", "road");
1179 name = f_name + f_ptr->name;
1185 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
1186 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
1187 have_flag(f_ptr->flags, FF_TOWN)))
1189 s2 = _("の中", "in ");
1192 /* Hack -- special introduction for store & building doors -KMW- */
1193 if (have_flag(f_ptr->flags, FF_STORE) ||
1194 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
1195 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
1196 have_flag(f_ptr->flags, FF_ENTRANCE))
1201 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
1202 have_flag(f_ptr->flags, FF_TOWN) ||
1203 have_flag(f_ptr->flags, FF_SHALLOW) ||
1204 have_flag(f_ptr->flags, FF_DEEP))
1210 /* Pick proper indefinite article */
1211 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
1215 /* Display a message */
1219 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
1220 else sprintf(f_idx_str, "%d", g_ptr->feat);
1222 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]);
1224 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);
1229 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
1231 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1235 move_cursor_relative(y, x);
1238 /* Always stop at "normal" keys */
1239 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1242 /* Stop on everything but "return" */
1243 if ((query != '\r') && (query != '\n')) return query;
1245 /* Repeat forever */
1251 * Handle "target" and "look".
1253 * Note that this code can be called from "get_aim_dir()".
1255 * All locations must be on the current panel. Consider the use of
1256 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1257 * some form of "scrolling" the map around the cursor.
1258 * That is, consider the possibility of "auto-scrolling" the screen
1259 * while the cursor moves around. This may require changes in the
1260 * "update_monster()" code to allow "visibility" even if off panel, and
1261 * may require dynamic recalculation of the "temp" grid set.
1263 * Hack -- targeting/observing an "outer border grid" may induce
1264 * problems, so this is not currently allowed.
1266 * The player can use the direction keys to move among "interesting"
1267 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1268 * move through the "interesting" grids in a sequential manner, or
1269 * can enter "location" mode, and use the direction keys to move one
1270 * grid at a time in any direction. The "t" (set target) command will
1271 * only target a monster (as opposed to a location) if the monster is
1272 * target_able and the "interesting" mode is being used.
1274 * The current grid is described using the "look" method above, and
1275 * a new command may be entered at any time, but note that if the
1276 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1277 * where "space" has no obvious meaning) then "space" will scan
1278 * through the description of the current grid until done, instead
1279 * of immediately jumping to the next "interesting" grid. This
1280 * allows the "target" command to retain its old semantics.
1282 * The "*", "+", and "-" keys may always be used to jump immediately
1283 * to the next (or previous) interesting grid, in the proper mode.
1285 * The "return" key may always be used to scan through a complete
1286 * grid description (forever).
1288 * This command will cancel any old target, even if used from
1289 * inside the "look" command.
1291 bool target_set(BIT_FLAGS mode)
1294 POSITION y = p_ptr->y;
1295 POSITION x = p_ptr->x;
1305 get_screen_size(&wid, &hgt);
1310 if (rogue_like_commands)
1319 /* Prepare the "temp" array */
1320 target_set_prepare(mode);
1322 /* Start near the player */
1328 /* Interesting grids */
1329 if (flag && tmp_pos.n)
1335 change_panel_xy(y, x);
1337 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1340 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1343 if (target_able(g_ptr->m_idx))
1345 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1348 /* Dis-allow target */
1351 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1357 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1358 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
1359 strcat(info, cheatinfo);
1362 /* Describe and Prompt */
1364 query = target_set_aux(y, x, mode, info);
1368 /* Assume no "direction" */
1373 if (query == '\r') query = 't';
1391 if (target_able(g_ptr->m_idx))
1393 health_track(g_ptr->m_idx);
1394 target_who = g_ptr->m_idx;
1410 if (++m == tmp_pos.n)
1413 if (!expand_list) done = TRUE;
1423 if (!expand_list) done = TRUE;
1430 /* Recenter the map around the player */
1432 p_ptr->update |= (PU_MONSTERS);
1433 p_ptr->redraw |= (PR_MAP);
1434 p_ptr->window |= (PW_OVERHEAD);
1437 /* Recalculate interesting grids */
1438 target_set_prepare(mode);
1457 if(query == same_key)
1459 if (++m == tmp_pos.n)
1462 if (!expand_list) done = TRUE;
1467 /* Extract the action (if any) */
1468 d = get_keymap_dir(query);
1475 /* Hack -- move around */
1478 /* Modified to scroll to monster */
1479 POSITION y2 = panel_row_min;
1480 POSITION x2 = panel_col_min;
1482 /* Find a new monster */
1483 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1485 /* Request to target past last interesting grid */
1486 while (flag && (i < 0))
1488 /* Note the change */
1489 if (change_panel(ddy[d], ddx[d]))
1491 int v = tmp_pos.y[m];
1492 int u = tmp_pos.x[m];
1494 /* Recalculate interesting grids */
1495 target_set_prepare(mode);
1497 /* Look at interesting grids */
1500 /* Find a new monster */
1501 i = target_pick(v, u, ddy[d], ddx[d]);
1507 /* Nothing interesting */
1510 POSITION dx = ddx[d];
1511 POSITION dy = ddy[d];
1513 /* Restore previous position */
1516 panel_bounds_center();
1518 p_ptr->update |= (PU_MONSTERS);
1519 p_ptr->redraw |= (PR_MAP);
1520 p_ptr->window |= (PW_OVERHEAD);
1523 /* Recalculate interesting grids */
1524 target_set_prepare(mode);
1526 /* Look at boring grids */
1533 /* Do not move horizontally if unnecessary */
1534 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1535 ((x > panel_col_min + wid / 2) && (dx < 0)))
1540 /* Do not move vertically if unnecessary */
1541 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1542 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1547 /* Apply the motion */
1548 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1549 (x >= panel_col_min+wid) || (x < panel_col_min))
1551 if (change_panel(dy, dx)) target_set_prepare(mode);
1554 /* Slide into legality */
1555 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1556 else if (x <= 0) x = 1;
1558 /* Slide into legality */
1559 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1560 else if (y <= 0) y = 1;
1569 /* Arbitrary grids */
1572 bool move_fast = FALSE;
1574 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1577 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1579 /* Default prompt */
1580 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1585 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1586 los(p_ptr->y, p_ptr->x, y, x),
1587 projectable(p_ptr->y, p_ptr->x, y, x));
1588 strcat(info, cheatinfo);
1591 /* Describe and Prompt (enable "TARGET_LOOK") */
1592 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
1594 /* Assume no direction */
1599 if (query == '\r') query = 't';
1602 /* Analyze the keypress */
1626 /* Recenter the map around the player */
1628 p_ptr->update |= (PU_MONSTERS);
1629 p_ptr->redraw |= (PR_MAP);
1630 p_ptr->window |= (PW_OVERHEAD);
1633 /* Recalculate interesting grids */
1634 target_set_prepare(mode);
1656 /* Pick a nearby monster */
1657 for (i = 0; i < tmp_pos.n; i++)
1659 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1669 /* Nothing interesting */
1670 if (bd == 999) flag = FALSE;
1677 /* Extract the action (if any) */
1678 d = get_keymap_dir(query);
1680 /* XTRA HACK MOVEFAST */
1681 if (isupper(query)) move_fast = TRUE;
1688 /* Handle "direction" */
1691 POSITION dx = ddx[d];
1692 POSITION dy = ddy[d];
1694 /* XTRA HACK MOVEFAST */
1697 int mag = MIN(wid / 2, hgt / 2);
1707 /* Do not move horizontally if unnecessary */
1708 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1709 ((x > panel_col_min + wid / 2) && (dx < 0)))
1714 /* Do not move vertically if unnecessary */
1715 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1716 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1721 /* Apply the motion */
1722 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1723 (x >= panel_col_min + wid) || (x < panel_col_min))
1725 if (change_panel(dy, dx)) target_set_prepare(mode);
1728 /* Slide into legality */
1729 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1730 else if (x <= 0) x = 1;
1732 /* Slide into legality */
1733 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1734 else if (y <= 0) y = 1;
1742 /* Clear the top line */
1745 /* Recenter the map around the player */
1747 p_ptr->update |= (PU_MONSTERS);
1748 p_ptr->redraw |= (PR_MAP);
1749 p_ptr->window |= (PW_OVERHEAD);
1752 /* Failure to set target */
1753 if (!target_who) return (FALSE);
1761 * Get an "aiming direction" from the user.
1763 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1764 * "0" for "current target", and "-1" for "entry aborted".
1766 * Note that "Force Target", if set, will pre-empt user interaction,
1767 * if there is a usable target already set.
1769 * Note that confusion over-rides any (explicit?) user choice.
1771 bool get_aim_dir(DIRECTION *dp)
1780 /* Global direction */
1783 /* Hack -- auto-target if requested */
1784 if (use_old_target && target_okay()) dir = 5;
1786 if (repeat_pull(&code))
1791 if (!(code == 5 && !target_okay()))
1793 /* return (TRUE); */
1794 dir = (DIRECTION)code;
1797 *dp = (DIRECTION)code;
1799 /* Ask until satisfied */
1802 /* Choose a prompt */
1805 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1809 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1812 /* Get a command (or Cancel) */
1813 if (!get_com(p, &command, TRUE)) break;
1817 if (command == '\r') command = 't';
1820 /* Convert various keys to "standard" keys */
1823 /* Use current target */
1834 /* Set new target */
1839 if (target_set(TARGET_KILL)) dir = 5;
1845 /* Extract the action (if any) */
1846 dir = get_keymap_dir(command);
1852 /* Verify requested targets */
1853 if ((dir == 5) && !target_okay()) dir = 0;
1862 project_length = 0; /* reset to default */
1866 /* Save the direction */
1869 /* Check for confusion */
1870 if (p_ptr->confused)
1872 /* Random direction */
1873 dir = ddd[randint0(8)];
1876 /* Notice confusion */
1877 if (command_dir != dir)
1880 msg_print(_("あなたは混乱している。", "You are confused."));
1883 /* Save direction */
1886 /* repeat_push(dir); */
1887 repeat_push((COMMAND_CODE)command_dir);
1889 /* A "valid" direction was entered */
1894 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
1902 /* Global direction */
1905 if (repeat_pull(&code))
1907 dir = (DIRECTION)code;
1908 /* return (TRUE); */
1910 *dp = (DIRECTION)code;
1914 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1918 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1921 /* Get a direction */
1926 /* Get a command (or Cancel) */
1927 if (!get_com(prompt, &ch, TRUE)) break;
1930 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1936 /* Look up the direction */
1937 dir = get_keymap_dir(ch);
1943 /* Prevent weirdness */
1944 if ((dir == 5) && (!allow_under)) dir = 0;
1947 if (!dir) return (FALSE);
1949 /* Save desired direction */
1952 /* Apply "confusion" */
1953 if (p_ptr->confused)
1955 /* Standard confusion */
1956 if (randint0(100) < 75)
1958 /* Random direction */
1959 dir = ddd[randint0(8)];
1962 else if (p_ptr->riding && with_steed)
1964 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1965 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1967 if (MON_CONFUSED(m_ptr))
1969 /* Standard confusion */
1970 if (randint0(100) < 75)
1972 /* Random direction */
1973 dir = ddd[randint0(8)];
1976 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1978 /* Random direction */
1979 dir = ddd[randint0(8)];
1981 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1983 /* Random direction */
1984 dir = ddd[randint0(8)];
1988 /* Notice confusion */
1989 if (command_dir != dir)
1991 if (p_ptr->confused)
1994 msg_print(_("あなたは混乱している。", "You are confused."));
1998 GAME_TEXT m_name[MAX_NLEN];
1999 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2001 monster_desc(m_name, m_ptr, 0);
2002 if (MON_CONFUSED(m_ptr))
2004 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2008 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2013 /* Save direction */
2016 /* repeat_push(dir); */
2017 repeat_push((COMMAND_CODE)command_dir);
2024 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
2025 * and place it into "command_dir", unless we already have one.
2027 * This function should be used for all "repeatable" commands, such as
2028 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
2029 * as all commands which must reference a grid adjacent to the player,
2030 * and which may not reference the grid under the player. Note that,
2031 * for example, it is no longer possible to "disarm" or "open" chests
2032 * in the same grid as the player.
2034 * Direction "5" is illegal and will (cleanly) abort the command.
2036 * This function tracks and uses the "global direction", and uses
2037 * that as the "desired direction", to which "confusion" is applied.
2039 bool get_rep_dir(DIRECTION *dp, bool under)
2047 /* Global direction */
2050 if (repeat_pull(&code))
2052 dir = (DIRECTION)code;
2053 /* return (TRUE); */
2055 *dp = (DIRECTION)code;
2059 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
2063 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
2066 /* Get a direction */
2071 /* Get a command (or Cancel) */
2072 if (!get_com(prompt, &ch, TRUE)) break;
2075 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
2081 /* Look up the direction */
2082 dir = get_keymap_dir(ch);
2088 /* Prevent weirdness */
2089 if ((dir == 5) && (!under)) dir = 0;
2092 if (!dir) return (FALSE);
2094 /* Save desired direction */
2097 /* Apply "confusion" */
2098 if (p_ptr->confused)
2100 /* Standard confusion */
2101 if (randint0(100) < 75)
2103 /* Random direction */
2104 dir = ddd[randint0(8)];
2107 else if (p_ptr->riding)
2109 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2110 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2112 if (MON_CONFUSED(m_ptr))
2114 /* Standard confusion */
2115 if (randint0(100) < 75)
2117 /* Random direction */
2118 dir = ddd[randint0(8)];
2121 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2123 /* Random direction */
2124 dir = ddd[randint0(8)];
2126 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2128 /* Random direction */
2129 dir = ddd[randint0(8)];
2133 /* Notice confusion */
2134 if (command_dir != dir)
2136 if (p_ptr->confused)
2139 msg_print(_("あなたは混乱している。", "You are confused."));
2143 GAME_TEXT m_name[MAX_NLEN];
2144 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2146 monster_desc(m_name, m_ptr, 0);
2147 if (MON_CONFUSED(m_ptr))
2149 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2153 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2158 /* Save direction */
2161 /* repeat_push(dir); */
2162 repeat_push((COMMAND_CODE)command_dir);
2170 * XAngband: determine if a given location is "interesting"
2171 * based on target_set_accept function.
2173 static bool tgt_pt_accept(POSITION y, POSITION x)
2178 if (!(in_bounds(y, x))) return (FALSE);
2180 /* Player grid is always interesting */
2181 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
2183 /* Handle hallucination */
2184 if (p_ptr->image) return (FALSE);
2186 /* Examine the grid */
2187 g_ptr = ¤t_floor_ptr->grid_array[y][x];
2189 /* Interesting memorized features */
2190 if (g_ptr->info & (CAVE_MARK))
2193 if (cave_have_flag_grid(g_ptr, FF_LESS)) return (TRUE);
2194 if (cave_have_flag_grid(g_ptr, FF_MORE)) return (TRUE);
2196 /* Notice quest features */
2197 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return (TRUE);
2198 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return (TRUE);
2206 * XAngband: Prepare the "temp" array for "tget_pt"
2207 * based on target_set_prepare funciton.
2209 static void tgt_pt_prepare(void)
2213 /* Reset "temp" array */
2216 if (!expand_list) return;
2218 /* Scan the current panel */
2219 for (y = 1; y < current_floor_ptr->height; y++)
2221 for (x = 1; x < current_floor_ptr->width; x++)
2223 /* Require "interesting" contents */
2224 if (!tgt_pt_accept(y, x)) continue;
2226 /* Save the location */
2227 tmp_pos.x[tmp_pos.n] = x;
2228 tmp_pos.y[tmp_pos.n] = y;
2233 /* Target the nearest monster for shooting */
2234 ang_sort_comp = ang_sort_comp_distance;
2235 ang_sort_swap = ang_sort_swap_distance;
2237 /* Sort the positions */
2238 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
2242 * old -- from PsiAngband.
2244 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
2249 bool success = FALSE;
2253 get_screen_size(&wid, &hgt);
2263 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2264 msg_flag = FALSE; /* prevents "-more-" message. */
2266 while ((ch != ESCAPE) && !success)
2268 bool move_fast = FALSE;
2270 move_cursor_relative(y, x);
2282 if (player_bold(y, x)) ch = 0;
2285 else success = TRUE;
2289 /* XAngband: Move cursor to stairs */
2292 if (expand_list && tmp_pos.n)
2295 int cx = (panel_col_min + panel_col_max) / 2;
2296 int cy = (panel_row_min + panel_row_max) / 2;
2300 /* Skip stairs which have defferent distance */
2301 for (; n < tmp_pos.n; ++ n)
2303 grid_type *g_ptr = ¤t_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2305 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2306 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2313 if (n == tmp_pos.n) /* Loop out taget list */
2318 verify_panel(); /* Move cursor to player */
2320 p_ptr->update |= (PU_MONSTERS);
2322 p_ptr->redraw |= (PR_MAP);
2324 p_ptr->window |= (PW_OVERHEAD);
2327 else /* move cursor to next stair and change panel */
2332 dy = 2 * (y - cy) / hgt;
2333 dx = 2 * (x - cx) / wid;
2334 if (dy || dx) change_panel(dy, dx);
2340 /* Look up the direction */
2341 d = get_keymap_dir(ch);
2343 /* XTRA HACK MOVEFAST */
2344 if (isupper(ch)) move_fast = TRUE;
2346 /* Handle "direction" */
2352 /* XTRA HACK MOVEFAST */
2355 int mag = MIN(wid / 2, hgt / 2);
2365 /* Do not move horizontally if unnecessary */
2366 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2367 ((x > panel_col_min + wid / 2) && (dx < 0)))
2372 /* Do not move vertically if unnecessary */
2373 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2374 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2379 /* Apply the motion */
2380 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2381 (x >= panel_col_min + wid) || (x < panel_col_min))
2383 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
2384 change_panel(dy, dx);
2387 /* Slide into legality */
2388 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
2389 else if (x <= 0) x = 1;
2391 /* Slide into legality */
2392 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
2393 else if (y <= 0) y = 1;
2400 /* Clear the top line */
2403 /* Recenter the map around the player */
2406 p_ptr->update |= (PU_MONSTERS);
2408 p_ptr->redraw |= (PR_MAP);
2410 p_ptr->window |= (PW_OVERHEAD);
2419 bool get_hack_dir(DIRECTION *dp)
2427 /* Global direction */
2430 /* (No auto-targeting) */
2432 /* Ask until satisfied */
2435 /* Choose a prompt */
2438 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2442 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2445 /* Get a command (or Cancel) */
2446 if (!get_com(p, &command, TRUE)) break;
2450 if (command == '\r') command = 't';
2453 /* Convert various keys to "standard" keys */
2456 /* Use current target */
2467 /* Set new target */
2472 if (target_set(TARGET_KILL)) dir = 5;
2478 /* Look up the direction */
2479 dir = get_keymap_dir(command);
2485 /* Verify requested targets */
2486 if ((dir == 5) && !target_okay()) dir = 0;
2493 if (!dir) return (FALSE);
2495 /* Save the direction */
2498 /* Check for confusion */
2499 if (p_ptr->confused)
2501 /* Random direction */
2502 dir = ddd[randint0(8)];
2505 /* Notice confusion */
2506 if (command_dir != dir)
2509 msg_print(_("あなたは混乱している。", "You are confused."));
2512 /* Save direction */
2515 /* A "valid" direction was entered */