OSDN Git Service

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