OSDN Git Service

[WIP] [Refactor] #39963 Separated spells2.h from spells1.h
[hengband/hengband.git] / src / spells-summon.c
1 #include "angband.h"
2 #include "util.h"
3
4 #include "spells-summon.h"
5 #include "player-inventory.h"
6 #include "monster-status.h"
7 #include "floor.h"
8 #include "effect/spells-effect-util.h"
9 #include "spell/spells2.h"
10
11 /*!
12 * @brief トランプ魔法独自の召喚処理を行う / Handle summoning and failure of trump spells
13 * @param num summon_specific()関数を呼び出す回数
14 * @param pet ペット化として召喚されるか否か
15 * @param y 召喚位置のy座標
16 * @param x 召喚位置のx座標
17 * @param lev 召喚レベル
18 * @param type 召喚条件ID
19 * @param mode モンスター生成条件フラグ
20 * @return モンスターが(敵対も含めて)召還されたならばTRUEを返す。
21 */
22 bool trump_summoning(player_type *caster_ptr, int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode)
23 {
24         /* Default level */
25         PLAYER_LEVEL plev = caster_ptr->lev;
26         if (!lev) lev = plev * 2 / 3 + randint1(plev / 2);
27
28         MONSTER_IDX who;
29         if (pet)
30         {
31                 /* Become pet */
32                 mode |= PM_FORCE_PET;
33
34                 /* Only sometimes allow unique monster */
35                 if (mode & PM_ALLOW_UNIQUE)
36                 {
37                         /* Forbid often */
38                         if (randint1(50 + plev) >= plev / 10)
39                                 mode &= ~PM_ALLOW_UNIQUE;
40                 }
41
42                 /* Player is who summons */
43                 who = -1;
44         }
45         else
46         {
47                 /* Prevent taming, allow unique monster */
48                 mode |= PM_NO_PET;
49
50                 /* Behave as if they appear by themselfs */
51                 who = 0;
52         }
53
54         bool success = FALSE;
55         for (int i = 0; i < num; i++)
56         {
57                 if (summon_specific(caster_ptr, who, y, x, lev, type, mode))
58                         success = TRUE;
59         }
60
61         if (!success)
62         {
63                 msg_print(_("誰もあなたのカードの呼び声に答えない。", "Nobody answers to your Trump call."));
64         }
65
66         return success;
67 }
68
69
70 bool cast_summon_demon(player_type *caster_ptr, int power)
71 {
72         u32b flg = 0L;
73         bool pet = !one_in_(3);
74         if (pet) flg |= PM_FORCE_PET;
75         else flg |= PM_NO_PET;
76         if (!(pet && (caster_ptr->lev < 50))) flg |= PM_ALLOW_GROUP;
77
78         if (!summon_specific(caster_ptr, (pet ? -1 : 0), caster_ptr->y, caster_ptr->x, power, SUMMON_DEMON, flg))
79                 return TRUE;
80
81         msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));
82         if (pet)
83         {
84                 msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'"));
85         }
86         else
87         {
88                 msg_print(_("「卑しき者よ、我は汝の下僕にあらず! お前の魂を頂くぞ!」",
89                         "'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'"));
90         }
91
92         return TRUE;
93 }
94
95 bool cast_summon_undead(player_type *creature_ptr, int power)
96 {
97         bool pet = one_in_(3);
98         int type = (creature_ptr->lev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
99
100         BIT_FLAGS mode = 0L;
101         if (!pet || ((creature_ptr->lev > 24) && one_in_(3))) mode |= PM_ALLOW_GROUP;
102         if (pet) mode |= PM_FORCE_PET;
103         else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
104
105         if (summon_specific(creature_ptr, (pet ? -1 : 0), creature_ptr->y, creature_ptr->x, power, type, mode))
106         {
107                 msg_print(_("冷たい風があなたの周りに吹き始めた。それは腐敗臭を運んでいる...",
108                         "Cold winds begin to blow around you, carrying with them the stench of decay..."));
109                 if (pet)
110                         msg_print(_("古えの死せる者共があなたに仕えるため土から甦った!",
111                                 "Ancient, long-dead forms arise from the ground to serve you!"));
112                 else
113                         msg_print(_("死者が甦った。眠りを妨げるあなたを罰するために!",
114                                 "'The dead arise... to punish you for disturbing them!'"));
115         }
116         return TRUE;
117 }
118
119
120 bool cast_summon_hound(player_type *creature_ptr, int power)
121 {
122         BIT_FLAGS mode = PM_ALLOW_GROUP;
123         bool pet = !one_in_(5);
124         if (pet) mode |= PM_FORCE_PET;
125         else mode |= PM_NO_PET;
126
127         if (summon_specific(creature_ptr, (pet ? -1 : 0), creature_ptr->y, creature_ptr->x, power, SUMMON_HOUND, mode))
128         {
129                 if (pet)
130                         msg_print(_("ハウンドがあなたの下僕として出現した。", "A group of hounds appear as your servant."));
131                 else
132                         msg_print(_("ハウンドはあなたに牙を向けている!", "A group of hounds appear as your enemy!"));
133         }
134
135         return TRUE;
136 }
137
138
139 bool cast_summon_elemental(player_type *creature_ptr, int power)
140 {
141         bool pet = one_in_(3);
142         BIT_FLAGS mode = 0L;
143         if (!(pet && (creature_ptr->lev < 50))) mode |= PM_ALLOW_GROUP;
144         if (pet) mode |= PM_FORCE_PET;
145         else mode |= PM_NO_PET;
146
147         if (summon_specific(creature_ptr, (pet ? -1 : 0), creature_ptr->y, creature_ptr->x, power, SUMMON_ELEMENTAL, mode))
148         {
149                 msg_print(_("エレメンタルが現れた...", "An elemental materializes..."));
150                 if (pet)
151                         msg_print(_("あなたに服従しているようだ。", "It seems obedient to you."));
152                 else
153                         msg_print(_("それをコントロールできなかった!", "You fail to control it!"));
154         }
155
156         return TRUE;
157 }
158
159
160 bool cast_summon_octopus(player_type *creature_ptr)
161 {
162         BIT_FLAGS mode = PM_ALLOW_GROUP;
163         bool pet = !one_in_(5);
164         if (pet) mode |= PM_FORCE_PET;
165         if (summon_named_creature(creature_ptr, 0, creature_ptr->y, creature_ptr->x, MON_JIZOTAKO, mode))
166         {
167                 if (pet)
168                         msg_print(_("蛸があなたの下僕として出現した。", "A group of octopuses appear as your servant."));
169                 else
170                         msg_print(_("蛸はあなたを睨んでいる!", "A group of octopuses appear as your enemy!"));
171         }
172
173         return TRUE;
174 }
175
176
177 /*!
178 * @brief 悪魔領域のグレーターデーモン召喚に利用可能な死体かどうかを返す。 / An "item_tester_hook" for offer
179 * @param o_ptr オブジェクト構造体の参照ポインタ
180 * @return 生贄に使用可能な死体ならばTRUEを返す。
181 */
182 bool item_tester_offer(object_type *o_ptr)
183 {
184         if (o_ptr->tval != TV_CORPSE) return FALSE;
185         if (o_ptr->sval != SV_CORPSE) return FALSE;
186         if (my_strchr("pht", r_info[o_ptr->pval].d_char)) return TRUE;
187         return FALSE;
188 }
189
190
191 /*!
192 * @brief 悪魔領域のグレーターデーモン召喚を処理する / Daemon spell Summon Greater Demon
193 * @return 処理を実行したならばTRUEを返す。
194 */
195 bool cast_summon_greater_demon(player_type *caster_ptr)
196 {
197         item_tester_hook = item_tester_offer;
198         concptr q = _("どの死体を捧げますか? ", "Sacrifice which corpse? ");
199         concptr s = _("捧げられる死体を持っていない。", "You have nothing to scrifice.");
200         OBJECT_IDX item;
201         object_type *o_ptr;
202         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
203         if (!o_ptr) return FALSE;
204
205         PLAYER_LEVEL plev = caster_ptr->lev;
206         int summon_lev = plev * 2 / 3 + r_info[o_ptr->pval].level;
207
208         if (summon_specific(caster_ptr, -1, caster_ptr->y, caster_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET)))
209         {
210                 msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));
211                 msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'"));
212                 vary_item(caster_ptr, item, -1);
213         }
214         else
215         {
216                 msg_print(_("悪魔は現れなかった。", "No Greater Demon arrives."));
217         }
218
219         return TRUE;
220 }
221
222
223 /*!
224  * @brief 同族召喚(援軍)処理
225  * @param player_ptr プレーヤーへの参照ポインタ
226  * @param level 召喚基準レベル
227  * @param y 召喚先Y座標
228  * @param x 召喚先X座標
229  * @param mode 召喚オプション
230  * @return ターンを消費した場合TRUEを返す
231  */
232 bool summon_kin_player(player_type *creature_ptr, DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
233 {
234         bool pet = (bool)(mode & PM_FORCE_PET);
235         if (!pet) mode |= PM_NO_PET;
236         return summon_specific(creature_ptr, (pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
237 }
238
239
240 /*!
241  * @brief サイバーデーモンの召喚
242  * @param player_ptr プレーヤーへの参照ポインタ
243  * @param who 召喚主のモンスターID(0ならばプレイヤー)
244  * @param y 召喚位置Y座標
245  * @param x 召喚位置X座標
246  * @return 作用が実際にあった場合TRUEを返す
247  */
248 int summon_cyber(player_type *creature_ptr, MONSTER_IDX who, POSITION y, POSITION x)
249 {
250         /* Summoned by a monster */
251         BIT_FLAGS mode = PM_ALLOW_GROUP;
252         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
253         if (who > 0)
254         {
255                 monster_type *m_ptr = &floor_ptr->m_list[who];
256                 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
257         }
258
259         int max_cyber = (easy_band ? 1 : (floor_ptr->dun_level / 50) + randint1(2));
260         if (max_cyber > 4) max_cyber = 4;
261
262         int count = 0;
263         for (int i = 0; i < max_cyber; i++)
264         {
265                 count += summon_specific(creature_ptr, who, y, x, 100, SUMMON_CYBER, mode);
266         }
267
268         return count;
269 }
270
271
272 void mitokohmon(player_type *kohmon_ptr)
273 {
274         int count = 0;
275         concptr sukekakusan = "";
276         if (summon_named_creature(kohmon_ptr, 0, kohmon_ptr->y, kohmon_ptr->x, MON_SUKE, PM_FORCE_PET))
277         {
278                 msg_print(_("『助さん』が現れた。", "Suke-san apperars."));
279                 sukekakusan = "Suke-san";
280                 count++;
281         }
282
283         if (summon_named_creature(kohmon_ptr, 0, kohmon_ptr->y, kohmon_ptr->x, MON_KAKU, PM_FORCE_PET))
284         {
285                 msg_print(_("『格さん』が現れた。", "Kaku-san appears."));
286                 sukekakusan = "Kaku-san";
287                 count++;
288         }
289
290         if (!count)
291         {
292                 for (int i = kohmon_ptr->current_floor_ptr->m_max - 1; i > 0; i--)
293                 {
294                         monster_type *m_ptr;
295                         m_ptr = &kohmon_ptr->current_floor_ptr->m_list[i];
296                         if (!monster_is_valid(m_ptr)) continue;
297                         if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
298                         if (!los(kohmon_ptr, m_ptr->fy, m_ptr->fx, kohmon_ptr->y, kohmon_ptr->x)) continue;
299                         if (!projectable(kohmon_ptr, m_ptr->fy, m_ptr->fx, kohmon_ptr->y, kohmon_ptr->x)) continue;
300                         count++;
301                         break;
302                 }
303         }
304
305         if (count == 0)
306         {
307                 msg_print(_("しかし、何も起きなかった。", "Nothing happens."));
308                 return;
309         }
310
311         msg_format(_("「者ども、ひかえおろう!!!このお方をどなたとこころえる。」",
312                 "%^s says 'WHO do you think this person is! Bow your head, down to your knees!'"), sukekakusan);
313         sukekaku = TRUE;
314         stun_monsters(kohmon_ptr, 120);
315         confuse_monsters(kohmon_ptr, 120);
316         turn_monsters(kohmon_ptr, 120);
317         stasis_monsters(kohmon_ptr, 120);
318         sukekaku = FALSE;
319 }