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 * Return monster death string
34 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
35 * @return 撃破されたモンスターの述語
37 concptr extract_note_dies(MONRACE_IDX r_idx)
39 monster_race *r_ptr = &r_info[r_idx];
40 /* Some monsters get "destroyed" */
41 if (!monster_living(r_idx))
45 for (i = 0; i < 4; i++)
47 if (r_ptr->blow[i].method == RBM_EXPLODE)
49 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
52 return _("を倒した。", " is destroyed.");
55 return _("は死んだ。", " dies.");
61 * @brief 現在のコンソール表示の縦横を返す。 /
62 * Get term size and calculate screen size
63 * @param wid_p コンソールの表示幅文字数を返す
64 * @param hgt_p コンソールの表示行数を返す
67 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
69 Term_get_size(wid_p, hgt_p);
70 *hgt_p -= ROW_MAP + 2;
71 *wid_p -= COL_MAP + 2;
72 if (use_bigtile) *wid_p /= 2;
77 * @brief コンソール上におけるマップ表示の左上位置を返す /
78 * Calculates current boundaries Called below and from "do_cmd_locate()".
81 void panel_bounds_center(void)
85 get_screen_size(&wid, &hgt);
87 panel_row_max = panel_row_min + hgt - 1;
88 panel_row_prt = panel_row_min - 1;
89 panel_col_max = panel_col_min + wid - 1;
90 panel_col_prt = panel_col_min - 13;
94 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
98 * Handle a request to change the current panel
99 * Return TRUE if the panel was changed.
100 * Also used in do_cmd_locate
101 * @return 実際に再描画が必要だった場合TRUEを返す
103 static bool change_panel_xy(POSITION y, POSITION x)
105 POSITION dy = 0, dx = 0;
108 get_screen_size(&wid, &hgt);
110 if (y < panel_row_min) dy = -1;
111 if (y > panel_row_max) dy = 1;
112 if (x < panel_col_min) dx = -1;
113 if (x > panel_col_max) dx = 1;
115 if (!dy && !dx) return (FALSE);
117 return change_panel(dy, dx);
122 * @brief マップ描画のフォーカスを当てるべき座標を更新する
124 * Given an row (y) and col (x), this routine detects when a move
125 * off the screen has occurred and figures new borders. -RAK-
126 * "Update" forces a "full update" to take place.
127 * The map is reprinted if necessary, and "TRUE" is returned.
128 * @return 実際に再描画が必要だった場合TRUEを返す
130 void verify_panel(void)
132 POSITION y = p_ptr->y;
133 POSITION x = p_ptr->x;
141 get_screen_size(&wid, &hgt);
143 max_prow_min = current_floor_ptr->height - hgt;
144 max_pcol_min = current_floor_ptr->width - wid;
146 /* Bounds checking */
147 if (max_prow_min < 0) max_prow_min = 0;
148 if (max_pcol_min < 0) max_pcol_min = 0;
150 /* Center on player */
151 if (center_player && (center_running || !running))
153 /* Center vertically */
154 prow_min = y - hgt / 2;
155 if (prow_min < 0) prow_min = 0;
156 else if (prow_min > max_prow_min) prow_min = max_prow_min;
158 /* Center horizontally */
159 pcol_min = x - wid / 2;
160 if (pcol_min < 0) pcol_min = 0;
161 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
165 prow_min = panel_row_min;
166 pcol_min = panel_col_min;
168 /* Scroll screen when 2 grids from top/bottom edge */
169 if (y > panel_row_max - 2)
171 while (y > prow_min + hgt-1 - 2)
173 prow_min += (hgt / 2);
177 if (y < panel_row_min + 2)
179 while (y < prow_min + 2)
181 prow_min -= (hgt / 2);
185 if (prow_min > max_prow_min) prow_min = max_prow_min;
186 if (prow_min < 0) prow_min = 0;
188 /* Scroll screen when 4 grids from left/right edge */
189 if (x > panel_col_max - 4)
191 while (x > pcol_min + wid-1 - 4)
193 pcol_min += (wid / 2);
197 if (x < panel_col_min + 4)
199 while (x < pcol_min + 4)
201 pcol_min -= (wid / 2);
205 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
206 if (pcol_min < 0) pcol_min = 0;
209 /* Check for "no change" */
210 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
212 /* Save the new panel info */
213 panel_row_min = prow_min;
214 panel_col_min = pcol_min;
216 /* Hack -- optional disturb on "panel change" */
217 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
219 /* Recalculate the boundaries */
220 panel_bounds_center();
222 p_ptr->update |= (PU_MONSTERS);
223 p_ptr->redraw |= (PR_MAP);
224 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
229 * Monster health description
231 concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
233 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
240 /* Determine if the monster is "living" */
241 living = monster_living(m_ptr->ap_r_idx);
243 /* Calculate a health "percentage" */
244 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
246 /* Healthy monsters */
247 if (m_ptr->hp >= m_ptr->maxhp)
249 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
254 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
259 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
264 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
269 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
272 /* Need attitude information? */
275 /* Full information is not needed */
278 else if (is_pet(m_ptr))
280 attitude = _(", ペット", ", pet");
282 else if (is_friendly(m_ptr))
284 attitude = _(", 友好的", ", friendly");
288 attitude = _("", "");
292 if (m_ptr->smart & SM_CLONED)
301 /* Display monster's level --- idea borrowed from ToME */
302 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
304 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
308 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
315 /*** Targeting Code ***/
319 * Determine is a monster makes a reasonable target
321 * The concept of "targeting" was stolen from "Morgul" (?)
323 * The player can target any location, or any "target-able" monster.
325 * Currently, a monster is "target_able" if it is visible, and if
326 * the player can hit it with a projection, and the player is not
327 * hallucinating. This allows use of "use closest target" macros.
329 * Future versions may restrict the ability to target "trappers"
330 * and "mimics", but the semantics is a little bit weird.
332 bool target_able(MONSTER_IDX m_idx)
334 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
336 /* Monster must be alive */
337 if (!monster_is_valid(m_ptr)) return (FALSE);
339 /* Hack -- no targeting hallucinations */
340 if (p_ptr->image) return (FALSE);
342 /* Monster must be visible */
343 if (!m_ptr->ml) return (FALSE);
345 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
347 /* Monster must be projectable */
348 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
350 /* Hack -- Never target trappers */
351 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
361 * Update (if necessary) and verify (if possible) the target.
363 * We return TRUE if the target is "okay" and FALSE otherwise.
365 bool target_okay(void)
367 /* Accept stationary targets */
368 if (target_who < 0) return (TRUE);
370 /* Check moving targets */
373 /* Accept reasonable targets */
374 if (target_able(target_who))
376 monster_type *m_ptr = ¤t_floor_ptr->m_list[target_who];
378 /* Acquire monster location */
379 target_row = m_ptr->fy;
380 target_col = m_ptr->fx;
387 /* Assume no target */
393 * Sorting hook -- comp function -- by "distance to player"
395 * We use "u" and "v" to point to arrays of "x" and "y" positions,
396 * and sort the arrays by double-distance to the player.
398 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
400 POSITION *x = (POSITION*)(u);
401 POSITION *y = (POSITION*)(v);
403 POSITION da, db, kx, ky;
405 /* Absolute distance components */
406 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
407 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
409 /* Approximate Double Distance to the first point */
410 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
412 /* Absolute distance components */
413 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
414 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
416 /* Approximate Double Distance to the first point */
417 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
419 /* Compare the distances */
425 * Sorting hook -- comp function -- by importance level of grids
427 * We use "u" and "v" to point to arrays of "x" and "y" positions,
428 * and sort the arrays by level of monster
430 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
432 POSITION *x = (POSITION*)(u);
433 POSITION *y = (POSITION*)(v);
434 grid_type *ca_ptr = ¤t_floor_ptr->grid_array[y[a]][x[a]];
435 grid_type *cb_ptr = ¤t_floor_ptr->grid_array[y[b]][x[b]];
436 monster_type *ma_ptr = ¤t_floor_ptr->m_list[ca_ptr->m_idx];
437 monster_type *mb_ptr = ¤t_floor_ptr->m_list[cb_ptr->m_idx];
438 monster_race *ap_ra_ptr, *ap_rb_ptr;
440 /* The player grid */
441 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
442 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
444 /* Extract monster race */
445 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
446 else ap_ra_ptr = NULL;
447 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
448 else ap_rb_ptr = NULL;
450 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
451 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
453 /* Compare two monsters */
454 if (ap_ra_ptr && ap_rb_ptr)
456 /* Unique monsters first */
457 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
458 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
460 /* Shadowers first (あやしい影) */
461 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
462 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
464 /* Unknown monsters first */
465 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
466 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
468 /* Higher level monsters first (if known) */
469 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
471 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
472 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
475 /* Sort by index if all conditions are same */
476 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
477 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
480 /* An object get higher priority */
481 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;
482 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;
484 /* Priority from the terrain */
485 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
486 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
488 /* If all conditions are same, compare distance */
489 return ang_sort_comp_distance(u, v, a, b);
494 * Sorting hook -- swap function -- by "distance to player"
496 * We use "u" and "v" to point to arrays of "x" and "y" positions,
497 * and sort the arrays by distance to the player.
499 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
501 POSITION *x = (POSITION*)(u);
502 POSITION *y = (POSITION*)(v);
520 * Hack -- help "select" a location (see below)
522 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
525 POSITION x2, y2, x3, y3, x4, y4;
526 POSITION_IDX b_i = -1, b_v = 9999;
529 /* Scan the locations */
530 for (i = 0; i < tmp_pos.n; i++)
536 /* Directed distance */
540 /* Verify quadrant */
541 if (dx && (x3 * dx <= 0)) continue;
542 if (dy && (y3 * dy <= 0)) continue;
544 /* Absolute distance */
548 /* Verify quadrant */
549 if (dy && !dx && (x4 > y4)) continue;
550 if (dx && !dy && (y4 > x4)) continue;
552 /* Approximate Double Distance */
553 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
555 /* Penalize location */
558 if ((b_i >= 0) && (v >= b_v)) continue;
568 * Hack -- determine if a given location is "interesting"
570 static bool target_set_accept(POSITION y, POSITION x)
573 OBJECT_IDX this_o_idx, next_o_idx = 0;
576 if (!(in_bounds(y, x))) return (FALSE);
578 /* Player grid is always interesting */
579 if (player_bold(y, x)) return (TRUE);
581 /* Handle hallucination */
582 if (p_ptr->image) return (FALSE);
584 /* Examine the grid */
585 g_ptr = ¤t_floor_ptr->grid_array[y][x];
587 /* Visible monsters */
590 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
592 /* Visible monsters */
593 if (m_ptr->ml) return (TRUE);
596 /* Scan all objects in the grid */
597 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
600 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
601 next_o_idx = o_ptr->next_o_idx;
603 /* Memorized object */
604 if (o_ptr->marked & OM_FOUND) return (TRUE);
607 /* Interesting memorized features */
608 if (g_ptr->info & (CAVE_MARK))
610 /* Notice object features */
611 if (g_ptr->info & CAVE_OBJECT) return (TRUE);
613 /* Feature code (applying "mimic" field) */
614 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
622 * Prepare the "temp" array for "target_set"
624 * Return the number of target_able monsters in the set.
626 static void target_set_prepare(BIT_FLAGS mode)
629 POSITION min_hgt, max_hgt, min_wid, max_wid;
631 if (mode & TARGET_KILL)
634 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
635 max_hgt = MIN((p_ptr->y + MAX_RANGE), current_floor_ptr->height - 1);
636 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
637 max_wid = MIN((p_ptr->x + MAX_RANGE), current_floor_ptr->width - 1);
639 else /* not targetting */
642 min_hgt = panel_row_min;
643 max_hgt = panel_row_max;
644 min_wid = panel_col_min;
645 max_wid = panel_col_max;
648 /* Reset "temp" array */
651 /* Scan the current panel */
652 for (y = min_hgt; y <= max_hgt; y++)
654 for (x = min_wid; x <= max_wid; x++)
658 /* Require "interesting" contents */
659 if (!target_set_accept(y, x)) continue;
661 g_ptr = ¤t_floor_ptr->grid_array[y][x];
663 /* Require target_able monsters for "TARGET_KILL" */
664 if ((mode & (TARGET_KILL)) && !target_able(g_ptr->m_idx)) continue;
666 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(¤t_floor_ptr->m_list[g_ptr->m_idx])) continue;
668 /* Save the location */
669 tmp_pos.x[tmp_pos.n] = x;
670 tmp_pos.y[tmp_pos.n] = y;
675 /* Set the sort hooks */
676 if (mode & (TARGET_KILL))
678 /* Target the nearest monster for shooting */
679 ang_sort_comp = ang_sort_comp_distance;
680 ang_sort_swap = ang_sort_swap_distance;
684 /* Look important grids first in Look command */
685 ang_sort_comp = ang_sort_comp_importance;
686 ang_sort_swap = ang_sort_swap_distance;
689 /* Sort the positions */
690 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
692 if (p_ptr->riding && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
697 tmp_pos.y[0] = tmp_pos.y[1];
700 tmp_pos.x[0] = tmp_pos.x[1];
705 void target_set_prepare_look(void){
706 target_set_prepare(TARGET_LOOK);
711 * Evaluate number of kill needed to gain level
713 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
715 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
717 s32b exp_mon, exp_adv;
718 u32b exp_mon_frac, exp_adv_frac;
720 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
725 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
735 /* The monster's experience point (assuming average monster speed) */
736 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
738 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
741 /* Total experience value for next level */
742 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
744 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
746 /* Experience value need to get */
747 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
750 /* You need to kill at least one monster to get any experience */
751 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
752 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
754 /* Extract number of monsters needed */
755 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
757 /* If 999 or more monsters needed, only display "999". */
758 num = MIN(999, exp_adv_frac);
760 /* Display the number */
761 sprintf(buf,"%03ld", (long int)num);
765 bool show_gold_on_floor = FALSE;
768 * Examine a grid, return a keypress.
770 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
771 * indicates that the "space" key should scan through the contents
772 * of the grid, instead of simply returning immediately. This lets
773 * the "look" command get complete information, without making the
774 * "target" command annoying.
776 * The "info" argument contains the "commands" which should be shown
777 * inside the "[xxx]" text. This string must never be empty, or grids
778 * containing monsters will be displayed with an extra comma.
780 * Note that if a monster is in the grid, we update both the monster
781 * recall info and the health bar info to track that monster.
783 * Eventually, we may allow multiple objects per grid, or objects
784 * and terrain features in the same grid.
786 * This function must handle blindness/hallucination.
788 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
790 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
791 OBJECT_IDX this_o_idx, next_o_idx = 0;
792 concptr s1 = "", s2 = "", s3 = "", x_info = "";
797 char out_val[MAX_NLEN+80];
798 OBJECT_IDX floor_list[23];
799 ITEM_NUMBER floor_num = 0;
801 /* Scan all objects in the grid */
804 floor_num = scan_floor(floor_list, y, x, 0x02);
808 x_info = _("x物 ", "x,");
812 /* Hack -- under the player */
813 if (player_bold(y, x))
826 s1 = _("ターゲット:", "Target:");
829 /* Hack -- hallucination */
832 concptr name = _("何か奇妙な物", "something strange");
834 /* Display a message */
836 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
838 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
842 move_cursor_relative(y, x);
845 /* Stop on everything but "return" */
846 if ((query != '\r') && (query != '\n')) return query;
853 /* Actual monsters */
854 if (g_ptr->m_idx && current_floor_ptr->m_list[g_ptr->m_idx].ml)
856 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
857 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
858 GAME_TEXT m_name[MAX_NLEN];
864 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
865 monster_race_track(m_ptr->ap_r_idx);
866 health_track(g_ptr->m_idx);
879 /* Recall on screen */
880 screen_roff(m_ptr->ap_r_idx, 0);
882 /* Hack -- Complete the prompt (again) */
883 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
890 /* Normal commands */
891 if (query != 'r') break;
896 /* Cleare recall text and repeat */
902 /* Describe, and prompt for recall */
903 evaluate_monster_exp(acount, m_ptr);
906 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);
908 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);
914 move_cursor_relative(y, x);
919 /* Normal commands */
920 if (query != 'r') break;
926 /* Always stop at "normal" keys */
927 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
929 /* Sometimes stop at "space" key */
930 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
932 /* Change the intro */
933 s1 = _("それは", "It is ");
935 /* Hack -- take account of gender */
936 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
937 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
939 /* Use a preposition */
948 /* Scan all objects being carried */
949 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
951 GAME_TEXT o_name[MAX_NLEN];
954 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
955 next_o_idx = o_ptr->next_o_idx;
957 /* Obtain an object description */
958 object_desc(o_name, o_ptr, 0);
961 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
963 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
967 move_cursor_relative(y, x);
970 /* Always stop at "normal" keys */
971 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
973 /* Sometimes stop at "space" key */
974 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
976 /* Change the intro */
977 s2 = _("をまた", "also carrying ");
980 /* Use a preposition */
997 GAME_TEXT o_name[MAX_NLEN];
1000 o_ptr = ¤t_floor_ptr->o_list[floor_list[0]];
1002 object_desc(o_name, o_ptr, 0);
1005 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1007 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1011 move_cursor_relative(y, x);
1020 /* Provide one cushion before item listing */
1023 /* Display rough information about items */
1025 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
1027 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
1031 move_cursor_relative(y, x);
1036 /* No request for listing */
1037 if (query != 'x' && query != ' ') return query;
1041 /** Display list of items **/
1043 /* Continue scrolling list if requested */
1051 show_gold_on_floor = TRUE;
1052 (void)show_floor(0, y, x, &min_width);
1053 show_gold_on_floor = FALSE;
1057 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
1059 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
1066 /* Exit unless 'Enter' */
1067 if (query != '\n' && query != '\r')
1072 /* Get the object being moved. */
1073 o_idx = g_ptr->o_idx;
1075 /* Only rotate a pile of two or more objects. */
1076 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
1078 /* Remove the first object from the list. */
1079 excise_object_idx(o_idx);
1081 /* Find end of the list. */
1083 while (current_floor_ptr->o_list[i].next_o_idx)
1084 i = current_floor_ptr->o_list[i].next_o_idx;
1086 /* Add after the last object. */
1087 current_floor_ptr->o_list[i].next_o_idx = o_idx;
1089 /* Loop and re-display the list */
1096 /* Scan all objects in the grid */
1097 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1100 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
1101 next_o_idx = o_ptr->next_o_idx;
1103 if (o_ptr->marked & OM_FOUND)
1105 GAME_TEXT o_name[MAX_NLEN];
1110 /* Obtain an object description */
1111 object_desc(o_name, o_ptr, 0);
1114 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1116 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1120 move_cursor_relative(y, x);
1123 /* Always stop at "normal" keys */
1124 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1126 /* Sometimes stop at "space" key */
1127 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
1129 /* Change the intro */
1130 s1 = _("それは", "It is ");
1133 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
1147 /* Feature code (applying "mimic" field) */
1148 feat = get_feat_mimic(g_ptr);
1150 /* Require knowledge about grid, or ability to see grid */
1151 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
1153 /* Forget feature */
1157 f_ptr = &f_info[feat];
1159 /* Terrain feature if needed */
1160 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
1164 /* Hack -- special handling for quest entrances */
1165 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
1167 /* Set the quest number temporary */
1168 IDX old_quest = p_ptr->inside_quest;
1171 /* Clear the text */
1172 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
1173 quest_text_line = 0;
1175 p_ptr->inside_quest = g_ptr->special;
1177 /* Get the quest text */
1178 init_flags = INIT_NAME_ONLY;
1180 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
1182 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
1183 quest[g_ptr->special].name, quest[g_ptr->special].level);
1185 /* Reset the old quest number */
1186 p_ptr->inside_quest = old_quest;
1189 /* Hack -- special handling for building doors */
1190 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
1192 name = building[f_ptr->subtype].name;
1194 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
1196 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
1198 else if (have_flag(f_ptr->flags, FF_TOWN))
1200 name = town_info[g_ptr->special].name;
1202 else if (p_ptr->wild_mode && (feat == feat_floor))
1204 name = _("道", "road");
1208 name = f_name + f_ptr->name;
1214 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
1215 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
1216 have_flag(f_ptr->flags, FF_TOWN)))
1218 s2 = _("の中", "in ");
1221 /* Hack -- special introduction for store & building doors -KMW- */
1222 if (have_flag(f_ptr->flags, FF_STORE) ||
1223 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
1224 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
1225 have_flag(f_ptr->flags, FF_ENTRANCE))
1230 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
1231 have_flag(f_ptr->flags, FF_TOWN) ||
1232 have_flag(f_ptr->flags, FF_SHALLOW) ||
1233 have_flag(f_ptr->flags, FF_DEEP))
1239 /* Pick proper indefinite article */
1240 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
1244 /* Display a message */
1248 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
1249 else sprintf(f_idx_str, "%d", g_ptr->feat);
1251 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]);
1253 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);
1258 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
1260 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1264 move_cursor_relative(y, x);
1267 /* Always stop at "normal" keys */
1268 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1271 /* Stop on everything but "return" */
1272 if ((query != '\r') && (query != '\n')) return query;
1274 /* Repeat forever */
1280 * Handle "target" and "look".
1282 * Note that this code can be called from "get_aim_dir()".
1284 * All locations must be on the current panel. Consider the use of
1285 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1286 * some form of "scrolling" the map around the cursor.
1287 * That is, consider the possibility of "auto-scrolling" the screen
1288 * while the cursor moves around. This may require changes in the
1289 * "update_monster()" code to allow "visibility" even if off panel, and
1290 * may require dynamic recalculation of the "temp" grid set.
1292 * Hack -- targeting/observing an "outer border grid" may induce
1293 * problems, so this is not currently allowed.
1295 * The player can use the direction keys to move among "interesting"
1296 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1297 * move through the "interesting" grids in a sequential manner, or
1298 * can enter "location" mode, and use the direction keys to move one
1299 * grid at a time in any direction. The "t" (set target) command will
1300 * only target a monster (as opposed to a location) if the monster is
1301 * target_able and the "interesting" mode is being used.
1303 * The current grid is described using the "look" method above, and
1304 * a new command may be entered at any time, but note that if the
1305 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1306 * where "space" has no obvious meaning) then "space" will scan
1307 * through the description of the current grid until done, instead
1308 * of immediately jumping to the next "interesting" grid. This
1309 * allows the "target" command to retain its old semantics.
1311 * The "*", "+", and "-" keys may always be used to jump immediately
1312 * to the next (or previous) interesting grid, in the proper mode.
1314 * The "return" key may always be used to scan through a complete
1315 * grid description (forever).
1317 * This command will cancel any old target, even if used from
1318 * inside the "look" command.
1320 bool target_set(BIT_FLAGS mode)
1323 POSITION y = p_ptr->y;
1324 POSITION x = p_ptr->x;
1334 get_screen_size(&wid, &hgt);
1339 if (rogue_like_commands)
1348 /* Prepare the "temp" array */
1349 target_set_prepare(mode);
1351 /* Start near the player */
1357 /* Interesting grids */
1358 if (flag && tmp_pos.n)
1364 change_panel_xy(y, x);
1366 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1369 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1372 if (target_able(g_ptr->m_idx))
1374 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1377 /* Dis-allow target */
1380 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1386 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1387 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
1388 strcat(info, cheatinfo);
1391 /* Describe and Prompt */
1393 query = target_set_aux(y, x, mode, info);
1397 /* Assume no "direction" */
1402 if (query == '\r') query = 't';
1420 if (target_able(g_ptr->m_idx))
1422 health_track(g_ptr->m_idx);
1423 target_who = g_ptr->m_idx;
1439 if (++m == tmp_pos.n)
1442 if (!expand_list) done = TRUE;
1452 if (!expand_list) done = TRUE;
1459 /* Recenter the map around the player */
1461 p_ptr->update |= (PU_MONSTERS);
1462 p_ptr->redraw |= (PR_MAP);
1463 p_ptr->window |= (PW_OVERHEAD);
1466 /* Recalculate interesting grids */
1467 target_set_prepare(mode);
1486 if(query == same_key)
1488 if (++m == tmp_pos.n)
1491 if (!expand_list) done = TRUE;
1496 /* Extract the action (if any) */
1497 d = get_keymap_dir(query);
1504 /* Hack -- move around */
1507 /* Modified to scroll to monster */
1508 POSITION y2 = panel_row_min;
1509 POSITION x2 = panel_col_min;
1511 /* Find a new monster */
1512 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1514 /* Request to target past last interesting grid */
1515 while (flag && (i < 0))
1517 /* Note the change */
1518 if (change_panel(ddy[d], ddx[d]))
1520 int v = tmp_pos.y[m];
1521 int u = tmp_pos.x[m];
1523 /* Recalculate interesting grids */
1524 target_set_prepare(mode);
1526 /* Look at interesting grids */
1529 /* Find a new monster */
1530 i = target_pick(v, u, ddy[d], ddx[d]);
1536 /* Nothing interesting */
1539 POSITION dx = ddx[d];
1540 POSITION dy = ddy[d];
1542 /* Restore previous position */
1545 panel_bounds_center();
1547 p_ptr->update |= (PU_MONSTERS);
1548 p_ptr->redraw |= (PR_MAP);
1549 p_ptr->window |= (PW_OVERHEAD);
1552 /* Recalculate interesting grids */
1553 target_set_prepare(mode);
1555 /* Look at boring grids */
1562 /* Do not move horizontally if unnecessary */
1563 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1564 ((x > panel_col_min + wid / 2) && (dx < 0)))
1569 /* Do not move vertically if unnecessary */
1570 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1571 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1576 /* Apply the motion */
1577 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1578 (x >= panel_col_min+wid) || (x < panel_col_min))
1580 if (change_panel(dy, dx)) target_set_prepare(mode);
1583 /* Slide into legality */
1584 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1585 else if (x <= 0) x = 1;
1587 /* Slide into legality */
1588 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1589 else if (y <= 0) y = 1;
1598 /* Arbitrary grids */
1601 bool move_fast = FALSE;
1603 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1606 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1608 /* Default prompt */
1609 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1614 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1615 los(p_ptr->y, p_ptr->x, y, x),
1616 projectable(p_ptr->y, p_ptr->x, y, x));
1617 strcat(info, cheatinfo);
1620 /* Describe and Prompt (enable "TARGET_LOOK") */
1621 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
1623 /* Assume no direction */
1628 if (query == '\r') query = 't';
1631 /* Analyze the keypress */
1655 /* Recenter the map around the player */
1657 p_ptr->update |= (PU_MONSTERS);
1658 p_ptr->redraw |= (PR_MAP);
1659 p_ptr->window |= (PW_OVERHEAD);
1662 /* Recalculate interesting grids */
1663 target_set_prepare(mode);
1685 /* Pick a nearby monster */
1686 for (i = 0; i < tmp_pos.n; i++)
1688 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1698 /* Nothing interesting */
1699 if (bd == 999) flag = FALSE;
1706 /* Extract the action (if any) */
1707 d = get_keymap_dir(query);
1709 /* XTRA HACK MOVEFAST */
1710 if (isupper(query)) move_fast = TRUE;
1717 /* Handle "direction" */
1720 POSITION dx = ddx[d];
1721 POSITION dy = ddy[d];
1723 /* XTRA HACK MOVEFAST */
1726 int mag = MIN(wid / 2, hgt / 2);
1736 /* Do not move horizontally if unnecessary */
1737 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1738 ((x > panel_col_min + wid / 2) && (dx < 0)))
1743 /* Do not move vertically if unnecessary */
1744 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1745 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1750 /* Apply the motion */
1751 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1752 (x >= panel_col_min + wid) || (x < panel_col_min))
1754 if (change_panel(dy, dx)) target_set_prepare(mode);
1757 /* Slide into legality */
1758 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1759 else if (x <= 0) x = 1;
1761 /* Slide into legality */
1762 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1763 else if (y <= 0) y = 1;
1771 /* Clear the top line */
1774 /* Recenter the map around the player */
1776 p_ptr->update |= (PU_MONSTERS);
1777 p_ptr->redraw |= (PR_MAP);
1778 p_ptr->window |= (PW_OVERHEAD);
1781 /* Failure to set target */
1782 if (!target_who) return (FALSE);
1790 * Get an "aiming direction" from the user.
1792 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1793 * "0" for "current target", and "-1" for "entry aborted".
1795 * Note that "Force Target", if set, will pre-empt user interaction,
1796 * if there is a usable target already set.
1798 * Note that confusion over-rides any (explicit?) user choice.
1800 bool get_aim_dir(DIRECTION *dp)
1809 /* Global direction */
1812 /* Hack -- auto-target if requested */
1813 if (use_old_target && target_okay()) dir = 5;
1815 if (repeat_pull(&code))
1820 if (!(code == 5 && !target_okay()))
1822 /* return (TRUE); */
1823 dir = (DIRECTION)code;
1826 *dp = (DIRECTION)code;
1828 /* Ask until satisfied */
1831 /* Choose a prompt */
1834 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1838 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1841 /* Get a command (or Cancel) */
1842 if (!get_com(p, &command, TRUE)) break;
1846 if (command == '\r') command = 't';
1849 /* Convert various keys to "standard" keys */
1852 /* Use current target */
1863 /* Set new target */
1868 if (target_set(TARGET_KILL)) dir = 5;
1874 /* Extract the action (if any) */
1875 dir = get_keymap_dir(command);
1881 /* Verify requested targets */
1882 if ((dir == 5) && !target_okay()) dir = 0;
1891 project_length = 0; /* reset to default */
1895 /* Save the direction */
1898 /* Check for confusion */
1899 if (p_ptr->confused)
1901 /* Random direction */
1902 dir = ddd[randint0(8)];
1905 /* Notice confusion */
1906 if (command_dir != dir)
1909 msg_print(_("あなたは混乱している。", "You are confused."));
1912 /* Save direction */
1915 /* repeat_push(dir); */
1916 repeat_push((COMMAND_CODE)command_dir);
1918 /* A "valid" direction was entered */
1923 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
1931 /* Global direction */
1934 if (repeat_pull(&code))
1936 dir = (DIRECTION)code;
1937 /* return (TRUE); */
1939 *dp = (DIRECTION)code;
1943 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1947 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1950 /* Get a direction */
1955 /* Get a command (or Cancel) */
1956 if (!get_com(prompt, &ch, TRUE)) break;
1959 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1965 /* Look up the direction */
1966 dir = get_keymap_dir(ch);
1972 /* Prevent weirdness */
1973 if ((dir == 5) && (!allow_under)) dir = 0;
1976 if (!dir) return (FALSE);
1978 /* Save desired direction */
1981 /* Apply "confusion" */
1982 if (p_ptr->confused)
1984 /* Standard confusion */
1985 if (randint0(100) < 75)
1987 /* Random direction */
1988 dir = ddd[randint0(8)];
1991 else if (p_ptr->riding && with_steed)
1993 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1994 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1996 if (MON_CONFUSED(m_ptr))
1998 /* Standard confusion */
1999 if (randint0(100) < 75)
2001 /* Random direction */
2002 dir = ddd[randint0(8)];
2005 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2007 /* Random direction */
2008 dir = ddd[randint0(8)];
2010 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2012 /* Random direction */
2013 dir = ddd[randint0(8)];
2017 /* Notice confusion */
2018 if (command_dir != dir)
2020 if (p_ptr->confused)
2023 msg_print(_("あなたは混乱している。", "You are confused."));
2027 GAME_TEXT m_name[MAX_NLEN];
2028 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2030 monster_desc(m_name, m_ptr, 0);
2031 if (MON_CONFUSED(m_ptr))
2033 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2037 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2042 /* Save direction */
2045 /* repeat_push(dir); */
2046 repeat_push((COMMAND_CODE)command_dir);
2053 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
2054 * and place it into "command_dir", unless we already have one.
2056 * This function should be used for all "repeatable" commands, such as
2057 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
2058 * as all commands which must reference a grid adjacent to the player,
2059 * and which may not reference the grid under the player. Note that,
2060 * for example, it is no longer possible to "disarm" or "open" chests
2061 * in the same grid as the player.
2063 * Direction "5" is illegal and will (cleanly) abort the command.
2065 * This function tracks and uses the "global direction", and uses
2066 * that as the "desired direction", to which "confusion" is applied.
2068 bool get_rep_dir(DIRECTION *dp, bool under)
2076 /* Global direction */
2079 if (repeat_pull(&code))
2081 dir = (DIRECTION)code;
2082 /* return (TRUE); */
2084 *dp = (DIRECTION)code;
2088 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
2092 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
2095 /* Get a direction */
2100 /* Get a command (or Cancel) */
2101 if (!get_com(prompt, &ch, TRUE)) break;
2104 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
2110 /* Look up the direction */
2111 dir = get_keymap_dir(ch);
2117 /* Prevent weirdness */
2118 if ((dir == 5) && (!under)) dir = 0;
2121 if (!dir) return (FALSE);
2123 /* Save desired direction */
2126 /* Apply "confusion" */
2127 if (p_ptr->confused)
2129 /* Standard confusion */
2130 if (randint0(100) < 75)
2132 /* Random direction */
2133 dir = ddd[randint0(8)];
2136 else if (p_ptr->riding)
2138 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2139 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2141 if (MON_CONFUSED(m_ptr))
2143 /* Standard confusion */
2144 if (randint0(100) < 75)
2146 /* Random direction */
2147 dir = ddd[randint0(8)];
2150 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2152 /* Random direction */
2153 dir = ddd[randint0(8)];
2155 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2157 /* Random direction */
2158 dir = ddd[randint0(8)];
2162 /* Notice confusion */
2163 if (command_dir != dir)
2165 if (p_ptr->confused)
2168 msg_print(_("あなたは混乱している。", "You are confused."));
2172 GAME_TEXT m_name[MAX_NLEN];
2173 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2175 monster_desc(m_name, m_ptr, 0);
2176 if (MON_CONFUSED(m_ptr))
2178 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2182 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2187 /* Save direction */
2190 /* repeat_push(dir); */
2191 repeat_push((COMMAND_CODE)command_dir);
2199 * XAngband: determine if a given location is "interesting"
2200 * based on target_set_accept function.
2202 static bool tgt_pt_accept(POSITION y, POSITION x)
2207 if (!(in_bounds(y, x))) return (FALSE);
2209 /* Player grid is always interesting */
2210 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
2212 /* Handle hallucination */
2213 if (p_ptr->image) return (FALSE);
2215 /* Examine the grid */
2216 g_ptr = ¤t_floor_ptr->grid_array[y][x];
2218 /* Interesting memorized features */
2219 if (g_ptr->info & (CAVE_MARK))
2222 if (cave_have_flag_grid(g_ptr, FF_LESS)) return (TRUE);
2223 if (cave_have_flag_grid(g_ptr, FF_MORE)) return (TRUE);
2225 /* Notice quest features */
2226 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return (TRUE);
2227 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return (TRUE);
2235 * XAngband: Prepare the "temp" array for "tget_pt"
2236 * based on target_set_prepare funciton.
2238 static void tgt_pt_prepare(void)
2242 /* Reset "temp" array */
2245 if (!expand_list) return;
2247 /* Scan the current panel */
2248 for (y = 1; y < current_floor_ptr->height; y++)
2250 for (x = 1; x < current_floor_ptr->width; x++)
2252 /* Require "interesting" contents */
2253 if (!tgt_pt_accept(y, x)) continue;
2255 /* Save the location */
2256 tmp_pos.x[tmp_pos.n] = x;
2257 tmp_pos.y[tmp_pos.n] = y;
2262 /* Target the nearest monster for shooting */
2263 ang_sort_comp = ang_sort_comp_distance;
2264 ang_sort_swap = ang_sort_swap_distance;
2266 /* Sort the positions */
2267 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
2271 * old -- from PsiAngband.
2273 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
2278 bool success = FALSE;
2282 get_screen_size(&wid, &hgt);
2292 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2293 msg_flag = FALSE; /* prevents "-more-" message. */
2295 while ((ch != ESCAPE) && !success)
2297 bool move_fast = FALSE;
2299 move_cursor_relative(y, x);
2311 if (player_bold(y, x)) ch = 0;
2314 else success = TRUE;
2318 /* XAngband: Move cursor to stairs */
2321 if (expand_list && tmp_pos.n)
2324 int cx = (panel_col_min + panel_col_max) / 2;
2325 int cy = (panel_row_min + panel_row_max) / 2;
2329 /* Skip stairs which have defferent distance */
2330 for (; n < tmp_pos.n; ++ n)
2332 grid_type *g_ptr = ¤t_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2334 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2335 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2342 if (n == tmp_pos.n) /* Loop out taget list */
2347 verify_panel(); /* Move cursor to player */
2349 p_ptr->update |= (PU_MONSTERS);
2351 p_ptr->redraw |= (PR_MAP);
2353 p_ptr->window |= (PW_OVERHEAD);
2356 else /* move cursor to next stair and change panel */
2361 dy = 2 * (y - cy) / hgt;
2362 dx = 2 * (x - cx) / wid;
2363 if (dy || dx) change_panel(dy, dx);
2369 /* Look up the direction */
2370 d = get_keymap_dir(ch);
2372 /* XTRA HACK MOVEFAST */
2373 if (isupper(ch)) move_fast = TRUE;
2375 /* Handle "direction" */
2381 /* XTRA HACK MOVEFAST */
2384 int mag = MIN(wid / 2, hgt / 2);
2394 /* Do not move horizontally if unnecessary */
2395 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2396 ((x > panel_col_min + wid / 2) && (dx < 0)))
2401 /* Do not move vertically if unnecessary */
2402 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2403 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2408 /* Apply the motion */
2409 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2410 (x >= panel_col_min + wid) || (x < panel_col_min))
2412 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
2413 change_panel(dy, dx);
2416 /* Slide into legality */
2417 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
2418 else if (x <= 0) x = 1;
2420 /* Slide into legality */
2421 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
2422 else if (y <= 0) y = 1;
2429 /* Clear the top line */
2432 /* Recenter the map around the player */
2435 p_ptr->update |= (PU_MONSTERS);
2437 p_ptr->redraw |= (PR_MAP);
2439 p_ptr->window |= (PW_OVERHEAD);
2448 bool get_hack_dir(DIRECTION *dp)
2456 /* Global direction */
2459 /* (No auto-targeting) */
2461 /* Ask until satisfied */
2464 /* Choose a prompt */
2467 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2471 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2474 /* Get a command (or Cancel) */
2475 if (!get_com(p, &command, TRUE)) break;
2479 if (command == '\r') command = 't';
2482 /* Convert various keys to "standard" keys */
2485 /* Use current target */
2496 /* Set new target */
2501 if (target_set(TARGET_KILL)) dir = 5;
2507 /* Look up the direction */
2508 dir = get_keymap_dir(command);
2514 /* Verify requested targets */
2515 if ((dir == 5) && !target_okay()) dir = 0;
2522 if (!dir) return (FALSE);
2524 /* Save the direction */
2527 /* Check for confusion */
2528 if (p_ptr->confused)
2530 /* Random direction */
2531 dir = ddd[randint0(8)];
2534 /* Notice confusion */
2535 if (command_dir != dir)
2538 msg_print(_("あなたは混乱している。", "You are confused."));
2541 /* Save direction */
2544 /* A "valid" direction was entered */