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 * Calculates current boundaries Called below and from "do_cmd_locate()".
36 void panel_bounds_center(void)
40 get_screen_size(&wid, &hgt);
42 panel_row_max = panel_row_min + hgt - 1;
43 panel_row_prt = panel_row_min - 1;
44 panel_col_max = panel_col_min + wid - 1;
45 panel_col_prt = panel_col_min - 13;
49 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
53 * Handle a request to change the current panel
54 * Return TRUE if the panel was changed.
55 * Also used in do_cmd_locate
56 * @return 実際に再描画が必要だった場合TRUEを返す
58 static bool change_panel_xy(POSITION y, POSITION x)
60 POSITION dy = 0, dx = 0;
63 get_screen_size(&wid, &hgt);
65 if (y < panel_row_min) dy = -1;
66 if (y > panel_row_max) dy = 1;
67 if (x < panel_col_min) dx = -1;
68 if (x > panel_col_max) dx = 1;
70 if (!dy && !dx) return (FALSE);
72 return change_panel(dy, dx);
77 * @brief マップ描画のフォーカスを当てるべき座標を更新する
79 * Given an row (y) and col (x), this routine detects when a move
80 * off the screen has occurred and figures new borders. -RAK-
81 * "Update" forces a "full update" to take place.
82 * The map is reprinted if necessary, and "TRUE" is returned.
83 * @return 実際に再描画が必要だった場合TRUEを返す
85 void verify_panel(void)
87 POSITION y = p_ptr->y;
88 POSITION x = p_ptr->x;
96 get_screen_size(&wid, &hgt);
98 max_prow_min = current_floor_ptr->height - hgt;
99 max_pcol_min = current_floor_ptr->width - wid;
101 /* Bounds checking */
102 if (max_prow_min < 0) max_prow_min = 0;
103 if (max_pcol_min < 0) max_pcol_min = 0;
105 /* Center on player */
106 if (center_player && (center_running || !running))
108 /* Center vertically */
109 prow_min = y - hgt / 2;
110 if (prow_min < 0) prow_min = 0;
111 else if (prow_min > max_prow_min) prow_min = max_prow_min;
113 /* Center horizontally */
114 pcol_min = x - wid / 2;
115 if (pcol_min < 0) pcol_min = 0;
116 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
120 prow_min = panel_row_min;
121 pcol_min = panel_col_min;
123 /* Scroll screen when 2 grids from top/bottom edge */
124 if (y > panel_row_max - 2)
126 while (y > prow_min + hgt-1 - 2)
128 prow_min += (hgt / 2);
132 if (y < panel_row_min + 2)
134 while (y < prow_min + 2)
136 prow_min -= (hgt / 2);
140 if (prow_min > max_prow_min) prow_min = max_prow_min;
141 if (prow_min < 0) prow_min = 0;
143 /* Scroll screen when 4 grids from left/right edge */
144 if (x > panel_col_max - 4)
146 while (x > pcol_min + wid-1 - 4)
148 pcol_min += (wid / 2);
152 if (x < panel_col_min + 4)
154 while (x < pcol_min + 4)
156 pcol_min -= (wid / 2);
160 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
161 if (pcol_min < 0) pcol_min = 0;
164 /* Check for "no change" */
165 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
167 /* Save the new panel info */
168 panel_row_min = prow_min;
169 panel_col_min = pcol_min;
171 /* Hack -- optional disturb on "panel change" */
172 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
174 /* Recalculate the boundaries */
175 panel_bounds_center();
177 p_ptr->update |= (PU_MONSTERS);
178 p_ptr->redraw |= (PR_MAP);
179 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
184 * Monster health description
186 concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
188 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
195 /* Determine if the monster is "living" */
196 living = monster_living(m_ptr->ap_r_idx);
198 /* Calculate a health "percentage" */
199 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
201 /* Healthy monsters */
202 if (m_ptr->hp >= m_ptr->maxhp)
204 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
209 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
214 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
219 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
224 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
227 /* Need attitude information? */
230 /* Full information is not needed */
233 else if (is_pet(m_ptr))
235 attitude = _(", ペット", ", pet");
237 else if (is_friendly(m_ptr))
239 attitude = _(", 友好的", ", friendly");
243 attitude = _("", "");
247 if (m_ptr->smart & SM_CLONED)
256 /* Display monster's level --- idea borrowed from ToME */
257 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
259 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
263 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
270 /*** Targeting Code ***/
274 * Determine is a monster makes a reasonable target
276 * The concept of "targeting" was stolen from "Morgul" (?)
278 * The player can target any location, or any "target-able" monster.
280 * Currently, a monster is "target_able" if it is visible, and if
281 * the player can hit it with a projection, and the player is not
282 * hallucinating. This allows use of "use closest target" macros.
284 * Future versions may restrict the ability to target "trappers"
285 * and "mimics", but the semantics is a little bit weird.
287 bool target_able(MONSTER_IDX m_idx)
289 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
291 /* Monster must be alive */
292 if (!monster_is_valid(m_ptr)) return (FALSE);
294 /* Hack -- no targeting hallucinations */
295 if (p_ptr->image) return (FALSE);
297 /* Monster must be visible */
298 if (!m_ptr->ml) return (FALSE);
300 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
302 /* Monster must be projectable */
303 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
305 /* Hack -- Never target trappers */
306 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
316 * Update (if necessary) and verify (if possible) the target.
318 * We return TRUE if the target is "okay" and FALSE otherwise.
320 bool target_okay(void)
322 /* Accept stationary targets */
323 if (target_who < 0) return (TRUE);
325 /* Check moving targets */
328 /* Accept reasonable targets */
329 if (target_able(target_who))
331 monster_type *m_ptr = ¤t_floor_ptr->m_list[target_who];
333 /* Acquire monster location */
334 target_row = m_ptr->fy;
335 target_col = m_ptr->fx;
342 /* Assume no target */
348 * Sorting hook -- comp function -- by "distance to player"
350 * We use "u" and "v" to point to arrays of "x" and "y" positions,
351 * and sort the arrays by double-distance to the player.
353 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
355 POSITION *x = (POSITION*)(u);
356 POSITION *y = (POSITION*)(v);
358 POSITION da, db, kx, ky;
360 /* Absolute distance components */
361 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
362 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
364 /* Approximate Double Distance to the first point */
365 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
367 /* Absolute distance components */
368 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
369 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
371 /* Approximate Double Distance to the first point */
372 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
374 /* Compare the distances */
380 * Sorting hook -- comp function -- by importance level of grids
382 * We use "u" and "v" to point to arrays of "x" and "y" positions,
383 * and sort the arrays by level of monster
385 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
387 POSITION *x = (POSITION*)(u);
388 POSITION *y = (POSITION*)(v);
389 grid_type *ca_ptr = ¤t_floor_ptr->grid_array[y[a]][x[a]];
390 grid_type *cb_ptr = ¤t_floor_ptr->grid_array[y[b]][x[b]];
391 monster_type *ma_ptr = ¤t_floor_ptr->m_list[ca_ptr->m_idx];
392 monster_type *mb_ptr = ¤t_floor_ptr->m_list[cb_ptr->m_idx];
393 monster_race *ap_ra_ptr, *ap_rb_ptr;
395 /* The player grid */
396 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
397 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
399 /* Extract monster race */
400 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
401 else ap_ra_ptr = NULL;
402 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
403 else ap_rb_ptr = NULL;
405 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
406 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
408 /* Compare two monsters */
409 if (ap_ra_ptr && ap_rb_ptr)
411 /* Unique monsters first */
412 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
413 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
415 /* Shadowers first (あやしい影) */
416 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
417 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
419 /* Unknown monsters first */
420 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
421 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
423 /* Higher level monsters first (if known) */
424 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
426 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
427 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
430 /* Sort by index if all conditions are same */
431 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
432 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
435 /* An object get higher priority */
436 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;
437 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;
439 /* Priority from the terrain */
440 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
441 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
443 /* If all conditions are same, compare distance */
444 return ang_sort_comp_distance(u, v, a, b);
449 * Sorting hook -- swap function -- by "distance to player"
451 * We use "u" and "v" to point to arrays of "x" and "y" positions,
452 * and sort the arrays by distance to the player.
454 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
456 POSITION *x = (POSITION*)(u);
457 POSITION *y = (POSITION*)(v);
475 * Hack -- help "select" a location (see below)
477 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
480 POSITION x2, y2, x3, y3, x4, y4;
481 POSITION_IDX b_i = -1, b_v = 9999;
484 /* Scan the locations */
485 for (i = 0; i < tmp_pos.n; i++)
491 /* Directed distance */
495 /* Verify quadrant */
496 if (dx && (x3 * dx <= 0)) continue;
497 if (dy && (y3 * dy <= 0)) continue;
499 /* Absolute distance */
503 /* Verify quadrant */
504 if (dy && !dx && (x4 > y4)) continue;
505 if (dx && !dy && (y4 > x4)) continue;
507 /* Approximate Double Distance */
508 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
510 /* Penalize location */
513 if ((b_i >= 0) && (v >= b_v)) continue;
523 * Hack -- determine if a given location is "interesting"
525 static bool target_set_accept(POSITION y, POSITION x)
528 OBJECT_IDX this_o_idx, next_o_idx = 0;
531 if (!(in_bounds(y, x))) return (FALSE);
533 /* Player grid is always interesting */
534 if (player_bold(y, x)) return (TRUE);
536 /* Handle hallucination */
537 if (p_ptr->image) return (FALSE);
539 /* Examine the grid */
540 g_ptr = ¤t_floor_ptr->grid_array[y][x];
542 /* Visible monsters */
545 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
547 /* Visible monsters */
548 if (m_ptr->ml) return (TRUE);
551 /* Scan all objects in the grid */
552 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
555 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
556 next_o_idx = o_ptr->next_o_idx;
558 /* Memorized object */
559 if (o_ptr->marked & OM_FOUND) return (TRUE);
562 /* Interesting memorized features */
563 if (g_ptr->info & (CAVE_MARK))
565 /* Notice object features */
566 if (g_ptr->info & CAVE_OBJECT) return (TRUE);
568 /* Feature code (applying "mimic" field) */
569 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
577 * Prepare the "temp" array for "target_set"
579 * Return the number of target_able monsters in the set.
581 static void target_set_prepare(BIT_FLAGS mode)
584 POSITION min_hgt, max_hgt, min_wid, max_wid;
586 if (mode & TARGET_KILL)
589 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
590 max_hgt = MIN((p_ptr->y + MAX_RANGE), current_floor_ptr->height - 1);
591 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
592 max_wid = MIN((p_ptr->x + MAX_RANGE), current_floor_ptr->width - 1);
594 else /* not targetting */
597 min_hgt = panel_row_min;
598 max_hgt = panel_row_max;
599 min_wid = panel_col_min;
600 max_wid = panel_col_max;
603 /* Reset "temp" array */
606 /* Scan the current panel */
607 for (y = min_hgt; y <= max_hgt; y++)
609 for (x = min_wid; x <= max_wid; x++)
613 /* Require "interesting" contents */
614 if (!target_set_accept(y, x)) continue;
616 g_ptr = ¤t_floor_ptr->grid_array[y][x];
618 /* Require target_able monsters for "TARGET_KILL" */
619 if ((mode & (TARGET_KILL)) && !target_able(g_ptr->m_idx)) continue;
621 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(¤t_floor_ptr->m_list[g_ptr->m_idx])) continue;
623 /* Save the location */
624 tmp_pos.x[tmp_pos.n] = x;
625 tmp_pos.y[tmp_pos.n] = y;
630 /* Set the sort hooks */
631 if (mode & (TARGET_KILL))
633 /* Target the nearest monster for shooting */
634 ang_sort_comp = ang_sort_comp_distance;
635 ang_sort_swap = ang_sort_swap_distance;
639 /* Look important grids first in Look command */
640 ang_sort_comp = ang_sort_comp_importance;
641 ang_sort_swap = ang_sort_swap_distance;
644 /* Sort the positions */
645 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
647 if (p_ptr->riding && target_pet && (tmp_pos.n > 1) && (mode & (TARGET_KILL)))
652 tmp_pos.y[0] = tmp_pos.y[1];
655 tmp_pos.x[0] = tmp_pos.x[1];
660 void target_set_prepare_look(void){
661 target_set_prepare(TARGET_LOOK);
666 * Evaluate number of kill needed to gain level
668 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
670 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
672 s32b exp_mon, exp_adv;
673 u32b exp_mon_frac, exp_adv_frac;
675 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
680 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
690 /* The monster's experience point (assuming average monster speed) */
691 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
693 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
696 /* Total experience value for next level */
697 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
699 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
701 /* Experience value need to get */
702 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
705 /* You need to kill at least one monster to get any experience */
706 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
707 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
709 /* Extract number of monsters needed */
710 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
712 /* If 999 or more monsters needed, only display "999". */
713 num = MIN(999, exp_adv_frac);
715 /* Display the number */
716 sprintf(buf,"%03ld", (long int)num);
720 bool show_gold_on_floor = FALSE;
723 * Examine a grid, return a keypress.
725 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
726 * indicates that the "space" key should scan through the contents
727 * of the grid, instead of simply returning immediately. This lets
728 * the "look" command get complete information, without making the
729 * "target" command annoying.
731 * The "info" argument contains the "commands" which should be shown
732 * inside the "[xxx]" text. This string must never be empty, or grids
733 * containing monsters will be displayed with an extra comma.
735 * Note that if a monster is in the grid, we update both the monster
736 * recall info and the health bar info to track that monster.
738 * Eventually, we may allow multiple objects per grid, or objects
739 * and terrain features in the same grid.
741 * This function must handle blindness/hallucination.
743 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
745 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
746 OBJECT_IDX this_o_idx, next_o_idx = 0;
747 concptr s1 = "", s2 = "", s3 = "", x_info = "";
752 char out_val[MAX_NLEN+80];
753 OBJECT_IDX floor_list[23];
754 ITEM_NUMBER floor_num = 0;
756 /* Scan all objects in the grid */
759 floor_num = scan_floor(floor_list, y, x, 0x02);
763 x_info = _("x物 ", "x,");
767 /* Hack -- under the player */
768 if (player_bold(y, x))
781 s1 = _("ターゲット:", "Target:");
784 /* Hack -- hallucination */
787 concptr name = _("何か奇妙な物", "something strange");
789 /* Display a message */
791 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
793 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
797 move_cursor_relative(y, x);
800 /* Stop on everything but "return" */
801 if ((query != '\r') && (query != '\n')) return query;
808 /* Actual monsters */
809 if (g_ptr->m_idx && current_floor_ptr->m_list[g_ptr->m_idx].ml)
811 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
812 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
813 GAME_TEXT m_name[MAX_NLEN];
819 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
820 monster_race_track(m_ptr->ap_r_idx);
821 health_track(g_ptr->m_idx);
834 /* Recall on screen */
835 screen_roff(m_ptr->ap_r_idx, 0);
837 /* Hack -- Complete the prompt (again) */
838 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
845 /* Normal commands */
846 if (query != 'r') break;
851 /* Cleare recall text and repeat */
857 /* Describe, and prompt for recall */
858 evaluate_monster_exp(acount, m_ptr);
861 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);
863 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);
869 move_cursor_relative(y, x);
874 /* Normal commands */
875 if (query != 'r') break;
881 /* Always stop at "normal" keys */
882 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
884 /* Sometimes stop at "space" key */
885 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
887 /* Change the intro */
888 s1 = _("それは", "It is ");
890 /* Hack -- take account of gender */
891 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
892 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
894 /* Use a preposition */
903 /* Scan all objects being carried */
904 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
906 GAME_TEXT o_name[MAX_NLEN];
909 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
910 next_o_idx = o_ptr->next_o_idx;
912 /* Obtain an object description */
913 object_desc(o_name, o_ptr, 0);
916 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
918 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
922 move_cursor_relative(y, x);
925 /* Always stop at "normal" keys */
926 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
928 /* Sometimes stop at "space" key */
929 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
931 /* Change the intro */
932 s2 = _("をまた", "also carrying ");
935 /* Use a preposition */
952 GAME_TEXT o_name[MAX_NLEN];
955 o_ptr = ¤t_floor_ptr->o_list[floor_list[0]];
957 object_desc(o_name, o_ptr, 0);
960 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
962 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
966 move_cursor_relative(y, x);
975 /* Provide one cushion before item listing */
978 /* Display rough information about items */
980 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
982 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
986 move_cursor_relative(y, x);
991 /* No request for listing */
992 if (query != 'x' && query != ' ') return query;
996 /** Display list of items **/
998 /* Continue scrolling list if requested */
1006 show_gold_on_floor = TRUE;
1007 (void)show_floor(0, y, x, &min_width);
1008 show_gold_on_floor = FALSE;
1012 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
1014 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
1021 /* Exit unless 'Enter' */
1022 if (query != '\n' && query != '\r')
1027 /* Get the object being moved. */
1028 o_idx = g_ptr->o_idx;
1030 /* Only rotate a pile of two or more objects. */
1031 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
1033 /* Remove the first object from the list. */
1034 excise_object_idx(o_idx);
1036 /* Find end of the list. */
1038 while (current_floor_ptr->o_list[i].next_o_idx)
1039 i = current_floor_ptr->o_list[i].next_o_idx;
1041 /* Add after the last object. */
1042 current_floor_ptr->o_list[i].next_o_idx = o_idx;
1044 /* Loop and re-display the list */
1051 /* Scan all objects in the grid */
1052 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1055 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
1056 next_o_idx = o_ptr->next_o_idx;
1058 if (o_ptr->marked & OM_FOUND)
1060 GAME_TEXT o_name[MAX_NLEN];
1065 /* Obtain an object description */
1066 object_desc(o_name, o_ptr, 0);
1069 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1071 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1075 move_cursor_relative(y, x);
1078 /* Always stop at "normal" keys */
1079 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1081 /* Sometimes stop at "space" key */
1082 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
1084 /* Change the intro */
1085 s1 = _("それは", "It is ");
1088 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
1102 /* Feature code (applying "mimic" field) */
1103 feat = get_feat_mimic(g_ptr);
1105 /* Require knowledge about grid, or ability to see grid */
1106 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
1108 /* Forget feature */
1112 f_ptr = &f_info[feat];
1114 /* Terrain feature if needed */
1115 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
1119 /* Hack -- special handling for quest entrances */
1120 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
1122 /* Set the quest number temporary */
1123 IDX old_quest = p_ptr->inside_quest;
1126 /* Clear the text */
1127 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
1128 quest_text_line = 0;
1130 p_ptr->inside_quest = g_ptr->special;
1132 /* Get the quest text */
1133 init_flags = INIT_NAME_ONLY;
1135 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
1137 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
1138 quest[g_ptr->special].name, quest[g_ptr->special].level);
1140 /* Reset the old quest number */
1141 p_ptr->inside_quest = old_quest;
1144 /* Hack -- special handling for building doors */
1145 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
1147 name = building[f_ptr->subtype].name;
1149 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
1151 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
1153 else if (have_flag(f_ptr->flags, FF_TOWN))
1155 name = town_info[g_ptr->special].name;
1157 else if (p_ptr->wild_mode && (feat == feat_floor))
1159 name = _("道", "road");
1163 name = f_name + f_ptr->name;
1169 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
1170 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
1171 have_flag(f_ptr->flags, FF_TOWN)))
1173 s2 = _("の中", "in ");
1176 /* Hack -- special introduction for store & building doors -KMW- */
1177 if (have_flag(f_ptr->flags, FF_STORE) ||
1178 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
1179 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
1180 have_flag(f_ptr->flags, FF_ENTRANCE))
1185 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
1186 have_flag(f_ptr->flags, FF_TOWN) ||
1187 have_flag(f_ptr->flags, FF_SHALLOW) ||
1188 have_flag(f_ptr->flags, FF_DEEP))
1194 /* Pick proper indefinite article */
1195 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
1199 /* Display a message */
1203 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
1204 else sprintf(f_idx_str, "%d", g_ptr->feat);
1206 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]);
1208 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);
1213 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
1215 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1219 move_cursor_relative(y, x);
1222 /* Always stop at "normal" keys */
1223 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1226 /* Stop on everything but "return" */
1227 if ((query != '\r') && (query != '\n')) return query;
1229 /* Repeat forever */
1235 * Handle "target" and "look".
1237 * Note that this code can be called from "get_aim_dir()".
1239 * All locations must be on the current panel. Consider the use of
1240 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1241 * some form of "scrolling" the map around the cursor.
1242 * That is, consider the possibility of "auto-scrolling" the screen
1243 * while the cursor moves around. This may require changes in the
1244 * "update_monster()" code to allow "visibility" even if off panel, and
1245 * may require dynamic recalculation of the "temp" grid set.
1247 * Hack -- targeting/observing an "outer border grid" may induce
1248 * problems, so this is not currently allowed.
1250 * The player can use the direction keys to move among "interesting"
1251 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1252 * move through the "interesting" grids in a sequential manner, or
1253 * can enter "location" mode, and use the direction keys to move one
1254 * grid at a time in any direction. The "t" (set target) command will
1255 * only target a monster (as opposed to a location) if the monster is
1256 * target_able and the "interesting" mode is being used.
1258 * The current grid is described using the "look" method above, and
1259 * a new command may be entered at any time, but note that if the
1260 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1261 * where "space" has no obvious meaning) then "space" will scan
1262 * through the description of the current grid until done, instead
1263 * of immediately jumping to the next "interesting" grid. This
1264 * allows the "target" command to retain its old semantics.
1266 * The "*", "+", and "-" keys may always be used to jump immediately
1267 * to the next (or previous) interesting grid, in the proper mode.
1269 * The "return" key may always be used to scan through a complete
1270 * grid description (forever).
1272 * This command will cancel any old target, even if used from
1273 * inside the "look" command.
1275 bool target_set(BIT_FLAGS mode)
1278 POSITION y = p_ptr->y;
1279 POSITION x = p_ptr->x;
1289 get_screen_size(&wid, &hgt);
1294 if (rogue_like_commands)
1303 /* Prepare the "temp" array */
1304 target_set_prepare(mode);
1306 /* Start near the player */
1312 /* Interesting grids */
1313 if (flag && tmp_pos.n)
1319 change_panel_xy(y, x);
1321 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1324 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1327 if (target_able(g_ptr->m_idx))
1329 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1332 /* Dis-allow target */
1335 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1341 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1342 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
1343 strcat(info, cheatinfo);
1346 /* Describe and Prompt */
1348 query = target_set_aux(y, x, mode, info);
1352 /* Assume no "direction" */
1357 if (query == '\r') query = 't';
1375 if (target_able(g_ptr->m_idx))
1377 health_track(g_ptr->m_idx);
1378 target_who = g_ptr->m_idx;
1394 if (++m == tmp_pos.n)
1397 if (!expand_list) done = TRUE;
1407 if (!expand_list) done = TRUE;
1414 /* Recenter the map around the player */
1416 p_ptr->update |= (PU_MONSTERS);
1417 p_ptr->redraw |= (PR_MAP);
1418 p_ptr->window |= (PW_OVERHEAD);
1421 /* Recalculate interesting grids */
1422 target_set_prepare(mode);
1441 if(query == same_key)
1443 if (++m == tmp_pos.n)
1446 if (!expand_list) done = TRUE;
1451 /* Extract the action (if any) */
1452 d = get_keymap_dir(query);
1459 /* Hack -- move around */
1462 /* Modified to scroll to monster */
1463 POSITION y2 = panel_row_min;
1464 POSITION x2 = panel_col_min;
1466 /* Find a new monster */
1467 i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]);
1469 /* Request to target past last interesting grid */
1470 while (flag && (i < 0))
1472 /* Note the change */
1473 if (change_panel(ddy[d], ddx[d]))
1475 int v = tmp_pos.y[m];
1476 int u = tmp_pos.x[m];
1478 /* Recalculate interesting grids */
1479 target_set_prepare(mode);
1481 /* Look at interesting grids */
1484 /* Find a new monster */
1485 i = target_pick(v, u, ddy[d], ddx[d]);
1491 /* Nothing interesting */
1494 POSITION dx = ddx[d];
1495 POSITION dy = ddy[d];
1497 /* Restore previous position */
1500 panel_bounds_center();
1502 p_ptr->update |= (PU_MONSTERS);
1503 p_ptr->redraw |= (PR_MAP);
1504 p_ptr->window |= (PW_OVERHEAD);
1507 /* Recalculate interesting grids */
1508 target_set_prepare(mode);
1510 /* Look at boring grids */
1517 /* Do not move horizontally if unnecessary */
1518 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1519 ((x > panel_col_min + wid / 2) && (dx < 0)))
1524 /* Do not move vertically if unnecessary */
1525 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1526 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1531 /* Apply the motion */
1532 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1533 (x >= panel_col_min+wid) || (x < panel_col_min))
1535 if (change_panel(dy, dx)) target_set_prepare(mode);
1538 /* Slide into legality */
1539 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1540 else if (x <= 0) x = 1;
1542 /* Slide into legality */
1543 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1544 else if (y <= 0) y = 1;
1553 /* Arbitrary grids */
1556 bool move_fast = FALSE;
1558 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1561 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1563 /* Default prompt */
1564 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1569 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1570 los(p_ptr->y, p_ptr->x, y, x),
1571 projectable(p_ptr->y, p_ptr->x, y, x));
1572 strcat(info, cheatinfo);
1575 /* Describe and Prompt (enable "TARGET_LOOK") */
1576 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
1578 /* Assume no direction */
1583 if (query == '\r') query = 't';
1586 /* Analyze the keypress */
1610 /* Recenter the map around the player */
1612 p_ptr->update |= (PU_MONSTERS);
1613 p_ptr->redraw |= (PR_MAP);
1614 p_ptr->window |= (PW_OVERHEAD);
1617 /* Recalculate interesting grids */
1618 target_set_prepare(mode);
1640 /* Pick a nearby monster */
1641 for (i = 0; i < tmp_pos.n; i++)
1643 t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]);
1653 /* Nothing interesting */
1654 if (bd == 999) flag = FALSE;
1661 /* Extract the action (if any) */
1662 d = get_keymap_dir(query);
1664 /* XTRA HACK MOVEFAST */
1665 if (isupper(query)) move_fast = TRUE;
1672 /* Handle "direction" */
1675 POSITION dx = ddx[d];
1676 POSITION dy = ddy[d];
1678 /* XTRA HACK MOVEFAST */
1681 int mag = MIN(wid / 2, hgt / 2);
1691 /* Do not move horizontally if unnecessary */
1692 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1693 ((x > panel_col_min + wid / 2) && (dx < 0)))
1698 /* Do not move vertically if unnecessary */
1699 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1700 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1705 /* Apply the motion */
1706 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1707 (x >= panel_col_min + wid) || (x < panel_col_min))
1709 if (change_panel(dy, dx)) target_set_prepare(mode);
1712 /* Slide into legality */
1713 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1714 else if (x <= 0) x = 1;
1716 /* Slide into legality */
1717 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1718 else if (y <= 0) y = 1;
1726 /* Clear the top line */
1729 /* Recenter the map around the player */
1731 p_ptr->update |= (PU_MONSTERS);
1732 p_ptr->redraw |= (PR_MAP);
1733 p_ptr->window |= (PW_OVERHEAD);
1736 /* Failure to set target */
1737 if (!target_who) return (FALSE);
1745 * Get an "aiming direction" from the user.
1747 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1748 * "0" for "current target", and "-1" for "entry aborted".
1750 * Note that "Force Target", if set, will pre-empt user interaction,
1751 * if there is a usable target already set.
1753 * Note that confusion over-rides any (explicit?) user choice.
1755 bool get_aim_dir(DIRECTION *dp)
1764 /* Global direction */
1767 /* Hack -- auto-target if requested */
1768 if (use_old_target && target_okay()) dir = 5;
1770 if (repeat_pull(&code))
1775 if (!(code == 5 && !target_okay()))
1777 /* return (TRUE); */
1778 dir = (DIRECTION)code;
1781 *dp = (DIRECTION)code;
1783 /* Ask until satisfied */
1786 /* Choose a prompt */
1789 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
1793 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
1796 /* Get a command (or Cancel) */
1797 if (!get_com(p, &command, TRUE)) break;
1801 if (command == '\r') command = 't';
1804 /* Convert various keys to "standard" keys */
1807 /* Use current target */
1818 /* Set new target */
1823 if (target_set(TARGET_KILL)) dir = 5;
1829 /* Extract the action (if any) */
1830 dir = get_keymap_dir(command);
1836 /* Verify requested targets */
1837 if ((dir == 5) && !target_okay()) dir = 0;
1846 project_length = 0; /* reset to default */
1850 /* Save the direction */
1853 /* Check for confusion */
1854 if (p_ptr->confused)
1856 /* Random direction */
1857 dir = ddd[randint0(8)];
1860 /* Notice confusion */
1861 if (command_dir != dir)
1864 msg_print(_("あなたは混乱している。", "You are confused."));
1867 /* Save direction */
1870 /* repeat_push(dir); */
1871 repeat_push((COMMAND_CODE)command_dir);
1873 /* A "valid" direction was entered */
1878 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
1886 /* Global direction */
1889 if (repeat_pull(&code))
1891 dir = (DIRECTION)code;
1892 /* return (TRUE); */
1894 *dp = (DIRECTION)code;
1898 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
1902 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
1905 /* Get a direction */
1910 /* Get a command (or Cancel) */
1911 if (!get_com(prompt, &ch, TRUE)) break;
1914 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
1920 /* Look up the direction */
1921 dir = get_keymap_dir(ch);
1927 /* Prevent weirdness */
1928 if ((dir == 5) && (!allow_under)) dir = 0;
1931 if (!dir) return (FALSE);
1933 /* Save desired direction */
1936 /* Apply "confusion" */
1937 if (p_ptr->confused)
1939 /* Standard confusion */
1940 if (randint0(100) < 75)
1942 /* Random direction */
1943 dir = ddd[randint0(8)];
1946 else if (p_ptr->riding && with_steed)
1948 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1949 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1951 if (MON_CONFUSED(m_ptr))
1953 /* Standard confusion */
1954 if (randint0(100) < 75)
1956 /* Random direction */
1957 dir = ddd[randint0(8)];
1960 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
1962 /* Random direction */
1963 dir = ddd[randint0(8)];
1965 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
1967 /* Random direction */
1968 dir = ddd[randint0(8)];
1972 /* Notice confusion */
1973 if (command_dir != dir)
1975 if (p_ptr->confused)
1978 msg_print(_("あなたは混乱している。", "You are confused."));
1982 GAME_TEXT m_name[MAX_NLEN];
1983 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
1985 monster_desc(m_name, m_ptr, 0);
1986 if (MON_CONFUSED(m_ptr))
1988 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
1992 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
1997 /* Save direction */
2000 /* repeat_push(dir); */
2001 repeat_push((COMMAND_CODE)command_dir);
2008 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
2009 * and place it into "command_dir", unless we already have one.
2011 * This function should be used for all "repeatable" commands, such as
2012 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
2013 * as all commands which must reference a grid adjacent to the player,
2014 * and which may not reference the grid under the player. Note that,
2015 * for example, it is no longer possible to "disarm" or "open" chests
2016 * in the same grid as the player.
2018 * Direction "5" is illegal and will (cleanly) abort the command.
2020 * This function tracks and uses the "global direction", and uses
2021 * that as the "desired direction", to which "confusion" is applied.
2023 bool get_rep_dir(DIRECTION *dp, bool under)
2031 /* Global direction */
2034 if (repeat_pull(&code))
2036 dir = (DIRECTION)code;
2037 /* return (TRUE); */
2039 *dp = (DIRECTION)code;
2043 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
2047 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
2050 /* Get a direction */
2055 /* Get a command (or Cancel) */
2056 if (!get_com(prompt, &ch, TRUE)) break;
2059 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
2065 /* Look up the direction */
2066 dir = get_keymap_dir(ch);
2072 /* Prevent weirdness */
2073 if ((dir == 5) && (!under)) dir = 0;
2076 if (!dir) return (FALSE);
2078 /* Save desired direction */
2081 /* Apply "confusion" */
2082 if (p_ptr->confused)
2084 /* Standard confusion */
2085 if (randint0(100) < 75)
2087 /* Random direction */
2088 dir = ddd[randint0(8)];
2091 else if (p_ptr->riding)
2093 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2094 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2096 if (MON_CONFUSED(m_ptr))
2098 /* Standard confusion */
2099 if (randint0(100) < 75)
2101 /* Random direction */
2102 dir = ddd[randint0(8)];
2105 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2107 /* Random direction */
2108 dir = ddd[randint0(8)];
2110 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2112 /* Random direction */
2113 dir = ddd[randint0(8)];
2117 /* Notice confusion */
2118 if (command_dir != dir)
2120 if (p_ptr->confused)
2123 msg_print(_("あなたは混乱している。", "You are confused."));
2127 GAME_TEXT m_name[MAX_NLEN];
2128 monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2130 monster_desc(m_name, m_ptr, 0);
2131 if (MON_CONFUSED(m_ptr))
2133 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2137 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2142 /* Save direction */
2145 /* repeat_push(dir); */
2146 repeat_push((COMMAND_CODE)command_dir);
2154 * XAngband: determine if a given location is "interesting"
2155 * based on target_set_accept function.
2157 static bool tgt_pt_accept(POSITION y, POSITION x)
2162 if (!(in_bounds(y, x))) return (FALSE);
2164 /* Player grid is always interesting */
2165 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
2167 /* Handle hallucination */
2168 if (p_ptr->image) return (FALSE);
2170 /* Examine the grid */
2171 g_ptr = ¤t_floor_ptr->grid_array[y][x];
2173 /* Interesting memorized features */
2174 if (g_ptr->info & (CAVE_MARK))
2177 if (cave_have_flag_grid(g_ptr, FF_LESS)) return (TRUE);
2178 if (cave_have_flag_grid(g_ptr, FF_MORE)) return (TRUE);
2180 /* Notice quest features */
2181 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return (TRUE);
2182 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return (TRUE);
2190 * XAngband: Prepare the "temp" array for "tget_pt"
2191 * based on target_set_prepare funciton.
2193 static void tgt_pt_prepare(void)
2197 /* Reset "temp" array */
2200 if (!expand_list) return;
2202 /* Scan the current panel */
2203 for (y = 1; y < current_floor_ptr->height; y++)
2205 for (x = 1; x < current_floor_ptr->width; x++)
2207 /* Require "interesting" contents */
2208 if (!tgt_pt_accept(y, x)) continue;
2210 /* Save the location */
2211 tmp_pos.x[tmp_pos.n] = x;
2212 tmp_pos.y[tmp_pos.n] = y;
2217 /* Target the nearest monster for shooting */
2218 ang_sort_comp = ang_sort_comp_distance;
2219 ang_sort_swap = ang_sort_swap_distance;
2221 /* Sort the positions */
2222 ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n);
2226 * old -- from PsiAngband.
2228 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
2233 bool success = FALSE;
2237 get_screen_size(&wid, &hgt);
2247 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2248 msg_flag = FALSE; /* prevents "-more-" message. */
2250 while ((ch != ESCAPE) && !success)
2252 bool move_fast = FALSE;
2254 move_cursor_relative(y, x);
2266 if (player_bold(y, x)) ch = 0;
2269 else success = TRUE;
2273 /* XAngband: Move cursor to stairs */
2276 if (expand_list && tmp_pos.n)
2279 int cx = (panel_col_min + panel_col_max) / 2;
2280 int cy = (panel_row_min + panel_row_max) / 2;
2284 /* Skip stairs which have defferent distance */
2285 for (; n < tmp_pos.n; ++ n)
2287 grid_type *g_ptr = ¤t_floor_ptr->grid_array[tmp_pos.y[n]][tmp_pos.x[n]];
2289 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2290 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2297 if (n == tmp_pos.n) /* Loop out taget list */
2302 verify_panel(); /* Move cursor to player */
2304 p_ptr->update |= (PU_MONSTERS);
2306 p_ptr->redraw |= (PR_MAP);
2308 p_ptr->window |= (PW_OVERHEAD);
2311 else /* move cursor to next stair and change panel */
2316 dy = 2 * (y - cy) / hgt;
2317 dx = 2 * (x - cx) / wid;
2318 if (dy || dx) change_panel(dy, dx);
2324 /* Look up the direction */
2325 d = get_keymap_dir(ch);
2327 /* XTRA HACK MOVEFAST */
2328 if (isupper(ch)) move_fast = TRUE;
2330 /* Handle "direction" */
2336 /* XTRA HACK MOVEFAST */
2339 int mag = MIN(wid / 2, hgt / 2);
2349 /* Do not move horizontally if unnecessary */
2350 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2351 ((x > panel_col_min + wid / 2) && (dx < 0)))
2356 /* Do not move vertically if unnecessary */
2357 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2358 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2363 /* Apply the motion */
2364 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2365 (x >= panel_col_min + wid) || (x < panel_col_min))
2367 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
2368 change_panel(dy, dx);
2371 /* Slide into legality */
2372 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
2373 else if (x <= 0) x = 1;
2375 /* Slide into legality */
2376 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
2377 else if (y <= 0) y = 1;
2384 /* Clear the top line */
2387 /* Recenter the map around the player */
2390 p_ptr->update |= (PU_MONSTERS);
2392 p_ptr->redraw |= (PR_MAP);
2394 p_ptr->window |= (PW_OVERHEAD);
2403 bool get_hack_dir(DIRECTION *dp)
2411 /* Global direction */
2414 /* (No auto-targeting) */
2416 /* Ask until satisfied */
2419 /* Choose a prompt */
2422 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2426 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2429 /* Get a command (or Cancel) */
2430 if (!get_com(p, &command, TRUE)) break;
2434 if (command == '\r') command = 't';
2437 /* Convert various keys to "standard" keys */
2440 /* Use current target */
2451 /* Set new target */
2456 if (target_set(TARGET_KILL)) dir = 5;
2462 /* Look up the direction */
2463 dir = get_keymap_dir(command);
2469 /* Verify requested targets */
2470 if ((dir == 5) && !target_okay()) dir = 0;
2477 if (!dir) return (FALSE);
2479 /* Save the direction */
2482 /* Check for confusion */
2483 if (p_ptr->confused)
2485 /* Random direction */
2486 dir = ddd[randint0(8)];
2489 /* Notice confusion */
2490 if (command_dir != dir)
2493 msg_print(_("あなたは混乱している。", "You are confused."));
2496 /* Save direction */
2499 /* A "valid" direction was entered */