OSDN Git Service

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