1 #include "mspell/mspell-util.h"
2 #include "core/disturbance.h"
3 #include "floor/geometry.h"
5 #include "monster/monster-info.h"
6 #include "system/floor-type-definition.h"
7 #include "system/monster-type-definition.h"
8 #include "system/player-type-definition.h"
9 #include "timed-effect/player-blindness.h"
10 #include "timed-effect/timed-effects.h"
11 #include "view/display-messages.h"
13 mspell_cast_msg::mspell_cast_msg(concptr to_player_true, concptr to_mons_true, concptr to_player_false, concptr to_mons_false)
14 : to_player_true(to_player_true)
15 , to_mons_true(to_mons_true)
16 , to_player_false(to_player_false)
17 , to_mons_false(to_mons_false)
21 mspell_cast_msg_blind::mspell_cast_msg_blind(concptr blind, concptr to_player, concptr to_mons)
23 , to_player(to_player)
28 mspell_cast_msg_simple::mspell_cast_msg_simple(concptr to_player, concptr to_mons)
29 : to_player(to_player)
35 * @brief プレイヤーがモンスターを見ることができるかの判定 /
36 * @param floor_ptr 現在フロアへの参照ポインタ
37 * @param m_idx モンスターID
38 * @return プレイヤーがモンスターを見ることができるならTRUE、そうでなければFALSEを返す。
40 bool see_monster(PlayerType *player_ptr, MONSTER_IDX m_idx)
42 monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
43 return is_seen(player_ptr, m_ptr);
47 * @brief モンスター2体がプレイヤーの近くに居るかの判定 /
48 * @param floor_ptr 現在フロアへの参照ポインタ
49 * @param m_idx モンスターID一体目
50 * @param t_idx モンスターID二体目
51 * @return モンスター2体のどちらかがプレイヤーの近くに居ればTRUE、どちらも遠ければFALSEを返す。
53 bool monster_near_player(floor_type *floor_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx)
55 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
56 monster_type *t_ptr = &floor_ptr->m_list[t_idx];
57 return (m_ptr->cdis <= MAX_SIGHT) || (t_ptr->cdis <= MAX_SIGHT);
61 * @brief モンスターが呪文行使する際のメッセージを処理する汎用関数 /
62 * @param player_ptr プレイヤーへの参照ポインタ
63 * @param m_idx 呪文を唱えるモンスターID
64 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
65 * @param msgs メッセージの構造体
66 * @param msg_flag_aux メッセージを分岐するためのフラグ
67 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
68 * @return メッセージを表示した場合trueを返す。
70 bool monspell_message_base(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, const mspell_cast_msg &msgs, bool msg_flag_aux, int target_type)
73 floor_type *floor_ptr = player_ptr->current_floor_ptr;
74 bool known = monster_near_player(floor_ptr, m_idx, t_idx);
75 bool see_either = see_monster(player_ptr, m_idx) || see_monster(player_ptr, t_idx);
76 bool mon_to_mon = (target_type == MONSTER_TO_MONSTER);
77 bool mon_to_player = (target_type == MONSTER_TO_PLAYER);
78 GAME_TEXT m_name[MAX_NLEN], t_name[MAX_NLEN];
79 monster_name(player_ptr, m_idx, m_name);
80 monster_name(player_ptr, t_idx, t_name);
82 if (mon_to_player || (mon_to_mon && known && see_either)) {
83 disturb(player_ptr, true, true);
88 msg_format(msgs.to_player_true, m_name);
90 } else if (mon_to_mon && known && see_either) {
91 msg_format(msgs.to_mons_true, m_name);
96 msg_format(msgs.to_player_false, m_name);
98 } else if (mon_to_mon && known && see_either) {
99 msg_format(msgs.to_mons_false, m_name, t_name);
104 if (mon_to_mon && known && !see_either) {
105 floor_ptr->monster_noise = true;
112 * @brief モンスターが呪文行使する際のメッセージを処理する汎用関数。盲目時と通常時のメッセージを切り替える。 /
113 * @param player_ptr プレイヤーへの参照ポインタ
114 * @param m_idx 呪文を唱えるモンスターID
115 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
116 * @param msgs メッセージの構造体
117 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
118 * @return メッセージを表示した場合trueを返す。
120 bool monspell_message(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, const mspell_cast_msg_blind &msgs, int target_type)
122 mspell_cast_msg mcm(msgs.blind, msgs.blind, msgs.to_player, msgs.to_mons);
123 const auto is_blind = player_ptr->effects()->blindness()->is_blind();
124 return monspell_message_base(player_ptr, m_idx, t_idx, mcm, is_blind, target_type);
128 * @brief モンスターが呪文行使する際のメッセージを処理する汎用関数。対モンスターと対プレイヤーのメッセージを切り替える。 /
129 * @param player_ptr プレイヤーへの参照ポインタ
130 * @param m_idx 呪文を唱えるモンスターID
131 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
132 * @param msgs メッセージの構造体
133 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
135 void simple_monspell_message(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, const mspell_cast_msg_simple &msgs, int target_type)
137 mspell_cast_msg mcm(msgs.to_player, msgs.to_mons, msgs.to_player, msgs.to_mons);
138 const auto is_blind = player_ptr->effects()->blindness()->is_blind();
139 monspell_message_base(player_ptr, m_idx, t_idx, mcm, is_blind, target_type);