OSDN Git Service

[Refactor] #37353 NIKKI_* をDIARY_* に改名 / Changed NIKKI_* to DIARY_*
[hengband/hengband.git] / src / spells2.c
1 /*!
2  * @file spells2.c
3  * @brief 魔法効果の実装/ Spell code (part 2)
4  * @date 2014/07/15
5  * @author
6  * <pre>
7  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  * </pre>
12  */
13
14 #include "angband.h"
15 #include "core.h"
16 #include "util.h"
17
18 #include "creature.h"
19
20 #include "artifact.h"
21 #include "cmd-pet.h"
22 #include "cmd-dump.h"
23 #include "floor.h"
24 #include "grid.h"
25 #include "trap.h"
26 #include "monsterrace-hook.h"
27 #include "melee.h"
28 #include "world.h"
29 #include "spells.h"
30 #include "spells-summon.h"
31 #include "mutation.h"
32 #include "quest.h"
33 #include "avatar.h"
34
35 #include "spells-status.h"
36 #include "spells-floor.h"
37 #include "spells-diceroll.h"
38 #include "realm-hex.h"
39 #include "autopick.h"
40 #include "object-flavor.h"
41 #include "object-hook.h"
42 #include "monster-status.h"
43 #include "player-move.h"
44 #include "player-status.h"
45 #include "player-effects.h"
46 #include "player-skill.h"
47 #include "player-class.h"
48 #include "player-damage.h"
49 #include "player-inventory.h"
50
51 #include "dungeon.h"
52 #include "floor-events.h"
53 #include "feature.h"
54 #include "view-mainwindow.h"
55 #include "objectkind.h"
56 #include "monsterrace.h"
57 #include "targeting.h"
58 #include "realm-song.h"
59 #include "english.h"
60
61 /*!
62  * @brief プレイヤー周辺の地形を感知する
63  * @param caster_ptr プレーヤーへの参照ポインタ
64  * @param range 効果範囲
65  * @param flag 特定地形ID
66  * @param known 地形から危険フラグを外すならTRUE
67  * @return 効力があった場合TRUEを返す
68  */
69 static bool detect_feat_flag(player_type *caster_ptr, POSITION range, int flag, bool known)
70 {
71         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
72
73         /* Scan the current panel */
74         grid_type *g_ptr;
75         bool detect = FALSE;
76         for (POSITION y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
77         {
78                 for (POSITION x = 1; x <= caster_ptr->current_floor_ptr->width - 1; x++)
79                 {
80                         int dist = distance(caster_ptr->y, caster_ptr->x, y, x);
81                         if (dist > range) continue;
82                         g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
83
84                         /* Hack -- Safe */
85                         if (flag == FF_TRAP)
86                         {
87                                 /* Mark as detected */
88                                 if (dist <= range && known)
89                                 {
90                                         if (dist <= range - 1) g_ptr->info |= (CAVE_IN_DETECT);
91
92                                         g_ptr->info &= ~(CAVE_UNSAFE);
93
94                                         lite_spot(y, x);
95                                 }
96                         }
97
98                         if (cave_have_flag_grid(g_ptr, flag))
99                         {
100                                 disclose_grid(caster_ptr, y, x);
101                                 g_ptr->info |= (CAVE_MARK);
102                                 lite_spot(y, x);
103                                 detect = TRUE;
104                         }
105                 }
106         }
107
108         return detect;
109 }
110
111
112 /*!
113  * @brief プレイヤー周辺のトラップを感知する / Detect all traps on current panel
114  * @param caster_ptr プレーヤーへの参照ポインタ
115  * @param range 効果範囲
116  * @param known 感知外範囲を超える警告フラグを立てる場合TRUEを返す
117  * @return 効力があった場合TRUEを返す
118  */
119 bool detect_traps(player_type *caster_ptr, POSITION range, bool known)
120 {
121         bool detect = detect_feat_flag(caster_ptr, range, FF_TRAP, known);
122
123         if (known) caster_ptr->dtrap = TRUE;
124
125         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 0) detect = FALSE;
126         if (detect)
127         {
128                 msg_print(_("トラップの存在を感じとった!", "You sense the presence of traps!"));
129         }
130
131         return detect;
132 }
133
134
135 /*!
136  * @brief プレイヤー周辺のドアを感知する / Detect all doors on current panel
137  * @param caster_ptr プレーヤーへの参照ポインタ
138  * @param range 効果範囲
139  * @return 効力があった場合TRUEを返す
140  */
141 bool detect_doors(player_type *caster_ptr, POSITION range)
142 {
143         bool detect = detect_feat_flag(caster_ptr, range, FF_DOOR, TRUE);
144
145         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 0) detect = FALSE;
146         if (detect)
147         {
148                 msg_print(_("ドアの存在を感じとった!", "You sense the presence of doors!"));
149         }
150
151         return detect;
152 }
153
154
155 /*!
156  * @brief プレイヤー周辺の階段を感知する / Detect all stairs on current panel
157  * @param caster_ptr プレーヤーへの参照ポインタ
158  * @param range 効果範囲
159  * @return 効力があった場合TRUEを返す
160  */
161 bool detect_stairs(player_type *caster_ptr, POSITION range)
162 {
163         bool detect = detect_feat_flag(caster_ptr, range, FF_STAIRS, TRUE);
164
165         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 0) detect = FALSE;
166         if (detect)
167         {
168                 msg_print(_("階段の存在を感じとった!", "You sense the presence of stairs!"));
169         }
170
171         return detect;
172 }
173
174
175 /*!
176  * @brief プレイヤー周辺の地形財宝を感知する / Detect any treasure on the current panel
177  * @param caster_ptr プレーヤーへの参照ポインタ
178  * @param range 効果範囲
179  * @return 効力があった場合TRUEを返す
180  */
181 bool detect_treasure(player_type *caster_ptr, POSITION range)
182 {
183         bool detect = detect_feat_flag(caster_ptr, range, FF_HAS_GOLD, TRUE);
184
185         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 6) detect = FALSE;
186         if (detect)
187         {
188                 msg_print(_("埋蔵された財宝の存在を感じとった!", "You sense the presence of buried treasure!"));
189         }
190
191         return detect;
192 }
193
194
195 /*!
196  * @brief プレイヤー周辺のアイテム財宝を感知する / Detect all "gold" objects on the current panel
197  * @param caster_ptr プレーヤーへの参照ポインタ
198  * @param range 効果範囲
199  * @return 効力があった場合TRUEを返す
200  */
201 bool detect_objects_gold(player_type *caster_ptr, POSITION range)
202 {
203         POSITION range2 = range;
204         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range2 /= 3;
205
206         /* Scan objects */
207         bool detect = FALSE;
208         POSITION y, x;
209         for (OBJECT_IDX i = 1; i < caster_ptr->current_floor_ptr->o_max; i++)
210         {
211                 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[i];
212
213                 if (!OBJECT_IS_VALID(o_ptr)) continue;
214                 if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
215
216                 y = o_ptr->iy;
217                 x = o_ptr->ix;
218
219                 /* Only detect nearby objects */
220                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range2) continue;
221
222                 /* Detect "gold" objects */
223                 if (o_ptr->tval == TV_GOLD)
224                 {
225                         o_ptr->marked |= OM_FOUND;
226                         lite_spot(y, x);
227                         detect = TRUE;
228                 }
229         }
230
231         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 6) detect = FALSE;
232         if (detect)
233         {
234                 msg_print(_("財宝の存在を感じとった!", "You sense the presence of treasure!"));
235         }
236
237         if (detect_monsters_string(caster_ptr, range, "$"))
238         {
239                 detect = TRUE;
240         }
241
242         return detect;
243 }
244
245
246 /*!
247  * @brief 通常のアイテムオブジェクトを感知する / Detect all "normal" objects on the current panel
248  * @param caster_ptr プレーヤーへの参照ポインタ
249  * @param range 効果範囲
250  * @return 効力があった場合TRUEを返す
251  */
252 bool detect_objects_normal(player_type *caster_ptr, POSITION range)
253 {
254         POSITION range2 = range;
255         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range2 /= 3;
256
257         /* Scan objects */
258         POSITION y, x;
259         bool detect = FALSE;
260         for (OBJECT_IDX i = 1; i < caster_ptr->current_floor_ptr->o_max; i++)
261         {
262                 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[i];
263
264                 if (!OBJECT_IS_VALID(o_ptr)) continue;
265                 if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
266
267                 y = o_ptr->iy;
268                 x = o_ptr->ix;
269
270                 /* Only detect nearby objects */
271                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range2) continue;
272
273                 /* Detect "real" objects */
274                 if (o_ptr->tval != TV_GOLD)
275                 {
276                         o_ptr->marked |= OM_FOUND;
277                         lite_spot(y, x);
278                         detect = TRUE;
279                 }
280         }
281
282         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 6) detect = FALSE;
283         if (detect)
284         {
285                 msg_print(_("アイテムの存在を感じとった!", "You sense the presence of objects!"));
286         }
287
288         if (detect_monsters_string(caster_ptr, range, "!=?|/`"))
289         {
290                 detect = TRUE;
291         }
292
293         return detect;
294 }
295
296
297 /*!
298  * @brief 魔法効果のあるのアイテムオブジェクトを感知する / Detect all "magic" objects on the current panel.
299  * @param caster_ptr プレーヤーへの参照ポインタ
300  * @param range 効果範囲
301  * @return 効力があった場合TRUEを返す
302  * @details
303  * <pre>
304  * This will light up all spaces with "magic" items, including artifacts,
305  * ego-items, potions, scrolls, books, rods, wands, staves, amulets, rings,
306  * and "enchanted" items of the "good" variety.
307  *
308  * It can probably be argued that this function is now too powerful.
309  * </pre>
310  */
311 bool detect_objects_magic(player_type *caster_ptr, POSITION range)
312 {
313         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
314
315         /* Scan all objects */
316         OBJECT_TYPE_VALUE tv;
317         POSITION y, x;
318         bool detect = FALSE;
319         for (OBJECT_IDX i = 1; i < caster_ptr->current_floor_ptr->o_max; i++)
320         {
321                 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[i];
322
323                 if (!OBJECT_IS_VALID(o_ptr)) continue;
324                 if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
325
326                 y = o_ptr->iy;
327                 x = o_ptr->ix;
328
329                 /* Only detect nearby objects */
330                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
331
332                 /* Examine the tval */
333                 tv = o_ptr->tval;
334
335                 /* Artifacts, misc magic items, or enchanted wearables */
336                 if (object_is_artifact(o_ptr) ||
337                         object_is_ego(o_ptr) ||
338                     (tv == TV_WHISTLE) ||
339                     (tv == TV_AMULET) ||
340                         (tv == TV_RING) ||
341                     (tv == TV_STAFF) ||
342                         (tv == TV_WAND) ||
343                         (tv == TV_ROD) ||
344                     (tv == TV_SCROLL) ||
345                         (tv == TV_POTION) ||
346                     (tv == TV_LIFE_BOOK) ||
347                         (tv == TV_SORCERY_BOOK) ||
348                     (tv == TV_NATURE_BOOK) ||
349                         (tv == TV_CHAOS_BOOK) ||
350                     (tv == TV_DEATH_BOOK) ||
351                     (tv == TV_TRUMP_BOOK) ||
352                         (tv == TV_ARCANE_BOOK) ||
353                         (tv == TV_CRAFT_BOOK) ||
354                         (tv == TV_DAEMON_BOOK) ||
355                         (tv == TV_CRUSADE_BOOK) ||
356                         (tv == TV_MUSIC_BOOK) ||
357                         (tv == TV_HISSATSU_BOOK) ||
358                         (tv == TV_HEX_BOOK) ||
359                     ((o_ptr->to_a > 0) || (o_ptr->to_h + o_ptr->to_d > 0)))
360                 {
361                         /* Memorize the item */
362                         o_ptr->marked |= OM_FOUND;
363                         lite_spot(y, x);
364                         detect = TRUE;
365                 }
366         }
367
368         if (detect)
369         {
370                 msg_print(_("魔法のアイテムの存在を感じとった!", "You sense the presence of magic objects!"));
371         }
372
373         return detect;
374 }
375
376
377 /*!
378  * @brief 一般のモンスターを感知する / Detect all "normal" monsters on the current panel
379  * @param caster_ptr プレーヤーへの参照ポインタ
380  * @param range 効果範囲
381  * @return 効力があった場合TRUEを返す
382  */
383 bool detect_monsters_normal(player_type *caster_ptr, POSITION range)
384 {
385         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
386
387         POSITION y, x;
388         bool flag = FALSE;
389         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
390         {
391                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
392                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
393                 if (!monster_is_valid(m_ptr)) continue;
394
395                 y = m_ptr->fy;
396                 x = m_ptr->fx;
397
398                 /* Only detect nearby monsters */
399                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
400
401                 /* Detect all non-invisible monsters */
402                 if (!(r_ptr->flags2 & RF2_INVISIBLE) || caster_ptr->see_inv)
403                 {
404                         /* Repair visibility later */
405                         repair_monsters = TRUE;
406
407                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
408                         update_monster(caster_ptr, i, FALSE);
409                         flag = TRUE;
410                 }
411         }
412
413         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 3) flag = FALSE;
414         if (flag)
415         {
416                 msg_print(_("モンスターの存在を感じとった!", "You sense the presence of monsters!"));
417         }
418
419         return flag;
420 }
421
422
423 /*!
424  * @brief 不可視のモンスターを感知する / Detect all "invisible" monsters around the player
425  * @param caster_ptr プレーヤーへの参照ポインタ
426  * @param range 効果範囲
427  * @return 効力があった場合TRUEを返す
428  */
429 bool detect_monsters_invis(player_type *caster_ptr, POSITION range)
430 {
431         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
432
433         POSITION y, x;
434         bool flag = FALSE;
435         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
436         {
437                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
438                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
439
440                 if (!monster_is_valid(m_ptr)) continue;
441
442                 y = m_ptr->fy;
443                 x = m_ptr->fx;
444
445                 /* Only detect nearby monsters */
446                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
447
448                 /* Detect invisible monsters */
449                 if (r_ptr->flags2 & RF2_INVISIBLE)
450                 {
451                         /* Update monster recall window */
452                         if (caster_ptr->monster_race_idx == m_ptr->r_idx)
453                         {
454                                 caster_ptr->window |= (PW_MONSTER);
455                         }
456
457                         /* Repair visibility later */
458                         repair_monsters = TRUE;
459
460                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
461                         update_monster(caster_ptr, i, FALSE);
462                         flag = TRUE;
463                 }
464         }
465
466         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 3) flag = FALSE;
467         if (flag)
468         {
469                 msg_print(_("透明な生物の存在を感じとった!", "You sense the presence of invisible creatures!"));
470         }
471
472         return flag;
473 }
474
475 /*!
476  * @brief 邪悪なモンスターを感知する / Detect all "evil" monsters on current panel
477  * @param caster_ptr プレーヤーへの参照ポインタ
478  * @param range 効果範囲
479  * @return 効力があった場合TRUEを返す
480  */
481 bool detect_monsters_evil(player_type *caster_ptr, POSITION range)
482 {
483         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
484
485         POSITION y, x;
486         bool flag = FALSE;
487         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
488         {
489                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
490                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
491                 if (!monster_is_valid(m_ptr)) continue;
492
493                 y = m_ptr->fy;
494                 x = m_ptr->fx;
495
496                 /* Only detect nearby monsters */
497                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
498
499                 /* Detect evil monsters */
500                 if (r_ptr->flags3 & RF3_EVIL)
501                 {
502                         if (is_original_ap(m_ptr))
503                         {
504                                 /* Take note that they are evil */
505                                 r_ptr->r_flags3 |= (RF3_EVIL);
506
507                                 /* Update monster recall window */
508                                 if (caster_ptr->monster_race_idx == m_ptr->r_idx)
509                                 {
510                                         caster_ptr->window |= (PW_MONSTER);
511                                 }
512                         }
513
514                         /* Repair visibility later */
515                         repair_monsters = TRUE;
516
517                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
518                         update_monster(caster_ptr, i, FALSE);
519                         flag = TRUE;
520                 }
521         }
522
523         if (flag)
524         {
525                 msg_print(_("邪悪なる生物の存在を感じとった!", "You sense the presence of evil creatures!"));
526         }
527
528         return flag;
529 }
530
531 /*!
532  * @brief 無生命のモンスターを感知する(アンデッド、悪魔系を含む) / Detect all "nonliving", "undead" or "demonic" monsters on current panel
533  * @param caster_ptr プレーヤーへの参照ポインタ
534  * @param range 効果範囲
535  * @return 効力があった場合TRUEを返す
536  */
537 bool detect_monsters_nonliving(player_type *caster_ptr, POSITION range)
538 {
539         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
540
541         POSITION y, x;
542         bool flag = FALSE;
543         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
544         {
545                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
546                 if (!monster_is_valid(m_ptr)) continue;
547
548                 y = m_ptr->fy;
549                 x = m_ptr->fx;
550
551                 /* Only detect nearby monsters */
552                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
553
554                 /* Detect non-living monsters */
555                 if (!monster_living(m_ptr->r_idx))
556                 {
557                         /* Update monster recall window */
558                         if (caster_ptr->monster_race_idx == m_ptr->r_idx)
559                         {
560                                 caster_ptr->window |= (PW_MONSTER);
561                         }
562
563                         /* Repair visibility later */
564                         repair_monsters = TRUE;
565
566                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
567                         update_monster(caster_ptr, i, FALSE);
568                         flag = TRUE;
569                 }
570         }
571
572         if (flag)
573         {
574                 msg_print(_("自然でないモンスターの存在を感じた!", "You sense the presence of unnatural beings!"));
575         }
576
577         return flag;
578 }
579
580 /*!
581  * @brief 精神のあるモンスターを感知する / Detect all monsters it has mind on current panel
582  * @param caster_ptr プレーヤーへの参照ポインタ
583  * @param range 効果範囲
584  * @return 効力があった場合TRUEを返す
585  */
586 bool detect_monsters_mind(player_type *caster_ptr, POSITION range)
587 {
588         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
589
590         POSITION y, x;
591         bool flag = FALSE;
592         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
593         {
594                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
595                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
596                 if (!monster_is_valid(m_ptr)) continue;
597
598                 y = m_ptr->fy;
599                 x = m_ptr->fx;
600
601                 /* Only detect nearby monsters */
602                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
603
604                 /* Detect non-living monsters */
605                 if (!(r_ptr->flags2 & RF2_EMPTY_MIND))
606                 {
607                         /* Update monster recall window */
608                         if (caster_ptr->monster_race_idx == m_ptr->r_idx)
609                         {
610                                 caster_ptr->window |= (PW_MONSTER);
611                         }
612
613                         /* Repair visibility later */
614                         repair_monsters = TRUE;
615
616                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
617                         update_monster(caster_ptr, i, FALSE);
618                         flag = TRUE;
619                 }
620         }
621
622         if (flag)
623         {
624                 msg_print(_("殺気を感じとった!", "You sense the presence of someone's mind!"));
625         }
626
627         return flag;
628 }
629
630
631 /*!
632  * @brief 該当シンボルのモンスターを感知する / Detect all (string) monsters on current panel
633  * @param caster_ptr プレーヤーへの参照ポインタ
634  * @param range 効果範囲
635  * @param Match 対応シンボルの混じったモンスター文字列(複数指定化)
636  * @return 効力があった場合TRUEを返す
637  */
638 bool detect_monsters_string(player_type *caster_ptr, POSITION range, concptr Match)
639 {
640         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
641
642         POSITION y, x;
643         bool flag = FALSE;
644         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
645         {
646                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
647                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
648                 if (!monster_is_valid(m_ptr)) continue;
649
650                 y = m_ptr->fy;
651                 x = m_ptr->fx;
652
653                 /* Only detect nearby monsters */
654                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
655
656                 /* Detect monsters with the same symbol */
657                 if (my_strchr(Match, r_ptr->d_char))
658                 {
659                         /* Update monster recall window */
660                         if (caster_ptr->monster_race_idx == m_ptr->r_idx)
661                         {
662                                 caster_ptr->window |= (PW_MONSTER);
663                         }
664
665                         /* Repair visibility later */
666                         repair_monsters = TRUE;
667
668                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
669                         update_monster(caster_ptr, i, FALSE);
670                         flag = TRUE;
671                 }
672         }
673
674         if (music_singing(caster_ptr, MUSIC_DETECT) && SINGING_COUNT(caster_ptr) > 3) flag = FALSE;
675         if (flag)
676         {
677                 msg_print(_("モンスターの存在を感じとった!", "You sense the presence of monsters!"));
678         }
679
680         return flag;
681 }
682
683 /*!
684  * @brief flags3に対応するモンスターを感知する / A "generic" detect monsters routine, tagged to flags3
685  * @param caster_ptr プレーヤーへの参照ポインタ
686  * @param range 効果範囲
687  * @param match_flag 感知フラグ
688  * @return 効力があった場合TRUEを返す
689  */
690 bool detect_monsters_xxx(player_type *caster_ptr, POSITION range, u32b match_flag)
691 {
692         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
693
694         POSITION y, x;
695         bool flag = FALSE;
696         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
697         {
698                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
699                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
700                 if (!monster_is_valid(m_ptr)) continue;
701
702                 y = m_ptr->fy;
703                 x = m_ptr->fx;
704
705                 /* Only detect nearby monsters */
706                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
707
708                 /* Detect evil monsters */
709                 if (r_ptr->flags3 & (match_flag))
710                 {
711                         if (is_original_ap(m_ptr))
712                         {
713                                 /* Take note that they are something */
714                                 r_ptr->r_flags3 |= (match_flag);
715
716                                 /* Update monster recall window */
717                                 if (caster_ptr->monster_race_idx == m_ptr->r_idx)
718                                 {
719                                         caster_ptr->window |= (PW_MONSTER);
720                                 }
721                         }
722
723                         /* Repair visibility later */
724                         repair_monsters = TRUE;
725
726                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
727                         update_monster(caster_ptr, i, FALSE);
728                         flag = TRUE;
729                 }
730         }
731
732         concptr desc_monsters = _("変なモンスター", "weird monsters");
733         if (flag)
734         {
735                 switch (match_flag)
736                 {
737                         case RF3_DEMON:
738                         desc_monsters = _("デーモン", "demons");
739                                 break;
740                         case RF3_UNDEAD:
741                         desc_monsters = _("アンデッド", "the undead");
742                                 break;
743                 }
744
745                 msg_format(_("%sの存在を感じとった!", "You sense the presence of %s!"), desc_monsters);
746                 msg_print(NULL);
747         }
748
749         return flag;
750 }
751
752
753 /*!
754  * @brief 全感知処理 / Detect everything
755  * @param caster_ptr プレーヤーへの参照ポインタ
756  * @param range 効果範囲
757  * @return 効力があった場合TRUEを返す
758  */
759 bool detect_all(player_type *caster_ptr, POSITION range)
760 {
761         bool detect = FALSE;
762
763         /* Detect everything */
764         if (detect_traps(caster_ptr, range, TRUE)) detect = TRUE;
765         if (detect_doors(caster_ptr, range)) detect = TRUE;
766         if (detect_stairs(caster_ptr, range)) detect = TRUE;
767
768         /* There are too many hidden treasure.  So... */
769         /* if (detect_treasure(range)) detect = TRUE; */
770
771         if (detect_objects_gold(caster_ptr, range)) detect = TRUE;
772         if (detect_objects_normal(caster_ptr, range)) detect = TRUE;
773         if (detect_monsters_invis(caster_ptr, range)) detect = TRUE;
774         if (detect_monsters_normal(caster_ptr, range)) detect = TRUE;
775         return (detect);
776 }
777
778
779 /*!
780  * @brief 視界内モンスターに魔法効果を与える / Apply a "project()" directly to all viewable monsters
781  * @param typ 属性効果
782  * @param dam 効果量
783  * @return 効力があった場合TRUEを返す
784  * @details
785  * <pre>
786  * Note that affected monsters are NOT auto-tracked by this usage.
787  *
788  * To avoid misbehavior when monster deaths have side-effects,
789  * this is done in two passes. -- JDL
790  * </pre>
791  */
792 bool project_all_los(player_type *caster_ptr, EFFECT_ID typ, HIT_POINT dam)
793 {
794         /* Mark all (nearby) monsters */
795         POSITION x, y;
796         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
797         {
798                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
799                 if (!monster_is_valid(m_ptr)) continue;
800
801                 y = m_ptr->fy;
802                 x = m_ptr->fx;
803
804                 /* Require line of sight */
805                 if (!player_has_los_bold(caster_ptr, y, x) || !projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)) continue;
806
807                 /* Mark the monster */
808                 m_ptr->mflag |= (MFLAG_LOS);
809         }
810
811         /* Affect all marked monsters */
812         BIT_FLAGS flg = PROJECT_JUMP | PROJECT_KILL | PROJECT_HIDE;
813         bool obvious = FALSE;
814         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
815         {
816                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
817
818                 /* Skip unmarked monsters */
819                 if (!(m_ptr->mflag & (MFLAG_LOS))) continue;
820
821                 /* Remove mark */
822                 m_ptr->mflag &= ~(MFLAG_LOS);
823
824                 y = m_ptr->fy;
825                 x = m_ptr->fx;
826
827                 /* Jump directly to the target monster */
828                 if (project(caster_ptr, 0, 0, y, x, dam, typ, flg, -1)) obvious = TRUE;
829         }
830
831         return obvious;
832 }
833
834
835 /*!
836  * @brief 視界内モンスターを加速する処理 / Speed monsters
837  * @param caster_ptr プレーヤーへの参照ポインタ
838  * @return 効力があった場合TRUEを返す
839  */
840 bool speed_monsters(player_type *caster_ptr)
841 {
842         return (project_all_los(caster_ptr, GF_OLD_SPEED, caster_ptr->lev));
843 }
844
845
846 /*!
847  * @brief 視界内モンスターを加速する処理 / Slow monsters
848  * @param caster_ptr プレーヤーへの参照ポインタ
849  * @return 効力があった場合TRUEを返す
850  */
851 bool slow_monsters(player_type *caster_ptr, int power)
852 {
853         return (project_all_los(caster_ptr, GF_OLD_SLOW, power));
854 }
855
856
857 /*!
858  * @brief 視界内モンスターを眠らせる処理 / Sleep monsters
859  * @param caster_ptr プレーヤーへの参照ポインタ
860  * @return 効力があった場合TRUEを返す
861  */
862 bool sleep_monsters(player_type *caster_ptr, int power)
863 {
864         return (project_all_los(caster_ptr, GF_OLD_SLEEP, power));
865 }
866
867
868 /*!
869  * @brief 視界内の邪悪なモンスターをテレポート・アウェイさせる処理 / Banish evil monsters
870  * @param caster_ptr プレーヤーへの参照ポインタ
871  * @return 効力があった場合TRUEを返す
872  */
873 bool banish_evil(player_type *caster_ptr, int dist)
874 {
875         return (project_all_los(caster_ptr, GF_AWAY_EVIL, dist));
876 }
877
878
879 /*!
880  * @brief 視界内のアンデッド・モンスターを恐怖させる処理 / Turn undead
881  * @return 効力があった場合TRUEを返す
882  */
883 bool turn_undead(player_type *caster_ptr)
884 {
885         bool tester = (project_all_los(caster_ptr, GF_TURN_UNDEAD, caster_ptr->lev));
886         if (tester)
887                 chg_virtue(caster_ptr, V_UNLIFE, -1);
888         return tester;
889 }
890
891
892 /*!
893  * @brief 視界内のアンデッド・モンスターにダメージを与える処理 / Dispel undead monsters
894  * @param caster_ptr プレーヤーへの参照ポインタ
895  * @return 効力があった場合TRUEを返す
896  */
897 bool dispel_undead(player_type *caster_ptr, HIT_POINT dam)
898 {
899         bool tester = (project_all_los(caster_ptr, GF_DISP_UNDEAD, dam));
900         if (tester)
901                 chg_virtue(caster_ptr, V_UNLIFE, -2);
902         return tester;
903 }
904
905
906 /*!
907  * @brief 視界内の邪悪なモンスターにダメージを与える処理 / Dispel evil monsters
908  * @param caster_ptr プレーヤーへの参照ポインタ
909  * @return 効力があった場合TRUEを返す
910  */
911 bool dispel_evil(player_type *caster_ptr, HIT_POINT dam)
912 {
913         return (project_all_los(caster_ptr, GF_DISP_EVIL, dam));
914 }
915
916
917 /*!
918  * @brief 視界内の善良なモンスターにダメージを与える処理 / Dispel good monsters
919  * @param caster_ptr プレーヤーへの参照ポインタ
920  * @return 効力があった場合TRUEを返す
921  */
922 bool dispel_good(player_type *caster_ptr, HIT_POINT dam)
923 {
924         return (project_all_los(caster_ptr, GF_DISP_GOOD, dam));
925 }
926
927
928 /*!
929  * @brief 視界内のあらゆるモンスターにダメージを与える処理 / Dispel all monsters
930  * @param caster_ptr プレーヤーへの参照ポインタ
931  * @return 効力があった場合TRUEを返す
932  */
933 bool dispel_monsters(player_type *caster_ptr, HIT_POINT dam)
934 {
935         return (project_all_los(caster_ptr, GF_DISP_ALL, dam));
936 }
937
938
939 bool cleansing_nova(player_type *creature_ptr, bool magic, bool powerful)
940 {
941         bool ident = FALSE;
942         if (dispel_evil(creature_ptr, powerful ? 225 : 150)) ident = TRUE;
943         int k = 3 * creature_ptr->lev;
944         if (set_protevil(creature_ptr, (magic ? 0 : creature_ptr->protevil) + randint1(25) + k, FALSE)) ident = TRUE;
945         if (set_poisoned(creature_ptr, 0)) ident = TRUE;
946         if (set_afraid(creature_ptr, 0)) ident = TRUE;
947         if (hp_player(creature_ptr, 50)) ident = TRUE;
948         if (set_stun(creature_ptr, 0)) ident = TRUE;
949         if (set_cut(creature_ptr,0)) ident = TRUE;
950         return ident;
951 }
952
953
954 bool unleash_mana_storm(player_type *creature_ptr, bool powerful)
955 {
956         msg_print(_("強力な魔力が敵を引き裂いた!", "Mighty magics rend your enemies!"));
957         project(creature_ptr, 0, (powerful ? 7 : 5), creature_ptr->y, creature_ptr->x,
958         (randint1(200) + (powerful ? 500 : 300)) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID, -1);
959
960         bool is_special_class = creature_ptr->pclass != CLASS_MAGE;
961         is_special_class &= creature_ptr->pclass != CLASS_HIGH_MAGE;
962         is_special_class &= creature_ptr->pclass != CLASS_SORCERER;
963         is_special_class &= creature_ptr->pclass != CLASS_MAGIC_EATER;
964         is_special_class &= creature_ptr->pclass != CLASS_BLUE_MAGE;
965         if (is_special_class)
966         {
967                 (void)take_hit(creature_ptr, DAMAGE_NOESCAPE, 50, _("コントロールし難い強力な魔力の解放", "unleashing magics too mighty to control"), -1);
968         }
969
970         return TRUE;
971 }
972
973
974 /*!
975  * @brief 視界内の生命のあるモンスターにダメージを与える処理 / Dispel 'living' monsters
976  * @param caster_ptr プレーヤーへの参照ポインタ
977  * @return 効力があった場合TRUEを返す
978  */
979 bool dispel_living(player_type *caster_ptr, HIT_POINT dam)
980 {
981         return (project_all_los(caster_ptr, GF_DISP_LIVING, dam));
982 }
983
984
985 /*!
986  * @brief 視界内の悪魔系モンスターにダメージを与える処理 / Dispel 'living' monsters
987  * @param caster_ptr プレーヤーへの参照ポインタ
988  * @return 効力があった場合TRUEを返す
989  */
990 bool dispel_demons(player_type *caster_ptr, HIT_POINT dam)
991 {
992         return (project_all_los(caster_ptr, GF_DISP_DEMON, dam));
993 }
994
995
996 /*!
997  * @brief 視界内のモンスターに「聖戦」効果を与える処理
998  * @param caster_ptr プレーヤーへの参照ポインタ
999  * @return 効力があった場合TRUEを返す
1000  */
1001 bool crusade(player_type *caster_ptr)
1002 {
1003         return (project_all_los(caster_ptr, GF_CRUSADE, caster_ptr->lev*4));
1004 }
1005
1006
1007 /*!
1008  * @brief 視界内モンスターを怒らせる処理 / Wake up all monsters, and speed up "los" monsters.
1009  * @param caster_ptr プレーヤーへの参照ポインタ
1010  * @param who 怒らせる原因を起こしたモンスター(0ならばプレイヤー)
1011  * @return なし
1012  */
1013 void aggravate_monsters(player_type *caster_ptr, MONSTER_IDX who)
1014 {
1015         /* Aggravate everyone nearby */
1016         bool sleep = FALSE;
1017         bool speed = FALSE;
1018         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1019         {
1020                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1021                 if (!monster_is_valid(m_ptr)) continue;
1022
1023                 /* Skip aggravating monster (or player) */
1024                 if (i == who) continue;
1025
1026                 /* Wake up nearby sleeping monsters */
1027                 if (m_ptr->cdis < MAX_SIGHT * 2)
1028                 {
1029                         /* Wake up */
1030                         if (MON_CSLEEP(m_ptr))
1031                         {
1032                                 (void)set_monster_csleep(caster_ptr, i, 0);
1033                                 sleep = TRUE;
1034                         }
1035                         if (!is_pet(m_ptr)) m_ptr->mflag2 |= MFLAG2_NOPET;
1036                 }
1037
1038                 /* Speed up monsters in line of sight */
1039                 if (player_has_los_bold(caster_ptr, m_ptr->fy, m_ptr->fx))
1040                 {
1041                         if (!is_pet(m_ptr))
1042                         {
1043                                 (void)set_monster_fast(caster_ptr, i, MON_FAST(m_ptr) + 100);
1044                                 speed = TRUE;
1045                         }
1046                 }
1047         }
1048
1049         if (speed) msg_print(_("付近で何かが突如興奮したような感じを受けた!", "You feel a sudden stirring nearby!"));
1050         else if (sleep) msg_print(_("何かが突如興奮したような騒々しい音が遠くに聞こえた!", "You hear a sudden stirring in the distance!"));
1051         if (caster_ptr->riding) caster_ptr->update |= PU_BONUS;
1052 }
1053
1054
1055 /*!
1056  * @brief モンスターへの単体抹殺処理サブルーチン / Delete a non-unique/non-quest monster
1057  * @param m_idx 抹殺するモンスターID
1058  * @param power 抹殺の威力
1059  * @param player_cast プレイヤーの魔法によるものならば TRUE
1060  * @param dam_side プレイヤーへの負担ダメージ量(1d(dam_side))
1061  * @param spell_name 抹殺効果を起こした魔法の名前
1062  * @return 効力があった場合TRUEを返す
1063  */
1064 bool genocide_aux(player_type *caster_ptr, MONSTER_IDX m_idx, int power, bool player_cast, int dam_side, concptr spell_name)
1065 {
1066         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
1067         monster_race *r_ptr = &r_info[m_ptr->r_idx];
1068         if (is_pet(m_ptr) && !player_cast) return FALSE;
1069
1070         /* Hack -- Skip Unique Monsters or Quest Monsters */
1071         bool resist = FALSE;
1072         if (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) resist = TRUE;
1073         else if (r_ptr->flags7 & RF7_UNIQUE2) resist = TRUE;
1074         else if (m_idx == caster_ptr->riding) resist = TRUE;
1075         else if ((caster_ptr->current_floor_ptr->inside_quest && !random_quest_number(caster_ptr, caster_ptr->current_floor_ptr->dun_level)) || caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out) resist = TRUE;
1076         else if (player_cast && (r_ptr->level > randint0(power))) resist = TRUE;
1077         else if (player_cast && (m_ptr->mflag2 & MFLAG2_NOGENO)) resist = TRUE;
1078         else
1079         {
1080                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1081                 {
1082                         GAME_TEXT m_name[MAX_NLEN];
1083
1084                         monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1085                         exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
1086                 }
1087
1088                 delete_monster_idx(m_idx);
1089         }
1090
1091         if (resist && player_cast)
1092         {
1093                 bool see_m = is_seen(m_ptr);
1094                 GAME_TEXT m_name[MAX_NLEN];
1095
1096                 monster_desc(m_name, m_ptr, 0);
1097                 if (see_m)
1098                 {
1099                         msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
1100                 }
1101
1102                 if (MON_CSLEEP(m_ptr))
1103                 {
1104                         (void)set_monster_csleep(caster_ptr, m_idx, 0);
1105                         if (m_ptr->ml)
1106                         {
1107                                 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1108                         }
1109                 }
1110
1111                 if (is_friendly(m_ptr) && !is_pet(m_ptr))
1112                 {
1113                         if (see_m)
1114                         {
1115                                 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
1116                         }
1117
1118                         set_hostile(m_ptr);
1119                 }
1120
1121                 if (one_in_(13)) m_ptr->mflag2 |= MFLAG2_NOGENO;
1122         }
1123
1124         if (player_cast)
1125         {
1126                 take_hit(caster_ptr, DAMAGE_GENO, randint1(dam_side), format(_("%^sの呪文を唱えた疲労", "the strain of casting %^s"), spell_name), -1);
1127         }
1128
1129         /* Visual feedback */
1130         move_cursor_relative(caster_ptr->y, caster_ptr->x);
1131
1132         caster_ptr->redraw |= (PR_HP);
1133         caster_ptr->window |= (PW_PLAYER);
1134
1135         handle_stuff(caster_ptr);
1136         Term_fresh();
1137
1138         int msec = delay_factor * delay_factor * delay_factor;
1139         Term_xtra(TERM_XTRA_DELAY, msec);
1140
1141         return !resist;
1142 }
1143
1144
1145 /*!
1146  * @brief モンスターへのシンボル抹殺処理ルーチン / Delete all non-unique/non-quest monsters of a given "type" from the level
1147  * @param power 抹殺の威力
1148  * @param player_cast プレイヤーの魔法によるものならば TRUE
1149  * @return 効力があった場合TRUEを返す
1150  */
1151 bool symbol_genocide(player_type *caster_ptr, int power, bool player_cast)
1152 {
1153         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
1154         bool is_special_floor = floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level);
1155         is_special_floor |= caster_ptr->current_floor_ptr->inside_arena;
1156         is_special_floor |= caster_ptr->phase_out;
1157         if (is_special_floor)
1158         {
1159                 msg_print(_("何も起きないようだ……", "It seems nothing happen here..."));
1160                 return FALSE;
1161         }
1162
1163         /* Mega-Hack -- Get a monster symbol */
1164         char typ;
1165         while (!get_com(_("どの種類(文字)のモンスターを抹殺しますか: ", "Choose a monster race (by symbol) to genocide: "), &typ, FALSE)) ;
1166
1167         /* Delete the monsters of that "type" */
1168         bool result = FALSE;
1169         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1170         {
1171                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1172                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1173                 if (!monster_is_valid(m_ptr)) continue;
1174
1175                 /* Skip "wrong" monsters */
1176                 if (r_ptr->d_char != typ) continue;
1177
1178                 result |= genocide_aux(caster_ptr, i, power, player_cast, 4, _("抹殺", "Genocide"));
1179         }
1180
1181         if (result)
1182         {
1183                 chg_virtue(caster_ptr, V_VITALITY, -2);
1184                 chg_virtue(caster_ptr, V_CHANCE, -1);
1185         }
1186
1187         return result;
1188 }
1189
1190
1191 /*!
1192  * @brief モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) monsters
1193  * @param power 抹殺の威力
1194  * @param player_cast プレイヤーの魔法によるものならば TRUE
1195  * @return 効力があった場合TRUEを返す
1196  */
1197 bool mass_genocide(player_type *caster_ptr, int power, bool player_cast)
1198 {
1199         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
1200         bool is_special_floor = floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level);
1201         is_special_floor |= caster_ptr->current_floor_ptr->inside_arena;
1202         is_special_floor |= caster_ptr->phase_out;
1203         if (is_special_floor)
1204         {
1205                 return FALSE;
1206         }
1207
1208         /* Delete the (nearby) monsters */
1209         bool result = FALSE;
1210         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1211         {
1212                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1213                 if (!monster_is_valid(m_ptr)) continue;
1214
1215                 /* Skip distant monsters */
1216                 if (m_ptr->cdis > MAX_SIGHT) continue;
1217
1218                 /* Note effect */
1219                 result |= genocide_aux(caster_ptr, i, power, player_cast, 3, _("周辺抹殺", "Mass Genocide"));
1220         }
1221
1222         if (result)
1223         {
1224                 chg_virtue(caster_ptr, V_VITALITY, -2);
1225                 chg_virtue(caster_ptr, V_CHANCE, -1);
1226         }
1227
1228         return result;
1229 }
1230
1231
1232 /*!
1233  * @brief アンデッド・モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) undead
1234  * @param power 抹殺の威力
1235  * @param player_cast プレイヤーの魔法によるものならば TRUE
1236  * @return 効力があった場合TRUEを返す
1237  */
1238 bool mass_genocide_undead(player_type *caster_ptr, int power, bool player_cast)
1239 {
1240         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
1241         bool is_special_floor = floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level);
1242         is_special_floor |= caster_ptr->current_floor_ptr->inside_arena;
1243         is_special_floor |= caster_ptr->phase_out;
1244         if (is_special_floor)
1245         {
1246                 return FALSE;
1247         }
1248
1249         /* Delete the (nearby) monsters */
1250         bool result = FALSE;
1251         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1252         {
1253                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1254                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1255                 if (!monster_is_valid(m_ptr)) continue;
1256
1257                 if (!(r_ptr->flags3 & RF3_UNDEAD)) continue;
1258
1259                 /* Skip distant monsters */
1260                 if (m_ptr->cdis > MAX_SIGHT) continue;
1261
1262                 /* Note effect */
1263                 result |= genocide_aux(caster_ptr, i, power, player_cast, 3, _("アンデッド消滅", "Annihilate Undead"));
1264         }
1265
1266         if (result)
1267         {
1268                 chg_virtue(caster_ptr, V_UNLIFE, -2);
1269                 chg_virtue(caster_ptr, V_CHANCE, -1);
1270         }
1271
1272         return result;
1273 }
1274
1275
1276 /*!
1277  * @brief 周辺モンスターを調査する / Probe nearby monsters
1278  * @return 効力があった場合TRUEを返す
1279  */
1280 bool probing(player_type *caster_ptr)
1281 {
1282         bool_hack cu = Term->scr->cu;
1283         bool_hack cv = Term->scr->cv;
1284         Term->scr->cu = 0;
1285         Term->scr->cv = 1;
1286
1287         bool probe = FALSE;
1288         int speed;
1289         char buf[256];
1290         concptr align;
1291         for (int i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1292         {
1293                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1294                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1295                 if (!monster_is_valid(m_ptr)) continue;
1296
1297                 /* Require line of sight */
1298                 if (!player_has_los_bold(caster_ptr, m_ptr->fy, m_ptr->fx)) continue;
1299
1300                 if (!m_ptr->ml) continue;
1301                 
1302                 GAME_TEXT m_name[MAX_NLEN];
1303
1304                 /* Start the message */
1305                 if (!probe) msg_print(_("調査中...", "Probing..."));
1306                 msg_print(NULL);
1307
1308                 if (!is_original_ap(m_ptr))
1309                 {
1310                         if (m_ptr->mflag2 & MFLAG2_KAGE)
1311                                 m_ptr->mflag2 &= ~(MFLAG2_KAGE);
1312
1313                         m_ptr->ap_r_idx = m_ptr->r_idx;
1314                         lite_spot(m_ptr->fy, m_ptr->fx);
1315                 }
1316
1317                 /* Get "the monster" or "something" */
1318                 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_INDEF_HIDDEN);
1319
1320                 speed = m_ptr->mspeed - 110;
1321                 if (MON_FAST(m_ptr)) speed += 10;
1322                 if (MON_SLOW(m_ptr)) speed -= 10;
1323                 if (ironman_nightmare) speed += 5;
1324
1325                 /* Get the monster's alignment */
1326                 if ((r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) == (RF3_EVIL | RF3_GOOD)) align = _("善悪", "good&evil");
1327                 else if (r_ptr->flags3 & RF3_EVIL) align = _("邪悪", "evil");
1328                 else if (r_ptr->flags3 & RF3_GOOD) align = _("善良", "good");
1329                 else if ((m_ptr->sub_align & (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) == (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) align = _("中立(善悪)", "neutral(good&evil)");
1330                 else if (m_ptr->sub_align & SUB_ALIGN_EVIL) align = _("中立(邪悪)", "neutral(evil)");
1331                 else if (m_ptr->sub_align & SUB_ALIGN_GOOD) align = _("中立(善良)", "neutral(good)");
1332                 else align = _("中立", "neutral");
1333
1334                 sprintf(buf, _("%s ... 属性:%s HP:%d/%d AC:%d 速度:%s%d 経験:", "%s ... align:%s HP:%d/%d AC:%d speed:%s%d exp:"),
1335                         m_name, align, (int)m_ptr->hp, (int)m_ptr->maxhp, r_ptr->ac, (speed > 0) ? "+" : "", speed);
1336
1337                 if (r_ptr->next_r_idx)
1338                 {
1339                         strcat(buf, format("%d/%d ", m_ptr->exp, r_ptr->next_exp));
1340                 }
1341                 else
1342                 {
1343                         strcat(buf, "xxx ");
1344                 }
1345
1346                 if (MON_CSLEEP(m_ptr)) strcat(buf, _("睡眠 ", "sleeping "));
1347                 if (MON_STUNNED(m_ptr)) strcat(buf, _("朦朧 ", "stunned "));
1348                 if (MON_MONFEAR(m_ptr)) strcat(buf, _("恐怖 ", "scared "));
1349                 if (MON_CONFUSED(m_ptr)) strcat(buf, _("混乱 ", "confused "));
1350                 if (MON_INVULNER(m_ptr)) strcat(buf, _("無敵 ", "invulnerable "));
1351                 buf[strlen(buf) - 1] = '\0';
1352                 prt(buf, 0, 0);
1353
1354                 /* HACK : Add the line to message buffer */
1355                 message_add(buf);
1356
1357                 caster_ptr->window |= (PW_MESSAGE);
1358                 handle_stuff(caster_ptr);
1359                 move_cursor_relative(m_ptr->fy, m_ptr->fx);
1360
1361                 inkey();
1362
1363                 Term_erase(0, 0, 255);
1364
1365                 if (lore_do_probe(m_ptr->r_idx))
1366                 {
1367                         strcpy(buf, (r_name + r_ptr->name));
1368 #ifdef JP
1369                         msg_format("%sについてさらに詳しくなった気がする。", buf);
1370 #else
1371                         plural_aux(buf);
1372                         msg_format("You now know more about %s.", buf);
1373 #endif
1374                         msg_print(NULL);
1375                 }
1376
1377                 probe = TRUE;
1378         }
1379
1380         Term->scr->cu = cu;
1381         Term->scr->cv = cv;
1382         Term_fresh();
1383
1384         if (probe)
1385         {
1386                 chg_virtue(caster_ptr, V_KNOWLEDGE, 1);
1387                 msg_print(_("これで全部です。", "That's all."));
1388         }
1389
1390         return (probe);
1391 }
1392
1393
1394 /*!
1395  * @brief ペット爆破処理 /
1396  * @return なし
1397  */
1398 void discharge_minion(player_type *caster_ptr)
1399 {
1400         bool okay = TRUE;
1401
1402         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1403         {
1404                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1405                 if (!m_ptr->r_idx || !is_pet(m_ptr)) continue;
1406                 if (m_ptr->nickname) okay = FALSE;
1407         }
1408
1409         if (!okay || caster_ptr->riding)
1410         {
1411                 if (!get_check(_("本当に全ペットを爆破しますか?", "You will blast all pets. Are you sure? ")))
1412                         return;
1413         }
1414
1415         for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
1416         {
1417                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
1418                 if (!m_ptr->r_idx || !is_pet(m_ptr)) continue;
1419
1420                 monster_race *r_ptr;
1421                 r_ptr = &r_info[m_ptr->r_idx];
1422
1423                 /* Uniques resist discharging */
1424                 if (r_ptr->flags1 & RF1_UNIQUE)
1425                 {
1426                         GAME_TEXT m_name[MAX_NLEN];
1427                         monster_desc(m_name, m_ptr, 0x00);
1428                         msg_format(_("%sは爆破されるのを嫌がり、勝手に自分の世界へと帰った。", "%^s resists being blasted and runs away."), m_name);
1429                         delete_monster_idx(i);
1430                         continue;
1431                 }
1432
1433                 HIT_POINT dam = m_ptr->maxhp / 2;
1434                 if (dam > 100) dam = (dam - 100) / 2 + 100;
1435                 if (dam > 400) dam = (dam - 400) / 2 + 400;
1436                 if (dam > 800) dam = 800;
1437                 project(caster_ptr, i, 2 + (r_ptr->level / 20), m_ptr->fy, m_ptr->fx, dam, GF_PLASMA, 
1438                         PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
1439
1440                 if (record_named_pet && m_ptr->nickname)
1441                 {
1442                         GAME_TEXT m_name[MAX_NLEN];
1443
1444                         monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1445                         exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name);
1446                 }
1447
1448                 delete_monster_idx(i);
1449         }
1450 }
1451
1452
1453 /*!
1454  * todo この辺、xとyが引数になっているが、caster_ptr->xとcaster_ptr->yで全て置き換えが効くはず……
1455  * @brief 部屋全体を照らすサブルーチン
1456  * @param caster_ptr プレーヤーへの参照ポインタ
1457  * @return なし
1458  * @details
1459  * <pre>
1460  * This routine clears the entire "temp" set.
1461  * This routine will Perma-Lite all "temp" grids.
1462  * This routine is used (only) by "lite_room()"
1463  * Dark grids are illuminated.
1464  * Also, process all affected monsters.
1465  *
1466  * SMART monsters always wake up when illuminated
1467  * NORMAL monsters wake up 1/4 the time when illuminated
1468  * STUPID monsters wake up 1/10 the time when illuminated
1469  * </pre>
1470  */
1471 static void cave_temp_room_lite(player_type *caster_ptr)
1472 {
1473         /* Clear them all */
1474         for (int i = 0; i < tmp_pos.n; i++)
1475         {
1476                 POSITION y = tmp_pos.y[i];
1477                 POSITION x = tmp_pos.x[i];
1478
1479                 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
1480
1481                 /* No longer in the array */
1482                 g_ptr->info &= ~(CAVE_TEMP);
1483
1484                 /* Perma-Lite */
1485                 g_ptr->info |= (CAVE_GLOW);
1486
1487                 /* Process affected monsters */
1488                 if (g_ptr->m_idx)
1489                 {
1490                         PERCENTAGE chance = 25;
1491                         monster_type    *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
1492                         monster_race    *r_ptr = &r_info[m_ptr->r_idx];
1493                         update_monster(caster_ptr, g_ptr->m_idx, FALSE);
1494
1495                         /* Stupid monsters rarely wake up */
1496                         if (r_ptr->flags2 & (RF2_STUPID)) chance = 10;
1497
1498                         /* Smart monsters always wake up */
1499                         if (r_ptr->flags2 & (RF2_SMART)) chance = 100;
1500
1501                         /* Sometimes monsters wake up */
1502                         if (MON_CSLEEP(m_ptr) && (randint0(100) < chance))
1503                         {
1504                                 /* Wake up! */
1505                                 (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
1506
1507                                 /* Notice the "waking up" */
1508                                 if (m_ptr->ml)
1509                                 {
1510                                         GAME_TEXT m_name[MAX_NLEN];
1511                                         monster_desc(m_name, m_ptr, 0);
1512                                         msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1513                                 }
1514                         }
1515                 }
1516
1517                 note_spot(y, x);
1518                 lite_spot(y, x);
1519                 update_local_illumination(caster_ptr, y, x);
1520         }
1521
1522         tmp_pos.n = 0;
1523 }
1524
1525
1526 /*!
1527  * todo この辺、xとyが引数になっているが、caster_ptr->xとcaster_ptr->yで全て置き換えが効くはず……
1528  * @brief 部屋全体を暗くするサブルーチン
1529  * @param caster_ptr プレーヤーへの参照ポインタ
1530  * @return なし
1531  * @details
1532  * <pre>
1533  * This routine clears the entire "temp" set.
1534  * This routine will "darken" all "temp" grids.
1535  * In addition, some of these grids will be "unmarked".
1536  * This routine is used (only) by "unlite_room()"
1537  * Also, process all affected monsters
1538  * </pre>
1539  */
1540 static void cave_temp_room_unlite(player_type *caster_ptr)
1541 {
1542         /* Clear them all */
1543         for (int i = 0; i < tmp_pos.n; i++)
1544         {
1545                 POSITION y = tmp_pos.y[i];
1546                 POSITION x = tmp_pos.x[i];
1547
1548                 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
1549                 bool do_dark = !is_mirror_grid(g_ptr);
1550
1551                 /* No longer in the array */
1552                 g_ptr->info &= ~(CAVE_TEMP);
1553
1554                 /* Darken the grid */
1555                 if (!do_dark) continue;
1556
1557                 if (caster_ptr->current_floor_ptr->dun_level || !is_daytime())
1558                 {
1559                         for (int j = 0; j < 9; j++)
1560                         {
1561                                 POSITION by = y + ddy_ddd[j];
1562                                 POSITION bx = x + ddx_ddd[j];
1563
1564                                 if (in_bounds2(caster_ptr->current_floor_ptr, by, bx))
1565                                 {
1566                                         grid_type *cc_ptr = &caster_ptr->current_floor_ptr->grid_array[by][bx];
1567
1568                                         if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
1569                                         {
1570                                                 do_dark = FALSE;
1571                                                 break;
1572                                         }
1573                                 }
1574                         }
1575
1576                         if (!do_dark) continue;
1577                 }
1578
1579                 g_ptr->info &= ~(CAVE_GLOW);
1580
1581                 /* Hack -- Forget "boring" grids */
1582                 if (!have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_REMEMBER))
1583                 {
1584                         /* Forget the grid */
1585                         if (!view_torch_grids) g_ptr->info &= ~(CAVE_MARK);
1586                         note_spot(y, x);
1587                 }
1588
1589                 /* Process affected monsters */
1590                 if (g_ptr->m_idx)
1591                 {
1592                         update_monster(caster_ptr, g_ptr->m_idx, FALSE);
1593                 }
1594
1595                 lite_spot(y, x);
1596                 update_local_illumination(caster_ptr, y, x);
1597         }
1598
1599         tmp_pos.n = 0;
1600 }
1601
1602
1603 /*!
1604  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
1605  * @param floor_ptr 配置するフロアの参照ポインタ
1606  * @param cy Y座標
1607  * @param cx X座標
1608  * @param pass_bold 地形条件を返す関数ポインタ
1609  * @return 該当地形の数
1610  */
1611 static int next_to_open(floor_type *floor_ptr, POSITION cy, POSITION cx, bool (*pass_bold)(floor_type*, POSITION, POSITION))
1612 {
1613         POSITION y, x;
1614         int len = 0;
1615         int blen = 0;
1616         for (int i = 0; i < 16; i++)
1617         {
1618                 y = cy + ddy_cdd[i % 8];
1619                 x = cx + ddx_cdd[i % 8];
1620
1621                 /* Found a wall, break the length */
1622                 if (!pass_bold(floor_ptr, y, x))
1623                 {
1624                         /* Track best length */
1625                         if (len > blen)
1626                         {
1627                                 blen = len;
1628                         }
1629
1630                         len = 0;
1631                 }
1632                 else
1633                 {
1634                         len++;
1635                 }
1636         }
1637
1638         return MAX(len, blen);
1639 }
1640
1641
1642 /*!
1643  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
1644  * @param floor_ptr 配置するフロアの参照ポインタ
1645  * @param cy Y座標
1646  * @param cx X座標
1647  * @param pass_bold 地形条件を返す関数ポインタ
1648  * @return 該当地形の数
1649  */
1650 static int next_to_walls_adj(floor_type *floor_ptr, POSITION cy, POSITION cx, bool (*pass_bold)(floor_type*, POSITION, POSITION))
1651 {
1652         POSITION y, x;
1653         int c = 0;
1654         for (DIRECTION i = 0; i < 8; i++)
1655         {
1656                 y = cy + ddy_ddd[i];
1657                 x = cx + ddx_ddd[i];
1658
1659                 if (!pass_bold(floor_ptr, y, x)) c++;
1660         }
1661
1662         return c;
1663 }
1664
1665
1666 /*!
1667  * @brief 部屋内にある一点の周囲に該当する地形数かいくつあるかをグローバル変数tmp_pos.nに返す / Aux function -- see below
1668  * @param caster_ptr プレーヤーへの参照ポインタ
1669  * @param y 部屋内のy座標1点
1670  * @param x 部屋内のx座標1点
1671  * @param only_room 部屋内地形のみをチェック対象にするならば TRUE
1672  * @param pass_bold 地形条件を返す関数ポインタ
1673  * @return 該当地形の数
1674  */
1675 static void cave_temp_room_aux(player_type *caster_ptr, POSITION y, POSITION x, bool only_room, bool (*pass_bold)(floor_type*, POSITION, POSITION))
1676 {
1677         grid_type *g_ptr;
1678         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
1679         g_ptr = &floor_ptr->grid_array[y][x];
1680
1681         /* Avoid infinite recursion */
1682         if (g_ptr->info & (CAVE_TEMP)) return;
1683
1684         /* Do not "leave" the current room */
1685         if (!(g_ptr->info & (CAVE_ROOM)))
1686         {
1687                 if (only_room) return;
1688
1689                 /* Verify */
1690                 if (!in_bounds2(floor_ptr, y, x)) return;
1691
1692                 /* Do not exceed the maximum spell range */
1693                 if (distance(caster_ptr->y, caster_ptr->x, y, x) > MAX_RANGE) return;
1694
1695                 /* Verify this grid */
1696                 /*
1697                  * The reason why it is ==6 instead of >5 is that 8 is impossible
1698                  * due to the check for cave_bold above.
1699                  * 7 lights dead-end corridors (you need to do this for the
1700                  * checkboard interesting rooms, so that the boundary is lit
1701                  * properly.
1702                  * This leaves only a check for 6 bounding walls!
1703                  */
1704                 if (in_bounds(floor_ptr, y, x) && pass_bold(floor_ptr, y, x) &&
1705                     (next_to_walls_adj(floor_ptr, y, x, pass_bold) == 6) && (next_to_open(floor_ptr, y, x, pass_bold) <= 1)) return;
1706         }
1707
1708         /* Paranoia -- verify space */
1709         if (tmp_pos.n == TEMP_MAX) return;
1710
1711         /* Mark the grid as "seen" */
1712         g_ptr->info |= (CAVE_TEMP);
1713
1714         /* Add it to the "seen" set */
1715         tmp_pos.y[tmp_pos.n] = y;
1716         tmp_pos.x[tmp_pos.n] = x;
1717         tmp_pos.n++;
1718 }
1719
1720
1721 /*!
1722  * todo このシンタックスシュガーは不要だが、関数ポインタなので安易には消せず……
1723  * @brief 指定のマスが光を通すか(LOSフラグを持つか)を返す。 / Aux function -- see below
1724  * @param floor_ptr 配置するフロアの参照ポインタ
1725  * @param y 指定Y座標
1726  * @param x 指定X座標
1727  * @return 光を通すならばtrueを返す。
1728  */
1729 static bool cave_pass_lite_bold(floor_type *floor_ptr, POSITION y, POSITION x)
1730 {
1731         return cave_los_bold(floor_ptr, y, x);
1732 }
1733
1734
1735 /*!
1736  * @brief 部屋内にある一点の周囲がいくつ光を通すかをグローバル変数tmp_pos.nに返す / Aux function -- see below
1737 * @param caster_ptr プレーヤーへの参照ポインタ
1738   * @param y 指定Y座標
1739  * @param x 指定X座標
1740  * @return なし
1741  */
1742 static void cave_temp_lite_room_aux(player_type *caster_ptr, POSITION y, POSITION x)
1743 {
1744         cave_temp_room_aux(caster_ptr, y, x, FALSE, cave_pass_lite_bold);
1745 }
1746
1747
1748 /*!
1749  * @brief 指定のマスが光を通さず射線のみを通すかを返す。 / Aux function -- see below
1750  * @param floor_ptr 配置するフロアの参照ポインタ
1751  * @param y 指定Y座標
1752  * @param x 指定X座標
1753  * @return 射線を通すならばtrueを返す。
1754  */
1755 static bool cave_pass_dark_bold(floor_type *floor_ptr, POSITION y, POSITION x)
1756 {
1757         return cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT);
1758 }
1759
1760
1761 /*!
1762  * @brief 部屋内にある一点の周囲がいくつ射線を通すかをグローバル変数tmp_pos.nに返す / Aux function -- see below
1763  * @param caster_ptr プレーヤーへの参照ポインタ
1764  * @param y 指定Y座標
1765  * @param x 指定X座標
1766  * @return なし
1767  */
1768 static void cave_temp_unlite_room_aux(player_type *caster_ptr, POSITION y, POSITION x)
1769 {
1770         cave_temp_room_aux(caster_ptr, y, x, TRUE, cave_pass_dark_bold);
1771 }
1772
1773
1774 /*!
1775  * @brief 指定された部屋内を照らす / Illuminate any room containing the given location.
1776  * @param caster_ptr プレーヤーへの参照ポインタ
1777  * @param y1 指定Y座標
1778  * @param x1 指定X座標
1779  * @return なし
1780  */
1781 void lite_room(player_type *caster_ptr, POSITION y1, POSITION x1)
1782 {
1783         /* Add the initial grid */
1784         cave_temp_lite_room_aux(caster_ptr, y1, x1);
1785
1786         /* While grids are in the queue, add their neighbors */
1787         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
1788         POSITION x, y;
1789         for (int i = 0; i < tmp_pos.n; i++)
1790         {
1791                 x = tmp_pos.x[i], y = tmp_pos.y[i];
1792
1793                 /* Walls get lit, but stop light */
1794                 if (!cave_pass_lite_bold(floor_ptr, y, x)) continue;
1795
1796                 /* Spread adjacent */
1797                 cave_temp_lite_room_aux(caster_ptr, y + 1, x);
1798                 cave_temp_lite_room_aux(caster_ptr, y - 1, x);
1799                 cave_temp_lite_room_aux(caster_ptr, y, x + 1);
1800                 cave_temp_lite_room_aux(caster_ptr, y, x - 1);
1801
1802                 /* Spread diagonal */
1803                 cave_temp_lite_room_aux(caster_ptr, y + 1, x + 1);
1804                 cave_temp_lite_room_aux(caster_ptr, y - 1, x - 1);
1805                 cave_temp_lite_room_aux(caster_ptr, y - 1, x + 1);
1806                 cave_temp_lite_room_aux(caster_ptr, y + 1, x - 1);
1807         }
1808
1809         /* Now, lite them all up at once */
1810         cave_temp_room_lite(caster_ptr);
1811
1812         if (caster_ptr->special_defense & NINJA_S_STEALTH)
1813         {
1814                 if (floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE);
1815         }
1816 }
1817
1818
1819 /*!
1820  * @brief 指定された部屋内を暗くする / Darken all rooms containing the given location
1821  * @param caster_ptr プレーヤーへの参照ポインタ
1822  * @param y1 指定Y座標
1823  * @param x1 指定X座標
1824  * @return なし
1825  */
1826 void unlite_room(player_type *caster_ptr, POSITION y1, POSITION x1)
1827 {
1828         /* Add the initial grid */
1829         cave_temp_unlite_room_aux(caster_ptr, y1, x1);
1830
1831         /* Spread, breadth first */
1832         POSITION x, y;
1833         for (int i = 0; i < tmp_pos.n; i++)
1834         {
1835                 x = tmp_pos.x[i], y = tmp_pos.y[i];
1836
1837                 /* Walls get dark, but stop darkness */
1838                 if (!cave_pass_dark_bold(caster_ptr->current_floor_ptr, y, x)) continue;
1839
1840                 /* Spread adjacent */
1841                 cave_temp_unlite_room_aux(caster_ptr, y + 1, x);
1842                 cave_temp_unlite_room_aux(caster_ptr, y - 1, x);
1843                 cave_temp_unlite_room_aux(caster_ptr, y, x + 1);
1844                 cave_temp_unlite_room_aux(caster_ptr, y, x - 1);
1845
1846                 /* Spread diagonal */
1847                 cave_temp_unlite_room_aux(caster_ptr, y + 1, x + 1);
1848                 cave_temp_unlite_room_aux(caster_ptr, y - 1, x - 1);
1849                 cave_temp_unlite_room_aux(caster_ptr, y - 1, x + 1);
1850                 cave_temp_unlite_room_aux(caster_ptr, y + 1, x - 1);
1851         }
1852
1853         /* Now, darken them all at once */
1854         cave_temp_room_unlite(caster_ptr);
1855 }
1856
1857
1858 /*!
1859  * @brief スターライトの効果を発生させる
1860  * @param caster_ptr プレーヤーへの参照ポインタ
1861  * @param magic 魔法による効果であればTRUE、スターライトの杖による効果であればFALSE
1862  * @return 常にTRUE
1863  */
1864 bool starlight(player_type *caster_ptr, bool magic)
1865 {
1866         if (!caster_ptr->blind && !magic)
1867         {
1868                 msg_print(_("杖の先が明るく輝いた...", "The end of the staff glows brightly..."));
1869         }
1870
1871         HIT_POINT num = damroll(5, 3);
1872         int attempts;
1873         POSITION y = 0, x = 0;
1874         for (int k = 0; k < num; k++)
1875         {
1876                 attempts = 1000;
1877
1878                 while (attempts--)
1879                 {
1880                         scatter(caster_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 4, PROJECT_LOS);
1881                         if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT)) continue;
1882                         if (!player_bold(caster_ptr, y, x)) break;
1883                 }
1884
1885                 project(caster_ptr, 0, 0, y, x, damroll(6 + caster_ptr->lev / 8, 10), GF_LITE_WEAK,
1886                         (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL | PROJECT_LOS), -1);
1887         }
1888
1889         return TRUE;
1890 }
1891
1892
1893 /*!
1894  * @brief プレイヤー位置を中心にLITE_WEAK属性を通じた照明処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
1895  * @param caster_ptr プレーヤーへの参照ポインタ
1896  * @param dam 威力
1897  * @param rad 効果半径
1898  * @return 作用が実際にあった場合TRUEを返す
1899  */
1900 bool lite_area(player_type *caster_ptr, HIT_POINT dam, POSITION rad)
1901 {
1902         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS)
1903         {
1904                 msg_print(_("ダンジョンが光を吸収した。", "The darkness of this dungeon absorb your light."));
1905                 return FALSE;
1906         }
1907
1908         if (!caster_ptr->blind)
1909         {
1910                 msg_print(_("白い光が辺りを覆った。", "You are surrounded by a white light."));
1911         }
1912
1913         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
1914         (void)project(caster_ptr, 0, rad, caster_ptr->y, caster_ptr->x, dam, GF_LITE_WEAK, flg, -1);
1915
1916         lite_room(caster_ptr, caster_ptr->y, caster_ptr->x);
1917
1918         return TRUE;
1919 }
1920
1921
1922 /*!
1923  * @brief プレイヤー位置を中心にLITE_DARK属性を通じた消灯処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
1924  * @param caster_ptr プレーヤーへの参照ポインタ
1925  * @param dam 威力
1926  * @param rad 効果半径
1927  * @return 作用が実際にあった場合TRUEを返す
1928  */
1929 bool unlite_area(player_type *caster_ptr, HIT_POINT dam, POSITION rad)
1930 {
1931         if (!caster_ptr->blind)
1932         {
1933                 msg_print(_("暗闇が辺りを覆った。", "Darkness surrounds you."));
1934         }
1935
1936         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
1937         (void)project(caster_ptr, 0, rad, caster_ptr->y, caster_ptr->x, dam, GF_DARK_WEAK, flg, -1);
1938
1939         unlite_room(caster_ptr, caster_ptr->y, caster_ptr->x);
1940
1941         return TRUE;
1942 }
1943
1944
1945 /*!
1946  * @brief ボール系スペルの発動 / Cast a ball spell
1947  * @param caster_ptr プレーヤーへの参照ポインタ
1948  * @param typ 効果属性
1949  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
1950  * @param dam 威力
1951  * @param rad 半径
1952  * @return 作用が実際にあった場合TRUEを返す
1953  * @details
1954  * <pre>
1955  * Stop if we hit a monster, act as a "ball"
1956  * Allow "target" mode to pass over monsters
1957  * Affect grids, objects, and monsters
1958  * </pre>
1959  */
1960 bool fire_ball(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
1961 {
1962         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1963         if (typ == GF_CHARM_LIVING) flg|= PROJECT_HIDE;
1964
1965         POSITION tx = caster_ptr->x + 99 * ddx[dir];
1966         POSITION ty = caster_ptr->y + 99 * ddy[dir];
1967
1968         /* Hack -- Use an actual "target" */
1969         if ((dir == 5) && target_okay(caster_ptr))
1970         {
1971                 flg &= ~(PROJECT_STOP);
1972                 tx = target_col;
1973                 ty = target_row;
1974         }
1975
1976         /* Analyze the "dir" and the "target".  Hurt items on floor. */
1977         return project(caster_ptr, 0, rad, ty, tx, dam, typ, flg, -1);
1978 }
1979
1980
1981 /*!
1982 * @brief ブレス系スペルの発動 / Cast a breath spell
1983 * @param caster_ptr プレーヤーへの参照ポインタ
1984 * @param typ 効果属性
1985 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
1986 * @param dam 威力
1987 * @param rad 半径
1988 * @return 作用が実際にあった場合TRUEを返す
1989 * @details
1990 * <pre>
1991 * Stop if we hit a monster, act as a "ball"
1992 * Allow "target" mode to pass over monsters
1993 * Affect grids, objects, and monsters
1994 * </pre>
1995 */
1996 bool fire_breath(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
1997 {
1998         return fire_ball(caster_ptr, typ, dir, dam, -rad);
1999 }
2000
2001
2002 /*!
2003  * @brief ロケット系スペルの発動(詳細な差は確認中) / Cast a ball spell
2004  * @param caster_ptr プレーヤーへの参照ポインタ
2005  * @param typ 効果属性
2006  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2007  * @param dam 威力
2008  * @param rad 半径
2009  * @return 作用が実際にあった場合TRUEを返す
2010  * @details
2011  * <pre>
2012  * Stop if we hit a monster, act as a "ball"
2013  * Allow "target" mode to pass over monsters
2014  * Affect grids, objects, and monsters
2015  * </pre>
2016  */
2017 bool fire_rocket(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2018 {
2019         POSITION tx = caster_ptr->x + 99 * ddx[dir];
2020         POSITION ty = caster_ptr->y + 99 * ddy[dir];
2021
2022         /* Hack -- Use an actual "target" */
2023         if ((dir == 5) && target_okay(caster_ptr))
2024         {
2025                 tx = target_col;
2026                 ty = target_row;
2027         }
2028
2029         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2030         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2031         return (project(caster_ptr, 0, rad, ty, tx, dam, typ, flg, -1));
2032 }
2033
2034
2035 /*!
2036  * @brief ボール(ハイド)系スペルの発動 / Cast a ball spell
2037  * @param caster_ptr プレーヤーへの参照ポインタ
2038  * @param typ 効果属性
2039  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2040  * @param dam 威力
2041  * @param rad 半径
2042  * @return 作用が実際にあった場合TRUEを返す
2043  * @details
2044  * <pre>
2045  * Stop if we hit a monster, act as a "ball"
2046  * Allow "target" mode to pass over monsters
2047  * Affect grids, objects, and monsters
2048  * </pre>
2049  */
2050 bool fire_ball_hide(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2051 {
2052         POSITION tx = caster_ptr->x + 99 * ddx[dir];
2053         POSITION ty = caster_ptr->y + 99 * ddy[dir];
2054
2055         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE;
2056         if ((dir == 5) && target_okay(caster_ptr))
2057         {
2058                 flg &= ~(PROJECT_STOP);
2059                 tx = target_col;
2060                 ty = target_row;
2061         }
2062
2063         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2064         return (project(caster_ptr, 0, rad, ty, tx, dam, typ, flg, -1));
2065 }
2066
2067
2068 /*!
2069  * @brief メテオ系スペルの発動 / Cast a meteor spell
2070  * @param caster_ptr プレーヤーへの参照ポインタ
2071  * @param who スぺル詠唱者のモンスターID(0=プレイヤー)
2072  * @param typ 効果属性
2073  * @param dam 威力
2074  * @param rad 半径
2075  * @param y 中心点Y座標
2076  * @param x 中心点X座標
2077  * @return 作用が実際にあった場合TRUEを返す
2078  * @details
2079  * <pre>
2080  * Cast a meteor spell, defined as a ball spell cast by an arbitary monster, 
2081  * player, or outside source, that starts out at an arbitrary location, and 
2082  * leaving no trail from the "caster" to the target.  This function is 
2083  * especially useful for bombardments and similar. -LM-
2084  * Option to hurt the player.
2085  * </pre>
2086  */
2087 bool fire_meteor(player_type *caster_ptr, MONSTER_IDX who, EFFECT_ID typ, POSITION y, POSITION x, HIT_POINT dam, POSITION rad)
2088 {
2089         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2090
2091         /* Analyze the "target" and the caster. */
2092         return (project(caster_ptr, who, rad, y, x, dam, typ, flg, -1));
2093 }
2094
2095
2096 /*!
2097  * @brief ブラスト系スペルの発動 / Cast a blast spell
2098  * @param caster_ptr プレーヤーへの参照ポインタ
2099  * @param typ 効果属性
2100  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2101  * @param dd 威力ダイス数
2102  * @param ds 威力ダイス目
2103  * @param num 基本回数
2104  * @param dev 回数分散
2105  * @return 作用が実際にあった場合TRUEを返す
2106  */
2107 bool fire_blast(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, DICE_NUMBER dd, DICE_SID ds, int num, int dev)
2108 {
2109         POSITION ty, tx, y, x;
2110         POSITION ly, lx;
2111         if (dir == 5)
2112         {
2113                 tx = target_col;
2114                 ty = target_row;
2115
2116                 lx = 20 * (tx - caster_ptr->x) + caster_ptr->x;
2117                 ly = 20 * (ty - caster_ptr->y) + caster_ptr->y;
2118         }
2119         else
2120         {
2121                 ly = ty = caster_ptr->y + 20 * ddy[dir];
2122                 lx = tx = caster_ptr->x + 20 * ddx[dir];
2123         }
2124
2125         int ld = distance(caster_ptr->y, caster_ptr->x, ly, lx);
2126         BIT_FLAGS flg = PROJECT_FAST | PROJECT_THRU | PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE | PROJECT_GRID;
2127         bool result = TRUE;
2128         for (int i = 0; i < num; i++)
2129         {
2130                 while (TRUE)
2131                 {
2132                         /* Get targets for some bolts */
2133                         y = rand_spread(ly, ld * dev / 20);
2134                         x = rand_spread(lx, ld * dev / 20);
2135
2136                         if (distance(ly, lx, y, x) <= ld * dev / 20) break;
2137                 }
2138
2139                 /* Analyze the "dir" and the "target". */
2140                 if (!project(caster_ptr, 0, 0, y, x, damroll(dd, ds), typ, flg, -1))
2141                 {
2142                         result = FALSE;
2143                 }
2144         }
2145
2146         return result;
2147 }
2148
2149
2150 /*!
2151  * @brief モンスターとの位置交換処理 / Switch position with a monster.
2152  * @param caster_ptr プレーヤーへの参照ポインタ
2153  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2154  * @return 作用が実際にあった場合TRUEを返す
2155  */
2156 bool teleport_swap(player_type *caster_ptr, DIRECTION dir)
2157 {
2158         POSITION tx, ty;
2159         if ((dir == 5) && target_okay(caster_ptr))
2160         {
2161                 tx = target_col;
2162                 ty = target_row;
2163         }
2164         else
2165         {
2166                 tx = caster_ptr->x + ddx[dir];
2167                 ty = caster_ptr->y + ddy[dir];
2168         }
2169
2170         if (caster_ptr->anti_tele)
2171         {
2172                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
2173                 return FALSE;
2174         }
2175
2176         grid_type* g_ptr;
2177         g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
2178         if (!g_ptr->m_idx || (g_ptr->m_idx == caster_ptr->riding))
2179         {
2180                 msg_print(_("それとは場所を交換できません。", "You can't trade places with that!"));
2181                 return FALSE;
2182         }
2183
2184         if ((g_ptr->info & CAVE_ICKY) || (distance(ty, tx, caster_ptr->y, caster_ptr->x) > caster_ptr->lev * 3 / 2 + 10))
2185         {
2186                 msg_print(_("失敗した。", "Failed to swap."));
2187                 return FALSE;
2188         }
2189
2190         monster_type* m_ptr;
2191         monster_race* r_ptr;
2192         m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2193         r_ptr = &r_info[m_ptr->r_idx];
2194
2195         (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
2196
2197         if (r_ptr->flagsr & RFR_RES_TELE)
2198         {
2199                 msg_print(_("テレポートを邪魔された!", "Your teleportation is blocked!"));
2200                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2201                 return FALSE;
2202         }
2203
2204         sound(SOUND_TELEPORT);
2205
2206         /* Swap the player and monster */
2207         (void)move_player_effect(caster_ptr, ty, tx, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
2208
2209         /* Success */
2210         return TRUE;
2211 }
2212
2213
2214 /*!
2215  * @brief 指定方向に飛び道具を飛ばす(フラグ任意指定) / Hack -- apply a "project()" in a direction (or at the target)
2216  * @param caster_ptr プレーヤーへの参照ポインタ
2217  * @param typ 効果属性
2218  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2219  * @param dam 威力
2220  * @param flg フラグ
2221  * @return 作用が実際にあった場合TRUEを返す
2222  */
2223 bool project_hook(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, BIT_FLAGS flg)
2224 {
2225         /* Pass through the target if needed */
2226         flg |= (PROJECT_THRU);
2227
2228         POSITION tx = caster_ptr->x + ddx[dir];
2229         POSITION ty = caster_ptr->y + ddy[dir];
2230         if ((dir == 5) && target_okay(caster_ptr))
2231         {
2232                 tx = target_col;
2233                 ty = target_row;
2234         }
2235
2236         /* Analyze the "dir" and the "target", do NOT explode */
2237         return (project(caster_ptr, 0, 0, ty, tx, dam, typ, flg, -1));
2238 }
2239
2240
2241 /*!
2242  * @brief ボルト系スペルの発動 / Cast a bolt spell.
2243  * @param caster_ptr プレーヤーへの参照ポインタ
2244  * @param typ 効果属性
2245  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2246  * @param dam 威力
2247  * @return 作用が実際にあった場合TRUEを返す
2248  * @details
2249  * <pre>
2250  * Stop if we hit a monster, as a "bolt".
2251  * Affect monsters and grids (not objects).
2252  * </pre>
2253  */
2254 bool fire_bolt(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
2255 {
2256         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_GRID;
2257         if (typ != GF_ARROW) flg |= PROJECT_REFLECTABLE;
2258         return (project_hook(caster_ptr, typ, dir, dam, flg));
2259 }
2260
2261
2262 /*!
2263  * @brief ビーム系スペルの発動 / Cast a beam spell.
2264  * @param caster_ptr プレーヤーへの参照ポインタ
2265  * @param typ 効果属性
2266  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2267  * @param dam 威力
2268  * @return 作用が実際にあった場合TRUEを返す
2269  * @details
2270  * <pre>
2271  * Pass through monsters, as a "beam".
2272  * Affect monsters, grids and objects.
2273  * </pre>
2274  */
2275 bool fire_beam(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
2276 {
2277         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM;
2278         return (project_hook(caster_ptr, typ, dir, dam, flg));
2279 }
2280
2281
2282 /*!
2283  * @brief 確率に応じたボルト系/ビーム系スペルの発動 / Cast a bolt spell, or rarely, a beam spell.
2284  * @param caster_ptr プレーヤーへの参照ポインタ
2285  * @param prob ビーム化する確率(%)
2286  * @param typ 効果属性
2287  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2288  * @param dam 威力
2289  * @return 作用が実際にあった場合TRUEを返す
2290  * @details
2291  * <pre>
2292  * Pass through monsters, as a "beam".
2293  * Affect monsters, grids and objects.
2294  * </pre>
2295  */
2296 bool fire_bolt_or_beam(player_type *caster_ptr, PERCENTAGE prob, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
2297 {
2298         if (randint0(100) < prob)
2299         {
2300                 return (fire_beam(caster_ptr, typ, dir, dam));
2301         }
2302         
2303         return (fire_bolt(caster_ptr, typ, dir, dam));
2304 }
2305
2306
2307 /*!
2308  * @brief LITE_WEAK属性による光源ビーム処理
2309  * @param caster_ptr プレーヤーへの参照ポインタ
2310  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2311  * @param dam 威力
2312  * @return 作用が実際にあった場合TRUEを返す
2313  */
2314 bool lite_line(player_type *caster_ptr, DIRECTION dir, HIT_POINT dam)
2315 {
2316         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_KILL;
2317         return (project_hook(caster_ptr, GF_LITE_WEAK, dir, dam, flg));
2318 }
2319
2320
2321 /*!
2322  * @brief 衰弱ボルト処理
2323  * @param caster_ptr プレーヤーへの参照ポインタ
2324  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2325  * @param dam 威力
2326  * @return 作用が実際にあった場合TRUEを返す
2327  */
2328 bool hypodynamic_bolt(player_type *caster_ptr, DIRECTION dir, HIT_POINT dam)
2329 {
2330         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
2331         return (project_hook(caster_ptr, GF_HYPODYNAMIA, dir, dam, flg));
2332 }
2333
2334
2335 /*!
2336  * @brief 岩石溶解処理
2337  * @param caster_ptr プレーヤーへの参照ポインタ
2338  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2339  * @param dam 威力
2340  * @return 作用が実際にあった場合TRUEを返す
2341  */
2342 bool wall_to_mud(player_type *caster_ptr, DIRECTION dir, HIT_POINT dam)
2343 {
2344         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2345         return (project_hook(caster_ptr, GF_KILL_WALL, dir, dam, flg));
2346 }
2347
2348
2349 /*!
2350  * @brief 魔法の施錠処理
2351  * @param caster_ptr プレーヤーへの参照ポインタ
2352  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2353  * @return 作用が実際にあった場合TRUEを返す
2354  */
2355 bool wizard_lock(player_type *caster_ptr, DIRECTION dir)
2356 {
2357         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2358         return (project_hook(caster_ptr, GF_JAM_DOOR, dir, 20 + randint1(30), flg));
2359 }
2360
2361
2362 /*!
2363  * @brief ドア破壊処理
2364  * @param caster_ptr プレーヤーへの参照ポインタ
2365  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2366  * @return 作用が実際にあった場合TRUEを返す
2367  */
2368 bool destroy_door(player_type *caster_ptr, DIRECTION dir)
2369 {
2370         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
2371         return (project_hook(caster_ptr, GF_KILL_DOOR, dir, 0, flg));
2372 }
2373
2374
2375 /*!
2376  * @brief トラップ解除処理
2377  * @param caster_ptr プレーヤーへの参照ポインタ
2378  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2379  * @return 作用が実際にあった場合TRUEを返す
2380  */
2381 bool disarm_trap(player_type *caster_ptr, DIRECTION dir)
2382 {
2383         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
2384         return (project_hook(caster_ptr, GF_KILL_TRAP, dir, 0, flg));
2385 }
2386
2387
2388 /*!
2389  * @brief 死の光線処理
2390  * @param caster_ptr プレーヤーへの参照ポインタ
2391  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2392  * @param plev プレイヤーレベル(効力はplev*200)
2393  * @return 作用が実際にあった場合TRUEを返す
2394  */
2395 bool death_ray(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
2396 {
2397         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
2398         return (project_hook(caster_ptr, GF_DEATH_RAY, dir, plev * 200, flg));
2399 }
2400
2401
2402 /*!
2403  * @brief モンスター用テレポート処理
2404  * @param caster_ptr プレーヤーへの参照ポインタ
2405  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2406  * @param distance 移動距離
2407  * @return 作用が実際にあった場合TRUEを返す
2408  */
2409 bool teleport_monster(player_type *caster_ptr, DIRECTION dir, int distance)
2410 {
2411         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL;
2412         return (project_hook(caster_ptr, GF_AWAY_ALL, dir, distance, flg));
2413 }
2414
2415
2416 /*!
2417  * @brief ドア生成処理(プレイヤー中心に周囲1マス) / Hooks -- affect adjacent grids (radius 1 ball attack)
2418  * @param caster_ptr プレーヤーへの参照ポインタ
2419  * @return 作用が実際にあった場合TRUEを返す
2420  */
2421 bool door_creation(player_type *caster_ptr, POSITION y, POSITION x)
2422 {
2423         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
2424         return (project(caster_ptr, 0, 1, y, x, 0, GF_MAKE_DOOR, flg, -1));
2425 }
2426
2427
2428 /*!
2429  * @brief トラップ生成処理(起点から周囲1マス)
2430  * @param caster_ptr プレーヤーへの参照ポインタ
2431  * @param y 起点Y座標
2432  * @param x 起点X座標
2433  * @return 作用が実際にあった場合TRUEを返す
2434  */
2435 bool trap_creation(player_type *caster_ptr, POSITION y, POSITION x)
2436 {
2437         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
2438         return (project(caster_ptr, 0, 1, y, x, 0, GF_MAKE_TRAP, flg, -1));
2439 }
2440
2441
2442 /*!
2443  * @brief 森林生成処理(プレイヤー中心に周囲1マス)
2444  * @param caster_ptr プレーヤーへの参照ポインタ
2445  * @return 作用が実際にあった場合TRUEを返す
2446  */
2447 bool tree_creation(player_type *caster_ptr, POSITION y, POSITION x)
2448 {
2449         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
2450         return (project(caster_ptr, 0, 1, y, x, 0, GF_MAKE_TREE, flg, -1));
2451 }
2452
2453
2454 /*!
2455  * @brief 魔法のルーン生成処理(プレイヤー中心に周囲1マス)
2456  * @param caster_ptr プレーヤーへの参照ポインタ
2457  * @return 作用が実際にあった場合TRUEを返す
2458  */
2459 bool glyph_creation(player_type *caster_ptr, POSITION y, POSITION x)
2460 {
2461         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM;
2462         return (project(caster_ptr, 0, 1, y, x, 0, GF_MAKE_GLYPH, flg, -1));
2463 }
2464
2465
2466 /*!
2467  * @brief 壁生成処理(プレイヤー中心に周囲1マス)
2468  * @param caster_ptr プレーヤーへの参照ポインタ
2469  * @return 作用が実際にあった場合TRUEを返す
2470  */
2471 bool wall_stone(player_type *caster_ptr)
2472 {
2473         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
2474         bool dummy = (project(caster_ptr, 0, 1, caster_ptr->y, caster_ptr->x, 0, GF_STONE_WALL, flg, -1));
2475         caster_ptr->update |= (PU_FLOW);
2476         caster_ptr->redraw |= (PR_MAP);
2477         return dummy;
2478 }
2479
2480
2481 /*!
2482  * @brief ドア破壊処理(プレイヤー中心に周囲1マス)
2483  * @param caster_ptr プレーヤーへの参照ポインタ
2484  * @return 作用が実際にあった場合TRUEを返す
2485  */
2486 bool destroy_doors_touch(player_type *caster_ptr)
2487 {
2488         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
2489         return (project(caster_ptr, 0, 1, caster_ptr->y, caster_ptr->x, 0, GF_KILL_DOOR, flg, -1));
2490 }
2491
2492
2493 /*!
2494  * @brief トラップ解除処理(プレイヤー中心に周囲1マス)
2495  * @param caster_ptr プレーヤーへの参照ポインタ
2496  * @return 作用が実際にあった場合TRUEを返す
2497  */
2498 bool disarm_traps_touch(player_type *caster_ptr)
2499 {
2500         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
2501         return (project(caster_ptr, 0, 1, caster_ptr->y, caster_ptr->x, 0, GF_KILL_TRAP, flg, -1));
2502 }
2503
2504
2505 /*!
2506  * @brief スリープモンスター処理(プレイヤー中心に周囲1マス)
2507  * @param caster_ptr プレーヤーへの参照ポインタ
2508  * @return 作用が実際にあった場合TRUEを返す
2509  */
2510 bool sleep_monsters_touch(player_type *caster_ptr)
2511 {
2512         BIT_FLAGS flg = PROJECT_KILL | PROJECT_HIDE;
2513         return (project(caster_ptr, 0, 1, caster_ptr->y, caster_ptr->x, caster_ptr->lev, GF_OLD_SLEEP, flg, -1));
2514 }
2515
2516
2517 /*!
2518  * @brief 死者復活処理(起点より周囲5マス)
2519  * @param caster_ptr プレーヤーへの参照ポインタ
2520  * @param who 術者モンスターID(0ならばプレイヤー)
2521  * @param y 起点Y座標
2522  * @param x 起点X座標
2523  * @return 作用が実際にあった場合TRUEを返す
2524  */
2525 bool animate_dead(player_type *caster_ptr, MONSTER_IDX who, POSITION y, POSITION x)
2526 {
2527         BIT_FLAGS flg = PROJECT_ITEM | PROJECT_HIDE;
2528         return (project(caster_ptr, who, 5, y, x, 0, GF_ANIM_DEAD, flg, -1));
2529 }
2530
2531
2532 /*!
2533  * @brief 混沌招来処理
2534  * @return 作用が実際にあった場合TRUEを返す
2535  */
2536 void call_chaos(player_type *caster_ptr)
2537 {
2538         int hurt_types[31] =
2539         {
2540                 GF_ELEC,      GF_POIS,    GF_ACID,    GF_COLD,
2541                 GF_FIRE,      GF_MISSILE, GF_ARROW,   GF_PLASMA,
2542                 GF_HOLY_FIRE, GF_WATER,   GF_LITE,    GF_DARK,
2543                 GF_FORCE,     GF_INERTIAL, GF_MANA,    GF_METEOR,
2544                 GF_ICE,       GF_CHAOS,   GF_NETHER,  GF_DISENCHANT,
2545                 GF_SHARDS,    GF_SOUND,   GF_NEXUS,   GF_CONFUSION,
2546                 GF_TIME,      GF_GRAVITY, GF_ROCKET,  GF_NUKE,
2547                 GF_HELL_FIRE, GF_DISINTEGRATE, GF_PSY_SPEAR
2548         };
2549
2550         int chaos_type = hurt_types[randint0(31)];
2551         bool line_chaos = FALSE;
2552         if (one_in_(4)) line_chaos = TRUE;
2553
2554         int dir;
2555         if (one_in_(6))
2556         {
2557                 for (int dummy = 1; dummy < 10; dummy++)
2558                 {
2559                         if (dummy - 5)
2560                         {
2561                                 if (line_chaos)
2562                                         fire_beam(caster_ptr, chaos_type, dummy, 150);
2563                                 else
2564                                         fire_ball(caster_ptr, chaos_type, dummy, 150, 2);
2565                         }
2566                 }
2567
2568                 return;
2569         }
2570
2571         if (one_in_(3))
2572         {
2573                 fire_ball(caster_ptr, chaos_type, 0, 500, 8);
2574                 return;
2575         }
2576
2577         if (!get_aim_dir(caster_ptr, &dir)) return;
2578         if (line_chaos)
2579                 fire_beam(caster_ptr, chaos_type, dir, 250);
2580         else
2581                 fire_ball(caster_ptr, chaos_type, dir, 250, 3 + (caster_ptr->lev / 35));
2582 }
2583
2584
2585 /*!
2586  * @brief TY_CURSE処理発動 / Activate the evil Topi Ylinen curse
2587  * @param target_ptr プレーヤーへの参照ポインタ
2588  * @param stop_ty 再帰処理停止フラグ
2589  * @param count 発動回数
2590  * @return 作用が実際にあった場合TRUEを返す
2591  * @details
2592  * <pre>
2593  * rr9: Stop the nasty things when a Cyberdemon is summoned
2594  * or the player gets paralyzed.
2595  * </pre>
2596  */
2597 bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count)
2598 {
2599         BIT_FLAGS flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
2600         bool is_first_curse = TRUE;
2601         floor_type *floor_ptr = target_ptr->current_floor_ptr;
2602         while (is_first_curse || one_in_(3) && !stop_ty)
2603         {
2604                 is_first_curse = FALSE;
2605                 switch (randint1(34))
2606                 {
2607                 case 28: case 29:
2608                         if (!(*count))
2609                         {
2610                                 msg_print(_("地面が揺れた...", "The ground trembles..."));
2611                                 earthquake(target_ptr, target_ptr->y, target_ptr->x, 5 + randint0(10), 0);
2612                                 if (!one_in_(6)) break;
2613                         }
2614                 case 30: case 31:
2615                         if (!(*count))
2616                         {
2617                                 HIT_POINT dam = damroll(10, 10);
2618                                 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
2619                                 project(target_ptr, 0, 8, target_ptr->y, target_ptr->x, dam, GF_MANA, flg, -1);
2620                                 take_hit(target_ptr, DAMAGE_NOESCAPE, dam, _("純粋な魔力の解放", "released pure mana"), -1);
2621                                 if (!one_in_(6)) break;
2622                         }
2623                 case 32: case 33:
2624                         if (!(*count))
2625                         {
2626                                 msg_print(_("周囲の空間が歪んだ!", "Space warps about you!"));
2627                                 teleport_player(target_ptr, damroll(10, 10), TELEPORT_PASSIVE);
2628                                 if (randint0(13)) (*count) += activate_hi_summon(target_ptr, target_ptr->y, target_ptr->x, FALSE);
2629                                 if (!one_in_(6)) break;
2630                         }
2631                 case 34:
2632                         msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
2633                         wall_breaker(target_ptr);
2634                         if (!randint0(7))
2635                         {
2636                                 project(target_ptr, 0, 7, target_ptr->y, target_ptr->x, 50, GF_KILL_WALL, flg, -1);
2637                                 take_hit(target_ptr, DAMAGE_NOESCAPE, 50, _("エネルギーのうねり", "surge of energy"), -1);
2638                         }
2639
2640                         if (!one_in_(6)) break;
2641                 case 1: case 2: case 3: case 16: case 17:
2642                         aggravate_monsters(target_ptr, 0);
2643                         if (!one_in_(6)) break;
2644                 case 4: case 5: case 6:
2645                         (*count) += activate_hi_summon(target_ptr, target_ptr->y, target_ptr->x, FALSE);
2646                         if (!one_in_(6)) break;
2647                 case 7: case 8: case 9: case 18:
2648                         (*count) += summon_specific(0, target_ptr->y, target_ptr->x, floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
2649                         if (!one_in_(6)) break;
2650                 case 10: case 11: case 12:
2651                         msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
2652                         lose_exp(target_ptr, target_ptr->exp / 16);
2653                         if (!one_in_(6)) break;
2654                 case 13: case 14: case 15: case 19: case 20:
2655                         if (stop_ty || (target_ptr->free_act && (randint1(125) < target_ptr->skill_sav)) || (target_ptr->pclass == CLASS_BERSERKER))
2656                         {
2657                                 /* Do nothing */ ;
2658                         }
2659                         else
2660                         {
2661                                 msg_print(_("彫像になった気分だ!", "You feel like a statue!"));
2662                                 if (target_ptr->free_act)
2663                                         set_paralyzed(target_ptr, target_ptr->paralyzed + randint1(3));
2664                                 else
2665                                         set_paralyzed(target_ptr, target_ptr->paralyzed + randint1(13));
2666                                 stop_ty = TRUE;
2667                         }
2668
2669                         if (!one_in_(6)) break;
2670                 case 21: case 22: case 23:
2671                         (void)do_dec_stat(target_ptr, randint0(6));
2672                         if (!one_in_(6)) break;
2673                 case 24:
2674                         msg_print(_("ほえ?私は誰?ここで何してる?", "Huh? Who am I? What am I doing here?"));
2675                         lose_all_info(target_ptr);
2676                         if (!one_in_(6)) break;
2677                 case 25:
2678                         if ((floor_ptr->dun_level > 65) && !stop_ty)
2679                         {
2680                                 (*count) += summon_cyber(floor_ptr, -1, target_ptr->y, target_ptr->x);
2681                                 stop_ty = TRUE;
2682                                 break;
2683                         }
2684
2685                         if (!one_in_(6)) break;
2686                 default:
2687                         for (int i = 0; i < A_MAX; i++)
2688                         {
2689                                 bool is_first_dec_stat = TRUE;
2690                                 while (is_first_dec_stat || one_in_(2))
2691                                 {
2692                                         is_first_dec_stat = FALSE;
2693                                         (void)do_dec_stat(target_ptr, i);
2694                                 }
2695                         }
2696                 }
2697         }
2698
2699         return stop_ty;
2700 }
2701
2702
2703 /*!
2704  * todo 引数にPOSITION x/yは必要か? 要調査
2705  * @brief HI_SUMMON(上級召喚)処理発動
2706  * @param caster_ptr プレーヤーへの参照ポインタ
2707  * @param y 召喚位置Y座標
2708  * @param x 召喚位置X座標
2709  * @param can_pet プレイヤーのペットとなる可能性があるならばTRUEにする
2710  * @return 作用が実際にあった場合TRUEを返す
2711  */
2712 int activate_hi_summon(player_type *caster_ptr, POSITION y, POSITION x, bool can_pet)
2713 {
2714         BIT_FLAGS mode = PM_ALLOW_GROUP;
2715         bool pet = FALSE;
2716         if (can_pet)
2717         {
2718                 if (one_in_(4))
2719                 {
2720                         mode |= PM_FORCE_FRIENDLY;
2721                 }
2722                 else
2723                 {
2724                         mode |= PM_FORCE_PET;
2725                         pet = TRUE;
2726                 }
2727         }
2728
2729         if (!pet) mode |= PM_NO_PET;
2730
2731         DEPTH dungeon_level = caster_ptr->current_floor_ptr->dun_level;
2732         DEPTH summon_lev = (pet ? caster_ptr->lev * 2 / 3 + randint1(caster_ptr->lev / 2) : dungeon_level);
2733
2734         int count = 0;
2735         for (int i = 0; i < (randint1(7) + (dungeon_level / 40)); i++)
2736         {
2737                 switch (randint1(25) + (dungeon_level / 20))
2738                 {
2739                 case 1: case 2:
2740                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANT, mode);
2741                         break;
2742                 case 3: case 4:
2743                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_SPIDER, mode);
2744                         break;
2745                 case 5: case 6:
2746                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HOUND, mode);
2747                         break;
2748                 case 7: case 8:
2749                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HYDRA, mode);
2750                         break;
2751                 case 9: case 10:
2752                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANGEL, mode);
2753                         break;
2754                 case 11: case 12:
2755                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNDEAD, mode);
2756                         break;
2757                 case 13: case 14:
2758                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DRAGON, mode);
2759                         break;
2760                 case 15: case 16:
2761                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DEMON, mode);
2762                         break;
2763                 case 17:
2764                         if (can_pet) break;
2765                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
2766                         break;
2767                 case 18: case 19:
2768                         if (can_pet) break;
2769                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE));
2770                         break;
2771                 case 20: case 21:
2772                         if (!can_pet) mode |= PM_ALLOW_UNIQUE;
2773                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_UNDEAD, mode);
2774                         break;
2775                 case 22: case 23:
2776                         if (!can_pet) mode |= PM_ALLOW_UNIQUE;
2777                         count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_DRAGON, mode);
2778                         break;
2779                 case 24:
2780                         count += summon_specific((pet ? -1 : 0), y, x, 100, SUMMON_CYBER, mode);
2781                         break;
2782                 default:
2783                         if (!can_pet) mode |= PM_ALLOW_UNIQUE;
2784                         count += summon_specific((pet ? -1 : 0), y, x, pet ? summon_lev : (((summon_lev * 3) / 2) + 5), 0, mode);
2785                 }
2786         }
2787
2788         return count;
2789 }
2790
2791
2792 /*!
2793  * @brief 周辺破壊効果(プレイヤー中心)
2794  * @param caster_ptr プレーヤーへの参照ポインタ
2795  * @return 作用が実際にあった場合TRUEを返す
2796  */
2797 void wall_breaker(player_type *caster_ptr)
2798 {
2799         POSITION y = 0, x = 0;
2800         int attempts = 1000;
2801         if (randint1(80 + caster_ptr->lev) < 70)
2802         {
2803                 while (attempts--)
2804                 {
2805                         scatter(caster_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 4, 0);
2806
2807                         if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT)) continue;
2808
2809                         if (!player_bold(caster_ptr, y, x)) break;
2810                 }
2811
2812                 project(caster_ptr, 0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
2813                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
2814                 return;
2815         }
2816
2817         if (randint1(100) > 30)
2818         {
2819                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 1, 0);
2820                 return;
2821         }
2822
2823         int num = damroll(5, 3);
2824         for (int i = 0; i < num; i++)
2825         {
2826                 while (TRUE)
2827                 {
2828                         scatter(caster_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 10, 0);
2829
2830                         if (!player_bold(caster_ptr, y, x)) break;
2831                 }
2832
2833                 project(caster_ptr, 0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
2834                         (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
2835         }
2836 }
2837
2838
2839 /*!
2840  * @brief パニック・モンスター効果(プレイヤー視界範囲内) / Confuse monsters
2841  * @param caster_ptr プレーヤーへの参照ポインタ
2842  * @param dam 効力
2843  * @return 作用が実際にあった場合TRUEを返す
2844  */
2845 bool confuse_monsters(player_type *caster_ptr, HIT_POINT dam)
2846 {
2847         return (project_all_los(caster_ptr, GF_OLD_CONF, dam));
2848 }
2849
2850
2851 /*!
2852  * @brief チャーム・モンスター効果(プレイヤー視界範囲内) / Charm monsters
2853  * @param caster_ptr プレーヤーへの参照ポインタ
2854  * @param dam 効力
2855  * @return 作用が実際にあった場合TRUEを返す
2856  */
2857 bool charm_monsters(player_type *caster_ptr, HIT_POINT dam)
2858 {
2859         return (project_all_los(caster_ptr, GF_CHARM, dam));
2860 }
2861
2862
2863 /*!
2864  * @brief 動物魅了効果(プレイヤー視界範囲内) / Charm Animals
2865  * @param caster_ptr プレーヤーへの参照ポインタ
2866  * @param dam 効力
2867  * @return 作用が実際にあった場合TRUEを返す
2868  */
2869 bool charm_animals(player_type *caster_ptr, HIT_POINT dam)
2870 {
2871         return (project_all_los(caster_ptr, GF_CONTROL_ANIMAL, dam));
2872 }
2873
2874
2875 /*!
2876  * @brief モンスター朦朧効果(プレイヤー視界範囲内) / Stun monsters
2877  * @param caster_ptr プレーヤーへの参照ポインタ
2878  * @param dam 効力
2879  * @return 作用が実際にあった場合TRUEを返す
2880  */
2881 bool stun_monsters(player_type *caster_ptr, HIT_POINT dam)
2882 {
2883         return (project_all_los(caster_ptr, GF_STUN, dam));
2884 }
2885
2886
2887 /*!
2888  * @brief モンスター停止効果(プレイヤー視界範囲内) / Stasis monsters
2889  * @param caster_ptr プレーヤーへの参照ポインタ
2890  * @param dam 効力
2891  * @return 作用が実際にあった場合TRUEを返す
2892  */
2893 bool stasis_monsters(player_type *caster_ptr, HIT_POINT dam)
2894 {
2895         return (project_all_los(caster_ptr, GF_STASIS, dam));
2896 }
2897
2898
2899 /*!
2900  * @brief モンスター精神攻撃効果(プレイヤー視界範囲内) / Mindblast monsters
2901  * @param caster_ptr プレーヤーへの参照ポインタ
2902  * @param dam 効力
2903  * @return 作用が実際にあった場合TRUEを返す
2904  */
2905 bool mindblast_monsters(player_type *caster_ptr, HIT_POINT dam)
2906 {
2907         return (project_all_los(caster_ptr, GF_PSI, dam));
2908 }
2909
2910
2911 /*!
2912  * @brief モンスター追放効果(プレイヤー視界範囲内) / Banish all monsters
2913  * @param caster_ptr プレーヤーへの参照ポインタ
2914  * @param dist 効力(距離)
2915  * @return 作用が実際にあった場合TRUEを返す
2916  */
2917 bool banish_monsters(player_type *caster_ptr, int dist)
2918 {
2919         return (project_all_los(caster_ptr, GF_AWAY_ALL, dist));
2920 }
2921
2922
2923 /*!
2924  * @brief 邪悪退散効果(プレイヤー視界範囲内) / Turn evil
2925  * @param caster_ptr プレーヤーへの参照ポインタ
2926  * @param dam 効力
2927  * @return 作用が実際にあった場合TRUEを返す
2928  */
2929 bool turn_evil(player_type *caster_ptr, HIT_POINT dam)
2930 {
2931         return (project_all_los(caster_ptr, GF_TURN_EVIL, dam));
2932 }
2933
2934
2935 /*!
2936  * @brief 全モンスター退散効果(プレイヤー視界範囲内) / Turn everyone
2937  * @param caster_ptr プレーヤーへの参照ポインタ
2938  * @param dam 効力
2939  * @return 作用が実際にあった場合TRUEを返す
2940  */
2941 bool turn_monsters(player_type *caster_ptr, HIT_POINT dam)
2942 {
2943         return (project_all_los(caster_ptr, GF_TURN_ALL, dam));
2944 }
2945
2946
2947 /*!
2948  * @brief 死の光線(プレイヤー視界範囲内) / Death-ray all monsters (note: OBSCENELY powerful)
2949  * @param caster_ptr プレーヤーへの参照ポインタ
2950  * @return 作用が実際にあった場合TRUEを返す
2951  */
2952 bool deathray_monsters(player_type *caster_ptr)
2953 {
2954         return (project_all_los(caster_ptr, GF_DEATH_RAY, caster_ptr->lev * 200));
2955 }
2956
2957
2958 /*!
2959  * @brief チャーム・モンスター(1体)
2960  * @param caster_ptr プレーヤーへの参照ポインタ
2961  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2962  * @param plev パワー
2963  * @return 作用が実際にあった場合TRUEを返す
2964  */
2965 bool charm_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
2966 {
2967         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
2968         return (project_hook(caster_ptr, GF_CHARM, dir, plev, flg));
2969 }
2970
2971
2972 /*!
2973  * @brief アンデッド支配(1体)
2974  * @param caster_ptr プレーヤーへの参照ポインタ
2975  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2976  * @param plev パワー
2977  * @return 作用が実際にあった場合TRUEを返す
2978  */
2979 bool control_one_undead(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
2980 {
2981         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
2982         return (project_hook(caster_ptr, GF_CONTROL_UNDEAD, dir, plev, flg));
2983 }
2984
2985
2986 /*!
2987  * @brief 悪魔支配(1体)
2988  * @param caster_ptr プレーヤーへの参照ポインタ
2989  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2990  * @param plev パワー
2991  * @return 作用が実際にあった場合TRUEを返す
2992  */
2993 bool control_one_demon(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
2994 {
2995         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
2996         return (project_hook(caster_ptr, GF_CONTROL_DEMON, dir, plev, flg));
2997 }
2998
2999
3000 /*!
3001  * @brief 動物支配(1体)
3002  * @param caster_ptr プレーヤーへの参照ポインタ
3003  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3004  * @param plev パワー
3005  * @return 作用が実際にあった場合TRUEを返す
3006  */
3007 bool charm_animal(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
3008 {
3009         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3010         return (project_hook(caster_ptr, GF_CONTROL_ANIMAL, dir, plev, flg));
3011 }
3012
3013
3014 /*!
3015  * @brief 変わり身処理
3016  * @param caster_ptr プレーヤーへの参照ポインタ
3017  * @param success 判定成功上の処理ならばTRUE
3018  * @return 作用が実際にあった場合TRUEを返す
3019  */
3020 bool kawarimi(player_type *caster_ptr, bool success)
3021 {
3022         object_type forge;
3023         object_type *q_ptr = &forge;
3024
3025         if (caster_ptr->is_dead) return FALSE;
3026         if (caster_ptr->confused || caster_ptr->blind || caster_ptr->paralyzed || caster_ptr->image) return FALSE;
3027         if (randint0(200) < caster_ptr->stun) return FALSE;
3028
3029         if (!success && one_in_(3))
3030         {
3031                 msg_print(_("失敗!逃げられなかった。", "Failed! You couldn't run away."));
3032                 caster_ptr->special_defense &= ~(NINJA_KAWARIMI);
3033                 caster_ptr->redraw |= (PR_STATUS);
3034                 return FALSE;
3035         }
3036
3037         POSITION y = caster_ptr->y;
3038         POSITION x = caster_ptr->x;
3039
3040         teleport_player(caster_ptr, 10 + randint1(90), 0L);
3041         object_wipe(q_ptr);
3042         object_prep(q_ptr, lookup_kind(TV_STATUE, SV_WOODEN_STATUE));
3043
3044         q_ptr->pval = MON_NINJA;
3045         (void)drop_near(caster_ptr, q_ptr, -1, y, x);
3046
3047         if (success) msg_print(_("攻撃を受ける前に素早く身をひるがえした。", "You have turned around just before the attack hit you."));
3048         else msg_print(_("失敗!攻撃を受けてしまった。", "Failed! You are hit by the attack."));
3049
3050         caster_ptr->special_defense &= ~(NINJA_KAWARIMI);
3051         caster_ptr->redraw |= (PR_STATUS);
3052
3053         /* Teleported */
3054         return TRUE;
3055 }
3056
3057
3058 /*!
3059  * @brief 入身処理 / "Rush Attack" routine for Samurai or Ninja
3060  * @param caster_ptr プレーヤーへの参照ポインタ
3061  * @param mdeath 目標モンスターが死亡したかを返す
3062  * @return 作用が実際にあった場合TRUEを返す /  Return value is for checking "done"
3063  */
3064 bool rush_attack(player_type *attacker_ptr, bool *mdeath)
3065 {
3066         if (mdeath) *mdeath = FALSE;
3067
3068         project_length = 5;
3069         DIRECTION dir;
3070         if (!get_aim_dir(attacker_ptr, &dir)) return FALSE;
3071
3072         /* Use the given direction */
3073         int tx = attacker_ptr->x + project_length * ddx[dir];
3074         int ty = attacker_ptr->y + project_length * ddy[dir];
3075
3076         if ((dir == 5) && target_okay(attacker_ptr))
3077         {
3078                 tx = target_col;
3079                 ty = target_row;
3080         }
3081
3082         int tm_idx = 0;
3083         floor_type *floor_ptr = attacker_ptr->current_floor_ptr;
3084         if (in_bounds(floor_ptr, ty, tx)) tm_idx = floor_ptr->grid_array[ty][tx].m_idx;
3085
3086         u16b path_g[32];
3087         int path_n = project_path(attacker_ptr, path_g, project_length, attacker_ptr->y, attacker_ptr->x, ty, tx, PROJECT_STOP | PROJECT_KILL);
3088         project_length = 0;
3089
3090         /* No need to move */
3091         if (!path_n) return TRUE;
3092
3093         /* Use ty and tx as to-move point */
3094         ty = attacker_ptr->y;
3095         tx = attacker_ptr->x;
3096
3097         /* Project along the path */
3098         bool tmp_mdeath = FALSE;
3099         bool moved = FALSE;
3100         for (int i = 0; i < path_n; i++)
3101         {
3102                 monster_type *m_ptr;
3103
3104                 int ny = GRID_Y(path_g[i]);
3105                 int nx = GRID_X(path_g[i]);
3106
3107                 if (cave_empty_bold(floor_ptr, ny, nx) && player_can_enter(attacker_ptr, floor_ptr->grid_array[ny][nx].feat, 0))
3108                 {
3109                         ty = ny;
3110                         tx = nx;
3111
3112                         /* Go to next grid */
3113                         continue;
3114                 }
3115
3116                 if (!floor_ptr->grid_array[ny][nx].m_idx)
3117                 {
3118                         if (tm_idx)
3119                         {
3120                                 msg_print(_("失敗!", "Failed!"));
3121                         }
3122                         else
3123                         {
3124                                 msg_print(_("ここには入身では入れない。", "You can't move to that place."));
3125                         }
3126
3127                         /* Exit loop */
3128                         break;
3129                 }
3130
3131                 /* Move player before updating the monster */
3132                 if (!player_bold(attacker_ptr, ty, tx)) teleport_player_to(attacker_ptr, ty, tx, TELEPORT_NONMAGICAL);
3133                 update_monster(attacker_ptr, floor_ptr->grid_array[ny][nx].m_idx, TRUE);
3134
3135                 /* Found a monster */
3136                 m_ptr = &floor_ptr->m_list[floor_ptr->grid_array[ny][nx].m_idx];
3137
3138                 if (tm_idx != floor_ptr->grid_array[ny][nx].m_idx)
3139                 {
3140 #ifdef JP
3141                         msg_format("%s%sが立ちふさがっている!", tm_idx ? "別の" : "", m_ptr->ml ? "モンスター" : "何か");
3142 #else
3143                         msg_format("There is %s in the way!", m_ptr->ml ? (tm_idx ? "another monster" : "a monster") : "someone");
3144 #endif
3145                 }
3146                 else if (!player_bold(attacker_ptr, ty, tx))
3147                 {
3148                         /* Hold the monster name */
3149                         GAME_TEXT m_name[MAX_NLEN];
3150
3151                         /* Get the monster name (BEFORE polymorphing) */
3152                         monster_desc(m_name, m_ptr, 0);
3153                         msg_format(_("素早く%sの懐に入り込んだ!", "You quickly jump in and attack %s!"), m_name);
3154                 }
3155
3156                 if (!player_bold(attacker_ptr, ty, tx)) teleport_player_to(attacker_ptr, ty, tx, TELEPORT_NONMAGICAL);
3157                 moved = TRUE;
3158                 tmp_mdeath = py_attack(attacker_ptr, ny, nx, HISSATSU_NYUSIN);
3159
3160                 break;
3161         }
3162
3163         if (!moved && !player_bold(attacker_ptr, ty, tx)) teleport_player_to(attacker_ptr, ty, tx, TELEPORT_NONMAGICAL);
3164
3165         if (mdeath) *mdeath = tmp_mdeath;
3166         return TRUE;
3167 }
3168
3169
3170 /*!
3171  * @brief 全鏡の消去 / Remove all mirrors in this floor
3172  * @param caster_ptr プレーヤーへの参照ポインタ
3173  * @param explode 爆発処理を伴うならばTRUE
3174  * @return なし
3175  */
3176 void remove_all_mirrors(player_type *caster_ptr, bool explode)
3177 {
3178         for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++)
3179         {
3180                 for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++)
3181                 {
3182                         if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
3183                                 continue;
3184
3185                         remove_mirror(caster_ptr, y, x);
3186                         if (!explode) continue;
3187
3188                         project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS,
3189                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
3190                 }
3191         }
3192 }
3193
3194
3195 /*!
3196  * @brief 『一つの指輪』の効果処理 /
3197  * Hack -- activate the ring of power
3198  * @param caster_ptr プレーヤーへの参照ポインタ
3199  * @param dir 発動の方向ID
3200  * @return なし
3201  */
3202 void ring_of_power(player_type *caster_ptr, DIRECTION dir)
3203 {
3204         switch (randint1(10))
3205         {
3206         case 1:
3207         case 2:
3208         {
3209                 msg_print(_("あなたは悪性のオーラに包み込まれた。", "You are surrounded by a malignant aura."));
3210                 sound(SOUND_EVIL);
3211
3212                 /* Decrease all stats (permanently) */
3213                 (void)dec_stat(caster_ptr, A_STR, 50, TRUE);
3214                 (void)dec_stat(caster_ptr, A_INT, 50, TRUE);
3215                 (void)dec_stat(caster_ptr, A_WIS, 50, TRUE);
3216                 (void)dec_stat(caster_ptr, A_DEX, 50, TRUE);
3217                 (void)dec_stat(caster_ptr, A_CON, 50, TRUE);
3218                 (void)dec_stat(caster_ptr, A_CHR, 50, TRUE);
3219
3220                 /* Lose some experience (permanently) */
3221                 caster_ptr->exp -= (caster_ptr->exp / 4);
3222                 caster_ptr->max_exp -= (caster_ptr->exp / 4);
3223                 check_experience(caster_ptr);
3224
3225                 break;
3226         }
3227
3228         case 3:
3229         {
3230                 msg_print(_("あなたは強力なオーラに包み込まれた。", "You are surrounded by a powerful aura."));
3231                 dispel_monsters(caster_ptr, 1000);
3232                 break;
3233         }
3234
3235         case 4:
3236         case 5:
3237         case 6:
3238         {
3239                 fire_ball(caster_ptr, GF_MANA, dir, 600, 3);
3240                 break;
3241         }
3242
3243         case 7:
3244         case 8:
3245         case 9:
3246         case 10:
3247         {
3248                 fire_bolt(caster_ptr, GF_MANA, dir, 500);
3249                 break;
3250         }
3251         }
3252 }
3253
3254
3255 /*!
3256 * @brief 運命の輪、並びにカオス的な効果の発動
3257 * @param caster_ptr プレーヤーへの参照ポインタ
3258 * @param spell ランダムな効果を選択するための基準ID
3259 * @return なし
3260 */
3261 void wild_magic(player_type *caster_ptr, int spell)
3262 {
3263         int type = SUMMON_MOLD + randint0(6);
3264         if (type < SUMMON_MOLD) type = SUMMON_MOLD;
3265         else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
3266
3267         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
3268         switch (randint1(spell) + randint1(8) + 1)
3269         {
3270         case 1:
3271         case 2:
3272         case 3:
3273                 teleport_player(caster_ptr, 10, TELEPORT_PASSIVE);
3274                 break;
3275         case 4:
3276         case 5:
3277         case 6:
3278                 teleport_player(caster_ptr, 100, TELEPORT_PASSIVE);
3279                 break;
3280         case 7:
3281         case 8:
3282                 teleport_player(caster_ptr, 200, TELEPORT_PASSIVE);
3283                 break;
3284         case 9:
3285         case 10:
3286         case 11:
3287                 unlite_area(caster_ptr, 10, 3);
3288                 break;
3289         case 12:
3290         case 13:
3291         case 14:
3292                 lite_area(caster_ptr, damroll(2, 3), 2);
3293                 break;
3294         case 15:
3295                 destroy_doors_touch(caster_ptr);
3296                 break;
3297         case 16: case 17:
3298                 wall_breaker(caster_ptr);
3299         case 18:
3300                 sleep_monsters_touch(caster_ptr);
3301                 break;
3302         case 19:
3303         case 20:
3304                 trap_creation(caster_ptr, caster_ptr->y, caster_ptr->x);
3305                 break;
3306         case 21:
3307         case 22:
3308                 door_creation(caster_ptr, caster_ptr->y, caster_ptr->x);
3309                 break;
3310         case 23:
3311         case 24:
3312         case 25:
3313                 aggravate_monsters(caster_ptr, 0);
3314                 break;
3315         case 26:
3316                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 5, 0);
3317                 break;
3318         case 27:
3319         case 28:
3320                 (void)gain_mutation(caster_ptr, 0);
3321                 break;
3322         case 29:
3323         case 30:
3324                 apply_disenchant(caster_ptr, 1);
3325                 break;
3326         case 31:
3327                 lose_all_info(caster_ptr);
3328                 break;
3329         case 32:
3330                 fire_ball(caster_ptr, GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
3331                 break;
3332         case 33:
3333                 wall_stone(caster_ptr);
3334                 break;
3335         case 34:
3336         case 35:
3337                 for (int counter = 0; counter < 8; counter++)
3338                 {
3339                         (void)summon_specific(0, caster_ptr->y, caster_ptr->x, (floor_ptr->dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
3340                 }
3341
3342                 break;
3343         case 36:
3344         case 37:
3345                 activate_hi_summon(caster_ptr, caster_ptr->y, caster_ptr->x, FALSE);
3346                 break;
3347         case 38:
3348                 (void)summon_cyber(floor_ptr, -1, caster_ptr->y, caster_ptr->x);
3349                 break;
3350         default:
3351         {
3352                 int count = 0;
3353                 (void)activate_ty_curse(caster_ptr, FALSE, &count);
3354                 break;
3355         }
3356         }
3357 }
3358
3359
3360 /*!
3361 * @brief カオス魔法「流星群」の処理としてプレイヤーを中心に隕石落下処理を10+1d10回繰り返す。
3362 * / Drop 10+1d10 meteor ball at random places near the player
3363 * @param caster_ptr プレーヤーへの参照ポインタ
3364 * @param dam ダメージ
3365 * @param rad 効力の半径
3366 * @return なし
3367 */
3368 void cast_meteor(player_type *caster_ptr, HIT_POINT dam, POSITION rad)
3369 {
3370         int b = 10 + randint1(10);
3371         for (int i = 0; i < b; i++)
3372         {
3373                 POSITION y = 0, x = 0;
3374                 int count;
3375
3376                 for (count = 0; count <= 20; count++)
3377                 {
3378                         int dy, dx, d;
3379
3380                         x = caster_ptr->x - 8 + randint0(17);
3381                         y = caster_ptr->y - 8 + randint0(17);
3382
3383                         dx = (caster_ptr->x > x) ? (caster_ptr->x - x) : (x - caster_ptr->x);
3384                         dy = (caster_ptr->y > y) ? (caster_ptr->y - y) : (y - caster_ptr->y);
3385
3386                         /* Approximate distance */
3387                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
3388
3389                         if (d >= 9) continue;
3390
3391                         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
3392                         if (!in_bounds(floor_ptr, y, x) || !projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x)
3393                                 || !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT)) continue;
3394
3395                         break;
3396                 }
3397
3398                 if (count > 20) continue;
3399
3400                 project(caster_ptr, 0, rad, y, x, dam, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
3401         }
3402 }
3403
3404
3405 /*!
3406 * @brief 破邪魔法「神の怒り」の処理としてターゲットを指定した後分解のボールを最大20回発生させる。
3407 * @param caster_ptr プレーヤーへの参照ポインタ
3408 * @param dam ダメージ
3409 * @param rad 効力の半径
3410 * @return ターゲットを指定し、実行したならばTRUEを返す。
3411 */
3412 bool cast_wrath_of_the_god(player_type *caster_ptr, HIT_POINT dam, POSITION rad)
3413 {
3414         DIRECTION dir;
3415         if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
3416
3417         /* Use the given direction */
3418         POSITION tx = caster_ptr->x + 99 * ddx[dir];
3419         POSITION ty = caster_ptr->y + 99 * ddy[dir];
3420
3421         /* Hack -- Use an actual "target" */
3422         if ((dir == 5) && target_okay(caster_ptr))
3423         {
3424                 tx = target_col;
3425                 ty = target_row;
3426         }
3427
3428         POSITION x = caster_ptr->x;
3429         POSITION y = caster_ptr->y;
3430         POSITION nx, ny;
3431         while (TRUE)
3432         {
3433                 /* Hack -- Stop at the target */
3434                 if ((y == ty) && (x == tx)) break;
3435
3436                 ny = y;
3437                 nx = x;
3438                 mmove2(&ny, &nx, caster_ptr->y, caster_ptr->x, ty, tx);
3439
3440                 /* Stop at maximum range */
3441                 if (MAX_RANGE <= distance(caster_ptr->y, caster_ptr->x, ny, nx)) break;
3442
3443                 /* Stopped by walls/doors */
3444                 if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, ny, nx, FF_PROJECT)) break;
3445
3446                 /* Stopped by monsters */
3447                 if ((dir != 5) && caster_ptr->current_floor_ptr->grid_array[ny][nx].m_idx != 0) break;
3448
3449                 /* Save the new location */
3450                 x = nx;
3451                 y = ny;
3452         }
3453
3454         tx = x;
3455         ty = y;
3456
3457         int b = 10 + randint1(10);
3458         for (int i = 0; i < b; i++)
3459         {
3460                 int count = 20, d = 0;
3461
3462                 while (count--)
3463                 {
3464                         int dx, dy;
3465
3466                         x = tx - 5 + randint0(11);
3467                         y = ty - 5 + randint0(11);
3468
3469                         dx = (tx > x) ? (tx - x) : (x - tx);
3470                         dy = (ty > y) ? (ty - y) : (y - ty);
3471
3472                         /* Approximate distance */
3473                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
3474                         /* Within the radius */
3475                         if (d < 5) break;
3476                 }
3477
3478                 if (count < 0) continue;
3479
3480                 /* Cannot penetrate perm walls */
3481                 if (!in_bounds(caster_ptr->current_floor_ptr, y, x) ||
3482                         cave_stop_disintegration(caster_ptr->current_floor_ptr, y, x) ||
3483                         !in_disintegration_range(caster_ptr->current_floor_ptr, ty, tx, y, x))
3484                         continue;
3485
3486                 project(caster_ptr, 0, rad, y, x, dam, GF_DISINTEGRATE, PROJECT_JUMP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
3487         }
3488
3489         return TRUE;
3490 }
3491
3492 /*!
3493 * @brief 「ワンダー」のランダムな効果を決定して処理する。
3494 * @param caster_ptr プレーヤーへの参照ポインタ
3495 * @param dir 方向ID
3496 * @return なし
3497 * @details
3498 * This spell should become more useful (more controlled) as the\n
3499 * player gains experience levels.  Thus, add 1/5 of the player's\n
3500 * level to the die roll.  This eliminates the worst effects later on,\n
3501 * while keeping the results quite random.  It also allows some potent\n
3502 * effects only at high level.
3503 */
3504 void cast_wonder(player_type *caster_ptr, DIRECTION dir)
3505 {
3506         PLAYER_LEVEL plev = caster_ptr->lev;
3507         int die = randint1(100) + plev / 5;
3508         int vir = virtue_number(caster_ptr, V_CHANCE);
3509         if (vir)
3510         {
3511                 if (caster_ptr->virtues[vir - 1] > 0)
3512                 {
3513                         while (randint1(400) < caster_ptr->virtues[vir - 1]) die++;
3514                 }
3515                 else
3516                 {
3517                         while (randint1(400) < (0 - caster_ptr->virtues[vir - 1])) die--;
3518                 }
3519         }
3520
3521         if (die < 26)
3522         {
3523                 chg_virtue(caster_ptr, V_CHANCE, 1);
3524         }
3525
3526         if (die > 100)
3527         {
3528                 msg_print(_("あなたは力がみなぎるのを感じた!", "You feel a surge of power!"));
3529         }
3530
3531         if (die < 8)
3532         {
3533                 clone_monster(caster_ptr, dir);
3534                 return;
3535         }
3536         
3537         if (die < 14)
3538         {
3539                 speed_monster(caster_ptr, dir, plev);
3540                 return;
3541         }
3542
3543         if (die < 26)
3544         {
3545                 heal_monster(caster_ptr, dir, damroll(4, 6));
3546                 return;
3547         }
3548
3549         if (die < 31)
3550         {
3551                 poly_monster(caster_ptr, dir, plev);
3552                 return;
3553         }
3554
3555         if (die < 36)
3556         {
3557                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_MISSILE, dir,
3558                         damroll(3 + ((plev - 1) / 5), 4));
3559                 return;
3560         }
3561
3562         if (die < 41)
3563         {
3564                 confuse_monster(caster_ptr, dir, plev);
3565                 return;
3566         }
3567         
3568         if (die < 46)
3569         {
3570                 fire_ball(caster_ptr, GF_POIS, dir, 20 + (plev / 2), 3);
3571                 return;
3572         }
3573
3574         if (die < 51)
3575         {
3576                 (void)lite_line(caster_ptr, dir, damroll(6, 8));
3577                 return;
3578         }
3579         
3580         if (die < 56)
3581         {
3582                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_ELEC, dir,
3583                         damroll(3 + ((plev - 5) / 4), 8));
3584                 return;
3585         }
3586         
3587         if (die < 61)
3588         {
3589                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_COLD, dir,
3590                         damroll(5 + ((plev - 5) / 4), 8));
3591                 return;
3592         }
3593         
3594         if (die < 66)
3595         {
3596                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_ACID, dir,
3597                         damroll(6 + ((plev - 5) / 4), 8));
3598                 return;
3599         }
3600         
3601         if (die < 71)
3602         {
3603                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_FIRE, dir,
3604                         damroll(8 + ((plev - 5) / 4), 8));
3605                 return;
3606         }
3607         
3608         if (die < 76)
3609         {
3610                 hypodynamic_bolt(caster_ptr, dir, 75);
3611                 return;
3612         }
3613         
3614         if (die < 81)
3615         {
3616                 fire_ball(caster_ptr, GF_ELEC, dir, 30 + plev / 2, 2);
3617                 return;
3618         }
3619         
3620         if (die < 86)
3621         {
3622                 fire_ball(caster_ptr, GF_ACID, dir, 40 + plev, 2);
3623                 return;
3624         }
3625         
3626         if (die < 91)
3627         {
3628                 fire_ball(caster_ptr, GF_ICE, dir, 70 + plev, 3);
3629                 return;
3630         }
3631
3632         if (die < 96)
3633         {
3634                 fire_ball(caster_ptr, GF_FIRE, dir, 80 + plev, 3);
3635                 return;
3636         }
3637
3638         if (die < 101)
3639         {
3640                 hypodynamic_bolt(caster_ptr, dir, 100 + plev);
3641                 return;
3642         }
3643         
3644         if (die < 104)
3645         {
3646                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 12, 0);
3647                 return;
3648         }
3649
3650         if (die < 106)
3651         {
3652                 (void)destroy_area(caster_ptr, caster_ptr->y, caster_ptr->x, 13 + randint0(5), FALSE);
3653                 return;
3654         }
3655         
3656         if (die < 108)
3657         {
3658                 symbol_genocide(caster_ptr, plev + 50, TRUE);
3659                 return;
3660         }
3661
3662         if (die < 110)
3663         {
3664                 dispel_monsters(caster_ptr, 120);
3665                 return;
3666         }
3667         
3668         dispel_monsters(caster_ptr, 150);
3669         slow_monsters(caster_ptr, plev);
3670         sleep_monsters(caster_ptr, plev);
3671         hp_player(caster_ptr, 300);
3672 }
3673
3674
3675 /*!
3676 * @brief 「悪霊召喚」のランダムな効果を決定して処理する。
3677 * @param caster_ptr プレーヤーへの参照ポインタ
3678 * @param dir 方向ID
3679 * @return なし
3680 */
3681 void cast_invoke_spirits(player_type *caster_ptr, DIRECTION dir)
3682 {
3683         PLAYER_LEVEL plev = caster_ptr->lev;
3684         int die = randint1(100) + plev / 5;
3685         int vir = virtue_number(caster_ptr, V_CHANCE);
3686
3687         if (vir)
3688         {
3689                 if (caster_ptr->virtues[vir - 1] > 0)
3690                 {
3691                         while (randint1(400) < caster_ptr->virtues[vir - 1]) die++;
3692                 }
3693                 else
3694                 {
3695                         while (randint1(400) < (0 - caster_ptr->virtues[vir - 1])) die--;
3696                 }
3697         }
3698
3699         msg_print(_("あなたは死者たちの力を招集した...", "You call on the power of the dead..."));
3700         if (die < 26)
3701                 chg_virtue(caster_ptr, V_CHANCE, 1);
3702
3703         if (die > 100)
3704         {
3705                 msg_print(_("あなたはおどろおどろしい力のうねりを感じた!", "You feel a surge of eldritch force!"));
3706         }
3707
3708         if (die < 8)
3709         {
3710                 msg_print(_("なんてこった!あなたの周りの地面から朽ちた人影が立ち上がってきた!",
3711                         "Oh no! Mouldering forms rise from the earth around you!"));
3712
3713                 (void)summon_specific(0, caster_ptr->y, caster_ptr->x, caster_ptr->current_floor_ptr->dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
3714                 chg_virtue(caster_ptr, V_UNLIFE, 1);
3715         }
3716         else if (die < 14)
3717         {
3718                 msg_print(_("名状し難い邪悪な存在があなたの心を通り過ぎて行った...", "An unnamable evil brushes against your mind..."));
3719
3720                 set_afraid(caster_ptr, caster_ptr->afraid + randint1(4) + 4);
3721         }
3722         else if (die < 26)
3723         {
3724                 msg_print(_("あなたの頭に大量の幽霊たちの騒々しい声が押し寄せてきた...",
3725                         "Your head is invaded by a horde of gibbering spectral voices..."));
3726
3727                 set_confused(caster_ptr, caster_ptr->confused + randint1(4) + 4);
3728         }
3729         else if (die < 31)
3730         {
3731                 poly_monster(caster_ptr, dir, plev);
3732         }
3733         else if (die < 36)
3734         {
3735                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_MISSILE, dir,
3736                         damroll(3 + ((plev - 1) / 5), 4));
3737         }
3738         else if (die < 41)
3739         {
3740                 confuse_monster(caster_ptr, dir, plev);
3741         }
3742         else if (die < 46)
3743         {
3744                 fire_ball(caster_ptr, GF_POIS, dir, 20 + (plev / 2), 3);
3745         }
3746         else if (die < 51)
3747         {
3748                 (void)lite_line(caster_ptr, dir, damroll(6, 8));
3749         }
3750         else if (die < 56)
3751         {
3752                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_ELEC, dir,
3753                         damroll(3 + ((plev - 5) / 4), 8));
3754         }
3755         else if (die < 61)
3756         {
3757                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_COLD, dir,
3758                         damroll(5 + ((plev - 5) / 4), 8));
3759         }
3760         else if (die < 66)
3761         {
3762                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_ACID, dir,
3763                         damroll(6 + ((plev - 5) / 4), 8));
3764         }
3765         else if (die < 71)
3766         {
3767                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr), GF_FIRE, dir,
3768                         damroll(8 + ((plev - 5) / 4), 8));
3769         }
3770         else if (die < 76)
3771         {
3772                 hypodynamic_bolt(caster_ptr, dir, 75);
3773         }
3774         else if (die < 81)
3775         {
3776                 fire_ball(caster_ptr, GF_ELEC, dir, 30 + plev / 2, 2);
3777         }
3778         else if (die < 86)
3779         {
3780                 fire_ball(caster_ptr, GF_ACID, dir, 40 + plev, 2);
3781         }
3782         else if (die < 91)
3783         {
3784                 fire_ball(caster_ptr, GF_ICE, dir, 70 + plev, 3);
3785         }
3786         else if (die < 96)
3787         {
3788                 fire_ball(caster_ptr, GF_FIRE, dir, 80 + plev, 3);
3789         }
3790         else if (die < 101)
3791         {
3792                 hypodynamic_bolt(caster_ptr, dir, 100 + plev);
3793         }
3794         else if (die < 104)
3795         {
3796                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 12, 0);
3797         }
3798         else if (die < 106)
3799         {
3800                 (void)destroy_area(caster_ptr, caster_ptr->y, caster_ptr->x, 13 + randint0(5), FALSE);
3801         }
3802         else if (die < 108)
3803         {
3804                 symbol_genocide(caster_ptr, plev + 50, TRUE);
3805         }
3806         else if (die < 110)
3807         {
3808                 dispel_monsters(caster_ptr, 120);
3809         }
3810         else
3811         {
3812                 dispel_monsters(caster_ptr, 150);
3813                 slow_monsters(caster_ptr, plev);
3814                 sleep_monsters(caster_ptr, plev);
3815                 hp_player(caster_ptr, 300);
3816         }
3817
3818         if (die < 31)
3819         {
3820                 msg_print(_("陰欝な声がクスクス笑う。「もうすぐおまえは我々の仲間になるだろう。弱き者よ。」",
3821                         "Sepulchral voices chuckle. 'Soon you will join us, mortal.'"));
3822         }
3823 }
3824
3825 /*!
3826 * @brief トランプ領域の「シャッフル」の効果をランダムに決めて処理する。
3827 * @param caster_ptr プレーヤーへの参照ポインタ
3828 * @return なし
3829 */
3830 void cast_shuffle(player_type *caster_ptr)
3831 {
3832         PLAYER_LEVEL plev = caster_ptr->lev;
3833         DIRECTION dir;
3834         int die;
3835         int vir = virtue_number(caster_ptr, V_CHANCE);
3836         int i;
3837
3838         /* Card sharks and high mages get a level bonus */
3839         if ((caster_ptr->pclass == CLASS_ROGUE) ||
3840                 (caster_ptr->pclass == CLASS_HIGH_MAGE) ||
3841                 (caster_ptr->pclass == CLASS_SORCERER))
3842                 die = (randint1(110)) + plev / 5;
3843         else
3844                 die = randint1(120);
3845         
3846         if (vir)
3847         {
3848                 if (caster_ptr->virtues[vir - 1] > 0)
3849                 {
3850                         while (randint1(400) < caster_ptr->virtues[vir - 1]) die++;
3851                 }
3852                 else
3853                 {
3854                         while (randint1(400) < (0 - caster_ptr->virtues[vir - 1])) die--;
3855                 }
3856         }
3857
3858         msg_print(_("あなたはカードを切って一枚引いた...", "You shuffle the deck and draw a card..."));
3859
3860         if (die < 30)
3861         {
3862                 chg_virtue(caster_ptr, V_CHANCE, 1);
3863         }
3864
3865         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
3866         if (die < 7)
3867         {
3868                 msg_print(_("なんてこった!《死》だ!", "Oh no! It's Death!"));
3869
3870                 for (i = 0; i < randint1(3); i++)
3871                 {
3872                         activate_hi_summon(caster_ptr, caster_ptr->y, caster_ptr->x, FALSE);
3873                 }
3874
3875                 return;
3876         }
3877
3878         if (die < 14)
3879         {
3880                 msg_print(_("なんてこった!《悪魔》だ!", "Oh no! It's the Devil!"));
3881                 summon_specific(0, caster_ptr->y, caster_ptr->x, floor_ptr->dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
3882                 return;
3883         }
3884         
3885         if (die < 18)
3886         {
3887                 int count = 0;
3888                 msg_print(_("なんてこった!《吊られた男》だ!", "Oh no! It's the Hanged Man."));
3889                 activate_ty_curse(caster_ptr, FALSE, &count);
3890                 return;
3891         }
3892         
3893         if (die < 22)
3894         {
3895                 msg_print(_("《不調和の剣》だ。", "It's the swords of discord."));
3896                 aggravate_monsters(caster_ptr, 0);
3897                 return;
3898         }
3899         
3900         if (die < 26)
3901         {
3902                 msg_print(_("《愚者》だ。", "It's the Fool."));
3903                 do_dec_stat(caster_ptr, A_INT);
3904                 do_dec_stat(caster_ptr, A_WIS);
3905                 return;
3906         }
3907         
3908         if (die < 30)
3909         {
3910                 msg_print(_("奇妙なモンスターの絵だ。", "It's the picture of a strange monster."));
3911                 trump_summoning(caster_ptr, 1, FALSE, caster_ptr->y, caster_ptr->x, (floor_ptr->dun_level * 3 / 2), (32 + randint1(6)), PM_ALLOW_GROUP | PM_ALLOW_UNIQUE);
3912                 return;
3913         }
3914         
3915         if (die < 33)
3916         {
3917                 msg_print(_("《月》だ。", "It's the Moon."));
3918                 unlite_area(caster_ptr, 10, 3);
3919                 return;
3920         }
3921         
3922         if (die < 38)
3923         {
3924                 msg_print(_("《運命の輪》だ。", "It's the Wheel of Fortune."));
3925                 wild_magic(caster_ptr, randint0(32));
3926                 return;
3927         }
3928         
3929         if (die < 40)
3930         {
3931                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
3932                 teleport_player(caster_ptr, 10, TELEPORT_PASSIVE);
3933                 return;
3934         }
3935         
3936         if (die < 42)
3937         {
3938                 msg_print(_("《正義》だ。", "It's Justice."));
3939                 set_blessed(caster_ptr, caster_ptr->lev, FALSE);
3940                 return;
3941         }
3942         
3943         if (die < 47)
3944         {
3945                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
3946                 teleport_player(caster_ptr, 100, TELEPORT_PASSIVE);
3947                 return;
3948         }
3949
3950         if (die < 52)
3951         {
3952                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
3953                 teleport_player(caster_ptr, 200, TELEPORT_PASSIVE);
3954                 return;
3955         }
3956         
3957         if (die < 60)
3958         {
3959                 msg_print(_("《塔》だ。", "It's the Tower."));
3960                 wall_breaker(caster_ptr);
3961                 return;
3962         }
3963         
3964         if (die < 72)
3965         {
3966                 msg_print(_("《節制》だ。", "It's Temperance."));
3967                 sleep_monsters_touch(caster_ptr);
3968                 return;
3969         }
3970         
3971         if (die < 80)
3972         {
3973                 msg_print(_("《塔》だ。", "It's the Tower."));
3974                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, 5, 0);
3975                 return;
3976         }
3977         
3978         if (die < 82)
3979         {
3980                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
3981                 trump_summoning(caster_ptr, 1, TRUE, caster_ptr->y, caster_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_MOLD, 0L);
3982                 return;
3983         }
3984         
3985         if (die < 84)
3986         {
3987                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
3988                 trump_summoning(caster_ptr, 1, TRUE, caster_ptr->y, caster_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_BAT, 0L);
3989                 return;
3990         }
3991         
3992         if (die < 86)
3993         {
3994                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
3995                 trump_summoning(caster_ptr, 1, TRUE, caster_ptr->y, caster_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_VORTEX, 0L);
3996                 return;
3997         }
3998         
3999         if (die < 88)
4000         {
4001                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4002                 trump_summoning(caster_ptr, 1, TRUE, caster_ptr->y, caster_ptr->x, (floor_ptr->dun_level * 3 / 2), SUMMON_COIN_MIMIC, 0L);
4003                 return;
4004         }
4005         
4006         if (die < 96)
4007         {
4008                 msg_print(_("《恋人》だ。", "It's the Lovers."));
4009
4010                 if (get_aim_dir(caster_ptr, &dir))
4011                 {
4012                         charm_monster(caster_ptr, dir, MIN(caster_ptr->lev, 20));
4013                 }
4014
4015                 return;
4016         }
4017         
4018         if (die < 101)
4019         {
4020                 msg_print(_("《隠者》だ。", "It's the Hermit."));
4021                 wall_stone(caster_ptr);
4022                 return;
4023         }
4024         
4025         if (die < 111)
4026         {
4027                 msg_print(_("《審判》だ。", "It's the Judgement."));
4028                 roll_hitdice(caster_ptr, 0L);
4029                 lose_all_mutations(caster_ptr);
4030                 return;
4031         }
4032         
4033         if (die < 120)
4034         {
4035                 msg_print(_("《太陽》だ。", "It's the Sun."));
4036                 chg_virtue(caster_ptr, V_KNOWLEDGE, 1);
4037                 chg_virtue(caster_ptr, V_ENLIGHTEN, 1);
4038                 wiz_lite(caster_ptr, FALSE);
4039                 return;
4040         }
4041         
4042         msg_print(_("《世界》だ。", "It's the World."));
4043         if (caster_ptr->exp >= PY_MAX_EXP)
4044         {
4045                 return;
4046         }
4047
4048         s32b ee = (caster_ptr->exp / 25) + 1;
4049         if (ee > 5000) ee = 5000;
4050         msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4051         gain_exp(caster_ptr, ee);
4052 }
4053
4054 /*!
4055  * @brief 口を使う継続的な処理を中断する
4056  * @param caster_ptr プレーヤーへの参照ポインタ
4057  * @return なし
4058  */
4059 void stop_mouth(player_type *caster_ptr)
4060 {
4061         if (music_singing_any(caster_ptr)) stop_singing(caster_ptr);
4062         if (hex_spelling_any(caster_ptr)) stop_hex_spell_all(caster_ptr);
4063 }
4064
4065
4066 bool_hack vampirism(player_type *caster_ptr)
4067 {
4068         if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_NO_MELEE)
4069         {
4070                 msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking."));
4071                 return FALSE;
4072         }
4073
4074         /* Only works on adjacent monsters */
4075         DIRECTION dir;
4076         if (!get_direction(caster_ptr, &dir, FALSE, FALSE)) return FALSE;
4077
4078         POSITION y = caster_ptr->y + ddy[dir];
4079         POSITION x = caster_ptr->x + ddx[dir];
4080         grid_type *g_ptr;
4081         g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
4082
4083         stop_mouth(caster_ptr);
4084
4085         if (!(g_ptr->m_idx))
4086         {
4087                 msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
4088                 return FALSE;
4089         }
4090
4091         msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs..."));
4092
4093         int dummy = caster_ptr->lev * 2;
4094         if (!hypodynamic_bolt(caster_ptr, dir, dummy))
4095         {
4096                 msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul."));
4097                 return TRUE;
4098         }
4099
4100         if (caster_ptr->food < PY_FOOD_FULL)
4101                 (void)hp_player(caster_ptr, dummy);
4102         else
4103                 msg_print(_("あなたは空腹ではありません。", "You were not hungry."));
4104
4105         /* Gain nutritional sustenance: 150/hp drained */
4106         /* A Food ration gives 5000 food points (by contrast) */
4107         /* Don't ever get more than "Full" this way */
4108         /* But if we ARE Gorged,  it won't cure us */
4109         dummy = caster_ptr->food + MIN(5000, 100 * dummy);
4110         if (caster_ptr->food < PY_FOOD_MAX)   /* Not gorged already */
4111                 (void)set_food(caster_ptr, dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
4112         return TRUE;
4113 }
4114
4115
4116 /*!
4117 * ヒット&アウェイのレイシャルパワー/突然変異
4118 * @param caster_ptr プレーヤーへの参照ポインタ
4119 * @return コマンドの入力先にモンスターがいたらTRUE
4120 */
4121 bool hit_and_away(player_type *caster_ptr)
4122 {
4123         DIRECTION dir;
4124         if (!get_direction(caster_ptr, &dir, FALSE, FALSE)) return FALSE;
4125         POSITION y = caster_ptr->y + ddy[dir];
4126         POSITION x = caster_ptr->x + ddx[dir];
4127         if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
4128         {
4129                 py_attack(caster_ptr, y, x, 0);
4130                 if (randint0(caster_ptr->skill_dis) < 7)
4131                         msg_print(_("うまく逃げられなかった。", "You failed to run away."));
4132                 else
4133                         teleport_player(caster_ptr, 30, 0L);
4134                 return TRUE;
4135         }
4136         
4137         msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
4138         msg_print(NULL);
4139         return FALSE;
4140 }
4141
4142
4143 /*!
4144 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
4145 * @param caster_ptr プレーヤーへの参照ポインタ
4146 * @return なし
4147 * @note
4148 * currently this function allows pseudo-id of any object,
4149 * including silly ones like potions & scrolls, which always
4150 * get '{average}'. This should be changed, either to stop such
4151 * items from being pseudo-id'd, or to allow psychometry to
4152 * detect whether the unidentified potion/scroll/etc is
4153 * good (Cure Light Wounds, Restore Strength, etc) or
4154 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
4155 */
4156 bool psychometry(player_type *caster_ptr)
4157 {
4158         concptr q = _("どのアイテムを調べますか?", "Meditate on which item? ");
4159         concptr s = _("調べるアイテムがありません。", "You have nothing appropriate.");
4160         object_type *o_ptr;
4161         OBJECT_IDX item;
4162         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
4163         if (!o_ptr) return FALSE;
4164
4165         if (object_is_known(o_ptr))
4166         {
4167                 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
4168                 return TRUE;
4169         }
4170
4171         /* Check for a feeling */
4172         byte feel = value_check_aux1(o_ptr);
4173
4174         /* Get an object description */
4175         GAME_TEXT o_name[MAX_NLEN];
4176         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4177
4178         /* Skip non-feelings */
4179         if (!feel)
4180         {
4181                 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
4182                 return TRUE;
4183         }
4184
4185 #ifdef JP
4186         msg_format("%sは%sという感じがする...", o_name, game_inscriptions[feel]);
4187 #else
4188         msg_format("You feel that the %s %s %s...",
4189                 o_name, ((o_ptr->number == 1) ? "is" : "are"), game_inscriptions[feel]);
4190 #endif
4191
4192         o_ptr->ident |= (IDENT_SENSE);
4193         o_ptr->feeling = feel;
4194         o_ptr->marked |= OM_TOUCHED;
4195
4196         caster_ptr->update |= (PU_COMBINE | PU_REORDER);
4197         caster_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4198
4199         bool okay = FALSE;
4200         switch (o_ptr->tval)
4201         {
4202         case TV_SHOT:
4203         case TV_ARROW:
4204         case TV_BOLT:
4205         case TV_BOW:
4206         case TV_DIGGING:
4207         case TV_HAFTED:
4208         case TV_POLEARM:
4209         case TV_SWORD:
4210         case TV_BOOTS:
4211         case TV_GLOVES:
4212         case TV_HELM:
4213         case TV_CROWN:
4214         case TV_SHIELD:
4215         case TV_CLOAK:
4216         case TV_SOFT_ARMOR:
4217         case TV_HARD_ARMOR:
4218         case TV_DRAG_ARMOR:
4219         case TV_CARD:
4220         case TV_RING:
4221         case TV_AMULET:
4222         case TV_LITE:
4223         case TV_FIGURINE:
4224                 okay = TRUE;
4225                 break;
4226         }
4227
4228         /* Auto-inscription/destroy */
4229         autopick_alter_item(caster_ptr, item, (bool)(okay && destroy_feeling));
4230
4231         return TRUE;
4232 }
4233
4234
4235 bool draconian_breath(player_type *creature_ptr)
4236 {
4237         int Type = (one_in_(3) ? GF_COLD : GF_FIRE);
4238         concptr Type_desc = ((Type == GF_COLD) ? _("冷気", "cold") : _("炎", "fire"));
4239
4240         DIRECTION dir;
4241         if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
4242
4243         if (randint1(100) < creature_ptr->lev)
4244         {
4245                 switch (creature_ptr->pclass)
4246                 {
4247                 case CLASS_WARRIOR:
4248                 case CLASS_BERSERKER:
4249                 case CLASS_RANGER:
4250                 case CLASS_TOURIST:
4251                 case CLASS_IMITATOR:
4252                 case CLASS_ARCHER:
4253                 case CLASS_SMITH:
4254                         if (one_in_(3))
4255                         {
4256                                 Type = GF_MISSILE;
4257                                 Type_desc = _("エレメント", "the elements");
4258                         }
4259                         else
4260                         {
4261                                 Type = GF_SHARDS;
4262                                 Type_desc = _("破片", "shards");
4263                         }
4264
4265                         break;
4266                 case CLASS_MAGE:
4267                 case CLASS_WARRIOR_MAGE:
4268                 case CLASS_HIGH_MAGE:
4269                 case CLASS_SORCERER:
4270                 case CLASS_MAGIC_EATER:
4271                 case CLASS_RED_MAGE:
4272                 case CLASS_BLUE_MAGE:
4273                 case CLASS_MIRROR_MASTER:
4274                         if (one_in_(3))
4275                         {
4276                                 Type = GF_MANA;
4277                                 Type_desc = _("魔力", "mana");
4278                         }
4279                         else
4280                         {
4281                                 Type = GF_DISENCHANT;
4282                                 Type_desc = _("劣化", "disenchantment");
4283                         }
4284
4285                         break;
4286                 case CLASS_CHAOS_WARRIOR:
4287                         if (!one_in_(3))
4288                         {
4289                                 Type = GF_CONFUSION;
4290                                 Type_desc = _("混乱", "confusion");
4291                         }
4292                         else
4293                         {
4294                                 Type = GF_CHAOS;
4295                                 Type_desc = _("カオス", "chaos");
4296                         }
4297
4298                         break;
4299                 case CLASS_MONK:
4300                 case CLASS_SAMURAI:
4301                 case CLASS_FORCETRAINER:
4302                         if (!one_in_(3))
4303                         {
4304                                 Type = GF_CONFUSION;
4305                                 Type_desc = _("混乱", "confusion");
4306                         }
4307                         else
4308                         {
4309                                 Type = GF_SOUND;
4310                                 Type_desc = _("轟音", "sound");
4311                         }
4312
4313                         break;
4314                 case CLASS_MINDCRAFTER:
4315                         if (!one_in_(3))
4316                         {
4317                                 Type = GF_CONFUSION;
4318                                 Type_desc = _("混乱", "confusion");
4319                         }
4320                         else
4321                         {
4322                                 Type = GF_PSI;
4323                                 Type_desc = _("精神エネルギー", "mental energy");
4324                         }
4325
4326                         break;
4327                 case CLASS_PRIEST:
4328                 case CLASS_PALADIN:
4329                         if (one_in_(3))
4330                         {
4331                                 Type = GF_HELL_FIRE;
4332                                 Type_desc = _("地獄の劫火", "hellfire");
4333                         }
4334                         else
4335                         {
4336                                 Type = GF_HOLY_FIRE;
4337                                 Type_desc = _("聖なる炎", "holy fire");
4338                         }
4339
4340                         break;
4341                 case CLASS_ROGUE:
4342                 case CLASS_NINJA:
4343                         if (one_in_(3))
4344                         {
4345                                 Type = GF_DARK;
4346                                 Type_desc = _("暗黒", "darkness");
4347                         }
4348                         else
4349                         {
4350                                 Type = GF_POIS;
4351                                 Type_desc = _("毒", "poison");
4352                         }
4353
4354                         break;
4355                 case CLASS_BARD:
4356                         if (!one_in_(3))
4357                         {
4358                                 Type = GF_SOUND;
4359                                 Type_desc = _("轟音", "sound");
4360                         }
4361                         else
4362                         {
4363                                 Type = GF_CONFUSION;
4364                                 Type_desc = _("混乱", "confusion");
4365                         }
4366
4367                         break;
4368                 }
4369         }
4370
4371         stop_mouth(creature_ptr);
4372         msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."), Type_desc);
4373
4374         fire_breath(creature_ptr, Type, dir, creature_ptr->lev * 2, (creature_ptr->lev / 15) + 1);
4375         return TRUE;
4376 }
4377
4378
4379 bool android_inside_weapon(player_type *creature_ptr)
4380 {
4381         DIRECTION dir;
4382         if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
4383
4384         if (creature_ptr->lev < 10)
4385         {
4386                 msg_print(_("レイガンを発射した。", "You fire your ray gun."));
4387                 fire_bolt(creature_ptr, GF_MISSILE, dir, (creature_ptr->lev + 1) / 2);
4388                 return TRUE;
4389         }
4390
4391         if (creature_ptr->lev < 25)
4392         {
4393                 msg_print(_("ブラスターを発射した。", "You fire your blaster."));
4394                 fire_bolt(creature_ptr, GF_MISSILE, dir, creature_ptr->lev);
4395                 return TRUE;
4396         }
4397
4398         if (creature_ptr->lev < 35)
4399         {
4400                 msg_print(_("バズーカを発射した。", "You fire your bazooka."));
4401                 fire_ball(creature_ptr, GF_MISSILE, dir, creature_ptr->lev * 2, 2);
4402                 return TRUE;
4403         }
4404
4405         if (creature_ptr->lev < 45)
4406         {
4407                 msg_print(_("ビームキャノンを発射した。", "You fire a beam cannon."));
4408                 fire_beam(creature_ptr, GF_MISSILE, dir, creature_ptr->lev * 2);
4409                 return TRUE;
4410         }
4411
4412         msg_print(_("ロケットを発射した。", "You fire a rocket."));
4413         fire_rocket(creature_ptr, GF_ROCKET, dir, creature_ptr->lev * 5, 2);
4414         return TRUE;
4415 }
4416
4417
4418 bool create_ration(player_type *creature_ptr)
4419 {
4420         object_type *q_ptr;
4421         object_type forge;
4422         q_ptr = &forge;
4423
4424         /* Create the food ration */
4425         object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION));
4426
4427         /* Drop the object from heaven */
4428         (void)drop_near(creature_ptr, q_ptr, -1, creature_ptr->y, creature_ptr->x);
4429         msg_print(_("食事を料理して作った。", "You cook some food."));
4430         return TRUE;
4431 }
4432
4433
4434 void hayagake(player_type *creature_ptr)
4435 {
4436         if (creature_ptr->action == ACTION_HAYAGAKE)
4437         {
4438                 set_action(creature_ptr, ACTION_NONE);
4439                 creature_ptr->energy_use = 0;
4440                 return;
4441         }
4442         
4443         grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
4444         feature_type *f_ptr = &f_info[g_ptr->feat];
4445
4446         if (!have_flag(f_ptr->flags, FF_PROJECT) ||
4447                 (!creature_ptr->levitation && have_flag(f_ptr->flags, FF_DEEP)))
4448         {
4449                 msg_print(_("ここでは素早く動けない。", "You cannot run in here."));
4450         }
4451         else
4452         {
4453                 set_action(creature_ptr, ACTION_HAYAGAKE);
4454         }
4455
4456         creature_ptr->energy_use = 0;
4457 }
4458
4459
4460 bool double_attack(player_type *creature_ptr)
4461 {
4462         DIRECTION dir;
4463         if (!get_rep_dir(creature_ptr, &dir, FALSE)) return FALSE;
4464         POSITION y = creature_ptr->y + ddy[dir];
4465         POSITION x = creature_ptr->x + ddx[dir];
4466         if (!creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
4467         {
4468                 msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
4469                 msg_print(NULL);
4470                 return TRUE;
4471         }
4472         
4473         if (one_in_(3))
4474                 msg_print(_("あーたたたたたたたたたたたたたたたたたたたたたた!!!",
4475                         "Ahhhtatatatatatatatatatatatatatataatatatatattaaaaa!!!!"));
4476         else if (one_in_(2))
4477                 msg_print(_("無駄無駄無駄無駄無駄無駄無駄無駄無駄無駄無駄無駄!!!",
4478                         "Mudamudamudamudamudamudamudamudamudamudamudamudamuda!!!!"));
4479         else
4480                 msg_print(_("オラオラオラオラオラオラオラオラオラオラオラオラ!!!",
4481                         "Oraoraoraoraoraoraoraoraoraoraoraoraoraoraoraoraora!!!!"));
4482
4483         py_attack(creature_ptr, y, x, 0);
4484         if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
4485         {
4486                 handle_stuff(creature_ptr);
4487                 py_attack(creature_ptr, y, x, 0);
4488         }
4489
4490         creature_ptr->energy_need += ENERGY_NEED();
4491         return TRUE;
4492 }
4493
4494
4495 bool comvert_hp_to_mp(player_type *creature_ptr)
4496 {
4497         int gain_sp = take_hit(creature_ptr, DAMAGE_USELIFE, creature_ptr->lev, _("HPからMPへの無謀な変換", "thoughtless convertion from HP to SP"), -1) / 5;
4498         if (!gain_sp)
4499         {
4500                 msg_print(_("変換に失敗した。", "You failed to convert."));
4501                 creature_ptr->redraw |= (PR_HP | PR_MANA);
4502                 return TRUE;
4503         }
4504         
4505         creature_ptr->csp += gain_sp;
4506         if (creature_ptr->csp > creature_ptr->msp)
4507         {
4508                 creature_ptr->csp = creature_ptr->msp;
4509                 creature_ptr->csp_frac = 0;
4510         }
4511
4512         creature_ptr->redraw |= (PR_HP | PR_MANA);
4513         return TRUE;
4514 }
4515
4516
4517 bool comvert_mp_to_hp(player_type *creature_ptr)
4518 {
4519         if (creature_ptr->csp >= creature_ptr->lev / 5)
4520         {
4521                 creature_ptr->csp -= creature_ptr->lev / 5;
4522                 hp_player(creature_ptr, creature_ptr->lev);
4523         }
4524         else
4525         {
4526                 msg_print(_("変換に失敗した。", "You failed to convert."));
4527         }
4528
4529         creature_ptr->redraw |= (PR_HP | PR_MANA);
4530         return TRUE;
4531 }
4532
4533
4534 bool demonic_breath(player_type *creature_ptr)
4535 {
4536         DIRECTION dir;
4537         int type = (one_in_(2) ? GF_NETHER : GF_FIRE);
4538         if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
4539         stop_mouth(creature_ptr);
4540         msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."), ((type == GF_NETHER) ? _("地獄", "nether") : _("火炎", "fire")));
4541         fire_breath(creature_ptr, type, dir, creature_ptr->lev * 3, (creature_ptr->lev / 15) + 1);
4542         return TRUE;
4543 }
4544
4545
4546 /*!
4547  * 静水
4548  * @param creature_ptr プレーヤーへの参照ポインタ
4549  * @return ペットを操っている場合を除きTRUE
4550 */
4551 bool mirror_concentration(player_type *creature_ptr)
4552 {
4553         if (total_friends)
4554         {
4555                 msg_print(_("今はペットを操ることに集中していないと。", "You need concentration on the pets now."));
4556                 return FALSE;
4557         }
4558
4559         if (!is_mirror_grid(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x]))
4560         {
4561                 msg_print(_("鏡の上でないと集中できない!", "Here are not any mirrors!"));
4562                 return TRUE;
4563         }
4564
4565         msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
4566
4567         creature_ptr->csp += (5 + creature_ptr->lev * creature_ptr->lev / 100);
4568         if (creature_ptr->csp >= creature_ptr->msp)
4569         {
4570                 creature_ptr->csp = creature_ptr->msp;
4571                 creature_ptr->csp_frac = 0;
4572         }
4573
4574         creature_ptr->redraw |= PR_MANA;
4575         return TRUE;
4576 }
4577
4578
4579 /*!
4580  * 剣の舞い
4581  * @param creature_ptr プレーヤーへの参照ポインタ
4582  * @return 常にTRUE
4583 */
4584 bool sword_dancing(player_type *creature_ptr)
4585 {
4586         DIRECTION dir;
4587         POSITION y = 0, x = 0;
4588         grid_type *g_ptr;
4589         for (int i = 0; i < 6; i++)
4590         {
4591                 dir = randint0(8);
4592                 y = creature_ptr->y + ddy_ddd[dir];
4593                 x = creature_ptr->x + ddx_ddd[dir];
4594                 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
4595
4596                 /* Hack -- attack monsters */
4597                 if (g_ptr->m_idx)
4598                         py_attack(creature_ptr, y, x, 0);
4599                 else
4600                 {
4601                         msg_print(_("攻撃が空をきった。", "You attack the empty air."));
4602                 }
4603         }
4604
4605         return TRUE;
4606 }
4607
4608
4609 /*!
4610  * 幻惑の光
4611  * @param creature_ptr プレーヤーへの参照ポインタ
4612  * @return 常にTRUE
4613 */
4614 bool confusing_light(player_type *creature_ptr)
4615 {
4616         msg_print(_("辺りを睨んだ...", "You glare nearby monsters..."));
4617         slow_monsters(creature_ptr, creature_ptr->lev);
4618         stun_monsters(creature_ptr, creature_ptr->lev * 4);
4619         confuse_monsters(creature_ptr, creature_ptr->lev * 4);
4620         turn_monsters(creature_ptr, creature_ptr->lev * 4);
4621         stasis_monsters(creature_ptr, creature_ptr->lev * 4);
4622         return TRUE;
4623 }
4624
4625
4626 /*!
4627  * 荒馬慣らし
4628  * @param creature_ptr プレーヤーへの参照ポインタ
4629  * @return 結果はどうあれ騎乗したらTRUE
4630 */
4631 bool rodeo(player_type *creature_ptr)
4632 {
4633         GAME_TEXT m_name[MAX_NLEN];
4634         monster_type *m_ptr;
4635         monster_race *r_ptr;
4636         int rlev;
4637
4638         if (creature_ptr->riding)
4639         {
4640                 msg_print(_("今は乗馬中だ。", "You ARE riding."));
4641                 return FALSE;
4642         }
4643
4644         if (!do_cmd_riding(creature_ptr, TRUE)) return TRUE;
4645
4646         m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
4647         r_ptr = &r_info[m_ptr->r_idx];
4648         monster_desc(m_name, m_ptr, 0);
4649         msg_format(_("%sに乗った。", "You ride on %s."), m_name);
4650
4651         if (is_pet(m_ptr)) return TRUE;
4652
4653         rlev = r_ptr->level;
4654
4655         if (r_ptr->flags1 & RF1_UNIQUE) rlev = rlev * 3 / 2;
4656         if (rlev > 60) rlev = 60 + (rlev - 60) / 2;
4657         if ((randint1(creature_ptr->skill_exp[GINOU_RIDING] / 120 + creature_ptr->lev * 2 / 3) > rlev)
4658                 && one_in_(2) && !creature_ptr->current_floor_ptr->inside_arena && !creature_ptr->phase_out
4659                 && !(r_ptr->flags7 & (RF7_GUARDIAN)) && !(r_ptr->flags1 & (RF1_QUESTOR))
4660                 && (rlev < creature_ptr->lev * 3 / 2 + randint0(creature_ptr->lev / 5)))
4661         {
4662                 msg_format(_("%sを手なずけた。", "You tame %s."), m_name);
4663                 set_pet(m_ptr);
4664         }
4665         else
4666         {
4667                 msg_format(_("%sに振り落とされた!", "You have been thrown off by %s."), m_name);
4668                 rakuba(creature_ptr, 1, TRUE);
4669                 /* 落馬処理に失敗してもとにかく乗馬解除 */
4670                 creature_ptr->riding = 0;
4671         }
4672
4673         return TRUE;
4674 }
4675
4676
4677 bool clear_mind(player_type *creature_ptr)
4678 {
4679         if (total_friends)
4680         {
4681                 msg_print(_("今はペットを操ることに集中していないと。", "You need concentration on the pets now."));
4682                 return FALSE;
4683         }
4684
4685         msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
4686
4687         creature_ptr->csp += (3 + creature_ptr->lev / 20);
4688         if (creature_ptr->csp >= creature_ptr->msp)
4689         {
4690                 creature_ptr->csp = creature_ptr->msp;
4691                 creature_ptr->csp_frac = 0;
4692         }
4693
4694         creature_ptr->redraw |= (PR_MANA);
4695         return TRUE;
4696 }
4697
4698
4699 bool concentration(player_type *creature_ptr)
4700 {
4701         int max_csp = MAX(creature_ptr->msp * 4, creature_ptr->lev * 5 + 5);
4702
4703         if (total_friends)
4704         {
4705                 msg_print(_("今はペットを操ることに集中していないと。", "You need concentration on the pets now."));
4706                 return FALSE;
4707         }
4708
4709         if (creature_ptr->special_defense & KATA_MASK)
4710         {
4711                 msg_print(_("今は構えに集中している。", "You need concentration on your form."));
4712                 return FALSE;
4713         }
4714
4715         msg_print(_("精神を集中して気合いを溜めた。", "You concentrate to charge your power."));
4716
4717         creature_ptr->csp += creature_ptr->msp / 2;
4718         if (creature_ptr->csp >= max_csp)
4719         {
4720                 creature_ptr->csp = max_csp;
4721                 creature_ptr->csp_frac = 0;
4722         }
4723
4724         creature_ptr->redraw |= PR_MANA;
4725         return TRUE;
4726 }