OSDN Git Service

[Refactor] #40413 Separated display-messages.c/h from util.c/h
[hengband/hengband.git] / src / mspell / mspell-special.c
1 /*!
2  * @brief 特殊な行動を取るモンスターの具体的な行動定義 (r_infoのSPECIALフラグ)
3  * @date 2020/05/16
4  * @author Hourier
5  */
6
7 #include "mspell/mspell-special.h"
8 #include "effect/effect-characteristics.h"
9 #include "main/sound-definitions-table.h"
10 #include "main/sound-of-music.h"
11 #include "melee/melee-postprocess.h"
12 #include "monster-floor/monster-death.h"
13 #include "monster-floor/monster-remover.h"
14 #include "monster-floor/monster-summon.h"
15 #include "monster-race/race-flags7.h"
16 #include "monster-race/race-indice-types.h"
17 #include "monster/monster-describer.h"
18 #include "monster/monster-description-types.h"
19 #include "monster/monster-info.h"
20 #include "monster/monster-util.h"
21 #include "mspell/monster-spell.h"
22 #include "mspell/mspell-util.h"
23 #include "player/player-damage.h"
24 #include "player/player-effects.h"
25 #include "player/player-move.h"
26 #include "spell-kind/spells-teleport.h"
27 #include "spell/process-effect.h"
28 #include "spell/spell-types.h"
29 #include "view/display-messages.h"
30
31 /*!
32  * @brief バーノール・ルパートのRF6_SPECIALの処理。分裂・合体。 /
33  * @param player_ptr プレーヤーへの参照ポインタ
34  * @param m_idx 呪文を唱えるモンスターID
35  */
36 HIT_POINT spell_RF6_SPECIAL_BANORLUPART(player_type *target_ptr, MONSTER_IDX m_idx)
37 {
38     floor_type *floor_ptr = target_ptr->current_floor_ptr;
39     monster_type *m_ptr = &floor_ptr->m_list[m_idx];
40     HIT_POINT dummy_hp, dummy_maxhp;
41     POSITION dummy_y = m_ptr->fy;
42     POSITION dummy_x = m_ptr->fx;
43     BIT_FLAGS mode = 0L;
44
45     switch (m_ptr->r_idx) {
46     case MON_BANORLUPART:
47         dummy_hp = (m_ptr->hp + 1) / 2;
48         dummy_maxhp = m_ptr->maxhp / 2;
49
50         if (floor_ptr->inside_arena || target_ptr->phase_out || !summon_possible(target_ptr, m_ptr->fy, m_ptr->fx))
51             return -1;
52
53         delete_monster_idx(target_ptr, floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx);
54         summon_named_creature(target_ptr, 0, dummy_y, dummy_x, MON_BANOR, mode);
55         floor_ptr->m_list[hack_m_idx_ii].hp = dummy_hp;
56         floor_ptr->m_list[hack_m_idx_ii].maxhp = dummy_maxhp;
57         summon_named_creature(target_ptr, 0, dummy_y, dummy_x, MON_LUPART, mode);
58         floor_ptr->m_list[hack_m_idx_ii].hp = dummy_hp;
59         floor_ptr->m_list[hack_m_idx_ii].maxhp = dummy_maxhp;
60
61         msg_print(_("『バーノール・ルパート』が分裂した!", "Banor=Rupart splits into two persons!"));
62         break;
63
64     case MON_BANOR:
65     case MON_LUPART:
66         dummy_hp = 0;
67         dummy_maxhp = 0;
68
69         if (!r_info[MON_BANOR].cur_num || !r_info[MON_LUPART].cur_num)
70             return -1;
71
72         for (MONSTER_IDX k = 1; k < floor_ptr->m_max; k++) {
73             if (floor_ptr->m_list[k].r_idx == MON_BANOR || floor_ptr->m_list[k].r_idx == MON_LUPART) {
74                 dummy_hp += floor_ptr->m_list[k].hp;
75                 dummy_maxhp += floor_ptr->m_list[k].maxhp;
76                 if (floor_ptr->m_list[k].r_idx != m_ptr->r_idx) {
77                     dummy_y = floor_ptr->m_list[k].fy;
78                     dummy_x = floor_ptr->m_list[k].fx;
79                 }
80                 delete_monster_idx(target_ptr, k);
81             }
82         }
83         summon_named_creature(target_ptr, 0, dummy_y, dummy_x, MON_BANORLUPART, mode);
84         floor_ptr->m_list[hack_m_idx_ii].hp = dummy_hp;
85         floor_ptr->m_list[hack_m_idx_ii].maxhp = dummy_maxhp;
86
87         msg_print(_("『バーノール』と『ルパート』が合体した!", "Banor and Rupart combine into one!"));
88         break;
89     }
90
91     return 0;
92 }
93
94 /*!
95  * @brief ロレントのRF6_SPECIALの処理。手榴弾の召喚。 /
96  * @param target_ptr プレーヤーへの参照ポインタ
97  * @param y 対象の地点のy座標
98  * @param x 対象の地点のx座標
99  * @param m_idx 呪文を唱えるモンスターID
100  * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
101  * @param TARGET_TYPE プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
102  * @return ダメージ量を返す。
103  */
104 HIT_POINT spell_RF6_SPECIAL_ROLENTO(player_type *target_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int TARGET_TYPE)
105 {
106     int count = 0, k;
107     int num = 1 + randint1(3);
108     BIT_FLAGS mode = 0L;
109
110     monspell_message(target_ptr, m_idx, t_idx, _("%^sが何か大量に投げた。", "%^s spreads something."),
111         _("%^sは手榴弾をばらまいた。", "%^s throws some hand grenades."), _("%^sは手榴弾をばらまいた。", "%^s throws some hand grenades."), TARGET_TYPE);
112
113     for (k = 0; k < num; k++) {
114         count += summon_named_creature(target_ptr, m_idx, y, x, MON_GRENADE, mode);
115     }
116     if (target_ptr->blind && count) {
117         msg_print(_("多くのものが間近にばらまかれる音がする。", "You hear many things scattered nearby."));
118     }
119     return 0;
120 }
121
122 /*!
123  * @brief BシンボルのRF6_SPECIALの処理。投げ落とす攻撃。 /
124  * @param target_ptr プレーヤーへの参照ポインタ
125  * @param y 対象の地点のy座標
126  * @param x 対象の地点のx座標
127  * @param m_idx 呪文を唱えるモンスターID
128  * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
129  * @param TARGET_TYPE プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
130  * @return ダメージ量を返す。
131  */
132 HIT_POINT spell_RF6_SPECIAL_B(player_type *target_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int TARGET_TYPE)
133 {
134     HIT_POINT dam = -1;
135     floor_type *floor_ptr = target_ptr->current_floor_ptr;
136     monster_type *m_ptr = &floor_ptr->m_list[m_idx];
137     monster_type *t_ptr = &floor_ptr->m_list[t_idx];
138     monster_race *tr_ptr = &r_info[t_ptr->r_idx];
139     bool monster_to_player = (TARGET_TYPE == MONSTER_TO_PLAYER);
140     bool monster_to_monster = (TARGET_TYPE == MONSTER_TO_MONSTER);
141     bool direct = player_bold(target_ptr, y, x);
142     GAME_TEXT m_name[MAX_NLEN];
143     monster_name(target_ptr, m_idx, m_name);
144
145     disturb(target_ptr, TRUE, TRUE);
146     if (one_in_(3) || !direct) {
147         simple_monspell_message(target_ptr, m_idx, t_idx, _("%^sは突然視界から消えた!", "%^s suddenly go out of your sight!"),
148             _("%^sは突然急上昇して視界から消えた!", "%^s suddenly go out of your sight!"), TARGET_TYPE);
149
150         teleport_away(target_ptr, m_idx, 10, TELEPORT_NONMAGICAL);
151         target_ptr->update |= (PU_MONSTERS);
152         return dam;
153     }
154
155     int get_damage = 0;
156     bool fear, dead; /* dummy */
157
158     simple_monspell_message(target_ptr, m_idx, t_idx, _("%^sがあなたを掴んで空中から投げ落とした。", "%^s holds you, and drops from the sky."),
159         _("%^sが%sを掴んで空中から投げ落とした。", "%^s holds %s, and drops from the sky."), TARGET_TYPE);
160
161     dam = damroll(4, 8);
162
163     if (monster_to_player || t_idx == target_ptr->riding)
164         teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
165     else
166         teleport_monster_to(target_ptr, t_idx, m_ptr->fy, m_ptr->fx, 100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
167
168     sound(SOUND_FALL);
169
170     if ((monster_to_player && target_ptr->levitation) || (monster_to_monster && (tr_ptr->flags7 & RF7_CAN_FLY))) {
171         simple_monspell_message(target_ptr, m_idx, t_idx, _("あなたは静かに着地した。", "You float gently down to the ground."),
172             _("%^sは静かに着地した。", "%^s floats gently down to the ground."), TARGET_TYPE);
173     } else {
174         simple_monspell_message(target_ptr, m_idx, t_idx, _("あなたは地面に叩きつけられた。", "You crashed into the ground."),
175             _("%^sは地面に叩きつけられた。", "%^s crashed into the ground."), TARGET_TYPE);
176         dam += damroll(6, 8);
177     }
178
179     if (monster_to_player || (monster_to_monster && target_ptr->riding == t_idx)) {
180         get_damage = take_hit(target_ptr, DAMAGE_NOESCAPE, dam, m_name, -1);
181         if (target_ptr->tim_eyeeye && get_damage > 0 && !target_ptr->is_dead) {
182             GAME_TEXT m_name_self[80];
183             monster_desc(target_ptr, m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
184             msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
185             project(target_ptr, 0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
186             set_tim_eyeeye(target_ptr, target_ptr->tim_eyeeye - 5, TRUE);
187         }
188     }
189
190     if (monster_to_player && target_ptr->riding)
191         mon_take_hit_mon(target_ptr, target_ptr->riding, dam, &dead, &fear, extract_note_dies(real_r_idx(&floor_ptr->m_list[target_ptr->riding])), m_idx);
192
193     if (monster_to_monster)
194         mon_take_hit_mon(target_ptr, t_idx, dam, &dead, &fear, extract_note_dies(real_r_idx(t_ptr)), m_idx);
195     return dam;
196 }
197
198 /*!
199  * @brief RF6_SPECIALの処理。モンスターの種類によって実処理に振り分ける。 /
200  * @param target_ptr プレーヤーへの参照ポインタ
201  * @param y 対象の地点のy座標
202  * @param x 対象の地点のx座標
203  * @param m_idx 呪文を唱えるモンスターID
204  * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
205  * @param TARGET_TYPE プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
206  * @return ダメージ量を返す。
207  */
208 HIT_POINT spell_RF6_SPECIAL(player_type *target_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, MONSTER_IDX t_idx, int TARGET_TYPE)
209 {
210     floor_type *floor_ptr = target_ptr->current_floor_ptr;
211     monster_type *m_ptr = &floor_ptr->m_list[m_idx];
212     monster_race *r_ptr = &r_info[m_ptr->r_idx];
213
214     disturb(target_ptr, TRUE, TRUE);
215     switch (m_ptr->r_idx) {
216     case MON_OHMU:
217         return -1;
218
219     case MON_BANORLUPART:
220     case MON_BANOR:
221     case MON_LUPART:
222         return spell_RF6_SPECIAL_BANORLUPART(target_ptr, m_idx);
223
224     case MON_ROLENTO:
225         return spell_RF6_SPECIAL_ROLENTO(target_ptr, y, x, m_idx, t_idx, TARGET_TYPE);
226         break;
227
228     default:
229         if (r_ptr->d_char == 'B') {
230             return spell_RF6_SPECIAL_B(target_ptr, y, x, m_idx, t_idx, TARGET_TYPE);
231             break;
232         }
233
234         else
235             return -1;
236     }
237 }