OSDN Git Service

[Refactor] #37353 player-class.c/h を作成して player_magic 構造体と関連変数を移動.
[hengband/hengband.git] / src / spells3.c
1 /*!
2  * @file spells3.c
3  * @brief 魔法効果の実装/ Spell code (part 3)
4  * @date 2014/07/26
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 "bldg.h"
16 #include "util.h"
17
18 #include "dungeon.h"
19 #include "floor.h"
20 #include "object-boost.h"
21 #include "object-flavor.h"
22 #include "object-hook.h"
23 #include "melee.h"
24 #include "player-move.h"
25 #include "player-status.h"
26 #include "player-class.h"
27 #include "spells-summon.h"
28 #include "quest.h"
29 #include "artifact.h"
30 #include "avatar.h"
31 #include "spells.h"
32 #include "spells-floor.h"
33 #include "grid.h"
34 #include "monster-process.h"
35 #include "monster-status.h"
36 #include "monster-spell.h"
37 #include "cmd-spell.h"
38 #include "snipe.h"
39 #include "floor-save.h"
40 #include "files.h"
41 #include "player-effects.h"
42 #include "player-skill.h"
43 #include "view-mainwindow.h"
44 #include "mind.h"
45 #include "wild.h"
46 #include "world.h"
47
48
49 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
50 #define MAX_TRIES 100
51
52
53 /*!
54  * @brief モンスターのテレポートアウェイ処理 /
55  * Teleport a monster, normally up to "dis" grids away.
56  * @param m_idx モンスターID
57  * @param dis テレポート距離
58  * @param mode オプション
59  * @return テレポートが実際に行われたらtrue
60  * @details
61  * Attempt to move the monster at least "dis/2" grids away.
62  * But allow variation to prevent infinite loops.
63  */
64 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
65 {
66         POSITION oy, ox, d, i, min;
67         int tries = 0;
68         POSITION ny = 0, nx = 0;
69
70         bool look = TRUE;
71
72         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
73         if (!monster_is_valid(m_ptr)) return (FALSE);
74
75         oy = m_ptr->fy;
76         ox = m_ptr->fx;
77
78         /* Minimum distance */
79         min = dis / 2;
80
81         if ((mode & TELEPORT_DEC_VALOUR) &&
82             (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
83                 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
84         {
85                 chg_virtue(V_VALOUR, -1);
86         }
87
88         /* Look until done */
89         while (look)
90         {
91                 tries++;
92
93                 /* Verify max distance */
94                 if (dis > 200) dis = 200;
95
96                 /* Try several locations */
97                 for (i = 0; i < 500; i++)
98                 {
99                         /* Pick a (possibly illegal) location */
100                         while (1)
101                         {
102                                 ny = rand_spread(oy, dis);
103                                 nx = rand_spread(ox, dis);
104                                 d = distance(oy, ox, ny, nx);
105                                 if ((d >= min) && (d <= dis)) break;
106                         }
107
108                         /* Ignore illegal locations */
109                         if (!in_bounds(ny, nx)) continue;
110
111                         if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
112
113                         /* No teleporting into vaults and such */
114                         if (!(p_ptr->inside_quest || p_ptr->inside_arena))
115                                 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
116
117                         /* This grid looks good */
118                         look = FALSE;
119
120                         /* Stop looking */
121                         break;
122                 }
123
124                 /* Increase the maximum distance */
125                 dis = dis * 2;
126
127                 /* Decrease the minimum distance */
128                 min = min / 2;
129
130                 /* Stop after MAX_TRIES tries */
131                 if (tries > MAX_TRIES) return (FALSE);
132         }
133
134         sound(SOUND_TPOTHER);
135
136         /* Update the old location */
137         current_floor_ptr->grid_array[oy][ox].m_idx = 0;
138
139         /* Update the new location */
140         current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
141
142         /* Move the monster */
143         m_ptr->fy = ny;
144         m_ptr->fx = nx;
145
146         /* Forget the counter target */
147         reset_target(m_ptr);
148
149         update_monster(m_idx, TRUE);
150         lite_spot(oy, ox);
151         lite_spot(ny, nx);
152
153         if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
154                 p_ptr->update |= (PU_MON_LITE);
155
156         return (TRUE);
157 }
158
159
160 /*!
161  * @brief モンスターを指定された座標付近にテレポートする /
162  * Teleport monster next to a grid near the given location
163  * @param m_idx モンスターID
164  * @param ty 目安Y座標
165  * @param tx 目安X座標
166  * @param power テレポート成功確率
167  * @param mode オプション
168  * @return なし
169  */
170 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
171 {
172         POSITION ny, nx, oy, ox;
173         int d, i, min;
174         int attempts = 500;
175         POSITION dis = 2;
176         bool look = TRUE;
177         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
178         if(!m_ptr->r_idx) return;
179
180         /* "Skill" test */
181         if(randint1(100) > power) return;
182
183         ny = m_ptr->fy;
184         nx = m_ptr->fx;
185         oy = m_ptr->fy;
186         ox = m_ptr->fx;
187
188         /* Minimum distance */
189         min = dis / 2;
190
191         /* Look until done */
192         while (look && --attempts)
193         {
194                 /* Verify max distance */
195                 if (dis > 200) dis = 200;
196
197                 /* Try several locations */
198                 for (i = 0; i < 500; i++)
199                 {
200                         /* Pick a (possibly illegal) location */
201                         while (1)
202                         {
203                                 ny = rand_spread(ty, dis);
204                                 nx = rand_spread(tx, dis);
205                                 d = distance(ty, tx, ny, nx);
206                                 if ((d >= min) && (d <= dis)) break;
207                         }
208
209                         /* Ignore illegal locations */
210                         if (!in_bounds(ny, nx)) continue;
211
212                         if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
213
214                         /* No teleporting into vaults and such */
215                         /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
216
217                         /* This grid looks good */
218                         look = FALSE;
219
220                         /* Stop looking */
221                         break;
222                 }
223
224                 /* Increase the maximum distance */
225                 dis = dis * 2;
226
227                 /* Decrease the minimum distance */
228                 min = min / 2;
229         }
230
231         if (attempts < 1) return;
232
233         sound(SOUND_TPOTHER);
234
235         /* Update the old location */
236         current_floor_ptr->grid_array[oy][ox].m_idx = 0;
237
238         /* Update the new location */
239         current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
240
241         /* Move the monster */
242         m_ptr->fy = ny;
243         m_ptr->fx = nx;
244
245         update_monster(m_idx, TRUE);
246         lite_spot(oy, ox);
247         lite_spot(ny, nx);
248
249         if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
250                 p_ptr->update |= (PU_MON_LITE);
251 }
252
253 /*!
254  * @brief プレイヤーのテレポート先選定と移動処理 /
255  * Teleport the player to a location up to "dis" grids away.
256  * @param dis 基本移動距離
257  * @param mode オプション
258  * @return 実際にテレポート処理が行われたらtrue
259  * @details
260  * <pre>
261  * If no such spaces are readily available, the distance may increase.
262  * Try very hard to move the player at least a quarter that distance.
263  *
264  * There was a nasty tendency for a long time; which was causing the
265  * player to "bounce" between two or three different spots because
266  * these are the only spots that are "far enough" way to satisfy the
267  * algorithm.
268  *
269  * But this tendency is now removed; in the new algorithm, a list of
270  * candidates is selected first, which includes at least 50% of all
271  * floor grids within the distance, and any single grid in this list
272  * of candidates has equal possibility to be choosen as a destination.
273  * </pre>
274  */
275
276 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
277 {
278         int candidates_at[MAX_TELEPORT_DISTANCE + 1];
279         int total_candidates, cur_candidates;
280         POSITION y = 0, x = 0;
281         int min, pick, i;
282
283         int left = MAX(1, p_ptr->x - dis);
284         int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
285         int top = MAX(1, p_ptr->y - dis);
286         int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
287
288         if (p_ptr->wild_mode) return FALSE;
289
290         if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
291         {
292                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
293                 return FALSE;
294         }
295
296         /* Initialize counters */
297         total_candidates = 0;
298         for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
299                 candidates_at[i] = 0;
300
301         /* Limit the distance */
302         if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
303
304         /* Search valid locations */
305         for (y = top; y <= bottom; y++)
306         {
307                 for (x = left; x <= right; x++)
308                 {
309                         int d;
310
311                         /* Skip illegal locations */
312                         if (!cave_player_teleportable_bold(y, x, mode)) continue;
313
314                         /* Calculate distance */
315                         d = distance(p_ptr->y, p_ptr->x, y, x);
316
317                         /* Skip too far locations */
318                         if (d > dis) continue;
319
320                         /* Count the total number of candidates */
321                         total_candidates++;
322
323                         /* Count the number of candidates in this circumference */
324                         candidates_at[d]++;
325                 }
326         }
327
328         /* No valid location! */
329         if (0 == total_candidates) return FALSE;
330
331         /* Fix the minimum distance */
332         for (cur_candidates = 0, min = dis; min >= 0; min--)
333         {
334                 cur_candidates += candidates_at[min];
335
336                 /* 50% of all candidates will have an equal chance to be choosen. */
337                 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
338         }
339
340         /* Pick up a single location randomly */
341         pick = randint1(cur_candidates);
342
343         /* Search again the choosen location */
344         for (y = top; y <= bottom; y++)
345         {
346                 for (x = left; x <= right; x++)
347                 {
348                         int d;
349
350                         /* Skip illegal locations */
351                         if (!cave_player_teleportable_bold(y, x, mode)) continue;
352
353                         /* Calculate distance */
354                         d = distance(p_ptr->y, p_ptr->x, y, x);
355
356                         /* Skip too far locations */
357                         if (d > dis) continue;
358
359                         /* Skip too close locations */
360                         if (d < min) continue;
361
362                         /* This grid was picked up? */
363                         pick--;
364                         if (!pick) break;
365                 }
366
367                 /* Exit the loop */
368                 if (!pick) break;
369         }
370
371         if (player_bold(y, x)) return FALSE;
372
373         sound(SOUND_TELEPORT);
374
375 #ifdef JP
376         if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
377                 msg_format("『こっちだぁ、%s』", p_ptr->name);
378 #endif
379
380         (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
381         return TRUE;
382 }
383
384 /*!
385  * @brief プレイヤーのテレポート処理メインルーチン
386  * @param dis 基本移動距離
387  * @param mode オプション
388  * @return なし
389  */
390 void teleport_player(POSITION dis, BIT_FLAGS mode)
391 {
392         POSITION yy, xx;
393         POSITION oy = p_ptr->y;
394         POSITION ox = p_ptr->x;
395
396         if (!teleport_player_aux(dis, mode)) return;
397
398         /* Monsters with teleport ability may follow the player */
399         for (xx = -1; xx < 2; xx++)
400         {
401                 for (yy = -1; yy < 2; yy++)
402                 {
403                         MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
404
405                         /* A monster except your mount may follow */
406                         if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
407                         {
408                                 monster_type *m_ptr = &current_floor_ptr->m_list[tmp_m_idx];
409                                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
410
411                                 /*
412                                  * The latter limitation is to avoid
413                                  * totally unkillable suckers...
414                                  */
415                                 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
416                                     !(r_ptr->flagsr & RFR_RES_TELE))
417                                 {
418                                         if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
419                                 }
420                         }
421                 }
422         }
423 }
424
425
426 /*!
427  * @brief プレイヤーのテレポートアウェイ処理 /
428  * @param m_idx アウェイを試みたプレイヤーID
429  * @param dis テレポート距離
430  * @return なし
431  */
432 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
433 {
434         POSITION yy, xx;
435         POSITION oy = p_ptr->y;
436         POSITION ox = p_ptr->x;
437
438         if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
439
440         /* Monsters with teleport ability may follow the player */
441         for (xx = -1; xx < 2; xx++)
442         {
443                 for (yy = -1; yy < 2; yy++)
444                 {
445                         MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
446
447                         /* A monster except your mount or caster may follow */
448                         if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
449                         {
450                                 monster_type *m_ptr = &current_floor_ptr->m_list[tmp_m_idx];
451                                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
452
453                                 /*
454                                  * The latter limitation is to avoid
455                                  * totally unkillable suckers...
456                                  */
457                                 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
458                                     !(r_ptr->flagsr & RFR_RES_TELE))
459                                 {
460                                         if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
461                                 }
462                         }
463                 }
464         }
465 }
466
467
468 /*!
469  * @brief プレイヤーを指定位置近辺にテレポートさせる
470  * Teleport player to a grid near the given location
471  * @param ny 目標Y座標
472  * @param nx 目標X座標
473  * @param mode オプションフラグ
474  * @return なし
475  * @details
476  * <pre>
477  * This function is slightly obsessive about correctness.
478  * This function allows teleporting into vaults (!)
479  * </pre>
480  */
481 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
482 {
483         POSITION y, x;
484         POSITION dis = 0, ctr = 0;
485
486         if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
487         {
488                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
489                 return;
490         }
491
492         /* Find a usable location */
493         while (1)
494         {
495                 /* Pick a nearby legal location */
496                 while (1)
497                 {
498                         y = (POSITION)rand_spread(ny, dis);
499                         x = (POSITION)rand_spread(nx, dis);
500                         if (in_bounds(y, x)) break;
501                 }
502
503                 /* Accept any grid when wizard mode */
504                 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!current_floor_ptr->grid_array[y][x].m_idx || (current_floor_ptr->grid_array[y][x].m_idx == p_ptr->riding))) break;
505
506                 /* Accept teleportable floor grids */
507                 if (cave_player_teleportable_bold(y, x, mode)) break;
508
509                 /* Occasionally advance the distance */
510                 if (++ctr > (4 * dis * dis + 4 * dis + 1))
511                 {
512                         ctr = 0;
513                         dis++;
514                 }
515         }
516
517         sound(SOUND_TELEPORT);
518         (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
519 }
520
521
522 void teleport_away_followable(MONSTER_IDX m_idx)
523 {
524         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
525         POSITION oldfy = m_ptr->fy;
526         POSITION oldfx = m_ptr->fx;
527         bool old_ml = m_ptr->ml;
528         POSITION old_cdis = m_ptr->cdis;
529
530         teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
531
532         if (old_ml && (old_cdis <= MAX_SIGHT) && !current_world_ptr->timewalk_m_idx && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
533         {
534                 bool follow = FALSE;
535
536                 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
537                 else
538                 {
539                         BIT_FLAGS flgs[TR_FLAG_SIZE];
540                         object_type *o_ptr;
541                         INVENTORY_IDX i;
542
543                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
544                         {
545                                 o_ptr = &p_ptr->inventory_list[i];
546                                 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
547                                 {
548                                         object_flags(o_ptr, flgs);
549                                         if (have_flag(flgs, TR_TELEPORT))
550                                         {
551                                                 follow = TRUE;
552                                                 break;
553                                         }
554                                 }
555                         }
556                 }
557
558                 if (follow)
559                 {
560                         if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
561                         {
562                                 if (one_in_(3))
563                                 {
564                                         teleport_player(200, TELEPORT_PASSIVE);
565                                         msg_print(_("失敗!", "Failed!"));
566                                 }
567                                 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
568                                 p_ptr->energy_need += ENERGY_NEED();
569                         }
570                 }
571         }
572 }
573
574
575 bool teleport_level_other(player_type *creature_ptr)
576 {
577         MONSTER_IDX target_m_idx;
578         monster_type *m_ptr;
579         monster_race *r_ptr;
580         GAME_TEXT m_name[MAX_NLEN];
581
582         if (!target_set(TARGET_KILL)) return FALSE;
583         target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
584         if (!target_m_idx) return TRUE;
585         if (!player_has_los_bold(target_row, target_col)) return TRUE;
586         if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
587         m_ptr = &current_floor_ptr->m_list[target_m_idx];
588         r_ptr = &r_info[m_ptr->r_idx];
589         monster_desc(m_name, m_ptr, 0);
590         msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
591
592         if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
593                 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
594         {
595                 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
596         }
597         else teleport_level(target_m_idx);
598         return TRUE;
599 }
600
601 /*!
602  * @brief プレイヤー及びモンスターをレベルテレポートさせる /
603  * Teleport the player one level up or down (random when legal)
604  * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
605  * @return なし
606  */
607 void teleport_level(MONSTER_IDX m_idx)
608 {
609         bool         go_up;
610         GAME_TEXT m_name[160];
611         bool         see_m = TRUE;
612
613         if (m_idx <= 0) /* To player */
614         {
615                 strcpy(m_name, _("あなた", "you"));
616         }
617         else /* To monster */
618         {
619                 monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
620
621                 /* Get the monster name (or "it") */
622                 monster_desc(m_name, m_ptr, 0);
623
624                 see_m = is_seen(m_ptr);
625         }
626
627         /* No effect in some case */
628         if (TELE_LEVEL_IS_INEFF(m_idx))
629         {
630                 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
631                 return;
632         }
633
634         if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
635         {
636                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
637                 return;
638         }
639
640         /* Choose up or down */
641         if (randint0(100) < 50) go_up = TRUE;
642         else go_up = FALSE;
643
644         if ((m_idx <= 0) && p_ptr->wizard)
645         {
646                 if (get_check("Force to go up? ")) go_up = TRUE;
647                 else if (get_check("Force to go down? ")) go_up = FALSE;
648         }
649
650         /* Down only */ 
651         if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
652         {
653 #ifdef JP
654                 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
655 #else
656                 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
657 #endif
658                 if (m_idx <= 0) /* To player */
659                 {
660                         if (!current_floor_ptr->dun_level)
661                         {
662                                 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
663                                 p_ptr->oldpy = p_ptr->y;
664                                 p_ptr->oldpx = p_ptr->x;
665                         }
666
667                         if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
668
669                         if (autosave_l) do_cmd_save_game(TRUE);
670
671                         if (!current_floor_ptr->dun_level)
672                         {
673                                 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
674                                 prepare_change_floor_mode(CFM_RAND_PLACE);
675                         }
676                         else
677                         {
678                                 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
679                         }
680                         p_ptr->leaving = TRUE;
681                 }
682         }
683
684         /* Up only */
685         else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
686         {
687 #ifdef JP
688                 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
689 #else
690                 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
691 #endif
692
693
694                 if (m_idx <= 0) /* To player */
695                 {
696                         if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
697
698                         if (autosave_l) do_cmd_save_game(TRUE);
699
700                         prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
701
702                         leave_quest_check();
703                         p_ptr->inside_quest = 0;
704                         p_ptr->leaving = TRUE;
705                 }
706         }
707         else if (go_up)
708         {
709 #ifdef JP
710                 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
711 #else
712                 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
713 #endif
714
715
716                 if (m_idx <= 0) /* To player */
717                 {
718                         if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
719
720                         if (autosave_l) do_cmd_save_game(TRUE);
721
722                         prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
723                         p_ptr->leaving = TRUE;
724                 }
725         }
726         else
727         {
728 #ifdef JP
729                 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
730 #else
731                 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
732 #endif
733
734                 if (m_idx <= 0) /* To player */
735                 {
736                         /* Never reach this code on the surface */
737                         /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
738                         if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
739                         if (autosave_l) do_cmd_save_game(TRUE);
740
741                         prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
742                         p_ptr->leaving = TRUE;
743                 }
744         }
745
746         /* Monster level teleportation is simple deleting now */
747         if (m_idx > 0)
748         {
749                 monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
750
751                 check_quest_completion(m_ptr);
752
753                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
754                 {
755                         char m2_name[MAX_NLEN];
756
757                         monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
758                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
759                 }
760
761                 delete_monster_idx(m_idx);
762         }
763
764         sound(SOUND_TPLEVEL);
765 }
766
767
768 /*!
769  * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
770  * @param note ダンジョンに施す処理記述
771  * @param y コンソールY座標
772  * @param x コンソールX座標
773  * @return 選択されたダンジョンID
774  */
775 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
776 {
777         DUNGEON_IDX select_dungeon;
778         DUNGEON_IDX i;
779         int num = 0;
780         DUNGEON_IDX *dun;
781
782         /* Hack -- No need to choose dungeon in some case */
783         if (lite_town || vanilla_town || ironman_downward)
784         {
785                 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
786                 else
787                 {
788                         msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
789                         msg_print(NULL);
790                         return 0;
791                 }
792         }
793
794         /* Allocate the "dun" array */
795         C_MAKE(dun, max_d_idx, DUNGEON_IDX);
796
797         screen_save();
798         for(i = 1; i < max_d_idx; i++)
799         {
800                 char buf[80];
801                 bool seiha = FALSE;
802
803                 if (!d_info[i].maxdepth) continue;
804                 if (!max_dlv[i]) continue;
805                 if (d_info[i].final_guardian)
806                 {
807                         if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
808                 }
809                 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
810
811                 sprintf(buf,_("      %c) %c%-12s : 最大 %d 階", "      %c) %c%-16s : Max level %d"), 
812                                         'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
813                 prt(buf, y + num, x);
814                 dun[num++] = i;
815         }
816
817         if (!num)
818         {
819                 prt(_("      選べるダンジョンがない。", "      No dungeon is available."), y, x);
820         }
821
822         prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
823         while(1)
824         {
825                 i = inkey();
826                 if ((i == ESCAPE) || !num)
827                 {
828                         /* Free the "dun" array */
829                         C_KILL(dun, max_d_idx, DUNGEON_IDX);
830
831                         screen_load();
832                         return 0;
833                 }
834                 if (i >= 'a' && i <('a'+num))
835                 {
836                         select_dungeon = dun[i-'a'];
837                         break;
838                 }
839                 else bell();
840         }
841         screen_load();
842
843         /* Free the "dun" array */
844         C_KILL(dun, max_d_idx, DUNGEON_IDX);
845
846         return select_dungeon;
847 }
848
849
850 /*!
851  * @brief プレイヤーの帰還発動及び中止処理 /
852  * Recall the player to town or dungeon
853  * @param turns 発動までのターン数
854  * @return 常にTRUEを返す
855  */
856 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
857 {
858         /*
859          * TODO: Recall the player to the last
860          * visited town when in the wilderness
861          */
862
863         /* Ironman option */
864         if (creature_ptr->inside_arena || ironman_downward)
865         {
866                 msg_print(_("何も起こらなかった。", "Nothing happens."));
867                 return TRUE;
868         }
869
870         if (current_floor_ptr->dun_level && (max_dlv[p_ptr->dungeon_idx] > current_floor_ptr->dun_level) && !creature_ptr->inside_quest && !creature_ptr->word_recall)
871         {
872                 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
873                 {
874                         max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
875                         if (record_maxdepth)
876                                 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
877                 }
878
879         }
880         if (!creature_ptr->word_recall)
881         {
882                 if (!current_floor_ptr->dun_level)
883                 {
884                         DUNGEON_IDX select_dungeon;
885                         select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
886                         if (!select_dungeon) return FALSE;
887                         creature_ptr->recall_dungeon = select_dungeon;
888                 }
889                 creature_ptr->word_recall = turns;
890                 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
891                 creature_ptr->redraw |= (PR_STATUS);
892         }
893         else
894         {
895                 creature_ptr->word_recall = 0;
896                 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
897                 creature_ptr->redraw |= (PR_STATUS);
898         }
899         return TRUE;
900 }
901
902 bool free_level_recall(player_type *creature_ptr)
903 {
904         DUNGEON_IDX select_dungeon;
905         DEPTH max_depth;
906         QUANTITY amt;
907
908         select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
909
910         if (!select_dungeon) return FALSE;
911
912         max_depth = d_info[select_dungeon].maxdepth;
913
914         /* Limit depth in Angband */
915         if (select_dungeon == DUNGEON_ANGBAND)
916         {
917                 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
918                 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
919         }
920         amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
921                 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
922
923         if (amt > 0)
924         {
925                 creature_ptr->word_recall = 1;
926                 creature_ptr->recall_dungeon = select_dungeon;
927                 max_dlv[creature_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
928                 if (record_maxdepth)
929                         do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
930
931                 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
932
933                 creature_ptr->redraw |= (PR_STATUS);
934                 return TRUE;
935         }
936         return FALSE;
937 }
938
939
940 /*!
941  * @brief フロア・リセット処理
942  * @return リセット処理が実際に行われたらTRUEを返す
943  */
944 bool reset_recall(void)
945 {
946         int select_dungeon, dummy = 0;
947         char ppp[80];
948         char tmp_val[160];
949
950         select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
951
952         /* Ironman option */
953         if (ironman_downward)
954         {
955                 msg_print(_("何も起こらなかった。", "Nothing happens."));
956                 return TRUE;
957         }
958
959         if (!select_dungeon) return FALSE;
960         /* Prompt */
961         sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
962                 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
963
964         /* Default */
965         sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
966
967         /* Ask for a level */
968         if (get_string(ppp, tmp_val, 10))
969         {
970                 /* Extract request */
971                 dummy = atoi(tmp_val);
972                 if (dummy < 1) dummy = 1;
973                 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
974                 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
975
976                 max_dlv[select_dungeon] = dummy;
977
978                 if (record_maxdepth)
979                         do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
980                                         /* Accept request */
981 #ifdef JP
982                 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
983 #else
984                 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
985 #endif
986
987         }
988         else
989         {
990                 return FALSE;
991         }
992         return TRUE;
993 }
994
995
996 /*!
997  * @brief プレイヤーの装備劣化処理 /
998  * Apply disenchantment to the player's stuff
999  * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1000  * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1001  * Return "TRUE" if the player notices anything
1002  */
1003 bool apply_disenchant(BIT_FLAGS mode)
1004 {
1005         int             t = 0;
1006         object_type *o_ptr;
1007         GAME_TEXT o_name[MAX_NLEN];
1008         int to_h, to_d, to_a, pval;
1009
1010         /* Pick a random slot */
1011         switch (randint1(8))
1012         {
1013                 case 1: t = INVEN_RARM; break;
1014                 case 2: t = INVEN_LARM; break;
1015                 case 3: t = INVEN_BOW; break;
1016                 case 4: t = INVEN_BODY; break;
1017                 case 5: t = INVEN_OUTER; break;
1018                 case 6: t = INVEN_HEAD; break;
1019                 case 7: t = INVEN_HANDS; break;
1020                 case 8: t = INVEN_FEET; break;
1021         }
1022
1023         o_ptr = &p_ptr->inventory_list[t];
1024
1025         /* No item, nothing happens */
1026         if (!o_ptr->k_idx) return (FALSE);
1027
1028         /* Disenchant equipments only -- No disenchant on monster ball */
1029         if (!object_is_weapon_armour_ammo(o_ptr))
1030                 return FALSE;
1031
1032         /* Nothing to disenchant */
1033         if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1034         {
1035                 /* Nothing to notice */
1036                 return (FALSE);
1037         }
1038
1039         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1040
1041         /* Artifacts have 71% chance to resist */
1042         if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1043         {
1044 #ifdef JP
1045                 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1046 #else
1047                 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1048                         ((o_ptr->number != 1) ? "" : "s"));
1049 #endif
1050                 return (TRUE);
1051         }
1052
1053
1054         /* Memorize old value */
1055         to_h = o_ptr->to_h;
1056         to_d = o_ptr->to_d;
1057         to_a = o_ptr->to_a;
1058         pval = o_ptr->pval;
1059
1060         /* Disenchant tohit */
1061         if (o_ptr->to_h > 0) o_ptr->to_h--;
1062         if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1063
1064         /* Disenchant todam */
1065         if (o_ptr->to_d > 0) o_ptr->to_d--;
1066         if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1067
1068         /* Disenchant toac */
1069         if (o_ptr->to_a > 0) o_ptr->to_a--;
1070         if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1071
1072         /* Disenchant pval (occasionally) */
1073         /* Unless called from wild_magic() */
1074         if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1075
1076         if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1077             (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1078         {
1079 #ifdef JP
1080                 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1081 #else
1082                 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1083                         ((o_ptr->number != 1) ? "were" : "was"));
1084 #endif
1085
1086                 chg_virtue(V_HARMONY, 1);
1087                 chg_virtue(V_ENCHANT, -2);
1088                 p_ptr->update |= (PU_BONUS);
1089                 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1090
1091                 calc_android_exp();
1092         }
1093
1094         return (TRUE);
1095 }
1096
1097
1098 /*!
1099  * @brief 武器へのエゴ付加処理 /
1100  * Brand the current weapon
1101  * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1102  * @return なし
1103  */
1104 void brand_weapon(int brand_type)
1105 {
1106         OBJECT_IDX item;
1107         object_type *o_ptr;
1108         concptr q, s;
1109
1110         /* Assume enchant weapon */
1111         item_tester_hook = object_allow_enchant_melee_weapon;
1112
1113         q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1114         s = _("強化できる武器がない。", "You have nothing to enchant.");
1115
1116         o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1117         if (!o_ptr) return;
1118
1119         /* you can never modify artifacts / ego-items */
1120         /* you can never modify cursed items */
1121         /* TY: You _can_ modify broken items (if you're silly enough) */
1122         if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1123             !object_is_cursed(o_ptr) &&
1124             !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1125             !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1126             !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1127         {
1128                 concptr act = NULL;
1129
1130                 /* Let's get the name before it is changed... */
1131                 GAME_TEXT o_name[MAX_NLEN];
1132                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1133
1134                 switch (brand_type)
1135                 {
1136                 case 17:
1137                         if (o_ptr->tval == TV_SWORD)
1138                         {
1139                                 act = _("は鋭さを増した!", "becomes very sharp!");
1140
1141                                 o_ptr->name2 = EGO_SHARPNESS;
1142                                 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1143
1144                                 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1145                                         o_ptr->pval = 2;
1146                         }
1147                         else
1148                         {
1149                                 act = _("は破壊力を増した!", "seems very powerful.");
1150                                 o_ptr->name2 = EGO_EARTHQUAKES;
1151                                 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1152                         }
1153                         break;
1154                 case 16:
1155                         act = _("は人間の血を求めている!", "seems to be looking for humans!");
1156                         o_ptr->name2 = EGO_KILL_HUMAN;
1157                         break;
1158                 case 15:
1159                         act = _("は電撃に覆われた!", "covered with lightning!");
1160                         o_ptr->name2 = EGO_BRAND_ELEC;
1161                         break;
1162                 case 14:
1163                         act = _("は酸に覆われた!", "coated with acid!");
1164                         o_ptr->name2 = EGO_BRAND_ACID;
1165                         break;
1166                 case 13:
1167                         act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1168                         o_ptr->name2 = EGO_KILL_EVIL;
1169                         break;
1170                 case 12:
1171                         act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1172                         o_ptr->name2 = EGO_KILL_DEMON;
1173                         break;
1174                 case 11:
1175                         act = _("は屍を求めている!", "seems to be looking for undead!");
1176                         o_ptr->name2 = EGO_KILL_UNDEAD;
1177                         break;
1178                 case 10:
1179                         act = _("は動物の血を求めている!", "seems to be looking for animals!");
1180                         o_ptr->name2 = EGO_KILL_ANIMAL;
1181                         break;
1182                 case 9:
1183                         act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1184                         o_ptr->name2 = EGO_KILL_DRAGON;
1185                         break;
1186                 case 8:
1187                         act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1188                         o_ptr->name2 = EGO_KILL_TROLL;
1189                         break;
1190                 case 7:
1191                         act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1192                         o_ptr->name2 = EGO_KILL_ORC;
1193                         break;
1194                 case 6:
1195                         act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1196                         o_ptr->name2 = EGO_KILL_GIANT;
1197                         break;
1198                 case 5:
1199                         act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1200                         o_ptr->name2 = EGO_TRUMP;
1201                         o_ptr->pval = randint1(2);
1202                         break;
1203                 case 4:
1204                         act = _("は血を求めている!", "thirsts for blood!");
1205                         o_ptr->name2 = EGO_VAMPIRIC;
1206                         break;
1207                 case 3:
1208                         act = _("は毒に覆われた。", "is coated with poison.");
1209                         o_ptr->name2 = EGO_BRAND_POIS;
1210                         break;
1211                 case 2:
1212                         act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1213                         o_ptr->name2 = EGO_CHAOTIC;
1214                         break;
1215                 case 1:
1216                         act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1217                         o_ptr->name2 = EGO_BRAND_FIRE;
1218                         break;
1219                 default:
1220                         act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1221                         o_ptr->name2 = EGO_BRAND_COLD;
1222                         break;
1223                 }
1224
1225                 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1226                 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1227
1228                 o_ptr->discount = 99;
1229                 chg_virtue(V_ENCHANT, 2);
1230         }
1231         else
1232         {
1233                 if (flush_failure) flush();
1234
1235                 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1236                 chg_virtue(V_ENCHANT, -2);
1237         }
1238         calc_android_exp();
1239 }
1240
1241
1242 /*!
1243  * @brief 虚無招来によるフロア中の全壁除去処理 /
1244  * Vanish all walls in this floor
1245  * @return 実際に処理が反映された場合TRUE
1246  */
1247 static bool vanish_dungeon(void)
1248 {
1249         POSITION y, x;
1250         grid_type *g_ptr;
1251         feature_type *f_ptr;
1252         monster_type *m_ptr;
1253         GAME_TEXT m_name[MAX_NLEN];
1254
1255         /* Prevent vasishing of quest levels and town */
1256         if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1257         {
1258                 return FALSE;
1259         }
1260
1261         /* Scan all normal grids */
1262         for (y = 1; y < current_floor_ptr->height - 1; y++)
1263         {
1264                 for (x = 1; x < current_floor_ptr->width - 1; x++)
1265                 {
1266                         g_ptr = &current_floor_ptr->grid_array[y][x];
1267
1268                         /* Seeing true feature code (ignore mimic) */
1269                         f_ptr = &f_info[g_ptr->feat];
1270
1271                         /* Lose room and vault */
1272                         g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1273
1274                         m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
1275
1276                         /* Awake monster */
1277                         if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1278                         {
1279                                 (void)set_monster_csleep(g_ptr->m_idx, 0);
1280
1281                                 /* Notice the "waking up" */
1282                                 if (m_ptr->ml)
1283                                 {
1284                                         monster_desc(m_name, m_ptr, 0);
1285                                         msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1286                                 }
1287                         }
1288
1289                         /* Process all walls, doors and patterns */
1290                         if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1291                 }
1292         }
1293
1294         /* Special boundary walls -- Top and bottom */
1295         for (x = 0; x < current_floor_ptr->width; x++)
1296         {
1297                 g_ptr = &current_floor_ptr->grid_array[0][x];
1298                 f_ptr = &f_info[g_ptr->mimic];
1299
1300                 /* Lose room and vault */
1301                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1302
1303                 /* Set boundary mimic if needed */
1304                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1305                 {
1306                         g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1307
1308                         /* Check for change to boring grid */
1309                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1310                 }
1311
1312                 g_ptr = &current_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1313                 f_ptr = &f_info[g_ptr->mimic];
1314
1315                 /* Lose room and vault */
1316                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1317
1318                 /* Set boundary mimic if needed */
1319                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1320                 {
1321                         g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1322
1323                         /* Check for change to boring grid */
1324                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1325                 }
1326         }
1327
1328         /* Special boundary walls -- Left and right */
1329         for (y = 1; y < (current_floor_ptr->height - 1); y++)
1330         {
1331                 g_ptr = &current_floor_ptr->grid_array[y][0];
1332                 f_ptr = &f_info[g_ptr->mimic];
1333
1334                 /* Lose room and vault */
1335                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1336
1337                 /* Set boundary mimic if needed */
1338                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1339                 {
1340                         g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1341
1342                         /* Check for change to boring grid */
1343                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1344                 }
1345
1346                 g_ptr = &current_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1347                 f_ptr = &f_info[g_ptr->mimic];
1348
1349                 /* Lose room and vault */
1350                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1351
1352                 /* Set boundary mimic if needed */
1353                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1354                 {
1355                         g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1356
1357                         /* Check for change to boring grid */
1358                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1359                 }
1360         }
1361
1362         /* Mega-Hack -- Forget the view and lite */
1363         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1364         p_ptr->redraw |= (PR_MAP);
1365         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1366
1367         return TRUE;
1368 }
1369
1370 /*!
1371  * @brief 虚無招来処理 /
1372  * @return なし
1373  */
1374 void call_the_(void)
1375 {
1376         int i;
1377         grid_type *g_ptr;
1378         bool do_call = TRUE;
1379
1380         for (i = 0; i < 9; i++)
1381         {
1382                 g_ptr = &current_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1383
1384                 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1385                 {
1386                         if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1387                             !permanent_wall(&f_info[g_ptr->feat]))
1388                         {
1389                                 do_call = FALSE;
1390                                 break;
1391                         }
1392                 }
1393         }
1394
1395         if (do_call)
1396         {
1397                 for (i = 1; i < 10; i++)
1398                 {
1399                         if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1400                 }
1401
1402                 for (i = 1; i < 10; i++)
1403                 {
1404                         if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1405                 }
1406
1407                 for (i = 1; i < 10; i++)
1408                 {
1409                         if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1410                 }
1411         }
1412
1413         /* Prevent destruction of quest levels and town */
1414         else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1415         {
1416                 msg_print(_("地面が揺れた。", "The ground trembles."));
1417         }
1418
1419         else
1420         {
1421 #ifdef JP
1422                 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1423                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1424 #else
1425                 msg_format("You %s the %s too close to a wall!",
1426                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1427                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1428 #endif
1429                 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1430
1431                 if (one_in_(666))
1432                 {
1433                         if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1434                 }
1435                 else
1436                 {
1437                         if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1438                                 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1439                         else
1440                                 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1441                 }
1442
1443                 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1444         }
1445 }
1446
1447
1448 /*!
1449  * @brief アイテム引き寄せ処理 /
1450  * Fetch an item (teleport it right underneath the caster)
1451  * @param dir 魔法の発動方向
1452  * @param wgt 許容重量
1453  * @param require_los 射線の通りを要求するならばTRUE
1454  * @return なし
1455  */
1456 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1457 {
1458         POSITION ty, tx;
1459         OBJECT_IDX i;
1460         grid_type *g_ptr;
1461         object_type *o_ptr;
1462         GAME_TEXT o_name[MAX_NLEN];
1463
1464         /* Check to see if an object is already there */
1465         if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1466         {
1467                 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1468                 return;
1469         }
1470
1471         /* Use a target */
1472         if (dir == 5 && target_okay())
1473         {
1474                 tx = target_col;
1475                 ty = target_row;
1476
1477                 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1478                 {
1479                         msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1480                         return;
1481                 }
1482
1483                 g_ptr = &current_floor_ptr->grid_array[ty][tx];
1484
1485                 /* We need an item to fetch */
1486                 if (!g_ptr->o_idx)
1487                 {
1488                         msg_print(_("そこには何もありません。", "There is no object at this place."));
1489                         return;
1490                 }
1491
1492                 /* No fetching from vault */
1493                 if (g_ptr->info & CAVE_ICKY)
1494                 {
1495                         msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1496                         return;
1497                 }
1498
1499                 /* We need to see the item */
1500                 if (require_los)
1501                 {
1502                         if (!player_has_los_bold(ty, tx))
1503                         {
1504                                 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1505                                 return;
1506                         }
1507                         else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1508                         {
1509                                 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1510                                 return;
1511                         }
1512                 }
1513         }
1514         else
1515         {
1516                 ty = p_ptr->y; 
1517                 tx = p_ptr->x;
1518                 do
1519                 {
1520                         ty += ddy[dir];
1521                         tx += ddx[dir];
1522                         g_ptr = &current_floor_ptr->grid_array[ty][tx];
1523
1524                         if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1525                                 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1526                 }
1527                 while (!g_ptr->o_idx);
1528         }
1529
1530         o_ptr = &current_floor_ptr->o_list[g_ptr->o_idx];
1531
1532         if (o_ptr->weight > wgt)
1533         {
1534                 /* Too heavy to 'fetch' */
1535                 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1536                 return;
1537         }
1538
1539         i = g_ptr->o_idx;
1540         g_ptr->o_idx = o_ptr->next_o_idx;
1541         current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1542
1543         o_ptr->next_o_idx = 0;
1544         o_ptr->iy = p_ptr->y;
1545         o_ptr->ix = p_ptr->x;
1546
1547         object_desc(o_name, o_ptr, OD_NAME_ONLY);
1548         msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1549
1550         note_spot(p_ptr->y, p_ptr->x);
1551         p_ptr->redraw |= PR_MAP;
1552 }
1553
1554 /*!
1555  * @brief 現実変容処理
1556  * @return なし
1557  */
1558 void alter_reality(void)
1559 {
1560         /* Ironman option */
1561         if (p_ptr->inside_arena || ironman_downward)
1562         {
1563                 msg_print(_("何も起こらなかった。", "Nothing happens."));
1564                 return;
1565         }
1566
1567         if (!p_ptr->alter_reality)
1568         {
1569                 TIME_EFFECT turns = randint0(21) + 15;
1570
1571                 p_ptr->alter_reality = turns;
1572                 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1573
1574                 p_ptr->redraw |= (PR_STATUS);
1575         }
1576         else
1577         {
1578                 p_ptr->alter_reality = 0;
1579                 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1580                 p_ptr->redraw |= (PR_STATUS);
1581         }
1582         return;
1583 }
1584
1585 /*!
1586  * @brief 全所持アイテム鑑定処理 /
1587  * Identify everything being carried.
1588  * Done by a potion of "self knowledge".
1589  * @return なし
1590  */
1591 void identify_pack(void)
1592 {
1593         INVENTORY_IDX i;
1594
1595         /* Simply identify and know every item */
1596         for (i = 0; i < INVEN_TOTAL; i++)
1597         {
1598                 object_type *o_ptr = &p_ptr->inventory_list[i];
1599                 if (!o_ptr->k_idx) continue;
1600
1601                 identify_item(o_ptr);
1602
1603                 /* Auto-inscription */
1604                 autopick_alter_item(i, FALSE);
1605         }
1606 }
1607
1608
1609 /*!
1610  * @brief 装備強化処理の失敗率定数(千分率) /
1611  * Used by the "enchant" function (chance of failure)
1612  * (modified for Zangband, we need better stuff there...) -- TY
1613  * @return なし
1614  */
1615 static int enchant_table[16] =
1616 {
1617         0, 10,  50, 100, 200,
1618         300, 400, 500, 650, 800,
1619         950, 987, 993, 995, 998,
1620         1000
1621 };
1622
1623
1624 /*!
1625  * @brief 装備の解呪処理 /
1626  * Removes curses from items in p_ptr->inventory_list
1627  * @param all 軽い呪いまでの解除ならば0
1628  * @return 解呪されたアイテムの数
1629  * @details
1630  * <pre>
1631  * Note that Items which are "Perma-Cursed" (The One Ring,
1632  * The Crown of Morgoth) can NEVER be uncursed.
1633  *
1634  * Note that if "all" is FALSE, then Items which are
1635  * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1636  * will not be uncursed.
1637  * </pre>
1638  */
1639 static int remove_curse_aux(int all)
1640 {
1641         int i, cnt = 0;
1642
1643         /* Attempt to uncurse items being worn */
1644         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1645         {
1646                 object_type *o_ptr = &p_ptr->inventory_list[i];
1647                 if (!o_ptr->k_idx) continue;
1648
1649                 /* Uncursed already */
1650                 if (!object_is_cursed(o_ptr)) continue;
1651
1652                 /* Heavily Cursed Items need a special spell */
1653                 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1654
1655                 /* Perma-Cursed Items can NEVER be uncursed */
1656                 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1657                 {
1658                         o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1659                         continue;
1660                 }
1661
1662                 o_ptr->curse_flags = 0L;
1663                 o_ptr->ident |= (IDENT_SENSE);
1664                 o_ptr->feeling = FEEL_NONE;
1665
1666                 p_ptr->update |= (PU_BONUS);
1667                 p_ptr->window |= (PW_EQUIP);
1668
1669                 /* Count the uncursings */
1670                 cnt++;
1671         }
1672
1673         if (cnt)
1674         {
1675                 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1676         }
1677         /* Return "something uncursed" */
1678         return (cnt);
1679 }
1680
1681
1682 /*!
1683  * @brief 装備の軽い呪い解呪処理 /
1684  * Remove most curses
1685  * @return 解呪に成功した装備数
1686  */
1687 int remove_curse(void)
1688 {
1689         return (remove_curse_aux(FALSE));
1690 }
1691
1692 /*!
1693  * @brief 装備の重い呪い解呪処理 /
1694  * Remove all curses
1695  * @return 解呪に成功した装備数
1696  */
1697 int remove_all_curse(void)
1698 {
1699         return (remove_curse_aux(TRUE));
1700 }
1701
1702
1703 /*!
1704  * @brief アイテムの価値に応じた錬金術処理 /
1705  * Turns an object into gold, gain some of its value in a shop
1706  * @return 処理が実際に行われたらTRUEを返す
1707  */
1708 bool alchemy(void)
1709 {
1710         OBJECT_IDX item;
1711         int amt = 1;
1712         ITEM_NUMBER old_number;
1713         PRICE price;
1714         bool force = FALSE;
1715         object_type *o_ptr;
1716         GAME_TEXT o_name[MAX_NLEN];
1717         char out_val[MAX_NLEN+40];
1718
1719         concptr q, s;
1720
1721         /* Hack -- force destruction */
1722         if (command_arg > 0) force = TRUE;
1723
1724         q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1725         s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1726
1727         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1728         if (!o_ptr) return (FALSE);
1729
1730         /* See how many items */
1731         if (o_ptr->number > 1)
1732         {
1733                 amt = get_quantity(NULL, o_ptr->number);
1734
1735                 /* Allow user abort */
1736                 if (amt <= 0) return FALSE;
1737         }
1738
1739         old_number = o_ptr->number;
1740         o_ptr->number = amt;
1741         object_desc(o_name, o_ptr, 0);
1742         o_ptr->number = old_number;
1743
1744         /* Verify unless quantity given */
1745         if (!force)
1746         {
1747                 if (confirm_destroy || (object_value(o_ptr) > 0))
1748                 {
1749                         /* Make a verification */
1750                         sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1751                         if (!get_check(out_val)) return FALSE;
1752                 }
1753         }
1754
1755         /* Artifacts cannot be destroyed */
1756         if (!can_player_destroy_object(o_ptr))
1757         {
1758                 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1759
1760                 return FALSE;
1761         }
1762
1763         price = object_value_real(o_ptr);
1764
1765         if (price <= 0)
1766         {
1767                 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1768         }
1769         else
1770         {
1771                 price /= 3;
1772
1773                 if (amt > 1) price *= amt;
1774
1775                 if (price > 30000) price = 30000;
1776                 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1777
1778                 p_ptr->au += price;
1779                 p_ptr->redraw |= (PR_GOLD);
1780                 p_ptr->window |= (PW_PLAYER);
1781         }
1782
1783         /* Eliminate the item (from the pack) */
1784         if (item >= 0)
1785         {
1786                 inven_item_increase(item, -amt);
1787                 inven_item_describe(item);
1788                 inven_item_optimize(item);
1789         }
1790
1791         /* Eliminate the item (from the floor) */
1792         else
1793         {
1794                 floor_item_increase(0 - item, -amt);
1795                 floor_item_describe(0 - item);
1796                 floor_item_optimize(0 - item);
1797         }
1798
1799         return TRUE;
1800 }
1801
1802
1803 /*!
1804  * @brief 呪いの打ち破り処理 /
1805  * Break the curse of an item
1806  * @param o_ptr 呪い装備情報の参照ポインタ
1807  * @return なし
1808  */
1809 static void break_curse(object_type *o_ptr)
1810 {
1811         if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1812         {
1813                 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1814
1815                 o_ptr->curse_flags = 0L;
1816                 o_ptr->ident |= (IDENT_SENSE);
1817                 o_ptr->feeling = FEEL_NONE;
1818         }
1819 }
1820
1821
1822 /*!
1823  * @brief 装備修正強化処理 /
1824  * Enchants a plus onto an item. -RAK-
1825  * @param o_ptr 強化するアイテムの参照ポインタ
1826  * @param n 強化基本量
1827  * @param eflag 強化オプション(命中/ダメージ/AC)
1828  * @return 強化に成功した場合TRUEを返す
1829  * @details
1830  * <pre>
1831  * Revamped!  Now takes item pointer, number of times to try enchanting,
1832  * and a flag of what to try enchanting.  Artifacts resist enchantment
1833  * some of the time, and successful enchantment to at least +0 might
1834  * break a curse on the item. -CFT-
1835  *
1836  * Note that an item can technically be enchanted all the way to +15 if
1837  * you wait a very, very, long time.  Going from +9 to +10 only works
1838  * about 5% of the time, and from +10 to +11 only about 1% of the time.
1839  *
1840  * Note that this function can now be used on "piles" of items, and
1841  * the larger the pile, the lower the chance of success.
1842  * </pre>
1843  */
1844 bool enchant(object_type *o_ptr, int n, int eflag)
1845 {
1846         int     i, chance, prob;
1847         bool    res = FALSE;
1848         bool    a = object_is_artifact(o_ptr);
1849         bool    force = (eflag & ENCH_FORCE);
1850
1851         /* Large piles resist enchantment */
1852         prob = o_ptr->number * 100;
1853
1854         /* Missiles are easy to enchant */
1855         if ((o_ptr->tval == TV_BOLT) ||
1856             (o_ptr->tval == TV_ARROW) ||
1857             (o_ptr->tval == TV_SHOT))
1858         {
1859                 prob = prob / 20;
1860         }
1861
1862         /* Try "n" times */
1863         for (i = 0; i < n; i++)
1864         {
1865                 /* Hack -- Roll for pile resistance */
1866                 if (!force && randint0(prob) >= 100) continue;
1867
1868                 /* Enchant to hit */
1869                 if (eflag & ENCH_TOHIT)
1870                 {
1871                         if (o_ptr->to_h < 0) chance = 0;
1872                         else if (o_ptr->to_h > 15) chance = 1000;
1873                         else chance = enchant_table[o_ptr->to_h];
1874
1875                         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1876                         {
1877                                 o_ptr->to_h++;
1878                                 res = TRUE;
1879
1880                                 /* only when you get it above -1 -CFT */
1881                                 if (o_ptr->to_h >= 0)
1882                                         break_curse(o_ptr);
1883                         }
1884                 }
1885
1886                 /* Enchant to damage */
1887                 if (eflag & ENCH_TODAM)
1888                 {
1889                         if (o_ptr->to_d < 0) chance = 0;
1890                         else if (o_ptr->to_d > 15) chance = 1000;
1891                         else chance = enchant_table[o_ptr->to_d];
1892
1893                         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1894                         {
1895                                 o_ptr->to_d++;
1896                                 res = TRUE;
1897
1898                                 /* only when you get it above -1 -CFT */
1899                                 if (o_ptr->to_d >= 0)
1900                                         break_curse(o_ptr);
1901                         }
1902                 }
1903
1904                 /* Enchant to armor class */
1905                 if (eflag & ENCH_TOAC)
1906                 {
1907                         if (o_ptr->to_a < 0) chance = 0;
1908                         else if (o_ptr->to_a > 15) chance = 1000;
1909                         else chance = enchant_table[o_ptr->to_a];
1910
1911                         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1912                         {
1913                                 o_ptr->to_a++;
1914                                 res = TRUE;
1915
1916                                 /* only when you get it above -1 -CFT */
1917                                 if (o_ptr->to_a >= 0)
1918                                         break_curse(o_ptr);
1919                         }
1920                 }
1921         }
1922
1923         /* Failure */
1924         if (!res) return (FALSE);
1925         p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1926         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1927
1928         calc_android_exp();
1929
1930         /* Success */
1931         return (TRUE);
1932 }
1933
1934
1935 /*!
1936  * @brief 装備修正強化処理のメインルーチン /
1937  * Enchant an item (in the p_ptr->inventory_list or on the floor)
1938  * @param num_hit 命中修正量
1939  * @param num_dam ダメージ修正量
1940  * @param num_ac AC修正量
1941  * @return 強化に成功した場合TRUEを返す
1942  * @details
1943  * Note that "num_ac" requires armour, else weapon
1944  * Returns TRUE if attempted, FALSE if cancelled
1945  */
1946 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1947 {
1948         OBJECT_IDX item;
1949         bool        okay = FALSE;
1950         object_type *o_ptr;
1951         GAME_TEXT o_name[MAX_NLEN];
1952         concptr        q, s;
1953
1954         /* Assume enchant weapon */
1955         item_tester_hook = object_allow_enchant_weapon;
1956
1957         /* Enchant armor if requested */
1958         if (num_ac) item_tester_hook = object_is_armour;
1959
1960         q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1961         s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1962
1963         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1964         if (!o_ptr) return (FALSE);
1965
1966         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1967 #ifdef JP
1968         msg_format("%s は明るく輝いた!", o_name);
1969 #else
1970         msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1971 #endif
1972
1973         /* Enchant */
1974         if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1975         if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1976         if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1977
1978         /* Failure */
1979         if (!okay)
1980         {
1981                 if (flush_failure) flush();
1982                 msg_print(_("強化に失敗した。", "The enchantment failed."));
1983                 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1984         }
1985         else
1986                 chg_virtue(V_ENCHANT, 1);
1987
1988         calc_android_exp();
1989
1990         /* Something happened */
1991         return (TRUE);
1992 }
1993
1994
1995 /*!
1996  * @brief アーティファクト生成の巻物処理 /
1997  * @return 生成が実際に試みられたらTRUEを返す
1998  */
1999 bool artifact_scroll(void)
2000 {
2001         OBJECT_IDX item;
2002         bool okay = FALSE;
2003         object_type *o_ptr;
2004         GAME_TEXT o_name[MAX_NLEN];
2005         concptr q, s;
2006
2007         /* Enchant weapon/armour */
2008         item_tester_hook = item_tester_hook_nameless_weapon_armour;
2009
2010         q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2011         s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2012
2013         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2014         if (!o_ptr) return (FALSE);
2015
2016         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2017 #ifdef JP
2018         msg_format("%s は眩い光を発した!",o_name);
2019 #else
2020         msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2021 #endif
2022
2023         if (object_is_artifact(o_ptr))
2024         {
2025 #ifdef JP
2026                 msg_format("%sは既に伝説のアイテムです!", o_name  );
2027 #else
2028                 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2029 #endif
2030
2031                 okay = FALSE;
2032         }
2033
2034         else if (object_is_ego(o_ptr))
2035         {
2036 #ifdef JP
2037                 msg_format("%sは既に名のあるアイテムです!", o_name );
2038 #else
2039                 msg_format("The %s %s already %s!",
2040                     o_name, ((o_ptr->number > 1) ? "are" : "is"),
2041                     ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2042 #endif
2043
2044                 okay = FALSE;
2045         }
2046
2047         else if (o_ptr->xtra3)
2048         {
2049 #ifdef JP
2050                 msg_format("%sは既に強化されています!", o_name );
2051 #else
2052                 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2053                     ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2054 #endif
2055         }
2056
2057         else
2058         {
2059                 if (o_ptr->number > 1)
2060                 {
2061                         msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2062 #ifdef JP
2063                         msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2064 #else
2065                         msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2066 #endif
2067
2068                         if (item >= 0)
2069                         {
2070                                 inven_item_increase(item, 1 - (o_ptr->number));
2071                         }
2072                         else
2073                         {
2074                                 floor_item_increase(0 - item, 1 - (o_ptr->number));
2075                         }
2076                 }
2077                 okay = create_artifact(o_ptr, TRUE);
2078         }
2079
2080         /* Failure */
2081         if (!okay)
2082         {
2083                 if (flush_failure) flush();
2084                 msg_print(_("強化に失敗した。", "The enchantment failed."));
2085                 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2086         }
2087         else
2088         {
2089                 if (record_rand_art)
2090                 {
2091                         object_desc(o_name, o_ptr, OD_NAME_ONLY);
2092                         do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2093                 }
2094                 chg_virtue(V_ENCHANT, 1);
2095         }
2096
2097         calc_android_exp();
2098
2099         /* Something happened */
2100         return (TRUE);
2101 }
2102
2103
2104 /*!
2105  * @brief アイテム鑑定処理 /
2106  * Identify an object
2107  * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2108  * @return 実際に鑑定できたらTRUEを返す
2109  */
2110 bool identify_item(object_type *o_ptr)
2111 {
2112         bool old_known = FALSE;
2113         GAME_TEXT o_name[MAX_NLEN];
2114
2115         object_desc(o_name, o_ptr, 0);
2116
2117         if (o_ptr->ident & IDENT_KNOWN)
2118                 old_known = TRUE;
2119
2120         if (!(o_ptr->ident & (IDENT_MENTAL)))
2121         {
2122                 if (object_is_artifact(o_ptr) || one_in_(5))
2123                         chg_virtue(V_KNOWLEDGE, 1);
2124         }
2125
2126         object_aware(o_ptr);
2127         object_known(o_ptr);
2128         o_ptr->marked |= OM_TOUCHED;
2129
2130         p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2131         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2132
2133         strcpy(record_o_name, o_name);
2134         record_turn = current_world_ptr->game_turn;
2135
2136         object_desc(o_name, o_ptr, OD_NAME_ONLY);
2137
2138         if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2139                 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2140         if(record_rand_art && !old_known && o_ptr->art_name)
2141                 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2142
2143         return old_known;
2144 }
2145
2146 /*!
2147  * @brief アイテム鑑定のメインルーチン処理 /
2148  * Identify an object in the p_ptr->inventory_list (or on the floor)
2149  * @param only_equip 装備品のみを対象とするならばTRUEを返す
2150  * @return 実際に鑑定を行ったならばTRUEを返す
2151  * @details
2152  * This routine does *not* automatically combine objects.
2153  * Returns TRUE if something was identified, else FALSE.
2154  */
2155 bool ident_spell(bool only_equip)
2156 {
2157         OBJECT_IDX item;
2158         object_type *o_ptr;
2159         GAME_TEXT o_name[MAX_NLEN];
2160         concptr            q, s;
2161         bool old_known;
2162
2163         if (only_equip)
2164                 item_tester_hook = item_tester_hook_identify_weapon_armour;
2165         else
2166                 item_tester_hook = item_tester_hook_identify;
2167
2168         if (can_get_item())
2169         {
2170                 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2171         }
2172         else
2173         {
2174                 if (only_equip)
2175                         item_tester_hook = object_is_weapon_armour_ammo;
2176                 else
2177                         item_tester_hook = NULL;
2178
2179                 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2180         }
2181
2182         s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2183
2184         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2185         if (!o_ptr) return (FALSE);
2186
2187         old_known = identify_item(o_ptr);
2188
2189         object_desc(o_name, o_ptr, 0);
2190         if (item >= INVEN_RARM)
2191         {
2192                 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2193         }
2194         else if (item >= 0)
2195         {
2196                 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2197         }
2198         else
2199         {
2200                 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2201         }
2202
2203         /* Auto-inscription/destroy */
2204         autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2205
2206         /* Something happened */
2207         return (TRUE);
2208 }
2209
2210
2211 /*!
2212  * @brief アイテム凡庸化のメインルーチン処理 /
2213  * Identify an object in the p_ptr->inventory_list (or on the floor)
2214  * @param only_equip 装備品のみを対象とするならばTRUEを返す
2215  * @return 実際に凡庸化をを行ったならばTRUEを返す
2216  * @details
2217  * <pre>
2218  * Mundanify an object in the p_ptr->inventory_list (or on the floor)
2219  * This routine does *not* automatically combine objects.
2220  * Returns TRUE if something was mundanified, else FALSE.
2221  * </pre>
2222  */
2223 bool mundane_spell(bool only_equip)
2224 {
2225         OBJECT_IDX item;
2226         object_type *o_ptr;
2227         concptr q, s;
2228
2229         if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2230
2231         q = _("どれを使いますか?", "Use which item? ");
2232         s = _("使えるものがありません。", "You have nothing you can use.");
2233
2234         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2235         if (!o_ptr) return (FALSE);
2236
2237         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2238         {
2239                 POSITION iy = o_ptr->iy;                 /* Y-position on map, or zero */
2240                 POSITION ix = o_ptr->ix;                 /* X-position on map, or zero */
2241                 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2242                 byte marked = o_ptr->marked;         /* Object is marked */
2243                 WEIGHT weight = o_ptr->number * o_ptr->weight;
2244                 u16b inscription = o_ptr->inscription;
2245
2246                 /* Wipe it clean */
2247                 object_prep(o_ptr, o_ptr->k_idx);
2248
2249                 o_ptr->iy = iy;
2250                 o_ptr->ix = ix;
2251                 o_ptr->next_o_idx = next_o_idx;
2252                 o_ptr->marked = marked;
2253                 o_ptr->inscription = inscription;
2254                 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2255         }
2256         calc_android_exp();
2257
2258         /* Something happened */
2259         return TRUE;
2260 }
2261
2262 /*!
2263  * @brief アイテム*鑑定*のメインルーチン処理 /
2264  * Identify an object in the p_ptr->inventory_list (or on the floor)
2265  * @param only_equip 装備品のみを対象とするならばTRUEを返す
2266  * @return 実際に鑑定を行ったならばTRUEを返す
2267  * @details
2268  * Fully "identify" an object in the p_ptr->inventory_list  -BEN-
2269  * This routine returns TRUE if an item was identified.
2270  */
2271 bool identify_fully(bool only_equip)
2272 {
2273         OBJECT_IDX item;
2274         object_type *o_ptr;
2275         GAME_TEXT o_name[MAX_NLEN];
2276         concptr q, s;
2277         bool old_known;
2278
2279         if (only_equip)
2280                 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2281         else
2282                 item_tester_hook = item_tester_hook_identify_fully;
2283
2284         if (can_get_item())
2285         {
2286                 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2287         }
2288         else
2289         {
2290                 if (only_equip)
2291                         item_tester_hook = object_is_weapon_armour_ammo;
2292                 else
2293                         item_tester_hook = NULL;
2294
2295                 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2296         }
2297
2298         s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2299
2300         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2301         if (!o_ptr) return (FALSE);
2302
2303         old_known = identify_item(o_ptr);
2304
2305         /* Mark the item as fully known */
2306         o_ptr->ident |= (IDENT_MENTAL);
2307         handle_stuff();
2308
2309         object_desc(o_name, o_ptr, 0);
2310         if (item >= INVEN_RARM)
2311         {
2312                 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2313         }
2314         else if (item >= 0)
2315         {
2316                 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2317         }
2318         else
2319         {
2320                 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2321         }
2322
2323         /* Describe it fully */
2324         (void)screen_object(o_ptr, 0L);
2325
2326         /* Auto-inscription/destroy */
2327         autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2328
2329         /* Success */
2330         return (TRUE);
2331 }
2332
2333
2334
2335 /*!
2336  * @brief 魔力充填処理 /
2337  * Recharge a wand/staff/rod from the pack or on the floor.
2338  * This function has been rewritten in Oangband and ZAngband.
2339  * @param power 充填パワー
2340  * @return ターン消費を要する処理まで進んだらTRUEを返す
2341  *
2342  * Sorcery/Arcane -- Recharge  --> recharge(plev * 4)
2343  * Chaos -- Arcane Binding     --> recharge(90)
2344  *
2345  * Scroll of recharging        --> recharge(130)
2346  * Artifact activation/Thingol --> recharge(130)
2347  *
2348  * It is harder to recharge high level, and highly charged wands,
2349  * staffs, and rods.  The more wands in a stack, the more easily and
2350  * strongly they recharge.  Staffs, however, each get fewer charges if
2351  * stacked.
2352  *
2353  * Beware of "sliding index errors".
2354  */
2355 bool recharge(int power)
2356 {
2357         OBJECT_IDX item;
2358         DEPTH lev;
2359         int recharge_strength;
2360         TIME_EFFECT recharge_amount;
2361
2362         object_type *o_ptr;
2363         object_kind *k_ptr;
2364
2365         bool fail = FALSE;
2366         byte fail_type = 1;
2367
2368         concptr q, s;
2369         GAME_TEXT o_name[MAX_NLEN];
2370
2371         /* Only accept legal items */
2372         item_tester_hook = item_tester_hook_recharge;
2373
2374         q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2375         s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2376
2377         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2378         if (!o_ptr) return (FALSE);
2379
2380         /* Get the object kind. */
2381         k_ptr = &k_info[o_ptr->k_idx];
2382
2383         /* Extract the object "level" */
2384         lev = k_info[o_ptr->k_idx].level;
2385
2386
2387         /* Recharge a rod */
2388         if (o_ptr->tval == TV_ROD)
2389         {
2390                 /* Extract a recharge strength by comparing object level to power. */
2391                 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2392
2393
2394                 /* Back-fire */
2395                 if (one_in_(recharge_strength))
2396                 {
2397                         /* Activate the failure code. */
2398                         fail = TRUE;
2399                 }
2400
2401                 /* Recharge */
2402                 else
2403                 {
2404                         /* Recharge amount */
2405                         recharge_amount = (power * damroll(3, 2));
2406
2407                         /* Recharge by that amount */
2408                         if (o_ptr->timeout > recharge_amount)
2409                                 o_ptr->timeout -= recharge_amount;
2410                         else
2411                                 o_ptr->timeout = 0;
2412                 }
2413         }
2414
2415
2416         /* Recharge wand/staff */
2417         else
2418         {
2419                 /* Extract a recharge strength by comparing object level to power.
2420                  * Divide up a stack of wands' charges to calculate charge penalty.
2421                  */
2422                 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2423                         recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2424
2425                 /* All staffs, unstacked wands. */
2426                 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2427                 if (recharge_strength < 0) recharge_strength = 0;
2428
2429                 /* Back-fire */
2430                 if (one_in_(recharge_strength))
2431                 {
2432                         /* Activate the failure code. */
2433                         fail = TRUE;
2434                 }
2435
2436                 /* If the spell didn't backfire, recharge the wand or staff. */
2437                 else
2438                 {
2439                         /* Recharge based on the standard number of charges. */
2440                         recharge_amount = randint1(1 + k_ptr->pval / 2);
2441
2442                         /* Multiple wands in a stack increase recharging somewhat. */
2443                         if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2444                         {
2445                                 recharge_amount +=
2446                                         (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2447                                 if (recharge_amount < 1) recharge_amount = 1;
2448                                 if (recharge_amount > 12) recharge_amount = 12;
2449                         }
2450
2451                         /* But each staff in a stack gets fewer additional charges,
2452                          * although always at least one.
2453                          */
2454                         if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2455                         {
2456                                 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2457                                 if (recharge_amount < 1) recharge_amount = 1;
2458                         }
2459
2460                         /* Recharge the wand or staff. */
2461                         o_ptr->pval += recharge_amount;
2462
2463
2464                         /* Hack -- we no longer "know" the item */
2465                         o_ptr->ident &= ~(IDENT_KNOWN);
2466
2467                         /* Hack -- we no longer think the item is empty */
2468                         o_ptr->ident &= ~(IDENT_EMPTY);
2469                 }
2470         }
2471
2472
2473         /* Inflict the penalties for failing a recharge. */
2474         if (fail)
2475         {
2476                 /* Artifacts are never destroyed. */
2477                 if (object_is_fixed_artifact(o_ptr))
2478                 {
2479                         object_desc(o_name, o_ptr, OD_NAME_ONLY);
2480                         msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2481
2482                         /* Artifact rods. */
2483                         if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2484                                 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2485
2486                         /* Artifact wands and staffs. */
2487                         else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2488                                 o_ptr->pval = 0;
2489                 }
2490                 else
2491                 {
2492                         /* Get the object description */
2493                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2494
2495                         /*** Determine Seriousness of Failure ***/
2496
2497                         /* Mages recharge objects more safely. */
2498                         if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2499                         {
2500                                 /* 10% chance to blow up one rod, otherwise draining. */
2501                                 if (o_ptr->tval == TV_ROD)
2502                                 {
2503                                         if (one_in_(10)) fail_type = 2;
2504                                         else fail_type = 1;
2505                                 }
2506                                 /* 75% chance to blow up one wand, otherwise draining. */
2507                                 else if (o_ptr->tval == TV_WAND)
2508                                 {
2509                                         if (!one_in_(3)) fail_type = 2;
2510                                         else fail_type = 1;
2511                                 }
2512                                 /* 50% chance to blow up one staff, otherwise no effect. */
2513                                 else if (o_ptr->tval == TV_STAFF)
2514                                 {
2515                                         if (one_in_(2)) fail_type = 2;
2516                                         else fail_type = 0;
2517                                 }
2518                         }
2519
2520                         /* All other classes get no special favors. */
2521                         else
2522                         {
2523                                 /* 33% chance to blow up one rod, otherwise draining. */
2524                                 if (o_ptr->tval == TV_ROD)
2525                                 {
2526                                         if (one_in_(3)) fail_type = 2;
2527                                         else fail_type = 1;
2528                                 }
2529                                 /* 20% chance of the entire stack, else destroy one wand. */
2530                                 else if (o_ptr->tval == TV_WAND)
2531                                 {
2532                                         if (one_in_(5)) fail_type = 3;
2533                                         else fail_type = 2;
2534                                 }
2535                                 /* Blow up one staff. */
2536                                 else if (o_ptr->tval == TV_STAFF)
2537                                 {
2538                                         fail_type = 2;
2539                                 }
2540                         }
2541
2542                         /*** Apply draining and destruction. ***/
2543
2544                         /* Drain object or stack of objects. */
2545                         if (fail_type == 1)
2546                         {
2547                                 if (o_ptr->tval == TV_ROD)
2548                                 {
2549                                         msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2550
2551                                         if (o_ptr->timeout < 10000)
2552                                                 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2553                                 }
2554                                 else if (o_ptr->tval == TV_WAND)
2555                                 {
2556                                         msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2557                                         o_ptr->pval = 0;
2558                                 }
2559                                 /* Staffs aren't drained. */
2560                         }
2561
2562                         /* Destroy an object or one in a stack of objects. */
2563                         if (fail_type == 2)
2564                         {
2565                                 if (o_ptr->number > 1)
2566                                         msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2567                                 else
2568                                         msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2569
2570                                 /* Reduce rod stack maximum timeout, drain wands. */
2571                                 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2572                                 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2573
2574                                 /* Reduce and describe p_ptr->inventory_list */
2575                                 if (item >= 0)
2576                                 {
2577                                         inven_item_increase(item, -1);
2578                                         inven_item_describe(item);
2579                                         inven_item_optimize(item);
2580                                 }
2581
2582                                 /* Reduce and describe floor item */
2583                                 else
2584                                 {
2585                                         floor_item_increase(0 - item, -1);
2586                                         floor_item_describe(0 - item);
2587                                         floor_item_optimize(0 - item);
2588                                 }
2589                         }
2590
2591                         /* Destroy all members of a stack of objects. */
2592                         if (fail_type == 3)
2593                         {
2594                                 if (o_ptr->number > 1)
2595                                         msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2596                                 else
2597                                         msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2598
2599                                 /* Reduce and describe p_ptr->inventory_list */
2600                                 if (item >= 0)
2601                                 {
2602                                         inven_item_increase(item, -999);
2603                                         inven_item_describe(item);
2604                                         inven_item_optimize(item);
2605                                 }
2606
2607                                 /* Reduce and describe floor item */
2608                                 else
2609                                 {
2610                                         floor_item_increase(0 - item, -999);
2611                                         floor_item_describe(0 - item);
2612                                         floor_item_optimize(0 - item);
2613                                 }
2614                         }
2615                 }
2616         }
2617         p_ptr->update |= (PU_COMBINE | PU_REORDER);
2618         p_ptr->window |= (PW_INVEN);
2619
2620         /* Something was done */
2621         return (TRUE);
2622 }
2623
2624
2625 /*!
2626  * @brief プレイヤーの全既知呪文を表示する /
2627  * Hack -- Display all known spells in a window
2628  * return なし
2629  * @details
2630  * Need to analyze size of the window.
2631  * Need more color coding.
2632  */
2633 void display_spell_list(void)
2634 {
2635         int i, j;
2636         TERM_LEN y, x;
2637         int m[9];
2638         const magic_type *s_ptr;
2639         GAME_TEXT name[MAX_NLEN];
2640         char out_val[160];
2641
2642         clear_from(0);
2643
2644         /* They have too many spells to list */
2645         if (p_ptr->pclass == CLASS_SORCERER) return;
2646         if (p_ptr->pclass == CLASS_RED_MAGE) return;
2647
2648         if (p_ptr->pclass == CLASS_SNIPER)
2649         {
2650                 display_snipe_list();
2651                 return;
2652         }
2653
2654         /* mind.c type classes */
2655         if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2656             (p_ptr->pclass == CLASS_BERSERKER) ||
2657             (p_ptr->pclass == CLASS_NINJA) ||
2658             (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2659             (p_ptr->pclass == CLASS_FORCETRAINER))
2660         {
2661                 PERCENTAGE minfail = 0;
2662                 PLAYER_LEVEL plev = p_ptr->lev;
2663                 PERCENTAGE chance = 0;
2664                 mind_type       spell;
2665                 char            comment[80];
2666                 char            psi_desc[80];
2667                 int             use_mind;
2668                 bool use_hp = FALSE;
2669
2670                 y = 1;
2671                 x = 1;
2672
2673                 /* Display a list of spells */
2674                 prt("", y, x);
2675                 put_str(_("名前", "Name"), y, x + 5);
2676                 put_str(_("Lv   MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2677
2678                 switch(p_ptr->pclass)
2679                 {
2680                 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2681                 case CLASS_FORCETRAINER:          use_mind = MIND_KI;break;
2682                 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2683                 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2684                 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2685                 default:                use_mind = 0;break;
2686                 }
2687
2688                 /* Dump the spells */
2689                 for (i = 0; i < MAX_MIND_POWERS; i++)
2690                 {
2691                         byte a = TERM_WHITE;
2692
2693                         /* Access the available spell */
2694                         spell = mind_powers[use_mind].info[i];
2695                         if (spell.min_lev > plev) break;
2696
2697                         /* Get the failure rate */
2698                         chance = spell.fail;
2699
2700                         /* Reduce failure rate by "effective" level adjustment */
2701                         chance -= 3 * (p_ptr->lev - spell.min_lev);
2702
2703                         /* Reduce failure rate by INT/WIS adjustment */
2704                         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2705
2706                         if (!use_hp)
2707                         {
2708                                 /* Not enough mana to cast */
2709                                 if (spell.mana_cost > p_ptr->csp)
2710                                 {
2711                                         chance += 5 * (spell.mana_cost - p_ptr->csp);
2712                                         a = TERM_ORANGE;
2713                                 }
2714                         }
2715                         else
2716                         {
2717                                 /* Not enough hp to cast */
2718                                 if (spell.mana_cost > p_ptr->chp)
2719                                 {
2720                                         chance += 100;
2721                                         a = TERM_RED;
2722                                 }
2723                         }
2724
2725                         /* Extract the minimum failure rate */
2726                         minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2727
2728                         /* Minimum failure rate */
2729                         if (chance < minfail) chance = minfail;
2730
2731                         /* Stunning makes spells harder */
2732                         if (p_ptr->stun > 50) chance += 25;
2733                         else if (p_ptr->stun) chance += 15;
2734
2735                         /* Always a 5 percent chance of working */
2736                         if (chance > 95) chance = 95;
2737
2738                         /* Get info */
2739                         mindcraft_info(comment, use_mind, i);
2740
2741                         /* Dump the spell */
2742                         sprintf(psi_desc, "  %c) %-30s%2d %4d %3d%%%s",
2743                             I2A(i), spell.name,
2744                             spell.min_lev, spell.mana_cost, chance, comment);
2745
2746                         Term_putstr(x, y + i + 1, -1, a, psi_desc);
2747                 }
2748                 return;
2749         }
2750
2751         /* Cannot read spellbooks */
2752         if (REALM_NONE == p_ptr->realm1) return;
2753
2754         /* Normal spellcaster with books */
2755
2756         /* Scan books */
2757         for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2758         {
2759                 int n = 0;
2760
2761                 /* Reset vertical */
2762                 m[j] = 0;
2763
2764                 /* Vertical location */
2765                 y = (j < 3) ? 0 : (m[j - 3] + 2);
2766
2767                 /* Horizontal location */
2768                 x = 27 * (j % 3);
2769
2770                 /* Scan spells */
2771                 for (i = 0; i < 32; i++)
2772                 {
2773                         byte a = TERM_WHITE;
2774
2775                         /* Access the spell */
2776                         if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2777                         {
2778                                 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2779                         }
2780                         else
2781                         {
2782                                 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2783                         }
2784
2785                         strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2786
2787                         /* Illegible */
2788                         if (s_ptr->slevel >= 99)
2789                         {
2790                                 /* Illegible */
2791                                 strcpy(name, _("(判読不能)", "(illegible)"));
2792
2793                                 /* Unusable */
2794                                 a = TERM_L_DARK;
2795                         }
2796
2797                         /* Forgotten */
2798                         else if ((j < 1) ?
2799                                 ((p_ptr->spell_forgotten1 & (1L << i))) :
2800                                 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2801                         {
2802                                 /* Forgotten */
2803                                 a = TERM_ORANGE;
2804                         }
2805
2806                         /* Unknown */
2807                         else if (!((j < 1) ?
2808                                 (p_ptr->spell_learned1 & (1L << i)) :
2809                                 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2810                         {
2811                                 /* Unknown */
2812                                 a = TERM_RED;
2813                         }
2814
2815                         /* Untried */
2816                         else if (!((j < 1) ?
2817                                 (p_ptr->spell_worked1 & (1L << i)) :
2818                                 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2819                         {
2820                                 /* Untried */
2821                                 a = TERM_YELLOW;
2822                         }
2823
2824                         /* Dump the spell --(-- */
2825                         sprintf(out_val, "%c/%c) %-20.20s",
2826                                 I2A(n / 8), I2A(n % 8), name);
2827
2828                         /* Track maximum */
2829                         m[j] = y + n;
2830
2831                         /* Dump onto the window */
2832                         Term_putstr(x, m[j], -1, a, out_val);
2833
2834                         /* Next */
2835                         n++;
2836                 }
2837         }
2838 }
2839
2840
2841 /*!
2842  * @brief 呪文の経験値を返す /
2843  * Returns experience of a spell
2844  * @param spell 呪文ID
2845  * @param use_realm 魔法領域
2846  * @return 経験値
2847  */
2848 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2849 {
2850         if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2851         else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2852         else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2853         else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2854         else return 0;
2855 }
2856
2857
2858 /*!
2859  * @brief 呪文の消費MPを返す /
2860  * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2861  * @param need_mana 基本消費MP
2862  * @param spell 呪文ID
2863  * @param realm 魔法領域
2864  * @return 消費MP
2865  */
2866 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2867 {
2868 #define MANA_CONST   2400
2869 #define MANA_DIV        4
2870 #define DEC_MANA_DIV    3
2871
2872         /* Realm magic */
2873         if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2874         {
2875                 /*
2876                  * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2877                  * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2878                  */
2879                 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2880                 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2881                 need_mana /= MANA_CONST * MANA_DIV;
2882                 if (need_mana < 1) need_mana = 1;
2883         }
2884
2885         /* Non-realm magic */
2886         else
2887         {
2888                 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2889         }
2890
2891 #undef DEC_MANA_DIV
2892 #undef MANA_DIV
2893 #undef MANA_CONST
2894
2895         return need_mana;
2896 }
2897
2898
2899 /*!
2900  * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2901  * Modify spell fail rate
2902  * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2903  * @param chance 修正前失敗率
2904  * @return 失敗率(%)
2905  * @todo 統合を検討
2906  */
2907 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2908 {
2909         chance += p_ptr->to_m_chance;
2910
2911         if (p_ptr->heavy_spell) chance += 20;
2912
2913         if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2914         else if (p_ptr->easy_spell) chance -= 3;
2915         else if (p_ptr->dec_mana) chance -= 2;
2916
2917         return chance;
2918 }
2919
2920
2921 /*!
2922  * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2923  * Modify spell fail rate
2924  * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2925  * @param chance 修正前失敗率
2926  * @return 失敗率(%)
2927  * Modify spell fail rate (as "suffix" process)
2928  * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2929  * Note: variable "chance" cannot be negative.
2930  * @todo 統合を検討
2931  */
2932 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2933 {
2934         if (p_ptr->dec_mana) chance--;
2935
2936         if (p_ptr->heavy_spell) chance += 5;
2937
2938         return MAX(chance, 0);
2939 }
2940
2941
2942 /*!
2943  * @brief 呪文の失敗率計算メインルーチン /
2944  * Returns spell chance of failure for spell -RAK-
2945  * @param spell 呪文ID
2946  * @param use_realm 魔法領域ID
2947  * @return 失敗率(%)
2948  */
2949 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2950 {
2951         PERCENTAGE chance, minfail;
2952         const magic_type *s_ptr;
2953         MANA_POINT need_mana;
2954         PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2955
2956
2957         /* Paranoia -- must be literate */
2958         if (!mp_ptr->spell_book) return (100);
2959
2960         if (use_realm == REALM_HISSATSU) return 0;
2961
2962         /* Access the spell */
2963         if (!is_magic(use_realm))
2964         {
2965                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2966         }
2967         else
2968         {
2969                 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2970         }
2971
2972         /* Extract the base spell failure rate */
2973         chance = s_ptr->sfail;
2974
2975         /* Reduce failure rate by "effective" level adjustment */
2976         chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2977
2978         /* Reduce failure rate by INT/WIS adjustment */
2979         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2980
2981         if (p_ptr->riding)
2982                 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2983
2984         /* Extract mana consumption rate */
2985         need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2986
2987         /* Not enough mana to cast */
2988         if (need_mana > p_ptr->csp)
2989         {
2990                 chance += 5 * (need_mana - p_ptr->csp);
2991         }
2992
2993         if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2994
2995         /* Extract the minimum failure rate */
2996         minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2997
2998         /*
2999          * Non mage/priest characters never get too good
3000          * (added high mage, mindcrafter)
3001          */
3002         if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3003         {
3004                 if (minfail < 5) minfail = 5;
3005         }
3006
3007         /* Hack -- Priest prayer penalty for "edged" weapons  -DGK */
3008         if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3009         if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3010
3011         chance = mod_spell_chance_1(chance);
3012
3013         /* Goodness or evilness gives a penalty to failure rate */
3014         switch (use_realm)
3015         {
3016         case REALM_NATURE:
3017                 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3018                 break;
3019         case REALM_LIFE: case REALM_CRUSADE:
3020                 if (p_ptr->align < -20) chance += penalty;
3021                 break;
3022         case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3023                 if (p_ptr->align > 20) chance += penalty;
3024                 break;
3025         }
3026
3027         /* Minimum failure rate */
3028         if (chance < minfail) chance = minfail;
3029
3030         /* Stunning makes spells harder */
3031         if (p_ptr->stun > 50) chance += 25;
3032         else if (p_ptr->stun) chance += 15;
3033
3034         /* Always a 5 percent chance of working */
3035         if (chance > 95) chance = 95;
3036
3037         if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3038             || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3039         {
3040                 EXP exp = experience_of_spell(spell, use_realm);
3041                 if (exp >= SPELL_EXP_EXPERT) chance--;
3042                 if (exp >= SPELL_EXP_MASTER) chance--;
3043         }
3044
3045         /* Return the chance */
3046         return mod_spell_chance_2(chance);
3047 }
3048
3049
3050
3051 /*!
3052  * @brief 呪文情報の表示処理 /
3053  * Print a list of spells (for browsing or casting or viewing)
3054  * @param target_spell 呪文ID             
3055  * @param spells 表示するスペルID配列の参照ポインタ
3056  * @param num 表示するスペルの数(spellsの要素数)
3057  * @param y 表示メッセージ左上Y座標
3058  * @param x 表示メッセージ左上X座標
3059  * @param use_realm 魔法領域ID
3060  * @return なし
3061  */
3062 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3063 {
3064         int i;
3065         SPELL_IDX spell;
3066         int  exp_level, increment = 64;
3067         const magic_type *s_ptr;
3068         concptr comment;
3069         char info[80];
3070         char out_val[160];
3071         byte line_attr;
3072         MANA_POINT need_mana;
3073         char ryakuji[5];
3074         char buf[256];
3075         bool max = FALSE;
3076
3077         if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3078         msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3079
3080         /* Title the list */
3081         prt("", y, x);
3082         if (use_realm == REALM_HISSATSU)
3083                 strcpy(buf,_("  Lv   MP", "  Lv   SP"));
3084         else
3085                 strcpy(buf,_("熟練度 Lv   MP 失率 効果", "Profic Lv   SP Fail Effect"));
3086
3087         put_str(_("名前", "Name"), y, x + 5);
3088         put_str(buf, y, x + 29);
3089
3090         if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3091         else if (use_realm == p_ptr->realm1) increment = 0;
3092         else if (use_realm == p_ptr->realm2) increment = 32;
3093
3094         /* Dump the spells */
3095         for (i = 0; i < num; i++)
3096         {
3097                 spell = spells[i];
3098
3099                 if (!is_magic(use_realm))
3100                 {
3101                         s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3102                 }
3103                 else
3104                 {
3105                         s_ptr = &mp_ptr->info[use_realm - 1][spell];
3106                 }
3107
3108                 if (use_realm == REALM_HISSATSU)
3109                         need_mana = s_ptr->smana;
3110                 else
3111                 {
3112                         EXP exp = experience_of_spell(spell, use_realm);
3113
3114                         /* Extract mana consumption rate */
3115                         need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3116
3117                         if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3118                         else exp_level = spell_exp_level(exp);
3119
3120                         max = FALSE;
3121                         if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3122                         else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3123                         else if (s_ptr->slevel >= 99) max = TRUE;
3124                         else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3125
3126                         strncpy(ryakuji, exp_level_str[exp_level], 4);
3127                         ryakuji[3] = ']';
3128                         ryakuji[4] = '\0';
3129                 }
3130
3131                 if (use_menu && target_spell)
3132                 {
3133                         if (i == (target_spell-1))
3134                                 strcpy(out_val, _("  》 ", "  >  "));
3135                         else
3136                                 strcpy(out_val, "     ");
3137                 }
3138                 else sprintf(out_val, "  %c) ", I2A(i));
3139                 /* Skip illegible spells */
3140                 if (s_ptr->slevel >= 99)
3141                 {
3142                         strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3143                         c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3144                         continue;
3145                 }
3146
3147                 /* XXX XXX Could label spells above the players level */
3148
3149                 /* Get extra info */
3150                 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3151
3152                 /* Use that info */
3153                 comment = info;
3154
3155                 /* Assume spell is known and tried */
3156                 line_attr = TERM_WHITE;
3157
3158                 /* Analyze the spell */
3159                 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3160                 {
3161                         if (s_ptr->slevel > p_ptr->max_plv)
3162                         {
3163                                 comment = _("未知", "unknown");
3164                                 line_attr = TERM_L_BLUE;
3165                         }
3166                         else if (s_ptr->slevel > p_ptr->lev)
3167                         {
3168                                 comment = _("忘却", "forgotten");
3169                                 line_attr = TERM_YELLOW;
3170                         }
3171                 }
3172                 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3173                 {
3174                         comment = _("未知", "unknown");
3175                         line_attr = TERM_L_BLUE;
3176                 }
3177                 else if ((use_realm == p_ptr->realm1) ?
3178                     ((p_ptr->spell_forgotten1 & (1L << spell))) :
3179                     ((p_ptr->spell_forgotten2 & (1L << spell))))
3180                 {
3181                         comment = _("忘却", "forgotten");
3182                         line_attr = TERM_YELLOW;
3183                 }
3184                 else if (!((use_realm == p_ptr->realm1) ?
3185                     (p_ptr->spell_learned1 & (1L << spell)) :
3186                     (p_ptr->spell_learned2 & (1L << spell))))
3187                 {
3188                         comment = _("未知", "unknown");
3189                         line_attr = TERM_L_BLUE;
3190                 }
3191                 else if (!((use_realm == p_ptr->realm1) ?
3192                     (p_ptr->spell_worked1 & (1L << spell)) :
3193                     (p_ptr->spell_worked2 & (1L << spell))))
3194                 {
3195                         comment = _("未経験", "untried");
3196                         line_attr = TERM_L_GREEN;
3197                 }
3198
3199                 /* Dump the spell --(-- */
3200                 if (use_realm == REALM_HISSATSU)
3201                 {
3202                         strcat(out_val, format("%-25s %2d %4d",
3203                             do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3204                             s_ptr->slevel, need_mana));
3205                 }
3206                 else
3207                 {
3208                         strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3209                             do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3210                             (max ? '!' : ' '), ryakuji,
3211                             s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3212                 }
3213                 c_prt(line_attr, out_val, y + i + 1, x);
3214         }
3215
3216         /* Clear the bottom line */
3217         prt("", y + i + 1, x);
3218 }
3219
3220 /*!
3221  * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3222  * Helper function -- return a "nearby" race for polymorphing
3223  * @param r_idx 基準となるモンスター種族ID
3224  * @return 変更先のモンスター種族ID
3225  * @details
3226  * Note that this function is one of the more "dangerous" ones...
3227  */
3228 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3229 {
3230         monster_race *r_ptr = &r_info[r_idx];
3231
3232         int i;
3233         MONRACE_IDX r;
3234         DEPTH lev1, lev2;
3235
3236         /* Hack -- Uniques/Questors never polymorph */
3237         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3238                 return (r_idx);
3239
3240         /* Allowable range of "levels" for resulting monster */
3241         lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3242         lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3243
3244         /* Pick a (possibly new) non-unique race */
3245         for (i = 0; i < 1000; i++)
3246         {
3247                 /* Pick a new race, using a level calculation */
3248                 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3249
3250                 /* Handle failure */
3251                 if (!r) break;
3252
3253                 /* Obtain race */
3254                 r_ptr = &r_info[r];
3255
3256                 /* Ignore unique monsters */
3257                 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3258
3259                 /* Ignore monsters with incompatible levels */
3260                 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3261
3262                 /* Use that index */
3263                 r_idx = r;
3264
3265                 break;
3266         }
3267         return (r_idx);
3268 }
3269
3270 /*!
3271  * @brief 指定座標にいるモンスターを変身させる /
3272  * Helper function -- return a "nearby" race for polymorphing
3273  * @param y 指定のY座標
3274  * @param x 指定のX座標
3275  * @return 実際に変身したらTRUEを返す
3276  */
3277 bool polymorph_monster(POSITION y, POSITION x)
3278 {
3279         grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
3280         monster_type *m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
3281         bool polymorphed = FALSE;
3282         MONRACE_IDX new_r_idx;
3283         MONRACE_IDX old_r_idx = m_ptr->r_idx;
3284         bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3285         bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3286         monster_type back_m;
3287
3288         if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3289
3290         if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3291
3292         /* Memorize the monster before polymorphing */
3293         back_m = *m_ptr;
3294
3295         /* Pick a "new" monster race */
3296         new_r_idx = poly_r_idx(old_r_idx);
3297
3298         /* Handle polymorph */
3299         if (new_r_idx != old_r_idx)
3300         {
3301                 BIT_FLAGS mode = 0L;
3302                 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3303                 OBJECT_IDX this_o_idx, next_o_idx = 0;
3304
3305                 /* Get the monsters attitude */
3306                 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3307                 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3308                 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3309
3310                 /* Mega-hack -- ignore held objects */
3311                 m_ptr->hold_o_idx = 0;
3312
3313                 /* "Kill" the "old" monster */
3314                 delete_monster_idx(g_ptr->m_idx);
3315
3316                 /* Create a new monster (no groups) */
3317                 if (place_monster_aux(0, y, x, new_r_idx, mode))
3318                 {
3319                         current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3320                         current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3321                         current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3322
3323                         /* Success */
3324                         polymorphed = TRUE;
3325                 }
3326                 else
3327                 {
3328                         /* Placing the new monster failed */
3329                         if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3330                         {
3331                                 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3332
3333                                 /* Re-initialize monster process */
3334                                 mproc_init();
3335                         }
3336                         else preserve_hold_objects = FALSE;
3337                 }
3338
3339                 /* Mega-hack -- preserve held objects */
3340                 if (preserve_hold_objects)
3341                 {
3342                         for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3343                         {
3344                                 object_type *o_ptr = &current_floor_ptr->o_list[this_o_idx];
3345                                 next_o_idx = o_ptr->next_o_idx;
3346
3347                                 /* Held by new monster */
3348                                 o_ptr->held_m_idx = hack_m_idx_ii;
3349                         }
3350                 }
3351                 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3352                 {
3353                         for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3354                         {
3355                                 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3356                                 delete_object_idx(this_o_idx);
3357                         }
3358                 }
3359
3360                 if (targeted) target_who = hack_m_idx_ii;
3361                 if (health_tracked) health_track(hack_m_idx_ii);
3362         }
3363
3364         return polymorphed;
3365 }
3366
3367 /*!
3368  * @brief 次元の扉処理 /
3369  * Dimension Door
3370  * @param x テレポート先のX座標
3371  * @param y テレポート先のY座標
3372  * @return 目標に指定通りテレポートできたならばTRUEを返す
3373  */
3374 static bool dimension_door_aux(DEPTH x, DEPTH y)
3375 {
3376         PLAYER_LEVEL plev = p_ptr->lev;
3377
3378         p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3379
3380         if (!cave_player_teleportable_bold(y, x, 0L) ||
3381             (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3382             (!randint0(plev / 10 + 10)))
3383         {
3384                 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3385                 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3386
3387                 /* Failed */
3388                 return FALSE;
3389         }
3390         else
3391         {
3392                 teleport_player_to(y, x, 0L);
3393
3394                 /* Success */
3395                 return TRUE;
3396         }
3397 }
3398
3399
3400 /*!
3401  * @brief 次元の扉処理のメインルーチン /
3402  * Dimension Door
3403  * @return ターンを消費した場合TRUEを返す
3404  */
3405 bool dimension_door(void)
3406 {
3407         DEPTH x = 0, y = 0;
3408
3409         /* Rerutn FALSE if cancelled */
3410         if (!tgt_pt(&x, &y)) return FALSE;
3411
3412         if (dimension_door_aux(x, y)) return TRUE;
3413
3414         msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3415
3416         return TRUE;
3417 }
3418
3419
3420 /*!
3421  * @brief 鏡抜け処理のメインルーチン /
3422  * Mirror Master's Dimension Door
3423  * @return ターンを消費した場合TRUEを返す
3424  */
3425 bool mirror_tunnel(void)
3426 {
3427         POSITION x = 0, y = 0;
3428
3429         /* Rerutn FALSE if cancelled */
3430         if (!tgt_pt(&x, &y)) return FALSE;
3431
3432         if (dimension_door_aux(x, y)) return TRUE;
3433
3434         msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3435
3436         return TRUE;
3437 }
3438
3439 /*!
3440  * @brief 魔力食い処理
3441  * @param power 基本効力
3442  * @return ターンを消費した場合TRUEを返す
3443  */
3444 bool eat_magic(int power)
3445 {
3446         object_type *o_ptr;
3447         object_kind *k_ptr;
3448         DEPTH lev;
3449         OBJECT_IDX item;
3450         int recharge_strength = 0;
3451
3452         bool fail = FALSE;
3453         byte fail_type = 1;
3454
3455         concptr q, s;
3456         GAME_TEXT o_name[MAX_NLEN];
3457
3458         item_tester_hook = item_tester_hook_recharge;
3459
3460         q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3461         s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3462
3463         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3464         if (!o_ptr) return FALSE;
3465
3466         k_ptr = &k_info[o_ptr->k_idx];
3467         lev = k_info[o_ptr->k_idx].level;
3468
3469         if (o_ptr->tval == TV_ROD)
3470         {
3471                 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3472
3473                 /* Back-fire */
3474                 if (one_in_(recharge_strength))
3475                 {
3476                         /* Activate the failure code. */
3477                         fail = TRUE;
3478                 }
3479                 else
3480                 {
3481                         if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3482                         {
3483                                 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3484                         }
3485                         else
3486                         {
3487                                 p_ptr->csp += lev;
3488                                 o_ptr->timeout += k_ptr->pval;
3489                         }
3490                 }
3491         }
3492         else
3493         {
3494                 /* All staffs, wands. */
3495                 recharge_strength = (100 + power - lev) / 15;
3496                 if (recharge_strength < 0) recharge_strength = 0;
3497
3498                 /* Back-fire */
3499                 if (one_in_(recharge_strength))
3500                 {
3501                         /* Activate the failure code. */
3502                         fail = TRUE;
3503                 }
3504                 else
3505                 {
3506                         if (o_ptr->pval > 0)
3507                         {
3508                                 p_ptr->csp += lev / 2;
3509                                 o_ptr->pval --;
3510
3511                                 /* XXX Hack -- unstack if necessary */
3512                                 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3513                                 {
3514                                         object_type forge;
3515                                         object_type *q_ptr;
3516                                         q_ptr = &forge;
3517
3518                                         /* Obtain a local object */
3519                                         object_copy(q_ptr, o_ptr);
3520
3521                                         /* Modify quantity */
3522                                         q_ptr->number = 1;
3523
3524                                         /* Restore the charges */
3525                                         o_ptr->pval++;
3526
3527                                         /* Unstack the used item */
3528                                         o_ptr->number--;
3529                                         p_ptr->total_weight -= q_ptr->weight;
3530                                         item = inven_carry(q_ptr);
3531
3532                                         msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3533                                 }
3534                         }
3535                         else
3536                         {
3537                                 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3538                         }
3539                         if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3540                 }
3541         }
3542
3543         /* Inflict the penalties for failing a recharge. */
3544         if (fail)
3545         {
3546                 /* Artifacts are never destroyed. */
3547                 if (object_is_fixed_artifact(o_ptr))
3548                 {
3549                         object_desc(o_name, o_ptr, OD_NAME_ONLY);
3550                         msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3551
3552                         /* Artifact rods. */
3553                         if (o_ptr->tval == TV_ROD)
3554                                 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3555
3556                         /* Artifact wands and staffs. */
3557                         else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3558                                 o_ptr->pval = 0;
3559                 }
3560                 else
3561                 {
3562                         /* Get the object description */
3563                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3564
3565                         /*** Determine Seriousness of Failure ***/
3566
3567                         /* Mages recharge objects more safely. */
3568                         if (IS_WIZARD_CLASS())
3569                         {
3570                                 /* 10% chance to blow up one rod, otherwise draining. */
3571                                 if (o_ptr->tval == TV_ROD)
3572                                 {
3573                                         if (one_in_(10)) fail_type = 2;
3574                                         else fail_type = 1;
3575                                 }
3576                                 /* 75% chance to blow up one wand, otherwise draining. */
3577                                 else if (o_ptr->tval == TV_WAND)
3578                                 {
3579                                         if (!one_in_(3)) fail_type = 2;
3580                                         else fail_type = 1;
3581                                 }
3582                                 /* 50% chance to blow up one staff, otherwise no effect. */
3583                                 else if (o_ptr->tval == TV_STAFF)
3584                                 {
3585                                         if (one_in_(2)) fail_type = 2;
3586                                         else fail_type = 0;
3587                                 }
3588                         }
3589
3590                         /* All other classes get no special favors. */
3591                         else
3592                         {
3593                                 /* 33% chance to blow up one rod, otherwise draining. */
3594                                 if (o_ptr->tval == TV_ROD)
3595                                 {
3596                                         if (one_in_(3)) fail_type = 2;
3597                                         else fail_type = 1;
3598                                 }
3599                                 /* 20% chance of the entire stack, else destroy one wand. */
3600                                 else if (o_ptr->tval == TV_WAND)
3601                                 {
3602                                         if (one_in_(5)) fail_type = 3;
3603                                         else fail_type = 2;
3604                                 }
3605                                 /* Blow up one staff. */
3606                                 else if (o_ptr->tval == TV_STAFF)
3607                                 {
3608                                         fail_type = 2;
3609                                 }
3610                         }
3611
3612                         /*** Apply draining and destruction. ***/
3613
3614                         /* Drain object or stack of objects. */
3615                         if (fail_type == 1)
3616                         {
3617                                 if (o_ptr->tval == TV_ROD)
3618                                 {
3619                                         msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3620                                                                  "You save your rod from destruction, but all charges are lost."), o_name);
3621                                         o_ptr->timeout = k_ptr->pval * o_ptr->number;
3622                                 }
3623                                 else if (o_ptr->tval == TV_WAND)
3624                                 {
3625                                         msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3626                                         o_ptr->pval = 0;
3627                                 }
3628                                 /* Staffs aren't drained. */
3629                         }
3630
3631                         /* Destroy an object or one in a stack of objects. */
3632                         if (fail_type == 2)
3633                         {
3634                                 if (o_ptr->number > 1)
3635                                 {
3636                                         msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3637                                         /* Reduce rod stack maximum timeout, drain wands. */
3638                                         if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3639                                         else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3640                                 }
3641                                 else
3642                                 {
3643                                         msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3644                                 }
3645                                 
3646                                 /* Reduce and describe p_ptr->inventory_list */
3647                                 if (item >= 0)
3648                                 {
3649                                         inven_item_increase(item, -1);
3650                                         inven_item_describe(item);
3651                                         inven_item_optimize(item);
3652                                 }
3653
3654                                 /* Reduce and describe floor item */
3655                                 else
3656                                 {
3657                                         floor_item_increase(0 - item, -1);
3658                                         floor_item_describe(0 - item);
3659                                         floor_item_optimize(0 - item);
3660                                 }
3661                         }
3662
3663                         /* Destroy all members of a stack of objects. */
3664                         if (fail_type == 3)
3665                         {
3666                                 if (o_ptr->number > 1)
3667                                         msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3668                                 else
3669                                         msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3670
3671                                 /* Reduce and describe p_ptr->inventory_list */
3672                                 if (item >= 0)
3673                                 {
3674                                         inven_item_increase(item, -999);
3675                                         inven_item_describe(item);
3676                                         inven_item_optimize(item);
3677                                 }
3678
3679                                 /* Reduce and describe floor item */
3680                                 else
3681                                 {
3682                                         floor_item_increase(0 - item, -999);
3683                                         floor_item_describe(0 - item);
3684                                         floor_item_optimize(0 - item);
3685                                 }
3686                         }
3687                 }
3688         }
3689
3690         if (p_ptr->csp > p_ptr->msp)
3691         {
3692                 p_ptr->csp = p_ptr->msp;
3693         }
3694
3695         p_ptr->redraw |= (PR_MANA);
3696         p_ptr->update |= (PU_COMBINE | PU_REORDER);
3697         p_ptr->window |= (PW_INVEN);
3698
3699         return TRUE;
3700 }
3701
3702
3703 /*!
3704  * @brief 皆殺し(全方向攻撃)処理
3705  * @param py プレイヤーY座標
3706  * @param px プレイヤーX座標
3707  * @return なし
3708  */
3709 void massacre(void)
3710 {
3711         POSITION x, y;
3712         grid_type *g_ptr;
3713         monster_type *m_ptr;
3714         DIRECTION dir;
3715
3716         for (dir = 0; dir < 8; dir++)
3717         {
3718                 y = p_ptr->y + ddy_ddd[dir];
3719                 x = p_ptr->x + ddx_ddd[dir];
3720                 g_ptr = &current_floor_ptr->grid_array[y][x];
3721                 m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
3722
3723                 /* Hack -- attack monsters */
3724                 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3725                         py_attack(y, x, 0);
3726         }
3727 }
3728
3729 bool eat_lock(void)
3730 {
3731         POSITION x, y;
3732         grid_type *g_ptr;
3733         feature_type *f_ptr, *mimic_f_ptr;
3734         DIRECTION dir;
3735
3736         if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3737         y = p_ptr->y + ddy[dir];
3738         x = p_ptr->x + ddx[dir];
3739         g_ptr = &current_floor_ptr->grid_array[y][x];
3740         f_ptr = &f_info[g_ptr->feat];
3741         mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3742
3743         stop_mouth();
3744
3745         if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3746         {
3747                 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3748         }
3749         else if (have_flag(f_ptr->flags, FF_PERMANENT))
3750         {
3751                 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch!  This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3752         }
3753         else if (g_ptr->m_idx)
3754         {
3755                 monster_type *m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
3756                 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3757
3758                 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3759         }
3760         else if (have_flag(f_ptr->flags, FF_TREE))
3761         {
3762                 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3763         }
3764         else if (have_flag(f_ptr->flags, FF_GLASS))
3765         {
3766                 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3767         }
3768         else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3769         {
3770                 (void)set_food(p_ptr->food + 3000);
3771         }
3772         else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3773         {
3774                 (void)set_food(p_ptr->food + 5000);
3775         }
3776         else
3777         {
3778                 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3779                 (void)set_food(p_ptr->food + 10000);
3780         }
3781
3782         /* Destroy the wall */
3783         cave_alter_feat(y, x, FF_HURT_ROCK);
3784
3785         (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3786         return TRUE;
3787 }
3788
3789
3790 bool shock_power(void)
3791 {
3792         DIRECTION dir;
3793         POSITION y, x;
3794         HIT_POINT dam;
3795         PLAYER_LEVEL plev = p_ptr->lev;
3796         int boost = P_PTR_KI;
3797         if (heavy_armor()) boost /= 2;
3798
3799         project_length = 1;
3800         if (!get_aim_dir(&dir)) return FALSE;
3801
3802         y = p_ptr->y + ddy[dir];
3803         x = p_ptr->x + ddx[dir];
3804         dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3805         fire_beam(GF_MISSILE, dir, dam);
3806         if (current_floor_ptr->grid_array[y][x].m_idx)
3807         {
3808                 int i;
3809                 POSITION ty = y, tx = x;
3810                 POSITION oy = y, ox = x;
3811                 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3812                 monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
3813                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3814                 GAME_TEXT m_name[MAX_NLEN];
3815
3816                 monster_desc(m_name, m_ptr, 0);
3817
3818                 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3819                 {
3820                         msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3821                 }
3822                 else
3823                 {
3824                         for (i = 0; i < 5; i++)
3825                         {
3826                                 y += ddy[dir];
3827                                 x += ddx[dir];
3828                                 if (cave_empty_bold(y, x))
3829                                 {
3830                                         ty = y;
3831                                         tx = x;
3832                                 }
3833                                 else break;
3834                         }
3835                         if ((ty != oy) || (tx != ox))
3836                         {
3837                                 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3838                                 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3839                                 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3840                                 m_ptr->fy = ty;
3841                                 m_ptr->fx = tx;
3842
3843                                 update_monster(m_idx, TRUE);
3844                                 lite_spot(oy, ox);
3845                                 lite_spot(ty, tx);
3846
3847                                 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3848                                         p_ptr->update |= (PU_MON_LITE);
3849                         }
3850                 }
3851         }
3852         return TRUE;
3853 }
3854
3855 bool booze(player_type *creature_ptr)
3856 {
3857         bool ident = FALSE;
3858         if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3859         else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3860         if (!creature_ptr->resist_conf)
3861         {
3862                 if (set_confused(randint0(20) + 15))
3863                 {
3864                         ident = TRUE;
3865                 }
3866         }
3867
3868         if (!creature_ptr->resist_chaos)
3869         {
3870                 if (one_in_(2))
3871                 {
3872                         if (set_image(creature_ptr->image + randint0(150) + 150))
3873                         {
3874                                 ident = TRUE;
3875                         }
3876                 }
3877                 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3878                 {
3879                         ident = TRUE;
3880                         if (one_in_(3)) lose_all_info();
3881                         else wiz_dark();
3882                         (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3883                         wiz_dark();
3884                         msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3885                         msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3886                 }
3887         }
3888         return ident;
3889 }
3890
3891 bool detonation(player_type *creature_ptr)
3892 {
3893         msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3894         take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3895         (void)set_stun(creature_ptr->stun + 75);
3896         (void)set_cut(creature_ptr->cut + 5000);
3897         return TRUE;
3898 }
3899
3900 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3901 {
3902         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
3903         grid_type *g_ptr = &current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3904         BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3905         int count = 0;
3906         do
3907         {
3908                 switch (randint1(28))
3909                 {
3910                 case 1: case 2:
3911                         if (!count)
3912                         {
3913                                 msg_print(_("地面が揺れた...", "The ground trembles..."));
3914                                 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3915                                 if (!one_in_(6)) break;
3916                         }
3917                 case 3: case 4: case 5: case 6:
3918                         if (!count)
3919                         {
3920                                 int extra_dam = damroll(10, 10);
3921                                 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3922
3923                                 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3924                                 if (!one_in_(6)) break;
3925                         }
3926                 case 7: case 8:
3927                         if (!count)
3928                         {
3929                                 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3930
3931                                 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3932                                 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3933                                 if (!one_in_(6)) break;
3934                         }
3935                 case 9: case 10: case 11:
3936                         msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3937                         project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3938                         if (!one_in_(6)) break;
3939                 case 12: case 13: case 14: case 15: case 16:
3940                         aggravate_monsters(0);
3941                         if (!one_in_(6)) break;
3942                 case 17: case 18:
3943                         count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3944                         if (!one_in_(6)) break;
3945                 case 19: case 20: case 21: case 22:
3946                 {
3947                         bool pet = !one_in_(3);
3948                         BIT_FLAGS mode = PM_ALLOW_GROUP;
3949
3950                         if (pet) mode |= PM_FORCE_PET;
3951                         else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3952
3953                         count += summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : current_floor_ptr->dun_level), 0, mode, '\0');
3954                         if (!one_in_(6)) break;
3955                 }
3956                 case 23: case 24: case 25:
3957                         if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3958                         msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3959
3960                         if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3961                         else lose_exp(p_ptr->exp / 16);
3962                         if (!one_in_(6)) break;
3963                 case 26: case 27: case 28:
3964                 {
3965                         int i = 0;
3966                         if (one_in_(13))
3967                         {
3968                                 while (i < A_MAX)
3969                                 {
3970                                         do
3971                                         {
3972                                                 (void)do_dec_stat(i);
3973                                         } while (one_in_(2));
3974
3975                                         i++;
3976                                 }
3977                         }
3978                         else
3979                         {
3980                                 (void)do_dec_stat(randint0(6));
3981                         }
3982                         break;
3983                 }
3984                 }
3985         } while (one_in_(5));
3986 }
3987
3988
3989 bool fire_crimson(void)
3990 {
3991         int num = 1;
3992         int i;
3993         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3994         POSITION tx, ty;
3995         DIRECTION dir;
3996
3997         if (!get_aim_dir(&dir)) return FALSE;
3998
3999         /* Use the given direction */
4000         tx = p_ptr->x + 99 * ddx[dir];
4001         ty = p_ptr->y + 99 * ddy[dir];
4002
4003         /* Hack -- Use an actual "target" */
4004         if ((dir == 5) && target_okay())
4005         {
4006                 tx = target_col;
4007                 ty = target_row;
4008         }
4009
4010         if (p_ptr->pclass == CLASS_ARCHER)
4011         {
4012                 /* Extra shot at level 10 */
4013                 if (p_ptr->lev >= 10) num++;
4014
4015                 /* Extra shot at level 30 */
4016                 if (p_ptr->lev >= 30) num++;
4017
4018                 /* Extra shot at level 45 */
4019                 if (p_ptr->lev >= 45) num++;
4020         }
4021
4022         for (i = 0; i < num; i++)
4023                 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
4024
4025         return TRUE;
4026 }
4027
4028
4029 /*!
4030  * @brief 町間のテレポートを行うメインルーチン。
4031  * @return テレポート処理を決定したか否か
4032  */
4033 bool tele_town(void)
4034 {
4035         int i;
4036         POSITION x, y;
4037         int num = 0;
4038
4039         if (current_floor_ptr->dun_level)
4040         {
4041                 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
4042                 return FALSE;
4043         }
4044
4045         if (p_ptr->inside_arena || p_ptr->inside_battle)
4046         {
4047                 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
4048                 return FALSE;
4049         }
4050
4051         screen_save();
4052         clear_bldg(4, 10);
4053
4054         for (i = 1; i < max_towns; i++)
4055         {
4056                 char buf[80];
4057
4058                 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i - 1)))) continue;
4059
4060                 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
4061                 prt(buf, 5 + i, 5);
4062                 num++;
4063         }
4064
4065         if (!num)
4066         {
4067                 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
4068                 msg_print(NULL);
4069                 screen_load();
4070                 return FALSE;
4071         }
4072
4073         prt(_("どこに行きますか:", "Which town you go: "), 0, 0);
4074         while (1)
4075         {
4076                 i = inkey();
4077
4078                 if (i == ESCAPE)
4079                 {
4080                         screen_load();
4081                         return FALSE;
4082                 }
4083                 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
4084                 else if (((i - 'a' + 1) == p_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN) || !(p_ptr->visit & (1L << (i - 'a')))) continue;
4085                 break;
4086         }
4087
4088         for (y = 0; y < current_world_ptr->max_wild_y; y++)
4089         {
4090                 for (x = 0; x < current_world_ptr->max_wild_x; x++)
4091                 {
4092                         if (wilderness[y][x].town == (i - 'a' + 1))
4093                         {
4094                                 p_ptr->wilderness_y = y;
4095                                 p_ptr->wilderness_x = x;
4096                         }
4097                 }
4098         }
4099
4100         p_ptr->leaving = TRUE;
4101         p_ptr->leave_bldg = TRUE;
4102         p_ptr->teleport_town = TRUE;
4103         screen_load();
4104         return TRUE;
4105 }