OSDN Git Service

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