OSDN Git Service

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