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"
25 #include "floor-events.h"
27 #define REWARD_CHANCE 10
31 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
32 * Advance experience levels and print experience
35 void check_experience(void)
37 bool level_reward = FALSE;
38 bool level_mutation = FALSE;
39 bool level_inc_stat = FALSE;
40 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
41 PLAYER_LEVEL old_lev = p_ptr->lev;
43 /* Hack -- lower limit */
44 if (p_ptr->exp < 0) p_ptr->exp = 0;
45 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
46 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
48 /* Hack -- upper limit */
49 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
50 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
51 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
53 /* Hack -- maintain "max" experience */
54 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
56 /* Hack -- maintain "max max" experience */
57 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
59 /* Redraw experience */
60 p_ptr->redraw |= (PR_EXP);
64 /* Lose levels while possible */
65 while ((p_ptr->lev > 1) &&
66 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
70 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
71 p_ptr->redraw |= (PR_LEV | PR_TITLE);
72 p_ptr->window |= (PW_PLAYER);
77 /* Gain levels while possible */
78 while ((p_ptr->lev < PY_MAX_LEVEL) &&
79 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
84 /* Save the highest level */
85 if (p_ptr->lev > p_ptr->max_plv)
87 p_ptr->max_plv = p_ptr->lev;
89 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
90 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
94 if (p_ptr->prace == RACE_BEASTMAN)
96 if (one_in_(5)) level_mutation = TRUE;
98 level_inc_stat = TRUE;
100 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
105 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
107 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
108 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
109 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
119 if(!(p_ptr->max_plv % 10))
128 cnv_stat(p_ptr->stat_max[0], tmp);
129 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
130 cnv_stat(p_ptr->stat_max[1], tmp);
131 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
132 cnv_stat(p_ptr->stat_max[2], tmp);
133 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
134 cnv_stat(p_ptr->stat_max[3], tmp);
135 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
136 cnv_stat(p_ptr->stat_max[4], tmp);
137 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
138 cnv_stat(p_ptr->stat_max[5], tmp);
139 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
142 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
147 if ((choice >= 'a') && (choice <= 'f')) break;
149 for(n = 0; n < A_MAX; n++)
150 if (n != choice - 'a')
152 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
154 do_inc_stat(choice - 'a');
157 else if(!(p_ptr->max_plv % 2))
158 do_inc_stat(randint0(6));
163 msg_print(_("あなたは変わった気がする...", "You feel different..."));
164 (void)gain_random_mutation(0);
165 level_mutation = FALSE;
169 * 報酬でレベルが上ると再帰的に check_experience() が
174 gain_level_reward(0);
175 level_reward = FALSE;
178 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
179 p_ptr->redraw |= (PR_LEV | PR_TITLE);
180 p_ptr->window |= (PW_PLAYER | PW_SPELL);
184 /* Load an autopick preference file */
185 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
191 * @brief モンスターを撃破した際の述語メッセージを返す /
192 * Return monster death string
193 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
194 * @return 撃破されたモンスターの述語
196 concptr extract_note_dies(MONRACE_IDX r_idx)
198 monster_race *r_ptr = &r_info[r_idx];
199 /* Some monsters get "destroyed" */
200 if (!monster_living(r_idx))
204 for (i = 0; i < 4; i++)
206 if (r_ptr->blow[i].method == RBM_EXPLODE)
208 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
211 return _("を倒した。", " is destroyed.");
214 return _("は死んだ。", " dies.");
220 * @brief 現在のコンソール表示の縦横を返す。 /
221 * Get term size and calculate screen size
222 * @param wid_p コンソールの表示幅文字数を返す
223 * @param hgt_p コンソールの表示行数を返す
226 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
228 Term_get_size(wid_p, hgt_p);
229 *hgt_p -= ROW_MAP + 2;
230 *wid_p -= COL_MAP + 2;
231 if (use_bigtile) *wid_p /= 2;
236 * @brief コンソール上におけるマップ表示の左上位置を返す /
237 * Calculates current boundaries Called below and from "do_cmd_locate()".
240 void panel_bounds_center(void)
244 get_screen_size(&wid, &hgt);
246 panel_row_max = panel_row_min + hgt - 1;
247 panel_row_prt = panel_row_min - 1;
248 panel_col_max = panel_col_min + wid - 1;
249 panel_col_prt = panel_col_min - 13;
253 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
254 * @param y 変更先のフロアY座標
255 * @param x 変更先のフロアX座標
257 * Handle a request to change the current panel
258 * Return TRUE if the panel was changed.
259 * Also used in do_cmd_locate
260 * @return 実際に再描画が必要だった場合TRUEを返す
262 static bool change_panel_xy(POSITION y, POSITION x)
264 POSITION dy = 0, dx = 0;
267 get_screen_size(&wid, &hgt);
269 if (y < panel_row_min) dy = -1;
270 if (y > panel_row_max) dy = 1;
271 if (x < panel_col_min) dx = -1;
272 if (x > panel_col_max) dx = 1;
274 if (!dy && !dx) return (FALSE);
276 return change_panel(dy, dx);
281 * @brief マップ描画のフォーカスを当てるべき座標を更新する
283 * Given an row (y) and col (x), this routine detects when a move
284 * off the screen has occurred and figures new borders. -RAK-
285 * "Update" forces a "full update" to take place.
286 * The map is reprinted if necessary, and "TRUE" is returned.
287 * @return 実際に再描画が必要だった場合TRUEを返す
289 void verify_panel(void)
291 POSITION y = p_ptr->y;
292 POSITION x = p_ptr->x;
300 get_screen_size(&wid, &hgt);
302 max_prow_min = current_floor_ptr->height - hgt;
303 max_pcol_min = current_floor_ptr->width - wid;
305 /* Bounds checking */
306 if (max_prow_min < 0) max_prow_min = 0;
307 if (max_pcol_min < 0) max_pcol_min = 0;
309 /* Center on player */
310 if (center_player && (center_running || !running))
312 /* Center vertically */
313 prow_min = y - hgt / 2;
314 if (prow_min < 0) prow_min = 0;
315 else if (prow_min > max_prow_min) prow_min = max_prow_min;
317 /* Center horizontally */
318 pcol_min = x - wid / 2;
319 if (pcol_min < 0) pcol_min = 0;
320 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
324 prow_min = panel_row_min;
325 pcol_min = panel_col_min;
327 /* Scroll screen when 2 grids from top/bottom edge */
328 if (y > panel_row_max - 2)
330 while (y > prow_min + hgt-1 - 2)
332 prow_min += (hgt / 2);
336 if (y < panel_row_min + 2)
338 while (y < prow_min + 2)
340 prow_min -= (hgt / 2);
344 if (prow_min > max_prow_min) prow_min = max_prow_min;
345 if (prow_min < 0) prow_min = 0;
347 /* Scroll screen when 4 grids from left/right edge */
348 if (x > panel_col_max - 4)
350 while (x > pcol_min + wid-1 - 4)
352 pcol_min += (wid / 2);
356 if (x < panel_col_min + 4)
358 while (x < pcol_min + 4)
360 pcol_min -= (wid / 2);
364 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
365 if (pcol_min < 0) pcol_min = 0;
368 /* Check for "no change" */
369 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
371 /* Save the new panel info */
372 panel_row_min = prow_min;
373 panel_col_min = pcol_min;
375 /* Hack -- optional disturb on "panel change" */
376 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
378 /* Recalculate the boundaries */
379 panel_bounds_center();
381 p_ptr->update |= (PU_MONSTERS);
382 p_ptr->redraw |= (PR_MAP);
383 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
388 * Monster health description
390 concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
392 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
399 /* Determine if the monster is "living" */
400 living = monster_living(m_ptr->ap_r_idx);
402 /* Calculate a health "percentage" */
403 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
405 /* Healthy monsters */
406 if (m_ptr->hp >= m_ptr->maxhp)
408 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
413 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
418 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
423 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
428 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
431 /* Need attitude information? */
434 /* Full information is not needed */
437 else if (is_pet(m_ptr))
439 attitude = _(", ペット", ", pet");
441 else if (is_friendly(m_ptr))
443 attitude = _(", 友好的", ", friendly");
447 attitude = _("", "");
451 if (m_ptr->smart & SM_CLONED)
460 /* Display monster's level --- idea borrowed from ToME */
461 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
463 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
467 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
474 /*** Targeting Code ***/
478 * Determine is a monster makes a reasonable target
480 * The concept of "targeting" was stolen from "Morgul" (?)
482 * The player can target any location, or any "target-able" monster.
484 * Currently, a monster is "target_able" if it is visible, and if
485 * the player can hit it with a projection, and the player is not
486 * hallucinating. This allows use of "use closest target" macros.
488 * Future versions may restrict the ability to target "trappers"
489 * and "mimics", but the semantics is a little bit weird.
491 bool target_able(MONSTER_IDX m_idx)
493 monster_type *m_ptr = &m_list[m_idx];
495 /* Monster must be alive */
496 if (!m_ptr->r_idx) return (FALSE);
498 /* Hack -- no targeting hallucinations */
499 if (p_ptr->image) return (FALSE);
501 /* Monster must be visible */
502 if (!m_ptr->ml) return (FALSE);
504 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
506 /* Monster must be projectable */
507 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
509 /* Hack -- Never target trappers */
510 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
520 * Update (if necessary) and verify (if possible) the target.
522 * We return TRUE if the target is "okay" and FALSE otherwise.
524 bool target_okay(void)
526 /* Accept stationary targets */
527 if (target_who < 0) return (TRUE);
529 /* Check moving targets */
532 /* Accept reasonable targets */
533 if (target_able(target_who))
535 monster_type *m_ptr = &m_list[target_who];
537 /* Acquire monster location */
538 target_row = m_ptr->fy;
539 target_col = m_ptr->fx;
546 /* Assume no target */
552 * Sorting hook -- comp function -- by "distance to player"
554 * We use "u" and "v" to point to arrays of "x" and "y" positions,
555 * and sort the arrays by double-distance to the player.
557 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
559 POSITION *x = (POSITION*)(u);
560 POSITION *y = (POSITION*)(v);
562 POSITION da, db, kx, ky;
564 /* Absolute distance components */
565 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
566 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
568 /* Approximate Double Distance to the first point */
569 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
571 /* Absolute distance components */
572 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
573 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
575 /* Approximate Double Distance to the first point */
576 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
578 /* Compare the distances */
584 * Sorting hook -- comp function -- by importance level of grids
586 * We use "u" and "v" to point to arrays of "x" and "y" positions,
587 * and sort the arrays by level of monster
589 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
591 POSITION *x = (POSITION*)(u);
592 POSITION *y = (POSITION*)(v);
593 grid_type *ca_ptr = ¤t_floor_ptr->grid_array[y[a]][x[a]];
594 grid_type *cb_ptr = ¤t_floor_ptr->grid_array[y[b]][x[b]];
595 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
596 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
597 monster_race *ap_ra_ptr, *ap_rb_ptr;
599 /* The player grid */
600 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
601 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
603 /* Extract monster race */
604 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
605 else ap_ra_ptr = NULL;
606 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
607 else ap_rb_ptr = NULL;
609 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
610 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
612 /* Compare two monsters */
613 if (ap_ra_ptr && ap_rb_ptr)
615 /* Unique monsters first */
616 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
617 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
619 /* Shadowers first (あやしい影) */
620 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
621 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
623 /* Unknown monsters first */
624 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
625 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
627 /* Higher level monsters first (if known) */
628 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
630 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
631 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
634 /* Sort by index if all conditions are same */
635 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
636 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
639 /* An object get higher priority */
640 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;
641 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;
643 /* Priority from the terrain */
644 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
645 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
647 /* If all conditions are same, compare distance */
648 return ang_sort_comp_distance(u, v, a, b);
653 * Sorting hook -- swap function -- by "distance to player"
655 * We use "u" and "v" to point to arrays of "x" and "y" positions,
656 * and sort the arrays by distance to the player.
658 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
660 POSITION *x = (POSITION*)(u);
661 POSITION *y = (POSITION*)(v);
679 * Hack -- help "select" a location (see below)
681 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
684 POSITION x2, y2, x3, y3, x4, y4;
685 POSITION_IDX b_i = -1, b_v = 9999;
688 /* Scan the locations */
689 for (i = 0; i < temp_n; i++)
695 /* Directed distance */
699 /* Verify quadrant */
700 if (dx && (x3 * dx <= 0)) continue;
701 if (dy && (y3 * dy <= 0)) continue;
703 /* Absolute distance */
707 /* Verify quadrant */
708 if (dy && !dx && (x4 > y4)) continue;
709 if (dx && !dy && (y4 > x4)) continue;
711 /* Approximate Double Distance */
712 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
714 /* Penalize location */
717 if ((b_i >= 0) && (v >= b_v)) continue;
727 * Hack -- determine if a given location is "interesting"
729 static bool target_set_accept(POSITION y, POSITION x)
732 OBJECT_IDX this_o_idx, next_o_idx = 0;
735 if (!(in_bounds(y, x))) return (FALSE);
737 /* Player grid is always interesting */
738 if (player_bold(y, x)) return (TRUE);
740 /* Handle hallucination */
741 if (p_ptr->image) return (FALSE);
743 /* Examine the grid */
744 g_ptr = ¤t_floor_ptr->grid_array[y][x];
746 /* Visible monsters */
749 monster_type *m_ptr = &m_list[g_ptr->m_idx];
751 /* Visible monsters */
752 if (m_ptr->ml) return (TRUE);
755 /* Scan all objects in the grid */
756 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
759 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
761 /* Acquire next object */
762 next_o_idx = o_ptr->next_o_idx;
764 /* Memorized object */
765 if (o_ptr->marked & OM_FOUND) return (TRUE);
768 /* Interesting memorized features */
769 if (g_ptr->info & (CAVE_MARK))
771 /* Notice object features */
772 if (g_ptr->info & CAVE_OBJECT) return (TRUE);
774 /* Feature code (applying "mimic" field) */
775 if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE)) return TRUE;
783 * Prepare the "temp" array for "target_set"
785 * Return the number of target_able monsters in the set.
787 static void target_set_prepare(BIT_FLAGS mode)
790 POSITION min_hgt, max_hgt, min_wid, max_wid;
792 if (mode & TARGET_KILL)
795 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
796 max_hgt = MIN((p_ptr->y + MAX_RANGE), current_floor_ptr->height - 1);
797 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
798 max_wid = MIN((p_ptr->x + MAX_RANGE), current_floor_ptr->width - 1);
800 else /* not targetting */
803 min_hgt = panel_row_min;
804 max_hgt = panel_row_max;
805 min_wid = panel_col_min;
806 max_wid = panel_col_max;
809 /* Reset "temp" array */
812 /* Scan the current panel */
813 for (y = min_hgt; y <= max_hgt; y++)
815 for (x = min_wid; x <= max_wid; x++)
819 /* Require "interesting" contents */
820 if (!target_set_accept(y, x)) continue;
822 g_ptr = ¤t_floor_ptr->grid_array[y][x];
824 /* Require target_able monsters for "TARGET_KILL" */
825 if ((mode & (TARGET_KILL)) && !target_able(g_ptr->m_idx)) continue;
827 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[g_ptr->m_idx])) continue;
829 /* Save the location */
836 /* Set the sort hooks */
837 if (mode & (TARGET_KILL))
839 /* Target the nearest monster for shooting */
840 ang_sort_comp = ang_sort_comp_distance;
841 ang_sort_swap = ang_sort_swap_distance;
845 /* Look important grids first in Look command */
846 ang_sort_comp = ang_sort_comp_importance;
847 ang_sort_swap = ang_sort_swap_distance;
850 /* Sort the positions */
851 ang_sort(temp_x, temp_y, temp_n);
853 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
858 temp_y[0] = temp_y[1];
861 temp_x[0] = temp_x[1];
866 void target_set_prepare_look(void){
867 target_set_prepare(TARGET_LOOK);
872 * Evaluate number of kill needed to gain level
874 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
876 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
878 s32b exp_mon, exp_adv;
879 u32b exp_mon_frac, exp_adv_frac;
881 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
886 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
896 /* The monster's experience point (assuming average monster speed) */
897 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
899 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
902 /* Total experience value for next level */
903 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
905 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
907 /* Experience value need to get */
908 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
911 /* You need to kill at least one monster to get any experience */
912 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
913 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
915 /* Extract number of monsters needed */
916 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
918 /* If 999 or more monsters needed, only display "999". */
919 num = MIN(999, exp_adv_frac);
921 /* Display the number */
922 sprintf(buf,"%03ld", (long int)num);
926 bool show_gold_on_floor = FALSE;
929 * Examine a grid, return a keypress.
931 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
932 * indicates that the "space" key should scan through the contents
933 * of the grid, instead of simply returning immediately. This lets
934 * the "look" command get complete information, without making the
935 * "target" command annoying.
937 * The "info" argument contains the "commands" which should be shown
938 * inside the "[xxx]" text. This string must never be empty, or grids
939 * containing monsters will be displayed with an extra comma.
941 * Note that if a monster is in the grid, we update both the monster
942 * recall info and the health bar info to track that monster.
944 * Eventually, we may allow multiple objects per grid, or objects
945 * and terrain features in the same grid.
947 * This function must handle blindness/hallucination.
949 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
951 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
952 OBJECT_IDX this_o_idx, next_o_idx = 0;
953 concptr s1 = "", s2 = "", s3 = "", x_info = "";
958 char out_val[MAX_NLEN+80];
959 OBJECT_IDX floor_list[23];
960 ITEM_NUMBER floor_num = 0;
962 /* Scan all objects in the grid */
965 floor_num = scan_floor(floor_list, y, x, 0x02);
969 x_info = _("x物 ", "x,");
973 /* Hack -- under the player */
974 if (player_bold(y, x))
987 s1 = _("ターゲット:", "Target:");
990 /* Hack -- hallucination */
993 concptr name = _("何か奇妙な物", "something strange");
995 /* Display a message */
997 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
999 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1003 move_cursor_relative(y, x);
1006 /* Stop on everything but "return" */
1007 if ((query != '\r') && (query != '\n')) return query;
1009 /* Repeat forever */
1014 /* Actual monsters */
1015 if (g_ptr->m_idx && m_list[g_ptr->m_idx].ml)
1017 monster_type *m_ptr = &m_list[g_ptr->m_idx];
1018 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
1019 GAME_TEXT m_name[MAX_NLEN];
1020 bool recall = FALSE;
1025 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1026 monster_race_track(m_ptr->ap_r_idx);
1027 health_track(g_ptr->m_idx);
1040 /* Recall on screen */
1041 screen_roff(m_ptr->ap_r_idx, 0);
1043 /* Hack -- Complete the prompt (again) */
1044 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
1051 /* Normal commands */
1052 if (query != 'r') break;
1057 /* Cleare recall text and repeat */
1063 /* Describe, and prompt for recall */
1064 evaluate_monster_exp(acount, m_ptr);
1067 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);
1069 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);
1075 move_cursor_relative(y, x);
1080 /* Normal commands */
1081 if (query != 'r') break;
1087 /* Always stop at "normal" keys */
1088 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1090 /* Sometimes stop at "space" key */
1091 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
1093 /* Change the intro */
1094 s1 = _("それは", "It is ");
1096 /* Hack -- take account of gender */
1097 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
1098 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
1100 /* Use a preposition */
1109 /* Scan all objects being carried */
1110 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
1112 GAME_TEXT o_name[MAX_NLEN];
1115 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
1117 /* Acquire next object */
1118 next_o_idx = o_ptr->next_o_idx;
1120 /* Obtain an object description */
1121 object_desc(o_name, o_ptr, 0);
1124 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1126 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1130 move_cursor_relative(y, x);
1133 /* Always stop at "normal" keys */
1134 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1136 /* Sometimes stop at "space" key */
1137 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
1139 /* Change the intro */
1140 s2 = _("をまた", "also carrying ");
1143 /* Use a preposition */
1160 GAME_TEXT o_name[MAX_NLEN];
1163 o_ptr = ¤t_floor_ptr->o_list[floor_list[0]];
1165 object_desc(o_name, o_ptr, 0);
1168 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1170 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1174 move_cursor_relative(y, x);
1183 /* Provide one cushion before item listing */
1186 /* Display rough information about items */
1188 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
1190 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
1194 move_cursor_relative(y, x);
1199 /* No request for listing */
1200 if (query != 'x' && query != ' ') return query;
1204 /** Display list of items **/
1206 /* Continue scrolling list if requested */
1214 show_gold_on_floor = TRUE;
1215 (void)show_floor(0, y, x, &min_width);
1216 show_gold_on_floor = FALSE;
1220 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
1222 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
1229 /* Exit unless 'Enter' */
1230 if (query != '\n' && query != '\r')
1235 /* Get the object being moved. */
1236 o_idx = g_ptr->o_idx;
1238 /* Only rotate a pile of two or more objects. */
1239 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) continue;
1241 /* Remove the first object from the list. */
1242 excise_object_idx(o_idx);
1244 /* Find end of the list. */
1246 while (current_floor_ptr->o_list[i].next_o_idx)
1247 i = current_floor_ptr->o_list[i].next_o_idx;
1249 /* Add after the last object. */
1250 current_floor_ptr->o_list[i].next_o_idx = o_idx;
1252 /* Loop and re-display the list */
1259 /* Scan all objects in the grid */
1260 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1263 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
1265 /* Acquire next object */
1266 next_o_idx = o_ptr->next_o_idx;
1268 if (o_ptr->marked & OM_FOUND)
1270 GAME_TEXT o_name[MAX_NLEN];
1275 /* Obtain an object description */
1276 object_desc(o_name, o_ptr, 0);
1279 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1281 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1285 move_cursor_relative(y, x);
1288 /* Always stop at "normal" keys */
1289 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1291 /* Sometimes stop at "space" key */
1292 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
1294 /* Change the intro */
1295 s1 = _("それは", "It is ");
1298 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
1312 /* Feature code (applying "mimic" field) */
1313 feat = get_feat_mimic(g_ptr);
1315 /* Require knowledge about grid, or ability to see grid */
1316 if (!(g_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
1318 /* Forget feature */
1322 f_ptr = &f_info[feat];
1324 /* Terrain feature if needed */
1325 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
1329 /* Hack -- special handling for quest entrances */
1330 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
1332 /* Set the quest number temporary */
1333 IDX old_quest = p_ptr->inside_quest;
1336 /* Clear the text */
1337 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
1338 quest_text_line = 0;
1340 p_ptr->inside_quest = g_ptr->special;
1342 /* Get the quest text */
1343 init_flags = INIT_NAME_ONLY;
1345 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
1347 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
1348 quest[g_ptr->special].name, quest[g_ptr->special].level);
1350 /* Reset the old quest number */
1351 p_ptr->inside_quest = old_quest;
1354 /* Hack -- special handling for building doors */
1355 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
1357 name = building[f_ptr->subtype].name;
1359 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
1361 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[g_ptr->special].text, d_info[g_ptr->special].mindepth);
1363 else if (have_flag(f_ptr->flags, FF_TOWN))
1365 name = town_info[g_ptr->special].name;
1367 else if (p_ptr->wild_mode && (feat == feat_floor))
1369 name = _("道", "road");
1373 name = f_name + f_ptr->name;
1379 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
1380 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
1381 have_flag(f_ptr->flags, FF_TOWN)))
1383 s2 = _("の中", "in ");
1386 /* Hack -- special introduction for store & building doors -KMW- */
1387 if (have_flag(f_ptr->flags, FF_STORE) ||
1388 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
1389 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
1390 have_flag(f_ptr->flags, FF_ENTRANCE))
1395 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
1396 have_flag(f_ptr->flags, FF_TOWN) ||
1397 have_flag(f_ptr->flags, FF_SHALLOW) ||
1398 have_flag(f_ptr->flags, FF_DEEP))
1404 /* Pick proper indefinite article */
1405 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
1409 /* Display a message */
1413 if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic);
1414 else sprintf(f_idx_str, "%d", g_ptr->feat);
1416 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]);
1418 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);
1423 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
1425 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1429 move_cursor_relative(y, x);
1432 /* Always stop at "normal" keys */
1433 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1436 /* Stop on everything but "return" */
1437 if ((query != '\r') && (query != '\n')) return query;
1439 /* Repeat forever */
1445 * Handle "target" and "look".
1447 * Note that this code can be called from "get_aim_dir()".
1449 * All locations must be on the current panel. Consider the use of
1450 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1451 * some form of "scrolling" the map around the cursor.
1452 * That is, consider the possibility of "auto-scrolling" the screen
1453 * while the cursor moves around. This may require changes in the
1454 * "update_monster()" code to allow "visibility" even if off panel, and
1455 * may require dynamic recalculation of the "temp" grid set.
1457 * Hack -- targeting/observing an "outer border grid" may induce
1458 * problems, so this is not currently allowed.
1460 * The player can use the direction keys to move among "interesting"
1461 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1462 * move through the "interesting" grids in a sequential manner, or
1463 * can enter "location" mode, and use the direction keys to move one
1464 * grid at a time in any direction. The "t" (set target) command will
1465 * only target a monster (as opposed to a location) if the monster is
1466 * target_able and the "interesting" mode is being used.
1468 * The current grid is described using the "look" method above, and
1469 * a new command may be entered at any time, but note that if the
1470 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1471 * where "space" has no obvious meaning) then "space" will scan
1472 * through the description of the current grid until done, instead
1473 * of immediately jumping to the next "interesting" grid. This
1474 * allows the "target" command to retain its old semantics.
1476 * The "*", "+", and "-" keys may always be used to jump immediately
1477 * to the next (or previous) interesting grid, in the proper mode.
1479 * The "return" key may always be used to scan through a complete
1480 * grid description (forever).
1482 * This command will cancel any old target, even if used from
1483 * inside the "look" command.
1485 bool target_set(BIT_FLAGS mode)
1488 POSITION y = p_ptr->y;
1489 POSITION x = p_ptr->x;
1499 get_screen_size(&wid, &hgt);
1504 if (rogue_like_commands)
1513 /* Prepare the "temp" array */
1514 target_set_prepare(mode);
1516 /* Start near the player */
1522 /* Interesting grids */
1529 change_panel_xy(y, x);
1531 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1534 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1537 if (target_able(g_ptr->m_idx))
1539 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1542 /* Dis-allow target */
1545 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1551 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1552 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
1553 strcat(info, cheatinfo);
1556 /* Describe and Prompt */
1558 query = target_set_aux(y, x, mode, info);
1562 /* Assume no "direction" */
1567 if (query == '\r') query = 't';
1585 if (target_able(g_ptr->m_idx))
1587 health_track(g_ptr->m_idx);
1588 target_who = g_ptr->m_idx;
1607 if (!expand_list) done = TRUE;
1617 if (!expand_list) done = TRUE;
1624 /* Recenter the map around the player */
1626 p_ptr->update |= (PU_MONSTERS);
1627 p_ptr->redraw |= (PR_MAP);
1628 p_ptr->window |= (PW_OVERHEAD);
1631 /* Recalculate interesting grids */
1632 target_set_prepare(mode);
1651 if(query == same_key)
1656 if (!expand_list) done = TRUE;
1661 /* Extract the action (if any) */
1662 d = get_keymap_dir(query);
1669 /* Hack -- move around */
1672 /* Modified to scroll to monster */
1673 POSITION y2 = panel_row_min;
1674 POSITION x2 = panel_col_min;
1676 /* Find a new monster */
1677 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
1679 /* Request to target past last interesting grid */
1680 while (flag && (i < 0))
1682 /* Note the change */
1683 if (change_panel(ddy[d], ddx[d]))
1688 /* Recalculate interesting grids */
1689 target_set_prepare(mode);
1691 /* Look at interesting grids */
1694 /* Find a new monster */
1695 i = target_pick(v, u, ddy[d], ddx[d]);
1701 /* Nothing interesting */
1704 POSITION dx = ddx[d];
1705 POSITION dy = ddy[d];
1707 /* Restore previous position */
1710 panel_bounds_center();
1712 p_ptr->update |= (PU_MONSTERS);
1713 p_ptr->redraw |= (PR_MAP);
1714 p_ptr->window |= (PW_OVERHEAD);
1717 /* Recalculate interesting grids */
1718 target_set_prepare(mode);
1720 /* Look at boring grids */
1727 /* Do not move horizontally if unnecessary */
1728 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1729 ((x > panel_col_min + wid / 2) && (dx < 0)))
1734 /* Do not move vertically if unnecessary */
1735 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1736 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1741 /* Apply the motion */
1742 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
1743 (x >= panel_col_min+wid) || (x < panel_col_min))
1745 if (change_panel(dy, dx)) target_set_prepare(mode);
1748 /* Slide into legality */
1749 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1750 else if (x <= 0) x = 1;
1752 /* Slide into legality */
1753 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1754 else if (y <= 0) y = 1;
1763 /* Arbitrary grids */
1766 bool move_fast = FALSE;
1768 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1771 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1773 /* Default prompt */
1774 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
1779 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1780 los(p_ptr->y, p_ptr->x, y, x),
1781 projectable(p_ptr->y, p_ptr->x, y, x));
1782 strcat(info, cheatinfo);
1785 /* Describe and Prompt (enable "TARGET_LOOK") */
1786 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
1788 /* Assume no direction */
1793 if (query == '\r') query = 't';
1796 /* Analyze the keypress */
1820 /* Recenter the map around the player */
1822 p_ptr->update |= (PU_MONSTERS);
1823 p_ptr->redraw |= (PR_MAP);
1824 p_ptr->window |= (PW_OVERHEAD);
1827 /* Recalculate interesting grids */
1828 target_set_prepare(mode);
1850 /* Pick a nearby monster */
1851 for (i = 0; i < temp_n; i++)
1853 t = distance(y, x, temp_y[i], temp_x[i]);
1863 /* Nothing interesting */
1864 if (bd == 999) flag = FALSE;
1871 /* Extract the action (if any) */
1872 d = get_keymap_dir(query);
1874 /* XTRA HACK MOVEFAST */
1875 if (isupper(query)) move_fast = TRUE;
1882 /* Handle "direction" */
1885 POSITION dx = ddx[d];
1886 POSITION dy = ddy[d];
1888 /* XTRA HACK MOVEFAST */
1891 int mag = MIN(wid / 2, hgt / 2);
1901 /* Do not move horizontally if unnecessary */
1902 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
1903 ((x > panel_col_min + wid / 2) && (dx < 0)))
1908 /* Do not move vertically if unnecessary */
1909 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
1910 ((y > panel_row_min + hgt / 2) && (dy < 0)))
1915 /* Apply the motion */
1916 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
1917 (x >= panel_col_min + wid) || (x < panel_col_min))
1919 if (change_panel(dy, dx)) target_set_prepare(mode);
1922 /* Slide into legality */
1923 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
1924 else if (x <= 0) x = 1;
1926 /* Slide into legality */
1927 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
1928 else if (y <= 0) y = 1;
1936 /* Clear the top line */
1939 /* Recenter the map around the player */
1941 p_ptr->update |= (PU_MONSTERS);
1942 p_ptr->redraw |= (PR_MAP);
1943 p_ptr->window |= (PW_OVERHEAD);
1946 /* Failure to set target */
1947 if (!target_who) return (FALSE);
1955 * Get an "aiming direction" from the user.
1957 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
1958 * "0" for "current target", and "-1" for "entry aborted".
1960 * Note that "Force Target", if set, will pre-empt user interaction,
1961 * if there is a usable target already set.
1963 * Note that confusion over-rides any (explicit?) user choice.
1965 bool get_aim_dir(DIRECTION *dp)
1974 /* Global direction */
1977 /* Hack -- auto-target if requested */
1978 if (use_old_target && target_okay()) dir = 5;
1980 if (repeat_pull(&code))
1985 if (!(code == 5 && !target_okay()))
1987 /* return (TRUE); */
1988 dir = (DIRECTION)code;
1991 *dp = (DIRECTION)code;
1993 /* Ask until satisfied */
1996 /* Choose a prompt */
1999 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2003 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2006 /* Get a command (or Cancel) */
2007 if (!get_com(p, &command, TRUE)) break;
2011 if (command == '\r') command = 't';
2014 /* Convert various keys to "standard" keys */
2017 /* Use current target */
2028 /* Set new target */
2033 if (target_set(TARGET_KILL)) dir = 5;
2039 /* Extract the action (if any) */
2040 dir = get_keymap_dir(command);
2046 /* Verify requested targets */
2047 if ((dir == 5) && !target_okay()) dir = 0;
2056 project_length = 0; /* reset to default */
2060 /* Save the direction */
2063 /* Check for confusion */
2064 if (p_ptr->confused)
2066 /* Random direction */
2067 dir = ddd[randint0(8)];
2070 /* Notice confusion */
2071 if (command_dir != dir)
2074 msg_print(_("あなたは混乱している。", "You are confused."));
2077 /* Save direction */
2080 /* repeat_push(dir); */
2081 repeat_push((COMMAND_CODE)command_dir);
2083 /* A "valid" direction was entered */
2088 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
2096 /* Global direction */
2099 if (repeat_pull(&code))
2101 dir = (DIRECTION)code;
2102 /* return (TRUE); */
2104 *dp = (DIRECTION)code;
2108 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
2112 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
2115 /* Get a direction */
2120 /* Get a command (or Cancel) */
2121 if (!get_com(prompt, &ch, TRUE)) break;
2124 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
2130 /* Look up the direction */
2131 dir = get_keymap_dir(ch);
2137 /* Prevent weirdness */
2138 if ((dir == 5) && (!allow_under)) dir = 0;
2141 if (!dir) return (FALSE);
2143 /* Save desired direction */
2146 /* Apply "confusion" */
2147 if (p_ptr->confused)
2149 /* Standard confusion */
2150 if (randint0(100) < 75)
2152 /* Random direction */
2153 dir = ddd[randint0(8)];
2156 else if (p_ptr->riding && with_steed)
2158 monster_type *m_ptr = &m_list[p_ptr->riding];
2159 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2161 if (MON_CONFUSED(m_ptr))
2163 /* Standard confusion */
2164 if (randint0(100) < 75)
2166 /* Random direction */
2167 dir = ddd[randint0(8)];
2170 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2172 /* Random direction */
2173 dir = ddd[randint0(8)];
2175 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2177 /* Random direction */
2178 dir = ddd[randint0(8)];
2182 /* Notice confusion */
2183 if (command_dir != dir)
2185 if (p_ptr->confused)
2188 msg_print(_("あなたは混乱している。", "You are confused."));
2192 GAME_TEXT m_name[MAX_NLEN];
2193 monster_type *m_ptr = &m_list[p_ptr->riding];
2195 monster_desc(m_name, m_ptr, 0);
2196 if (MON_CONFUSED(m_ptr))
2198 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2202 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2207 /* Save direction */
2210 /* repeat_push(dir); */
2211 repeat_push((COMMAND_CODE)command_dir);
2218 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
2219 * and place it into "command_dir", unless we already have one.
2221 * This function should be used for all "repeatable" commands, such as
2222 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
2223 * as all commands which must reference a grid adjacent to the player,
2224 * and which may not reference the grid under the player. Note that,
2225 * for example, it is no longer possible to "disarm" or "open" chests
2226 * in the same grid as the player.
2228 * Direction "5" is illegal and will (cleanly) abort the command.
2230 * This function tracks and uses the "global direction", and uses
2231 * that as the "desired direction", to which "confusion" is applied.
2233 bool get_rep_dir(DIRECTION *dp, bool under)
2241 /* Global direction */
2244 if (repeat_pull(&code))
2246 dir = (DIRECTION)code;
2247 /* return (TRUE); */
2249 *dp = (DIRECTION)code;
2253 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
2257 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
2260 /* Get a direction */
2265 /* Get a command (or Cancel) */
2266 if (!get_com(prompt, &ch, TRUE)) break;
2269 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
2275 /* Look up the direction */
2276 dir = get_keymap_dir(ch);
2282 /* Prevent weirdness */
2283 if ((dir == 5) && (!under)) dir = 0;
2286 if (!dir) return (FALSE);
2288 /* Save desired direction */
2291 /* Apply "confusion" */
2292 if (p_ptr->confused)
2294 /* Standard confusion */
2295 if (randint0(100) < 75)
2297 /* Random direction */
2298 dir = ddd[randint0(8)];
2301 else if (p_ptr->riding)
2303 monster_type *m_ptr = &m_list[p_ptr->riding];
2304 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2306 if (MON_CONFUSED(m_ptr))
2308 /* Standard confusion */
2309 if (randint0(100) < 75)
2311 /* Random direction */
2312 dir = ddd[randint0(8)];
2315 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2317 /* Random direction */
2318 dir = ddd[randint0(8)];
2320 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2322 /* Random direction */
2323 dir = ddd[randint0(8)];
2327 /* Notice confusion */
2328 if (command_dir != dir)
2330 if (p_ptr->confused)
2333 msg_print(_("あなたは混乱している。", "You are confused."));
2337 GAME_TEXT m_name[MAX_NLEN];
2338 monster_type *m_ptr = &m_list[p_ptr->riding];
2340 monster_desc(m_name, m_ptr, 0);
2341 if (MON_CONFUSED(m_ptr))
2343 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2347 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2352 /* Save direction */
2355 /* repeat_push(dir); */
2356 repeat_push((COMMAND_CODE)command_dir);
2364 * XAngband: determine if a given location is "interesting"
2365 * based on target_set_accept function.
2367 static bool tgt_pt_accept(POSITION y, POSITION x)
2372 if (!(in_bounds(y, x))) return (FALSE);
2374 /* Player grid is always interesting */
2375 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
2377 /* Handle hallucination */
2378 if (p_ptr->image) return (FALSE);
2380 /* Examine the grid */
2381 g_ptr = ¤t_floor_ptr->grid_array[y][x];
2383 /* Interesting memorized features */
2384 if (g_ptr->info & (CAVE_MARK))
2387 if (cave_have_flag_grid(g_ptr, FF_LESS)) return (TRUE);
2388 if (cave_have_flag_grid(g_ptr, FF_MORE)) return (TRUE);
2390 /* Notice quest features */
2391 if (cave_have_flag_grid(g_ptr, FF_QUEST_ENTER)) return (TRUE);
2392 if (cave_have_flag_grid(g_ptr, FF_QUEST_EXIT)) return (TRUE);
2400 * XAngband: Prepare the "temp" array for "tget_pt"
2401 * based on target_set_prepare funciton.
2403 static void tgt_pt_prepare(void)
2407 /* Reset "temp" array */
2410 if (!expand_list) return;
2412 /* Scan the current panel */
2413 for (y = 1; y < current_floor_ptr->height; y++)
2415 for (x = 1; x < current_floor_ptr->width; x++)
2417 /* Require "interesting" contents */
2418 if (!tgt_pt_accept(y, x)) continue;
2420 /* Save the location */
2427 /* Target the nearest monster for shooting */
2428 ang_sort_comp = ang_sort_comp_distance;
2429 ang_sort_swap = ang_sort_swap_distance;
2431 /* Sort the positions */
2432 ang_sort(temp_x, temp_y, temp_n);
2436 * old -- from PsiAngband.
2438 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
2443 bool success = FALSE;
2447 get_screen_size(&wid, &hgt);
2457 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2458 msg_flag = FALSE; /* prevents "-more-" message. */
2460 while ((ch != ESCAPE) && !success)
2462 bool move_fast = FALSE;
2464 move_cursor_relative(y, x);
2476 if (player_bold(y, x)) ch = 0;
2479 else success = TRUE;
2483 /* XAngband: Move cursor to stairs */
2486 if (expand_list && temp_n)
2489 int cx = (panel_col_min + panel_col_max) / 2;
2490 int cy = (panel_row_min + panel_row_max) / 2;
2494 /* Skip stairs which have defferent distance */
2495 for (; n < temp_n; ++ n)
2497 grid_type *g_ptr = ¤t_floor_ptr->grid_array[temp_y[n]][temp_x[n]];
2499 if (cave_have_flag_grid(g_ptr, FF_STAIRS) &&
2500 cave_have_flag_grid(g_ptr, ch == '>' ? FF_MORE : FF_LESS))
2507 if (n == temp_n) /* Loop out taget list */
2512 verify_panel(); /* Move cursor to player */
2514 p_ptr->update |= (PU_MONSTERS);
2516 p_ptr->redraw |= (PR_MAP);
2518 p_ptr->window |= (PW_OVERHEAD);
2521 else /* move cursor to next stair and change panel */
2526 dy = 2 * (y - cy) / hgt;
2527 dx = 2 * (x - cx) / wid;
2528 if (dy || dx) change_panel(dy, dx);
2534 /* Look up the direction */
2535 d = get_keymap_dir(ch);
2537 /* XTRA HACK MOVEFAST */
2538 if (isupper(ch)) move_fast = TRUE;
2540 /* Handle "direction" */
2546 /* XTRA HACK MOVEFAST */
2549 int mag = MIN(wid / 2, hgt / 2);
2559 /* Do not move horizontally if unnecessary */
2560 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2561 ((x > panel_col_min + wid / 2) && (dx < 0)))
2566 /* Do not move vertically if unnecessary */
2567 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2568 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2573 /* Apply the motion */
2574 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2575 (x >= panel_col_min + wid) || (x < panel_col_min))
2577 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
2578 change_panel(dy, dx);
2581 /* Slide into legality */
2582 if (x >= current_floor_ptr->width-1) x = current_floor_ptr->width - 2;
2583 else if (x <= 0) x = 1;
2585 /* Slide into legality */
2586 if (y >= current_floor_ptr->height-1) y = current_floor_ptr->height- 2;
2587 else if (y <= 0) y = 1;
2594 /* Clear the top line */
2597 /* Recenter the map around the player */
2600 p_ptr->update |= (PU_MONSTERS);
2602 p_ptr->redraw |= (PR_MAP);
2604 p_ptr->window |= (PW_OVERHEAD);
2613 bool get_hack_dir(DIRECTION *dp)
2621 /* Global direction */
2624 /* (No auto-targeting) */
2626 /* Ask until satisfied */
2629 /* Choose a prompt */
2632 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2636 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2639 /* Get a command (or Cancel) */
2640 if (!get_com(p, &command, TRUE)) break;
2644 if (command == '\r') command = 't';
2647 /* Convert various keys to "standard" keys */
2650 /* Use current target */
2661 /* Set new target */
2666 if (target_set(TARGET_KILL)) dir = 5;
2672 /* Look up the direction */
2673 dir = get_keymap_dir(command);
2679 /* Verify requested targets */
2680 if ((dir == 5) && !target_okay()) dir = 0;
2687 if (!dir) return (FALSE);
2689 /* Save the direction */
2692 /* Check for confusion */
2693 if (p_ptr->confused)
2695 /* Random direction */
2696 dir = ddd[randint0(8)];
2699 /* Notice confusion */
2700 if (command_dir != dir)
2703 msg_print(_("あなたは混乱している。", "You are confused."));
2706 /* Save direction */
2709 /* A "valid" direction was entered */