OSDN Git Service

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