OSDN Git Service

refactor: extract damage spells in monst_spell_monst
[hengbandforosx/hengbandosx.git] / src / mspells2.c
1 /*!
2  * @file mspells2.c
3  * @brief ¥â¥ó¥¹¥¿¡¼ËâË¡¤Î¼ÂÁõ(ÂÐ¥â¥ó¥¹¥¿¡¼½èÍý) / Monster spells (attack monster)
4  * @date 2014/01/17
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7  * This software may be copied and distributed for educational, research,\n
8  * and not for profit purposes provided that this copyright and statement\n
9  * are included in all such copies.  Other copyrights may also apply.\n
10  * 2014 Deskull rearranged comment for Doxygen.\n
11  * @details
12  */
13
14 #include "angband.h"
15
16 /*!
17  * @brief ¥â¥ó¥¹¥¿¡¼¤¬Å¨ÂÐ¥â¥ó¥¹¥¿¡¼¤Ë¥Ó¡¼¥à¤òÅö¤Æ¤ë¤³¤È²Äǽ¤«¤òȽÄꤹ¤ë /
18  * Determine if a beam spell will hit the target.
19  * @param y1 »ÏÅÀ¤ÎYºÂɸ
20  * @param x1 »ÏÅÀ¤ÎXºÂɸ
21  * @param y2 ÌÜɸ¤ÎYºÂɸ
22  * @param x2 ÌÜɸ¤ÎXºÂɸ
23  * @param m_ptr »ÈÍѤ¹¤ë¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
24  * @return ¥Ó¡¼¥à¤¬Åþã²Äǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
25  */
26 static bool direct_beam(int y1, int x1, int y2, int x2, monster_type *m_ptr)
27 {
28         bool hit2 = FALSE;
29         int i, y, x;
30
31         int grid_n = 0;
32         u16b grid_g[512];
33
34         bool is_friend = is_pet(m_ptr);
35
36         /* Check the projection path */
37         grid_n = project_path(grid_g, MAX_RANGE, y1, x1, y2, x2, PROJECT_THRU);
38
39         /* No grid is ever projectable from itself */
40         if (!grid_n) return (FALSE);
41
42         for (i = 0; i < grid_n; i++)
43         {
44                 y = GRID_Y(grid_g[i]);
45                 x = GRID_X(grid_g[i]);
46
47                 if (y == y2 && x == x2)
48                         hit2 = TRUE;
49                 else if (is_friend && cave[y][x].m_idx > 0 &&
50                          !are_enemies(m_ptr, &m_list[cave[y][x].m_idx]))
51                 {
52                         /* Friends don't shoot friends */
53                         return FALSE;
54                 }
55
56                 if (is_friend && player_bold(y, x))
57                         return FALSE;
58         }
59         if (!hit2)
60                 return FALSE;
61         return TRUE;
62 }
63
64 /*!
65  * @brief ¥â¥ó¥¹¥¿¡¼¤¬Å¨ÂÐ¥â¥ó¥¹¥¿¡¼¤ËľÀܥ֥쥹¤òÅö¤Æ¤ë¤³¤È¤¬²Äǽ¤«¤òȽÄꤹ¤ë /
66  * Determine if a breath will hit the target.
67  * @param y1 »ÏÅÀ¤ÎYºÂɸ
68  * @param x1 »ÏÅÀ¤ÎXºÂɸ
69  * @param y2 ÌÜɸ¤ÎYºÂɸ
70  * @param x2 ÌÜɸ¤ÎXºÂɸ
71  * @param rad È¾·Â
72  * @param typ ¸ú²Ì°À­ID
73  * @param is_friend TRUE¤Ê¤é¤Ð¡¢¥×¥ì¥¤¥ä¡¼¤ò´¬¤­¹þ¤à»þ¤Ë¥Ö¥ì¥¹¤ÎȽÄê¤òFALSE¤Ë¤¹¤ë¡£
74  * @return ¥Ö¥ì¥¹¤òľÀÜÅö¤Æ¤é¤ì¤ë¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
75  */
76 static bool breath_direct(int y1, int x1, int y2, int x2, int rad, int typ, bool is_friend)
77 {
78         /* Must be the same as projectable() */
79
80         int i;
81
82         /* Initial grid */
83         int y = y1;
84         int x = x1;
85
86         int grid_n = 0;
87         u16b grid_g[512];
88
89         int grids = 0;
90         byte gx[1024], gy[1024];
91         byte gm[32];
92         int gm_rad = rad;
93
94         bool hit2 = FALSE;
95         bool hityou = FALSE;
96
97         int flg;
98
99         switch (typ)
100         {
101         case GF_LITE:
102         case GF_LITE_WEAK:
103                 flg = PROJECT_LOS;
104                 break;
105         case GF_DISINTEGRATE:
106                 flg = PROJECT_DISI;
107                 break;
108         default:
109                 flg = 0;
110                 break;
111         }
112
113         /* Check the projection path */
114         grid_n = project_path(grid_g, MAX_RANGE, y1, x1, y2, x2, flg);
115
116         /* Project along the path */
117         for (i = 0; i < grid_n; ++i)
118         {
119                 int ny = GRID_Y(grid_g[i]);
120                 int nx = GRID_X(grid_g[i]);
121
122                 if (flg & PROJECT_DISI)
123                 {
124                         /* Hack -- Balls explode before reaching walls */
125                         if (cave_stop_disintegration(ny, nx)) break;
126                 }
127                 else if (flg & PROJECT_LOS)
128                 {
129                         /* Hack -- Balls explode before reaching walls */
130                         if (!cave_los_bold(ny, nx)) break;
131                 }
132                 else
133                 {
134                         /* Hack -- Balls explode before reaching walls */
135                         if (!cave_have_flag_bold(ny, nx, FF_PROJECT)) break;
136                 }
137
138                 /* Save the "blast epicenter" */
139                 y = ny;
140                 x = nx;
141         }
142
143         grid_n = i;
144
145         if (!grid_n)
146         {
147                 if (flg & PROJECT_DISI)
148                 {
149                         if (in_disintegration_range(y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad)) hit2 = TRUE;
150                         if (in_disintegration_range(y1, x1, py, px) && (distance(y1, x1, py, px) <= rad)) hityou = TRUE;
151                 }
152                 else if (flg & PROJECT_LOS)
153                 {
154                         if (los(y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad)) hit2 = TRUE;
155                         if (los(y1, x1, py, px) && (distance(y1, x1, py, px) <= rad)) hityou = TRUE;
156                 }
157                 else
158                 {
159                         if (projectable(y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad)) hit2 = TRUE;
160                         if (projectable(y1, x1, py, px) && (distance(y1, x1, py, px) <= rad)) hityou = TRUE;
161                 }
162         }
163         else
164         {
165                 breath_shape(grid_g, grid_n, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, y, x, typ);
166
167                 for (i = 0; i < grids; i++)
168                 {
169                         /* Extract the location */
170                         y = gy[i];
171                         x = gx[i];
172
173                         if ((y == y2) && (x == x2)) hit2 = TRUE;
174                         if (player_bold(y, x)) hityou = TRUE;
175                 }
176         }
177
178         if (!hit2) return FALSE;
179         if (is_friend && hityou) return FALSE;
180
181         return TRUE;
182 }
183
184 /*!
185  * @brief ¥â¥ó¥¹¥¿¡¼¤¬ÆüìǽÎϤÎÌÜɸÃÏÅÀ¤ò·è¤á¤ë½èÍý /
186  * Get the actual center point of ball spells (rad > 1) (originally from TOband)
187  * @param sy »ÏÅÀ¤ÎYºÂɸ
188  * @param sx »ÏÅÀ¤ÎXºÂɸ
189  * @param ty ÌÜɸYºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
190  * @param tx ÌÜɸXºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
191  * @param flg È½Äê¤Î¥Õ¥é¥°ÇÛÎó
192  * @return ¤Ê¤·
193  */
194 void get_project_point(int sy, int sx, int *ty, int *tx, int flg)
195 {
196         u16b path_g[128];
197         int  path_n, i;
198
199         path_n = project_path(path_g, MAX_RANGE, sy, sx, *ty, *tx, flg);
200
201         *ty = sy;
202         *tx = sx;
203
204         /* Project along the path */
205         for (i = 0; i < path_n; i++)
206         {
207                 sy = GRID_Y(path_g[i]);
208                 sx = GRID_X(path_g[i]);
209
210                 /* Hack -- Balls explode before reaching walls */
211                 if (!cave_have_flag_bold(sy, sx, FF_PROJECT)) break;
212
213                 *ty = sy;
214                 *tx = sx;
215         }
216 }
217
218 /*!
219  * @brief ¥â¥ó¥¹¥¿¡¼¤¬Å¨¥â¥ó¥¹¥¿¡¼¤ËËâÎϾõî¤ò»È¤¦¤«¤É¤¦¤«¤òÊÖ¤¹ /
220  * Check should monster cast dispel spell at other monster.
221  * @param m_idx ½Ñ¼Ô¤Î¥â¥ó¥¹¥¿¡¼ID
222  * @param t_idx ÌÜɸ¤Î¥â¥ó¥¹¥¿¡¼ID
223  * @return ËâÎϾõî¤ò»È¤¦¤Ù¤­¤Ê¤é¤ÐTRUE¤òÊѤ¨¤¹¡£
224  */
225 static bool dispel_check_monster(int m_idx, int t_idx)
226 {
227         monster_type *t_ptr = &m_list[t_idx];
228
229         /* Invulnabilty */
230         if (MON_INVULNER(t_ptr)) return TRUE;
231
232         /* Speed */
233         if (t_ptr->mspeed < 135)
234         {
235                 if (MON_FAST(t_ptr)) return TRUE;
236         }
237
238         /* Riding monster */
239         if (t_idx == p_ptr->riding)
240         {
241                 if (dispel_check(m_idx)) return TRUE;
242         }
243
244         /* No need to cast dispel spell */
245         return FALSE;
246 }
247
248 /*!
249  * @brief ¥â¥ó¥¹¥¿¡¼¤¬Å¨¥â¥ó¥¹¥¿¡¼¤ËÆüìǽÎϤò»È¤¦½èÍý¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
250  * Monster tries to 'cast a spell' (or breath, etc) at another monster.
251  * @param m_idx ½Ñ¼Ô¤Î¥â¥ó¥¹¥¿¡¼ID
252  * @return ¼ÂºÝ¤ËÆüìǽÎϤò»È¤Ã¤¿¾ì¹çTRUE¤òÊÖ¤¹
253  * @details
254  * The player is only disturbed if able to be affected by the spell.
255  */
256 bool monst_spell_monst(int m_idx)
257 {
258         int y = 0, x = 0;
259         int i, k, t_idx = 0;
260         int thrown_spell, count = 0;
261         int rlev;
262         int dam = 0;
263         int start;
264         int plus = 1;
265         u32b u_mode = 0L;
266         int s_num_6 = (easy_band ? 2 : 6);
267         int s_num_4 = (easy_band ? 1 : 4);
268         int rad = 0; //For elemental balls
269
270         byte spell[96], num = 0;
271
272         char m_name[160];
273         char t_name[160];
274
275 #ifndef JP
276         char m_poss[160];
277 #endif
278
279         monster_type *m_ptr = &m_list[m_idx];
280         monster_type *t_ptr = NULL;
281
282         monster_race *r_ptr = &r_info[m_ptr->r_idx];
283         monster_race *tr_ptr = NULL;
284
285         u32b f4, f5, f6;
286
287         bool wake_up = FALSE;
288         bool fear = FALSE;
289
290         bool blind = (p_ptr->blind ? TRUE : FALSE);
291
292         bool see_m = is_seen(m_ptr);
293         bool maneable = player_has_los_bold(m_ptr->fy, m_ptr->fx);
294         bool see_t;
295         bool see_either;
296         bool known;
297
298         bool pet = is_pet(m_ptr);
299
300         bool in_no_magic_dungeon = (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && dun_level
301                 && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest));
302
303         bool can_use_lite_area = FALSE;
304
305         bool can_remember;
306
307         bool resists_tele = FALSE;
308
309         /* Prepare flags for summoning */
310         if (!pet) u_mode |= PM_ALLOW_UNIQUE;
311
312         /* Cannot cast spells when confused */
313         if (MON_CONFUSED(m_ptr)) return (FALSE);
314
315         /* Extract the racial spell flags */
316         f4 = r_ptr->flags4;
317         f5 = r_ptr->flags5;
318         f6 = r_ptr->flags6;
319
320         /* Target is given for pet? */
321         if (pet_t_m_idx && pet)
322         {
323                 t_idx = pet_t_m_idx;
324                 t_ptr = &m_list[t_idx];
325
326                 /* Cancel if not projectable (for now) */
327                 if ((m_idx == t_idx) || !projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
328                 {
329                         t_idx = 0;
330                 }
331         }
332
333         /* Is there counter attack target? */
334         if (!t_idx && m_ptr->target_y)
335         {
336                 t_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
337
338                 if (t_idx)
339                 {
340                         t_ptr = &m_list[t_idx];
341
342                         /* Cancel if neither enemy nor a given target */
343                         if ((m_idx == t_idx) ||
344                             ((t_idx != pet_t_m_idx) && !are_enemies(m_ptr, t_ptr)))
345                         {
346                                 t_idx = 0;
347                         }
348
349                         /* Allow only summoning etc.. if not projectable */
350                         else if (!projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
351                         {
352                                 f4 &= (RF4_INDIRECT_MASK);
353                                 f5 &= (RF5_INDIRECT_MASK);
354                                 f6 &= (RF6_INDIRECT_MASK);
355                         }
356                 }
357         }
358
359         /* Look for enemies normally */
360         if (!t_idx)
361         {
362                 bool success = FALSE;
363
364                 if (p_ptr->inside_battle)
365                 {
366                         start = randint1(m_max-1) + m_max;
367                         if (randint0(2)) plus = -1;
368                 }
369                 else start = m_max + 1;
370
371                 /* Scan thru all monsters */
372                 for (i = start; ((i < start + m_max) && (i > start - m_max)); i += plus)
373                 {
374                         int dummy = (i % m_max);
375                         if (!dummy) continue;
376
377                         t_idx = dummy;
378                         t_ptr = &m_list[t_idx];
379
380                         /* Skip dead monsters */
381                         if (!t_ptr->r_idx) continue;
382
383                         /* Monster must be 'an enemy' */
384                         if ((m_idx == t_idx) || !are_enemies(m_ptr, t_ptr)) continue;
385
386                         /* Monster must be projectable */
387                         if (!projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;
388
389                         /* Get it */
390                         success = TRUE;
391                         break;
392                 }
393
394                 /* No enemy found */
395                 if (!success) return FALSE;
396         }
397
398
399         /* OK -- we've got a target */
400         y = t_ptr->fy;
401         x = t_ptr->fx;
402         tr_ptr = &r_info[t_ptr->r_idx];
403
404         /* Forget old counter attack target */
405         reset_target(m_ptr);
406
407         /* Extract the monster level */
408         rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
409
410         /* Remove unimplemented spells */
411         f6 &= ~(RF6_WORLD | RF6_TRAPS | RF6_FORGET);
412
413         if (f4 & RF4_BR_LITE)
414         {
415                 if (!los(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
416                         f4 &= ~(RF4_BR_LITE);
417         }
418
419         /* Remove unimplemented special moves */
420         if (f6 & RF6_SPECIAL)
421         {
422                 if ((m_ptr->r_idx != MON_ROLENTO) && (r_ptr->d_char != 'B'))
423                         f6 &= ~(RF6_SPECIAL);
424         }
425
426         if (f6 & RF6_DARKNESS)
427         {
428                 bool vs_ninja = (p_ptr->pclass == CLASS_NINJA) && !is_hostile(t_ptr);
429
430                 if (vs_ninja &&
431                     !(r_ptr->flags3 & (RF3_UNDEAD | RF3_HURT_LITE)) &&
432                     !(r_ptr->flags7 & RF7_DARK_MASK))
433                         can_use_lite_area = TRUE;
434
435                 if (!(r_ptr->flags2 & RF2_STUPID))
436                 {
437                         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) f6 &= ~(RF6_DARKNESS);
438                         else if (vs_ninja && !can_use_lite_area) f6 &= ~(RF6_DARKNESS);
439                 }
440         }
441
442         if (in_no_magic_dungeon && !(r_ptr->flags2 & RF2_STUPID))
443         {
444                 f4 &= (RF4_NOMAGIC_MASK);
445                 f5 &= (RF5_NOMAGIC_MASK);
446                 f6 &= (RF6_NOMAGIC_MASK);
447         }
448
449         if (p_ptr->inside_arena || p_ptr->inside_battle)
450         {
451                 f4 &= ~(RF4_SUMMON_MASK);
452                 f5 &= ~(RF5_SUMMON_MASK);
453                 f6 &= ~(RF6_SUMMON_MASK | RF6_TELE_LEVEL);
454
455                 if (m_ptr->r_idx == MON_ROLENTO) f6 &= ~(RF6_SPECIAL);
456         }
457
458         if (p_ptr->inside_battle && !one_in_(3))
459         {
460                 f6 &= ~(RF6_HEAL);
461         }
462
463         if (m_idx == p_ptr->riding)
464         {
465                 f4 &= ~(RF4_RIDING_MASK);
466                 f5 &= ~(RF5_RIDING_MASK);
467                 f6 &= ~(RF6_RIDING_MASK);
468         }
469
470         if (pet)
471         {
472                 f4 &= ~(RF4_SHRIEK);
473                 f6 &= ~(RF6_DARKNESS | RF6_TRAPS);
474
475                 if (!(p_ptr->pet_extra_flags & PF_TELEPORT))
476                 {
477                         f6 &= ~(RF6_BLINK | RF6_TPORT | RF6_TELE_TO | RF6_TELE_AWAY | RF6_TELE_LEVEL);
478                 }
479
480                 if (!(p_ptr->pet_extra_flags & PF_ATTACK_SPELL))
481                 {
482                         f4 &= ~(RF4_ATTACK_MASK);
483                         f5 &= ~(RF5_ATTACK_MASK);
484                         f6 &= ~(RF6_ATTACK_MASK);
485                 }
486
487                 if (!(p_ptr->pet_extra_flags & PF_SUMMON_SPELL))
488                 {
489                         f4 &= ~(RF4_SUMMON_MASK);
490                         f5 &= ~(RF5_SUMMON_MASK);
491                         f6 &= ~(RF6_SUMMON_MASK);
492                 }
493
494                 /* Prevent collateral damage */
495                 if (!(p_ptr->pet_extra_flags & PF_BALL_SPELL) && (m_idx != p_ptr->riding))
496                 {
497                         if ((f4 & (RF4_BALL_MASK & ~(RF4_ROCKET))) ||
498                             (f5 & RF5_BALL_MASK) ||
499                             (f6 & RF6_BALL_MASK))
500                         {
501                                 int real_y = y;
502                                 int real_x = x;
503
504                                 get_project_point(m_ptr->fy, m_ptr->fx, &real_y, &real_x, 0L);
505
506                                 if (projectable(real_y, real_x, py, px))
507                                 {
508                                         int dist = distance(real_y, real_x, py, px);
509
510                                         if (dist <= 2)
511                                         {
512                                                 f4 &= ~(RF4_BALL_MASK & ~(RF4_ROCKET));
513                                                 f5 &= ~(RF5_BALL_MASK);
514                                                 f6 &= ~(RF6_BALL_MASK);
515                                         }
516                                         else if (dist <= 4)
517                                         {
518                                                 f4 &= ~(RF4_BIG_BALL_MASK);
519                                                 f5 &= ~(RF5_BIG_BALL_MASK);
520                                                 f6 &= ~(RF6_BIG_BALL_MASK);
521                                         }
522                                 }
523                                 else if (f5 & RF5_BA_LITE)
524                                 {
525                                         if ((distance(real_y, real_x, py, px) <= 4) && los(real_y, real_x, py, px))
526                                                 f5 &= ~(RF5_BA_LITE);
527                                 }
528                         }
529
530                         if (f4 & RF4_ROCKET)
531                         {
532                                 int real_y = y;
533                                 int real_x = x;
534
535                                 get_project_point(m_ptr->fy, m_ptr->fx, &real_y, &real_x, PROJECT_STOP);
536                                 if (projectable(real_y, real_x, py, px) && (distance(real_y, real_x, py, px) <= 2))
537                                         f4 &= ~(RF4_ROCKET);
538                         }
539
540                         if (((f4 & RF4_BEAM_MASK) ||
541                              (f5 & RF5_BEAM_MASK) ||
542                              (f6 & RF6_BEAM_MASK)) &&
543                             !direct_beam(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, m_ptr))
544                         {
545                                 f4 &= ~(RF4_BEAM_MASK);
546                                 f5 &= ~(RF5_BEAM_MASK);
547                                 f6 &= ~(RF6_BEAM_MASK);
548                         }
549
550                         if ((f4 & RF4_BREATH_MASK) ||
551                             (f5 & RF5_BREATH_MASK) ||
552                             (f6 & RF6_BREATH_MASK))
553                         {
554                                 /* Expected breath radius */
555                                 int rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2;
556
557                                 if (!breath_direct(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, rad, 0, TRUE))
558                                 {
559                                         f4 &= ~(RF4_BREATH_MASK);
560                                         f5 &= ~(RF5_BREATH_MASK);
561                                         f6 &= ~(RF6_BREATH_MASK);
562                                 }
563                                 else if ((f4 & RF4_BR_LITE) &&
564                                          !breath_direct(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, rad, GF_LITE, TRUE))
565                                 {
566                                         f4 &= ~(RF4_BR_LITE);
567                                 }
568                                 else if ((f4 & RF4_BR_DISI) &&
569                                          !breath_direct(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, rad, GF_DISINTEGRATE, TRUE))
570                                 {
571                                         f4 &= ~(RF4_BR_DISI);
572                                 }
573                         }
574                 }
575
576                 /* Special moves restriction */
577                 if (f6 & RF6_SPECIAL)
578                 {
579                         if (m_ptr->r_idx == MON_ROLENTO)
580                         {
581                                 if ((p_ptr->pet_extra_flags & (PF_ATTACK_SPELL | PF_SUMMON_SPELL)) != (PF_ATTACK_SPELL | PF_SUMMON_SPELL))
582                                         f6 &= ~(RF6_SPECIAL);
583                         }
584                         else if (r_ptr->d_char == 'B')
585                         {
586                                 if ((p_ptr->pet_extra_flags & (PF_ATTACK_SPELL | PF_TELEPORT)) != (PF_ATTACK_SPELL | PF_TELEPORT))
587                                         f6 &= ~(RF6_SPECIAL);
588                         }
589                         else f6 &= ~(RF6_SPECIAL);
590                 }
591         }
592
593         /* Remove some spells if necessary */
594
595         if (!(r_ptr->flags2 & RF2_STUPID))
596         {
597                 /* Check for a clean bolt shot */
598                 if (((f4 & RF4_BOLT_MASK) ||
599                      (f5 & RF5_BOLT_MASK) ||
600                      (f6 & RF6_BOLT_MASK)) &&
601                     !clean_shot(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, pet))
602                 {
603                         f4 &= ~(RF4_BOLT_MASK);
604                         f5 &= ~(RF5_BOLT_MASK);
605                         f6 &= ~(RF6_BOLT_MASK);
606                 }
607
608                 /* Check for a possible summon */
609                 if (((f4 & RF4_SUMMON_MASK) ||
610                      (f5 & RF5_SUMMON_MASK) ||
611                      (f6 & RF6_SUMMON_MASK)) &&
612                     !(summon_possible(t_ptr->fy, t_ptr->fx)))
613                 {
614                         /* Remove summoning spells */
615                         f4 &= ~(RF4_SUMMON_MASK);
616                         f5 &= ~(RF5_SUMMON_MASK);
617                         f6 &= ~(RF6_SUMMON_MASK);
618                 }
619
620                 /* Dispel magic */
621                 if ((f4 & RF4_DISPEL) && !dispel_check_monster(m_idx, t_idx))
622                 {
623                         /* Remove dispel spell */
624                         f4 &= ~(RF4_DISPEL);
625                 }
626
627                 /* Check for a possible raise dead */
628                 if ((f6 & RF6_RAISE_DEAD) && !raise_possible(m_ptr))
629                 {
630                         /* Remove raise dead spell */
631                         f6 &= ~(RF6_RAISE_DEAD);
632                 }
633
634                 /* Special moves restriction */
635                 if (f6 & RF6_SPECIAL)
636                 {
637                         if ((m_ptr->r_idx == MON_ROLENTO) && !summon_possible(t_ptr->fy, t_ptr->fx))
638                         {
639                                 f6 &= ~(RF6_SPECIAL);
640                         }
641                 }
642         }
643
644         if (r_ptr->flags2 & RF2_SMART)
645         {
646                 /* Hack -- allow "desperate" spells */
647                 if ((m_ptr->hp < m_ptr->maxhp / 10) &&
648                     (randint0(100) < 50))
649                 {
650                         /* Require intelligent spells */
651                         f4 &= (RF4_INT_MASK);
652                         f5 &= (RF5_INT_MASK);
653                         f6 &= (RF6_INT_MASK);
654                 }
655
656                 /* Hack -- decline "teleport level" in some case */
657                 if ((f6 & RF6_TELE_LEVEL) && TELE_LEVEL_IS_INEFF((t_idx == p_ptr->riding) ? 0 : t_idx))
658                 {
659                         f6 &= ~(RF6_TELE_LEVEL);
660                 }
661         }
662
663         /* No spells left */
664         if (!f4 && !f5 && !f6) return FALSE;
665
666         /* Extract the "inate" spells */
667         for (k = 0; k < 32; k++)
668         {
669                 if (f4 & (1L << k)) spell[num++] = k + 32 * 3;
670         }
671
672         /* Extract the "normal" spells */
673         for (k = 0; k < 32; k++)
674         {
675                 if (f5 & (1L << k)) spell[num++] = k + 32 * 4;
676         }
677
678         /* Extract the "bizarre" spells */
679         for (k = 0; k < 32; k++)
680         {
681                 if (f6 & (1L << k)) spell[num++] = k + 32 * 5;
682         }
683
684         /* No spells left */
685         if (!num) return (FALSE);
686
687         /* Stop if player is dead or gone */
688         if (!p_ptr->playing || p_ptr->is_dead) return (FALSE);
689
690         /* Handle "leaving" */
691         if (p_ptr->leaving) return (FALSE);
692
693         /* Get the monster name (or "it") */
694         monster_desc(m_name, m_ptr, 0x00);
695
696 #ifndef JP
697         /* Get the monster possessive ("his"/"her"/"its") */
698         monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
699 #endif
700
701         /* Get the target's name (or "it") */
702         monster_desc(t_name, t_ptr, 0x00);
703
704         /* Choose a spell to cast */
705         thrown_spell = spell[randint0(num)];
706
707         see_t = is_seen(t_ptr);
708         see_either = (see_m || see_t);
709
710         /* Can the player be aware of this attack? */
711         known = (m_ptr->cdis <= MAX_SIGHT) || (t_ptr->cdis <= MAX_SIGHT);
712
713         if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 1);
714
715         /* Check for spell failure (inate attacks never fail) */
716         if (!spell_is_inate(thrown_spell) && (in_no_magic_dungeon || (MON_STUNNED(m_ptr) && one_in_(2))))
717         {
718                 disturb(1, 1);
719                 /* Message */
720                 if (see_m) msg_format(_("%^s¤Ï¼öʸ¤ò¾§¤¨¤è¤¦¤È¤·¤¿¤¬¼ºÇÔ¤·¤¿¡£", 
721                                             "%^s tries to cast a spell, but fails."), m_name);
722
723                 return (TRUE);
724         }
725
726         /* Hex: Anti Magic Barrier */
727         if (!spell_is_inate(thrown_spell) && magic_barrier(m_idx))
728         {
729                 if (see_m) msg_format(_("È¿ËâË¡¥Ð¥ê¥¢¤¬%^s¤Î¼öʸ¤ò¤«¤­¾Ã¤·¤¿¡£", 
730                                             "Anti magic barrier cancels the spell which %^s casts."), m_name);
731                 return (TRUE);
732         }
733
734         can_remember = is_original_ap_and_seen(m_ptr);
735
736         switch (thrown_spell)
737         {
738     case 96 + 0:   spell_RF4_SHRIEK(m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_SHRIEK */
739     case 96 + 1:   return FALSE;  /* RF4_XXX1 */
740     case 96 + 2:   spell_RF4_DISPEL(m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_DISPEL */
741     case 96 + 3:   dam = spell_RF4_ROCKET(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_ROCKET */
742     case 96 + 4:   dam = spell_RF4_SHOOT(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_SHOOT */
743     case 96 + 5:   return FALSE; /* RF4_XXX2 */
744     case 96 + 6:   return FALSE; /* RF4_XXX3 */
745     case 96 + 7:   return FALSE; /* RF4_XXX4 */
746     case 96 + 8:   dam = spell_RF4_BREATH(GF_ACID, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_ACID */
747     case 96 + 9:   dam = spell_RF4_BREATH(GF_ELEC, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_ELEC */
748     case 96 + 10:  dam = spell_RF4_BREATH(GF_FIRE, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_FIRE */
749     case 96 + 11:  dam = spell_RF4_BREATH(GF_COLD, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_COLD */
750     case 96 + 12:  dam = spell_RF4_BREATH(GF_POIS, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_POIS */
751     case 96 + 13:  dam = spell_RF4_BREATH(GF_NETHER, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_NETH */
752     case 96 + 14:  dam = spell_RF4_BREATH(GF_LITE, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_LITE */
753     case 96 + 15:  dam = spell_RF4_BREATH(GF_DARK, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_DARK */
754     case 96 + 16:  dam = spell_RF4_BREATH(GF_CONFUSION, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_CONF */
755     case 96 + 17:  dam = spell_RF4_BREATH(GF_SOUND, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_SOUN */
756     case 96 + 18:  dam = spell_RF4_BREATH(GF_CHAOS, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_CHAO */
757     case 96 + 19:  dam = spell_RF4_BREATH(GF_DISENCHANT, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_DISE */
758     case 96 + 20:  dam = spell_RF4_BREATH(GF_NEXUS, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_NEXU */
759     case 96 + 21:  dam = spell_RF4_BREATH(GF_TIME, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_TIME */
760     case 96 + 22:  dam = spell_RF4_BREATH(GF_INERTIA, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_INER */
761     case 96 + 23:  dam = spell_RF4_BREATH(GF_GRAVITY, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_GRAV */
762     case 96 + 24:  dam = spell_RF4_BREATH(GF_SHARDS, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_SHAR */
763     case 96 + 25:  dam = spell_RF4_BREATH(GF_PLASMA, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_PLAS */
764     case 96 + 26:  dam = spell_RF4_BREATH(GF_FORCE, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_WALL */
765     case 96 + 27:  dam = spell_RF4_BREATH(GF_MANA, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_MANA */
766     case 96 + 28:  dam = spell_RF4_BA_NUKE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BA_NUKE */
767     case 96 + 29:  dam = spell_RF4_BREATH(GF_NUKE, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_NUKE */
768     case 96 + 30:  dam = spell_RF4_BA_CHAO(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BA_CHAO */
769     case 96 + 31:  dam = spell_RF4_BREATH(GF_DISINTEGRATE, y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF4_BR_DISI */
770     case 128 + 0:  dam = spell_RF5_BA_ACID(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_ACID */
771     case 128 + 1:  dam = spell_RF5_BA_ELEC(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_ELEC */
772     case 128 + 2:  dam = spell_RF5_BA_FIRE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_FIRE */
773     case 128 + 3:  dam = spell_RF5_BA_COLD(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_COLD */
774     case 128 + 4:  dam = spell_RF5_BA_POIS(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_POIS */
775     case 128 + 5:  dam = spell_RF5_BA_NETH(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_NETH */
776     case 128 + 6:  dam = spell_RF5_BA_WATE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_WATE */
777     case 128 + 7:  dam = spell_RF5_BA_MANA(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_MANA */
778     case 128 + 8:  dam = spell_RF5_BA_DARK(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_DARK */
779     case 128 + 9:  dam = spell_RF5_DRAIN_MANA(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_DRAIN_MANA */
780     case 128 + 10: dam = spell_RF5_MIND_BLAST(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_MIND_BLAST */
781     case 128 + 11: dam = spell_RF5_BRAIN_SMASH(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BRAIN_SMASH */
782     case 128 + 12: dam = spell_RF5_CAUSE_1(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_CAUSE_1 */
783     case 128 + 13: dam = spell_RF5_CAUSE_2(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_CAUSE_2 */
784     case 128 + 14: dam = spell_RF5_CAUSE_3(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_CAUSE_3 */
785     case 128 + 15: dam = spell_RF5_CAUSE_4(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_CAUSE_4 */
786     case 128 + 16: dam = spell_RF5_BO_ACID(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_ACID */
787     case 128 + 17: dam = spell_RF5_BO_ELEC(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_ELEC */
788     case 128 + 18: dam = spell_RF5_BO_FIRE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_FIRE */
789     case 128 + 19: dam = spell_RF5_BO_COLD(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_COLD */
790     case 128 + 20: dam = spell_RF5_BA_LITE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BA_LITE */
791     case 128 + 21: dam = spell_RF5_BO_NETH(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_NETH */
792     case 128 + 22: dam = spell_RF5_BO_WATE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_WATE */
793     case 128 + 23: dam = spell_RF5_BO_MANA(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_MANA */
794     case 128 + 24: dam = spell_RF5_BO_PLAS(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_PLAS */
795     case 128 + 25: dam = spell_RF5_BO_ICEE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_BO_ICEE */
796     case 128 + 26: dam = spell_RF5_MISSILE(y, x, m_idx, t_idx, MONSTER_TO_MONSTER); break; /* RF5_MISSILE */
797
798         /* RF5_SCARE */
799         case 128+27:
800                 if (known)
801                 {
802                         if (see_either)
803                         {
804                                 msg_format(_("%^s¤¬¶²¤í¤·¤²¤Ê¸¸³Ð¤òºî¤ê½Ð¤·¤¿¡£",
805                                                  "%^s casts a fearful illusion in front of %s."), m_name, t_name);
806                         }
807                         else
808                         {
809                                 mon_fight = TRUE;
810                         }
811                 }
812
813                 if (tr_ptr->flags3 & RF3_NO_FEAR)
814                 {
815                         if (see_t) msg_format(_("%^s¤Ï¶²Éݤò´¶¤¸¤Ê¤¤¡£", 
816                                                     "%^s refuses to be frightened."), t_name);
817
818                 }
819                 else if (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)
820                 {
821                         if (see_t) msg_format(_("%^s¤Ï¶²Éݤò´¶¤¸¤Ê¤¤¡£", 
822                                                     "%^s refuses to be frightened."), t_name);
823                 }
824                 else
825                 {
826                         if (set_monster_monfear(t_idx, MON_MONFEAR(t_ptr) + randint0(4) + 4)) fear = TRUE;
827                 }
828
829                 wake_up = TRUE;
830
831                 break;
832
833         /* RF5_BLIND */
834         case 128+28:
835                 if (known)
836                 {
837                         if (see_either)
838                         {
839                                 _(msg_format("%s¤Ï¼öʸ¤ò¾§¤¨¤Æ%s¤ÎÌܤò¾Æ¤­ÉÕ¤«¤»¤¿¡£", m_name, t_name),
840                                   msg_format("%^s casts a spell, burning %s%s eyes.", m_name, t_name,
841                                                  (streq(t_name, "it") ? "s" : "'s")));
842
843                         }
844                         else
845                         {
846                                 mon_fight = TRUE;
847                         }
848                 }
849
850                 /* Simulate blindness with confusion */
851                 if (tr_ptr->flags3 & RF3_NO_CONF)
852                 {
853                         if (see_t) msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", "%^s is unaffected."), t_name);
854                 }
855                 else if (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)
856                 {
857                         if (see_t) msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", "%^s is unaffected."), t_name);
858                 }
859                 else
860                 {
861                         if (see_t) msg_format(_("%^s¤ÏÌܤ¬¸«¤¨¤Ê¤¯¤Ê¤Ã¤¿¡ª ", "%^s is blinded!"), t_name);
862
863                         (void)set_monster_confused(t_idx, MON_CONFUSED(t_ptr) + 12 + randint0(4));
864                 }
865
866                 wake_up = TRUE;
867
868                 break;
869
870         /* RF5_CONF */
871         case 128+29:
872                 if (known)
873                 {
874                         if (see_either)
875                         {
876                                 msg_format(_("%^s¤¬%s¤ÎÁ°¤Ë¸¸ÏÇŪ¤Ê¸¸¤ò¤Ä¤¯¤ê½Ð¤·¤¿¡£",
877                                                  "%^s casts a mesmerizing illusion in front of %s."), m_name, t_name);
878                         }
879                         else
880                         {
881                                 mon_fight = TRUE;
882                         }
883                 }
884
885                 if (tr_ptr->flags3 & RF3_NO_CONF)
886                 {
887                         if (see_t) msg_format(_("%^s¤ÏÏǤ蘆¤ì¤Ê¤«¤Ã¤¿¡£",
888                                                     "%^s disbelieves the feeble spell."), t_name);
889                 }
890                 else if (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)
891                 {
892                         if (see_t) msg_format(_("%^s¤ÏÏǤ蘆¤ì¤Ê¤«¤Ã¤¿¡£",
893                                                     "%^s disbelieves the feeble spell."), t_name);
894                 }
895                 else
896                 {
897                         if (see_t) msg_format(_("%^s¤Ïº®Í𤷤¿¤è¤¦¤À¡£",
898                                                     "%^s seems confused."), t_name);
899
900                         (void)set_monster_confused(t_idx, MON_CONFUSED(t_ptr) + 12 + randint0(4));
901                 }
902
903                 wake_up = TRUE;
904
905                 break;
906
907         /* RF5_SLOW */
908         case 128+30:
909                 if (known)
910                 {
911                         if (see_either)
912                         {
913                                 _(msg_format("%s¤¬%s¤Î¶ÚÆù¤«¤éÎϤòµÛ¤¤¤È¤Ã¤¿¡£", m_name, t_name),
914                                   msg_format("%^s drains power from %s%s muscles.", m_name, t_name,
915                                            (streq(t_name, "it") ? "s" : "'s")));
916                         }
917                         else
918                         {
919                                 mon_fight = TRUE;
920                         }
921                 }
922
923                 if (tr_ptr->flags1 & RF1_UNIQUE)
924                 {
925                         if (see_t) msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£",
926                                                     "%^s is unaffected."), t_name);
927                 }
928                 else if (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)
929                 {
930                         if (see_t) msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£",
931                                                     "%^s is unaffected."), t_name);
932                 }
933                 else
934                 {
935                         if (set_monster_slow(t_idx, MON_SLOW(t_ptr) + 50))
936                         {
937                                 if (see_t) msg_format(_("%s¤ÎÆ°¤­¤¬ÃÙ¤¯¤Ê¤Ã¤¿¡£",
938                                                             "%^s starts moving slower."), t_name);
939                         }
940                 }
941
942                 wake_up = TRUE;
943
944                 break;
945
946         /* RF5_HOLD */
947         case 128+31:
948                 if (known)
949                 {
950                         if (see_either)
951                         {
952                                 msg_format(_("%^s¤Ï%s¤ò¤¸¤Ã¤È¸«¤Ä¤á¤¿¡£", "%^s stares intently at %s."), m_name, t_name);
953                         }
954                         else
955                         {
956                                 mon_fight = TRUE;
957                         }
958                 }
959
960                 if ((tr_ptr->flags1 & RF1_UNIQUE) ||
961                     (tr_ptr->flags3 & RF3_NO_STUN))
962                 {
963                         if (see_t) msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", "%^s is unaffected."), t_name);
964                 }
965                 else if (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10)
966                 {
967                         if (see_t) msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", "%^s is unaffected."), t_name);
968                 }
969                 else
970                 {
971                         if (see_t) msg_format(_("%^s¤ÏËãá㤷¤¿¡ª", "%^s is paralyzed!"), t_name);
972
973                         (void)set_monster_stunned(t_idx, MON_STUNNED(t_ptr) + randint1(4) + 4);
974                 }
975
976                 wake_up = TRUE;
977
978                 break;
979
980
981         /* RF6_HASTE */
982         case 160+0:
983                 if (known)
984                 {
985                         if (see_m)
986                         {
987                                 msg_format(_("%^s¤¬¼«Ê¬¤ÎÂΤËÇ°¤òÁ÷¤Ã¤¿¡£", "%^s concentrates on %s body."), m_name);
988                         }
989                         else
990                         {
991                                 mon_fight = TRUE;
992                         }
993                 }
994
995                 /* Allow quick speed increases to base+10 */
996                 if (set_monster_fast(m_idx, MON_FAST(m_ptr) + 100))
997                 {
998                         if (see_m) msg_format(_("%^s¤ÎÆ°¤­¤¬Â®¤¯¤Ê¤Ã¤¿¡£", "%^s starts moving faster."), m_name);
999                 }
1000                 break;
1001
1002         /* RF6_HAND_DOOM */
1003         case 160+1:
1004                 if (known)
1005                 {
1006                         if (see_m)
1007                         {
1008                                 msg_format(_("%^s¤¬%s¤Ë<ÇËÌǤμê>¤òÊü¤Ã¤¿¡ª", "%^s invokes the Hand of Doom upon %s!"), m_name, t_name);
1009                         }
1010                         else
1011                         {
1012                                 mon_fight = TRUE;
1013                         }
1014                 }
1015
1016                 dam = 20; /* Dummy power */
1017         breath(y, x, m_idx,GF_HAND_DOOM, dam, 0, FALSE, MS_HAND_DOOM, MONSTER_TO_MONSTER);
1018
1019                 break;
1020
1021         /* RF6_HEAL */
1022         case 160+2:
1023                 if (known)
1024                 {
1025                         if (see_m)
1026                         {
1027                                 msg_format(_("%^s¤Ï¼«Ê¬¤Î½ý¤ËÇ°¤ò½¸Ã椷¤¿¡£", "%^s concentrates on %s wounds."), m_name);
1028                         }
1029                         else
1030                         {
1031                                 mon_fight = TRUE;
1032                         }
1033                 }
1034
1035                 /* Heal some */
1036                 m_ptr->hp += (rlev * 6);
1037
1038                 /* Fully healed */
1039                 if (m_ptr->hp >= m_ptr->maxhp)
1040                 {
1041                         /* Fully healed */
1042                         m_ptr->hp = m_ptr->maxhp;
1043
1044                         if (known)
1045                         {
1046                                 if (see_m)
1047                                 {
1048                                         msg_format(_("%^s¤Ï´°Á´¤Ë¼£¤Ã¤¿¡ª", "%^s looks completely healed!"), m_name);
1049                                 }
1050                                 else
1051                                 {
1052                                         mon_fight = TRUE;
1053                                 }
1054                         }
1055                 }
1056
1057                 /* Partially healed */
1058                 else if (known)
1059                 {
1060                         if (see_m)
1061                         {
1062                                 msg_format(_("%^s¤ÏÂÎÎϤò²óÉü¤·¤¿¤è¤¦¤À¡£", "%^s looks healthier."), m_name);
1063                         }
1064                         else
1065                         {
1066                                 mon_fight = TRUE;
1067                         }
1068                 }
1069
1070                 /* Redraw (later) if needed */
1071                 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1072                 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1073
1074                 /* Cancel fear */
1075                 if (MON_MONFEAR(m_ptr))
1076                 {
1077                         /* Cancel fear */
1078                         (void)set_monster_monfear(m_idx, 0);
1079
1080                         /* Message */
1081                         if (see_m) msg_format(_("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", "%^s recovers %s courage."), m_name);
1082                 }
1083
1084                 break;
1085
1086         /* RF6_INVULNER */
1087         case 160+3:
1088                 if (known)
1089                 {
1090                         if (see_m)
1091                         {
1092                                 disturb(1, 1);
1093                                 msg_format(_("%s¤Ï̵½ý¤Îµå¤Î¼öʸ¤ò¾§¤¨¤¿¡£", "%^s casts a Globe of Invulnerability."), m_name);
1094                         }
1095                         else
1096                         {
1097                                 mon_fight = TRUE;
1098                         }
1099                 }
1100
1101                 if (!MON_INVULNER(m_ptr)) (void)set_monster_invulner(m_idx, randint1(4) + 4, FALSE);
1102                 break;
1103
1104         /* RF6_BLINK */
1105         case 160+4:
1106                 if (teleport_barrier(m_idx))
1107                 {
1108                         if (see_m)
1109                         {
1110                                 msg_format(_("ËâË¡¤Î¥Ð¥ê¥¢¤¬%^s¤Î¥Æ¥ì¥Ý¡¼¥È¤ò¼ÙË⤷¤¿¡£", "Magic barrier obstructs teleporting of %^s."), m_name);
1111                         }
1112                 }
1113                 else
1114                 {
1115                         if (see_m)
1116                         {
1117                                 msg_format(_("%^s¤¬½Ö»þ¤Ë¾Ã¤¨¤¿¡£", "%^s blinks away."), m_name);
1118                         }
1119                         teleport_away(m_idx, 10, 0L);
1120                 }
1121                 break;
1122
1123         /* RF6_TPORT */
1124         case 160+5:
1125                 if (teleport_barrier(m_idx))
1126                 {
1127                         if (see_m)
1128                         {
1129                                 msg_format(_("ËâË¡¤Î¥Ð¥ê¥¢¤¬%^s¤Î¥Æ¥ì¥Ý¡¼¥È¤ò¼ÙË⤷¤¿¡£", "Magic barrier obstructs teleporting of %^s."), m_name);
1130                         }
1131                 }
1132                 else
1133                 {
1134                         if (see_m)
1135                         {
1136                                 msg_format(_("%^s¤¬¥Æ¥ì¥Ý¡¼¥È¤·¤¿¡£", "%^s teleports away."), m_name);
1137                         }
1138                         teleport_away_followable(m_idx);
1139                 }
1140                 break;
1141
1142         /* RF6_WORLD */
1143         case 160+6:
1144 #if 0
1145                 int who = 0;
1146                 if(m_ptr->r_idx = MON_DIO) who == 1;
1147                 else if(m_ptr->r_idx = MON_WONG) who == 3;
1148                 dam = who;
1149                 if(!process_the_world(randint1(2)+2, who, player_has_los_bold(m_ptr->fy, m_ptr->fx))) return (FALSE);
1150 #endif
1151                 return FALSE;
1152
1153         /* RF6_SPECIAL */
1154         case 160+7:
1155                 switch (m_ptr->r_idx)
1156                 {
1157                 case MON_OHMU:
1158                         /* Moved to process_monster(), like multiplication */
1159                         return FALSE;
1160
1161                 case MON_ROLENTO:
1162                         if (known)
1163                         {
1164                                 if (see_either)
1165                                 {
1166                                         disturb(1, 1);
1167
1168                                         msg_format(_("%^s¤Ï¼êÜØÃƤò¤Ð¤é¤Þ¤¤¤¿¡£", "%^s throws some hand grenades."), m_name);
1169                                 }
1170                                 else
1171                                 {
1172                                         mon_fight = TRUE;
1173                                 }
1174                         }
1175
1176                         {
1177                                 int num = 1 + randint1(3);
1178                                 for (k = 0; k < num; k++)
1179                                 {
1180                                         count += summon_named_creature(m_idx, y, x, MON_SHURYUUDAN, 0);
1181                                 }
1182                         }
1183
1184                         if (known && !see_t && count)
1185                         {
1186                                 mon_fight = TRUE;
1187                         }
1188                         break;
1189
1190                 default:
1191                         if (r_ptr->d_char == 'B')
1192                         {
1193                                 if (one_in_(3))
1194                                 {
1195                                         if (see_m)
1196                                         {
1197                                                 msg_format(_("%^s¤ÏÆÍÁ³µÞ¾å¾º¤·¤Æ»ë³¦¤«¤é¾Ã¤¨¤¿!", "%^s suddenly go out of your sight!"), m_name);
1198                                         }
1199                                         teleport_away(m_idx, 10, TELEPORT_NONMAGICAL);
1200                                         p_ptr->update |= (PU_MONSTERS);
1201                                 }
1202                                 else
1203                                 {
1204                                         if (known)
1205                                         {
1206                                                 if (see_either)
1207                                                 {
1208                                                         msg_format(_("%^s¤¬%s¤òÄϤó¤Ç¶õÃ椫¤éÅꤲÍî¤È¤·¤¿¡£", "%^s holds %s, and drops from the sky."), m_name, t_name);
1209                                                 }
1210                                                 else
1211                                                 {
1212                                                         mon_fight = TRUE;
1213                                                 }
1214                                         }
1215
1216                                         dam = damroll(4, 8);
1217
1218                                         if (t_idx == p_ptr->riding) teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
1219                                         else teleport_monster_to(t_idx, m_ptr->fy, m_ptr->fx, 100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
1220
1221                                         sound(SOUND_FALL);
1222
1223                                         if (tr_ptr->flags7 & RF7_CAN_FLY)
1224                                         {
1225                                                 if (see_t) msg_format(_("%^s¤ÏÀŤ«¤ËÃåÃϤ·¤¿¡£", "%^s floats gently down to the ground."), t_name);
1226                                         }
1227                                         else
1228                                         {
1229                                                 if (see_t) msg_format(_("%^s¤ÏÃÏÌ̤Ë᤭¤Ä¤±¤é¤ì¤¿¡£", "%^s crashed into the ground."), t_name);
1230
1231                                                 dam += damroll(6, 8);
1232                                         }
1233
1234                                         if (p_ptr->riding == t_idx)
1235                                         {
1236                                                 int get_damage = 0;
1237
1238                                                 /* Mega hack -- this special action deals damage to the player. Therefore the code of "eyeeye" is necessary.
1239                                                    -- henkma
1240                                                  */
1241                                                 get_damage = take_hit(DAMAGE_NOESCAPE, dam, m_name, -1);
1242                                                 if (p_ptr->tim_eyeeye && get_damage > 0 && !p_ptr->is_dead)
1243                                                 {
1244                                                         char m_name_self[80];
1245
1246                                                         /* hisself */
1247                                                         monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
1248
1249                                                         _(msg_format("¹¶·â¤¬%s¼«¿È¤ò½ý¤Ä¤±¤¿¡ª", m_name),
1250                                                           msg_format("The attack of %s has wounded %s!", m_name, m_name_self));
1251
1252                                                         project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
1253                                                         set_tim_eyeeye(p_ptr->tim_eyeeye-5, TRUE);
1254                                                 }
1255                                         }
1256
1257                                         mon_take_hit_mon(t_idx, dam, &fear, extract_note_dies(real_r_ptr(t_ptr)), m_idx);
1258                                 }
1259                                 break;
1260                         }
1261
1262                         /* Something is wrong */
1263                         else return FALSE;
1264                 }
1265
1266                 /* done */
1267                 break;
1268
1269         /* RF6_TELE_TO */
1270         case 160+8:
1271                 if (known)
1272                 {
1273                         if (see_either)
1274                         {
1275                                 msg_format(_("%^s¤¬%s¤ò°ú¤­Ìᤷ¤¿¡£", "%^s commands %s to return."), m_name, t_name);
1276                         }
1277                         else
1278                         {
1279                                 mon_fight = TRUE;
1280                         }
1281                 }
1282
1283                 if (tr_ptr->flagsr & RFR_RES_TELE)
1284                 {
1285                         if ((tr_ptr->flags1 & RF1_UNIQUE) || (tr_ptr->flagsr & RFR_RES_ALL))
1286                         {
1287                                 if (is_original_ap_and_seen(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
1288                                 if (see_t)
1289                                 {
1290                                         msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", "%^s is unaffected!"), t_name);
1291                                 }
1292
1293                                 resists_tele = TRUE;
1294                         }
1295                         else if (tr_ptr->level > randint1(100))
1296                         {
1297                                 if (is_original_ap_and_seen(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
1298                                 if (see_t)
1299                                 {
1300                                         msg_format(_("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", "%^s resists!"), t_name);
1301                                 }
1302
1303                                 resists_tele = TRUE;
1304                         }
1305                 }
1306
1307                 if (!resists_tele)
1308                 {
1309                         if (t_idx == p_ptr->riding) teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1310                         else teleport_monster_to(t_idx, m_ptr->fy, m_ptr->fx, 100, TELEPORT_PASSIVE);
1311                 }
1312
1313                 wake_up = TRUE;
1314                 break;
1315
1316         /* RF6_TELE_AWAY */
1317         case 160+9:
1318                 if (known)
1319                 {
1320                         if (see_either)
1321                         {
1322                                 msg_format(_("%^s¤Ï%s¤ò¥Æ¥ì¥Ý¡¼¥È¤µ¤»¤¿¡£", "%^s teleports %s away."), m_name, t_name);
1323                         }
1324                         else
1325                         {
1326                                 mon_fight = TRUE;
1327                         }
1328                 }
1329
1330                 if (tr_ptr->flagsr & RFR_RES_TELE)
1331                 {
1332                         if ((tr_ptr->flags1 & RF1_UNIQUE) || (tr_ptr->flagsr & RFR_RES_ALL))
1333                         {
1334                                 if (is_original_ap_and_seen(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
1335                                 if (see_t)
1336                                 {
1337                                         msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", "%^s is unaffected!"), t_name);
1338                                 }
1339
1340                                 resists_tele = TRUE;
1341                         }
1342                         else if (tr_ptr->level > randint1(100))
1343                         {
1344                                 if (is_original_ap_and_seen(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
1345                                 if (see_t)
1346                                 {
1347                                         msg_format(_("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", "%^s resists!"), t_name);
1348                                 }
1349
1350                                 resists_tele = TRUE;
1351                         }
1352                 }
1353
1354                 if (!resists_tele)
1355                 {
1356                         if (t_idx == p_ptr->riding) teleport_player_away(m_idx, MAX_SIGHT * 2 + 5);
1357                         else teleport_away(t_idx, MAX_SIGHT * 2 + 5, TELEPORT_PASSIVE);
1358                 }
1359
1360                 wake_up = TRUE;
1361                 break;
1362
1363         /* RF6_TELE_LEVEL */
1364         case 160+10:
1365                 if (known)
1366                 {
1367                         if (see_either)
1368                         {
1369                                 msg_format(_("%^s¤¬%s¤Î­¤ò»Ø¤µ¤·¤¿¡£", "%^s gestures at %s's feet."), m_name, t_name);
1370                         }
1371                         else
1372                         {
1373                                 mon_fight = TRUE;
1374                         }
1375                 }
1376
1377                 if (tr_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE))
1378                 {
1379                         if (see_t) msg_format(_("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", "%^s is unaffected!"), t_name);
1380                 }
1381                 else if ((tr_ptr->flags1 & RF1_QUESTOR) ||
1382                             (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10))
1383                 {
1384                         if (see_t) msg_format(_("%^s¤Ï¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª", "%^s resist the effects!"), t_name);
1385                 }
1386                 else teleport_level((t_idx == p_ptr->riding) ? 0 : t_idx);
1387
1388                 wake_up = TRUE;
1389                 break;
1390
1391         /* RF6_PSY_SPEAR */
1392         case 160+11:
1393                 if (known)
1394                 {
1395                         if (see_either)
1396                         {
1397                                 msg_format(_("%^s¤¬%s¤Ë¸þ¤«¤Ã¤Æ¸÷¤Î·õ¤òÊü¤Ã¤¿¡£", "%^s throw a Psycho-spear at %s."), m_name, t_name);
1398                         }
1399                         else
1400                         {
1401                                 mon_fight = TRUE;
1402                         }
1403                 }
1404
1405                 dam = (r_ptr->flags2 & RF2_POWERFUL) ? (randint1(rlev * 2) + 180) : (randint1(rlev * 3 / 2) + 120);
1406                 beam(m_idx, y, x, GF_PSY_SPEAR, dam, MS_PSY_SPEAR, MONSTER_TO_MONSTER);
1407                 break;
1408
1409         /* RF6_DARKNESS */
1410         case 160+12:
1411                 if (known)
1412                 {
1413                         if (see_m)
1414                         {
1415                                 if (can_use_lite_area)
1416                                 {
1417                                         msg_format(_("%^s¤¬ÊÕ¤ê¤òÌÀ¤ë¤¯¾È¤é¤·¤¿¡£", "%^s cast a spell to light up."), m_name);
1418                                 }
1419                                 else
1420                                 {
1421                                         msg_format(_("%^s¤¬°Å°Ç¤ÎÃæ¤Ç¼ê¤ò¿¶¤Ã¤¿¡£", "%^s gestures in shadow."), m_name);
1422                                 }
1423
1424                                 if (see_t)
1425                                 {
1426                                         if (can_use_lite_area)
1427                                         {
1428                                                 msg_format(_("%^s¤ÏÇò¤¤¸÷¤ËÊñ¤Þ¤ì¤¿¡£", "%^s is surrounded by a white light."), t_name);
1429                                         }
1430                                         else
1431                                         {
1432                                                 msg_format(_("%^s¤Ï°Å°Ç¤ËÊñ¤Þ¤ì¤¿¡£", "%^s is surrounded by darkness."), t_name);
1433                                         }
1434                                 }
1435                         }
1436                         else
1437                         {
1438                                 mon_fight = TRUE;
1439                         }
1440                 }
1441
1442                 if (can_use_lite_area)
1443                 {
1444                         (void)project(m_idx, 3, y, x, 0, GF_LITE_WEAK, PROJECT_GRID | PROJECT_KILL, -1);
1445                         lite_room(y, x);
1446                 }
1447                 else
1448                 {
1449                         (void)project(m_idx, 3, y, x, 0, GF_DARK_WEAK, PROJECT_GRID | PROJECT_KILL, MS_DARKNESS);
1450                         unlite_room(y, x);
1451                 }
1452
1453                 break;
1454
1455         /* RF6_TRAPS */
1456         case 160+13:
1457 #if 0
1458                 if (known)
1459                 {
1460                         if (see_m)
1461                         {
1462                                 msg_format(_("%^s¤¬¼öʸ¤ò¾§¤¨¤Æ¼Ù°­¤ËÈù¾Ð¤ó¤À¡£", "%^s casts a spell and cackles evilly."), m_name);
1463                         }
1464                         else
1465                         {
1466                                 msg_format(_("%^s¤¬²¿¤«¤ò¤Ä¤Ö¤ä¤¤¤¿¡£", "%^s mumbles."), m_name);
1467                         }
1468                 }
1469
1470                 trap_creation(y, x);
1471
1472                 break;
1473 #else
1474                 /* Not implemented */
1475                 return FALSE;
1476 #endif
1477
1478         /* RF6_FORGET */
1479         case 160+14:
1480                 /* Not implemented */
1481                 return FALSE;
1482
1483         /* RF6_RAISE_DEAD */
1484         case 160+15:
1485                 if (known)
1486                 {
1487                         if (see_either)
1488                         {
1489                                 disturb(1, 1);
1490                                 if (blind)
1491                                 {
1492                                         msg_format(_("%^s¤¬²¿¤«¤ò¤Ä¤Ö¤ä¤¤¤¿¡£", "%^s mumbles."), m_name);
1493                                 }
1494                                 else
1495                                 {
1496                                         msg_format(_("%^s¤¬»à¼ÔÉü³è¤Î¼öʸ¤ò¾§¤¨¤¿¡£", "%^s casts a spell to revive corpses."), m_name);
1497                                 }
1498                         }
1499                         else
1500                         {
1501                                 mon_fight = TRUE;
1502                         }
1503                 }
1504                 animate_dead(m_idx, m_ptr->fy, m_ptr->fx);
1505                 break;
1506
1507         /* RF6_S_KIN */
1508         case 160+16:
1509                 if (known)
1510                 {
1511                         if (see_either)
1512                         {
1513                                 disturb(1, 1);
1514
1515                                 if (m_ptr->r_idx == MON_SERPENT || m_ptr->r_idx == MON_ZOMBI_SERPENT)
1516                                 {
1517                                         msg_format(_("%^s¤¬¥À¥ó¥¸¥ç¥ó¤Î¼ç¤ò¾¤´­¤·¤¿¡£", "%^s magically summons guardians of dungeons."), m_name);
1518                                 }
1519                                 else
1520                                 {
1521                                         _(msg_format("%s¤¬ËâË¡¤Ç%s¤ò¾¤´­¤·¤¿¡£", m_name, ((r_ptr->flags1 & RF1_UNIQUE) ? "¼ê²¼" : "Ãç´Ö")),   
1522                                           msg_format("%^s magically summons %s %s.", m_name, m_poss, ((r_ptr->flags1 & RF1_UNIQUE) ? "minions" : "kin")));
1523                                 }
1524
1525                         }
1526                         else
1527                         {
1528                                 mon_fight = TRUE;
1529                         }
1530                 }
1531
1532                 switch (m_ptr->r_idx)
1533                 {
1534                 case MON_MENELDOR:
1535                 case MON_GWAIHIR:
1536                 case MON_THORONDOR:
1537                         {
1538                                 int num = 4 + randint1(3);
1539                                 for (k = 0; k < num; k++)
1540                                 {
1541                                         count += summon_specific(m_idx, y, x, rlev, SUMMON_EAGLES, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1542                                 }
1543                         }
1544                         break;
1545
1546                 case MON_BULLGATES:
1547                         {
1548                                 int num = 2 + randint1(3);
1549                                 for (k = 0; k < num; k++)
1550                                 {
1551                                         count += summon_named_creature(m_idx, y, x, MON_IE, 0);
1552                                 }
1553                         }
1554                         break;
1555
1556                 case MON_SERPENT:
1557                 case MON_ZOMBI_SERPENT:
1558                         if (r_info[MON_JORMUNGAND].cur_num < r_info[MON_JORMUNGAND].max_num && one_in_(6))
1559                         {
1560                                 if (known && see_t)
1561                                 {
1562                                         msg_print(_("ÃÏÌ̤«¤é¿å¤¬¿á¤­½Ð¤·¤¿¡ª", "Water blew off from the ground!"));
1563                                 }
1564                                 project(t_idx, 8, y, x, 3, GF_WATER_FLOW, PROJECT_GRID | PROJECT_HIDE, -1);
1565                         }
1566
1567                         {
1568                                 int num = 2 + randint1(3);
1569                                 for (k = 0; k < num; k++)
1570                                 {
1571                                         count += summon_specific(m_idx, y, x, rlev, SUMMON_GUARDIANS, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
1572                                 }
1573                         }
1574                         break;
1575
1576                 case MON_CALDARM:
1577                         {
1578                                 int num = randint1(3);
1579                                 for (k = 0; k < num; k++)
1580                                 {
1581                                         count += summon_named_creature(m_idx, y, x, MON_LOCKE_CLONE, 0);
1582                                 }
1583                         }
1584                         break;
1585
1586                 case MON_LOUSY:
1587                         {
1588                                 int num = 2 + randint1(3);
1589                                 for (k = 0; k < num; k++)
1590                                 {
1591                                         count += summon_specific(m_idx, y, x, rlev, SUMMON_LOUSE, (PM_ALLOW_GROUP));
1592                                 }
1593                         }
1594                         break;
1595
1596                 default:
1597                         summon_kin_type = r_ptr->d_char;
1598
1599                         for (k = 0; k < 4; k++)
1600                         {
1601                                 count += summon_specific(m_idx, y, x, rlev, SUMMON_KIN, (PM_ALLOW_GROUP));
1602                         }
1603                         break;
1604                 }
1605
1606                 if (known && !see_t && count)
1607                 {
1608                         mon_fight = TRUE;
1609                 }
1610
1611                 break;
1612
1613         /* RF6_S_CYBER */
1614         case 160+17:
1615                 if (known)
1616                 {
1617                         if (see_either)
1618                         {
1619                                 disturb(1, 1);
1620
1621                                 msg_format(_("%^s¤¬¥µ¥¤¥Ð¡¼¥Ç¡¼¥â¥ó¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons Cyberdemons!"), m_name);
1622                         }
1623                         else
1624                         {
1625                                 mon_fight = TRUE;
1626                         }
1627                 }
1628
1629                 if (is_friendly(m_ptr))
1630                 {
1631                         count += summon_specific(m_idx, y, x, rlev, SUMMON_CYBER, (PM_ALLOW_GROUP));
1632                 }
1633                 else
1634                 {
1635                         count += summon_cyber(m_idx, y, x);
1636                 }
1637
1638                 if (known && !see_t && count)
1639                 {
1640                         mon_fight = TRUE;
1641                 }
1642
1643                 break;
1644
1645         /* RF6_S_MONSTER */
1646         case 160+18:
1647                 if (known)
1648                 {
1649                         if (see_either)
1650                         {
1651                                 disturb(1, 1);
1652
1653                                 msg_format(_("%^s¤¬ËâË¡¤ÇÃç´Ö¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons help!"), m_name);
1654                         }
1655                         else
1656                         {
1657                                 mon_fight = TRUE;
1658                         }
1659                 }
1660
1661                 count += summon_specific(m_idx, y, x, rlev, 0, (u_mode));
1662
1663                 if (known && !see_t && count)
1664                 {
1665                         mon_fight = TRUE;
1666                 }
1667
1668                 break;
1669
1670         /* RF6_S_MONSTERS */
1671         case 160+19:
1672                 if (known)
1673                 {
1674                         if (see_either)
1675                         {
1676                                 disturb(1, 1);
1677
1678                                 msg_format(_("%^s¤¬ËâË¡¤Ç¥â¥ó¥¹¥¿¡¼¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons monsters!"), m_name);
1679                         }
1680                         else
1681                         {
1682                                 mon_fight = TRUE;
1683                         }
1684                 }
1685
1686                 for (k = 0; k < s_num_6; k++)
1687                 {
1688                         count += summon_specific(m_idx, y, x, rlev, 0, (PM_ALLOW_GROUP | u_mode));
1689                 }
1690
1691                 if (known && !see_t && count)
1692                 {
1693                         mon_fight = TRUE;
1694                 }
1695
1696                 break;
1697
1698         /* RF6_S_ANT */
1699         case 160+20:
1700                 if (known)
1701                 {
1702                         if (see_either)
1703                         {
1704                                 disturb(1, 1);
1705
1706                                 msg_format(_("%^s¤¬ËâË¡¤Ç¥¢¥ê¤ò¾¤´­¤·¤¿¡£", "%^s magically summons ants."), m_name);
1707                         }
1708                         else
1709                         {
1710                                 mon_fight = TRUE;
1711                         }
1712                 }
1713
1714                 for (k = 0; k < s_num_6; k++)
1715                 {
1716                         count += summon_specific(m_idx, y, x, rlev, SUMMON_ANT, (PM_ALLOW_GROUP));
1717                 }
1718
1719                 if (known && !see_t && count)
1720                 {
1721                         mon_fight = TRUE;
1722                 }
1723
1724                 break;
1725
1726         /* RF6_S_SPIDER */
1727         case 160+21:
1728                 if (known)
1729                 {
1730                         if (see_either)
1731                         {
1732                                 disturb(1, 1);
1733
1734                                 msg_format(_("%^s¤¬ËâË¡¤Ç¥¯¥â¤ò¾¤´­¤·¤¿¡£", "%^s magically summons spiders."), m_name);
1735                         }
1736                         else
1737                         {
1738                                 mon_fight = TRUE;
1739                         }
1740                 }
1741
1742                 for (k = 0; k < s_num_6; k++)
1743                 {
1744                         count += summon_specific(m_idx, y, x, rlev, SUMMON_SPIDER, (PM_ALLOW_GROUP));
1745                 }
1746
1747                 if (known && !see_t && count)
1748                 {
1749                         mon_fight = TRUE;
1750                 }
1751
1752                 break;
1753
1754         /* RF6_S_HOUND */
1755         case 160+22:
1756                 if (known)
1757                 {
1758                         if (see_either)
1759                         {
1760                                 disturb(1, 1);
1761
1762                                 msg_format(_("%^s¤¬ËâË¡¤Ç¥Ï¥¦¥ó¥É¤ò¾¤´­¤·¤¿¡£", "%^s magically summons hounds."), m_name);
1763                         }
1764                         else
1765                         {
1766                                 mon_fight = TRUE;
1767                         }
1768                 }
1769
1770                 for (k = 0; k < s_num_4; k++)
1771                 {
1772                         count += summon_specific(m_idx, y, x, rlev, SUMMON_HOUND, (PM_ALLOW_GROUP));
1773                 }
1774
1775                 if (known && !see_t && count)
1776                 {
1777                         mon_fight = TRUE;
1778                 }
1779
1780                 break;
1781
1782         /* RF6_S_HYDRA */
1783         case 160+23:
1784                 if (known)
1785                 {
1786                         if (see_either)
1787                         {
1788                                 disturb(1, 1);
1789
1790                                 msg_format(_("%^s¤¬ËâË¡¤Ç¥Ò¥É¥é¤ò¾¤´­¤·¤¿¡£", "%^s magically summons hydras."), m_name);
1791                         }
1792                         else
1793                         {
1794                                 mon_fight = TRUE;
1795                         }
1796                 }
1797
1798                 for (k = 0; k < s_num_4; k++)
1799                 {
1800                         count += summon_specific(m_idx, y, x, rlev, SUMMON_HYDRA, (PM_ALLOW_GROUP));
1801                 }
1802
1803                 if (known && !see_t && count)
1804                 {
1805                         mon_fight = TRUE;
1806                 }
1807
1808                 break;
1809
1810         /* RF6_S_ANGEL */
1811         case 160+24:
1812                 if (known)
1813                 {
1814                         if (see_either)
1815                         {
1816                                 disturb(1, 1);
1817
1818                                 msg_format(_("%^s¤¬ËâË¡¤ÇÅ·»È¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons an angel!"), m_name);
1819                         }
1820                         else
1821                         {
1822                                 mon_fight = TRUE;
1823                         }
1824                 }
1825
1826                 {
1827                         int num = 1;
1828
1829                         if ((r_ptr->flags1 & RF1_UNIQUE) && !easy_band)
1830                         {
1831                                 num += r_ptr->level/40;
1832                         }
1833
1834                         for (k = 0; k < num; k++)
1835                         {
1836                                 count += summon_specific(m_idx, y, x, rlev, SUMMON_ANGEL, (PM_ALLOW_GROUP));
1837                         }
1838                 }
1839
1840                 if (known && !see_t && count)
1841                 {
1842                         mon_fight = TRUE;
1843                 }
1844
1845                 break;
1846
1847         /* RF6_S_DEMON */
1848         case 160+25:
1849                 if (known)
1850                 {
1851                         if (see_either)
1852                         {
1853                                 disturb(1, 1);
1854
1855                                 msg_format(_("%^s¤¬ËâË¡¤Çº®Æ٤εÜÄ¤é¥Ç¡¼¥â¥ó¤ò¾¤´­¤·¤¿¡ª", 
1856                                                  "%^s magically summons a demon from the Courts of Chaos!"), m_name);
1857                         }
1858                         else
1859                         {
1860                                 mon_fight = TRUE;
1861                         }
1862                 }
1863
1864                 for (k = 0; k < 1; k++)
1865                 {
1866                         count += summon_specific(m_idx, y, x, rlev, SUMMON_DEMON, (PM_ALLOW_GROUP));
1867                 }
1868
1869                 if (known && !see_t && count)
1870                 {
1871                         mon_fight = TRUE;
1872                 }
1873
1874                 break;
1875
1876         /* RF6_S_UNDEAD */
1877         case 160+26:
1878                 if (known)
1879                 {
1880                         if (see_either)
1881                         {
1882                                 disturb(1, 1);
1883
1884                                 msg_format(_("%s¤¬ËâË¡¤Ç¥¢¥ó¥Ç¥Ã¥É¤ò¾¤´­¤·¤¿¡£", "%^s magically summons undead."), m_name);
1885                         }
1886                         else
1887                         {
1888                                 mon_fight = TRUE;
1889                         }
1890                 }
1891
1892                 for (k = 0; k < 1; k++)
1893                 {
1894                         count += summon_specific(m_idx, y, x, rlev, SUMMON_UNDEAD, (PM_ALLOW_GROUP));
1895                 }
1896
1897                 if (known && !see_t && count)
1898                 {
1899                         mon_fight = TRUE;
1900                 }
1901
1902                 break;
1903
1904         /* RF6_S_DRAGON */
1905         case 160+27:
1906                 if (known)
1907                 {
1908                         if (see_either)
1909                         {
1910                                 disturb(1, 1);
1911
1912                                 msg_format(_("%^s¤¬ËâË¡¤Ç¥É¥é¥´¥ó¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons a dragon!"), m_name);
1913                         }
1914                         else
1915                         {
1916                                 mon_fight = TRUE;
1917                         }
1918                 }
1919
1920                 for (k = 0; k < 1; k++)
1921                 {
1922                         count += summon_specific(m_idx, y, x, rlev, SUMMON_DRAGON, (PM_ALLOW_GROUP));
1923                 }
1924
1925                 if (known && !see_t && count)
1926                 {
1927                         mon_fight = TRUE;
1928                 }
1929
1930                 break;
1931
1932         /* RF6_S_HI_UNDEAD */
1933         case 160+28:
1934                 if (known)
1935                 {
1936                         if (see_either)
1937                         {
1938                                 disturb(1, 1);
1939
1940                                 msg_format(_("%s¤¬ËâË¡¤Ç¥¢¥ó¥Ç¥Ã¥É¤ò¾¤´­¤·¤¿¡£", "%^s magically summons undead."), m_name);
1941                         }
1942                         else
1943                         {
1944                                 mon_fight = TRUE;
1945                         }
1946                 }
1947
1948                 for (k = 0; k < s_num_6; k++)
1949                 {
1950                         count += summon_specific(m_idx, y, x, rlev, SUMMON_HI_UNDEAD, (PM_ALLOW_GROUP | u_mode));
1951                 }
1952
1953                 if (known && !see_t && count)
1954                 {
1955                         mon_fight = TRUE;
1956                 }
1957
1958                 break;
1959
1960         /* RF6_S_HI_DRAGON */
1961         case 160+29:
1962                 if (known)
1963                 {
1964                         if (see_either)
1965                         {
1966                                 disturb(1, 1);
1967
1968                                 msg_format(_("%^s¤¬ËâË¡¤Ç¸ÅÂå¥É¥é¥´¥ó¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons ancient dragons!"), m_name);
1969                         }
1970                         else
1971                         {
1972                                 mon_fight = TRUE;
1973                         }
1974                 }
1975
1976                 for (k = 0; k < s_num_4; k++)
1977                 {
1978                         count += summon_specific(m_idx, y, x, rlev, SUMMON_HI_DRAGON, (PM_ALLOW_GROUP | u_mode));
1979                 }
1980
1981                 if (known && !see_t && count)
1982                 {
1983                         mon_fight = TRUE;
1984                 }
1985
1986                 break;
1987
1988         /* RF6_S_AMBERITES */
1989         case 160+30:
1990                 if (known)
1991                 {
1992                         if (see_either)
1993                         {
1994                                 disturb(1, 1);
1995
1996                                 msg_format(_("%^s¤¬¥¢¥ó¥Ð¡¼¤Î²¦Â²¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons Lords of Amber!"), m_name);
1997                         }
1998                         else
1999                         {
2000                                 mon_fight = TRUE;
2001                         }
2002                 }
2003
2004                 for (k = 0; k < s_num_4; k++)
2005                 {
2006                         count += summon_specific(m_idx, y, x, rlev, SUMMON_AMBERITES, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
2007                 }
2008
2009                 if (known && !see_t && count)
2010                 {
2011                         mon_fight = TRUE;
2012                 }
2013
2014                 break;
2015
2016         /* RF6_S_UNIQUE */
2017         case 160+31:
2018                 if (known)
2019                 {
2020                         if (see_either)
2021                         {
2022                                 disturb(1, 1);
2023
2024                                 msg_format(_("%^s¤¬ËâË¡¤ÇÆÃÊ̤ʶ¯Å¨¤ò¾¤´­¤·¤¿¡ª", "%^s magically summons special opponents!"), m_name);
2025                         }
2026                         else
2027                         {
2028                                 mon_fight = TRUE;
2029                         }
2030                 }
2031
2032                 for (k = 0; k < s_num_4; k++)
2033                 {
2034                         count += summon_specific(m_idx, y, x, rlev, SUMMON_UNIQUE, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
2035                 }
2036
2037                 {
2038                         int non_unique_type = SUMMON_HI_UNDEAD;
2039
2040                         if ((m_ptr->sub_align & (SUB_ALIGN_GOOD | SUB_ALIGN_EVIL)) == (SUB_ALIGN_GOOD | SUB_ALIGN_EVIL))
2041                                 non_unique_type = 0;
2042                         else if (m_ptr->sub_align & SUB_ALIGN_GOOD)
2043                                 non_unique_type = SUMMON_ANGEL;
2044
2045                         for (k = count; k < s_num_4; k++)
2046                         {
2047                                 count += summon_specific(m_idx, y, x, rlev, non_unique_type, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
2048                         }
2049                 }
2050
2051                 if (known && !see_t && count)
2052                 {
2053                         mon_fight = TRUE;
2054                 }
2055
2056                 break;
2057         }
2058
2059         if (wake_up) (void)set_monster_csleep(t_idx, 0);
2060
2061         if (fear && see_t)
2062         {
2063                 msg_format(_("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", "%^s flees in terror!"), t_name);
2064         }
2065
2066         if (m_ptr->ml && maneable && !world_monster && !p_ptr->blind && (p_ptr->pclass == CLASS_IMITATOR))
2067         {
2068                 if (thrown_spell != 167) /* Not RF6_SPECIAL */
2069                 {
2070                         if (p_ptr->mane_num == MAX_MANE)
2071                         {
2072                                 p_ptr->mane_num--;
2073                                 for (i = 0; i < p_ptr->mane_num - 1; i++)
2074                                 {
2075                                         p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
2076                                         p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
2077                                 }
2078                         }
2079                         p_ptr->mane_spell[p_ptr->mane_num] = thrown_spell - 96;
2080                         p_ptr->mane_dam[p_ptr->mane_num] = dam;
2081                         p_ptr->mane_num++;
2082                         new_mane = TRUE;
2083
2084                         p_ptr->redraw |= (PR_IMITATION);
2085                 }
2086         }
2087
2088         /* Remember what the monster did, if we saw it */
2089         if (can_remember)
2090         {
2091                 /* Inate spell */
2092                 if (thrown_spell < 32*4)
2093                 {
2094                         r_ptr->r_flags4 |= (1L << (thrown_spell - 32*3));
2095                         if (r_ptr->r_cast_spell < MAX_UCHAR) r_ptr->r_cast_spell++;
2096                 }
2097
2098                 /* Bolt or Ball */
2099                 else if (thrown_spell < 32*5)
2100                 {
2101                         r_ptr->r_flags5 |= (1L << (thrown_spell - 32*4));
2102                         if (r_ptr->r_cast_spell < MAX_UCHAR) r_ptr->r_cast_spell++;
2103                 }
2104
2105                 /* Special spell */
2106                 else if (thrown_spell < 32*6)
2107                 {
2108                         r_ptr->r_flags6 |= (1L << (thrown_spell - 32*5));
2109                         if (r_ptr->r_cast_spell < MAX_UCHAR) r_ptr->r_cast_spell++;
2110                 }
2111         }
2112
2113         /* Always take note of monsters that kill you */
2114         if (p_ptr->is_dead && (r_ptr->r_deaths < MAX_SHORT) && !p_ptr->inside_arena)
2115         {
2116                 r_ptr->r_deaths++; /* Ignore appearance difference */
2117         }
2118
2119         /* A spell was cast */
2120         return TRUE;
2121 }