OSDN Git Service

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