OSDN Git Service

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