OSDN Git Service

v3.0.0 Alpha5 OSDN最終版
[hengband/hengband.git] / src / spells-summon.c
1 #include "angband.h"
2 #include "spells-summon.h"
3
4 /*!
5 * @brief トランプ魔法独自の召喚処理を行う / Handle summoning and failure of trump spells
6 * @param num summon_specific()関数を呼び出す回数
7 * @param pet ペット化として召喚されるか否か
8 * @param y 召喚位置のy座標
9 * @param x 召喚位置のx座標
10 * @param lev 召喚レベル
11 * @param type 召喚条件ID
12 * @param mode モンスター生成条件フラグ
13 * @return モンスターが(敵対も含めて)召還されたならばTRUEを返す。
14 */
15 bool trump_summoning(int num, bool pet, POSITION y, POSITION x, DEPTH lev, int type, BIT_FLAGS mode)
16 {
17         PLAYER_LEVEL plev = p_ptr->lev;
18
19         MONSTER_IDX who;
20         int i;
21         bool success = FALSE;
22
23         /* Default level */
24         if (!lev) lev = plev * 2 / 3 + randint1(plev / 2);
25
26         if (pet)
27         {
28                 /* Become pet */
29                 mode |= PM_FORCE_PET;
30
31                 /* Only sometimes allow unique monster */
32                 if (mode & PM_ALLOW_UNIQUE)
33                 {
34                         /* Forbid often */
35                         if (randint1(50 + plev) >= plev / 10)
36                                 mode &= ~PM_ALLOW_UNIQUE;
37                 }
38
39                 /* Player is who summons */
40                 who = -1;
41         }
42         else
43         {
44                 /* Prevent taming, allow unique monster */
45                 mode |= PM_NO_PET;
46
47                 /* Behave as if they appear by themselfs */
48                 who = 0;
49         }
50
51         for (i = 0; i < num; i++)
52         {
53                 if (summon_specific(who, y, x, lev, type, mode, '\0'))
54                         success = TRUE;
55         }
56
57         if (!success)
58         {
59                 msg_print(_("誰もあなたのカードの呼び声に答えない。", "Nobody answers to your Trump call."));
60         }
61
62         return success;
63 }
64
65
66 bool cast_summon_demon(int power)
67 {
68         u32b flg = 0L;
69         bool pet = !one_in_(3);
70
71         if (pet) flg |= PM_FORCE_PET;
72         else flg |= PM_NO_PET;
73         if (!(pet && (p_ptr->lev < 50))) flg |= PM_ALLOW_GROUP;
74
75         if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, power, SUMMON_DEMON, flg, '\0'))
76         {
77                 msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));
78                 if (pet)
79                 {
80                         msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'"));
81                 }
82                 else
83                 {
84                         msg_print(_("「卑しき者よ、我は汝の下僕にあらず! お前の魂を頂くぞ!」",
85                                 "'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'"));
86                 }
87         }
88         return TRUE;
89 }
90
91
92 /*!
93 * @brief 悪魔領域のグレーターデーモン召喚に利用可能な死体かどうかを返す。 / An "item_tester_hook" for offer
94 * @param o_ptr オブジェクト構造体の参照ポインタ
95 * @return 生贄に使用可能な死体ならばTRUEを返す。
96 */
97 bool item_tester_offer(object_type *o_ptr)
98 {
99         /* Flasks of oil are okay */
100         if (o_ptr->tval != TV_CORPSE) return (FALSE);
101         if (o_ptr->sval != SV_CORPSE) return (FALSE);
102
103         if (my_strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE);
104
105         /* Assume not okay */
106         return (FALSE);
107 }
108
109 /*!
110 * @brief 悪魔領域のグレーターデーモン召喚を処理する / Daemon spell Summon Greater Demon
111 * @return 処理を実行したならばTRUEを返す。
112 */
113 bool cast_summon_greater_demon(void)
114 {
115         PLAYER_LEVEL plev = p_ptr->lev;
116         OBJECT_IDX item;
117         concptr q, s;
118         int summon_lev;
119         object_type *o_ptr;
120
121         item_tester_hook = item_tester_offer;
122         q = _("どの死体を捧げますか? ", "Sacrifice which corpse? ");
123         s = _("捧げられる死体を持っていない。", "You have nothing to scrifice.");
124         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
125         if (!o_ptr) return FALSE;
126
127         summon_lev = plev * 2 / 3 + r_info[o_ptr->pval].level;
128
129         if (summon_specific(-1, p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET), '\0'))
130         {
131                 msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));
132                 msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'"));
133
134                 /* Decrease the item (from the pack) */
135                 if (item >= 0)
136                 {
137                         inven_item_increase(item, -1);
138                         inven_item_describe(item);
139                         inven_item_optimize(item);
140                 }
141
142                 /* Decrease the item (from the floor) */
143                 else
144                 {
145                         floor_item_increase(0 - item, -1);
146                         floor_item_describe(0 - item);
147                         floor_item_optimize(0 - item);
148                 }
149         }
150         else
151         {
152                 msg_print(_("悪魔は現れなかった。", "No Greater Demon arrive."));
153         }
154
155         return TRUE;
156 }
157
158 /*!
159  * @brief 同族召喚(援軍)処理
160  * @param level 召喚基準レベル
161  * @param y 召喚先Y座標
162  * @param x 召喚先X座標
163  * @param mode 召喚オプション
164  * @return ターンを消費した場合TRUEを返す
165  */
166 bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
167 {
168         bool pet = (bool)(mode & PM_FORCE_PET);
169         SYMBOL_CODE symbol = '\0';
170         if (!pet) mode |= PM_NO_PET;
171
172         switch (p_ptr->mimic_form)
173         {
174         case MIMIC_NONE:
175                 switch (p_ptr->prace)
176                 {
177                 case RACE_HUMAN:
178                 case RACE_AMBERITE:
179                 case RACE_BARBARIAN:
180                 case RACE_BEASTMAN:
181                 case RACE_DUNADAN:
182                         symbol = 'p';
183                         break;
184                 case RACE_HALF_ELF:
185                 case RACE_ELF:
186                 case RACE_HOBBIT:
187                 case RACE_GNOME:
188                 case RACE_DWARF:
189                 case RACE_HIGH_ELF:
190                 case RACE_NIBELUNG:
191                 case RACE_DARK_ELF:
192                 case RACE_MIND_FLAYER:
193                 case RACE_KUTAR:
194                 case RACE_S_FAIRY:
195                         symbol = 'h';
196                         break;
197                 case RACE_HALF_ORC:
198                         symbol = 'o';
199                         break;
200                 case RACE_HALF_TROLL:
201                         symbol = 'T';
202                         break;
203                 case RACE_HALF_OGRE:
204                         symbol = 'O';
205                         break;
206                 case RACE_HALF_GIANT:
207                 case RACE_HALF_TITAN:
208                 case RACE_CYCLOPS:
209                         symbol = 'P';
210                         break;
211                 case RACE_YEEK:
212                         symbol = 'y';
213                         break;
214                 case RACE_KLACKON:
215                         symbol = 'K';
216                         break;
217                 case RACE_KOBOLD:
218                         symbol = 'k';
219                         break;
220                 case RACE_IMP:
221                         if (one_in_(13)) symbol = 'U';
222                         else symbol = 'u';
223                         break;
224                 case RACE_DRACONIAN:
225                         symbol = 'd';
226                         break;
227                 case RACE_GOLEM:
228                 case RACE_ANDROID:
229                         symbol = 'g';
230                         break;
231                 case RACE_SKELETON:
232                         if (one_in_(13)) symbol = 'L';
233                         else symbol = 's';
234                         break;
235                 case RACE_ZOMBIE:
236                         symbol = 'z';
237                         break;
238                 case RACE_VAMPIRE:
239                         symbol = 'V';
240                         break;
241                 case RACE_SPECTRE:
242                         symbol = 'G';
243                         break;
244                 case RACE_SPRITE:
245                         symbol = 'I';
246                         break;
247                 case RACE_ENT:
248                         symbol = '#';
249                         break;
250                 case RACE_ANGEL:
251                         symbol = 'A';
252                         break;
253                 case RACE_DEMON:
254                         symbol = 'U';
255                         break;
256                 default:
257                         symbol = 'p';
258                         break;
259                 }
260                 break;
261         case MIMIC_DEMON:
262                 if (one_in_(13)) symbol = 'U';
263                 else symbol = 'u';
264                 break;
265         case MIMIC_DEMON_LORD:
266                 symbol = 'U';
267                 break;
268         case MIMIC_VAMPIRE:
269                 symbol = 'V';
270                 break;
271         }
272         return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode, symbol);
273 }
274
275 /*!
276  * @brief サイバーデーモンの召喚
277  * @param who 召喚主のモンスターID(0ならばプレイヤー)
278  * @param y 召喚位置Y座標
279  * @param x 召喚位置X座標
280  * @return 作用が実際にあった場合TRUEを返す
281  */
282 int summon_cyber(MONSTER_IDX who, POSITION y, POSITION x)
283 {
284         int i;
285         int max_cyber = (easy_band ? 1 : (dun_level / 50) + randint1(2));
286         int count = 0;
287         BIT_FLAGS mode = PM_ALLOW_GROUP;
288
289         /* Summoned by a monster */
290         if (who > 0)
291         {
292                 monster_type *m_ptr = &m_list[who];
293                 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
294         }
295
296         if (max_cyber > 4) max_cyber = 4;
297
298         for (i = 0; i < max_cyber; i++)
299         {
300                 count += summon_specific(who, y, x, 100, SUMMON_CYBER, mode, '\0');
301         }
302
303         return count;
304 }