OSDN Git Service

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