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"
26 #define REWARD_CHANCE 10
30 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
31 * Advance experience levels and print experience
34 void check_experience(void)
36 bool level_reward = FALSE;
37 bool level_mutation = FALSE;
38 bool level_inc_stat = FALSE;
39 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
40 PLAYER_LEVEL old_lev = p_ptr->lev;
42 /* Hack -- lower limit */
43 if (p_ptr->exp < 0) p_ptr->exp = 0;
44 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
45 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
47 /* Hack -- upper limit */
48 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
49 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
50 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
52 /* Hack -- maintain "max" experience */
53 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
55 /* Hack -- maintain "max max" experience */
56 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
58 /* Redraw experience */
59 p_ptr->redraw |= (PR_EXP);
63 /* Lose levels while possible */
64 while ((p_ptr->lev > 1) &&
65 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
69 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
70 p_ptr->redraw |= (PR_LEV | PR_TITLE);
71 p_ptr->window |= (PW_PLAYER);
76 /* Gain levels while possible */
77 while ((p_ptr->lev < PY_MAX_LEVEL) &&
78 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
83 /* Save the highest level */
84 if (p_ptr->lev > p_ptr->max_plv)
86 p_ptr->max_plv = p_ptr->lev;
88 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
89 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
93 if (p_ptr->prace == RACE_BEASTMAN)
95 if (one_in_(5)) level_mutation = TRUE;
97 level_inc_stat = TRUE;
99 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
104 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
106 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
107 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
108 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
118 if(!(p_ptr->max_plv % 10))
127 cnv_stat(p_ptr->stat_max[0], tmp);
128 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
129 cnv_stat(p_ptr->stat_max[1], tmp);
130 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
131 cnv_stat(p_ptr->stat_max[2], tmp);
132 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
133 cnv_stat(p_ptr->stat_max[3], tmp);
134 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
135 cnv_stat(p_ptr->stat_max[4], tmp);
136 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
137 cnv_stat(p_ptr->stat_max[5], tmp);
138 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
141 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
146 if ((choice >= 'a') && (choice <= 'f')) break;
148 for(n = 0; n < A_MAX; n++)
149 if (n != choice - 'a')
151 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
153 do_inc_stat(choice - 'a');
156 else if(!(p_ptr->max_plv % 2))
157 do_inc_stat(randint0(6));
162 msg_print(_("あなたは変わった気がする...", "You feel different..."));
163 (void)gain_random_mutation(0);
164 level_mutation = FALSE;
168 * 報酬でレベルが上ると再帰的に check_experience() が
173 gain_level_reward(0);
174 level_reward = FALSE;
177 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
178 p_ptr->redraw |= (PR_LEV | PR_TITLE);
179 p_ptr->window |= (PW_PLAYER | PW_SPELL);
183 /* Load an autopick preference file */
184 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
190 * @brief クエストを達成状態にする /
191 * @param quest_num 達成状態にしたいクエストのID
194 void complete_quest(QUEST_IDX quest_num)
196 quest_type* const q_ptr = &quest[quest_num];
200 case QUEST_TYPE_RANDOM:
201 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
204 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
208 q_ptr->status = QUEST_STATUS_COMPLETED;
209 q_ptr->complev = p_ptr->lev;
211 q_ptr->comptime = playtime;
213 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
215 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
216 msg_print(_("クエストを達成した!", "You just completed your quest!"));
222 * @brief 現在フロアに残っている敵モンスターの数を返す /
223 * @return 現在の敵モンスターの数
225 static MONSTER_NUMBER count_all_hostile_monsters(void)
228 MONSTER_NUMBER number_mon = 0;
230 for (x = 0; x < cur_wid; ++ x)
232 for (y = 0; y < cur_hgt; ++ y)
234 MONSTER_IDX m_idx = cave[y][x].m_idx;
236 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
247 * @brief 特定の敵を倒した際にクエスト達成処理 /
248 * Check for "Quest" completion when a quest monster is killed or charmed.
249 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
252 void check_quest_completion(monster_type *m_ptr)
257 bool create_stairs = FALSE;
267 quest_num = p_ptr->inside_quest;
269 /* Search for an active quest on this dungeon level */
274 for (i = max_q_idx - 1; i > 0; i--)
276 quest_type* const q_ptr = &quest[i];
278 /* Quest is not active */
279 if (q_ptr->status != QUEST_STATUS_TAKEN)
282 /* Quest is not a dungeon quest */
283 if (q_ptr->flags & QUEST_FLAG_PRESET)
286 /* Quest is not on this level */
287 if ((q_ptr->level != dun_level) &&
288 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
291 /* Not a "kill monster" quest */
292 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
293 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
296 /* Interesting quest */
297 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
298 (q_ptr->type == QUEST_TYPE_TOWER) ||
299 (q_ptr->type == QUEST_TYPE_KILL_ALL))
302 /* Interesting quest */
303 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
304 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
305 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
306 (q_ptr->r_idx == m_ptr->r_idx))
313 /* Handle the current quest */
314 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
317 quest_type* const q_ptr = &quest[quest_num];
321 case QUEST_TYPE_KILL_NUMBER:
325 if (q_ptr->cur_num >= q_ptr->num_mon)
327 complete_quest(quest_num);
333 case QUEST_TYPE_KILL_ALL:
335 if (!is_hostile(m_ptr)) break;
337 if (count_all_hostile_monsters() == 1)
339 if (q_ptr->flags & QUEST_FLAG_SILENT)
341 q_ptr->status = QUEST_STATUS_FINISHED;
345 complete_quest(quest_num);
350 case QUEST_TYPE_KILL_LEVEL:
351 case QUEST_TYPE_RANDOM:
353 /* Only count valid monsters */
354 if (q_ptr->r_idx != m_ptr->r_idx)
359 if (q_ptr->cur_num >= q_ptr->max_num)
361 complete_quest(quest_num);
363 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
365 create_stairs = TRUE;
366 p_ptr->inside_quest = 0;
369 /* Finish the two main quests without rewarding */
370 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
372 q_ptr->status = QUEST_STATUS_FINISHED;
375 if (q_ptr->type == QUEST_TYPE_RANDOM)
378 q_ptr->status = QUEST_STATUS_FINISHED;
383 case QUEST_TYPE_KILL_ANY_LEVEL:
386 if (q_ptr->cur_num >= q_ptr->max_num)
388 complete_quest(quest_num);
393 case QUEST_TYPE_TOWER:
395 if (!is_hostile(m_ptr)) break;
397 if (count_all_hostile_monsters() == 1)
399 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
401 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
402 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
403 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
406 complete_quest(QUEST_TOWER1);
414 /* Create a magical staircase */
420 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
422 /* Pick a location */
423 scatter(&ny, &nx, y, x, 1, 0);
429 /* Explain the staircase */
430 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
432 /* Create stairs down */
433 cave_set_feat(y, x, feat_down_stair);
435 /* Remember to update everything */
436 p_ptr->update |= (PU_FLOW);
446 for (i = 0; i < (dun_level / 15)+1; i++)
451 /* Make a great object */
452 make_object(o_ptr, AM_GOOD | AM_GREAT);
453 (void)drop_near(o_ptr, -1, y, x);
459 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
460 * Check for "Quest" completion when a quest monster is killed or charmed.
461 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
464 void check_find_art_quest_completion(object_type *o_ptr)
467 /* Check if completed a quest */
468 for (i = 0; i < max_q_idx; i++)
470 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
471 (quest[i].status == QUEST_STATUS_TAKEN) &&
472 (quest[i].k_idx == o_ptr->name1))
481 * @brief モンスターを撃破した際の述語メッセージを返す /
482 * Return monster death string
483 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
484 * @return 撃破されたモンスターの述語
486 concptr extract_note_dies(MONRACE_IDX r_idx)
488 monster_race *r_ptr = &r_info[r_idx];
489 /* Some monsters get "destroyed" */
490 if (!monster_living(r_idx))
494 for (i = 0; i < 4; i++)
496 if (r_ptr->blow[i].method == RBM_EXPLODE)
498 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
501 return _("を倒した。", " is destroyed.");
504 /* Assume a default death */
505 return _("は死んだ。", " dies.");
510 * @brief モンスターに与えたダメージの修正処理 /
511 * Modify the physical damage done to the monster.
512 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
514 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
515 * @return 修正を行った結果のダメージ量
518 * (for example when it's invulnerable or shielded)
519 * ToDo: Accept a damage-type to calculate the modified damage from
520 * things like fire, frost, lightning, poison, ... attacks.
521 * "type" is not yet used and should be 0.
524 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
526 monster_race *r_ptr = &r_info[m_ptr->r_idx];
528 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
531 if ((dam == 0) && one_in_(3)) dam = 1;
534 if (MON_INVULNER(m_ptr))
538 if (!p_ptr->blind && is_seen(m_ptr))
540 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
543 else if (!one_in_(PENETRATE_INVULNERABILITY))
555 * @brief 現在のコンソール表示の縦横を返す。 /
556 * Get term size and calculate screen size
557 * @param wid_p コンソールの表示幅文字数を返す
558 * @param hgt_p コンソールの表示行数を返す
561 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
563 Term_get_size(wid_p, hgt_p);
564 *hgt_p -= ROW_MAP + 2;
565 *wid_p -= COL_MAP + 2;
566 if (use_bigtile) *wid_p /= 2;
571 * @brief コンソール上におけるマップ表示の左上位置を返す /
572 * Calculates current boundaries Called below and from "do_cmd_locate()".
575 void panel_bounds_center(void)
579 get_screen_size(&wid, &hgt);
581 panel_row_max = panel_row_min + hgt - 1;
582 panel_row_prt = panel_row_min - 1;
583 panel_col_max = panel_col_min + wid - 1;
584 panel_col_prt = panel_col_min - 13;
589 * @brief コンソールのリサイズに合わせてマップを再描画する /
590 * Map resizing whenever the main term changes size
593 void resize_map(void)
595 /* Only if the dungeon exists */
596 if (!character_dungeon) return;
598 /* Mega-Hack -- no panel yet */
602 /* Reset the panels */
603 panel_row_min = cur_hgt;
604 panel_col_min = cur_wid;
608 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
609 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
610 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
611 p_ptr->update |= (PU_MONSTERS);
612 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
619 * Place the cursor on the player
621 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
627 * @brief コンソールを再描画する /
628 * Redraw a term when it is resized
631 void redraw_window(void)
633 /* Only if the dungeon exists */
634 if (!character_dungeon) return;
636 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
637 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
645 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
646 * @param dy 変更先のフロアY座標
647 * @param dx 変更先のフロアX座標
648 * Handle a request to change the current panel
649 * Return TRUE if the panel was changed.
650 * Also used in do_cmd_locate
651 * @return 実際に再描画が必要だった場合TRUEを返す
653 bool change_panel(POSITION dy, POSITION dx)
658 get_screen_size(&wid, &hgt);
660 /* Apply the motion */
661 y = panel_row_min + dy * hgt / 2;
662 x = panel_col_min + dx * wid / 2;
665 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
669 if (x > cur_wid - wid) x = cur_wid - wid;
672 /* Handle "changes" */
673 if ((y != panel_row_min) || (x != panel_col_min))
675 /* Save the new panel info */
679 /* Recalculate the boundaries */
680 panel_bounds_center();
682 p_ptr->update |= (PU_MONSTERS);
683 p_ptr->redraw |= (PR_MAP);
695 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
696 * @param y 変更先のフロアY座標
697 * @param x 変更先のフロアX座標
699 * Handle a request to change the current panel
700 * Return TRUE if the panel was changed.
701 * Also used in do_cmd_locate
702 * @return 実際に再描画が必要だった場合TRUEを返す
704 static bool change_panel_xy(POSITION y, POSITION x)
706 POSITION dy = 0, dx = 0;
709 get_screen_size(&wid, &hgt);
711 if (y < panel_row_min) dy = -1;
712 if (y > panel_row_max) dy = 1;
713 if (x < panel_col_min) dx = -1;
714 if (x > panel_col_max) dx = 1;
716 if (!dy && !dx) return (FALSE);
718 return change_panel(dy, dx);
723 * @brief マップ描画のフォーカスを当てるべき座標を更新する
725 * Given an row (y) and col (x), this routine detects when a move
726 * off the screen has occurred and figures new borders. -RAK-
727 * "Update" forces a "full update" to take place.
728 * The map is reprinted if necessary, and "TRUE" is returned.
729 * @return 実際に再描画が必要だった場合TRUEを返す
731 void verify_panel(void)
733 POSITION y = p_ptr->y;
734 POSITION x = p_ptr->x;
742 get_screen_size(&wid, &hgt);
744 max_prow_min = cur_hgt - hgt;
745 max_pcol_min = cur_wid - wid;
747 /* Bounds checking */
748 if (max_prow_min < 0) max_prow_min = 0;
749 if (max_pcol_min < 0) max_pcol_min = 0;
751 /* Center on player */
752 if (center_player && (center_running || !running))
754 /* Center vertically */
755 prow_min = y - hgt / 2;
756 if (prow_min < 0) prow_min = 0;
757 else if (prow_min > max_prow_min) prow_min = max_prow_min;
759 /* Center horizontally */
760 pcol_min = x - wid / 2;
761 if (pcol_min < 0) pcol_min = 0;
762 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
766 prow_min = panel_row_min;
767 pcol_min = panel_col_min;
769 /* Scroll screen when 2 grids from top/bottom edge */
770 if (y > panel_row_max - 2)
772 while (y > prow_min + hgt-1 - 2)
774 prow_min += (hgt / 2);
778 if (y < panel_row_min + 2)
780 while (y < prow_min + 2)
782 prow_min -= (hgt / 2);
786 if (prow_min > max_prow_min) prow_min = max_prow_min;
787 if (prow_min < 0) prow_min = 0;
789 /* Scroll screen when 4 grids from left/right edge */
790 if (x > panel_col_max - 4)
792 while (x > pcol_min + wid-1 - 4)
794 pcol_min += (wid / 2);
798 if (x < panel_col_min + 4)
800 while (x < pcol_min + 4)
802 pcol_min -= (wid / 2);
806 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
807 if (pcol_min < 0) pcol_min = 0;
810 /* Check for "no change" */
811 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
813 /* Save the new panel info */
814 panel_row_min = prow_min;
815 panel_col_min = pcol_min;
817 /* Hack -- optional disturb on "panel change" */
818 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
820 /* Recalculate the boundaries */
821 panel_bounds_center();
823 p_ptr->update |= (PU_MONSTERS);
824 p_ptr->redraw |= (PR_MAP);
825 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
830 * Monster health description
832 concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
834 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
841 /* Determine if the monster is "living" */
842 living = monster_living(m_ptr->ap_r_idx);
844 /* Calculate a health "percentage" */
845 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
847 /* Healthy monsters */
848 if (m_ptr->hp >= m_ptr->maxhp)
850 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
855 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
860 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
865 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
870 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
873 /* Need attitude information? */
876 /* Full information is not needed */
879 else if (is_pet(m_ptr))
881 attitude = _(", ペット", ", pet");
883 else if (is_friendly(m_ptr))
885 attitude = _(", 友好的", ", friendly");
889 attitude = _("", "");
893 if (m_ptr->smart & SM_CLONED)
902 /* Display monster's level --- idea borrowed from ToME */
903 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
905 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
909 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
916 /*** Targeting Code ***/
920 * Determine is a monster makes a reasonable target
922 * The concept of "targeting" was stolen from "Morgul" (?)
924 * The player can target any location, or any "target-able" monster.
926 * Currently, a monster is "target_able" if it is visible, and if
927 * the player can hit it with a projection, and the player is not
928 * hallucinating. This allows use of "use closest target" macros.
930 * Future versions may restrict the ability to target "trappers"
931 * and "mimics", but the semantics is a little bit weird.
933 bool target_able(MONSTER_IDX m_idx)
935 monster_type *m_ptr = &m_list[m_idx];
937 /* Monster must be alive */
938 if (!m_ptr->r_idx) return (FALSE);
940 /* Hack -- no targeting hallucinations */
941 if (p_ptr->image) return (FALSE);
943 /* Monster must be visible */
944 if (!m_ptr->ml) return (FALSE);
946 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
948 /* Monster must be projectable */
949 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
951 /* Hack -- Never target trappers */
952 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
962 * Update (if necessary) and verify (if possible) the target.
964 * We return TRUE if the target is "okay" and FALSE otherwise.
966 bool target_okay(void)
968 /* Accept stationary targets */
969 if (target_who < 0) return (TRUE);
971 /* Check moving targets */
974 /* Accept reasonable targets */
975 if (target_able(target_who))
977 monster_type *m_ptr = &m_list[target_who];
979 /* Acquire monster location */
980 target_row = m_ptr->fy;
981 target_col = m_ptr->fx;
988 /* Assume no target */
994 * Sorting hook -- comp function -- by "distance to player"
996 * We use "u" and "v" to point to arrays of "x" and "y" positions,
997 * and sort the arrays by double-distance to the player.
999 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
1001 POSITION *x = (POSITION*)(u);
1002 POSITION *y = (POSITION*)(v);
1004 POSITION da, db, kx, ky;
1006 /* Absolute distance components */
1007 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
1008 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
1010 /* Approximate Double Distance to the first point */
1011 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
1013 /* Absolute distance components */
1014 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
1015 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
1017 /* Approximate Double Distance to the first point */
1018 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
1020 /* Compare the distances */
1026 * Sorting hook -- comp function -- by importance level of grids
1028 * We use "u" and "v" to point to arrays of "x" and "y" positions,
1029 * and sort the arrays by level of monster
1031 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
1033 POSITION *x = (POSITION*)(u);
1034 POSITION *y = (POSITION*)(v);
1035 cave_type *ca_ptr = &cave[y[a]][x[a]];
1036 cave_type *cb_ptr = &cave[y[b]][x[b]];
1037 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
1038 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
1039 monster_race *ap_ra_ptr, *ap_rb_ptr;
1041 /* The player grid */
1042 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
1043 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
1045 /* Extract monster race */
1046 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
1047 else ap_ra_ptr = NULL;
1048 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
1049 else ap_rb_ptr = NULL;
1051 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
1052 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
1054 /* Compare two monsters */
1055 if (ap_ra_ptr && ap_rb_ptr)
1057 /* Unique monsters first */
1058 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
1059 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
1061 /* Shadowers first (あやしい影) */
1062 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
1063 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
1065 /* Unknown monsters first */
1066 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
1067 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
1069 /* Higher level monsters first (if known) */
1070 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
1072 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
1073 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
1076 /* Sort by index if all conditions are same */
1077 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
1078 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
1081 /* An object get higher priority */
1082 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
1083 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
1085 /* Priority from the terrain */
1086 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
1087 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
1089 /* If all conditions are same, compare distance */
1090 return ang_sort_comp_distance(u, v, a, b);
1095 * Sorting hook -- swap function -- by "distance to player"
1097 * We use "u" and "v" to point to arrays of "x" and "y" positions,
1098 * and sort the arrays by distance to the player.
1100 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
1102 POSITION *x = (POSITION*)(u);
1103 POSITION *y = (POSITION*)(v);
1121 * Hack -- help "select" a location (see below)
1123 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
1126 POSITION x2, y2, x3, y3, x4, y4;
1127 POSITION_IDX b_i = -1, b_v = 9999;
1130 /* Scan the locations */
1131 for (i = 0; i < temp_n; i++)
1137 /* Directed distance */
1141 /* Verify quadrant */
1142 if (dx && (x3 * dx <= 0)) continue;
1143 if (dy && (y3 * dy <= 0)) continue;
1145 /* Absolute distance */
1149 /* Verify quadrant */
1150 if (dy && !dx && (x4 > y4)) continue;
1151 if (dx && !dy && (y4 > x4)) continue;
1153 /* Approximate Double Distance */
1154 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
1156 /* Penalize location */
1159 if ((b_i >= 0) && (v >= b_v)) continue;
1169 * Hack -- determine if a given location is "interesting"
1171 static bool target_set_accept(POSITION y, POSITION x)
1174 OBJECT_IDX this_o_idx, next_o_idx = 0;
1177 if (!(in_bounds(y, x))) return (FALSE);
1179 /* Player grid is always interesting */
1180 if (player_bold(y, x)) return (TRUE);
1182 /* Handle hallucination */
1183 if (p_ptr->image) return (FALSE);
1185 /* Examine the grid */
1186 c_ptr = &cave[y][x];
1188 /* Visible monsters */
1191 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1193 /* Visible monsters */
1194 if (m_ptr->ml) return (TRUE);
1197 /* Scan all objects in the grid */
1198 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1201 o_ptr = &o_list[this_o_idx];
1203 /* Acquire next object */
1204 next_o_idx = o_ptr->next_o_idx;
1206 /* Memorized object */
1207 if (o_ptr->marked & OM_FOUND) return (TRUE);
1210 /* Interesting memorized features */
1211 if (c_ptr->info & (CAVE_MARK))
1213 /* Notice object features */
1214 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
1216 /* Feature code (applying "mimic" field) */
1217 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
1225 * Prepare the "temp" array for "target_set"
1227 * Return the number of target_able monsters in the set.
1229 static void target_set_prepare(BIT_FLAGS mode)
1232 POSITION min_hgt, max_hgt, min_wid, max_wid;
1234 if (mode & TARGET_KILL)
1237 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
1238 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
1239 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
1240 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
1242 else /* not targetting */
1245 min_hgt = panel_row_min;
1246 max_hgt = panel_row_max;
1247 min_wid = panel_col_min;
1248 max_wid = panel_col_max;
1251 /* Reset "temp" array */
1254 /* Scan the current panel */
1255 for (y = min_hgt; y <= max_hgt; y++)
1257 for (x = min_wid; x <= max_wid; x++)
1261 /* Require "interesting" contents */
1262 if (!target_set_accept(y, x)) continue;
1264 c_ptr = &cave[y][x];
1266 /* Require target_able monsters for "TARGET_KILL" */
1267 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
1269 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
1271 /* Save the location */
1278 /* Set the sort hooks */
1279 if (mode & (TARGET_KILL))
1281 /* Target the nearest monster for shooting */
1282 ang_sort_comp = ang_sort_comp_distance;
1283 ang_sort_swap = ang_sort_swap_distance;
1287 /* Look important grids first in Look command */
1288 ang_sort_comp = ang_sort_comp_importance;
1289 ang_sort_swap = ang_sort_swap_distance;
1292 /* Sort the positions */
1293 ang_sort(temp_x, temp_y, temp_n);
1295 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
1300 temp_y[0] = temp_y[1];
1303 temp_x[0] = temp_x[1];
1308 void target_set_prepare_look(void){
1309 target_set_prepare(TARGET_LOOK);
1314 * Evaluate number of kill needed to gain level
1316 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
1318 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
1320 s32b exp_mon, exp_adv;
1321 u32b exp_mon_frac, exp_adv_frac;
1323 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1328 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
1338 /* The monster's experience point (assuming average monster speed) */
1339 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
1341 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
1344 /* Total experience value for next level */
1345 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
1347 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
1349 /* Experience value need to get */
1350 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
1353 /* You need to kill at least one monster to get any experience */
1354 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
1355 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
1357 /* Extract number of monsters needed */
1358 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
1360 /* If 999 or more monsters needed, only display "999". */
1361 num = MIN(999, exp_adv_frac);
1363 /* Display the number */
1364 sprintf(buf,"%03ld", (long int)num);
1368 bool show_gold_on_floor = FALSE;
1371 * Examine a grid, return a keypress.
1373 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
1374 * indicates that the "space" key should scan through the contents
1375 * of the grid, instead of simply returning immediately. This lets
1376 * the "look" command get complete information, without making the
1377 * "target" command annoying.
1379 * The "info" argument contains the "commands" which should be shown
1380 * inside the "[xxx]" text. This string must never be empty, or grids
1381 * containing monsters will be displayed with an extra comma.
1383 * Note that if a monster is in the grid, we update both the monster
1384 * recall info and the health bar info to track that monster.
1386 * Eventually, we may allow multiple objects per grid, or objects
1387 * and terrain features in the same grid.
1389 * This function must handle blindness/hallucination.
1391 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
1393 cave_type *c_ptr = &cave[y][x];
1394 OBJECT_IDX this_o_idx, next_o_idx = 0;
1395 concptr s1 = "", s2 = "", s3 = "", x_info = "";
1398 feature_type *f_ptr;
1399 char query = '\001';
1400 char out_val[MAX_NLEN+80];
1401 OBJECT_IDX floor_list[23];
1402 ITEM_NUMBER floor_num = 0;
1404 /* Scan all objects in the grid */
1407 floor_num = scan_floor(floor_list, y, x, 0x02);
1411 x_info = _("x物 ", "x,");
1415 /* Hack -- under the player */
1416 if (player_bold(y, x))
1429 s1 = _("ターゲット:", "Target:");
1432 /* Hack -- hallucination */
1435 concptr name = _("何か奇妙な物", "something strange");
1437 /* Display a message */
1439 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
1441 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1445 move_cursor_relative(y, x);
1448 /* Stop on everything but "return" */
1449 if ((query != '\r') && (query != '\n')) return query;
1451 /* Repeat forever */
1456 /* Actual monsters */
1457 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
1459 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1460 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
1461 GAME_TEXT m_name[MAX_NLEN];
1462 bool recall = FALSE;
1467 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1468 monster_race_track(m_ptr->ap_r_idx);
1469 health_track(c_ptr->m_idx);
1482 /* Recall on screen */
1483 screen_roff(m_ptr->ap_r_idx, 0);
1485 /* Hack -- Complete the prompt (again) */
1486 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
1493 /* Normal commands */
1494 if (query != 'r') break;
1499 /* Cleare recall text and repeat */
1505 /* Describe, and prompt for recall */
1506 evaluate_monster_exp(acount, m_ptr);
1509 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);
1511 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);
1517 move_cursor_relative(y, x);
1522 /* Normal commands */
1523 if (query != 'r') break;
1529 /* Always stop at "normal" keys */
1530 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1532 /* Sometimes stop at "space" key */
1533 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
1535 /* Change the intro */
1536 s1 = _("それは", "It is ");
1538 /* Hack -- take account of gender */
1539 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
1540 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
1542 /* Use a preposition */
1551 /* Scan all objects being carried */
1552 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
1554 GAME_TEXT o_name[MAX_NLEN];
1557 o_ptr = &o_list[this_o_idx];
1559 /* Acquire next object */
1560 next_o_idx = o_ptr->next_o_idx;
1562 /* Obtain an object description */
1563 object_desc(o_name, o_ptr, 0);
1566 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1568 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1572 move_cursor_relative(y, x);
1575 /* Always stop at "normal" keys */
1576 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1578 /* Sometimes stop at "space" key */
1579 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
1581 /* Change the intro */
1582 s2 = _("をまた", "also carrying ");
1585 /* Use a preposition */
1602 GAME_TEXT o_name[MAX_NLEN];
1605 o_ptr = &o_list[floor_list[0]];
1607 object_desc(o_name, o_ptr, 0);
1610 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1612 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1616 move_cursor_relative(y, x);
1625 /* Provide one cushion before item listing */
1628 /* Display rough information about items */
1630 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
1632 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
1636 move_cursor_relative(y, x);
1641 /* No request for listing */
1642 if (query != 'x' && query != ' ') return query;
1646 /** Display list of items **/
1648 /* Continue scrolling list if requested */
1656 show_gold_on_floor = TRUE;
1657 (void)show_floor(0, y, x, &min_width);
1658 show_gold_on_floor = FALSE;
1662 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
1664 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
1671 /* Exit unless 'Enter' */
1672 if (query != '\n' && query != '\r')
1677 /* Get the object being moved. */
1678 o_idx = c_ptr->o_idx;
1680 /* Only rotate a pile of two or more objects. */
1681 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
1683 /* Remove the first object from the list. */
1684 excise_object_idx(o_idx);
1686 /* Find end of the list. */
1688 while (o_list[i].next_o_idx)
1689 i = o_list[i].next_o_idx;
1691 /* Add after the last object. */
1692 o_list[i].next_o_idx = o_idx;
1694 /* Loop and re-display the list */
1701 /* Scan all objects in the grid */
1702 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1705 o_ptr = &o_list[this_o_idx];
1707 /* Acquire next object */
1708 next_o_idx = o_ptr->next_o_idx;
1710 if (o_ptr->marked & OM_FOUND)
1712 GAME_TEXT o_name[MAX_NLEN];
1717 /* Obtain an object description */
1718 object_desc(o_name, o_ptr, 0);
1721 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
1723 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
1727 move_cursor_relative(y, x);
1730 /* Always stop at "normal" keys */
1731 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
1733 /* Sometimes stop at "space" key */
1734 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
1736 /* Change the intro */
1737 s1 = _("それは", "It is ");
1740 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
1754 /* Feature code (applying "mimic" field) */
1755 feat = get_feat_mimic(c_ptr);
1757 /* Require knowledge about grid, or ability to see grid */
1758 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
1760 /* Forget feature */
1764 f_ptr = &f_info[feat];
1766 /* Terrain feature if needed */
1767 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
1771 /* Hack -- special handling for quest entrances */
1772 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
1774 /* Set the quest number temporary */
1775 IDX old_quest = p_ptr->inside_quest;
1778 /* Clear the text */
1779 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
1780 quest_text_line = 0;
1782 p_ptr->inside_quest = c_ptr->special;
1784 /* Get the quest text */
1785 init_flags = INIT_NAME_ONLY;
1787 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
1789 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
1790 quest[c_ptr->special].name, quest[c_ptr->special].level);
1792 /* Reset the old quest number */
1793 p_ptr->inside_quest = old_quest;
1796 /* Hack -- special handling for building doors */
1797 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
1799 name = building[f_ptr->subtype].name;
1801 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
1803 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
1805 else if (have_flag(f_ptr->flags, FF_TOWN))
1807 name = town[c_ptr->special].name;
1809 else if (p_ptr->wild_mode && (feat == feat_floor))
1811 name = _("道", "road");
1815 name = f_name + f_ptr->name;
1821 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
1822 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
1823 have_flag(f_ptr->flags, FF_TOWN)))
1825 s2 = _("の中", "in ");
1828 /* Hack -- special introduction for store & building doors -KMW- */
1829 if (have_flag(f_ptr->flags, FF_STORE) ||
1830 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
1831 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
1832 have_flag(f_ptr->flags, FF_ENTRANCE))
1837 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
1838 have_flag(f_ptr->flags, FF_TOWN) ||
1839 have_flag(f_ptr->flags, FF_SHALLOW) ||
1840 have_flag(f_ptr->flags, FF_DEEP))
1846 /* Pick proper indefinite article */
1847 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
1851 /* Display a message */
1855 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
1856 else sprintf(f_idx_str, "%d", c_ptr->feat);
1858 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d) %d", s1, name, s2, s3, info, (unsigned int)c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, (int)y, (int)x, travel.cost[y][x]);
1860 sprintf(out_val, "%s%s%s%s [%s] %x %s %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, (int)y, (int)x);
1865 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
1867 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1871 move_cursor_relative(y, x);
1874 /* Always stop at "normal" keys */
1875 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
1878 /* Stop on everything but "return" */
1879 if ((query != '\r') && (query != '\n')) return query;
1881 /* Repeat forever */
1887 * Handle "target" and "look".
1889 * Note that this code can be called from "get_aim_dir()".
1891 * All locations must be on the current panel. Consider the use of
1892 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
1893 * some form of "scrolling" the map around the cursor.
1894 * That is, consider the possibility of "auto-scrolling" the screen
1895 * while the cursor moves around. This may require changes in the
1896 * "update_monster()" code to allow "visibility" even if off panel, and
1897 * may require dynamic recalculation of the "temp" grid set.
1899 * Hack -- targeting/observing an "outer border grid" may induce
1900 * problems, so this is not currently allowed.
1902 * The player can use the direction keys to move among "interesting"
1903 * grids in a heuristic manner, or the "space", "+", and "-" keys to
1904 * move through the "interesting" grids in a sequential manner, or
1905 * can enter "location" mode, and use the direction keys to move one
1906 * grid at a time in any direction. The "t" (set target) command will
1907 * only target a monster (as opposed to a location) if the monster is
1908 * target_able and the "interesting" mode is being used.
1910 * The current grid is described using the "look" method above, and
1911 * a new command may be entered at any time, but note that if the
1912 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
1913 * where "space" has no obvious meaning) then "space" will scan
1914 * through the description of the current grid until done, instead
1915 * of immediately jumping to the next "interesting" grid. This
1916 * allows the "target" command to retain its old semantics.
1918 * The "*", "+", and "-" keys may always be used to jump immediately
1919 * to the next (or previous) interesting grid, in the proper mode.
1921 * The "return" key may always be used to scan through a complete
1922 * grid description (forever).
1924 * This command will cancel any old target, even if used from
1925 * inside the "look" command.
1927 bool target_set(BIT_FLAGS mode)
1930 POSITION y = p_ptr->y;
1931 POSITION x = p_ptr->x;
1941 get_screen_size(&wid, &hgt);
1946 if (rogue_like_commands)
1955 /* Prepare the "temp" array */
1956 target_set_prepare(mode);
1958 /* Start near the player */
1964 /* Interesting grids */
1971 change_panel_xy(y, x);
1973 if (!(mode & TARGET_LOOK)) prt_path(y, x);
1976 c_ptr = &cave[y][x];
1979 if (target_able(c_ptr->m_idx))
1981 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
1984 /* Dis-allow target */
1987 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
1993 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
1994 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
1995 strcat(info, cheatinfo);
1998 /* Describe and Prompt */
2000 query = target_set_aux(y, x, mode, info);
2004 /* Assume no "direction" */
2009 if (query == '\r') query = 't';
2027 if (target_able(c_ptr->m_idx))
2029 health_track(c_ptr->m_idx);
2030 target_who = c_ptr->m_idx;
2049 if (!expand_list) done = TRUE;
2059 if (!expand_list) done = TRUE;
2066 /* Recenter the map around the player */
2068 p_ptr->update |= (PU_MONSTERS);
2069 p_ptr->redraw |= (PR_MAP);
2070 p_ptr->window |= (PW_OVERHEAD);
2073 /* Recalculate interesting grids */
2074 target_set_prepare(mode);
2093 if(query == same_key)
2098 if (!expand_list) done = TRUE;
2103 /* Extract the action (if any) */
2104 d = get_keymap_dir(query);
2111 /* Hack -- move around */
2114 /* Modified to scroll to monster */
2115 POSITION y2 = panel_row_min;
2116 POSITION x2 = panel_col_min;
2118 /* Find a new monster */
2119 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
2121 /* Request to target past last interesting grid */
2122 while (flag && (i < 0))
2124 /* Note the change */
2125 if (change_panel(ddy[d], ddx[d]))
2130 /* Recalculate interesting grids */
2131 target_set_prepare(mode);
2133 /* Look at interesting grids */
2136 /* Find a new monster */
2137 i = target_pick(v, u, ddy[d], ddx[d]);
2143 /* Nothing interesting */
2146 POSITION dx = ddx[d];
2147 POSITION dy = ddy[d];
2149 /* Restore previous position */
2152 panel_bounds_center();
2154 p_ptr->update |= (PU_MONSTERS);
2155 p_ptr->redraw |= (PR_MAP);
2156 p_ptr->window |= (PW_OVERHEAD);
2159 /* Recalculate interesting grids */
2160 target_set_prepare(mode);
2162 /* Look at boring grids */
2169 /* Do not move horizontally if unnecessary */
2170 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2171 ((x > panel_col_min + wid / 2) && (dx < 0)))
2176 /* Do not move vertically if unnecessary */
2177 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2178 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2183 /* Apply the motion */
2184 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
2185 (x >= panel_col_min+wid) || (x < panel_col_min))
2187 if (change_panel(dy, dx)) target_set_prepare(mode);
2190 /* Slide into legality */
2191 if (x >= cur_wid-1) x = cur_wid - 2;
2192 else if (x <= 0) x = 1;
2194 /* Slide into legality */
2195 if (y >= cur_hgt-1) y = cur_hgt- 2;
2196 else if (y <= 0) y = 1;
2205 /* Arbitrary grids */
2208 bool move_fast = FALSE;
2210 if (!(mode & TARGET_LOOK)) prt_path(y, x);
2213 c_ptr = &cave[y][x];
2215 /* Default prompt */
2216 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
2221 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
2222 los(p_ptr->y, p_ptr->x, y, x),
2223 projectable(p_ptr->y, p_ptr->x, y, x));
2224 strcat(info, cheatinfo);
2227 /* Describe and Prompt (enable "TARGET_LOOK") */
2228 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
2230 /* Assume no direction */
2235 if (query == '\r') query = 't';
2238 /* Analyze the keypress */
2262 /* Recenter the map around the player */
2264 p_ptr->update |= (PU_MONSTERS);
2265 p_ptr->redraw |= (PR_MAP);
2266 p_ptr->window |= (PW_OVERHEAD);
2269 /* Recalculate interesting grids */
2270 target_set_prepare(mode);
2292 /* Pick a nearby monster */
2293 for (i = 0; i < temp_n; i++)
2295 t = distance(y, x, temp_y[i], temp_x[i]);
2305 /* Nothing interesting */
2306 if (bd == 999) flag = FALSE;
2313 /* Extract the action (if any) */
2314 d = get_keymap_dir(query);
2316 /* XTRA HACK MOVEFAST */
2317 if (isupper(query)) move_fast = TRUE;
2324 /* Handle "direction" */
2327 POSITION dx = ddx[d];
2328 POSITION dy = ddy[d];
2330 /* XTRA HACK MOVEFAST */
2333 int mag = MIN(wid / 2, hgt / 2);
2343 /* Do not move horizontally if unnecessary */
2344 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2345 ((x > panel_col_min + wid / 2) && (dx < 0)))
2350 /* Do not move vertically if unnecessary */
2351 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2352 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2357 /* Apply the motion */
2358 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2359 (x >= panel_col_min + wid) || (x < panel_col_min))
2361 if (change_panel(dy, dx)) target_set_prepare(mode);
2364 /* Slide into legality */
2365 if (x >= cur_wid-1) x = cur_wid - 2;
2366 else if (x <= 0) x = 1;
2368 /* Slide into legality */
2369 if (y >= cur_hgt-1) y = cur_hgt- 2;
2370 else if (y <= 0) y = 1;
2378 /* Clear the top line */
2381 /* Recenter the map around the player */
2383 p_ptr->update |= (PU_MONSTERS);
2384 p_ptr->redraw |= (PR_MAP);
2385 p_ptr->window |= (PW_OVERHEAD);
2388 /* Failure to set target */
2389 if (!target_who) return (FALSE);
2397 * Get an "aiming direction" from the user.
2399 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
2400 * "0" for "current target", and "-1" for "entry aborted".
2402 * Note that "Force Target", if set, will pre-empt user interaction,
2403 * if there is a usable target already set.
2405 * Note that confusion over-rides any (explicit?) user choice.
2407 bool get_aim_dir(DIRECTION *dp)
2416 /* Global direction */
2419 /* Hack -- auto-target if requested */
2420 if (use_old_target && target_okay()) dir = 5;
2422 if (repeat_pull(&code))
2427 if (!(code == 5 && !target_okay()))
2429 /* return (TRUE); */
2430 dir = (DIRECTION)code;
2433 *dp = (DIRECTION)code;
2435 /* Ask until satisfied */
2438 /* Choose a prompt */
2441 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2445 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2448 /* Get a command (or Cancel) */
2449 if (!get_com(p, &command, TRUE)) break;
2453 if (command == '\r') command = 't';
2456 /* Convert various keys to "standard" keys */
2459 /* Use current target */
2470 /* Set new target */
2475 if (target_set(TARGET_KILL)) dir = 5;
2481 /* Extract the action (if any) */
2482 dir = get_keymap_dir(command);
2488 /* Verify requested targets */
2489 if ((dir == 5) && !target_okay()) dir = 0;
2498 project_length = 0; /* reset to default */
2502 /* Save the direction */
2505 /* Check for confusion */
2506 if (p_ptr->confused)
2508 /* Random direction */
2509 dir = ddd[randint0(8)];
2512 /* Notice confusion */
2513 if (command_dir != dir)
2516 msg_print(_("あなたは混乱している。", "You are confused."));
2519 /* Save direction */
2522 /* repeat_push(dir); */
2523 repeat_push((COMMAND_CODE)command_dir);
2525 /* A "valid" direction was entered */
2530 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
2538 /* Global direction */
2541 if (repeat_pull(&code))
2543 dir = (DIRECTION)code;
2544 /* return (TRUE); */
2546 *dp = (DIRECTION)code;
2550 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
2554 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
2557 /* Get a direction */
2562 /* Get a command (or Cancel) */
2563 if (!get_com(prompt, &ch, TRUE)) break;
2566 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
2572 /* Look up the direction */
2573 dir = get_keymap_dir(ch);
2579 /* Prevent weirdness */
2580 if ((dir == 5) && (!allow_under)) dir = 0;
2583 if (!dir) return (FALSE);
2585 /* Save desired direction */
2588 /* Apply "confusion" */
2589 if (p_ptr->confused)
2591 /* Standard confusion */
2592 if (randint0(100) < 75)
2594 /* Random direction */
2595 dir = ddd[randint0(8)];
2598 else if (p_ptr->riding && with_steed)
2600 monster_type *m_ptr = &m_list[p_ptr->riding];
2601 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2603 if (MON_CONFUSED(m_ptr))
2605 /* Standard confusion */
2606 if (randint0(100) < 75)
2608 /* Random direction */
2609 dir = ddd[randint0(8)];
2612 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2614 /* Random direction */
2615 dir = ddd[randint0(8)];
2617 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2619 /* Random direction */
2620 dir = ddd[randint0(8)];
2624 /* Notice confusion */
2625 if (command_dir != dir)
2627 if (p_ptr->confused)
2630 msg_print(_("あなたは混乱している。", "You are confused."));
2634 GAME_TEXT m_name[MAX_NLEN];
2635 monster_type *m_ptr = &m_list[p_ptr->riding];
2637 monster_desc(m_name, m_ptr, 0);
2638 if (MON_CONFUSED(m_ptr))
2640 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2644 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2649 /* Save direction */
2652 /* repeat_push(dir); */
2653 repeat_push((COMMAND_CODE)command_dir);
2660 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
2661 * and place it into "command_dir", unless we already have one.
2663 * This function should be used for all "repeatable" commands, such as
2664 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
2665 * as all commands which must reference a grid adjacent to the player,
2666 * and which may not reference the grid under the player. Note that,
2667 * for example, it is no longer possible to "disarm" or "open" chests
2668 * in the same grid as the player.
2670 * Direction "5" is illegal and will (cleanly) abort the command.
2672 * This function tracks and uses the "global direction", and uses
2673 * that as the "desired direction", to which "confusion" is applied.
2675 bool get_rep_dir(DIRECTION *dp, bool under)
2683 /* Global direction */
2686 if (repeat_pull(&code))
2688 dir = (DIRECTION)code;
2689 /* return (TRUE); */
2691 *dp = (DIRECTION)code;
2695 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
2699 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
2702 /* Get a direction */
2707 /* Get a command (or Cancel) */
2708 if (!get_com(prompt, &ch, TRUE)) break;
2711 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
2717 /* Look up the direction */
2718 dir = get_keymap_dir(ch);
2724 /* Prevent weirdness */
2725 if ((dir == 5) && (!under)) dir = 0;
2728 if (!dir) return (FALSE);
2730 /* Save desired direction */
2733 /* Apply "confusion" */
2734 if (p_ptr->confused)
2736 /* Standard confusion */
2737 if (randint0(100) < 75)
2739 /* Random direction */
2740 dir = ddd[randint0(8)];
2743 else if (p_ptr->riding)
2745 monster_type *m_ptr = &m_list[p_ptr->riding];
2746 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2748 if (MON_CONFUSED(m_ptr))
2750 /* Standard confusion */
2751 if (randint0(100) < 75)
2753 /* Random direction */
2754 dir = ddd[randint0(8)];
2757 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
2759 /* Random direction */
2760 dir = ddd[randint0(8)];
2762 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
2764 /* Random direction */
2765 dir = ddd[randint0(8)];
2769 /* Notice confusion */
2770 if (command_dir != dir)
2772 if (p_ptr->confused)
2775 msg_print(_("あなたは混乱している。", "You are confused."));
2779 GAME_TEXT m_name[MAX_NLEN];
2780 monster_type *m_ptr = &m_list[p_ptr->riding];
2782 monster_desc(m_name, m_ptr, 0);
2783 if (MON_CONFUSED(m_ptr))
2785 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
2789 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
2794 /* Save direction */
2797 /* repeat_push(dir); */
2798 repeat_push((COMMAND_CODE)command_dir);
2806 * XAngband: determine if a given location is "interesting"
2807 * based on target_set_accept function.
2809 static bool tgt_pt_accept(POSITION y, POSITION x)
2814 if (!(in_bounds(y, x))) return (FALSE);
2816 /* Player grid is always interesting */
2817 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
2819 /* Handle hallucination */
2820 if (p_ptr->image) return (FALSE);
2822 /* Examine the grid */
2823 c_ptr = &cave[y][x];
2825 /* Interesting memorized features */
2826 if (c_ptr->info & (CAVE_MARK))
2829 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
2830 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
2832 /* Notice quest features */
2833 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
2834 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
2842 * XAngband: Prepare the "temp" array for "tget_pt"
2843 * based on target_set_prepare funciton.
2845 static void tgt_pt_prepare(void)
2849 /* Reset "temp" array */
2852 if (!expand_list) return;
2854 /* Scan the current panel */
2855 for (y = 1; y < cur_hgt; y++)
2857 for (x = 1; x < cur_wid; x++)
2859 /* Require "interesting" contents */
2860 if (!tgt_pt_accept(y, x)) continue;
2862 /* Save the location */
2869 /* Target the nearest monster for shooting */
2870 ang_sort_comp = ang_sort_comp_distance;
2871 ang_sort_swap = ang_sort_swap_distance;
2873 /* Sort the positions */
2874 ang_sort(temp_x, temp_y, temp_n);
2878 * old -- from PsiAngband.
2880 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
2885 bool success = FALSE;
2889 get_screen_size(&wid, &hgt);
2899 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
2900 msg_flag = FALSE; /* prevents "-more-" message. */
2902 while ((ch != ESCAPE) && !success)
2904 bool move_fast = FALSE;
2906 move_cursor_relative(y, x);
2918 if (player_bold(y, x)) ch = 0;
2921 else success = TRUE;
2925 /* XAngband: Move cursor to stairs */
2928 if (expand_list && temp_n)
2931 int cx = (panel_col_min + panel_col_max) / 2;
2932 int cy = (panel_row_min + panel_row_max) / 2;
2936 /* Skip stairs which have defferent distance */
2937 for (; n < temp_n; ++ n)
2939 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
2941 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
2942 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
2949 if (n == temp_n) /* Loop out taget list */
2954 verify_panel(); /* Move cursor to player */
2956 p_ptr->update |= (PU_MONSTERS);
2958 p_ptr->redraw |= (PR_MAP);
2960 p_ptr->window |= (PW_OVERHEAD);
2963 else /* move cursor to next stair and change panel */
2968 dy = 2 * (y - cy) / hgt;
2969 dx = 2 * (x - cx) / wid;
2970 if (dy || dx) change_panel(dy, dx);
2976 /* Look up the direction */
2977 d = get_keymap_dir(ch);
2979 /* XTRA HACK MOVEFAST */
2980 if (isupper(ch)) move_fast = TRUE;
2982 /* Handle "direction" */
2988 /* XTRA HACK MOVEFAST */
2991 int mag = MIN(wid / 2, hgt / 2);
3001 /* Do not move horizontally if unnecessary */
3002 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3003 ((x > panel_col_min + wid / 2) && (dx < 0)))
3008 /* Do not move vertically if unnecessary */
3009 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3010 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3015 /* Apply the motion */
3016 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3017 (x >= panel_col_min + wid) || (x < panel_col_min))
3019 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
3020 change_panel(dy, dx);
3023 /* Slide into legality */
3024 if (x >= cur_wid-1) x = cur_wid - 2;
3025 else if (x <= 0) x = 1;
3027 /* Slide into legality */
3028 if (y >= cur_hgt-1) y = cur_hgt- 2;
3029 else if (y <= 0) y = 1;
3036 /* Clear the top line */
3039 /* Recenter the map around the player */
3042 p_ptr->update |= (PU_MONSTERS);
3044 p_ptr->redraw |= (PR_MAP);
3046 p_ptr->window |= (PW_OVERHEAD);
3055 bool get_hack_dir(DIRECTION *dp)
3063 /* Global direction */
3066 /* (No auto-targeting) */
3068 /* Ask until satisfied */
3071 /* Choose a prompt */
3074 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3078 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3081 /* Get a command (or Cancel) */
3082 if (!get_com(p, &command, TRUE)) break;
3086 if (command == '\r') command = 't';
3089 /* Convert various keys to "standard" keys */
3092 /* Use current target */
3103 /* Set new target */
3108 if (target_set(TARGET_KILL)) dir = 5;
3114 /* Look up the direction */
3115 dir = get_keymap_dir(command);
3121 /* Verify requested targets */
3122 if ((dir == 5) && !target_okay()) dir = 0;
3129 if (!dir) return (FALSE);
3131 /* Save the direction */
3134 /* Check for confusion */
3135 if (p_ptr->confused)
3137 /* Random direction */
3138 dir = ddd[randint0(8)];
3141 /* Notice confusion */
3142 if (command_dir != dir)
3145 msg_print(_("あなたは混乱している。", "You are confused."));
3148 /* Save direction */
3151 /* A "valid" direction was entered */
3157 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
3158 * @param sval 射撃武器のアイテム副分類ID
3159 * @return 消費する基本エネルギー
3161 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
3163 ENERGY energy = 10000;
3165 /* Analyze the launcher */
3168 /* Sling and ammo */
3175 /* Short Bow and Arrow */
3182 /* Long Bow and Arrow */
3189 /* Bow of irresponsiblity and Arrow */
3196 /* Light Crossbow and Bolt */
3203 /* Heavy Crossbow and Bolt */
3218 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
3222 /* Analyze the launcher */
3225 /* Sling and ammo */
3232 /* Short Bow and Arrow */
3239 /* Long Bow and Arrow */
3246 /* Bow of irresponsiblity and Arrow */
3253 /* Light Crossbow and Bolt */
3260 /* Heavy Crossbow and Bolt */
3273 * Display a rumor and apply its effects
3276 IDX rumor_num(char *zz, IDX max_idx)
3278 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
3279 return (IDX)atoi(zz);
3282 concptr rumor_bind_name(char *base, concptr fullname)
3286 s = strstr(base, "{Name}");
3290 v = format("%s%s%s", base, fullname, (s + 6));
3300 void display_rumor(bool ex)
3308 if (randint0(3) == 0) section = 1;
3311 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
3312 get_rnd_line("rumors.txt", section, Rumor));
3313 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
3317 if (strncmp(Rumor, "R:", 2) == 0)
3320 concptr rumor_msg = NULL;
3321 concptr rumor_eff_format = NULL;
3322 char fullname[1024] = "";
3324 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
3326 if (strcmp(zz[0], "ARTIFACT") == 0)
3330 object_type *q_ptr = &forge;
3331 artifact_type *a_ptr;
3335 a_idx = rumor_num(zz[1], max_a_idx);
3337 a_ptr = &a_info[a_idx];
3338 if (a_ptr->name) break;
3341 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
3342 object_prep(q_ptr, k_idx);
3343 q_ptr->name1 = a_idx;
3344 q_ptr->ident = IDENT_STORE;
3345 object_desc(fullname, q_ptr, OD_NAME_ONLY);
3347 else if (strcmp(zz[0], "MONSTER") == 0)
3350 monster_race *r_ptr;
3354 r_idx = rumor_num(zz[1], max_r_idx);
3355 r_ptr = &r_info[r_idx];
3356 if (r_ptr->name) break;
3359 strcpy(fullname, r_name + r_ptr->name);
3361 /* Remember this monster */
3362 if (!r_ptr->r_sights)
3367 else if (strcmp(zz[0], "DUNGEON") == 0)
3370 dungeon_info_type *d_ptr;
3374 d_idx = rumor_num(zz[1], max_d_idx);
3375 d_ptr = &d_info[d_idx];
3376 if (d_ptr->name) break;
3379 strcpy(fullname, d_name + d_ptr->name);
3381 if (!max_dlv[d_idx])
3383 max_dlv[d_idx] = d_ptr->mindepth;
3384 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
3387 else if (strcmp(zz[0], "TOWN") == 0)
3394 t_idx = rumor_num(zz[1], NO_TOWN);
3395 if (town[t_idx].name) break;
3398 strcpy(fullname, town[t_idx].name);
3400 visit = (1L << (t_idx - 1));
3401 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
3403 p_ptr->visit |= visit;
3404 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
3408 rumor_msg = rumor_bind_name(zz[2], fullname);
3409 msg_print(rumor_msg);
3410 if (rumor_eff_format)
3413 msg_format(rumor_eff_format, fullname);
3418 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
3422 msg_format("%s", Rumor);