2 * @brief 特殊な行動を取るモンスターの具体的な行動定義 (r_infoのSPECIALフラグ)
7 #include "mspell/mspell-special.h"
8 #include "core/disturbance.h"
9 #include "core/player-update-types.h"
10 #include "effect/effect-characteristics.h"
11 #include "effect/effect-processor.h"
12 #include "floor/cave.h"
13 #include "main/sound-definitions-table.h"
14 #include "main/sound-of-music.h"
15 #include "melee/melee-postprocess.h"
16 #include "monster-floor/monster-death.h"
17 #include "monster-floor/monster-remover.h"
18 #include "monster-floor/monster-summon.h"
19 #include "monster-race/monster-race.h"
20 #include "monster-race/race-flags7.h"
21 #include "monster-race/race-indice-types.h"
22 #include "monster/monster-describer.h"
23 #include "monster/monster-description-types.h"
24 #include "monster/monster-info.h"
25 #include "monster/monster-util.h"
26 #include "mspell/mspell-checker.h"
27 #include "mspell/mspell-result.h"
28 #include "mspell/mspell-util.h"
29 #include "player/player-damage.h"
30 #include "spell-kind/spells-teleport.h"
31 #include "spell-realm/spells-crusade.h"
32 #include "effect/attribute-types.h"
33 #include "system/floor-type-definition.h"
34 #include "system/grid-type-definition.h"
35 #include "system/monster-race-definition.h"
36 #include "system/monster-type-definition.h"
37 #include "system/player-type-definition.h"
38 #include "view/display-messages.h"
41 * @brief バーノール・ルパートのRF6_SPECIALの処理。分裂・合体。 /
42 * @param player_ptr プレイヤーへの参照ポインタ
43 * @param m_idx 呪文を唱えるモンスターID
45 static MonsterSpellResult spell_RF6_SPECIAL_BANORLUPART(PlayerType *player_ptr, MONSTER_IDX m_idx)
47 auto *floor_ptr = player_ptr->current_floor_ptr;
48 auto *m_ptr = &floor_ptr->m_list[m_idx];
49 int dummy_hp, dummy_maxhp;
50 POSITION dummy_y = m_ptr->fy;
51 POSITION dummy_x = m_ptr->fx;
54 if (see_monster(player_ptr, m_idx) && monster_near_player(floor_ptr, m_idx, 0))
55 disturb(player_ptr, true, true);
57 switch (m_ptr->r_idx) {
59 dummy_hp = (m_ptr->hp + 1) / 2;
60 dummy_maxhp = m_ptr->maxhp / 2;
62 if (floor_ptr->inside_arena || player_ptr->phase_out || !summon_possible(player_ptr, m_ptr->fy, m_ptr->fx))
63 return MonsterSpellResult::make_invalid();
65 delete_monster_idx(player_ptr, floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx);
66 summon_named_creature(player_ptr, 0, dummy_y, dummy_x, MON_BANOR, mode);
67 floor_ptr->m_list[hack_m_idx_ii].hp = dummy_hp;
68 floor_ptr->m_list[hack_m_idx_ii].maxhp = dummy_maxhp;
69 summon_named_creature(player_ptr, 0, dummy_y, dummy_x, MON_LUPART, mode);
70 floor_ptr->m_list[hack_m_idx_ii].hp = dummy_hp;
71 floor_ptr->m_list[hack_m_idx_ii].maxhp = dummy_maxhp;
73 msg_print(_("『バーノール・ルパート』が分裂した!", "Banor=Rupart splits into two persons!"));
81 if (!r_info[MON_BANOR].cur_num || !r_info[MON_LUPART].cur_num)
82 return MonsterSpellResult::make_invalid();
84 for (MONSTER_IDX k = 1; k < floor_ptr->m_max; k++) {
85 if (floor_ptr->m_list[k].r_idx == MON_BANOR || floor_ptr->m_list[k].r_idx == MON_LUPART) {
86 dummy_hp += floor_ptr->m_list[k].hp;
87 dummy_maxhp += floor_ptr->m_list[k].maxhp;
88 if (floor_ptr->m_list[k].r_idx != m_ptr->r_idx) {
89 dummy_y = floor_ptr->m_list[k].fy;
90 dummy_x = floor_ptr->m_list[k].fx;
92 delete_monster_idx(player_ptr, k);
95 summon_named_creature(player_ptr, 0, dummy_y, dummy_x, MON_BANORLUPART, mode);
96 floor_ptr->m_list[hack_m_idx_ii].hp = dummy_hp;
97 floor_ptr->m_list[hack_m_idx_ii].maxhp = dummy_maxhp;
99 msg_print(_("『バーノール』と『ルパート』が合体した!", "Banor and Rupart combine into one!"));
103 return MonsterSpellResult::make_valid();
107 * @brief ロレントのRF6_SPECIALの処理。手榴弾の召喚。 /
108 * @param player_ptr プレイヤーへの参照ポインタ
111 * @param m_idx 呪文を唱えるモンスターID
112 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
113 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
115 static MonsterSpellResult spell_RF6_SPECIAL_ROLENTO(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
118 int num = 1 + randint1(3);
120 auto *floor_ptr = player_ptr->current_floor_ptr;
121 bool see_either = see_monster(player_ptr, m_idx) || see_monster(player_ptr, t_idx);
122 bool mon_to_mon = target_type == MONSTER_TO_MONSTER;
123 bool mon_to_player = target_type == MONSTER_TO_PLAYER;
124 bool known = monster_near_player(floor_ptr, m_idx, t_idx);
126 mspell_cast_msg_blind msg(_("%^sが何か大量に投げた。", "%^s spreads something."),
127 _("%^sは手榴弾をばらまいた。", "%^s throws some hand grenades."), _("%^sは手榴弾をばらまいた。", "%^s throws some hand grenades."));
129 monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
130 if (mon_to_player || (mon_to_mon && known && see_either))
131 disturb(player_ptr, true, true);
133 for (k = 0; k < num; k++) {
134 count += summon_named_creature(player_ptr, m_idx, y, x, MON_GRENADE, mode);
136 if (player_ptr->blind && count) {
137 msg_print(_("多くのものが間近にばらまかれる音がする。", "You hear many things scattered nearby."));
140 return MonsterSpellResult::make_valid();
144 * @brief BシンボルのRF6_SPECIALの処理。投げ落とす攻撃。 /
145 * @param player_ptr プレイヤーへの参照ポインタ
148 * @param m_idx 呪文を唱えるモンスターID
149 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
150 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
152 static MonsterSpellResult spell_RF6_SPECIAL_B(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
154 mspell_cast_msg_simple msg;
155 auto *floor_ptr = player_ptr->current_floor_ptr;
156 auto *m_ptr = &floor_ptr->m_list[m_idx];
157 monster_type *t_ptr = &floor_ptr->m_list[t_idx];
158 monster_race *tr_ptr = &r_info[t_ptr->r_idx];
159 bool monster_to_player = (target_type == MONSTER_TO_PLAYER);
160 bool monster_to_monster = (target_type == MONSTER_TO_MONSTER);
161 bool direct = player_bold(player_ptr, y, x);
162 GAME_TEXT m_name[MAX_NLEN];
163 monster_name(player_ptr, m_idx, m_name);
165 disturb(player_ptr, true, true);
166 if (one_in_(3) || !direct) {
167 msg.to_player = _("%^sは突然視界から消えた!", "You lose sight of %s!");
168 msg.to_mons = _("%^sは突然急上昇して視界から消えた!", "You lose sight of %s!");
170 simple_monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
172 teleport_away(player_ptr, m_idx, 10, TELEPORT_NONMAGICAL);
173 player_ptr->update |= (PU_MONSTERS);
174 return MonsterSpellResult::make_valid();
181 msg.to_player = _("%^sがあなたを掴んで空中から投げ落とした。", "%^s snatches you, soars into the sky, and drops you.");
182 msg.to_mons = _("%^sが%sを掴んで空中から投げ落とした。", "%^s snatches %s, soars into the sky, and releases its grip.");
184 simple_monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
186 bool fear, dead; /* dummy */
187 int dam = damroll(4, 8);
189 if (monster_to_player || t_idx == player_ptr->riding)
190 teleport_player_to(player_ptr, m_ptr->fy, m_ptr->fx, i2enum<teleport_flags>(TELEPORT_NONMAGICAL | TELEPORT_PASSIVE));
192 teleport_monster_to(player_ptr, t_idx, m_ptr->fy, m_ptr->fx, 100, i2enum<teleport_flags>(TELEPORT_NONMAGICAL | TELEPORT_PASSIVE));
194 if ((monster_to_player && player_ptr->levitation) || (monster_to_monster && (tr_ptr->flags7 & RF7_CAN_FLY))) {
195 msg.to_player = _("あなたは静かに着地した。", "You float gently down to the ground.");
196 msg.to_mons = _("%^sは静かに着地した。", "%^s floats gently down to the ground.");
198 msg.to_player = _("あなたは地面に叩きつけられた。", "You crashed into the ground.");
199 msg.to_mons = _("%^sは地面に叩きつけられた。", "%^s crashed into the ground.");
202 simple_monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
203 dam += damroll(6, 8);
205 if (monster_to_player || (monster_to_monster && player_ptr->riding == t_idx)) {
206 int get_damage = take_hit(player_ptr, DAMAGE_NOESCAPE, dam, m_name);
207 if (player_ptr->tim_eyeeye && get_damage > 0 && !player_ptr->is_dead) {
208 GAME_TEXT m_name_self[MAX_MONSTER_NAME];
209 monster_desc(player_ptr, m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
210 msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
211 project(player_ptr, 0, 0, m_ptr->fy, m_ptr->fx, get_damage, AttributeType::MISSILE, PROJECT_KILL);
212 set_tim_eyeeye(player_ptr, player_ptr->tim_eyeeye - 5, true);
216 if (monster_to_player && player_ptr->riding)
217 mon_take_hit_mon(player_ptr, player_ptr->riding, dam, &dead, &fear, extract_note_dies(real_r_idx(&floor_ptr->m_list[player_ptr->riding])), m_idx);
219 if (monster_to_monster)
220 mon_take_hit_mon(player_ptr, t_idx, dam, &dead, &fear, extract_note_dies(real_r_idx(t_ptr)), m_idx);
222 return MonsterSpellResult::make_valid();
226 * @brief RF6_SPECIALの処理。モンスターの種類によって実処理に振り分ける。 /
227 * @param player_ptr プレイヤーへの参照ポインタ
230 * @param m_idx 呪文を唱えるモンスターID
231 * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
232 * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
236 MonsterSpellResult spell_RF6_SPECIAL(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int target_type)
238 auto *floor_ptr = player_ptr->current_floor_ptr;
239 auto *m_ptr = &floor_ptr->m_list[m_idx];
240 auto *r_ptr = &r_info[m_ptr->r_idx];
242 switch (m_ptr->r_idx) {
244 return MonsterSpellResult::make_invalid();
246 case MON_BANORLUPART:
249 return spell_RF6_SPECIAL_BANORLUPART(player_ptr, m_idx);
252 return spell_RF6_SPECIAL_ROLENTO(player_ptr, y, x, m_idx, t_idx, target_type);
256 if (r_ptr->d_char == 'B') {
257 return spell_RF6_SPECIAL_B(player_ptr, y, x, m_idx, t_idx, target_type);
260 return MonsterSpellResult::make_invalid();