OSDN Git Service

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