OSDN Git Service

[Refactor] #37353 ART_* を artifact.h へ分離。 / Separate ART_* to artifact.h.
[hengband/hengband.git] / src / spells1.c
1 /*!
2  * @file spells1.c
3  * @brief 魔法による遠隔処理の実装 / Spell projection
4  * @date 2014/07/10
5  * @author
6  * <pre>
7  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  * </pre>
12  */
13
14 #include "angband.h"
15 #include "cmd-pet.h"
16 #include "trap.h"
17 #include "object-curse.h"
18 #include "player-damage.h"
19
20 #include "monster.h"
21 #include "monster-status.h"
22 #include "spells-summon.h"
23 #include "monsterrace-hook.h"
24
25 #include "melee.h"
26 #include "world.h"
27 #include "projection.h"
28 #include "mutation.h"
29 #include "rooms.h"
30 #include "artifact.h"
31
32
33 static int rakubadam_m; /*!< 振り落とされた際のダメージ量 */
34 static int rakubadam_p; /*!< 落馬した際のダメージ量 */
35
36 int project_length = 0; /*!< 投射の射程距離 */
37
38
39 /*!
40  * @brief モンスター魅了用セービングスロー共通部(汎用系)
41  * @param pow 魅了パワー
42  * @param m_ptr 対象モンスター
43  * @return 魅了に抵抗したらTRUE
44  */
45 static bool_hack common_saving_throw_charm(player_type *player_ptr, HIT_POINT pow, monster_type *m_ptr)
46 {
47         monster_race *r_ptr = &r_info[m_ptr->r_idx];
48
49         if(p_ptr->inside_arena) return TRUE;
50
51         /* Memorize a flag */
52         if (r_ptr->flagsr & RFR_RES_ALL)
53         {
54                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
55                 return TRUE;
56         }
57
58         if (r_ptr->flags3 & RF3_NO_CONF)
59         {
60                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
61                 return TRUE;
62         }
63
64         if (r_ptr->flags1 & RF1_QUESTOR || m_ptr->mflag2 & MFLAG2_NOPET) return TRUE;
65
66         pow += (adj_chr_chm[player_ptr->stat_ind[A_CHR]] - 1);
67         if((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) pow = pow * 2 / 3;
68         return (r_ptr->level > randint1((pow - 10) < 1 ? 1 : (pow - 10)) + 5);
69 }
70
71 /*!
72  * @brief モンスター服従用セービングスロー共通部(部族依存系)
73  * @param pow 服従パワー
74  * @param m_ptr 対象モンスター
75  * @return 服従に抵抗したらTRUE
76  */
77 static bool_hack common_saving_throw_control(player_type *player_ptr, HIT_POINT pow, monster_type *m_ptr)
78 {
79         monster_race *r_ptr = &r_info[m_ptr->r_idx];
80
81         if (p_ptr->inside_arena) return TRUE;
82
83         /* Memorize a flag */
84         if (r_ptr->flagsr & RFR_RES_ALL)
85         {
86                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
87                 return TRUE;
88         }
89
90         if (r_ptr->flags1 & RF1_QUESTOR || m_ptr->mflag2 & MFLAG2_NOPET) return TRUE;
91
92         pow += adj_chr_chm[player_ptr->stat_ind[A_CHR]] - 1;
93         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) pow = pow * 2 / 3;
94         return (r_ptr->level > randint1((pow - 10) < 1 ? 1 : (pow - 10)) + 5);
95 }
96
97 /*!
98 * @brief 一部ボルト魔法のビーム化確率を算出する / Prepare standard probability to become beam for fire_bolt_or_beam()
99 * @return ビーム化確率(%)
100 * @details
101 * ハードコーティングによる実装が行われている。
102 * メイジは(レベル)%、ハイメイジ、スペルマスターは(レベル)%、それ以外の職業は(レベル/2)%
103 */
104 PERCENTAGE beam_chance(void)
105 {
106         if (p_ptr->pclass == CLASS_MAGE)
107                 return (PERCENTAGE)(p_ptr->lev);
108         if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER)
109                 return (PERCENTAGE)(p_ptr->lev + 10);
110
111         return (PERCENTAGE)(p_ptr->lev / 2);
112 }
113
114
115 /*!
116  * @brief 配置した鏡リストの次を取得する /
117  * Get another mirror. for SEEKER 
118  * @param next_y 次の鏡のy座標を返す参照ポインタ
119  * @param next_x 次の鏡のx座標を返す参照ポインタ
120  * @param cury 現在の鏡のy座標
121  * @param curx 現在の鏡のx座標
122  */
123 static void next_mirror(POSITION* next_y, POSITION* next_x, POSITION cury, POSITION curx)
124 {
125         POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
126         int mirror_num = 0;                       /* 鏡の数 */
127         POSITION x, y;
128         int num;
129
130         for (x = 0; x < cur_wid; x++)
131         {
132                 for (y = 0; y < cur_hgt; y++)
133                 {
134                         if (is_mirror_grid(&cave[y][x])) {
135                                 mirror_y[mirror_num] = y;
136                                 mirror_x[mirror_num] = x;
137                                 mirror_num++;
138                         }
139                 }
140         }
141         if (mirror_num)
142         {
143                 num = randint0(mirror_num);
144                 *next_y = mirror_y[num];
145                 *next_x = mirror_x[num];
146                 return;
147         }
148         *next_y = cury + randint0(5) - 2;
149         *next_x = curx + randint0(5) - 2;
150         return;
151 }
152                 
153 /*!
154  * @brief 万色表現用にランダムな色を選択する関数 /
155  * Get a legal "multi-hued" color for drawing "spells"
156  * @param max 色IDの最大値
157  * @return 選択した色ID
158  */
159 static TERM_COLOR mh_attr(int max)
160 {
161         switch (randint1(max))
162         {
163                 case  1: return (TERM_RED);
164                 case  2: return (TERM_GREEN);
165                 case  3: return (TERM_BLUE);
166                 case  4: return (TERM_YELLOW);
167                 case  5: return (TERM_ORANGE);
168                 case  6: return (TERM_VIOLET);
169                 case  7: return (TERM_L_RED);
170                 case  8: return (TERM_L_GREEN);
171                 case  9: return (TERM_L_BLUE);
172                 case 10: return (TERM_UMBER);
173                 case 11: return (TERM_L_UMBER);
174                 case 12: return (TERM_SLATE);
175                 case 13: return (TERM_WHITE);
176                 case 14: return (TERM_L_WHITE);
177                 case 15: return (TERM_L_DARK);
178         }
179
180         return (TERM_WHITE);
181 }
182
183
184 /*!
185  * @brief 魔法属性に応じたエフェクトの色を返す /
186  * Return a color to use for the bolt/ball spells
187  * @param type 魔法属性
188  * @return 対応する色ID
189  */
190 static TERM_COLOR spell_color(int type)
191 {
192         /* Check if A.B.'s new graphics should be used (rr9) */
193         if (streq(ANGBAND_GRAF, "new") || streq(ANGBAND_GRAF, "ne2"))
194         {
195                 /* Analyze */
196                 switch (type)
197                 {
198                         case GF_PSY_SPEAR:              return (0x06);
199                         case GF_MISSILE:                return (0x0F);
200                         case GF_ACID:                   return (0x04);
201                         case GF_ELEC:                   return (0x02);
202                         case GF_FIRE:                   return (0x00);
203                         case GF_COLD:                   return (0x01);
204                         case GF_POIS:                   return (0x03);
205                         case GF_HOLY_FIRE:              return (0x00);
206                         case GF_HELL_FIRE:              return (0x00);
207                         case GF_MANA:                   return (0x0E);
208                           /* by henkma */
209                         case GF_SEEKER:                 return (0x0E);
210                         case GF_SUPER_RAY:              return (0x0E);
211
212                         case GF_ARROW:                  return (0x0F);
213                         case GF_WATER:                  return (0x04);
214                         case GF_NETHER:                 return (0x07);
215                         case GF_CHAOS:                  return (mh_attr(15));
216                         case GF_DISENCHANT:             return (0x05);
217                         case GF_NEXUS:                  return (0x0C);
218                         case GF_CONFUSION:              return (mh_attr(4));
219                         case GF_SOUND:                  return (0x09);
220                         case GF_SHARDS:                 return (0x08);
221                         case GF_FORCE:                  return (0x09);
222                         case GF_INERTIAL:               return (0x09);
223                         case GF_GRAVITY:                return (0x09);
224                         case GF_TIME:                   return (0x09);
225                         case GF_LITE_WEAK:              return (0x06);
226                         case GF_LITE:                   return (0x06);
227                         case GF_DARK_WEAK:              return (0x07);
228                         case GF_DARK:                   return (0x07);
229                         case GF_PLASMA:                 return (0x0B);
230                         case GF_METEOR:                 return (0x00);
231                         case GF_ICE:                    return (0x01);
232                         case GF_ROCKET:                 return (0x0F);
233                         case GF_DEATH_RAY:              return (0x07);
234                         case GF_NUKE:                   return (mh_attr(2));
235                         case GF_DISINTEGRATE:   return (0x05);
236                         case GF_PSI:
237                         case GF_PSI_DRAIN:
238                         case GF_TELEKINESIS:
239                         case GF_DOMINATION:
240                         case GF_DRAIN_MANA:
241                         case GF_MIND_BLAST:
242                         case GF_BRAIN_SMASH:
243                                 return (0x09);
244                         case GF_CAUSE_1:
245                         case GF_CAUSE_2:
246                         case GF_CAUSE_3:
247                         case GF_CAUSE_4:                return (0x0E);
248                         case GF_HAND_DOOM:              return (0x07);
249                         case GF_CAPTURE  :              return (0x0E);
250                         case GF_IDENTIFY:               return (0x01);
251                         case GF_ATTACK:                 return (0x0F);
252                         case GF_PHOTO   :               return (0x06);
253                 }
254         }
255         /* Normal tiles or ASCII */
256         else
257         {
258                 TERM_COLOR a;
259                 SYMBOL_CODE c;
260
261                 /* Lookup the default colors for this type */
262                 concptr s = quark_str(gf_color[type]);
263
264                 if (!s) return (TERM_WHITE);
265
266                 /* Pick a random color */
267                 c = s[randint0(strlen(s))];
268
269                 /* Lookup this color */
270                 a = my_strchr(color_char, c) - color_char;
271
272                 /* Invalid color (note check for < 0 removed, gave a silly
273                  * warning because bytes are always >= 0 -- RG) */
274                 if (a > 15) return (TERM_WHITE);
275
276                 /* Use this color */
277                 return (a);
278         }
279
280         /* Standard "color" */
281         return (TERM_WHITE);
282 }
283
284
285 /*!
286  * @brief 始点から終点にかけた方向毎にボルトのキャラクタを返す /
287  * Find the attr/char pair to use for a spell effect
288  * @param y 始点Y座標
289  * @param x 始点X座標
290  * @param ny 終点Y座標
291  * @param nx 終点X座標
292  * @param typ 魔法の効果属性
293  * @return 方向キャラID
294  * @details
295  * <pre>
296  * It is moving (or has moved) from (x,y) to (nx,ny).
297  * If the distance is not "one", we (may) return "*".
298  * </pre>
299  */
300 u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ)
301 {
302         int base;
303
304         byte k;
305
306         TERM_COLOR a;
307         SYMBOL_CODE c;
308
309         /* No motion (*) */
310         if ((ny == y) && (nx == x)) base = 0x30;
311
312         /* Vertical (|) */
313         else if (nx == x) base = 0x40;
314
315         /* Horizontal (-) */
316         else if (ny == y) base = 0x50;
317
318         /* Diagonal (/) */
319         else if ((ny - y) == (x - nx)) base = 0x60;
320
321         /* Diagonal (\) */
322         else if ((ny - y) == (nx - x)) base = 0x70;
323
324         /* Weird (*) */
325         else base = 0x30;
326
327         /* Basic spell color */
328         k = spell_color(typ);
329
330         /* Obtain attr/char */
331         a = misc_to_attr[base + k];
332         c = misc_to_char[base + k];
333
334         /* Create pict */
335         return (PICT(a, c));
336 }
337
338
339
340 /*
341  * Mega-Hack -- track "affected" monsters (see "project()" comments)
342  */
343 static int project_m_n; /*!< 魔法効果範囲内にいるモンスターの数 */
344 static POSITION project_m_x; /*!< 処理中のモンスターX座標 */
345 static POSITION project_m_y; /*!< 処理中のモンスターY座標 */
346 /* Mega-Hack -- monsters target */
347 static POSITION monster_target_x; /*!< モンスターの攻撃目標X座標 */
348 static POSITION monster_target_y; /*!< モンスターの攻撃目標Y座標 */
349
350
351 /*!
352  * @brief 汎用的なビーム/ボルト/ボール系による地形効果処理 / We are called from "project()" to "damage" terrain features
353  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
354  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
355  * @param y 目標Y座標 / Target y location (or location to travel "towards")
356  * @param x 目標X座標 / Target x location (or location to travel "towards")
357  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
358  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
359  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
360  * @details
361  * <pre>
362  * We are called both for "beam" effects and "ball" effects.
363  *
364  * The "r" parameter is the "distance from ground zero".
365  *
366  * Note that we determine if the player can "see" anything that happens
367  * by taking into account: blindness, line-of-sight, and illumination.
368  *
369  * We return "TRUE" if the effect of the projection is "obvious".
370  *
371  * We also "see" grids which are "memorized", probably a hack
372  *
373  * Perhaps we should affect doors?
374  * </pre>
375  */
376 static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
377 {
378         cave_type *c_ptr = &cave[y][x];
379         feature_type *f_ptr = &f_info[c_ptr->feat];
380
381         bool obvious = FALSE;
382         bool known = player_has_los_bold(y, x);
383
384
385         who = who ? who : 0;
386
387         /* Reduce damage by distance */
388         dam = (dam + r) / (r + 1);
389
390
391         if (have_flag(f_ptr->flags, FF_TREE))
392         {
393                 concptr message;
394                 switch (typ)
395                 {
396                 case GF_POIS:
397                 case GF_NUKE:
398                 case GF_DEATH_RAY:
399                         message = _("枯れた", "was blasted."); break;
400                 case GF_TIME:
401                         message = _("縮んだ", "shrank."); break;
402                 case GF_ACID:
403                         message = _("溶けた", "melted."); break;
404                 case GF_COLD:
405                 case GF_ICE:
406                         message = _("凍り、砕け散った", "was frozen and smashed."); break;
407                 case GF_FIRE:
408                 case GF_ELEC:
409                 case GF_PLASMA:
410                         message = _("燃えた", "burns up!"); break;
411                 case GF_METEOR:
412                 case GF_CHAOS:
413                 case GF_MANA:
414                 case GF_SEEKER:
415                 case GF_SUPER_RAY:
416                 case GF_SHARDS:
417                 case GF_ROCKET:
418                 case GF_SOUND:
419                 case GF_DISENCHANT:
420                 case GF_FORCE:
421                 case GF_GRAVITY:
422                         message = _("粉砕された", "was crushed."); break;
423                 default:
424                         message = NULL; break;
425                 }
426                 if (message)
427                 {
428                         msg_format(_("木は%s。", "A tree %s"), message);
429                         cave_set_feat(y, x, one_in_(3) ? feat_brake : feat_grass);
430
431                         /* Observe */
432                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
433                 }
434         }
435
436         /* Analyze the type */
437         switch (typ)
438         {
439                 /* Ignore most effects */
440                 case GF_CAPTURE:
441                 case GF_HAND_DOOM:
442                 case GF_CAUSE_1:
443                 case GF_CAUSE_2:
444                 case GF_CAUSE_3:
445                 case GF_CAUSE_4:
446                 case GF_MIND_BLAST:
447                 case GF_BRAIN_SMASH:
448                 case GF_DRAIN_MANA:
449                 case GF_PSY_SPEAR:
450                 case GF_FORCE:
451                 case GF_HOLY_FIRE:
452                 case GF_HELL_FIRE:
453                 case GF_PSI:
454                 case GF_PSI_DRAIN:
455                 case GF_TELEKINESIS:
456                 case GF_DOMINATION:
457                 case GF_IDENTIFY:
458                 case GF_ATTACK:
459                 case GF_ACID:
460                 case GF_ELEC:
461                 case GF_COLD:
462                 case GF_ICE:
463                 case GF_FIRE:
464                 case GF_PLASMA:
465                 case GF_METEOR:
466                 case GF_CHAOS:
467                 case GF_MANA:
468                 case GF_SEEKER:
469                 case GF_SUPER_RAY:
470                 {
471                         break;
472                 }
473
474                 /* Destroy Traps (and Locks) */
475                 case GF_KILL_TRAP:
476                 {
477                         /* Reveal secret doors */
478                         if (is_hidden_door(c_ptr))
479                         {
480                                 /* Pick a door */
481                                 disclose_grid(y, x);
482
483                                 /* Check line of sight */
484                                 if (known)
485                                 {
486                                         obvious = TRUE;
487                                 }
488                         }
489
490                         /* Destroy traps */
491                         if (is_trap(c_ptr->feat))
492                         {
493                                 /* Check line of sight */
494                                 if (known)
495                                 {
496                                         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
497                                         obvious = TRUE;
498                                 }
499
500                                 /* Destroy the trap */
501                                 cave_alter_feat(y, x, FF_DISARM);
502                         }
503
504                         /* Locked doors are unlocked */
505                         if (is_closed_door(c_ptr->feat) && f_ptr->power && have_flag(f_ptr->flags, FF_OPEN))
506                         {
507                                 s16b old_feat = c_ptr->feat;
508
509                                 /* Unlock the door */
510                                 cave_alter_feat(y, x, FF_DISARM);
511
512                                 /* Check line of sound */
513                                 if (known && (old_feat != c_ptr->feat))
514                                 {
515                                         msg_print(_("カチッと音がした!", "Click!"));
516                                         obvious = TRUE;
517                                 }
518                         }
519
520                         /* Remove "unsafe" flag if player is not blind */
521                         if (!p_ptr->blind && player_has_los_bold(y, x))
522                         {
523                                 c_ptr->info &= ~(CAVE_UNSAFE);
524                                 lite_spot(y, x);
525                                 obvious = TRUE;
526                         }
527
528                         break;
529                 }
530
531                 /* Destroy Doors (and traps) */
532                 case GF_KILL_DOOR:
533                 {
534                         /* Destroy all doors and traps */
535                         if (is_trap(c_ptr->feat) || have_flag(f_ptr->flags, FF_DOOR))
536                         {
537                                 /* Check line of sight */
538                                 if (known)
539                                 {
540                                         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
541                                         obvious = TRUE;
542                                 }
543
544                                 /* Destroy the feature */
545                                 cave_alter_feat(y, x, FF_TUNNEL);
546                         }
547
548                         /* Remove "unsafe" flag if player is not blind */
549                         if (!p_ptr->blind && player_has_los_bold(y, x))
550                         {
551                                 c_ptr->info &= ~(CAVE_UNSAFE);
552                                 lite_spot(y, x);
553                                 obvious = TRUE;
554                         }
555
556                         break;
557                 }
558
559                 case GF_JAM_DOOR: /* Jams a door (as if with a spike) */
560                 {
561                         if (have_flag(f_ptr->flags, FF_SPIKE))
562                         {
563                                 s16b old_mimic = c_ptr->mimic;
564                                 feature_type *mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
565
566                                 cave_alter_feat(y, x, FF_SPIKE);
567                                 c_ptr->mimic = old_mimic;
568
569                                 note_spot(y, x);
570                                 lite_spot(y, x);
571
572                                 /* Check line of sight */
573                                 if (known && have_flag(mimic_f_ptr->flags, FF_OPEN))
574                                 {
575                                         msg_format(_("%sに何かがつっかえて開かなくなった。", "The %s seems stuck."), f_name + mimic_f_ptr->name);
576                                         obvious = TRUE;
577                                 }
578                         }
579                         break;
580                 }
581
582                 /* Destroy walls (and doors) */
583                 case GF_KILL_WALL:
584                 {
585                         if (have_flag(f_ptr->flags, FF_HURT_ROCK))
586                         {
587                                 if (known && (c_ptr->info & (CAVE_MARK)))
588                                 {
589                                         msg_format(_("%sが溶けて泥になった!", "The %s turns into mud!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
590                                         obvious = TRUE;
591                                 }
592
593                                 /* Destroy the wall */
594                                 cave_alter_feat(y, x, FF_HURT_ROCK);
595
596                                 /* Update some things */
597                                 p_ptr->update |= (PU_FLOW);
598                         }
599
600                         break;
601                 }
602
603                 /* Make doors */
604                 case GF_MAKE_DOOR:
605                 {
606                         /* Require a "naked" floor grid */
607                         if (!cave_naked_bold(y, x)) break;
608
609                         /* Not on the player */
610                         if (player_bold(y, x)) break;
611
612                         /* Create a closed door */
613                         cave_set_feat(y, x, feat_door[DOOR_DOOR].closed);
614
615                         /* Observe */
616                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
617
618                         break;
619                 }
620
621                 /* Make traps */
622                 case GF_MAKE_TRAP:
623                 {
624                         /* Place a trap */
625                         place_trap(y, x);
626
627                         break;
628                 }
629
630                 /* Make doors */
631                 case GF_MAKE_TREE:
632                 {
633                         /* Require a "naked" floor grid */
634                         if (!cave_naked_bold(y, x)) break;
635
636                         /* Not on the player */
637                         if (player_bold(y, x)) break;
638
639                         /* Create a closed door */
640                         cave_set_feat(y, x, feat_tree);
641
642                         /* Observe */
643                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
644
645
646                         break;
647                 }
648
649                 case GF_MAKE_GLYPH:
650                 {
651                         /* Require a "naked" floor grid */
652                         if (!cave_naked_bold(y, x)) break;
653
654                         /* Create a glyph */
655                         c_ptr->info |= CAVE_OBJECT;
656                         c_ptr->mimic = feat_glyph;
657
658                         note_spot(y, x);
659
660                         lite_spot(y, x);
661
662                         break;
663                 }
664
665                 case GF_STONE_WALL:
666                 {
667                         /* Require a "naked" floor grid */
668                         if (!cave_naked_bold(y, x)) break;
669
670                         /* Not on the player */
671                         if (player_bold(y, x)) break;
672
673                         /* Place a wall */
674                         cave_set_feat(y, x, feat_granite);
675
676                         break;
677                 }
678
679
680                 case GF_LAVA_FLOW:
681                 {
682                         /* Ignore permanent grid */
683                         if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
684
685                         /* Shallow Lava */
686                         if (dam == 1)
687                         {
688                                 /* Ignore grid without enough space */
689                                 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
690
691                                 /* Place a shallow lava */
692                                 cave_set_feat(y, x, feat_shallow_lava);
693                         }
694                         /* Deep Lava */
695                         else if (dam)
696                         {
697                                 /* Place a deep lava */
698                                 cave_set_feat(y, x, feat_deep_lava);
699                         }
700                         break;
701                 }
702
703                 case GF_WATER_FLOW:
704                 {
705                         /* Ignore permanent grid */
706                         if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
707
708                         /* Shallow Water */
709                         if (dam == 1)
710                         {
711                                 /* Ignore grid without enough space */
712                                 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
713
714                                 /* Place a shallow water */
715                                 cave_set_feat(y, x, feat_shallow_water);
716                         }
717                         /* Deep Water */
718                         else if (dam)
719                         {
720                                 /* Place a deep water */
721                                 cave_set_feat(y, x, feat_deep_water);
722                         }
723                         break;
724                 }
725
726                 /* Lite up the grid */
727                 case GF_LITE_WEAK:
728                 case GF_LITE:
729                 {
730                         /* Turn on the light */
731                         if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
732                         {
733                                 c_ptr->info |= (CAVE_GLOW);
734                                 note_spot(y, x);
735                                 lite_spot(y, x);
736                                 update_local_illumination(y, x);
737
738                                 /* Observe */
739                                 if (player_can_see_bold(y, x)) obvious = TRUE;
740
741                                 /* Mega-Hack -- Update the monster in the affected grid */
742                                 /* This allows "spear of light" (etc) to work "correctly" */
743                                 if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
744
745                                 if (p_ptr->special_defense & NINJA_S_STEALTH)
746                                 {
747                                         if (player_bold(y, x)) set_superstealth(FALSE);
748                                 }
749                         }
750
751                         break;
752                 }
753
754                 /* Darken the grid */
755                 case GF_DARK_WEAK:
756                 case GF_DARK:
757                 {
758                         bool do_dark = !p_ptr->inside_battle && !is_mirror_grid(c_ptr);
759                         int j;
760
761                         /* Turn off the light. */
762                         if (do_dark)
763                         {
764                                 if (dun_level || !is_daytime())
765                                 {
766                                         for (j = 0; j < 9; j++)
767                                         {
768                                                 int by = y + ddy_ddd[j];
769                                                 int bx = x + ddx_ddd[j];
770
771                                                 if (in_bounds2(by, bx))
772                                                 {
773                                                         cave_type *cc_ptr = &cave[by][bx];
774
775                                                         if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
776                                                         {
777                                                                 do_dark = FALSE;
778                                                                 break;
779                                                         }
780                                                 }
781                                         }
782
783                                         if (!do_dark) break;
784                                 }
785
786                                 c_ptr->info &= ~(CAVE_GLOW);
787
788                                 /* Hack -- Forget "boring" grids */
789                                 if (!have_flag(f_ptr->flags, FF_REMEMBER))
790                                 {
791                                         /* Forget */
792                                         c_ptr->info &= ~(CAVE_MARK);
793
794                                         note_spot(y, x);
795                                 }
796
797                                 lite_spot(y, x);
798
799                                 update_local_illumination(y, x);
800
801                                 if (player_can_see_bold(y, x)) obvious = TRUE;
802
803                                 /* Mega-Hack -- Update the monster in the affected grid */
804                                 /* This allows "spear of light" (etc) to work "correctly" */
805                                 if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
806                         }
807
808                         /* All done */
809                         break;
810                 }
811
812                 case GF_SHARDS:
813                 case GF_ROCKET:
814                 {
815                         if (is_mirror_grid(c_ptr))
816                         {
817                                 msg_print(_("鏡が割れた!", "The mirror was crashed!"));
818                                 sound(SOUND_GLASS);
819                                 remove_mirror(y, x);
820                                 project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
821                         }
822
823                         if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 50))
824                         {
825                                 if (known && (c_ptr->info & CAVE_MARK))
826                                 {
827                                         msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
828                                         sound(SOUND_GLASS);
829                                 }
830
831                                 /* Destroy the wall */
832                                 cave_alter_feat(y, x, FF_HURT_ROCK);
833
834                                 /* Update some things */
835                                 p_ptr->update |= (PU_FLOW);
836                         }
837                         break;
838                 }
839
840                 case GF_SOUND:
841                 {
842                         if (is_mirror_grid(c_ptr) && p_ptr->lev < 40)
843                         {
844                                 msg_print(_("鏡が割れた!", "The mirror was crashed!"));
845                                 sound(SOUND_GLASS);
846                                 remove_mirror(y, x);
847                                 project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
848                         }
849
850                         if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 200))
851                         {
852                                 if (known && (c_ptr->info & CAVE_MARK))
853                                 {
854                                         msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
855                                         sound(SOUND_GLASS);
856                                 }
857
858                                 /* Destroy the wall */
859                                 cave_alter_feat(y, x, FF_HURT_ROCK);
860
861                                 /* Update some things */
862                                 p_ptr->update |= (PU_FLOW);
863                         }
864                         break;
865                 }
866
867                 case GF_DISINTEGRATE:
868                 {
869                         /* Destroy mirror/glyph */
870                         if (is_mirror_grid(c_ptr) || is_glyph_grid(c_ptr) || is_explosive_rune_grid(c_ptr))
871                                 remove_mirror(y, x);
872
873                         /* Permanent features don't get effect */
874                         /* But not protect monsters and other objects */
875                         if (have_flag(f_ptr->flags, FF_HURT_DISI) && !have_flag(f_ptr->flags, FF_PERMANENT))
876                         {
877                                 cave_alter_feat(y, x, FF_HURT_DISI);
878
879                                 /* Update some things -- similar to GF_KILL_WALL */
880                                 p_ptr->update |= (PU_FLOW);
881                         }
882                         break;
883                 }
884         }
885
886         lite_spot(y, x);
887         /* Return "Anything seen?" */
888         return (obvious);
889 }
890
891
892
893 /*!
894  * @brief 汎用的なビーム/ボルト/ボール系によるアイテムオブジェクトへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
895  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
896  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
897  * @param y 目標Y座標 / Target y location (or location to travel "towards")
898  * @param x 目標X座標 / Target x location (or location to travel "towards")
899  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
900  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
901  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
902  * @details
903  * <pre>
904  * We are called from "project()" to "damage" objects
905  *
906  * We are called both for "beam" effects and "ball" effects.
907  *
908  * Perhaps we should only SOMETIMES damage things on the ground.
909  *
910  * The "r" parameter is the "distance from ground zero".
911  *
912  * Note that we determine if the player can "see" anything that happens
913  * by taking into account: blindness, line-of-sight, and illumination.
914  *
915  * We also "see" grids which are "memorized", probably a hack
916  *
917  * We return "TRUE" if the effect of the projection is "obvious".
918  * </pre>
919  */
920 static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
921 {
922         cave_type *c_ptr = &cave[y][x];
923
924         OBJECT_IDX this_o_idx, next_o_idx = 0;
925
926         bool obvious = FALSE;
927         bool known = player_has_los_bold(y, x);
928
929         BIT_FLAGS flgs[TR_FLAG_SIZE];
930
931         GAME_TEXT o_name[MAX_NLEN];
932
933         KIND_OBJECT_IDX k_idx = 0;
934         bool is_potion = FALSE;
935
936
937         who = who ? who : 0;
938
939         /* Reduce damage by distance */
940         dam = (dam + r) / (r + 1);
941
942
943         /* Scan all objects in the grid */
944         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
945         {
946                 object_type *o_ptr = &o_list[this_o_idx];
947
948                 bool is_art = FALSE;
949                 bool ignore = FALSE;
950                 bool do_kill = FALSE;
951
952                 concptr note_kill = NULL;
953
954 #ifndef JP
955                 /* Get the "plural"-ness */
956                 bool plural = (o_ptr->number > 1);
957 #endif
958
959                 /* Acquire next object */
960                 next_o_idx = o_ptr->next_o_idx;
961                 object_flags(o_ptr, flgs);
962
963                 /* Check for artifact */
964                 if (object_is_artifact(o_ptr)) is_art = TRUE;
965
966                 /* Analyze the type */
967                 switch (typ)
968                 {
969                         /* Acid -- Lots of things */
970                         case GF_ACID:
971                         {
972                                 if (hates_acid(o_ptr))
973                                 {
974                                         do_kill = TRUE;
975                                         note_kill = _("融けてしまった!", (plural ? " melt!" : " melts!"));
976                                         if (have_flag(flgs, TR_IGNORE_ACID)) ignore = TRUE;
977                                 }
978                                 break;
979                         }
980
981                         /* Elec -- Rings and Wands */
982                         case GF_ELEC:
983                         {
984                                 if (hates_elec(o_ptr))
985                                 {
986                                         do_kill = TRUE;
987                                         note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
988                                         if (have_flag(flgs, TR_IGNORE_ELEC)) ignore = TRUE;
989                                 }
990                                 break;
991                         }
992
993                         /* Fire -- Flammable objects */
994                         case GF_FIRE:
995                         {
996                                 if (hates_fire(o_ptr))
997                                 {
998                                         do_kill = TRUE;
999                                         note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
1000                                         if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
1001                                 }
1002                                 break;
1003                         }
1004
1005                         /* Cold -- potions and flasks */
1006                         case GF_COLD:
1007                         {
1008                                 if (hates_cold(o_ptr))
1009                                 {
1010                                         note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
1011                                         do_kill = TRUE;
1012                                         if (have_flag(flgs, TR_IGNORE_COLD)) ignore = TRUE;
1013                                 }
1014                                 break;
1015                         }
1016
1017                         /* Fire + Elec */
1018                         case GF_PLASMA:
1019                         {
1020                                 if (hates_fire(o_ptr))
1021                                 {
1022                                         do_kill = TRUE;
1023                                         note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
1024                                         if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
1025                                 }
1026                                 if (hates_elec(o_ptr))
1027                                 {
1028                                         ignore = FALSE;
1029                                         do_kill = TRUE;
1030                                         note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1031                                         if (have_flag(flgs, TR_IGNORE_ELEC)) ignore = TRUE;
1032                                 }
1033                                 break;
1034                         }
1035
1036                         /* Fire + Cold */
1037                         case GF_METEOR:
1038                         {
1039                                 if (hates_fire(o_ptr))
1040                                 {
1041                                         do_kill = TRUE;
1042                                         note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
1043                                         if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
1044                                 }
1045                                 if (hates_cold(o_ptr))
1046                                 {
1047                                         ignore = FALSE;
1048                                         do_kill = TRUE;
1049                                         note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
1050                                         if (have_flag(flgs, TR_IGNORE_COLD)) ignore = TRUE;
1051                                 }
1052                                 break;
1053                         }
1054
1055                         /* Hack -- break potions and such */
1056                         case GF_ICE:
1057                         case GF_SHARDS:
1058                         case GF_FORCE:
1059                         case GF_SOUND:
1060                         {
1061                                 if (hates_cold(o_ptr))
1062                                 {
1063                                         note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
1064                                         do_kill = TRUE;
1065                                 }
1066                                 break;
1067                         }
1068
1069                         /* Mana and Chaos -- destroy everything */
1070                         case GF_MANA:
1071                         case GF_SEEKER:
1072                         case GF_SUPER_RAY:
1073                         {
1074                                 do_kill = TRUE;
1075                                 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1076                                 break;
1077                         }
1078
1079                         case GF_DISINTEGRATE:
1080                         {
1081                                 do_kill = TRUE;
1082                                 note_kill = _("蒸発してしまった!", (plural ? " evaporate!" : " evaporates!"));
1083                                 break;
1084                         }
1085
1086                         case GF_CHAOS:
1087                         {
1088                                 do_kill = TRUE;
1089                                 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1090                                 if (have_flag(flgs, TR_RES_CHAOS)) ignore = TRUE;
1091                                 else if ((o_ptr->tval == TV_SCROLL) && (o_ptr->sval == SV_SCROLL_CHAOS)) ignore = TRUE;
1092                                 break;
1093                         }
1094
1095                         /* Holy Fire and Hell Fire -- destroys cursed non-artifacts */
1096                         case GF_HOLY_FIRE:
1097                         case GF_HELL_FIRE:
1098                         {
1099                                 if (object_is_cursed(o_ptr))
1100                                 {
1101                                         do_kill = TRUE;
1102                                         note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1103                                 }
1104                                 break;
1105                         }
1106
1107                         case GF_IDENTIFY:
1108                         {
1109                                 identify_item(o_ptr);
1110
1111                                 /* Auto-inscription */
1112                                 autopick_alter_item((-this_o_idx), FALSE);
1113                                 break;
1114                         }
1115
1116                         /* Unlock chests */
1117                         case GF_KILL_TRAP:
1118                         case GF_KILL_DOOR:
1119                         {
1120                                 /* Chests are noticed only if trapped or locked */
1121                                 if (o_ptr->tval == TV_CHEST)
1122                                 {
1123                                         /* Disarm/Unlock traps */
1124                                         if (o_ptr->pval > 0)
1125                                         {
1126                                                 /* Disarm or Unlock */
1127                                                 o_ptr->pval = (0 - o_ptr->pval);
1128
1129                                                 /* Identify */
1130                                                 object_known(o_ptr);
1131
1132                                                 if (known && (o_ptr->marked & OM_FOUND))
1133                                                 {
1134                                                         msg_print(_("カチッと音がした!", "Click!"));
1135                                                         obvious = TRUE;
1136                                                 }
1137                                         }
1138                                 }
1139
1140                                 break;
1141                         }
1142                         case GF_ANIM_DEAD:
1143                         {
1144                                 if (o_ptr->tval == TV_CORPSE)
1145                                 {
1146                                         int i;
1147                                         BIT_FLAGS mode = 0L;
1148
1149                                         if (!who || is_pet(&m_list[who]))
1150                                                 mode |= PM_FORCE_PET;
1151
1152                                         for (i = 0; i < o_ptr->number ; i++)
1153                                         {
1154                                                 if (((o_ptr->sval == SV_CORPSE) && (randint1(100) > 80)) ||
1155                                                         ((o_ptr->sval == SV_SKELETON) && (randint1(100) > 60)))
1156                                                 {
1157                                                         if (!note_kill)
1158                                                         {
1159                                                                 note_kill = _("灰になった。", (plural ? " become dust." : " becomes dust."));
1160                                                         }
1161                                                         continue;
1162                                                 }
1163                                                 else if (summon_named_creature(who, y, x, o_ptr->pval, mode))
1164                                                 {
1165                                                         note_kill = _("生き返った。", " revived.");
1166                                                 }
1167                                                 else if (!note_kill)
1168                                                 {
1169                                                         note_kill = _("灰になった。", (plural ? " become dust." : " becomes dust."));
1170                                                 }
1171                                         }
1172                                         do_kill = TRUE;
1173                                         obvious = TRUE;
1174                                 }
1175                                 break;
1176                         }
1177                 }
1178
1179
1180                 /* Attempt to destroy the object */
1181                 if (do_kill)
1182                 {
1183                         /* Effect "observed" */
1184                         if (known && (o_ptr->marked & OM_FOUND))
1185                         {
1186                                 obvious = TRUE;
1187                                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1188                         }
1189
1190                         /* Artifacts, and other objects, get to resist */
1191                         if (is_art || ignore)
1192                         {
1193                                 /* Observe the resist */
1194                                 if (known && (o_ptr->marked & OM_FOUND))
1195                                 {
1196                                         msg_format(_("%sは影響を受けない!", 
1197                                            (plural ? "The %s are unaffected!" : "The %s is unaffected!")), o_name);
1198                                 }
1199                         }
1200
1201                         /* Kill it */
1202                         else
1203                         {
1204                                 /* Describe if needed */
1205                                 if (known && (o_ptr->marked & OM_FOUND) && note_kill)
1206                                 {
1207                                         msg_format(_("%sは%s", "The %s%s"), o_name, note_kill);
1208                                 }
1209
1210                                 k_idx = o_ptr->k_idx;
1211                                 is_potion = object_is_potion(o_ptr);
1212                                 delete_object_idx(this_o_idx);
1213
1214                                 /* Potions produce effects when 'shattered' */
1215                                 if (is_potion)
1216                                 {
1217                                         (void)potion_smash_effect(who, y, x, k_idx);
1218                                 }
1219
1220                                 lite_spot(y, x);
1221                         }
1222                 }
1223         }
1224
1225         /* Return "Anything seen?" */
1226         return (obvious);
1227 }
1228
1229
1230 /*!
1231  * @brief 汎用的なビーム/ボルト/ボール系によるモンスターへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
1232  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
1233  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
1234  * @param y 目標Y座標 / Target y location (or location to travel "towards")
1235  * @param x 目標X座標 / Target x location (or location to travel "towards")
1236  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
1237  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
1238  * @param flg 効果フラグ
1239  * @param see_s_msg TRUEならばメッセージを表示する
1240  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
1241  * @details
1242  * <pre>
1243  * This routine takes a "source monster" (by index) which is mostly used to
1244  * determine if the player is causing the damage, and a "radius" (see below),
1245  * which is used to decrease the power of explosions with distance, and a
1246  * location, via integers which are modified by certain types of attacks
1247  * (polymorph and teleport being the obvious ones), a default damage, which
1248  * is modified as needed based on various properties, and finally a "damage
1249  * type" (see below).
1250  * </pre>
1251  * <pre>
1252  * Note that this routine can handle "no damage" attacks (like teleport) by
1253  * taking a "zero" damage, and can even take "parameters" to attacks (like
1254  * confuse) by accepting a "damage", using it to calculate the effect, and
1255  * then setting the damage to zero.  Note that the "damage" parameter is
1256  * divided by the radius, so monsters not at the "epicenter" will not take
1257  * as much damage (or whatever)...
1258  * </pre>
1259  * <pre>
1260  * Note that "polymorph" is dangerous, since a failure in "place_monster()"'
1261  * may result in a dereference of an invalid pointer.  
1262  * </pre>
1263  * <pre>
1264  * Various messages are produced, and damage is applied.
1265  * </pre>
1266  * <pre>
1267  * Just "casting" a substance (i.e. plasma) does not make you immune, you must
1268  * actually be "made" of that substance, or "breathe" big balls of it.
1269  * We assume that "Plasma" monsters, and "Plasma" breathers, are immune
1270  * to plasma.
1271  * We assume "Nether" is an evil, necromantic force, so it doesn't hurt undead,
1272  * and hurts evil less.  If can breath nether, then it resists it as well.
1273  * </pre>
1274  * <pre>
1275  * Damage reductions use the following formulas:
1276  *   Note that "dam = dam * 6 / (randint1(6) + 6);"
1277  *       gives avg damage of .655, ranging from .858 to .500
1278  *   Note that "dam = dam * 5 / (randint1(6) + 6);"
1279  *       gives avg damage of .544, ranging from .714 to .417
1280  *   Note that "dam = dam * 4 / (randint1(6) + 6);"
1281  *       gives avg damage of .444, ranging from .556 to .333
1282  *   Note that "dam = dam * 3 / (randint1(6) + 6);"
1283  *       gives avg damage of .327, ranging from .427 to .250
1284  *   Note that "dam = dam * 2 / (randint1(6) + 6);"
1285  *       gives something simple.
1286  * </pre>
1287  * <pre>
1288  * In this function, "result" messages are postponed until the end, where
1289  * the "note" string is appended to the monster name, if not NULL.  So,
1290  * to make a spell have "no effect" just set "note" to NULL.  You should
1291  * also set "notice" to FALSE, or the player will learn what the spell does.
1292  * </pre>
1293  * <pre>
1294  * We attempt to return "TRUE" if the player saw anything "useful" happen.
1295  * "flg" was added.
1296  * </pre>
1297  */
1298 static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, bool see_s_msg)
1299 {
1300         int tmp;
1301
1302         cave_type *c_ptr = &cave[y][x];
1303
1304         monster_type *m_ptr = &m_list[c_ptr->m_idx];
1305         monster_type *caster_ptr = (who > 0) ? &m_list[who] : NULL;
1306
1307         monster_race *r_ptr = &r_info[m_ptr->r_idx];
1308
1309         char killer[80];
1310
1311         /* Is the monster "seen"? */
1312         bool seen = m_ptr->ml;
1313         bool seen_msg = is_seen(m_ptr);
1314
1315         bool slept = (bool)MON_CSLEEP(m_ptr);
1316
1317         /* Were the effects "obvious" (if seen)? */
1318         bool obvious = FALSE;
1319
1320         /* Can the player know about this effect? */
1321         bool known = ((m_ptr->cdis <= MAX_SIGHT) || p_ptr->inside_battle);
1322
1323         /* Were the effects "irrelevant"? */
1324         bool skipped = FALSE;
1325
1326         /* Gets the monster angry at the source of the effect? */
1327         bool get_angry = FALSE;
1328
1329         /* Polymorph setting (true or false) */
1330         bool do_poly = FALSE;
1331
1332         /* Teleport setting (max distance) */
1333         int do_dist = 0;
1334
1335         /* Confusion setting (amount to confuse) */
1336         int do_conf = 0;
1337
1338         /* Stunning setting (amount to stun) */
1339         int do_stun = 0;
1340
1341         /* Sleep amount (amount to sleep) */
1342         int do_sleep = 0;
1343
1344         /* Fear amount (amount to fear) */
1345         int do_fear = 0;
1346
1347         /* Time amount (amount to time) */
1348         int do_time = 0;
1349
1350         bool heal_leper = FALSE;
1351
1352         /* Hold the monster name */
1353         GAME_TEXT m_name[MAX_NLEN];
1354         char m_poss[10];
1355
1356         PARAMETER_VALUE photo = 0;
1357
1358         /* Assume no note */
1359         concptr note = NULL;
1360
1361         /* Assume a default death */
1362         concptr note_dies = extract_note_dies(real_r_idx(m_ptr));
1363
1364         POSITION ty = m_ptr->fy;
1365         POSITION tx = m_ptr->fx;
1366
1367         DEPTH caster_lev = (who > 0) ? r_info[caster_ptr->r_idx].level : (p_ptr->lev * 2);
1368
1369         /* Nobody here */
1370         if (!c_ptr->m_idx) return (FALSE);
1371
1372         /* Never affect projector */
1373         if (who && (c_ptr->m_idx == who)) return (FALSE);
1374         if ((c_ptr->m_idx == p_ptr->riding) && !who && !(typ == GF_OLD_HEAL) && !(typ == GF_OLD_SPEED) && !(typ == GF_STAR_HEAL)) return (FALSE);
1375         if (sukekaku && ((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) return FALSE;
1376
1377         /* Don't affect already death monsters */
1378         /* Prevents problems with chain reactions of exploding monsters */
1379         if (m_ptr->hp < 0) return (FALSE);
1380
1381         /* Reduce damage by distance */
1382         dam = (dam + r) / (r + 1);
1383
1384
1385         /* Get the monster name (BEFORE polymorphing) */
1386         monster_desc(m_name, m_ptr, 0);
1387
1388         /* Get the monster possessive ("his"/"her"/"its") */
1389         monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
1390
1391         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
1392
1393         /* Analyze the damage type */
1394         switch (typ)
1395         {
1396                 /* Magic Missile -- pure damage */
1397                 case GF_MISSILE:
1398                 {
1399                         if (seen) obvious = TRUE;
1400
1401                         if (r_ptr->flagsr & RFR_RES_ALL)
1402                         {
1403                                 note = _("には完全な耐性がある!", " is immune.");
1404                                 dam = 0;
1405                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1406                                 break;
1407                         }
1408                         break;
1409                 }
1410
1411                 /* Acid */
1412                 case GF_ACID:
1413                 {
1414                         if (seen) obvious = TRUE;
1415
1416                         if (r_ptr->flagsr & RFR_RES_ALL)
1417                         {
1418                                 note = _("には完全な耐性がある!", " is immune.");
1419                                 dam = 0;
1420                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1421                                 break;
1422                         }
1423                         if (r_ptr->flagsr & RFR_IM_ACID)
1424                         {
1425                                 note = _("にはかなり耐性がある!", " resists a lot.");
1426                                 dam /= 9;
1427                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_ACID);
1428                         }
1429                         break;
1430                 }
1431
1432                 /* Electricity */
1433                 case GF_ELEC:
1434                 {
1435                         if (seen) obvious = TRUE;
1436
1437                         if (r_ptr->flagsr & RFR_RES_ALL)
1438                         {
1439                                 note = _("には完全な耐性がある!", " is immune.");
1440                                 dam = 0;
1441                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1442                                 break;
1443                         }
1444                         if (r_ptr->flagsr & RFR_IM_ELEC)
1445                         {
1446                                 note = _("にはかなり耐性がある!", " resists a lot.");
1447                                 dam /= 9;
1448                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_ELEC);
1449                         }
1450                         break;
1451                 }
1452
1453                 /* Fire damage */
1454                 case GF_FIRE:
1455                 {
1456                         if (seen) obvious = TRUE;
1457
1458                         if (r_ptr->flagsr & RFR_RES_ALL)
1459                         {
1460                                 note = _("には完全な耐性がある!", " is immune.");
1461                                 dam = 0;
1462                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1463                                 break;
1464                         }
1465                         if (r_ptr->flagsr & RFR_IM_FIRE)
1466                         {
1467                                 note = _("にはかなり耐性がある!", " resists a lot.");
1468                                 dam /= 9;
1469                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_FIRE);
1470                         }
1471                         else if (r_ptr->flags3 & (RF3_HURT_FIRE))
1472                         {
1473                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1474                                 dam *= 2;
1475                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_FIRE);
1476                         }
1477                         break;
1478                 }
1479
1480                 /* Cold */
1481                 case GF_COLD:
1482                 {
1483                         if (seen) obvious = TRUE;
1484
1485                         if (r_ptr->flagsr & RFR_RES_ALL)
1486                         {
1487                                 note = _("には完全な耐性がある!", " is immune.");
1488                                 dam = 0;
1489                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1490                                 break;
1491                         }
1492                         if (r_ptr->flagsr & RFR_IM_COLD)
1493                         {
1494                                 note = _("にはかなり耐性がある!", " resists a lot.");
1495                                 dam /= 9;
1496                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_COLD);
1497                         }
1498                         else if (r_ptr->flags3 & (RF3_HURT_COLD))
1499                         {
1500                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1501                                 dam *= 2;
1502                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_COLD);
1503                         }
1504                         break;
1505                 }
1506
1507                 /* Poison */
1508                 case GF_POIS:
1509                 {
1510                         if (seen) obvious = TRUE;
1511
1512                         if (r_ptr->flagsr & RFR_RES_ALL)
1513                         {
1514                                 note = _("には完全な耐性がある!", " is immune.");
1515                                 dam = 0;
1516                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1517                                 break;
1518                         }
1519                         if (r_ptr->flagsr & RFR_IM_POIS)
1520                         {
1521                                 note = _("にはかなり耐性がある!", " resists a lot.");
1522                                 dam /= 9;
1523                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_POIS);
1524                         }
1525                         break;
1526                 }
1527
1528                 /* Nuclear waste */
1529                 case GF_NUKE:
1530                 {
1531                         if (seen) obvious = TRUE;
1532
1533                         if (r_ptr->flagsr & RFR_RES_ALL)
1534                         {
1535                                 note = _("には完全な耐性がある!", " is immune.");
1536                                 dam = 0;
1537                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1538                                 break;
1539                         }
1540                         if (r_ptr->flagsr & RFR_IM_POIS)
1541                         {
1542                                 note = _("には耐性がある。", " resists.");
1543                                 dam *= 3; dam /= randint1(6) + 6;
1544                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_POIS);
1545                         }
1546                         else if (one_in_(3)) do_poly = TRUE;
1547                         break;
1548                 }
1549
1550                 /* Hellfire -- hurts Evil */
1551                 case GF_HELL_FIRE:
1552                 {
1553                         if (seen) obvious = TRUE;
1554
1555                         if (r_ptr->flagsr & RFR_RES_ALL)
1556                         {
1557                                 note = _("には完全な耐性がある!", " is immune.");
1558                                 dam = 0;
1559                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1560                                 break;
1561                         }
1562                         if (r_ptr->flags3 & RF3_GOOD)
1563                         {
1564                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1565                                 dam *= 2;
1566                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
1567                         }
1568                         break;
1569                 }
1570
1571                 /* Holy Fire -- hurts Evil, Good are immune, others _resist_ */
1572                 case GF_HOLY_FIRE:
1573                 {
1574                         if (seen) obvious = TRUE;
1575
1576                         if (r_ptr->flagsr & RFR_RES_ALL)
1577                         {
1578                                 note = _("には完全な耐性がある!", " is immune.");
1579                                 dam = 0;
1580                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1581                                 break;
1582                         }
1583                         if (r_ptr->flags3 & RF3_GOOD)
1584                         {
1585                                 note = _("には完全な耐性がある!", " is immune.");
1586                                 dam = 0;
1587                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= RF3_GOOD;
1588                         }
1589                         else if (r_ptr->flags3 & RF3_EVIL)
1590                         {
1591                                 dam *= 2;
1592                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1593                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= RF3_EVIL;
1594                         }
1595                         else
1596                         {
1597                                 note = _("には耐性がある。", " resists.");
1598                                 dam *= 3; dam /= randint1(6) + 6;
1599                         }
1600                         break;
1601                 }
1602
1603                 /* Arrow -- XXX no defense */
1604                 case GF_ARROW:
1605                 {
1606                         if (seen) obvious = TRUE;
1607
1608                         if (r_ptr->flagsr & RFR_RES_ALL)
1609                         {
1610                                 note = _("には完全な耐性がある!", " is immune.");
1611                                 dam = 0;
1612                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1613                                 break;
1614                         }
1615                         break;
1616                 }
1617
1618                 /* Plasma -- XXX perhaps check ELEC or FIRE */
1619                 case GF_PLASMA:
1620                 {
1621                         if (seen) obvious = TRUE;
1622
1623                         if (r_ptr->flagsr & RFR_RES_ALL)
1624                         {
1625                                 note = _("には完全な耐性がある!", " is immune.");
1626                                 dam = 0;
1627                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1628                                 break;
1629                         }
1630                         if (r_ptr->flagsr & RFR_RES_PLAS)
1631                         {
1632                                 note = _("には耐性がある。", " resists.");
1633                                 dam *= 3; dam /= randint1(6) + 6;
1634                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_PLAS);
1635                         }
1636                         break;
1637                 }
1638
1639                 /* Nether -- see above */
1640                 case GF_NETHER:
1641                 {
1642                         if (seen) obvious = TRUE;
1643
1644                         if (r_ptr->flagsr & RFR_RES_ALL)
1645                         {
1646                                 note = _("には完全な耐性がある!", " is immune.");
1647                                 dam = 0;
1648                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1649                                 break;
1650                         }
1651                         if (r_ptr->flagsr & RFR_RES_NETH)
1652                         {
1653                                 if (r_ptr->flags3 & RF3_UNDEAD)
1654                                 {
1655                                         note = _("には完全な耐性がある!", " is immune.");
1656                                         dam = 0;
1657                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
1658                                 }
1659                                 else
1660                                 {
1661                                         note = _("には耐性がある。", " resists.");
1662                                         dam *= 3; dam /= randint1(6) + 6;
1663                                 }
1664                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_NETH);
1665                         }
1666                         else if (r_ptr->flags3 & RF3_EVIL)
1667                         {
1668                                 note = _("はいくらか耐性を示した。", " resists somewhat.");
1669                                 dam /= 2;
1670                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
1671                         }
1672                         break;
1673                 }
1674
1675                 /* Water (acid) damage -- Water spirits/elementals are immune */
1676                 case GF_WATER:
1677                 {
1678                         if (seen) obvious = TRUE;
1679
1680                         if (r_ptr->flagsr & RFR_RES_ALL)
1681                         {
1682                                 note = _("には完全な耐性がある!", " is immune.");
1683                                 dam = 0;
1684                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1685                                 break;
1686                         }
1687                         if (r_ptr->flagsr & RFR_RES_WATE)
1688                         {
1689                                 if ((m_ptr->r_idx == MON_WATER_ELEM) || (m_ptr->r_idx == MON_UNMAKER))
1690                                 {
1691                                         note = _("には完全な耐性がある!", " is immune.");
1692                                         dam = 0;
1693                                 }
1694                                 else
1695                                 {
1696                                         note = _("には耐性がある。", " resists.");
1697                                         dam *= 3; dam /= randint1(6) + 6;
1698                                 }
1699                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_WATE);
1700                         }
1701                         break;
1702                 }
1703
1704                 /* Chaos -- Chaos breathers resist */
1705                 case GF_CHAOS:
1706                 {
1707                         if (seen) obvious = TRUE;
1708
1709                         if (r_ptr->flagsr & RFR_RES_ALL)
1710                         {
1711                                 note = _("には完全な耐性がある!", " is immune.");
1712                                 dam = 0;
1713                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1714                                 break;
1715                         }
1716                         if (r_ptr->flagsr & RFR_RES_CHAO)
1717                         {
1718                                 note = _("には耐性がある。", " resists.");
1719                                 dam *= 3; dam /= randint1(6) + 6;
1720                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_CHAO);
1721                         }
1722                         else if ((r_ptr->flags3 & RF3_DEMON) && one_in_(3))
1723                         {
1724                                 note = _("はいくらか耐性を示した。", " resists somewhat.");
1725                                 dam *= 3; dam /= randint1(6) + 6;
1726                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
1727                         }
1728                         else
1729                         {
1730                                 do_poly = TRUE;
1731                                 do_conf = (5 + randint1(11) + r) / (r + 1);
1732                         }
1733                         break;
1734                 }
1735
1736                 /* Shards -- Shard breathers resist */
1737                 case GF_SHARDS:
1738                 {
1739                         if (seen) obvious = TRUE;
1740
1741                         if (r_ptr->flagsr & RFR_RES_ALL)
1742                         {
1743                                 note = _("には完全な耐性がある!", " is immune.");
1744                                 dam = 0;
1745                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1746                                 break;
1747                         }
1748                         if (r_ptr->flagsr & RFR_RES_SHAR)
1749                         {
1750                                 note = _("には耐性がある。", " resists.");
1751                                 dam *= 3; dam /= randint1(6) + 6;
1752                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SHAR);
1753                         }
1754                         break;
1755                 }
1756
1757                 /* Rocket: Shard resistance helps */
1758                 case GF_ROCKET:
1759                 {
1760                         if (seen) obvious = TRUE;
1761
1762                         if (r_ptr->flagsr & RFR_RES_ALL)
1763                         {
1764                                 note = _("には完全な耐性がある!", " is immune.");
1765                                 dam = 0;
1766                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1767                                 break;
1768                         }
1769                         if (r_ptr->flagsr & RFR_RES_SHAR)
1770                         {
1771                                 note = _("はいくらか耐性を示した。", " resists somewhat.");
1772                                 dam /= 2;
1773                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SHAR);
1774                         }
1775                         break;
1776                 }
1777
1778
1779                 /* Sound -- Sound breathers resist */
1780                 case GF_SOUND:
1781                 {
1782                         if (seen) obvious = TRUE;
1783
1784                         if (r_ptr->flagsr & RFR_RES_ALL)
1785                         {
1786                                 note = _("には完全な耐性がある!", " is immune.");
1787                                 dam = 0;
1788                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1789                                 break;
1790                         }
1791                         if (r_ptr->flagsr & RFR_RES_SOUN)
1792                         {
1793                                 note = _("には耐性がある。", " resists.");
1794                                 dam *= 2; dam /= randint1(6) + 6;
1795                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SOUN);
1796                         }
1797                         else do_stun = (10 + randint1(15) + r) / (r + 1);
1798                         break;
1799                 }
1800
1801                 /* Confusion */
1802                 case GF_CONFUSION:
1803                 {
1804                         if (seen) obvious = TRUE;
1805
1806                         if (r_ptr->flagsr & RFR_RES_ALL)
1807                         {
1808                                 note = _("には完全な耐性がある!", " is immune.");
1809                                 dam = 0;
1810                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1811                                 break;
1812                         }
1813                         if (r_ptr->flags3 & RF3_NO_CONF)
1814                         {
1815                                 note = _("には耐性がある。", " resists.");
1816                                 dam *= 3; dam /= randint1(6) + 6;
1817                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
1818                         }
1819                         else do_conf = (10 + randint1(15) + r) / (r + 1);
1820                         break;
1821                 }
1822
1823                 /* Disenchantment -- Breathers and Disenchanters resist */
1824                 case GF_DISENCHANT:
1825                 {
1826                         if (seen) obvious = TRUE;
1827
1828                         if (r_ptr->flagsr & RFR_RES_ALL)
1829                         {
1830                                 note = _("には完全な耐性がある!", " is immune.");
1831                                 dam = 0;
1832                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1833                                 break;
1834                         }
1835                         if (r_ptr->flagsr & RFR_RES_DISE)
1836                         {
1837                                 note = _("には耐性がある。", " resists.");
1838                                 dam *= 3; dam /= randint1(6) + 6;
1839                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_DISE);
1840                         }
1841                         break;
1842                 }
1843
1844                 /* Nexus -- Breathers and Existers resist */
1845                 case GF_NEXUS:
1846                 {
1847                         if (seen) obvious = TRUE;
1848
1849                         if (r_ptr->flagsr & RFR_RES_ALL)
1850                         {
1851                                 note = _("には完全な耐性がある!", " is immune.");
1852                                 dam = 0;
1853                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1854                                 break;
1855                         }
1856                         if (r_ptr->flagsr & RFR_RES_NEXU)
1857                         {
1858                                 note = _("には耐性がある。", " resists.");
1859                                 dam *= 3; dam /= randint1(6) + 6;
1860                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_NEXU);
1861                         }
1862                         break;
1863                 }
1864
1865                 /* Force */
1866                 case GF_FORCE:
1867                 {
1868                         if (seen) obvious = TRUE;
1869
1870                         if (r_ptr->flagsr & RFR_RES_ALL)
1871                         {
1872                                 note = _("には完全な耐性がある!", " is immune.");
1873                                 dam = 0;
1874                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1875                                 break;
1876                         }
1877                         if (r_ptr->flagsr & RFR_RES_WALL)
1878                         {
1879                                 note = _("には耐性がある。", " resists.");
1880                                 dam *= 3; dam /= randint1(6) + 6;
1881                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_WALL);
1882                         }
1883                         else do_stun = (randint1(15) + r) / (r + 1);
1884                         break;
1885                 }
1886
1887                 /* Inertia -- breathers resist */
1888                 case GF_INERTIAL:
1889                 {
1890                         if (seen) obvious = TRUE;
1891
1892                         if (r_ptr->flagsr & RFR_RES_ALL)
1893                         {
1894                                 note = _("には完全な耐性がある!", " is immune.");
1895                                 dam = 0;
1896                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1897                                 break;
1898                         }
1899                         if (r_ptr->flagsr & RFR_RES_INER)
1900                         {
1901                                 note = _("には耐性がある。", " resists.");
1902                                 dam *= 3; dam /= randint1(6) + 6;
1903                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_INER);
1904                         }
1905                         else
1906                         {
1907                                 /* Powerful monsters can resist */
1908                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
1909                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
1910                                 {
1911                                         obvious = FALSE;
1912                                 }
1913                                 /* Normal monsters slow down */
1914                                 else
1915                                 {
1916                                         if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
1917                                         {
1918                                                 note = _("の動きが遅くなった。", " starts moving slower.");
1919                                         }
1920                                 }
1921                         }
1922                         break;
1923                 }
1924
1925                 /* Time -- breathers resist */
1926                 case GF_TIME:
1927                 {
1928                         if (seen) obvious = TRUE;
1929
1930                         if (r_ptr->flagsr & RFR_RES_ALL)
1931                         {
1932                                 note = _("には完全な耐性がある!", " is immune.");
1933                                 dam = 0;
1934                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1935                                 break;
1936                         }
1937                         if (r_ptr->flagsr & RFR_RES_TIME)
1938                         {
1939                                 note = _("には耐性がある。", " resists.");
1940                                 dam *= 3; dam /= randint1(6) + 6;
1941                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_TIME);
1942                         }
1943                         else do_time = (dam + 1) / 2;
1944                         break;
1945                 }
1946
1947                 /* Gravity -- breathers resist */
1948                 case GF_GRAVITY:
1949                 {
1950                         bool resist_tele = FALSE;
1951
1952                         if (seen) obvious = TRUE;
1953
1954                         if (r_ptr->flagsr & RFR_RES_ALL)
1955                         {
1956                                 note = _("には完全な耐性がある!", " is immune.");
1957                                 dam = 0;
1958                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1959                                 break;
1960                         }
1961                         if (r_ptr->flagsr & RFR_RES_TELE)
1962                         {
1963                                 if (r_ptr->flags1 & (RF1_UNIQUE))
1964                                 {
1965                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
1966                                         note = _("には効果がなかった。", " is unaffected!");
1967                                         resist_tele = TRUE;
1968                                 }
1969                                 else if (r_ptr->level > randint1(100))
1970                                 {
1971                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
1972                                         note = _("には耐性がある!", " resists!");
1973                                         resist_tele = TRUE;
1974                                 }
1975                         }
1976
1977                         if (!resist_tele) do_dist = 10;
1978                         else do_dist = 0;
1979                         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_dist = 0;
1980
1981                         if (r_ptr->flagsr & RFR_RES_GRAV)
1982                         {
1983                                 note = _("には耐性がある!", " resists!");
1984                                 dam *= 3; dam /= randint1(6) + 6;
1985                                 do_dist = 0;
1986                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_GRAV);
1987                         }
1988                         else
1989                         {
1990                                 /* 1. slowness */
1991                                 /* Powerful monsters can resist */
1992                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
1993                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
1994                                 {
1995                                         obvious = FALSE;
1996                                 }
1997                                 /* Normal monsters slow down */
1998                                 else
1999                                 {
2000                                         if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
2001                                         {
2002                                                 note = _("の動きが遅くなった。", " starts moving slower.");
2003                                         }
2004                                 }
2005
2006                                 /* 2. stun */
2007                                 do_stun = damroll((caster_lev / 20) + 3 , (dam)) + 1;
2008
2009                                 /* Attempt a saving throw */
2010                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
2011                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2012                                 {
2013                                         /* Resist */
2014                                         do_stun = 0;
2015                                         /* No obvious effect */
2016                                         note = _("には効果がなかった。", " is unaffected!");
2017                                         obvious = FALSE;
2018                                 }
2019                         }
2020                         break;
2021                 }
2022
2023                 /* Pure damage */
2024                 case GF_MANA:
2025                 case GF_SEEKER:
2026                 case GF_SUPER_RAY:
2027                 {
2028                         if (seen) obvious = TRUE;
2029
2030                         if (r_ptr->flagsr & RFR_RES_ALL)
2031                         {
2032                                 note = _("には完全な耐性がある!", " is immune.");
2033                                 dam = 0;
2034                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2035                                 break;
2036                         }
2037                         break;
2038                 }
2039
2040
2041                 /* Pure damage */
2042                 case GF_DISINTEGRATE:
2043                 {
2044                         if (seen) obvious = TRUE;
2045
2046                         if (r_ptr->flagsr & RFR_RES_ALL)
2047                         {
2048                                 note = _("には完全な耐性がある!", " is immune.");
2049                                 dam = 0;
2050                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2051                                 break;
2052                         }
2053                         if (r_ptr->flags3 & RF3_HURT_ROCK)
2054                         {
2055                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
2056                                 note = _("の皮膚がただれた!", " loses some skin!");
2057                                 note_dies = _("は蒸発した!", " evaporates!");
2058                                 dam *= 2;
2059                         }
2060                         break;
2061                 }
2062
2063                 case GF_PSI:
2064                 {
2065                         if (seen) obvious = TRUE;
2066
2067                         /* PSI only works if the monster can see you! -- RG */
2068                         if (!(los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)))
2069                         {
2070                                 if (seen_msg) 
2071                                         msg_format(_("%sはあなたが見えないので影響されない!", "%^s can't see you, and isn't affected!"), m_name);
2072                                 skipped = TRUE;
2073                                 break;
2074                         }
2075
2076                         if (r_ptr->flagsr & RFR_RES_ALL)
2077                         {
2078                                 note = _("には完全な耐性がある!", " is immune.");
2079                                 dam = 0;
2080                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2081                                 break;
2082                         }
2083                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
2084                         {
2085                                 dam = 0;
2086                                 note = _("には完全な耐性がある!", " is immune.");
2087                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2088
2089                         }
2090                         else if ((r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
2091                                          (r_ptr->flags3 & RF3_ANIMAL) ||
2092                                          (r_ptr->level > randint1(3 * dam)))
2093                         {
2094                                 note = _("には耐性がある!", " resists!");
2095                                 dam /= 3;
2096
2097                                 /*
2098                                  * Powerful demons & undead can turn a mindcrafter's
2099                                  * attacks back on them
2100                                  */
2101                                 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
2102                                         (r_ptr->level > p_ptr->lev / 2) &&
2103                                         one_in_(2))
2104                                 {
2105                                         note = NULL;
2106                                         msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!", 
2107                                                 (seen ? "%^s's corrupted mind backlashes your attack!" : 
2108                                                                 "%^ss corrupted mind backlashes your attack!")), m_name);
2109
2110                                         /* Saving throw */
2111                                         if ((randint0(100 + r_ptr->level / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
2112                                         {
2113                                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
2114                                         }
2115                                         else
2116                                         {
2117                                                 /* Injure +/- confusion */
2118                                                 monster_desc(killer, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
2119                                                 take_hit(DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
2120                                                 if (one_in_(4) && !CHECK_MULTISHADOW())
2121                                                 {
2122                                                         switch (randint1(4))
2123                                                         {
2124                                                                 case 1:
2125                                                                         set_confused(p_ptr->confused + 3 + randint1(dam));
2126                                                                         break;
2127                                                                 case 2:
2128                                                                         set_stun(p_ptr->stun + randint1(dam));
2129                                                                         break;
2130                                                                 case 3:
2131                                                                 {
2132                                                                         if (r_ptr->flags3 & RF3_NO_FEAR)
2133                                                                                 note = _("には効果がなかった。", " is unaffected.");
2134                                                                         else
2135                                                                                 set_afraid(p_ptr->afraid + 3 + randint1(dam));
2136                                                                         break;
2137                                                                 }
2138                                                                 default:
2139                                                                         if (!p_ptr->free_act)
2140                                                                                 (void)set_paralyzed(p_ptr->paralyzed + randint1(dam));
2141                                                                         break;
2142                                                         }
2143                                                 }
2144                                         }
2145                                         dam = 0;
2146                                 }
2147                         }
2148
2149                         if ((dam > 0) && one_in_(4))
2150                         {
2151                                 switch (randint1(4))
2152                                 {
2153                                         case 1:
2154                                                 do_conf = 3 + randint1(dam);
2155                                                 break;
2156                                         case 2:
2157                                                 do_stun = 3 + randint1(dam);
2158                                                 break;
2159                                         case 3:
2160                                                 do_fear = 3 + randint1(dam);
2161                                                 break;
2162                                         default:
2163                                                 note = _("は眠り込んでしまった!", " falls asleep!");
2164                                                 do_sleep = 3 + randint1(dam);
2165                                                 break;
2166                                 }
2167                         }
2168
2169                         note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
2170                         break;
2171                 }
2172
2173                 case GF_PSI_DRAIN:
2174                 {
2175                         if (seen) obvious = TRUE;
2176
2177                         if (r_ptr->flagsr & RFR_RES_ALL)
2178                         {
2179                                 note = _("には完全な耐性がある!", " is immune.");
2180                                 dam = 0;
2181                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2182                                 break;
2183                         }
2184                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
2185                         {
2186                                 dam = 0;
2187                                 note = _("には完全な耐性がある!", " is immune.");
2188                         }
2189                         else if ((r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
2190                                          (r_ptr->flags3 & RF3_ANIMAL) ||
2191                                          (r_ptr->level > randint1(3 * dam)))
2192                         {
2193                                 note = _("には耐性がある!", " resists!");
2194                                 dam /= 3;
2195
2196                                 /*
2197                                  * Powerful demons & undead can turn a mindcrafter's
2198                                  * attacks back on them
2199                                  */
2200                                 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
2201                                          (r_ptr->level > p_ptr->lev / 2) &&
2202                                          (one_in_(2)))
2203                                 {
2204                                         note = NULL;
2205                                         msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!", 
2206                                                 (seen ? "%^s's corrupted mind backlashes your attack!" : 
2207                                                                 "%^ss corrupted mind backlashes your attack!")), m_name);
2208                                         /* Saving throw */
2209                                         if ((randint0(100 + r_ptr->level / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
2210                                         {
2211                                                 msg_print(_("あなたは効力を跳ね返した!", "You resist the effects!"));
2212                                         }
2213                                         else
2214                                         {
2215                                                 /* Injure + mana drain */
2216                                                 monster_desc(killer, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
2217                                                 if (!CHECK_MULTISHADOW())
2218                                                 {
2219                                                         msg_print(_("超能力パワーを吸いとられた!", "Your psychic energy is drained!"));
2220                                                         p_ptr->csp -= damroll(5, dam) / 2;
2221                                                         if (p_ptr->csp < 0) p_ptr->csp = 0;
2222                                                         p_ptr->redraw |= PR_MANA;
2223                                                         p_ptr->window |= (PW_SPELL);
2224                                                 }
2225                                                 take_hit(DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
2226                                         }
2227                                         dam = 0;
2228                                 }
2229                         }
2230                         else if (dam > 0)
2231                         {
2232                                 int b = damroll(5, dam) / 4;
2233                                 concptr str = (p_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
2234                                 concptr msg = _("あなたは%sの苦痛を%sに変換した!", 
2235                                          (seen ? "You convert %s's pain into %s!" : 
2236                                                          "You convert %ss pain into %s!"));
2237                                 msg_format(msg, m_name, str);
2238
2239                                 b = MIN(p_ptr->msp, p_ptr->csp + b);
2240                                 p_ptr->csp = b;
2241                                 p_ptr->redraw |= PR_MANA;
2242                                 p_ptr->window |= (PW_SPELL);
2243                         }
2244                         note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
2245                         break;
2246                 }
2247
2248                 case GF_TELEKINESIS:
2249                 {
2250                         if (seen) obvious = TRUE;
2251
2252                         if (r_ptr->flagsr & RFR_RES_ALL)
2253                         {
2254                                 note = _("には完全な耐性がある!", " is immune.");
2255                                 dam = 0;
2256                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2257                                 break;
2258                         }
2259                         if (one_in_(4))
2260                         {
2261                                 if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_dist = 0;
2262                                 else do_dist = 7;
2263                         }
2264
2265                         /* 1. stun */
2266                         do_stun = damroll((caster_lev / 20) + 3 , dam) + 1;
2267
2268                         /* Attempt a saving throw */
2269                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2270                                 (r_ptr->level > 5 + randint1(dam)))
2271                         {
2272                                 /* Resist */
2273                                 do_stun = 0;
2274                                 /* No obvious effect */
2275                                 obvious = FALSE;
2276                         }
2277                         break;
2278                 }
2279
2280                 /* Psycho-spear -- powerful magic missile */
2281                 case GF_PSY_SPEAR:
2282                 {
2283                         if (seen) obvious = TRUE;
2284
2285                         if (r_ptr->flagsr & RFR_RES_ALL)
2286                         {
2287                                 note = _("には完全な耐性がある!", " is immune.");
2288                                 dam = 0;
2289                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2290                                 break;
2291                         }
2292                         break;
2293                 }
2294
2295                 /* Meteor -- powerful magic missile */
2296                 case GF_METEOR:
2297                 {
2298                         if (seen) obvious = TRUE;
2299
2300                         if (r_ptr->flagsr & RFR_RES_ALL)
2301                         {
2302                                 note = _("には完全な耐性がある!", " is immune.");
2303                                 dam = 0;
2304                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2305                                 break;
2306                         }
2307                         break;
2308                 }
2309
2310                 case GF_DOMINATION:
2311                 {
2312                         if (!is_hostile(m_ptr)) break;
2313
2314                         if (seen) obvious = TRUE;
2315
2316                         if (r_ptr->flagsr & RFR_RES_ALL)
2317                         {
2318                                 note = _("には効果がなかった!", " is immune.");
2319                                 dam = 0;
2320                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2321                                 break;
2322                         }
2323                         /* Attempt a saving throw */
2324                         if ((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) ||
2325                                 (r_ptr->flags3 & RF3_NO_CONF) ||
2326                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2327                         {
2328                                 /* Memorize a flag */
2329                                 if (r_ptr->flags3 & RF3_NO_CONF)
2330                                 {
2331                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
2332                                 }
2333
2334                                 /* Resist */
2335                                 do_conf = 0;
2336
2337                                 /*
2338                                  * Powerful demons & undead can turn a mindcrafter's
2339                                  * attacks back on them
2340                                  */
2341                                 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
2342                                         (r_ptr->level > p_ptr->lev / 2) &&
2343                                         (one_in_(2)))
2344                                 {
2345                                         note = NULL;
2346                                         msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!",
2347                                                 (seen ? "%^s's corrupted mind backlashes your attack!" :
2348                                                 "%^ss corrupted mind backlashes your attack!")), m_name);
2349
2350                                         /* Saving throw */
2351                                         if (randint0(100 + r_ptr->level/2) < p_ptr->skill_sav)
2352                                         {
2353                                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
2354                                         }
2355                                         else
2356                                         {
2357                                                 /* Confuse, stun, terrify */
2358                                                 switch (randint1(4))
2359                                                 {
2360                                                         case 1:
2361                                                                 set_stun(p_ptr->stun + dam / 2);
2362                                                                 break;
2363                                                         case 2:
2364                                                                 set_confused(p_ptr->confused + dam / 2);
2365                                                                 break;
2366                                                         default:
2367                                                         {
2368                                                                 if (r_ptr->flags3 & RF3_NO_FEAR)
2369                                                                         note = _("には効果がなかった。", " is unaffected.");
2370                                                                 else
2371                                                                         set_afraid(p_ptr->afraid + dam);
2372                                                         }
2373                                                 }
2374                                         }
2375                                 }
2376                                 else
2377                                 {
2378                                         /* No obvious effect */
2379                                         note = _("には効果がなかった。", " is unaffected.");
2380                                         obvious = FALSE;
2381                                 }
2382                         }
2383                         else
2384                         {
2385                                 if (!common_saving_throw_charm(p_ptr, dam, m_ptr))
2386                                 {
2387                                         note = _("があなたに隷属した。", " is in your thrall!");
2388                                         set_pet(m_ptr);
2389                                 }
2390                                 else
2391                                 {
2392                                         switch (randint1(4))
2393                                         {
2394                                                 case 1:
2395                                                         do_stun = dam / 2;
2396                                                         break;
2397                                                 case 2:
2398                                                         do_conf = dam / 2;
2399                                                         break;
2400                                                 default:
2401                                                         do_fear = dam;
2402                                         }
2403                                 }
2404                         }
2405
2406                         /* No "real" damage */
2407                         dam = 0;
2408                         break;
2409                 }
2410
2411
2412
2413                 /* Ice -- Cold + Cuts + Stun */
2414                 case GF_ICE:
2415                 {
2416                         if (seen) obvious = TRUE;
2417
2418                         if (r_ptr->flagsr & RFR_RES_ALL)
2419                         {
2420                                 note = _("には完全な耐性がある!", " is immune.");
2421                                 dam = 0;
2422                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2423                                 break;
2424                         }
2425                         do_stun = (randint1(15) + 1) / (r + 1);
2426                         if (r_ptr->flagsr & RFR_IM_COLD)
2427                         {
2428                                 note = _("にはかなり耐性がある!", " resists a lot.");
2429                                 dam /= 9;
2430                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_COLD);
2431                         }
2432                         else if (r_ptr->flags3 & (RF3_HURT_COLD))
2433                         {
2434                                 note = _("はひどい痛手をうけた。", " is hit hard.");
2435                                 dam *= 2;
2436                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_COLD);
2437                         }
2438                         break;
2439                 }
2440
2441
2442                 /* Drain Life */
2443                 case GF_HYPODYNAMIA:
2444                 {
2445                         if (seen) obvious = TRUE;
2446
2447                         if (r_ptr->flagsr & RFR_RES_ALL)
2448                         {
2449                                 note = _("には完全な耐性がある!", " is immune.");
2450                                 dam = 0;
2451                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2452                                 break;
2453                         }
2454                         if (!monster_living(m_ptr->r_idx))
2455                         {
2456                                 if (is_original_ap_and_seen(m_ptr))
2457                                 {
2458                                         if (r_ptr->flags3 & RF3_DEMON) r_ptr->r_flags3 |= (RF3_DEMON);
2459                                         if (r_ptr->flags3 & RF3_UNDEAD) r_ptr->r_flags3 |= (RF3_UNDEAD);
2460                                         if (r_ptr->flags3 & RF3_NONLIVING) r_ptr->r_flags3 |= (RF3_NONLIVING);
2461                                 }
2462                                 note = _("には効果がなかった。", " is unaffected.");
2463                                 obvious = FALSE;
2464                                 dam = 0;
2465                         }
2466                         else do_time = (dam+7)/8;
2467
2468                         break;
2469                 }
2470
2471                 /* Death Ray */
2472                 case GF_DEATH_RAY:
2473                 {
2474                         if (seen) obvious = TRUE;
2475
2476                         if (r_ptr->flagsr & RFR_RES_ALL)
2477                         {
2478                                 note = _("には完全な耐性がある!", " is immune.");
2479                                 dam = 0;
2480                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2481                                 break;
2482                         }
2483                         if (!monster_living(m_ptr->r_idx))
2484                         {
2485                                 if (is_original_ap_and_seen(m_ptr))
2486                                 {
2487                                         if (r_ptr->flags3 & RF3_DEMON) r_ptr->r_flags3 |= (RF3_DEMON);
2488                                         if (r_ptr->flags3 & RF3_UNDEAD) r_ptr->r_flags3 |= (RF3_UNDEAD);
2489                                         if (r_ptr->flags3 & RF3_NONLIVING) r_ptr->r_flags3 |= (RF3_NONLIVING);
2490                                 }
2491                                 note = _("には完全な耐性がある!", " is immune.");
2492                                 obvious = FALSE;
2493                                 dam = 0;
2494                         }
2495                         else if (((r_ptr->flags1 & RF1_UNIQUE) &&
2496                                  (randint1(888) != 666)) ||
2497                                  (((r_ptr->level + randint1(20)) > randint1((caster_lev / 2) + randint1(10))) &&
2498                                  randint1(100) != 66))
2499                         {
2500                                 note = _("には耐性がある!", " resists!");
2501                                 obvious = FALSE;
2502                                 dam = 0;
2503                         }
2504
2505                         break;
2506                 }
2507
2508                 /* Polymorph monster (Use "dam" as "power") */
2509                 case GF_OLD_POLY:
2510                 {
2511                         if (seen) obvious = TRUE;
2512
2513                         if (r_ptr->flagsr & RFR_RES_ALL)
2514                         {
2515                                 note = _("には効果がなかった。", " is unaffected.");
2516                                 dam = 0;
2517                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2518                                 break;
2519                         }
2520                         /* Attempt to polymorph (see below) */
2521                         do_poly = TRUE;
2522
2523                         /* Powerful monsters can resist */
2524                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2525                                 (r_ptr->flags1 & RF1_QUESTOR) ||
2526                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2527                         {
2528                                 note = _("には効果がなかった。", " is unaffected.");
2529                                 do_poly = FALSE;
2530                                 obvious = FALSE;
2531                         }
2532
2533                         /* No "real" damage */
2534                         dam = 0;
2535
2536                         break;
2537                 }
2538
2539
2540                 /* Clone monsters (Ignore "dam") */
2541                 case GF_OLD_CLONE:
2542                 {
2543                         if (seen) obvious = TRUE;
2544
2545                         if ((p_ptr->inside_arena) || is_pet(m_ptr) || (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)))
2546                         {
2547                                 note = _("には効果がなかった。", " is unaffected.");
2548                         }
2549                         else
2550                         {
2551                                 /* Heal fully */
2552                                 m_ptr->hp = m_ptr->maxhp;
2553
2554                                 /* Attempt to clone. */
2555                                 if (multiply_monster(c_ptr->m_idx, TRUE, 0L))
2556                                 {
2557                                         note = _("が分裂した!", " spawns!");
2558                                 }
2559                         }
2560
2561                         /* No "real" damage */
2562                         dam = 0;
2563
2564                         break;
2565                 }
2566
2567
2568                 /* Heal Monster (use "dam" as amount of healing) */
2569                 case GF_STAR_HEAL:
2570                 {
2571                         if (seen) obvious = TRUE;
2572
2573                         /* Wake up */
2574                         (void)set_monster_csleep(c_ptr->m_idx, 0);
2575
2576                         if (m_ptr->maxhp < m_ptr->max_maxhp)
2577                         {
2578                                 if (seen_msg) msg_format(_("%^sの強さが戻った。", "%^s recovers %s vitality."), m_name, m_poss);
2579                                 m_ptr->maxhp = m_ptr->max_maxhp;
2580                         }
2581
2582                         if (!dam)
2583                         {
2584                                 /* Redraw (later) if needed */
2585                                 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
2586                                 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
2587                                 break;
2588                         }
2589
2590                         /* Fall through */
2591                 }
2592                 case GF_OLD_HEAL:
2593                 {
2594                         if (seen) obvious = TRUE;
2595
2596                         /* Wake up */
2597                         (void)set_monster_csleep(c_ptr->m_idx, 0);
2598                         if (MON_STUNNED(m_ptr))
2599                         {
2600                                 if (seen_msg) msg_format(_("%^sは朦朧状態から立ち直った。", "%^s is no longer stunned."), m_name);
2601                                 (void)set_monster_stunned(c_ptr->m_idx, 0);
2602                         }
2603                         if (MON_CONFUSED(m_ptr))
2604                         {
2605                                 if (seen_msg) msg_format(_("%^sは混乱から立ち直った。", "%^s is no longer confused."), m_name);
2606                                 (void)set_monster_confused(c_ptr->m_idx, 0);
2607                         }
2608                         if (MON_MONFEAR(m_ptr))
2609                         {
2610                                 if (seen_msg) msg_format(_("%^sは勇気を取り戻した。", "%^s recovers %s courage."), m_name);
2611                                 (void)set_monster_monfear(c_ptr->m_idx, 0);
2612                         }
2613
2614                         /* Heal */
2615                         if (m_ptr->hp < 30000) m_ptr->hp += dam;
2616
2617                         /* No overflow */
2618                         if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
2619
2620                         if (!who)
2621                         {
2622                                 chg_virtue(V_VITALITY, 1);
2623
2624                                 if (r_ptr->flags1 & RF1_UNIQUE)
2625                                         chg_virtue(V_INDIVIDUALISM, 1);
2626
2627                                 if (is_friendly(m_ptr))
2628                                         chg_virtue(V_HONOUR, 1);
2629                                 else if (!(r_ptr->flags3 & RF3_EVIL))
2630                                 {
2631                                         if (r_ptr->flags3 & RF3_GOOD)
2632                                                 chg_virtue(V_COMPASSION, 2);
2633                                         else
2634                                                 chg_virtue(V_COMPASSION, 1);
2635                                 }
2636
2637                                 if (r_ptr->flags3 & RF3_ANIMAL)
2638                                         chg_virtue(V_NATURE, 1);
2639                         }
2640
2641                         if (m_ptr->r_idx == MON_LEPER)
2642                         {
2643                                 heal_leper = TRUE;
2644                                 if (!who) chg_virtue(V_COMPASSION, 5);
2645                         }
2646
2647                         /* Redraw (later) if needed */
2648                         if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
2649                         if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
2650
2651                         note = _("は体力を回復したようだ。", " looks healthier.");
2652
2653                         /* No "real" damage */
2654                         dam = 0;
2655                         break;
2656                 }
2657
2658
2659                 /* Speed Monster (Ignore "dam") */
2660                 case GF_OLD_SPEED:
2661                 {
2662                         if (seen) obvious = TRUE;
2663
2664                         /* Speed up */
2665                         if (set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100))
2666                         {
2667                                 note = _("の動きが速くなった。", " starts moving faster.");
2668                         }
2669
2670                         if (!who)
2671                         {
2672                                 if (r_ptr->flags1 & RF1_UNIQUE)
2673                                         chg_virtue(V_INDIVIDUALISM, 1);
2674                                 if (is_friendly(m_ptr))
2675                                         chg_virtue(V_HONOUR, 1);
2676                         }
2677
2678                         /* No "real" damage */
2679                         dam = 0;
2680                         break;
2681                 }
2682
2683
2684                 /* Slow Monster (Use "dam" as "power") */
2685                 case GF_OLD_SLOW:
2686                 {
2687                         if (seen) obvious = TRUE;
2688
2689                         if (r_ptr->flagsr & RFR_RES_ALL)
2690                         {
2691                                 note = _("には効果がなかった。", " is unaffected.");
2692                                 dam = 0;
2693                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2694                                 break;
2695                         }
2696                         /* Powerful monsters can resist */
2697                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2698                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2699                         {
2700                                 note = _("には効果がなかった。", " is unaffected.");
2701                                 obvious = FALSE;
2702                         }
2703
2704                         /* Normal monsters slow down */
2705                         else
2706                         {
2707                                 if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
2708                                 {
2709                                         note = _("の動きが遅くなった。", " starts moving slower.");
2710                                 }
2711                         }
2712
2713                         /* No "real" damage */
2714                         dam = 0;
2715                         break;
2716                 }
2717
2718
2719                 /* Sleep (Use "dam" as "power") */
2720                 case GF_OLD_SLEEP:
2721                 {
2722                         if (seen) obvious = TRUE;
2723
2724                         if (r_ptr->flagsr & RFR_RES_ALL)
2725                         {
2726                                 note = _("には効果がなかった。", " is unaffected.");
2727                                 dam = 0;
2728                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2729                                 break;
2730                         }
2731                         /* Attempt a saving throw */
2732                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2733                                 (r_ptr->flags3 & RF3_NO_SLEEP) ||
2734                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2735                         {
2736                                 /* Memorize a flag */
2737                                 if (r_ptr->flags3 & RF3_NO_SLEEP)
2738                                 {
2739                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
2740                                 }
2741                                 /* No obvious effect */
2742                                 note = _("には効果がなかった。", " is unaffected.");
2743                                 obvious = FALSE;
2744                         }
2745                         else
2746                         {
2747                                 /* Go to sleep (much) later */
2748                                 note = _("は眠り込んでしまった!", " falls asleep!");
2749                                 do_sleep = 500;
2750                         }
2751
2752                         /* No "real" damage */
2753                         dam = 0;
2754                         break;
2755                 }
2756
2757
2758                 /* Sleep (Use "dam" as "power") */
2759                 case GF_STASIS_EVIL:
2760                 {
2761                         if (seen) obvious = TRUE;
2762
2763                         if (r_ptr->flagsr & RFR_RES_ALL)
2764                         {
2765                                 note = _("には効果がなかった!", " is immune.");
2766                                 dam = 0;
2767                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2768                                 break;
2769                         }
2770                         /* Attempt a saving throw */
2771                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2772                                 !(r_ptr->flags3 & RF3_EVIL) ||
2773                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2774                         {
2775                                 note = _("には効果がなかった。", " is unaffected.");
2776                                 obvious = FALSE;
2777                         }
2778                         else
2779                         {
2780                                 /* Go to sleep (much) later */
2781                                 note = _("は動けなくなった!", " is suspended!");
2782                                 do_sleep = 500;
2783                         }
2784
2785                         /* No "real" damage */
2786                         dam = 0;
2787                         break;
2788                 }
2789
2790                 /* Sleep (Use "dam" as "power") */
2791                 case GF_STASIS:
2792                 {
2793                         if (seen) obvious = TRUE;
2794
2795                         if (r_ptr->flagsr & RFR_RES_ALL)
2796                         {
2797                                 note = _("には効果がなかった。", " is unaffected.");
2798                                 dam = 0;
2799                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2800                                 break;
2801                         }
2802                         /* Attempt a saving throw */
2803                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2804                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2805                         {
2806                                 note = _("には効果がなかった。", " is unaffected.");
2807                                 obvious = FALSE;
2808                         }
2809                         else
2810                         {
2811                                 /* Go to sleep (much) later */
2812                                 note = _("は動けなくなった!", " is suspended!");
2813                                 do_sleep = 500;
2814                         }
2815
2816                         /* No "real" damage */
2817                         dam = 0;
2818                         break;
2819                 }
2820
2821                 /* Charm monster */
2822                 case GF_CHARM:
2823                 {
2824                         int vir;
2825                         vir = virtue_number(V_HARMONY);
2826                         if (vir)
2827                         {
2828                                 dam += p_ptr->virtues[vir-1]/10;
2829                         }
2830
2831                         vir = virtue_number(V_INDIVIDUALISM);
2832                         if (vir)
2833                         {
2834                                 dam -= p_ptr->virtues[vir-1]/20;
2835                         }
2836
2837                         if (seen) obvious = TRUE;
2838
2839                         /* Attempt a saving throw */
2840                         if (common_saving_throw_charm(p_ptr, dam, m_ptr))
2841                         {
2842
2843                                 /* Resist */
2844                                 /* No obvious effect */
2845                                 note = _("には効果がなかった。", " is unaffected.");
2846                                 obvious = FALSE;
2847
2848                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2849                         }
2850                         else if (p_ptr->cursed & TRC_AGGRAVATE)
2851                         {
2852                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2853                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2854                         }
2855                         else
2856                         {
2857                                 note = _("は突然友好的になったようだ!", " suddenly seems friendly!");
2858                                 set_pet(m_ptr);
2859
2860                                 chg_virtue(V_INDIVIDUALISM, -1);
2861                                 if (r_ptr->flags3 & RF3_ANIMAL)
2862                                         chg_virtue(V_NATURE, 1);
2863                         }
2864
2865                         /* No "real" damage */
2866                         dam = 0;
2867                         break;
2868                 }
2869
2870                 /* Control undead */
2871                 case GF_CONTROL_UNDEAD:
2872                 {
2873                         int vir;
2874                         if (seen) obvious = TRUE;
2875
2876                         vir = virtue_number(V_UNLIFE);
2877                         if (vir)
2878                         {
2879                                 dam += p_ptr->virtues[vir-1]/10;
2880                         }
2881
2882                         vir = virtue_number(V_INDIVIDUALISM);
2883                         if (vir)
2884                         {
2885                                 dam -= p_ptr->virtues[vir-1]/20;
2886                         }
2887
2888                         /* Attempt a saving throw */
2889                         if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
2890                                 !(r_ptr->flags3 & RF3_UNDEAD))
2891                         {
2892                                 /* No obvious effect */
2893                                 note = _("には効果がなかった。", " is unaffected.");
2894                                 obvious = FALSE;
2895                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2896                         }
2897                         else if (p_ptr->cursed & TRC_AGGRAVATE)
2898                         {
2899                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2900                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2901                         }
2902                         else
2903                         {
2904                                 note = _("は既にあなたの奴隷だ!", " is in your thrall!");
2905                                 set_pet(m_ptr);
2906                         }
2907
2908                         /* No "real" damage */
2909                         dam = 0;
2910                         break;
2911                 }
2912
2913                 /* Control demon */
2914                 case GF_CONTROL_DEMON:
2915                 {
2916                         int vir;
2917                         if (seen) obvious = TRUE;
2918
2919                         vir = virtue_number(V_UNLIFE);
2920                         if (vir)
2921                         {
2922                                 dam += p_ptr->virtues[vir-1]/10;
2923                         }
2924
2925                         vir = virtue_number(V_INDIVIDUALISM);
2926                         if (vir)
2927                         {
2928                                 dam -= p_ptr->virtues[vir-1]/20;
2929                         }
2930
2931                         /* Attempt a saving throw */
2932                         if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
2933                                 !(r_ptr->flags3 & RF3_DEMON))
2934                         {
2935                                 /* No obvious effect */
2936                                 note = _("には効果がなかった。", " is unaffected.");
2937                                 obvious = FALSE;
2938                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2939                         }
2940                         else if (p_ptr->cursed & TRC_AGGRAVATE)
2941                         {
2942                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2943                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2944                         }
2945                         else
2946                         {
2947                                 note = _("は既にあなたの奴隷だ!", " is in your thrall!");
2948                                 set_pet(m_ptr);
2949                         }
2950
2951                         /* No "real" damage */
2952                         dam = 0;
2953                         break;
2954                 }
2955
2956                 /* Tame animal */
2957                 case GF_CONTROL_ANIMAL:
2958                 {
2959                         int vir;
2960                         if (seen) obvious = TRUE;
2961
2962                         vir = virtue_number(V_NATURE);
2963                         if (vir)
2964                         {
2965                                 dam += p_ptr->virtues[vir-1]/10;
2966                         }
2967
2968                         vir = virtue_number(V_INDIVIDUALISM);
2969                         if (vir)
2970                         {
2971                                 dam -= p_ptr->virtues[vir-1]/20;
2972                         }
2973
2974                         /* Attempt a saving throw */
2975                         if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
2976                                 !(r_ptr->flags3 & RF3_ANIMAL))
2977                         {
2978                                 /* Resist */
2979                                 /* No obvious effect */
2980                                 note = _("には効果がなかった。", " is unaffected.");
2981                                 obvious = FALSE;
2982                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2983                         }
2984                         else if (p_ptr->cursed & TRC_AGGRAVATE)
2985                         {
2986                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
2987                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
2988                         }
2989                         else
2990                         {
2991                                 note = _("はなついた。", " is tamed!");
2992                                 set_pet(m_ptr);
2993                                 if (r_ptr->flags3 & RF3_ANIMAL)
2994                                         chg_virtue(V_NATURE, 1);
2995                         }
2996
2997                         /* No "real" damage */
2998                         dam = 0;
2999                         break;
3000                 }
3001
3002                 /* Tame animal */
3003                 case GF_CHARM_LIVING:
3004                 {
3005                         int vir;
3006
3007                         vir = virtue_number(V_UNLIFE);
3008                         if (seen) obvious = TRUE;
3009
3010                         vir = virtue_number(V_UNLIFE);
3011                         if (vir)
3012                         {
3013                                 dam -= p_ptr->virtues[vir-1]/10;
3014                         }
3015
3016                         vir = virtue_number(V_INDIVIDUALISM);
3017                         if (vir)
3018                         {
3019                                 dam -= p_ptr->virtues[vir-1]/20;
3020                         }
3021
3022                         msg_format(_("%sを見つめた。", "You stare into %s."), m_name);
3023
3024                         /* Attempt a saving throw */
3025                         if (common_saving_throw_charm(p_ptr, dam, m_ptr) ||
3026                                 !monster_living(m_ptr->r_idx))
3027                         {
3028                                 /* Resist */
3029                                 /* No obvious effect */
3030                                 note = _("には効果がなかった。", " is unaffected.");
3031                                 obvious = FALSE;
3032                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3033                         }
3034                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3035                         {
3036                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
3037                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3038                         }
3039                         else
3040                         {
3041                                 note = _("を支配した。", " is tamed!");
3042                                 set_pet(m_ptr);
3043                                 if (r_ptr->flags3 & RF3_ANIMAL)
3044                                         chg_virtue(V_NATURE, 1);
3045                         }
3046
3047                         /* No "real" damage */
3048                         dam = 0;
3049                         break;
3050                 }
3051
3052                 /* Confusion (Use "dam" as "power") */
3053                 case GF_OLD_CONF:
3054                 {
3055                         if (seen) obvious = TRUE;
3056
3057                         if (r_ptr->flagsr & RFR_RES_ALL)
3058                         {
3059                                 note = _("には効果がなかった。", " is unaffected.");
3060                                 dam = 0;
3061                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3062                                 break;
3063                         }
3064                         /* Get confused later */
3065                         do_conf = damroll(3, (dam / 2)) + 1;
3066
3067                         /* Attempt a saving throw */
3068                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
3069                                 (r_ptr->flags3 & (RF3_NO_CONF)) ||
3070                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3071                         {
3072                                 /* Memorize a flag */
3073                                 if (r_ptr->flags3 & (RF3_NO_CONF))
3074                                 {
3075                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3076                                 }
3077
3078                                 /* Resist */
3079                                 do_conf = 0;
3080
3081                                 /* No obvious effect */
3082                                 note = _("には効果がなかった。", " is unaffected.");
3083                                 obvious = FALSE;
3084                         }
3085
3086                         /* No "real" damage */
3087                         dam = 0;
3088                         break;
3089                 }
3090
3091                 case GF_STUN:
3092                 {
3093                         if (seen) obvious = TRUE;
3094
3095                         if (r_ptr->flagsr & RFR_RES_ALL)
3096                         {
3097                                 note = _("には効果がなかった。", " is unaffected.");
3098                                 dam = 0;
3099                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3100                                 break;
3101                         }
3102                         do_stun = damroll((caster_lev / 20) + 3 , (dam)) + 1;
3103
3104                         /* Attempt a saving throw */
3105                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
3106                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3107                         {
3108                                 /* Resist */
3109                                 do_stun = 0;
3110
3111                                 /* No obvious effect */
3112                                 note = _("には効果がなかった。", " is unaffected.");
3113                                 obvious = FALSE;
3114                         }
3115
3116                         /* No "real" damage */
3117                         dam = 0;
3118                         break;
3119                 }
3120
3121
3122
3123
3124                 /* Lite, but only hurts susceptible creatures */
3125                 case GF_LITE_WEAK:
3126                 {
3127                         if (!dam)
3128                         {
3129                                 skipped = TRUE;
3130                                 break;
3131                         }
3132                         if (r_ptr->flagsr & RFR_RES_ALL)
3133                         {
3134                                 dam = 0;
3135                                 break;
3136                         }
3137                         /* Hurt by light */
3138                         if (r_ptr->flags3 & (RF3_HURT_LITE))
3139                         {
3140                                 /* Obvious effect */
3141                                 if (seen) obvious = TRUE;
3142
3143                                 /* Memorize the effects */
3144                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
3145
3146                                 /* Special effect */
3147                                 note = _("は光に身をすくめた!", " cringes from the light!");
3148                                 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
3149                         }
3150
3151                         /* Normally no damage */
3152                         else
3153                         {
3154                                 /* No damage */
3155                                 dam = 0;
3156                         }
3157
3158                         break;
3159                 }
3160
3161
3162
3163                 /* Lite -- opposite of Dark */
3164                 case GF_LITE:
3165                 {
3166                         if (seen) obvious = TRUE;
3167
3168                         if (r_ptr->flagsr & RFR_RES_ALL)
3169                         {
3170                                 note = _("には完全な耐性がある!", " is immune.");
3171                                 dam = 0;
3172                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3173                                 break;
3174                         }
3175                         if (r_ptr->flagsr & RFR_RES_LITE)
3176                         {
3177                                 note = _("には耐性がある!", " resists!");
3178                                 dam *= 2; dam /= (randint1(6)+6);
3179                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_LITE);
3180                         }
3181                         else if (r_ptr->flags3 & (RF3_HURT_LITE))
3182                         {
3183                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
3184                                 note = _("は光に身をすくめた!", " cringes from the light!");
3185                                 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
3186                                 dam *= 2;
3187                         }
3188                         break;
3189                 }
3190
3191
3192                 /* Dark -- opposite of Lite */
3193                 case GF_DARK:
3194                 {
3195                         if (seen) obvious = TRUE;
3196
3197                         if (r_ptr->flagsr & RFR_RES_ALL)
3198                         {
3199                                 note = _("には完全な耐性がある!", " is immune.");
3200                                 dam = 0;
3201                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3202                                 break;
3203                         }
3204                         if (r_ptr->flagsr & RFR_RES_DARK)
3205                         {
3206                                 note = _("には耐性がある!", " resists!");
3207                                 dam *= 2; dam /= (randint1(6)+6);
3208                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_DARK);
3209                         }
3210                         break;
3211                 }
3212
3213
3214                 /* Stone to Mud */
3215                 case GF_KILL_WALL:
3216                 {
3217                         if (r_ptr->flagsr & RFR_RES_ALL)
3218                         {
3219                                 dam = 0;
3220                                 break;
3221                         }
3222                         /* Hurt by rock remover */
3223                         if (r_ptr->flags3 & (RF3_HURT_ROCK))
3224                         {
3225                                 /* Notice effect */
3226                                 if (seen) obvious = TRUE;
3227
3228                                 /* Memorize the effects */
3229                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
3230
3231                                 /* Cute little message */
3232                                 note = _("の皮膚がただれた!", " loses some skin!");
3233                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3234                         }
3235
3236                         /* Usually, ignore the effects */
3237                         else
3238                         {
3239                                 /* No damage */
3240                                 dam = 0;
3241                         }
3242
3243                         break;
3244                 }
3245
3246
3247                 /* Teleport undead (Use "dam" as "power") */
3248                 case GF_AWAY_UNDEAD:
3249                 {
3250                         /* Only affect undead */
3251                         if (r_ptr->flags3 & (RF3_UNDEAD))
3252                         {
3253                                 bool resists_tele = FALSE;
3254
3255                                 if (r_ptr->flagsr & RFR_RES_TELE)
3256                                 {
3257                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
3258                                         {
3259                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3260                                                 note = _("には効果がなかった。", " is unaffected.");
3261                                                 resists_tele = TRUE;
3262                                         }
3263                                         else if (r_ptr->level > randint1(100))
3264                                         {
3265                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3266                                                 note = _("には耐性がある!", " resists!");
3267                                                 resists_tele = TRUE;
3268                                         }
3269                                 }
3270
3271                                 if (!resists_tele)
3272                                 {
3273                                         if (seen) obvious = TRUE;
3274                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
3275                                         do_dist = dam;
3276                                 }
3277                         }
3278
3279                         /* Others ignore */
3280                         else
3281                         {
3282                                 /* Irrelevant */
3283                                 skipped = TRUE;
3284                         }
3285
3286                         /* No "real" damage */
3287                         dam = 0;
3288                         break;
3289                 }
3290
3291
3292                 /* Teleport evil (Use "dam" as "power") */
3293                 case GF_AWAY_EVIL:
3294                 {
3295                         /* Only affect evil */
3296                         if (r_ptr->flags3 & (RF3_EVIL))
3297                         {
3298                                 bool resists_tele = FALSE;
3299
3300                                 if (r_ptr->flagsr & RFR_RES_TELE)
3301                                 {
3302                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
3303                                         {
3304                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3305                                                 note = _("には効果がなかった。", " is unaffected.");
3306                                                 resists_tele = TRUE;
3307                                         }
3308                                         else if (r_ptr->level > randint1(100))
3309                                         {
3310                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3311                                                 note = _("には耐性がある!", " resists!");
3312                                                 resists_tele = TRUE;
3313                                         }
3314                                 }
3315
3316                                 if (!resists_tele)
3317                                 {
3318                                         if (seen) obvious = TRUE;
3319                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
3320                                         do_dist = dam;
3321                                 }
3322                         }
3323
3324                         /* Others ignore */
3325                         else
3326                         {
3327                                 /* Irrelevant */
3328                                 skipped = TRUE;
3329                         }
3330
3331                         /* No "real" damage */
3332                         dam = 0;
3333                         break;
3334                 }
3335
3336
3337                 /* Teleport monster (Use "dam" as "power") */
3338                 case GF_AWAY_ALL:
3339                 {
3340                         bool resists_tele = FALSE;
3341                         if (r_ptr->flagsr & RFR_RES_TELE)
3342                         {
3343                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
3344                                 {
3345                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3346                                         note = _("には効果がなかった。", " is unaffected.");
3347                                         resists_tele = TRUE;
3348                                 }
3349                                 else if (r_ptr->level > randint1(100))
3350                                 {
3351                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3352                                         note = _("には耐性がある!", " resists!");
3353                                         resists_tele = TRUE;
3354                                 }
3355                         }
3356
3357                         if (!resists_tele)
3358                         {
3359                                 if (seen) obvious = TRUE;
3360
3361                                 /* Prepare to teleport */
3362                                 do_dist = dam;
3363                         }
3364
3365                         /* No "real" damage */
3366                         dam = 0;
3367                         break;
3368                 }
3369
3370
3371                 /* Turn undead (Use "dam" as "power") */
3372                 case GF_TURN_UNDEAD:
3373                 {
3374                         if (r_ptr->flagsr & RFR_RES_ALL)
3375                         {
3376                                 skipped = TRUE;
3377                                 break;
3378                         }
3379                         /* Only affect undead */
3380                         if (r_ptr->flags3 & (RF3_UNDEAD))
3381                         {
3382                                 if (seen) obvious = TRUE;
3383
3384                                 /* Learn about type */
3385                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
3386
3387                                 /* Apply some fear */
3388                                 do_fear = damroll(3, (dam / 2)) + 1;
3389
3390                                 /* Attempt a saving throw */
3391                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
3392                                 {
3393                                         /* No obvious effect */
3394                                         note = _("には効果がなかった。", " is unaffected.");
3395                                         obvious = FALSE;
3396                                         do_fear = 0;
3397                                 }
3398                         }
3399
3400                         /* Others ignore */
3401                         else
3402                         {
3403                                 /* Irrelevant */
3404                                 skipped = TRUE;
3405                         }
3406
3407                         /* No "real" damage */
3408                         dam = 0;
3409                         break;
3410                 }
3411
3412
3413                 /* Turn evil (Use "dam" as "power") */
3414                 case GF_TURN_EVIL:
3415                 {
3416                         if (r_ptr->flagsr & RFR_RES_ALL)
3417                         {
3418                                 skipped = TRUE;
3419                                 break;
3420                         }
3421                         /* Only affect evil */
3422                         if (r_ptr->flags3 & (RF3_EVIL))
3423                         {
3424                                 if (seen) obvious = TRUE;
3425
3426                                 /* Learn about type */
3427                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
3428
3429                                 /* Apply some fear */
3430                                 do_fear = damroll(3, (dam / 2)) + 1;
3431
3432                                 /* Attempt a saving throw */
3433                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
3434                                 {
3435                                         /* No obvious effect */
3436                                         note = _("には効果がなかった。", " is unaffected.");
3437                                         obvious = FALSE;
3438                                         do_fear = 0;
3439                                 }
3440                         }
3441
3442                         /* Others ignore */
3443                         else
3444                         {
3445                                 /* Irrelevant */
3446                                 skipped = TRUE;
3447                         }
3448
3449                         /* No "real" damage */
3450                         dam = 0;
3451                         break;
3452                 }
3453
3454
3455                 /* Turn monster (Use "dam" as "power") */
3456                 case GF_TURN_ALL:
3457                 {
3458                         if (r_ptr->flagsr & RFR_RES_ALL)
3459                         {
3460                                 skipped = TRUE;
3461                                 break;
3462                         }
3463                         if (seen) obvious = TRUE;
3464
3465                         /* Apply some fear */
3466                         do_fear = damroll(3, (dam / 2)) + 1;
3467
3468                         /* Attempt a saving throw */
3469                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
3470                                 (r_ptr->flags3 & (RF3_NO_FEAR)) ||
3471                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3472                         {
3473                                 /* No obvious effect */
3474                                 note = _("には効果がなかった。", " is unaffected.");
3475                                 obvious = FALSE;
3476                                 do_fear = 0;
3477                         }
3478
3479                         /* No "real" damage */
3480                         dam = 0;
3481                         break;
3482                 }
3483
3484
3485                 /* Dispel undead */
3486                 case GF_DISP_UNDEAD:
3487                 {
3488                         if (r_ptr->flagsr & RFR_RES_ALL)
3489                         {
3490                                 skipped = TRUE;
3491                                 dam = 0;
3492                                 break;
3493                         }
3494                         /* Only affect undead */
3495                         if (r_ptr->flags3 & (RF3_UNDEAD))
3496                         {
3497                                 if (seen) obvious = TRUE;
3498
3499                                 /* Learn about type */
3500                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
3501
3502                                 note = _("は身震いした。", " shudders.");
3503                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3504                         }
3505
3506                         /* Others ignore */
3507                         else
3508                         {
3509                                 /* Irrelevant */
3510                                 skipped = TRUE;
3511
3512                                 /* No damage */
3513                                 dam = 0;
3514                         }
3515
3516                         break;
3517                 }
3518
3519
3520                 /* Dispel evil */
3521                 case GF_DISP_EVIL:
3522                 {
3523                         if (r_ptr->flagsr & RFR_RES_ALL)
3524                         {
3525                                 skipped = TRUE;
3526                                 dam = 0;
3527                                 break;
3528                         }
3529                         /* Only affect evil */
3530                         if (r_ptr->flags3 & (RF3_EVIL))
3531                         {
3532                                 if (seen) obvious = TRUE;
3533
3534                                 /* Learn about type */
3535                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
3536
3537                                 note = _("は身震いした。", " shudders.");
3538                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3539                         }
3540
3541                         /* Others ignore */
3542                         else
3543                         {
3544                                 /* Irrelevant */
3545                                 skipped = TRUE;
3546
3547                                 /* No damage */
3548                                 dam = 0;
3549                         }
3550
3551                         break;
3552                 }
3553
3554                 /* Dispel good */
3555                 case GF_DISP_GOOD:
3556                 {
3557                         if (r_ptr->flagsr & RFR_RES_ALL)
3558                         {
3559                                 skipped = TRUE;
3560                                 dam = 0;
3561                                 break;
3562                         }
3563                         /* Only affect good */
3564                         if (r_ptr->flags3 & (RF3_GOOD))
3565                         {
3566                                 if (seen) obvious = TRUE;
3567
3568                                 /* Learn about type */
3569                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
3570
3571                                 note = _("は身震いした。", " shudders.");
3572                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3573                         }
3574
3575                         /* Others ignore */
3576                         else
3577                         {
3578                                 /* Irrelevant */
3579                                 skipped = TRUE;
3580
3581                                 /* No damage */
3582                                 dam = 0;
3583                         }
3584
3585                         break;
3586                 }
3587
3588                 /* Dispel living */
3589                 case GF_DISP_LIVING:
3590                 {
3591                         if (r_ptr->flagsr & RFR_RES_ALL)
3592                         {
3593                                 skipped = TRUE;
3594                                 dam = 0;
3595                                 break;
3596                         }
3597                         /* Only affect non-undead */
3598                         if (monster_living(m_ptr->r_idx))
3599                         {
3600                                 if (seen) obvious = TRUE;
3601
3602                                 note = _("は身震いした。", " shudders.");
3603                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3604                         }
3605
3606                         /* Others ignore */
3607                         else
3608                         {
3609                                 /* Irrelevant */
3610                                 skipped = TRUE;
3611
3612                                 /* No damage */
3613                                 dam = 0;
3614                         }
3615
3616                         break;
3617                 }
3618
3619                 /* Dispel demons */
3620                 case GF_DISP_DEMON:
3621                 {
3622                         if (r_ptr->flagsr & RFR_RES_ALL)
3623                         {
3624                                 skipped = TRUE;
3625                                 dam = 0;
3626                                 break;
3627                         }
3628                         /* Only affect demons */
3629                         if (r_ptr->flags3 & (RF3_DEMON))
3630                         {
3631                                 if (seen) obvious = TRUE;
3632
3633                                 /* Learn about type */
3634                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
3635
3636                                 note = _("は身震いした。", " shudders.");
3637                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3638                         }
3639
3640                         /* Others ignore */
3641                         else
3642                         {
3643                                 /* Irrelevant */
3644                                 skipped = TRUE;
3645
3646                                 /* No damage */
3647                                 dam = 0;
3648                         }
3649
3650                         break;
3651                 }
3652
3653                 /* Dispel monster */
3654                 case GF_DISP_ALL:
3655                 {
3656                         if (r_ptr->flagsr & RFR_RES_ALL)
3657                         {
3658                                 skipped = TRUE;
3659                                 dam = 0;
3660                                 break;
3661                         }
3662                         if (seen) obvious = TRUE;
3663
3664                         note = _("は身震いした。", " shudders.");
3665                         note_dies = _("はドロドロに溶けた!", " dissolves!");
3666                         break;
3667                 }
3668
3669                 /* Drain mana */
3670                 case GF_DRAIN_MANA:
3671                 {
3672                         if (seen) obvious = TRUE;
3673
3674                         if (r_ptr->flagsr & RFR_RES_ALL)
3675                         {
3676                                 note = _("には完全な耐性がある!", " is immune.");
3677                                 skipped = TRUE;
3678                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3679                                 break;
3680                         }
3681
3682                         if ((r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) || (r_ptr->a_ability_flags1 & ~(RF5_NOMAGIC_MASK)) || (r_ptr->a_ability_flags2 & ~(RF6_NOMAGIC_MASK)))
3683                         {
3684                                 if (who > 0)
3685                                 {
3686                                         /* Heal the monster */
3687                                         if (caster_ptr->hp < caster_ptr->maxhp)
3688                                         {
3689                                                 /* Heal */
3690                                                 caster_ptr->hp += dam;
3691                                                 if (caster_ptr->hp > caster_ptr->maxhp) caster_ptr->hp = caster_ptr->maxhp;
3692
3693                                                 /* Redraw (later) if needed */
3694                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
3695                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
3696
3697                                                 /* Special message */
3698                                                 if (see_s_msg)
3699                                                 {
3700                                                         monster_desc(killer, caster_ptr, 0);
3701                                                         msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), killer);
3702                                                 }
3703                                         }
3704                                 }
3705                                 else
3706                                 {
3707                                         msg_format(_("%sから精神エネルギーを吸いとった。", "You draw psychic energy from %s."), m_name);
3708                                         (void)hp_player(dam);
3709                                 }
3710                         }
3711                         else
3712                         {
3713                                 if (see_s_msg) msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
3714                         }
3715                         dam = 0;
3716                         break;
3717                 }
3718
3719                 /* Mind blast */
3720                 case GF_MIND_BLAST:
3721                 {
3722                         if (seen) obvious = TRUE;
3723                         if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
3724
3725                         if (r_ptr->flagsr & RFR_RES_ALL)
3726                         {
3727                                 note = _("には完全な耐性がある!", " is immune.");
3728                                 skipped = TRUE;
3729                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3730                                 break;
3731                         }
3732
3733                         /* Attempt a saving throw */
3734                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3735                                  (r_ptr->flags3 & RF3_NO_CONF) ||
3736                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
3737                         {
3738                                 /* Memorize a flag */
3739                                 if (r_ptr->flags3 & (RF3_NO_CONF))
3740                                 {
3741                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3742                                 }
3743                                 note = _("には効果がなかった。", " is unaffected.");
3744                                 dam = 0;
3745                         }
3746                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
3747                         {
3748                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
3749                                 note = _("には完全な耐性がある!", " is immune.");
3750                                 dam = 0;
3751                         }
3752                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
3753                         {
3754                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
3755                                 note = _("には耐性がある。", " resists.");
3756                                 dam /= 3;
3757                         }
3758                         else
3759                         {
3760                                 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
3761                                 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
3762
3763                                 if (who > 0) do_conf = randint0(4) + 4;
3764                                 else do_conf = randint0(8) + 8;
3765                         }
3766                         break;
3767                 }
3768
3769                 /* Brain smash */
3770                 case GF_BRAIN_SMASH:
3771                 {
3772                         if (seen) obvious = TRUE;
3773                         if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
3774
3775                         if (r_ptr->flagsr & RFR_RES_ALL)
3776                         {
3777                                 note = _("には完全な耐性がある!", " is immune.");
3778                                 skipped = TRUE;
3779                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3780                                 break;
3781                         }
3782
3783                         /* Attempt a saving throw */
3784                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3785                                  (r_ptr->flags3 & RF3_NO_CONF) ||
3786                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
3787                         {
3788                                 /* Memorize a flag */
3789                                 if (r_ptr->flags3 & (RF3_NO_CONF))
3790                                 {
3791                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3792                                 }
3793                                 note = _("には効果がなかった。", " is unaffected.");
3794                                 dam = 0;
3795                         }
3796                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
3797                         {
3798                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
3799                                 note = _("には完全な耐性がある!", " is immune.");
3800                                 dam = 0;
3801                         }
3802                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
3803                         {
3804                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
3805                                 note = _("には耐性がある!", " resists!");
3806                                 dam /= 3;
3807                         }
3808                         else
3809                         {
3810                                 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
3811                                 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
3812
3813                                 if (who > 0)
3814                                 {
3815                                         do_conf = randint0(4) + 4;
3816                                         do_stun = randint0(4) + 4;
3817                                 }
3818                                 else
3819                                 {
3820                                         do_conf = randint0(8) + 8;
3821                                         do_stun = randint0(8) + 8;
3822                                 }
3823                                 (void)set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 10);
3824                         }
3825                         break;
3826                 }
3827
3828                 /* CAUSE_1 */
3829                 case GF_CAUSE_1:
3830                 {
3831                         if (seen) obvious = TRUE;
3832                         if (!who) msg_format(_("%sを指差して呪いをかけた。", "You point at %s and curse."), m_name);
3833
3834                         if (r_ptr->flagsr & RFR_RES_ALL)
3835                         {
3836                                 note = _("には完全な耐性がある!", " is immune.");
3837                                 skipped = TRUE;
3838                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3839                                 break;
3840                         }
3841
3842                         /* Attempt a saving throw */
3843                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
3844                         {
3845                                 note = _("には効果がなかった。", " is unaffected.");
3846                                 dam = 0;
3847                         }
3848                         break;
3849                 }
3850
3851                 /* CAUSE_2 */
3852                 case GF_CAUSE_2:
3853                 {
3854                         if (seen) obvious = TRUE;
3855                         if (!who) msg_format(_("%sを指差して恐ろしげに呪いをかけた。", "You point at %s and curse horribly."), m_name);
3856
3857                         if (r_ptr->flagsr & RFR_RES_ALL)
3858                         {
3859                                 note = _("には完全な耐性がある!", " is immune.");
3860                                 skipped = TRUE;
3861                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3862                                 break;
3863                         }
3864
3865                         /* Attempt a saving throw */
3866                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
3867                         {
3868                                 note = _("には効果がなかった。", " is unaffected.");
3869                                 dam = 0;
3870                         }
3871                         break;
3872                 }
3873
3874                 /* CAUSE_3 */
3875                 case GF_CAUSE_3:
3876                 {
3877                         if (seen) obvious = TRUE;
3878                         if (!who) msg_format(_("%sを指差し、恐ろしげに呪文を唱えた!", "You point at %s, incanting terribly!"), m_name);
3879
3880                         if (r_ptr->flagsr & RFR_RES_ALL)
3881                         {
3882                                 note = _("には完全な耐性がある!", " is immune.");
3883                                 skipped = TRUE;
3884                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3885                                 break;
3886                         }
3887
3888                         /* Attempt a saving throw */
3889                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
3890                         {
3891                                 note = _("には効果がなかった。", " is unaffected.");
3892                                 dam = 0;
3893                         }
3894                         break;
3895                 }
3896
3897                 /* CAUSE_4 */
3898                 case GF_CAUSE_4:
3899                 {
3900                         if (seen) obvious = TRUE;
3901                         if (!who) 
3902                                 msg_format(_("%sの秘孔を突いて、「お前は既に死んでいる」と叫んだ。", 
3903                                                          "You point at %s, screaming the word, 'DIE!'."), m_name);
3904
3905                         if (r_ptr->flagsr & RFR_RES_ALL)
3906                         {
3907                                 note = _("には完全な耐性がある!", " is immune.");
3908                                 skipped = TRUE;
3909                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3910                                 break;
3911                         }
3912
3913                         /* Attempt a saving throw */
3914                         if ((randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35)) && ((who <= 0) || (caster_ptr->r_idx != MON_KENSHIROU)))
3915                         {
3916                                 note = _("には効果がなかった。", " is unaffected.");
3917                                 dam = 0;
3918                         }
3919                         break;
3920                 }
3921
3922                 /* HAND_DOOM */
3923                 case GF_HAND_DOOM:
3924                 {
3925                         if (seen) obvious = TRUE;
3926
3927                         if (r_ptr->flagsr & RFR_RES_ALL)
3928                         {
3929                                 note = _("には完全な耐性がある!", " is immune.");
3930                                 skipped = TRUE;
3931                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3932                                 break;
3933                         }
3934
3935                         if (r_ptr->flags1 & RF1_UNIQUE)
3936                         {
3937                                 note = _("には効果がなかった。", " is unaffected.");
3938                                 dam = 0;
3939                         }
3940                         else
3941                         {
3942                                 if ((who > 0) ? ((caster_lev + randint1(dam)) > (r_ptr->level + 10 + randint1(20))) :
3943                                    (((caster_lev / 2) + randint1(dam)) > (r_ptr->level + randint1(200))))
3944                                 {
3945                                         dam = ((40 + randint1(20)) * m_ptr->hp) / 100;
3946
3947                                         if (m_ptr->hp < dam) dam = m_ptr->hp - 1;
3948                                 }
3949                                 else
3950                                 {
3951                                         note = _("は耐性を持っている!", "resists!");
3952                                         dam = 0;
3953                                 }
3954                         }
3955                         break;
3956                 }
3957
3958                 /* Capture monster */
3959                 case GF_CAPTURE:
3960                 {
3961                         int nokori_hp;
3962                         if ((p_ptr->inside_quest && (quest[p_ptr->inside_quest].type == QUEST_TYPE_KILL_ALL) && !is_pet(m_ptr)) ||
3963                                 (r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_NAZGUL)) || (r_ptr->flags7 & (RF7_UNIQUE2)) || (r_ptr->flags1 & RF1_QUESTOR) || m_ptr->parent_m_idx)
3964                         {
3965                                 msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
3966                                 skipped = TRUE;
3967                                 break;
3968                         }
3969
3970                         if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp * 4L;
3971                         else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(m_ptr->r_idx))
3972                                 nokori_hp = m_ptr->maxhp * 3 / 10;
3973                         else
3974                                 nokori_hp = m_ptr->maxhp * 3 / 20;
3975
3976                         if (m_ptr->hp >= nokori_hp)
3977                         {
3978                                 msg_format(_("もっと弱らせないと。", "You need to weaken %s more."), m_name);
3979                                 skipped = TRUE;
3980                         }
3981                         else if (m_ptr->hp < randint0(nokori_hp))
3982                         {
3983                                 if (m_ptr->mflag2 & MFLAG2_CHAMELEON) choose_new_monster(c_ptr->m_idx, FALSE, MON_CHAMELEON);
3984                                 msg_format(_("%sを捕えた!", "You capture %^s!"), m_name);
3985                                 cap_mon = m_ptr->r_idx;
3986                                 cap_mspeed = m_ptr->mspeed;
3987                                 cap_hp = m_ptr->hp;
3988                                 cap_maxhp = m_ptr->max_maxhp;
3989                                 cap_nickname = m_ptr->nickname; /* Quark transfer */
3990                                 if (c_ptr->m_idx == p_ptr->riding)
3991                                 {
3992                                         if (rakuba(-1, FALSE))
3993                                         {
3994                                                 msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
3995                                         }
3996                                 }
3997
3998                                 delete_monster_idx(c_ptr->m_idx);
3999
4000                                 return (TRUE);
4001                         }
4002                         else
4003                         {
4004                                 msg_format(_("うまく捕まえられなかった。", "You failed to capture %s."), m_name);
4005                                 skipped = TRUE;
4006                         }
4007                         break;
4008                 }
4009
4010                 /* Attack (Use "dam" as attack type) */
4011                 case GF_ATTACK:
4012                 {
4013                         /* Return this monster's death */
4014                         return py_attack(y, x, dam);
4015                 }
4016
4017                 /* Sleep (Use "dam" as "power") */
4018                 case GF_ENGETSU:
4019                 {
4020                         int effect = 0;
4021                         bool done = TRUE;
4022
4023                         if (seen) obvious = TRUE;
4024
4025                         if (r_ptr->flagsr & RFR_RES_ALL)
4026                         {
4027                                 note = _("には効果がなかった。", " is unaffected.");
4028                                 dam = 0;
4029                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4030                                 break;
4031                         }
4032                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
4033                         {
4034                                 note = _("には効果がなかった。", " is unaffected.");
4035                                 dam = 0;
4036                                 skipped = TRUE;
4037                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
4038                                 break;
4039                         }
4040                         if (MON_CSLEEP(m_ptr))
4041                         {
4042                                 note = _("には効果がなかった。", " is unaffected.");
4043                                 dam = 0;
4044                                 skipped = TRUE;
4045                                 break;
4046                         }
4047
4048                         if (one_in_(5)) effect = 1;
4049                         else if (one_in_(4)) effect = 2;
4050                         else if (one_in_(3)) effect = 3;
4051                         else done = FALSE;
4052
4053                         if (effect == 1)
4054                         {
4055                                 /* Powerful monsters can resist */
4056                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4057                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4058                                 {
4059                                         note = _("には効果がなかった。", " is unaffected.");
4060                                         obvious = FALSE;
4061                                 }
4062
4063                                 /* Normal monsters slow down */
4064                                 else
4065                                 {
4066                                         if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
4067                                         {
4068                                                 note = _("の動きが遅くなった。", " starts moving slower.");
4069                                         }
4070                                 }
4071                         }
4072
4073                         else if (effect == 2)
4074                         {
4075                                 do_stun = damroll((p_ptr->lev / 10) + 3 , (dam)) + 1;
4076
4077                                 /* Attempt a saving throw */
4078                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4079                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4080                                 {
4081                                         /* Resist */
4082                                         do_stun = 0;
4083
4084                                         /* No obvious effect */
4085                                         note = _("には効果がなかった。", " is unaffected.");
4086                                         obvious = FALSE;
4087                                 }
4088                         }
4089
4090                         else if (effect == 3)
4091                         {
4092                                 /* Attempt a saving throw */
4093                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4094                                         (r_ptr->flags3 & RF3_NO_SLEEP) ||
4095                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4096                                 {
4097                                         /* Memorize a flag */
4098                                         if (r_ptr->flags3 & RF3_NO_SLEEP)
4099                                         {
4100                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
4101                                         }
4102
4103                                         /* No obvious effect */
4104                                         note = _("には効果がなかった。", " is unaffected.");
4105                                         obvious = FALSE;
4106                                 }
4107                                 else
4108                                 {
4109                                         /* Go to sleep (much) later */
4110                                         note = _("は眠り込んでしまった!", " falls asleep!");
4111                                         do_sleep = 500;
4112                                 }
4113                         }
4114
4115                         if (!done)
4116                         {
4117                                 note = _("には効果がなかった。", " is unaffected.");
4118                         }
4119
4120                         /* No "real" damage */
4121                         dam = 0;
4122                         break;
4123                 }
4124
4125                 /* GENOCIDE */
4126                 case GF_GENOCIDE:
4127                 {
4128                         if (seen) obvious = TRUE;
4129
4130                         if (r_ptr->flagsr & RFR_RES_ALL)
4131                         {
4132                                 note = _("には効果がなかった。", " is unaffected.");
4133                                 skipped = TRUE;
4134                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4135                                 break;
4136                         }
4137
4138                         if (genocide_aux(c_ptr->m_idx, dam, !who, (r_ptr->level + 1) / 2, _("モンスター消滅", "Genocide One")))
4139                         {
4140                                 if (seen_msg) msg_format(_("%sは消滅した!", "%^s disappered!"), m_name);
4141                                 chg_virtue(V_VITALITY, -1);
4142                                 return TRUE;
4143                         }
4144
4145                         skipped = TRUE;
4146                         break;
4147                 }
4148
4149                 case GF_PHOTO:
4150                 {
4151                         if (!who) msg_format(_("%sを写真に撮った。", "You take a photograph of %s."), m_name);
4152                         /* Hurt by light */
4153                         if (r_ptr->flags3 & (RF3_HURT_LITE))
4154                         {
4155                                 /* Obvious effect */
4156                                 if (seen) obvious = TRUE;
4157
4158                                 /* Memorize the effects */
4159                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
4160
4161                                 /* Special effect */
4162                                 note = _("は光に身をすくめた!", " cringes from the light!");
4163                                 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
4164                         }
4165
4166                         /* Normally no damage */
4167                         else
4168                         {
4169                                 /* No damage */
4170                                 dam = 0;
4171                         }
4172
4173                         photo = m_ptr->r_idx;
4174
4175                         break;
4176                 }
4177
4178
4179                 /* blood curse */
4180                 case GF_BLOOD_CURSE:
4181                 {
4182                         if (seen) obvious = TRUE;
4183
4184                         if (r_ptr->flagsr & RFR_RES_ALL)
4185                         {
4186                                 note = _("には完全な耐性がある!", " is immune.");
4187                                 dam = 0;
4188                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4189                                 break;
4190                         }
4191                         break;
4192                 }
4193
4194                 case GF_CRUSADE:
4195                 {
4196                         bool success = FALSE;
4197                         if (seen) obvious = TRUE;
4198
4199                         if ((r_ptr->flags3 & (RF3_GOOD)) && !p_ptr->inside_arena)
4200                         {
4201                                 if (r_ptr->flags3 & (RF3_NO_CONF)) dam -= 50;
4202                                 if (dam < 1) dam = 1;
4203
4204                                 /* No need to tame your pet */
4205                                 if (is_pet(m_ptr))
4206                                 {
4207                                         note = _("の動きが速くなった。", " starts moving faster.");
4208                                         (void)set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100);
4209                                         success = TRUE;
4210                                 }
4211
4212                                 /* Attempt a saving throw */
4213                                 else if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
4214                                         (r_ptr->flags1 & (RF1_UNIQUE)) ||
4215                                         (m_ptr->mflag2 & MFLAG2_NOPET) ||
4216                                         (p_ptr->cursed & TRC_AGGRAVATE) ||
4217                                          ((r_ptr->level+10) > randint1(dam)))
4218                                 {
4219                                         /* Resist */
4220                                         if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
4221                                 }
4222                                 else
4223                                 {
4224                                         note = _("を支配した。", " is tamed!");
4225                                         set_pet(m_ptr);
4226                                         (void)set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100);
4227
4228                                         /* Learn about type */
4229                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
4230                                         success = TRUE;
4231                                 }
4232                         }
4233
4234                         if (!success)
4235                         {
4236                                 if (!(r_ptr->flags3 & RF3_NO_FEAR))
4237                                 {
4238                                         do_fear = randint1(90)+10;
4239                                 }
4240                                 else if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_FEAR);
4241                         }
4242
4243                         /* No "real" damage */
4244                         dam = 0;
4245                         break;
4246                 }
4247
4248                 case GF_WOUNDS:
4249                 {
4250                         if (seen) obvious = TRUE;
4251
4252                         if (r_ptr->flagsr & RFR_RES_ALL)
4253                         {
4254                                 note = _("には完全な耐性がある!", " is immune.");
4255                                 skipped = TRUE;
4256                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4257                                 break;
4258                         }
4259
4260                         /* Attempt a saving throw */
4261                         if (randint0(100 + dam) < (r_ptr->level + 50))
4262                         {
4263                                 note = _("には効果がなかった。", " is unaffected.");
4264                                 dam = 0;
4265                         }
4266                         break;
4267                 }
4268
4269                 /* Default */
4270                 default:
4271                 {
4272                         /* Irrelevant */
4273                         skipped = TRUE;
4274
4275                         /* No damage */
4276                         dam = 0;
4277
4278                         break;
4279                 }
4280         }
4281
4282
4283         /* Absolutely no effect */
4284         if (skipped) return (FALSE);
4285
4286         /* "Unique" monsters cannot be polymorphed */
4287         if (r_ptr->flags1 & (RF1_UNIQUE)) do_poly = FALSE;
4288
4289         /* Quest monsters cannot be polymorphed */
4290         if (r_ptr->flags1 & RF1_QUESTOR) do_poly = FALSE;
4291
4292         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_poly = FALSE;
4293
4294         /* "Unique" and "quest" monsters can only be "killed" by the player. */
4295         if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->inside_battle)
4296         {
4297                 if (who && (dam > m_ptr->hp)) dam = m_ptr->hp;
4298         }
4299
4300         if (!who && slept)
4301         {
4302                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
4303                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
4304         }
4305
4306         /* Modify the damage */
4307         tmp = dam;
4308         dam = mon_damage_mod(m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
4309         if ((tmp > 0) && (dam == 0)) note = _("はダメージを受けていない。", " is unharmed.");
4310
4311         /* Check for death */
4312         if (dam > m_ptr->hp)
4313         {
4314                 /* Extract method of death */
4315                 note = note_dies;
4316         }
4317         else
4318         {
4319                 /* Sound and Impact resisters never stun */
4320                 if (do_stun &&
4321                         !(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
4322                         !(r_ptr->flags3 & RF3_NO_STUN))
4323                 {
4324                         if (seen) obvious = TRUE;
4325
4326                         /* Get stunned */
4327                         if (MON_STUNNED(m_ptr))
4328                         {
4329                                 note = _("はひどくもうろうとした。", " is more dazed.");
4330                                 tmp = MON_STUNNED(m_ptr) + (do_stun / 2);
4331                         }
4332                         else
4333                         {
4334                                 note = _("はもうろうとした。", " is dazed.");
4335                                 tmp = do_stun;
4336                         }
4337
4338                         /* Apply stun */
4339                         (void)set_monster_stunned(c_ptr->m_idx, tmp);
4340
4341                         /* Get angry */
4342                         get_angry = TRUE;
4343                 }
4344
4345                 /* Confusion and Chaos resisters (and sleepers) never confuse */
4346                 if (do_conf &&
4347                          !(r_ptr->flags3 & RF3_NO_CONF) &&
4348                          !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
4349                 {
4350                         if (seen) obvious = TRUE;
4351
4352                         /* Already partially confused */
4353                         if (MON_CONFUSED(m_ptr))
4354                         {
4355                                 note = _("はさらに混乱したようだ。", " looks more confused.");
4356                                 tmp = MON_CONFUSED(m_ptr) + (do_conf / 2);
4357                         }
4358
4359                         /* Was not confused */
4360                         else
4361                         {
4362                                 note = _("は混乱したようだ。", " looks confused.");
4363                                 tmp = do_conf;
4364                         }
4365
4366                         /* Apply confusion */
4367                         (void)set_monster_confused(c_ptr->m_idx, tmp);
4368
4369                         /* Get angry */
4370                         get_angry = TRUE;
4371                 }
4372
4373                 if (do_time)
4374                 {
4375                         if (seen) obvious = TRUE;
4376
4377                         if (do_time >= m_ptr->maxhp) do_time = m_ptr->maxhp - 1;
4378
4379                         if (do_time)
4380                         {
4381                                 note = _("は弱くなったようだ。", " seems weakened.");
4382                                 m_ptr->maxhp -= do_time;
4383                                 if ((m_ptr->hp - dam) > m_ptr->maxhp) dam = m_ptr->hp - m_ptr->maxhp;
4384                         }
4385                         get_angry = TRUE;
4386                 }
4387
4388                 /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
4389                 if (do_poly && (randint1(90) > r_ptr->level))
4390                 {
4391                         if (polymorph_monster(y, x))
4392                         {
4393                                 if (seen) obvious = TRUE;
4394
4395                                 /* Monster polymorphs */
4396                                 note = _("が変身した!", " changes!");
4397
4398                                 /* Turn off the damage */
4399                                 dam = 0;
4400                         }
4401                         else
4402                         {
4403                                 /* No polymorph */
4404                                 note = _("には効果がなかった。", " is unaffected.");
4405                         }
4406
4407                         /* Hack -- Get new monster */
4408                         m_ptr = &m_list[c_ptr->m_idx];
4409
4410                         /* Hack -- Get new race */
4411                         r_ptr = &r_info[m_ptr->r_idx];
4412                 }
4413
4414                 /* Handle "teleport" */
4415                 if (do_dist)
4416                 {
4417                         if (seen) obvious = TRUE;
4418
4419                         note = _("が消え去った!", " disappears!");
4420
4421                         if (!who) chg_virtue(V_VALOUR, -1);
4422
4423                         /* Teleport */
4424                         teleport_away(c_ptr->m_idx, do_dist,
4425                                                 (!who ? TELEPORT_DEC_VALOUR : 0L) | TELEPORT_PASSIVE);
4426
4427                         /* Hack -- get new location */
4428                         y = m_ptr->fy;
4429                         x = m_ptr->fx;
4430
4431                         /* Hack -- get new grid */
4432                         c_ptr = &cave[y][x];
4433                 }
4434
4435                 /* Fear */
4436                 if (do_fear)
4437                 {
4438                         /* Set fear */
4439                         (void)set_monster_monfear(c_ptr->m_idx, MON_MONFEAR(m_ptr) + do_fear);
4440
4441                         /* Get angry */
4442                         get_angry = TRUE;
4443                 }
4444         }
4445
4446         if (typ == GF_DRAIN_MANA)
4447         {
4448                 /* Drain mana does nothing */
4449         }
4450
4451         /* If another monster did the damage, hurt the monster by hand */
4452         else if (who)
4453         {
4454                 /* Redraw (later) if needed */
4455                 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
4456                 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
4457
4458                 /* Wake the monster up */
4459                 (void)set_monster_csleep(c_ptr->m_idx, 0);
4460
4461                 /* Hurt the monster */
4462                 m_ptr->hp -= dam;
4463
4464                 /* Dead monster */
4465                 if (m_ptr->hp < 0)
4466                 {
4467                         bool sad = FALSE;
4468
4469                         if (is_pet(m_ptr) && !(m_ptr->ml))
4470                                 sad = TRUE;
4471
4472                         /* Give detailed messages if destroyed */
4473                         if (known && note)
4474                         {
4475                                 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
4476                                 if (see_s_msg)
4477                                 {
4478                                         msg_format("%^s%s", m_name, note);
4479                                 }
4480                                 else
4481                                 {
4482                                         mon_fight = TRUE;
4483                                 }
4484                         }
4485
4486                         if (who > 0) monster_gain_exp(who, m_ptr->r_idx);
4487
4488                         /* Generate treasure, etc */
4489                         monster_death(c_ptr->m_idx, FALSE);
4490
4491
4492                         delete_monster_idx(c_ptr->m_idx);
4493
4494                         if (sad)
4495                         {
4496                                 msg_print(_("少し悲しい気分がした。", "You feel sad for a moment."));
4497                         }
4498                 }
4499
4500                 /* Damaged monster */
4501                 else
4502                 {
4503                         /* Give detailed messages if visible or destroyed */
4504                         if (note && seen_msg) msg_format("%^s%s", m_name, note);
4505
4506                         /* Hack -- Pain message */
4507                         else if (see_s_msg)
4508                         {
4509                                 message_pain(c_ptr->m_idx, dam);
4510                         }
4511                         else
4512                         {
4513                                 mon_fight = TRUE;
4514                         }
4515
4516                         /* Hack -- handle sleep */
4517                         if (do_sleep) (void)set_monster_csleep(c_ptr->m_idx, do_sleep);
4518                 }
4519         }
4520
4521         else if (heal_leper)
4522         {
4523                 if (seen_msg) msg_print(_("不潔な病人は病気が治った!", "The Mangy looking leper is healed!"));
4524
4525                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
4526                 {
4527                         char m2_name[MAX_NLEN];
4528
4529                         monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
4530                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_HEAL_LEPER, m2_name);
4531                 }
4532
4533                 delete_monster_idx(c_ptr->m_idx);
4534         }
4535
4536         /* If the player did it, give him experience, check fear */
4537         else
4538         {
4539                 bool fear = FALSE;
4540
4541                 /* Hurt the monster, check for fear and death */
4542                 if (mon_take_hit(c_ptr->m_idx, dam, &fear, note_dies))
4543                 {
4544                         /* Dead monster */
4545                 }
4546
4547                 /* Damaged monster */
4548                 else
4549                 {
4550                         /* HACK - anger the monster before showing the sleep message */
4551                         if (do_sleep) anger_monster(m_ptr);
4552
4553                         /* Give detailed messages if visible or destroyed */
4554                         if (note && seen_msg)
4555                                 msg_format(_("%s%s", "%^s%s"), m_name, note);
4556
4557                         /* Hack -- Pain message */
4558                         else if (known && (dam || !do_fear))
4559                         {
4560                                 message_pain(c_ptr->m_idx, dam);
4561                         }
4562
4563                         /* Anger monsters */
4564                         if (((dam > 0) || get_angry) && !do_sleep)
4565                                 anger_monster(m_ptr);
4566
4567                         if ((fear || do_fear) && seen)
4568                         {
4569                                 sound(SOUND_FLEE);
4570                                 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
4571                         }
4572
4573                         /* Hack -- handle sleep */
4574                         if (do_sleep) (void)set_monster_csleep(c_ptr->m_idx, do_sleep);
4575                 }
4576         }
4577
4578         if ((typ == GF_BLOOD_CURSE) && one_in_(4))
4579         {
4580                 int curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
4581                 int count = 0;
4582                 do
4583                 {
4584                         switch (randint1(28))
4585                         {
4586                         case 1: case 2:
4587                                 if (!count)
4588                                 {
4589                                         msg_print(_("地面が揺れた...", "The ground trembles..."));
4590                                         earthquake(ty, tx, 4 + randint0(4));
4591                                         if (!one_in_(6)) break;
4592                                 }
4593                         case 3: case 4: case 5: case 6:
4594                                 if (!count)
4595                                 {
4596                                         int extra_dam = damroll(10, 10);
4597                                         msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
4598
4599                                         project(0, 8, ty, tx, extra_dam, GF_MANA, curse_flg, -1);
4600                                         if (!one_in_(6)) break;
4601                                 }
4602                         case 7: case 8:
4603                                 if (!count)
4604                                 {
4605                                         msg_print(_("空間が歪んだ!", "Space warps about you!"));
4606
4607                                         if (m_ptr->r_idx) teleport_away(c_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
4608                                         if (one_in_(13)) count += activate_hi_summon(ty, tx, TRUE);
4609                                         if (!one_in_(6)) break;
4610                                 }
4611                         case 9: case 10: case 11:
4612                                 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
4613                                 project(0, 7, ty, tx, 50, GF_DISINTEGRATE, curse_flg, -1);
4614                                 if (!one_in_(6)) break;
4615                         case 12: case 13: case 14: case 15: case 16:
4616                                 aggravate_monsters(0);
4617                                 if (!one_in_(6)) break;
4618                         case 17: case 18:
4619                                 count += activate_hi_summon(ty, tx, TRUE);
4620                                 if (!one_in_(6)) break;
4621                         case 19: case 20: case 21: case 22:
4622                         {
4623                                 bool pet = !one_in_(3);
4624                                 BIT_FLAGS mode = PM_ALLOW_GROUP;
4625
4626                                 if (pet) mode |= PM_FORCE_PET;
4627                                 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
4628
4629                                 count += summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (pet ? p_ptr->lev*2/3+randint1(p_ptr->lev/2) : dun_level), 0, mode, '\0');
4630                                 if (!one_in_(6)) break;
4631                         }
4632                         case 23: case 24: case 25:
4633                                 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
4634                                 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
4635
4636                                 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
4637                                 else lose_exp(p_ptr->exp / 16);
4638                                 if (!one_in_(6)) break;
4639                         case 26: case 27: case 28:
4640                         {
4641                                 int i = 0;
4642                                 if (one_in_(13))
4643                                 {
4644                                         while (i < A_MAX)
4645                                         {
4646                                                 do
4647                                                 {
4648                                                         (void)do_dec_stat(i);
4649                                                 }
4650                                                 while (one_in_(2));
4651
4652                                                 i++;
4653                                         }
4654                                 }
4655                                 else
4656                                 {
4657                                         (void)do_dec_stat(randint0(6));
4658                                 }
4659                                 break;
4660                         }
4661                         }
4662                 }
4663                 while (one_in_(5));
4664         }
4665
4666         if (p_ptr->inside_battle)
4667         {
4668                 p_ptr->health_who = c_ptr->m_idx;
4669                 p_ptr->redraw |= (PR_HEALTH);
4670                 handle_stuff();
4671         }
4672
4673         /* Verify this code */
4674         if (m_ptr->r_idx) update_monster(c_ptr->m_idx, FALSE);
4675
4676         /* Redraw the monster grid */
4677         lite_spot(y, x);
4678
4679
4680         /* Update monster recall window */
4681         if ((p_ptr->monster_race_idx == m_ptr->r_idx) && (seen || !m_ptr->r_idx))
4682         {
4683                 p_ptr->window |= (PW_MONSTER);
4684         }
4685
4686         if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
4687         {
4688                 if (!who)
4689                 {
4690                         if (!(flg & PROJECT_NO_HANGEKI))
4691                         {
4692                                 set_target(m_ptr, monster_target_y, monster_target_x);
4693                         }
4694                 }
4695                 else if ((who > 0) && is_pet(caster_ptr) && !player_bold(m_ptr->target_y, m_ptr->target_x))
4696                 {
4697                         set_target(m_ptr, caster_ptr->fy, caster_ptr->fx);
4698                 }
4699         }
4700
4701         if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx) && (dam > 0))
4702         {
4703                 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
4704                 rakubadam_m = (dam > 200) ? 200 : dam;
4705         }
4706
4707
4708         if (photo)
4709         {
4710                 object_type *q_ptr;
4711                 object_type forge;
4712                 q_ptr = &forge;
4713
4714                 /* Prepare to make a Blade of Chaos */
4715                 object_prep(q_ptr, lookup_kind(TV_STATUE, SV_PHOTO));
4716
4717                 q_ptr->pval = photo;
4718
4719                 /* Mark the item as fully known */
4720                 q_ptr->ident |= (IDENT_MENTAL);
4721                 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4722         }
4723
4724         /* Track it */
4725         project_m_n++;
4726         project_m_x = x;
4727         project_m_y = y;
4728
4729         /* Return "Anything seen?" */
4730         return (obvious);
4731 }
4732
4733 /*!
4734  * @brief 汎用的なビーム/ボルト/ボール系によるプレイヤーへの効果処理 / Helper function for "project()" below.
4735  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
4736  * @param who_name 効果を起こしたモンスターの名前
4737  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
4738  * @param y 目標Y座標 / Target y location (or location to travel "towards")
4739  * @param x 目標X座標 / Target x location (or location to travel "towards")
4740  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
4741  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
4742  * @param flg 効果フラグ
4743  * @param monspell 効果元のモンスター魔法ID
4744  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
4745  * @details
4746  * Handle a beam/bolt/ball causing damage to the player.
4747  * This routine takes a "source monster" (by index), a "distance", a default
4748  * "damage", and a "damage type".  See "project_m()" above.
4749  * If "rad" is non-zero, then the blast was centered elsewhere, and the damage
4750  * is reduced (see "project_m()" above).  This can happen if a monster breathes
4751  * at the player and hits a wall instead.
4752  * NOTE (Zangband): 'Bolt' attacks can be reflected back, so we need
4753  * to know if this is actually a ball or a bolt spell
4754  * We return "TRUE" if any "obvious" effects were observed.  XXX XXX Actually,
4755  * we just assume that the effects were obvious, for historical reasons.
4756  */
4757 static bool project_p(MONSTER_IDX who, concptr who_name, int r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
4758 {
4759         int k = 0;
4760         DEPTH rlev = 0;
4761
4762         /* Hack -- assume obvious */
4763         bool obvious = TRUE;
4764
4765         /* Player blind-ness */
4766         bool blind = (p_ptr->blind ? TRUE : FALSE);
4767
4768         /* Player needs a "description" (he is blind) */
4769         bool fuzzy = FALSE;
4770
4771         /* Source monster */
4772         monster_type *m_ptr = NULL;
4773
4774         /* Monster name (for attacks) */
4775         GAME_TEXT m_name[MAX_NLEN];
4776
4777         /* Monster name (for damage) */
4778         char killer[80];
4779
4780         /* Hack -- messages */
4781         concptr act = NULL;
4782
4783         int get_damage = 0;
4784
4785
4786         /* Player is not here */
4787         if (!player_bold(y, x)) return (FALSE);
4788
4789         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (p_ptr->lev*3/5+20)) && who && (who != p_ptr->riding))
4790         {
4791                 if (kawarimi(TRUE)) return FALSE;
4792         }
4793
4794         /* Player cannot hurt himself */
4795         if (!who) return (FALSE);
4796         if (who == p_ptr->riding) return (FALSE);
4797
4798         if ((p_ptr->reflect || ((p_ptr->special_defense & KATA_FUUJIN) && !p_ptr->blind)) && (flg & PROJECT_REFLECTABLE) && !one_in_(10))
4799         {
4800                 POSITION t_y, t_x;
4801                 int max_attempts = 10;
4802                 sound(SOUND_REFLECT);
4803
4804                 if (blind) 
4805                         msg_print(_("何かが跳ね返った!", "Something bounces!"));
4806                 else if (p_ptr->special_defense & KATA_FUUJIN) 
4807                         msg_print(_("風の如く武器を振るって弾き返した!", "The attack bounces!"));
4808                 else 
4809                         msg_print(_("攻撃が跳ね返った!", "The attack bounces!"));
4810
4811
4812                 /* Choose 'new' target */
4813                 if (who > 0)
4814                 {
4815                         do
4816                         {
4817                                 t_y = m_list[who].fy - 1 + randint1(3);
4818                                 t_x = m_list[who].fx - 1 + randint1(3);
4819                                 max_attempts--;
4820                         }
4821                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(p_ptr->y, p_ptr->x, t_y, t_x));
4822
4823                         if (max_attempts < 1)
4824                         {
4825                                 t_y = m_list[who].fy;
4826                                 t_x = m_list[who].fx;
4827                         }
4828                 }
4829                 else
4830                 {
4831                         t_y = p_ptr->y - 1 + randint1(3);
4832                         t_x = p_ptr->x - 1 + randint1(3);
4833                 }
4834
4835                 project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP|PROJECT_KILL|PROJECT_REFLECTABLE), monspell);
4836
4837                 disturb(TRUE, TRUE);
4838                 return TRUE;
4839         }
4840
4841         /* Limit maximum damage */
4842         if (dam > 1600) dam = 1600;
4843
4844         /* Reduce damage by distance */
4845         dam = (dam + r) / (r + 1);
4846
4847
4848         /* If the player is blind, be more descriptive */
4849         if (blind) fuzzy = TRUE;
4850
4851
4852         if (who > 0)
4853         {
4854                 m_ptr = &m_list[who];
4855                 rlev = (((&r_info[m_ptr->r_idx])->level >= 1) ? (&r_info[m_ptr->r_idx])->level : 1);
4856                 monster_desc(m_name, m_ptr, 0);
4857
4858                 /* Get the monster's real name (gotten before polymorph!) */
4859                 strcpy(killer, who_name);
4860         }
4861         else
4862         {
4863                 switch (who)
4864                 {
4865                 case PROJECT_WHO_UNCTRL_POWER:
4866                         strcpy(killer, _("制御できない力の氾流", "uncontrollable power storm"));
4867                         break;
4868
4869                 case PROJECT_WHO_GLASS_SHARDS:
4870                         strcpy(killer, _("ガラスの破片", "shards of glass"));
4871                         break;
4872
4873                 default:
4874                         strcpy(killer, _("罠", "a trap"));
4875                         break;
4876                 }
4877
4878                 /* Paranoia */
4879                 strcpy(m_name, killer);
4880         }
4881
4882         /* Analyze the damage */
4883         switch (typ)
4884         {
4885                 /* Standard damage -- hurts inventory too */
4886                 case GF_ACID:
4887                 {
4888                         if (fuzzy) msg_print(_("酸で攻撃された!", "You are hit by acid!"));                    
4889                         get_damage = acid_dam(dam, killer, monspell, FALSE);
4890                         break;
4891                 }
4892
4893                 /* Standard damage -- hurts inventory too */
4894                 case GF_FIRE:
4895                 {
4896                         if (fuzzy) msg_print(_("火炎で攻撃された!", "You are hit by fire!"));
4897                         get_damage = fire_dam(dam, killer, monspell, FALSE);
4898                         break;
4899                 }
4900
4901                 /* Standard damage -- hurts inventory too */
4902                 case GF_COLD:
4903                 {
4904                         if (fuzzy) msg_print(_("冷気で攻撃された!", "You are hit by cold!"));
4905                         get_damage = cold_dam(dam, killer, monspell, FALSE);
4906                         break;
4907                 }
4908
4909                 /* Standard damage -- hurts inventory too */
4910                 case GF_ELEC:
4911                 {
4912                         if (fuzzy) msg_print(_("電撃で攻撃された!", "You are hit by lightning!"));
4913                         get_damage = elec_dam(dam, killer, monspell, FALSE);
4914                         break;
4915                 }
4916
4917                 /* Standard damage -- also poisons player */
4918                 case GF_POIS:
4919                 {
4920                         bool double_resist = IS_OPPOSE_POIS();
4921                         if (fuzzy) msg_print(_("毒で攻撃された!", "You are hit by poison!"));
4922
4923                         if (p_ptr->resist_pois) dam = (dam + 2) / 3;
4924                         if (double_resist) dam = (dam + 2) / 3;
4925
4926                         if ((!(double_resist || p_ptr->resist_pois)) && one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
4927                         {
4928                                 do_dec_stat(A_CON);
4929                         }
4930
4931                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
4932
4933                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
4934                         {
4935                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
4936                         }
4937                         break;
4938                 }
4939
4940                 /* Standard damage -- also poisons / mutates player */
4941                 case GF_NUKE:
4942                 {
4943                         bool double_resist = IS_OPPOSE_POIS();
4944                         if (fuzzy) msg_print(_("放射能で攻撃された!", "You are hit by radiation!"));
4945
4946                         if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
4947                         if (double_resist) dam = (2 * dam + 2) / 5;
4948                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
4949                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
4950                         {
4951                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
4952
4953                                 if (one_in_(5)) /* 6 */
4954                                 {
4955                                         msg_print(_("奇形的な変身を遂げた!", "You undergo a freakish metamorphosis!"));
4956                                         if (one_in_(4)) /* 4 */
4957                                                 do_poly_self();
4958                                         else
4959                                                 mutate_player();
4960                                 }
4961
4962                                 if (one_in_(6))
4963                                 {
4964                                         inven_damage(set_acid_destroy, 2);
4965                                 }
4966                         }
4967                         break;
4968                 }
4969
4970                 /* Standard damage */
4971                 case GF_MISSILE:
4972                 {
4973                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4974                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
4975                         break;
4976                 }
4977
4978                 /* Holy Orb -- Player only takes partial damage */
4979                 case GF_HOLY_FIRE:
4980                 {
4981                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4982                         if (p_ptr->align > 10)
4983                                 dam /= 2;
4984                         else if (p_ptr->align < -10)
4985                                 dam *= 2;
4986                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
4987                         break;
4988                 }
4989
4990                 case GF_HELL_FIRE:
4991                 {
4992                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
4993                         if (p_ptr->align > 10)
4994                                 dam *= 2;
4995                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
4996                         break;
4997                 }
4998
4999                 /* Arrow -- XXX no dodging */
5000                 case GF_ARROW:
5001                 {
5002                         if (fuzzy)
5003                         {
5004                                 msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5005                         }
5006                         else if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
5007                         {
5008                                 msg_print(_("矢を斬り捨てた!", "You cut down the arrow!"));
5009                                 break;
5010                         }
5011                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5012                         break;
5013                 }
5014
5015                 /* Plasma -- XXX No resist */
5016                 case GF_PLASMA:
5017                 {
5018                         if (fuzzy) msg_print(_("何かとても熱いもので攻撃された!", "You are hit by something *HOT*!"));
5019                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5020
5021                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5022                         {
5023                                 int plus_stun = (randint1((dam > 40) ? 35 : (dam * 3 / 4 + 5)));
5024                                 (void)set_stun(p_ptr->stun + plus_stun);
5025                         }
5026
5027                         if (!(p_ptr->resist_fire || IS_OPPOSE_FIRE() || p_ptr->immune_fire))
5028                         {
5029                                 inven_damage(set_acid_destroy, 3);
5030                         }
5031
5032                         break;
5033                 }
5034
5035                 /* Nether -- drain experience */
5036                 case GF_NETHER:
5037                 {
5038                         if (fuzzy) msg_print(_("地獄の力で攻撃された!", "You are hit by nether forces!"));
5039                         if (p_ptr->resist_neth)
5040                         {
5041                                 if (!prace_is_(RACE_SPECTRE))
5042                                 {
5043                                         dam *= 6; dam /= (randint1(4) + 7);
5044                                 }
5045                         }
5046                         else if (!CHECK_MULTISHADOW()) drain_exp(200 + (p_ptr->exp / 100), 200 + (p_ptr->exp / 1000), 75);
5047
5048                         if (prace_is_(RACE_SPECTRE) && !CHECK_MULTISHADOW())
5049                         {
5050                                 msg_print(_("気分がよくなった。", "You feel invigorated!"));
5051                                 hp_player(dam / 4);
5052                                 learn_spell(monspell);
5053                         }
5054                         else
5055                         {
5056                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5057                         }
5058
5059                         break;
5060                 }
5061
5062                 /* Water -- stun/confuse */
5063                 case GF_WATER:
5064                 {
5065                         if (fuzzy) msg_print(_("何か湿ったもので攻撃された!", "You are hit by something wet!"));
5066                         if (!CHECK_MULTISHADOW())
5067                         {
5068                                 if (!p_ptr->resist_sound && !p_ptr->resist_water)
5069                                 {
5070                                         set_stun(p_ptr->stun + randint1(40));
5071                                 }
5072                                 if (!p_ptr->resist_conf && !p_ptr->resist_water)
5073                                 {
5074                                         set_confused(p_ptr->confused + randint1(5) + 5);
5075                                 }
5076
5077                                 if (one_in_(5) && !p_ptr->resist_water)
5078                                 {
5079                                         inven_damage(set_cold_destroy, 3);
5080                                 }
5081
5082                                 if (p_ptr->resist_water) get_damage /= 4;
5083                         }
5084
5085                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5086                         break;
5087                 }
5088
5089                 /* Chaos -- many effects */
5090                 case GF_CHAOS:
5091                 {
5092                         if (fuzzy) msg_print(_("無秩序の波動で攻撃された!", "You are hit by a wave of anarchy!"));
5093                         if (p_ptr->resist_chaos)
5094                         {
5095                                 dam *= 6; dam /= (randint1(4) + 7);
5096                         }
5097
5098                         if (!CHECK_MULTISHADOW())
5099                         {
5100                                 if (!p_ptr->resist_conf)
5101                                 {
5102                                         (void)set_confused(p_ptr->confused + randint0(20) + 10);
5103                                 }
5104                                 if (!p_ptr->resist_chaos)
5105                                 {
5106                                         (void)set_image(p_ptr->image + randint1(10));
5107                                         if (one_in_(3))
5108                                         {
5109                                                 msg_print(_("あなたの身体はカオスの力で捻じ曲げられた!", "Your body is twisted by chaos!"));
5110                                                 (void)gain_random_mutation(0);
5111                                         }
5112                                 }
5113                                 if (!p_ptr->resist_neth && !p_ptr->resist_chaos)
5114                                 {
5115                                         drain_exp(5000 + (p_ptr->exp / 100), 500 + (p_ptr->exp / 1000), 75);
5116                                 }
5117
5118                                 if (!p_ptr->resist_chaos || one_in_(9))
5119                                 {
5120                                         inven_damage(set_elec_destroy, 2);
5121                                         inven_damage(set_fire_destroy, 2);
5122                                 }
5123                         }
5124
5125                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5126                         break;
5127                 }
5128
5129                 /* Shards -- mostly cutting */
5130                 case GF_SHARDS:
5131                 {
5132                         if (fuzzy) msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5133                         if (p_ptr->resist_shard)
5134                         {
5135                                 dam *= 6; dam /= (randint1(4) + 7);
5136                         }
5137                         else if (!CHECK_MULTISHADOW())
5138                         {
5139                                 (void)set_cut(p_ptr->cut + dam);
5140                         }
5141
5142                         if (!p_ptr->resist_shard || one_in_(13))
5143                         {
5144                                 inven_damage(set_cold_destroy, 2);
5145                         }
5146
5147                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5148                         break;
5149                 }
5150
5151                 /* Sound -- mostly stunning */
5152                 case GF_SOUND:
5153                 {
5154                         if (fuzzy) msg_print(_("轟音で攻撃された!", "You are hit by a loud noise!"));
5155                         if (p_ptr->resist_sound)
5156                         {
5157                                 dam *= 5; dam /= (randint1(4) + 7);
5158                         }
5159                         else if (!CHECK_MULTISHADOW())
5160                         {
5161                                 int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5162                                 (void)set_stun(p_ptr->stun + plus_stun);
5163                         }
5164
5165                         if (!p_ptr->resist_sound || one_in_(13))
5166                         {
5167                                 inven_damage(set_cold_destroy, 2);
5168                         }
5169
5170                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5171                         break;
5172                 }
5173
5174                 /* Pure confusion */
5175                 case GF_CONFUSION:
5176                 {
5177                         if (fuzzy) msg_print(_("何か混乱するもので攻撃された!", "You are hit by something puzzling!"));
5178                         if (p_ptr->resist_conf)
5179                         {
5180                                 dam *= 5; dam /= (randint1(4) + 7);
5181                         }
5182                         else if (!CHECK_MULTISHADOW())
5183                         {
5184                                 (void)set_confused(p_ptr->confused + randint1(20) + 10);
5185                         }
5186                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5187                         break;
5188                 }
5189
5190                 /* Disenchantment -- see above */
5191                 case GF_DISENCHANT:
5192                 {
5193                         if (fuzzy) msg_print(_("何かさえないもので攻撃された!", "You are hit by something static!"));
5194                         if (p_ptr->resist_disen)
5195                         {
5196                                 dam *= 6; dam /= (randint1(4) + 7);
5197                         }
5198                         else if (!CHECK_MULTISHADOW())
5199                         {
5200                                 (void)apply_disenchant(0);
5201                         }
5202                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5203                         break;
5204                 }
5205
5206                 /* Nexus -- see above */
5207                 case GF_NEXUS:
5208                 {
5209                         if (fuzzy) msg_print(_("何か奇妙なもので攻撃された!", "You are hit by something strange!"));
5210                         if (p_ptr->resist_nexus)
5211                         {
5212                                 dam *= 6; dam /= (randint1(4) + 7);
5213                         }
5214                         else if (!CHECK_MULTISHADOW())
5215                         {
5216                                 apply_nexus(m_ptr);
5217                         }
5218                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5219                         break;
5220                 }
5221
5222                 /* Force -- mostly stun */
5223                 case GF_FORCE:
5224                 {
5225                         if (fuzzy) msg_print(_("運動エネルギーで攻撃された!", "You are hit by kinetic force!"));
5226                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5227                         {
5228                                 (void)set_stun(p_ptr->stun + randint1(20));
5229                         }
5230                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5231                         break;
5232                 }
5233
5234
5235                 /* Rocket -- stun, cut */
5236                 case GF_ROCKET:
5237                 {
5238                         if (fuzzy) msg_print(_("爆発があった!", "There is an explosion!"));
5239                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5240                         {
5241                                 (void)set_stun(p_ptr->stun + randint1(20));
5242                         }
5243
5244                         if (p_ptr->resist_shard)
5245                         {
5246                                 dam /= 2;
5247                         }
5248                         else if (!CHECK_MULTISHADOW())
5249                         {
5250                                 (void)set_cut(p_ptr->cut + (dam / 2));
5251                         }
5252
5253                         if (!p_ptr->resist_shard || one_in_(12))
5254                         {
5255                                 inven_damage(set_cold_destroy, 3);
5256                         }
5257
5258                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5259                         break;
5260                 }
5261
5262                 /* Inertia -- slowness */
5263                 case GF_INERTIAL:
5264                 {
5265                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5266                         if (!CHECK_MULTISHADOW()) (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5267                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5268                         break;
5269                 }
5270
5271                 /* Lite -- blinding */
5272                 case GF_LITE:
5273                 {
5274                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5275                         if (p_ptr->resist_lite)
5276                         {
5277                                 dam *= 4; dam /= (randint1(4) + 7);
5278                         }
5279                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5280                         {
5281                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5282                         }
5283
5284                         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
5285                         {
5286                                 if (!CHECK_MULTISHADOW()) msg_print(_("光で肉体が焦がされた!", "The light scorches your flesh!"));
5287                                 dam *= 2;
5288                         }
5289                         else if (prace_is_(RACE_S_FAIRY))
5290                         {
5291                                 dam = dam * 4 / 3;
5292                         }
5293
5294                         if (p_ptr->wraith_form) dam *= 2;
5295                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5296
5297                         if (p_ptr->wraith_form && !CHECK_MULTISHADOW())
5298                         {
5299                                 p_ptr->wraith_form = 0;
5300                                 msg_print(_("閃光のため非物質的な影の存在でいられなくなった。",
5301                                         "The light forces you out of your incorporeal shadow form."));
5302
5303                                 p_ptr->redraw |= (PR_MAP | PR_STATUS);
5304                                 p_ptr->update |= (PU_MONSTERS);
5305                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5306                         }
5307
5308                         break;
5309                 }
5310
5311                 /* Dark -- blinding */
5312                 case GF_DARK:
5313                 {
5314                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5315                         if (p_ptr->resist_dark)
5316                         {
5317                                 dam *= 4; dam /= (randint1(4) + 7);
5318
5319                                 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form) dam = 0;
5320                         }
5321                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5322                         {
5323                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5324                         }
5325                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5326                         break;
5327                 }
5328
5329                 /* Time -- bolt fewer effects XXX */
5330                 case GF_TIME:
5331                 {
5332                         if (fuzzy) msg_print(_("過去からの衝撃に攻撃された!", "You are hit by a blast from the past!"));
5333                         if (p_ptr->resist_time)
5334                         {
5335                                 dam *= 4;
5336                                 dam /= (randint1(4) + 7);
5337                                 msg_print(_("時間が通り過ぎていく気がする。", "You feel as if time is passing you by."));
5338                         }
5339                         else if (!CHECK_MULTISHADOW())
5340                         {
5341                                 switch (randint1(10))
5342                                 {
5343                                         case 1: case 2: case 3: case 4: case 5:
5344                                         {
5345                                                 if (p_ptr->prace == RACE_ANDROID) break;
5346                                                 msg_print(_("人生が逆戻りした気がする。", "You feel life has clocked back."));
5347                                                 lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
5348                                                 break;
5349                                         }
5350
5351                                         case 6: case 7: case 8: case 9:
5352                                         {
5353                                                 switch (randint1(6))
5354                                                 {
5355                                                         case 1: k = A_STR; act = _("強く", "strong"); break;
5356                                                         case 2: k = A_INT; act = _("聡明で", "bright"); break;
5357                                                         case 3: k = A_WIS; act = _("賢明で", "wise"); break;
5358                                                         case 4: k = A_DEX; act = _("器用で", "agile"); break;
5359                                                         case 5: k = A_CON; act = _("健康で", "hale"); break;
5360                                                         case 6: k = A_CHR; act = _("美しく", "beautiful"); break;
5361                                                 }
5362
5363                                                 msg_format(_("あなたは以前ほど%sなくなってしまった...。", 
5364                                                                          "You're not as %s as you used to be..."), act);
5365
5366                                                 p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4;
5367                                                 if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5368                                                 p_ptr->update |= (PU_BONUS);
5369                                                 break;
5370                                         }
5371
5372                                         case 10:
5373                                         {
5374                                                 msg_print(_("あなたは以前ほど力強くなくなってしまった...。", 
5375                                                                         "You're not as powerful as you used to be..."));
5376
5377                                                 for (k = 0; k < A_MAX; k++)
5378                                                 {
5379                                                         p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8;
5380                                                         if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5381                                                 }
5382                                                 p_ptr->update |= (PU_BONUS);
5383                                                 break;
5384                                         }
5385                                 }
5386                         }
5387
5388                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5389                         break;
5390                 }
5391
5392                 /* Gravity -- stun plus slowness plus teleport */
5393                 case GF_GRAVITY:
5394                 {
5395                         if (fuzzy) msg_print(_("何か重いもので攻撃された!", "You are hit by something heavy!"));
5396                                 msg_print(_("周辺の重力がゆがんだ。", "Gravity warps around you."));
5397
5398                         if (!CHECK_MULTISHADOW())
5399                         {
5400                                 teleport_player(5, TELEPORT_PASSIVE);
5401                                 if (!p_ptr->levitation)
5402                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5403                                 if (!(p_ptr->resist_sound || p_ptr->levitation))
5404                                 {
5405                                         int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5406                                         (void)set_stun(p_ptr->stun + plus_stun);
5407                                 }
5408                         }
5409                         if (p_ptr->levitation)
5410                         {
5411                                 dam = (dam * 2) / 3;
5412                         }
5413
5414                         if (!p_ptr->levitation || one_in_(13))
5415                         {
5416                                 inven_damage(set_cold_destroy, 2);
5417                         }
5418
5419                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5420                         break;
5421                 }
5422
5423                 /* Standard damage */
5424                 case GF_DISINTEGRATE:
5425                 {
5426                         if (fuzzy) msg_print(_("純粋なエネルギーで攻撃された!", "You are hit by pure energy!"));
5427
5428                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5429                         break;
5430                 }
5431
5432                 case GF_OLD_HEAL:
5433                 {
5434                         if (fuzzy) msg_print(_("何らかの攻撃によって気分がよくなった。", "You are hit by something invigorating!"));
5435
5436                         (void)hp_player(dam);
5437                         dam = 0;
5438                         break;
5439                 }
5440
5441                 case GF_OLD_SPEED:
5442                 {
5443                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5444                         (void)set_fast(p_ptr->fast + randint1(5), FALSE);
5445                         dam = 0;
5446                         break;
5447                 }
5448
5449                 case GF_OLD_SLOW:
5450                 {
5451                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5452                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5453                         break;
5454                 }
5455
5456                 case GF_OLD_SLEEP:
5457                 {
5458                         if (p_ptr->free_act)  break;
5459                         if (fuzzy) msg_print(_("眠ってしまった!", "You fall asleep!"));
5460
5461                         if (ironman_nightmare)
5462                         {
5463                                 msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind."));
5464                                 /* Have some nightmares */
5465                                 sanity_blast(NULL, FALSE);
5466                         }
5467
5468                         set_paralyzed(p_ptr->paralyzed + dam);
5469                         dam = 0;
5470                         break;
5471                 }
5472
5473                 /* Pure damage */
5474                 case GF_MANA:
5475                 case GF_SEEKER:
5476                 case GF_SUPER_RAY:
5477                 {
5478                         if (fuzzy) msg_print(_("魔法のオーラで攻撃された!", "You are hit by an aura of magic!"));
5479                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5480                         break;
5481                 }
5482
5483                 /* Pure damage */
5484                 case GF_PSY_SPEAR:
5485                 {
5486                         if (fuzzy) msg_print(_("エネルギーの塊で攻撃された!", "You are hit by an energy!"));
5487                         get_damage = take_hit(DAMAGE_FORCE, dam, killer, monspell);
5488                         break;
5489                 }
5490
5491                 /* Pure damage */
5492                 case GF_METEOR:
5493                 {
5494                         if (fuzzy) msg_print(_("何かが空からあなたの頭上に落ちてきた!", "Something falls from the sky on you!"));
5495
5496                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5497                         if (!p_ptr->resist_shard || one_in_(13))
5498                         {
5499                                 if (!p_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
5500                                 inven_damage(set_cold_destroy, 2);
5501                         }
5502
5503                         break;
5504                 }
5505
5506                 /* Ice -- cold plus stun plus cuts */
5507                 case GF_ICE:
5508                 {
5509                         if (fuzzy) msg_print(_("何か鋭く冷たいもので攻撃された!", "You are hit by something sharp and cold!"));
5510                         get_damage = cold_dam(dam, killer, monspell, FALSE);
5511                         if (!CHECK_MULTISHADOW())
5512                         {
5513                                 if (!p_ptr->resist_shard)
5514                                 {
5515                                         (void)set_cut(p_ptr->cut + damroll(5, 8));
5516                                 }
5517                                 if (!p_ptr->resist_sound)
5518                                 {
5519                                         (void)set_stun(p_ptr->stun + randint1(15));
5520                                 }
5521
5522                                 if ((!(p_ptr->resist_cold || IS_OPPOSE_COLD())) || one_in_(12))
5523                                 {
5524                                         if (!p_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
5525                                 }
5526                         }
5527
5528                         break;
5529                 }
5530
5531                 /* Death Ray */
5532                 case GF_DEATH_RAY:
5533                 {
5534                         if (fuzzy) msg_print(_("何か非常に冷たいもので攻撃された!", "You are hit by something extremely cold!"));
5535
5536                         if (p_ptr->mimic_form)
5537                         {
5538                                 if (!(mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
5539                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5540                         }
5541                         else
5542                         {
5543
5544                         switch (p_ptr->prace)
5545                         {
5546                                 /* Some races are immune */
5547                                 case RACE_GOLEM:
5548                                 case RACE_SKELETON:
5549                                 case RACE_ZOMBIE:
5550                                 case RACE_VAMPIRE:
5551                                 case RACE_DEMON:
5552                                 case RACE_SPECTRE:
5553                                 {
5554                                         dam = 0;
5555                                         break;
5556                                 }
5557                                 /* Hurt a lot */
5558                                 default:
5559                                 {
5560                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5561                                         break;
5562                                 }
5563                         }
5564                         }
5565
5566                         break;
5567                 }
5568
5569                 /* Drain mana */
5570                 case GF_DRAIN_MANA:
5571                 {
5572                         if (CHECK_MULTISHADOW())
5573                         {
5574                                 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, you are unharmed!"));
5575                         }
5576                         else if (p_ptr->csp)
5577                         {
5578                                 /* Basic message */
5579                                 if (who > 0) 
5580                                         msg_format(_("%^sに精神エネルギーを吸い取られてしまった!", "%^s draws psychic energy from you!"), m_name);
5581                                 else 
5582                                         msg_print(_("精神エネルギーを吸い取られてしまった!", "Your psychic energy is drawn!"));
5583
5584                                 /* Full drain */
5585                                 if (dam >= p_ptr->csp)
5586                                 {
5587                                         dam = p_ptr->csp;
5588                                         p_ptr->csp = 0;
5589                                         p_ptr->csp_frac = 0;
5590                                 }
5591
5592                                 /* Partial drain */
5593                                 else
5594                                 {
5595                                         p_ptr->csp -= dam;
5596                                 }
5597
5598                                 learn_spell(monspell);
5599                                 p_ptr->redraw |= (PR_MANA);
5600                                 p_ptr->window |= (PW_PLAYER | PW_SPELL);
5601
5602                                 if (who > 0)
5603                                 {
5604                                         /* Heal the monster */
5605                                         if (m_ptr->hp < m_ptr->maxhp)
5606                                         {
5607                                                 /* Heal */
5608                                                 m_ptr->hp += dam;
5609                                                 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
5610
5611                                                 /* Redraw (later) if needed */
5612                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
5613                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
5614
5615                                                 /* Special message */
5616                                                 if (m_ptr->ml)
5617                                                 {
5618                                                         msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), m_name);
5619                                                 }
5620                                         }
5621                                 }
5622                         }
5623
5624                         dam = 0;
5625                         break;
5626                 }
5627
5628                 /* Mind blast */
5629                 case GF_MIND_BLAST:
5630                 {
5631                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
5632                         {
5633                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5634                                 learn_spell(monspell);
5635                         }
5636                         else
5637                         {
5638                                 if (!CHECK_MULTISHADOW())
5639                                 {
5640                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
5641
5642                                         if (!p_ptr->resist_conf)
5643                                         {
5644                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
5645                                         }
5646
5647                                         if (!p_ptr->resist_chaos && one_in_(3))
5648                                         {
5649                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
5650                                         }
5651
5652                                         p_ptr->csp -= 50;
5653                                         if (p_ptr->csp < 0)
5654                                         {
5655                                                 p_ptr->csp = 0;
5656                                                 p_ptr->csp_frac = 0;
5657                                         }
5658                                         p_ptr->redraw |= PR_MANA;
5659                                 }
5660
5661                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5662                         }
5663                         break;
5664                 }
5665
5666                 /* Brain smash */
5667                 case GF_BRAIN_SMASH:
5668                 {
5669                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
5670                         {
5671                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5672                                 learn_spell(monspell);
5673                         }
5674                         else
5675                         {
5676                                 if (!CHECK_MULTISHADOW())
5677                                 {
5678                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
5679
5680                                         p_ptr->csp -= 100;
5681                                         if (p_ptr->csp < 0)
5682                                         {
5683                                                 p_ptr->csp = 0;
5684                                                 p_ptr->csp_frac = 0;
5685                                         }
5686                                         p_ptr->redraw |= PR_MANA;
5687                                 }
5688
5689                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5690                                 if (!CHECK_MULTISHADOW())
5691                                 {
5692                                         if (!p_ptr->resist_blind)
5693                                         {
5694                                                 (void)set_blind(p_ptr->blind + 8 + randint0(8));
5695                                         }
5696                                         if (!p_ptr->resist_conf)
5697                                         {
5698                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
5699                                         }
5700                                         if (!p_ptr->free_act)
5701                                         {
5702                                                 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
5703                                         }
5704                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5705
5706                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
5707                                                 (void)do_dec_stat(A_INT);
5708                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
5709                                                 (void)do_dec_stat(A_WIS);
5710
5711                                         if (!p_ptr->resist_chaos)
5712                                         {
5713                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
5714                                         }
5715                                 }
5716                         }
5717                         break;
5718                 }
5719
5720                 /* cause 1 */
5721                 case GF_CAUSE_1:
5722                 {
5723                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
5724                         {
5725                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5726                                 learn_spell(monspell);
5727                         }
5728                         else
5729                         {
5730                                 if (!CHECK_MULTISHADOW()) curse_equipment(15, 0);
5731                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5732                         }
5733                         break;
5734                 }
5735
5736                 /* cause 2 */
5737                 case GF_CAUSE_2:
5738                 {
5739                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
5740                         {
5741                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5742                                 learn_spell(monspell);
5743                         }
5744                         else
5745                         {
5746                                 if (!CHECK_MULTISHADOW()) curse_equipment(25, MIN(rlev / 2 - 15, 5));
5747                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5748                         }
5749                         break;
5750                 }
5751
5752                 /* cause 3 */
5753                 case GF_CAUSE_3:
5754                 {
5755                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
5756                         {
5757                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5758                                 learn_spell(monspell);
5759                         }
5760                         else
5761                         {
5762                                 if (!CHECK_MULTISHADOW()) curse_equipment(33, MIN(rlev / 2 - 15, 15));
5763                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5764                         }
5765                         break;
5766                 }
5767
5768                 /* cause 4 */
5769                 case GF_CAUSE_4:
5770                 {
5771                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !(m_ptr->r_idx == MON_KENSHIROU) && !CHECK_MULTISHADOW())
5772                         {
5773                                 msg_print(_("しかし秘孔を跳ね返した!", "You resist the effects!"));
5774                                 learn_spell(monspell);
5775                         }
5776                         else
5777                         {
5778                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5779                                 if (!CHECK_MULTISHADOW()) (void)set_cut(p_ptr->cut + damroll(10, 10));
5780                         }
5781                         break;
5782                 }
5783
5784                 /* Hand of Doom */
5785                 case GF_HAND_DOOM:
5786                 {
5787                         if ((randint0(100 + rlev/2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
5788                         {
5789                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5790                                 learn_spell(monspell);
5791                         }
5792                         else
5793                         {
5794                                 if (!CHECK_MULTISHADOW())
5795                                 {
5796                                         msg_print(_("あなたは命が薄まっていくように感じた!", "You feel your life fade away!"));
5797                                         curse_equipment(40, 20);
5798                                 }
5799
5800                                 get_damage = take_hit(DAMAGE_ATTACK, dam, m_name, monspell);
5801
5802                                 if (p_ptr->chp < 1) p_ptr->chp = 1; /* Paranoia */
5803                         }
5804                         break;
5805                 }
5806
5807                 /* Default */
5808                 default:
5809                 {
5810                         /* No damage */
5811                         dam = 0;
5812
5813                         break;
5814                 }
5815         }
5816
5817         /* Hex - revenge damage stored */
5818         revenge_store(get_damage);
5819
5820         if ((p_ptr->tim_eyeeye || hex_spelling(HEX_EYE_FOR_EYE))
5821                 && (get_damage > 0) && !p_ptr->is_dead && (who > 0))
5822         {
5823                 GAME_TEXT m_name_self[80];
5824
5825                 /* hisself */
5826                 monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
5827
5828                 msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
5829                 project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
5830                 if (p_ptr->tim_eyeeye) set_tim_eyeeye(p_ptr->tim_eyeeye-5, TRUE);
5831         }
5832
5833         if (p_ptr->riding && dam > 0)
5834         {
5835                 rakubadam_p = (dam > 200) ? 200 : dam;
5836         }
5837
5838
5839         disturb(TRUE, TRUE);
5840
5841
5842         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != p_ptr->riding))
5843         {
5844                 (void)kawarimi(FALSE);
5845         }
5846
5847         /* Return "Anything seen?" */
5848         return (obvious);
5849 }
5850
5851
5852 /*
5853  * Find the distance from (x, y) to a line.
5854  */
5855 POSITION dist_to_line(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
5856 {
5857         /* Vector from (x, y) to (x1, y1) */
5858         POSITION py = y1 - y;
5859         POSITION px = x1 - x;
5860
5861         /* Normal vector */
5862         POSITION ny = x2 - x1;
5863         POSITION nx = y1 - y2;
5864
5865         /* Length of N */
5866         POSITION pd = distance(y1, x1, y, x);
5867         POSITION nd = distance(y1, x1, y2, x2);
5868
5869         if (pd > nd) return distance(y, x, y2, x2);
5870
5871         /* Component of P on N */
5872         nd = ((nd) ? ((py * ny + px * nx) / nd) : 0);
5873
5874         /* Absolute value */
5875         return((nd >= 0) ? nd : 0 - nd);
5876 }
5877
5878
5879
5880 /*
5881  * 
5882  * Modified version of los() for calculation of disintegration balls.
5883  * Disintegration effects are stopped by permanent walls.
5884  */
5885 bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
5886 {
5887         POSITION dx, dy; /* Delta */
5888         POSITION ax, ay; /* Absolute */
5889         POSITION sx, sy; /* Signs */
5890         POSITION qx, qy; /* Fractions */
5891         POSITION tx, ty; /* Scanners */
5892         POSITION f1, f2; /* Scale factors */
5893         POSITION m; /* Slope, or 1/Slope, of LOS */
5894
5895         /* Extract the offset */
5896         dy = y2 - y1;
5897         dx = x2 - x1;
5898
5899         /* Extract the absolute offset */
5900         ay = ABS(dy);
5901         ax = ABS(dx);
5902
5903         /* Handle adjacent (or identical) grids */
5904         if ((ax < 2) && (ay < 2)) return (TRUE);
5905
5906         /* Paranoia -- require "safe" origin */
5907         /* if (!in_bounds(y1, x1)) return (FALSE); */
5908
5909         /* Directly South/North */
5910         if (!dx)
5911         {
5912                 /* South -- check for walls */
5913                 if (dy > 0)
5914                 {
5915                         for (ty = y1 + 1; ty < y2; ty++)
5916                         {
5917                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
5918                         }
5919                 }
5920
5921                 /* North -- check for walls */
5922                 else
5923                 {
5924                         for (ty = y1 - 1; ty > y2; ty--)
5925                         {
5926                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
5927                         }
5928                 }
5929
5930                 /* Assume los */
5931                 return (TRUE);
5932         }
5933
5934         /* Directly East/West */
5935         if (!dy)
5936         {
5937                 /* East -- check for walls */
5938                 if (dx > 0)
5939                 {
5940                         for (tx = x1 + 1; tx < x2; tx++)
5941                         {
5942                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
5943                         }
5944                 }
5945
5946                 /* West -- check for walls */
5947                 else
5948                 {
5949                         for (tx = x1 - 1; tx > x2; tx--)
5950                         {
5951                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
5952                         }
5953                 }
5954
5955                 /* Assume los */
5956                 return (TRUE);
5957         }
5958
5959         /* Extract some signs */
5960         sx = (dx < 0) ? -1 : 1;
5961         sy = (dy < 0) ? -1 : 1;
5962
5963         /* Vertical "knights" */
5964         if (ax == 1)
5965         {
5966                 if (ay == 2)
5967                 {
5968                         if (!cave_stop_disintegration(y1 + sy, x1)) return (TRUE);
5969                 }
5970         }
5971
5972         /* Horizontal "knights" */
5973         else if (ay == 1)
5974         {
5975                 if (ax == 2)
5976                 {
5977                         if (!cave_stop_disintegration(y1, x1 + sx)) return (TRUE);
5978                 }
5979         }
5980
5981         /* Calculate scale factor div 2 */
5982         f2 = (ax * ay);
5983
5984         /* Calculate scale factor */
5985         f1 = f2 << 1;
5986
5987
5988         /* Travel horizontally */
5989         if (ax >= ay)
5990         {
5991                 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
5992                 qy = ay * ay;
5993                 m = qy << 1;
5994
5995                 tx = x1 + sx;
5996
5997                 /* Consider the special case where slope == 1. */
5998                 if (qy == f2)
5999                 {
6000                         ty = y1 + sy;
6001                         qy -= f1;
6002                 }
6003                 else
6004                 {
6005                         ty = y1;
6006                 }
6007
6008                 /* Note (below) the case (qy == f2), where */
6009                 /* the LOS exactly meets the corner of a tile. */
6010                 while (x2 - tx)
6011                 {
6012                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6013
6014                         qy += m;
6015
6016                         if (qy < f2)
6017                         {
6018                                 tx += sx;
6019                         }
6020                         else if (qy > f2)
6021                         {
6022                                 ty += sy;
6023                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6024                                 qy -= f1;
6025                                 tx += sx;
6026                         }
6027                         else
6028                         {
6029                                 ty += sy;
6030                                 qy -= f1;
6031                                 tx += sx;
6032                         }
6033                 }
6034         }
6035
6036         /* Travel vertically */
6037         else
6038         {
6039                 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
6040                 qx = ax * ax;
6041                 m = qx << 1;
6042
6043                 ty = y1 + sy;
6044
6045                 if (qx == f2)
6046                 {
6047                         tx = x1 + sx;
6048                         qx -= f1;
6049                 }
6050                 else
6051                 {
6052                         tx = x1;
6053                 }
6054
6055                 /* Note (below) the case (qx == f2), where */
6056                 /* the LOS exactly meets the corner of a tile. */
6057                 while (y2 - ty)
6058                 {
6059                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6060
6061                         qx += m;
6062
6063                         if (qx < f2)
6064                         {
6065                                 ty += sy;
6066                         }
6067                         else if (qx > f2)
6068                         {
6069                                 tx += sx;
6070                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6071                                 qx -= f1;
6072                                 ty += sy;
6073                         }
6074                         else
6075                         {
6076                                 tx += sx;
6077                                 qx -= f1;
6078                                 ty += sy;
6079                         }
6080                 }
6081         }
6082
6083         /* Assume los */
6084         return (TRUE);
6085 }
6086
6087
6088 /*
6089  * breath shape
6090  */
6091 void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *gy, POSITION *gm, POSITION *pgm_rad, POSITION rad, POSITION y1, POSITION x1, POSITION y2, POSITION x2, EFFECT_ID typ)
6092 {
6093         POSITION by = y1;
6094         POSITION bx = x1;
6095         int brad = 0;
6096         int brev = rad * rad / dist;
6097         int bdis = 0;
6098         int cdis;
6099         int path_n = 0;
6100         int mdis = distance(y1, x1, y2, x2) + rad;
6101
6102         while (bdis <= mdis)
6103         {
6104                 POSITION x, y;
6105
6106                 if ((0 < dist) && (path_n < dist))
6107                 {
6108                         POSITION ny = GRID_Y(path_g[path_n]);
6109                         POSITION nx = GRID_X(path_g[path_n]);
6110                         POSITION nd = distance(ny, nx, y1, x1);
6111
6112                         /* Get next base point */
6113                         if (bdis >= nd)
6114                         {
6115                                 by = ny;
6116                                 bx = nx;
6117                                 path_n++;
6118                         }
6119                 }
6120
6121                 /* Travel from center outward */
6122                 for (cdis = 0; cdis <= brad; cdis++)
6123                 {
6124                         /* Scan the maximal blast area of radius "cdis" */
6125                         for (y = by - cdis; y <= by + cdis; y++)
6126                         {
6127                                 for (x = bx - cdis; x <= bx + cdis; x++)
6128                                 {
6129                                         /* Ignore "illegal" locations */
6130                                         if (!in_bounds(y, x)) continue;
6131
6132                                         /* Enforce a circular "ripple" */
6133                                         if (distance(y1, x1, y, x) != bdis) continue;
6134
6135                                         /* Enforce an arc */
6136                                         if (distance(by, bx, y, x) != cdis) continue;
6137
6138                                         switch (typ)
6139                                         {
6140                                         case GF_LITE:
6141                                         case GF_LITE_WEAK:
6142                                                 /* Lights are stopped by opaque terrains */
6143                                                 if (!los(by, bx, y, x)) continue;
6144                                                 break;
6145                                         case GF_DISINTEGRATE:
6146                                                 /* Disintegration are stopped only by perma-walls */
6147                                                 if (!in_disintegration_range(by, bx, y, x)) continue;
6148                                                 break;
6149                                         default:
6150                                                 /* Ball explosions are stopped by walls */
6151                                                 if (!projectable(by, bx, y, x)) continue;
6152                                                 break;
6153                                         }
6154
6155                                         /* Save this grid */
6156                                         gy[*pgrids] = y;
6157                                         gx[*pgrids] = x;
6158                                         (*pgrids)++;
6159                                 }
6160                         }
6161                 }
6162
6163                 /* Encode some more "radius" info */
6164                 gm[bdis + 1] = *pgrids;
6165
6166                 /* Increase the size */
6167                 brad = rad * (path_n + brev) / (dist + brev);
6168
6169                 /* Find the next ripple */
6170                 bdis++;
6171         }
6172
6173         /* Store the effect size */
6174         *pgm_rad = bdis;
6175 }
6176
6177
6178 /*!
6179  * @brief 汎用的なビーム/ボルト/ボール系処理のルーチン Generic "beam"/"bolt"/"ball" projection routine.
6180  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
6181  * @param rad 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
6182  * @param y 目標Y座標 / Target y location (or location to travel "towards")
6183  * @param x 目標X座標 / Target x location (or location to travel "towards")
6184  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
6185  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
6186  * @param flg 効果フラグ / Extra bit flags (see PROJECT_xxxx in "defines.h")
6187  * @param monspell 効果元のモンスター魔法ID
6188  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
6189  * @details
6190  * <pre>
6191  * Allows a monster (or player) to project a beam/bolt/ball of a given kind
6192  * towards a given location (optionally passing over the heads of interposing
6193  * monsters), and have it do a given amount of damage to the monsters (and
6194  * optionally objects) within the given radius of the final location.
6195  *
6196  * A "bolt" travels from source to target and affects only the target grid.
6197  * A "beam" travels from source to target, affecting all grids passed through.
6198  * A "ball" travels from source to the target, exploding at the target, and
6199  *   affecting everything within the given radius of the target location.
6200  *
6201  * Traditionally, a "bolt" does not affect anything on the ground, and does
6202  * not pass over the heads of interposing monsters, much like a traditional
6203  * missile, and will "stop" abruptly at the "target" even if no monster is
6204  * positioned there, while a "ball", on the other hand, passes over the heads
6205  * of monsters between the source and target, and affects everything except
6206  * the source monster which lies within the final radius, while a "beam"
6207  * affects every monster between the source and target, except for the casting
6208  * monster (or player), and rarely affects things on the ground.
6209  *
6210  * Two special flags allow us to use this function in special ways, the
6211  * "PROJECT_HIDE" flag allows us to perform "invisible" projections, while
6212  * the "PROJECT_JUMP" flag allows us to affect a specific grid, without
6213  * actually projecting from the source monster (or player).
6214  *
6215  * The player will only get "experience" for monsters killed by himself
6216  * Unique monsters can only be destroyed by attacks from the player
6217  *
6218  * Only 256 grids can be affected per projection, limiting the effective
6219  * "radius" of standard ball attacks to nine units (diameter nineteen).
6220  *
6221  * One can project in a given "direction" by combining PROJECT_THRU with small
6222  * offsets to the initial location (see "line_spell()"), or by calculating
6223  * "virtual targets" far away from the player.
6224  *
6225  * One can also use PROJECT_THRU to send a beam/bolt along an angled path,
6226  * continuing until it actually hits somethings (useful for "stone to mud").
6227  *
6228  * Bolts and Beams explode INSIDE walls, so that they can destroy doors.
6229  *
6230  * Balls must explode BEFORE hitting walls, or they would affect monsters
6231  * on both sides of a wall.  Some bug reports indicate that this is still
6232  * happening in 2.7.8 for Windows, though it appears to be impossible.
6233  *
6234  * We "pre-calculate" the blast area only in part for efficiency.
6235  * More importantly, this lets us do "explosions" from the "inside" out.
6236  * This results in a more logical distribution of "blast" treasure.
6237  * It also produces a better (in my opinion) animation of the explosion.
6238  * It could be (but is not) used to have the treasure dropped by monsters
6239  * in the middle of the explosion fall "outwards", and then be damaged by
6240  * the blast as it spreads outwards towards the treasure drop location.
6241  *
6242  * Walls and doors are included in the blast area, so that they can be
6243  * "burned" or "melted" in later versions.
6244  *
6245  * This algorithm is intended to maximize simplicity, not necessarily
6246  * efficiency, since this function is not a bottleneck in the code.
6247  *
6248  * We apply the blast effect from ground zero outwards, in several passes,
6249  * first affecting features, then objects, then monsters, then the player.
6250  * This allows walls to be removed before checking the object or monster
6251  * in the wall, and protects objects which are dropped by monsters killed
6252  * in the blast, and allows the player to see all affects before he is
6253  * killed or teleported away.  The semantics of this method are open to
6254  * various interpretations, but they seem to work well in practice.
6255  *
6256  * We process the blast area from ground-zero outwards to allow for better
6257  * distribution of treasure dropped by monsters, and because it provides a
6258  * pleasing visual effect at low cost.
6259  *
6260  * Note that the damage done by "ball" explosions decreases with distance.
6261  * This decrease is rapid, grids at radius "dist" take "1/dist" damage.
6262  *
6263  * Notice the "napalm" effect of "beam" weapons.  First they "project" to
6264  * the target, and then the damage "flows" along this beam of destruction.
6265  * The damage at every grid is the same as at the "center" of a "ball"
6266  * explosion, since the "beam" grids are treated as if they ARE at the
6267  * center of a "ball" explosion.
6268  *
6269  * Currently, specifying "beam" plus "ball" means that locations which are
6270  * covered by the initial "beam", and also covered by the final "ball", except
6271  * for the final grid (the epicenter of the ball), will be "hit twice", once
6272  * by the initial beam, and once by the exploding ball.  For the grid right
6273  * next to the epicenter, this results in 150% damage being done.  The center
6274  * does not have this problem, for the same reason the final grid in a "beam"
6275  * plus "bolt" does not -- it is explicitly removed.  Simply removing "beam"
6276  * grids which are covered by the "ball" will NOT work, as then they will
6277  * receive LESS damage than they should.  Do not combine "beam" with "ball".
6278  *
6279  * The array "gy[],gx[]" with current size "grids" is used to hold the
6280  * collected locations of all grids in the "blast area" plus "beam path".
6281  *
6282  * Note the rather complex usage of the "gm[]" array.  First, gm[0] is always
6283  * zero.  Second, for N>1, gm[N] is always the index (in gy[],gx[]) of the
6284  * first blast grid (see above) with radius "N" from the blast center.  Note
6285  * that only the first gm[1] grids in the blast area thus take full damage.
6286  * Also, note that gm[rad+1] is always equal to "grids", which is the total
6287  * number of blast grids.
6288  *
6289  * Note that once the projection is complete, (y2,x2) holds the final location
6290  * of bolts/beams, and the "epicenter" of balls.
6291  *
6292  * Note also that "rad" specifies the "inclusive" radius of projection blast,
6293  * so that a "rad" of "one" actually covers 5 or 9 grids, depending on the
6294  * implementation of the "distance" function.  Also, a bolt can be properly
6295  * viewed as a "ball" with a "rad" of "zero".
6296  *
6297  * Note that if no "target" is reached before the beam/bolt/ball travels the
6298  * maximum distance allowed (MAX_RANGE), no "blast" will be induced.  This
6299  * may be relevant even for bolts, since they have a "1x1" mini-blast.
6300  *
6301  * Note that for consistency, we "pretend" that the bolt actually takes "time"
6302  * to move from point A to point B, even if the player cannot see part of the
6303  * projection path.  Note that in general, the player will *always* see part
6304  * of the path, since it either starts at the player or ends on the player.
6305  *
6306  * Hack -- we assume that every "projection" is "self-illuminating".
6307  *
6308  * Hack -- when only a single monster is affected, we automatically track
6309  * (and recall) that monster, unless "PROJECT_JUMP" is used.
6310  *
6311  * Note that all projections now "explode" at their final destination, even
6312  * if they were being projected at a more distant destination.  This means
6313  * that "ball" spells will *always* explode.
6314  *
6315  * Note that we must call "handle_stuff()" after affecting terrain features
6316  * in the blast radius, in case the "illumination" of the grid was changed,
6317  * and "update_view()" and "update_monsters()" need to be called.
6318  * </pre>
6319  */
6320 bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
6321 {
6322         int i, t, dist;
6323
6324         POSITION y1, x1;
6325         POSITION y2, x2;
6326         POSITION by, bx;
6327
6328         int dist_hack = 0;
6329
6330         POSITION y_saver, x_saver; /* For reflecting monsters */
6331
6332         int msec = delay_factor * delay_factor * delay_factor;
6333
6334         /* Assume the player sees nothing */
6335         bool notice = FALSE;
6336
6337         /* Assume the player has seen nothing */
6338         bool visual = FALSE;
6339
6340         /* Assume the player has seen no blast grids */
6341         bool drawn = FALSE;
6342
6343         /* Assume to be a normal ball spell */
6344         bool breath = FALSE;
6345
6346         /* Is the player blind? */
6347         bool blind = (p_ptr->blind ? TRUE : FALSE);
6348
6349         bool old_hide = FALSE;
6350
6351         /* Number of grids in the "path" */
6352         int path_n = 0;
6353
6354         /* Actual grids in the "path" */
6355         u16b path_g[512];
6356
6357         /* Number of grids in the "blast area" (including the "beam" path) */
6358         int grids = 0;
6359
6360         /* Coordinates of the affected grids */
6361         POSITION gx[1024], gy[1024];
6362
6363         /* Encoded "radius" info (see above) */
6364         POSITION gm[32];
6365
6366         /* Actual radius encoded in gm[] */
6367         POSITION gm_rad = rad;
6368
6369         bool jump = FALSE;
6370
6371         /* Attacker's name (prepared before polymorph)*/
6372         GAME_TEXT who_name[MAX_NLEN];
6373
6374         /* Can the player see the source of this effect? */
6375         bool see_s_msg = TRUE;
6376
6377         /* Initialize by null string */
6378         who_name[0] = '\0';
6379
6380         rakubadam_p = 0;
6381         rakubadam_m = 0;
6382
6383         /* Default target of monsterspell is player */
6384         monster_target_y = p_ptr->y;
6385         monster_target_x = p_ptr->x;
6386
6387         /* Hack -- Jump to target */
6388         if (flg & (PROJECT_JUMP))
6389         {
6390                 x1 = x;
6391                 y1 = y;
6392
6393                 /* Clear the flag */
6394                 flg &= ~(PROJECT_JUMP);
6395
6396                 jump = TRUE;
6397         }
6398
6399         /* Start at player */
6400         else if (who <= 0)
6401         {
6402                 x1 = p_ptr->x;
6403                 y1 = p_ptr->y;
6404         }
6405
6406         /* Start at monster */
6407         else if (who > 0)
6408         {
6409                 x1 = m_list[who].fx;
6410                 y1 = m_list[who].fy;
6411                 monster_desc(who_name, &m_list[who], MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
6412         }
6413
6414         else
6415         {
6416                 x1 = x;
6417                 y1 = y;
6418         }
6419
6420         y_saver = y1;
6421         x_saver = x1;
6422
6423         /* Default "destination" */
6424         y2 = y;
6425         x2 = x;
6426
6427
6428         /* Hack -- verify stuff */
6429         if (flg & (PROJECT_THRU))
6430         {
6431                 if ((x1 == x2) && (y1 == y2))
6432                 {
6433                         flg &= ~(PROJECT_THRU);
6434                 }
6435         }
6436
6437         /* Handle a breath attack */
6438         if (rad < 0)
6439         {
6440                 rad = 0 - rad;
6441                 breath = TRUE;
6442                 if (flg & PROJECT_HIDE) old_hide = TRUE;
6443                 flg |= PROJECT_HIDE;
6444         }
6445
6446
6447         /* Hack -- Assume there will be no blast (max radius 32) */
6448         for (dist = 0; dist < 32; dist++) gm[dist] = 0;
6449
6450
6451         /* Initial grid */
6452         y = y1;
6453         x = x1;
6454         dist = 0;
6455
6456         /* Collect beam grids */
6457         if (flg & (PROJECT_BEAM))
6458         {
6459                 gy[grids] = y;
6460                 gx[grids] = x;
6461                 grids++;
6462         }
6463
6464         switch (typ)
6465         {
6466         case GF_LITE:
6467         case GF_LITE_WEAK:
6468                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_LOS);
6469                 break;
6470         case GF_DISINTEGRATE:
6471                 flg |= (PROJECT_GRID);
6472                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_DISI);
6473                 break;
6474         }
6475
6476         /* Calculate the projection path */
6477
6478         path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
6479         handle_stuff();
6480
6481         /* Giga-Hack SEEKER & SUPER_RAY */
6482
6483         if( typ == GF_SEEKER )
6484         {
6485                 int j;
6486                 int last_i=0;
6487
6488                 /* Mega-Hack */
6489                 project_m_n = 0;
6490                 project_m_x = 0;
6491                 project_m_y = 0;
6492
6493                 for (i = 0; i < path_n; ++i)
6494                 {
6495                         int oy = y;
6496                         int ox = x;
6497
6498                         int ny = GRID_Y(path_g[i]);
6499                         int nx = GRID_X(path_g[i]);
6500
6501                         /* Advance */
6502                         y = ny;
6503                         x = nx;
6504
6505                         gy[grids] = y;
6506                         gx[grids] = x;
6507                         grids++;
6508
6509
6510                         /* Only do visuals if requested */
6511                         if (!blind && !(flg & (PROJECT_HIDE)))
6512                         {
6513                                 /* Only do visuals if the player can "see" the bolt */
6514                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
6515                                 {
6516                                         u16b p;
6517
6518                                         TERM_COLOR a;
6519                                         SYMBOL_CODE c;
6520
6521                                         /* Obtain the bolt pict */
6522                                         p = bolt_pict(oy, ox, y, x, typ);
6523
6524                                         /* Extract attr/char */
6525                                         a = PICT_A(p);
6526                                         c = PICT_C(p);
6527
6528                                         /* Visual effects */
6529                                         print_rel(c, a, y, x);
6530                                         move_cursor_relative(y, x);
6531                                         /*if (fresh_before)*/ Term_fresh();
6532                                         Term_xtra(TERM_XTRA_DELAY, msec);
6533                                         lite_spot(y, x);
6534                                         /*if (fresh_before)*/ Term_fresh();
6535
6536                                         /* Display "beam" grids */
6537                                         if (flg & (PROJECT_BEAM))
6538                                         {
6539                                                 /* Obtain the explosion pict */
6540                                                 p = bolt_pict(y, x, y, x, typ);
6541
6542                                                 /* Extract attr/char */
6543                                                 a = PICT_A(p);
6544                                                 c = PICT_C(p);
6545
6546                                                 /* Visual effects */
6547                                                 print_rel(c, a, y, x);
6548                                         }
6549
6550                                         /* Hack -- Activate delay */
6551                                         visual = TRUE;
6552                                 }
6553
6554                                 /* Hack -- delay anyway for consistency */
6555                                 else if (visual)
6556                                 {
6557                                         /* Delay for consistency */
6558                                         Term_xtra(TERM_XTRA_DELAY, msec);
6559                                 }
6560                         }
6561                         if (project_o(0, 0, y, x, dam, GF_SEEKER))notice = TRUE;
6562                         if (is_mirror_grid(&cave[y][x]))
6563                         {
6564                                 /* The target of monsterspell becomes tha mirror(broken) */
6565                                 monster_target_y = y;
6566                                 monster_target_x = x;
6567
6568                                 remove_mirror(y, x);
6569                                 next_mirror(&oy, &ox, y, x);
6570
6571                                 path_n = i + project_path(&(path_g[i + 1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
6572                                 for (j = last_i; j <= i; j++)
6573                                 {
6574                                         y = GRID_Y(path_g[j]);
6575                                         x = GRID_X(path_g[j]);
6576                                         if (project_m(0, 0, y, x, dam, GF_SEEKER, flg, TRUE)) notice = TRUE;
6577                                         if (!who && (project_m_n == 1) && !jump) {
6578                                                 if (cave[project_m_y][project_m_x].m_idx > 0) {
6579                                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
6580
6581                                                         if (m_ptr->ml)
6582                                                         {
6583                                                                 /* Hack -- auto-recall */
6584                                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
6585
6586                                                                 /* Hack - auto-track */
6587                                                                 health_track(cave[project_m_y][project_m_x].m_idx);
6588                                                         }
6589                                                 }
6590                                         }
6591                                         (void)project_f(0, 0, y, x, dam, GF_SEEKER);
6592                                 }
6593                                 last_i = i;
6594                         }
6595                 }
6596                 for(i = last_i ; i < path_n ; i++)
6597                 {
6598                         POSITION py, px;
6599                         py = GRID_Y(path_g[i]);
6600                         px = GRID_X(path_g[i]);
6601                         if (project_m(0, 0, py, px, dam, GF_SEEKER, flg, TRUE))
6602                                 notice = TRUE;
6603                         if (!who && (project_m_n == 1) && !jump) {
6604                                 if (cave[project_m_y][project_m_x].m_idx > 0)
6605                                 {
6606                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
6607
6608                                         if (m_ptr->ml)
6609                                         {
6610                                                 /* Hack -- auto-recall */
6611                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
6612
6613                                                 /* Hack - auto-track */
6614                                                 health_track(cave[project_m_y][project_m_x].m_idx);
6615                                         }
6616                                 }
6617                         }
6618                         (void)project_f(0, 0, py, px, dam, GF_SEEKER);
6619                 }
6620                 return notice;
6621         }
6622         else if(typ == GF_SUPER_RAY){
6623                 int j;
6624                 int second_step = 0;
6625
6626                 /* Mega-Hack */
6627                 project_m_n = 0;
6628                 project_m_x = 0;
6629                 project_m_y = 0;
6630
6631                 for (i = 0; i < path_n; ++i)
6632                 {
6633                         POSITION oy = y;
6634                         POSITION ox = x;
6635
6636                         POSITION ny = GRID_Y(path_g[i]);
6637                         POSITION nx = GRID_X(path_g[i]);
6638
6639                         /* Advance */
6640                         y = ny;
6641                         x = nx;
6642
6643                         gy[grids] = y;
6644                         gx[grids] = x;
6645                         grids++;
6646
6647
6648                         /* Only do visuals if requested */
6649                         if (!blind && !(flg & (PROJECT_HIDE)))
6650                         {
6651                                 /* Only do visuals if the player can "see" the bolt */
6652                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
6653                                 {
6654                                         u16b p;
6655
6656                                         TERM_COLOR a;
6657                                         SYMBOL_CODE c;
6658
6659                                         /* Obtain the bolt pict */
6660                                         p = bolt_pict(oy, ox, y, x, typ);
6661
6662                                         /* Extract attr/char */
6663                                         a = PICT_A(p);
6664                                         c = PICT_C(p);
6665
6666                                         /* Visual effects */
6667                                         print_rel(c, a, y, x);
6668                                         move_cursor_relative(y, x);
6669                                         /*if (fresh_before)*/ Term_fresh();
6670                                         Term_xtra(TERM_XTRA_DELAY, msec);
6671                                         lite_spot(y, x);
6672                                         /*if (fresh_before)*/ Term_fresh();
6673
6674                                         /* Display "beam" grids */
6675                                         if (flg & (PROJECT_BEAM))
6676                                         {
6677                                                 /* Obtain the explosion pict */
6678                                                 p = bolt_pict(y, x, y, x, typ);
6679
6680                                                 /* Extract attr/char */
6681                                                 a = PICT_A(p);
6682                                                 c = PICT_C(p);
6683
6684                                                 /* Visual effects */
6685                                                 print_rel(c, a, y, x);
6686                                         }
6687
6688                                         /* Hack -- Activate delay */
6689                                         visual = TRUE;
6690                                 }
6691
6692                                 /* Hack -- delay anyway for consistency */
6693                                 else if (visual)
6694                                 {
6695                                         /* Delay for consistency */
6696                                         Term_xtra(TERM_XTRA_DELAY, msec);
6697                                 }
6698                         }
6699                         if(project_o(0,0,y,x,dam,GF_SUPER_RAY) )notice=TRUE;
6700                         if (!cave_have_flag_bold(y, x, FF_PROJECT))
6701                         {
6702                                 if( second_step )continue;
6703                                 break;
6704                         }
6705                         if( is_mirror_grid(&cave[y][x]) && !second_step )
6706                         {
6707                           /* The target of monsterspell becomes tha mirror(broken) */
6708                                 monster_target_y=(s16b)y;
6709                                 monster_target_x=(s16b)x;
6710
6711                                 remove_mirror(y,x);
6712                                 for( j = 0; j <=i ; j++ )
6713                                 {
6714                                         y = GRID_Y(path_g[j]);
6715                                         x = GRID_X(path_g[j]);
6716                                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
6717                                 }
6718                                 path_n = i;
6719                                 second_step =i+1;
6720                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x-1, flg);
6721                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x  , flg);
6722                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x+1, flg);
6723                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x-1, flg);
6724                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x+1, flg);
6725                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x-1, flg);
6726                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x  , flg);
6727                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x+1, flg);
6728                         }
6729                 }
6730                 for( i = 0; i < path_n ; i++ )
6731                 {
6732                         POSITION py, px;
6733                         py = GRID_Y(path_g[i]);
6734                         px = GRID_X(path_g[i]);
6735                         (void)project_m(0, 0, py, px, dam, GF_SUPER_RAY, flg, TRUE);
6736                         if(!who && (project_m_n == 1) && !jump){
6737                                 if(cave[project_m_y][project_m_x].m_idx >0 ){
6738                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
6739
6740                                         if (m_ptr->ml)
6741                                         {
6742                                                 /* Hack -- auto-recall */
6743                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
6744
6745                                                 /* Hack - auto-track */
6746                                                 health_track(cave[project_m_y][project_m_x].m_idx);
6747                                         }
6748                                 }
6749                         }
6750                         (void)project_f(0, 0, py, px, dam, GF_SUPER_RAY);
6751                 }
6752                 return notice;
6753         }
6754
6755         /* Project along the path */
6756         for (i = 0; i < path_n; ++i)
6757         {
6758                 POSITION oy = y;
6759                 POSITION ox = x;
6760
6761                 POSITION ny = GRID_Y(path_g[i]);
6762                 POSITION nx = GRID_X(path_g[i]);
6763
6764                 if (flg & PROJECT_DISI)
6765                 {
6766                         /* Hack -- Balls explode before reaching walls */
6767                         if (cave_stop_disintegration(ny, nx) && (rad > 0)) break;
6768                 }
6769                 else if (flg & PROJECT_LOS)
6770                 {
6771                         /* Hack -- Balls explode before reaching walls */
6772                         if (!cave_los_bold(ny, nx) && (rad > 0)) break;
6773                 }
6774                 else
6775                 {
6776                         /* Hack -- Balls explode before reaching walls */
6777                         if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && (rad > 0)) break;
6778                 }
6779
6780                 /* Advance */
6781                 y = ny;
6782                 x = nx;
6783
6784                 /* Collect beam grids */
6785                 if (flg & (PROJECT_BEAM))
6786                 {
6787                         gy[grids] = y;
6788                         gx[grids] = x;
6789                         grids++;
6790                 }
6791
6792                 /* Only do visuals if requested */
6793                 if (!blind && !(flg & (PROJECT_HIDE | PROJECT_FAST)))
6794                 {
6795                         /* Only do visuals if the player can "see" the bolt */
6796                         if (panel_contains(y, x) && player_has_los_bold(y, x))
6797                         {
6798                                 u16b p;
6799
6800                                 TERM_COLOR a;
6801                                 SYMBOL_CODE c;
6802
6803                                 /* Obtain the bolt pict */
6804                                 p = bolt_pict(oy, ox, y, x, typ);
6805
6806                                 /* Extract attr/char */
6807                                 a = PICT_A(p);
6808                                 c = PICT_C(p);
6809
6810                                 /* Visual effects */
6811                                 print_rel(c, a, y, x);
6812                                 move_cursor_relative(y, x);
6813                                 /*if (fresh_before)*/ Term_fresh();
6814                                 Term_xtra(TERM_XTRA_DELAY, msec);
6815                                 lite_spot(y, x);
6816                                 /*if (fresh_before)*/ Term_fresh();
6817
6818                                 /* Display "beam" grids */
6819                                 if (flg & (PROJECT_BEAM))
6820                                 {
6821                                         /* Obtain the explosion pict */
6822                                         p = bolt_pict(y, x, y, x, typ);
6823
6824                                         /* Extract attr/char */
6825                                         a = PICT_A(p);
6826                                         c = PICT_C(p);
6827
6828                                         /* Visual effects */
6829                                         print_rel(c, a, y, x);
6830                                 }
6831
6832                                 /* Hack -- Activate delay */
6833                                 visual = TRUE;
6834                         }
6835
6836                         /* Hack -- delay anyway for consistency */
6837                         else if (visual)
6838                         {
6839                                 /* Delay for consistency */
6840                                 Term_xtra(TERM_XTRA_DELAY, msec);
6841                         }
6842                 }
6843         }
6844
6845         path_n = i;
6846
6847         /* Save the "blast epicenter" */
6848         by = y;
6849         bx = x;
6850
6851         if (breath && !path_n)
6852         {
6853                 breath = FALSE;
6854                 gm_rad = rad;
6855                 if (!old_hide)
6856                 {
6857                         flg &= ~(PROJECT_HIDE);
6858                 }
6859         }
6860
6861         /* Start the "explosion" */
6862         gm[0] = 0;
6863
6864         /* Hack -- make sure beams get to "explode" */
6865         gm[1] = grids;
6866
6867         dist = path_n;
6868         dist_hack = dist;
6869
6870         project_length = 0;
6871
6872         /* If we found a "target", explode there */
6873         if (dist <= MAX_RANGE)
6874         {
6875                 /* Mega-Hack -- remove the final "beam" grid */
6876                 if ((flg & (PROJECT_BEAM)) && (grids > 0)) grids--;
6877
6878                 /*
6879                  * Create a conical breath attack
6880                  *
6881                  *       ***
6882                  *   ********
6883                  * D********@**
6884                  *   ********
6885                  *       ***
6886                  */
6887
6888                 if (breath)
6889                 {
6890                         flg &= ~(PROJECT_HIDE);
6891
6892                         breath_shape(path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
6893                 }
6894                 else
6895                 {
6896                         /* Determine the blast area, work from the inside out */
6897                         for (dist = 0; dist <= rad; dist++)
6898                         {
6899                                 /* Scan the maximal blast area of radius "dist" */
6900                                 for (y = by - dist; y <= by + dist; y++)
6901                                 {
6902                                         for (x = bx - dist; x <= bx + dist; x++)
6903                                         {
6904                                                 /* Ignore "illegal" locations */
6905                                                 if (!in_bounds2(y, x)) continue;
6906
6907                                                 /* Enforce a "circular" explosion */
6908                                                 if (distance(by, bx, y, x) != dist) continue;
6909
6910                                                 switch (typ)
6911                                                 {
6912                                                 case GF_LITE:
6913                                                 case GF_LITE_WEAK:
6914                                                         /* Lights are stopped by opaque terrains */
6915                                                         if (!los(by, bx, y, x)) continue;
6916                                                         break;
6917                                                 case GF_DISINTEGRATE:
6918                                                         /* Disintegration are stopped only by perma-walls */
6919                                                         if (!in_disintegration_range(by, bx, y, x)) continue;
6920                                                         break;
6921                                                 default:
6922                                                         /* Ball explosions are stopped by walls */
6923                                                         if (!projectable(by, bx, y, x)) continue;
6924                                                         break;
6925                                                 }
6926
6927                                                 /* Save this grid */
6928                                                 gy[grids] = y;
6929                                                 gx[grids] = x;
6930                                                 grids++;
6931                                         }
6932                                 }
6933
6934                                 /* Encode some more "radius" info */
6935                                 gm[dist+1] = grids;
6936                         }
6937                 }
6938         }
6939
6940         /* Speed -- ignore "non-explosions" */
6941         if (!grids) return (FALSE);
6942
6943
6944         /* Display the "blast area" if requested */
6945         if (!blind && !(flg & (PROJECT_HIDE)))
6946         {
6947                 /* Then do the "blast", from inside out */
6948                 for (t = 0; t <= gm_rad; t++)
6949                 {
6950                         /* Dump everything with this radius */
6951                         for (i = gm[t]; i < gm[t+1]; i++)
6952                         {
6953                                 /* Extract the location */
6954                                 y = gy[i];
6955                                 x = gx[i];
6956
6957                                 /* Only do visuals if the player can "see" the blast */
6958                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
6959                                 {
6960                                         u16b p;
6961
6962                                         TERM_COLOR a;
6963                                         SYMBOL_CODE c;
6964
6965                                         drawn = TRUE;
6966
6967                                         /* Obtain the explosion pict */
6968                                         p = bolt_pict(y, x, y, x, typ);
6969
6970                                         /* Extract attr/char */
6971                                         a = PICT_A(p);
6972                                         c = PICT_C(p);
6973
6974                                         /* Visual effects -- Display */
6975                                         print_rel(c, a, y, x);
6976                                 }
6977                         }
6978
6979                         /* Hack -- center the cursor */
6980                         move_cursor_relative(by, bx);
6981
6982                         /* Flush each "radius" seperately */
6983                         /*if (fresh_before)*/ Term_fresh();
6984
6985                         /* Delay (efficiently) */
6986                         if (visual || drawn)
6987                         {
6988                                 Term_xtra(TERM_XTRA_DELAY, msec);
6989                         }
6990                 }
6991
6992                 /* Flush the erasing */
6993                 if (drawn)
6994                 {
6995                         /* Erase the explosion drawn above */
6996                         for (i = 0; i < grids; i++)
6997                         {
6998                                 /* Extract the location */
6999                                 y = gy[i];
7000                                 x = gx[i];
7001
7002                                 /* Hack -- Erase if needed */
7003                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7004                                 {
7005                                         lite_spot(y, x);
7006                                 }
7007                         }
7008
7009                         /* Hack -- center the cursor */
7010                         move_cursor_relative(by, bx);
7011
7012                         /* Flush the explosion */
7013                         /*if (fresh_before)*/ Term_fresh();
7014                 }
7015         }
7016
7017         update_creature(p_ptr);
7018
7019         if (flg & PROJECT_KILL)
7020         {
7021                 see_s_msg = (who > 0) ? is_seen(&m_list[who]) :
7022                         (!who ? TRUE : (player_can_see_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)));
7023         }
7024
7025
7026         /* Check features */
7027         if (flg & (PROJECT_GRID))
7028         {
7029                 /* Start with "dist" of zero */
7030                 dist = 0;
7031
7032                 /* Scan for features */
7033                 for (i = 0; i < grids; i++)
7034                 {
7035                         /* Hack -- Notice new "dist" values */
7036                         if (gm[dist+1] == i) dist++;
7037
7038                         /* Get the grid location */
7039                         y = gy[i];
7040                         x = gx[i];
7041
7042                         /* Find the closest point in the blast */
7043                         if (breath)
7044                         {
7045                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7046
7047                                 /* Affect the grid */
7048                                 if (project_f(who, d, y, x, dam, typ)) notice = TRUE;
7049                         }
7050                         else
7051                         {
7052                                 /* Affect the grid */
7053                                 if (project_f(who, dist, y, x, dam, typ)) notice = TRUE;
7054                         }
7055                 }
7056         }
7057
7058         update_creature(p_ptr);
7059
7060         /* Check objects */
7061         if (flg & (PROJECT_ITEM))
7062         {
7063                 /* Start with "dist" of zero */
7064                 dist = 0;
7065
7066                 /* Scan for objects */
7067                 for (i = 0; i < grids; i++)
7068                 {
7069                         /* Hack -- Notice new "dist" values */
7070                         if (gm[dist+1] == i) dist++;
7071
7072                         /* Get the grid location */
7073                         y = gy[i];
7074                         x = gx[i];
7075
7076                         /* Find the closest point in the blast */
7077                         if (breath)
7078                         {
7079                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7080
7081                                 /* Affect the object in the grid */
7082                                 if (project_o(who, d, y, x, dam, typ)) notice = TRUE;
7083                         }
7084                         else
7085                         {
7086                                 /* Affect the object in the grid */
7087                                 if (project_o(who, dist, y, x, dam, typ)) notice = TRUE;
7088                         }
7089                 }
7090         }
7091
7092
7093         /* Check monsters */
7094         if (flg & (PROJECT_KILL))
7095         {
7096                 /* Mega-Hack */
7097                 project_m_n = 0;
7098                 project_m_x = 0;
7099                 project_m_y = 0;
7100
7101                 /* Start with "dist" of zero */
7102                 dist = 0;
7103
7104                 /* Scan for monsters */
7105                 for (i = 0; i < grids; i++)
7106                 {
7107                         int effective_dist;
7108
7109                         /* Hack -- Notice new "dist" values */
7110                         if (gm[dist + 1] == i) dist++;
7111
7112                         /* Get the grid location */
7113                         y = gy[i];
7114                         x = gx[i];
7115
7116                         /* A single bolt may be reflected */
7117                         if (grids <= 1)
7118                         {
7119                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7120                                 monster_race *ref_ptr = &r_info[m_ptr->r_idx];
7121
7122                                 if ((flg & PROJECT_REFLECTABLE) && cave[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) &&
7123                                         ((cave[y][x].m_idx != p_ptr->riding) || !(flg & PROJECT_PLAYER)) &&
7124                                         (!who || dist_hack > 1) && !one_in_(10))
7125                                 {
7126                                         POSITION t_y, t_x;
7127                                         int max_attempts = 10;
7128
7129                                         /* Choose 'new' target */
7130                                         do
7131                                         {
7132                                                 t_y = y_saver - 1 + randint1(3);
7133                                                 t_x = x_saver - 1 + randint1(3);
7134                                                 max_attempts--;
7135                                         }
7136                                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(y, x, t_y, t_x));
7137
7138                                         if (max_attempts < 1)
7139                                         {
7140                                                 t_y = y_saver;
7141                                                 t_x = x_saver;
7142                                         }
7143
7144                                         sound(SOUND_REFLECT);
7145                                         if (is_seen(m_ptr))
7146                                         {
7147                                                 if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU))
7148                                                         msg_print(_("「北斗神拳奥義・二指真空把!」", "The attack bounces!"));
7149                                                 else if (m_ptr->r_idx == MON_DIO) 
7150                                                         msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", "The attack bounces!"));
7151                                                 else 
7152                                                         msg_print(_("攻撃は跳ね返った!", "The attack bounces!"));
7153                                         }
7154                                         if (is_original_ap_and_seen(m_ptr)) ref_ptr->r_flags2 |= RF2_REFLECTING;
7155
7156                                         /* Reflected bolts randomly target either one */
7157                                         if (player_bold(y, x) || one_in_(2)) flg &= ~(PROJECT_PLAYER);
7158                                         else flg |= PROJECT_PLAYER;
7159
7160                                         /* The bolt is reflected */
7161                                         project(cave[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
7162
7163                                         /* Don't affect the monster any longer */
7164                                         continue;
7165                                 }
7166                         }
7167
7168
7169                         /* Find the closest point in the blast */
7170                         if (breath)
7171                         {
7172                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7173                         }
7174                         else
7175                         {
7176                                 effective_dist = dist;
7177                         }
7178
7179
7180                         /* There is the riding player on this monster */
7181                         if (p_ptr->riding && player_bold(y, x))
7182                         {
7183                                 /* Aimed on the player */
7184                                 if (flg & PROJECT_PLAYER)
7185                                 {
7186                                         if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7187                                         {
7188                                                 /*
7189                                                  * A beam or bolt is well aimed
7190                                                  * at the PLAYER!
7191                                                  * So don't affects the mount.
7192                                                  */
7193                                                 continue;
7194                                         }
7195                                         else
7196                                         {
7197                                                 /*
7198                                                  * The spell is not well aimed, 
7199                                                  * So partly affect the mount too.
7200                                                  */
7201                                                 effective_dist++;
7202                                         }
7203                                 }
7204
7205                                 /*
7206                                  * This grid is the original target.
7207                                  * Or aimed on your horse.
7208                                  */
7209                                 else if (((y == y2) && (x == x2)) || (flg & PROJECT_AIMED))
7210                                 {
7211                                         /* Hit the mount with full damage */
7212                                 }
7213
7214                                 /*
7215                                  * Otherwise this grid is not the
7216                                  * original target, it means that line
7217                                  * of fire is obstructed by this
7218                                  * monster.
7219                                  */
7220                                 /*
7221                                  * A beam or bolt will hit either
7222                                  * player or mount.  Choose randomly.
7223                                  */
7224                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE))
7225                                 {
7226                                         if (one_in_(2))
7227                                         {
7228                                                 /* Hit the mount with full damage */
7229                                         }
7230                                         else
7231                                         {
7232                                                 /* Hit the player later */
7233                                                 flg |= PROJECT_PLAYER;
7234
7235                                                 /* Don't affect the mount */
7236                                                 continue;
7237                                         }
7238                                 }
7239
7240                                 /*
7241                                  * The spell is not well aimed, so
7242                                  * partly affect both player and
7243                                  * mount.
7244                                  */
7245                                 else
7246                                 {
7247                                         effective_dist++;
7248                                 }
7249                         }
7250
7251                         /* Affect the monster in the grid */
7252                         if (project_m(who, effective_dist, y, x, dam, typ, flg, see_s_msg)) notice = TRUE;
7253                 }
7254
7255
7256                 /* Player affected one monster (without "jumping") */
7257                 if (!who && (project_m_n == 1) && !jump)
7258                 {
7259                         x = project_m_x;
7260                         y = project_m_y;
7261
7262                         /* Track if possible */
7263                         if (cave[y][x].m_idx > 0)
7264                         {
7265                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7266
7267                                 if (m_ptr->ml)
7268                                 {
7269                                         /* Hack -- auto-recall */
7270                                         if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7271
7272                                         /* Hack - auto-track */
7273                                         if (m_ptr->ml) health_track(cave[y][x].m_idx);
7274                                 }
7275                         }
7276                 }
7277         }
7278
7279
7280         /* Check player */
7281         if (flg & (PROJECT_KILL))
7282         {
7283                 /* Start with "dist" of zero */
7284                 dist = 0;
7285
7286                 /* Scan for player */
7287                 for (i = 0; i < grids; i++)
7288                 {
7289                         int effective_dist;
7290
7291                         /* Hack -- Notice new "dist" values */
7292                         if (gm[dist+1] == i) dist++;
7293
7294                         /* Get the grid location */
7295                         y = gy[i];
7296                         x = gx[i];
7297
7298                         /* Affect the player? */
7299                         if (!player_bold(y, x)) continue;
7300
7301                         /* Find the closest point in the blast */
7302                         if (breath)
7303                         {
7304                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7305                         }
7306                         else
7307                         {
7308                                 effective_dist = dist;
7309                         }
7310
7311                         /* Target may be your horse */
7312                         if (p_ptr->riding)
7313                         {
7314                                 /* Aimed on the player */
7315                                 if (flg & PROJECT_PLAYER)
7316                                 {
7317                                         /* Hit the player with full damage */
7318                                 }
7319
7320                                 /*
7321                                  * Hack -- When this grid was not the
7322                                  * original target, a beam or bolt
7323                                  * would hit either player or mount,
7324                                  * and should be choosen randomly.
7325                                  *
7326                                  * But already choosen to hit the
7327                                  * mount at this point.
7328                                  *
7329                                  * Or aimed on your horse.
7330                                  */
7331                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7332                                 {
7333                                         /*
7334                                          * A beam or bolt is well aimed
7335                                          * at the mount!
7336                                          * So don't affects the player.
7337                                          */
7338                                         continue;
7339                                 }
7340                                 else
7341                                 {
7342                                         /*
7343                                          * The spell is not well aimed, 
7344                                          * So partly affect the player too.
7345                                          */
7346                                         effective_dist++;
7347                                 }
7348                         }
7349
7350                         /* Affect the player */
7351                         if (project_p(who, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
7352                 }
7353         }
7354
7355         if (p_ptr->riding)
7356         {
7357                 GAME_TEXT m_name[MAX_NLEN];
7358
7359                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
7360
7361                 if (rakubadam_m > 0)
7362                 {
7363                         if (rakuba(rakubadam_m, FALSE))
7364                         {
7365                                 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
7366                         }
7367                 }
7368                 if (p_ptr->riding && rakubadam_p > 0)
7369                 {
7370                         if(rakuba(rakubadam_p, FALSE))
7371                         {
7372                                 msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_name);
7373                         }
7374                 }
7375         }
7376
7377         /* Return "something was noticed" */
7378         return (notice);
7379 }
7380
7381 /*!
7382  * @brief 鏡魔法「封魔結界」の効果処理
7383  * @param dam ダメージ量
7384  * @return 効果があったらTRUEを返す
7385  */
7386 bool binding_field(HIT_POINT dam)
7387 {
7388         POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
7389         int mirror_num = 0;                       /* 鏡の数 */
7390         POSITION x, y;
7391         POSITION centersign;
7392         POSITION x1, x2, y1, y2;
7393         u16b p;
7394         int msec = delay_factor*delay_factor*delay_factor;
7395
7396         /* 三角形の頂点 */
7397         POSITION point_x[3];
7398         POSITION point_y[3];
7399
7400         /* Default target of monsterspell is player */
7401         monster_target_y = p_ptr->y;
7402         monster_target_x = p_ptr->x;
7403
7404         for (x = 0; x < cur_wid; x++)
7405         {
7406                 for (y = 0; y < cur_hgt; y++)
7407                 {
7408                         if (is_mirror_grid(&cave[y][x]) &&
7409                                 distance(p_ptr->y, p_ptr->x, y, x) <= MAX_RANGE &&
7410                                 distance(p_ptr->y, p_ptr->x, y, x) != 0 &&
7411                                 player_has_los_bold(y, x) &&
7412                                 projectable(p_ptr->y, p_ptr->x, y, x)
7413                                 ) {
7414                                 mirror_y[mirror_num] = y;
7415                                 mirror_x[mirror_num] = x;
7416                                 mirror_num++;
7417                         }
7418                 }
7419         }
7420
7421         if (mirror_num < 2)return FALSE;
7422
7423         point_x[0] = randint0(mirror_num);
7424         do {
7425                 point_x[1] = randint0(mirror_num);
7426         } while (point_x[0] == point_x[1]);
7427
7428         point_y[0] = mirror_y[point_x[0]];
7429         point_x[0] = mirror_x[point_x[0]];
7430         point_y[1] = mirror_y[point_x[1]];
7431         point_x[1] = mirror_x[point_x[1]];
7432         point_y[2] = p_ptr->y;
7433         point_x[2] = p_ptr->x;
7434
7435         x = point_x[0] + point_x[1] + point_x[2];
7436         y = point_y[0] + point_y[1] + point_y[2];
7437
7438         centersign = (point_x[0] * 3 - x)*(point_y[1] * 3 - y)
7439                 - (point_y[0] * 3 - y)*(point_x[1] * 3 - x);
7440         if (centersign == 0)return FALSE;
7441
7442         x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
7443         x1 = x1 < point_x[2] ? x1 : point_x[2];
7444         y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
7445         y1 = y1 < point_y[2] ? y1 : point_y[2];
7446
7447         x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
7448         x2 = x2 > point_x[2] ? x2 : point_x[2];
7449         y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
7450         y2 = y2 > point_y[2] ? y2 : point_y[2];
7451
7452         for (y = y1; y <= y2; y++) {
7453                 for (x = x1; x <= x2; x++) {
7454                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7455                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7456                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7457                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7458                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7459                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7460                         {
7461                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7462                                         /* Visual effects */
7463                                         if (!(p_ptr->blind)
7464                                                 && panel_contains(y, x)) {
7465                                                 p = bolt_pict(y, x, y, x, GF_MANA);
7466                                                 print_rel(PICT_C(p), PICT_A(p), y, x);
7467                                                 move_cursor_relative(y, x);
7468                                                 /*if (fresh_before)*/ Term_fresh();
7469                                                 Term_xtra(TERM_XTRA_DELAY, msec);
7470                                         }
7471                                 }
7472                         }
7473                 }
7474         }
7475         for (y = y1; y <= y2; y++) {
7476                 for (x = x1; x <= x2; x++) {
7477                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7478                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7479                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7480                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7481                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7482                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7483                         {
7484                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7485                                         (void)project_f(0, 0, y, x, dam, GF_MANA);
7486                                 }
7487                         }
7488                 }
7489         }
7490         for (y = y1; y <= y2; y++) {
7491                 for (x = x1; x <= x2; x++) {
7492                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7493                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7494                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7495                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7496                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7497                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7498                         {
7499                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7500                                         (void)project_o(0, 0, y, x, dam, GF_MANA);
7501                                 }
7502                         }
7503                 }
7504         }
7505         for (y = y1; y <= y2; y++) {
7506                 for (x = x1; x <= x2; x++) {
7507                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7508                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7509                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7510                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7511                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7512                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7513                         {
7514                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7515                                         (void)project_m(0, 0, y, x, dam, GF_MANA,
7516                                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
7517                                 }
7518                         }
7519                 }
7520         }
7521         if (one_in_(7)) {
7522                 msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
7523                 remove_mirror(point_y[0], point_x[0]);
7524         }
7525
7526         return TRUE;
7527 }
7528
7529 /*!
7530  * @brief 鏡魔法「鏡の封印」の効果処理
7531  * @param dam ダメージ量
7532  * @return 効果があったらTRUEを返す
7533  */
7534 void seal_of_mirror(HIT_POINT dam)
7535 {
7536         POSITION x, y;
7537
7538         for (x = 0; x < cur_wid; x++)
7539         {
7540                 for (y = 0; y < cur_hgt; y++)
7541                 {
7542                         if (is_mirror_grid(&cave[y][x]))
7543                         {
7544                                 if (project_m(0, 0, y, x, dam, GF_GENOCIDE,
7545                                         (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
7546                                 {
7547                                         if (!cave[y][x].m_idx)
7548                                         {
7549                                                 remove_mirror(y, x);
7550                                         }
7551                                 }
7552                         }
7553                 }
7554         }
7555         return;
7556 }
7557