OSDN Git Service

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