OSDN Git Service

[modify]スクリーンダンプの最大サイズを増加
[hengband/hengband.git] / src / dungeon.c
1 /*!
2     @file dungeon.c
3     @brief Angbandゲームエンジン / Angband game engine
4     @date 2013/12/31
5     @author
6     Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7     This software may be copied and distributed for educational, research, and\n
8     not for profit purposes provided that this copyright and statement are\n
9     included in all such copies.\n
10     2013 Deskull rearranged comment for Doxygen.
11  */
12
13 #include "angband.h"
14
15 #define TY_CURSE_CHANCE 200 /*!<太古の怨念の1ターン毎の発動確率(1/n)*/
16 #define CHAINSWORD_NOISE 100 /*!<チェンソーの1ターン毎の発動確率(1/n)*/
17
18 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
19 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
20
21 /*!
22  * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item.  Method 1 (Heavy).
23  * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
24  * @return 擬似鑑定結果のIDを返す。
25  */
26 static byte value_check_aux1(object_type *o_ptr)
27 {
28         /* Artifacts */
29         if (object_is_artifact(o_ptr))
30         {
31                 /* Cursed/Broken */
32                 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
33
34                 /* Normal */
35                 return FEEL_SPECIAL;
36         }
37
38         /* Ego-Items */
39         if (object_is_ego(o_ptr))
40         {
41                 /* Cursed/Broken */
42                 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
43
44                 /* Normal */
45                 return FEEL_EXCELLENT;
46         }
47
48         /* Cursed items */
49         if (object_is_cursed(o_ptr)) return FEEL_CURSED;
50
51         /* Broken items */
52         if (object_is_broken(o_ptr)) return FEEL_BROKEN;
53
54         if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
55
56         /* Good "armor" bonus */
57         if (o_ptr->to_a > 0) return FEEL_GOOD;
58
59         /* Good "weapon" bonus */
60         if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
61
62         /* Default to "average" */
63         return FEEL_AVERAGE;
64 }
65
66 /*!
67  * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item.  Method 2 (Light).
68  * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
69  * @return 擬似鑑定結果のIDを返す。
70  */
71 static byte value_check_aux2(object_type *o_ptr)
72 {
73         /* Cursed items (all of them) */
74         if (object_is_cursed(o_ptr)) return FEEL_CURSED;
75
76         /* Broken items (all of them) */
77         if (object_is_broken(o_ptr)) return FEEL_BROKEN;
78
79         /* Artifacts -- except cursed/broken ones */
80         if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
81
82         /* Ego-Items -- except cursed/broken ones */
83         if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
84
85         /* Good armor bonus */
86         if (o_ptr->to_a > 0) return FEEL_UNCURSED;
87
88         /* Good weapon bonuses */
89         if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
90
91         /* No feeling */
92         return FEEL_NONE;
93 }
94
95
96 /*!
97  * @brief 擬似鑑定を実際に行い判定を反映する
98  * @param slot 擬似鑑定を行うプレイヤーの所持リストID
99  * @param heavy 重度の擬似鑑定を行うならばTRUE
100  * @return なし
101  */
102 static void sense_inventory_aux(int slot, bool heavy)
103 {
104         byte        feel;
105         object_type *o_ptr = &inventory[slot];
106         char        o_name[MAX_NLEN];
107
108         /* We know about it already, do not tell us again */
109         if (o_ptr->ident & (IDENT_SENSE))return;
110
111         /* It is fully known, no information needed */
112         if (object_is_known(o_ptr)) return;
113
114         /* Check for a feeling */
115         feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
116
117         /* Skip non-feelings */
118         if (!feel) return;
119
120         /* Bad luck */
121         if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
122         {
123                 switch (feel)
124                 {
125                         case FEEL_TERRIBLE:
126                         {
127                                 feel = FEEL_SPECIAL;
128                                 break;
129                         }
130                         case FEEL_WORTHLESS:
131                         {
132                                 feel = FEEL_EXCELLENT;
133                                 break;
134                         }
135                         case FEEL_CURSED:
136                         {
137                                 if (heavy)
138                                         feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
139                                 else
140                                         feel = FEEL_UNCURSED;
141                                 break;
142                         }
143                         case FEEL_AVERAGE:
144                         {
145                                 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
146                                 break;
147                         }
148                         case FEEL_GOOD:
149                         {
150                                 if (heavy)
151                                         feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
152                                 else
153                                         feel = FEEL_CURSED;
154                                 break;
155                         }
156                         case FEEL_EXCELLENT:
157                         {
158                                 feel = FEEL_WORTHLESS;
159                                 break;
160                         }
161                         case FEEL_SPECIAL:
162                         {
163                                 feel = FEEL_TERRIBLE;
164                                 break;
165                         }
166                 }
167         }
168
169         /* Stop everything */
170         if (disturb_minor) disturb(0, 0);
171
172         /* Get an object description */
173         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
174
175         /* Message (equipment) */
176         if (slot >= INVEN_RARM)
177         {
178 #ifdef JP
179 msg_format("%s%s(%c)は%sという感じがする...",
180 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
181 #else
182                 msg_format("You feel the %s (%c) you are %s %s %s...",
183                            o_name, index_to_label(slot), describe_use(slot),
184                            ((o_ptr->number == 1) ? "is" : "are"),
185                                    game_inscriptions[feel]);
186 #endif
187
188         }
189
190         /* Message (inventory) */
191         else
192         {
193 #ifdef JP
194 msg_format("ザックの中の%s(%c)は%sという感じがする...",
195 o_name, index_to_label(slot),game_inscriptions[feel]);
196 #else
197                 msg_format("You feel the %s (%c) in your pack %s %s...",
198                            o_name, index_to_label(slot),
199                            ((o_ptr->number == 1) ? "is" : "are"),
200                                    game_inscriptions[feel]);
201 #endif
202
203         }
204
205         /* We have "felt" it */
206         o_ptr->ident |= (IDENT_SENSE);
207
208         /* Set the "inscription" */
209         o_ptr->feeling = feel;
210
211         /* Auto-inscription/destroy */
212         autopick_alter_item(slot, destroy_feeling);
213
214         /* Combine / Reorder the pack (later) */
215         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
216
217         /* Window stuff */
218         p_ptr->window |= (PW_INVEN | PW_EQUIP);
219 }
220
221
222
223 /*!
224  * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
225  * @return なし
226  * @details
227  * Sense the inventory\n
228  *\n
229  *   Class 0 = Warrior --> fast and heavy\n
230  *   Class 1 = Mage    --> slow and light\n
231  *   Class 2 = Priest  --> fast but light\n
232  *   Class 3 = Rogue   --> okay and heavy\n
233  *   Class 4 = Ranger  --> slow but heavy  (changed!)\n
234  *   Class 5 = Paladin --> slow but heavy\n
235  */
236 static void sense_inventory1(void)
237 {
238         int         i;
239         int         plev = p_ptr->lev;
240         bool        heavy = FALSE;
241         object_type *o_ptr;
242
243
244         /*** Check for "sensing" ***/
245
246         /* No sensing when confused */
247         if (p_ptr->confused) return;
248
249         /* Analyze the class */
250         switch (p_ptr->pclass)
251         {
252                 case CLASS_WARRIOR:
253                 case CLASS_ARCHER:
254                 case CLASS_SAMURAI:
255                 case CLASS_CAVALRY:
256                 {
257                         /* Good sensing */
258                         if (0 != randint0(9000L / (plev * plev + 40))) return;
259
260                         /* Heavy sensing */
261                         heavy = TRUE;
262
263                         /* Done */
264                         break;
265                 }
266
267                 case CLASS_SMITH:
268                 {
269                         /* Good sensing */
270                         if (0 != randint0(6000L / (plev * plev + 50))) return;
271
272                         /* Heavy sensing */
273                         heavy = TRUE;
274
275                         /* Done */
276                         break;
277                 }
278
279                 case CLASS_MAGE:
280                 case CLASS_HIGH_MAGE:
281                 case CLASS_SORCERER:
282                 case CLASS_MAGIC_EATER:
283                 {
284                         /* Very bad (light) sensing */
285                         if (0 != randint0(240000L / (plev + 5))) return;
286
287                         /* Done */
288                         break;
289                 }
290
291                 case CLASS_PRIEST:
292                 case CLASS_BARD:
293                 {
294                         /* Good (light) sensing */
295                         if (0 != randint0(10000L / (plev * plev + 40))) return;
296
297                         /* Done */
298                         break;
299                 }
300
301                 case CLASS_ROGUE:
302                 case CLASS_NINJA:
303                 {
304                         /* Okay sensing */
305                         if (0 != randint0(20000L / (plev * plev + 40))) return;
306
307                         /* Heavy sensing */
308                         heavy = TRUE;
309
310                         /* Done */
311                         break;
312                 }
313
314                 case CLASS_RANGER:
315                 {
316                         /* Bad sensing */
317                         if (0 != randint0(95000L / (plev * plev + 40))) return;
318
319                         /* Changed! */
320                         heavy = TRUE;
321
322                         /* Done */
323                         break;
324                 }
325
326                 case CLASS_PALADIN:
327                 case CLASS_SNIPER:
328                 {
329                         /* Bad sensing */
330                         if (0 != randint0(77777L / (plev * plev + 40))) return;
331
332                         /* Heavy sensing */
333                         heavy = TRUE;
334
335                         /* Done */
336                         break;
337                 }
338
339                 case CLASS_WARRIOR_MAGE:
340                 case CLASS_RED_MAGE:
341                 {
342                         /* Bad sensing */
343                         if (0 != randint0(75000L / (plev * plev + 40))) return;
344
345                         /* Done */
346                         break;
347                 }
348
349                 case CLASS_MINDCRAFTER:
350                 case CLASS_IMITATOR:
351                 case CLASS_BLUE_MAGE:
352                 case CLASS_MIRROR_MASTER:
353                 {
354                         /* Bad sensing */
355                         if (0 != randint0(55000L / (plev * plev + 40))) return;
356
357                         /* Done */
358                         break;
359                 }
360
361                 case CLASS_CHAOS_WARRIOR:
362                 {
363                         /* Bad sensing */
364                         if (0 != randint0(80000L / (plev * plev + 40))) return;
365
366                         /* Changed! */
367                         heavy = TRUE;
368
369                         /* Done */
370                         break;
371                 }
372
373                 case CLASS_MONK:
374                 case CLASS_FORCETRAINER:
375                 {
376                         /* Okay sensing */
377                         if (0 != randint0(20000L / (plev * plev + 40))) return;
378
379                         /* Done */
380                         break;
381                 }
382
383                 case CLASS_TOURIST:
384                 {
385                         /* Good sensing */
386                         if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
387
388                         /* Heavy sensing */
389                         heavy = TRUE;
390
391                         /* Done */
392                         break;
393                 }
394
395                 case CLASS_BEASTMASTER:
396                 {
397                         /* Bad sensing */
398                         if (0 != randint0(65000L / (plev * plev + 40))) return;
399
400                         /* Done */
401                         break;
402                 }
403                 case CLASS_BERSERKER:
404                 {
405                         /* Heavy sensing */
406                         heavy = TRUE;
407
408                         /* Done */
409                         break;
410                 }
411         }
412
413         if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
414
415         /*** Sense everything ***/
416
417         /* Check everything */
418         for (i = 0; i < INVEN_TOTAL; i++)
419         {
420                 bool okay = FALSE;
421
422                 o_ptr = &inventory[i];
423
424                 /* Skip empty slots */
425                 if (!o_ptr->k_idx) continue;
426
427                 /* Valid "tval" codes */
428                 switch (o_ptr->tval)
429                 {
430                         case TV_SHOT:
431                         case TV_ARROW:
432                         case TV_BOLT:
433                         case TV_BOW:
434                         case TV_DIGGING:
435                         case TV_HAFTED:
436                         case TV_POLEARM:
437                         case TV_SWORD:
438                         case TV_BOOTS:
439                         case TV_GLOVES:
440                         case TV_HELM:
441                         case TV_CROWN:
442                         case TV_SHIELD:
443                         case TV_CLOAK:
444                         case TV_SOFT_ARMOR:
445                         case TV_HARD_ARMOR:
446                         case TV_DRAG_ARMOR:
447                         case TV_CARD:
448                         {
449                                 okay = TRUE;
450                                 break;
451                         }
452                 }
453
454                 /* Skip non-sense machines */
455                 if (!okay) continue;
456
457                 /* Occasional failure on inventory items */
458                 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
459
460                 /* Good luck */
461                 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
462                 {
463                         heavy = TRUE;
464                 }
465
466                 sense_inventory_aux(i, heavy);
467         }
468 }
469
470 /*!
471  * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。
472  * @return なし
473  */
474 static void sense_inventory2(void)
475 {
476         int         i;
477         int         plev = p_ptr->lev;
478         object_type *o_ptr;
479
480
481         /*** Check for "sensing" ***/
482
483         /* No sensing when confused */
484         if (p_ptr->confused) return;
485
486         /* Analyze the class */
487         switch (p_ptr->pclass)
488         {
489                 case CLASS_WARRIOR:
490                 case CLASS_ARCHER:
491                 case CLASS_SAMURAI:
492                 case CLASS_CAVALRY:
493                 case CLASS_BERSERKER:
494                 case CLASS_SNIPER:
495                 {
496                         return;
497                 }
498
499                 case CLASS_SMITH:
500                 case CLASS_PALADIN:
501                 case CLASS_CHAOS_WARRIOR:
502                 case CLASS_IMITATOR:
503                 case CLASS_BEASTMASTER:
504                 case CLASS_NINJA:
505                 {
506                         /* Very bad (light) sensing */
507                         if (0 != randint0(240000L / (plev + 5))) return;
508
509                         /* Done */
510                         break;
511                 }
512
513                 case CLASS_RANGER:
514                 case CLASS_WARRIOR_MAGE:
515                 case CLASS_RED_MAGE:
516                 case CLASS_MONK:
517                 {
518                         /* Bad sensing */
519                         if (0 != randint0(95000L / (plev * plev + 40))) return;
520
521                         /* Done */
522                         break;
523                 }
524
525                 case CLASS_PRIEST:
526                 case CLASS_BARD:
527                 case CLASS_ROGUE:
528                 case CLASS_FORCETRAINER:
529                 case CLASS_MINDCRAFTER:
530                 {
531                         /* Good sensing */
532                         if (0 != randint0(20000L / (plev * plev + 40))) return;
533
534                         /* Done */
535                         break;
536                 }
537
538                 case CLASS_MAGE:
539                 case CLASS_HIGH_MAGE:
540                 case CLASS_SORCERER:
541                 case CLASS_MAGIC_EATER:
542                 case CLASS_MIRROR_MASTER:
543                 case CLASS_BLUE_MAGE:
544                 {
545                         /* Good sensing */
546                         if (0 != randint0(9000L / (plev * plev + 40))) return;
547
548                         /* Done */
549                         break;
550                 }
551
552                 case CLASS_TOURIST:
553                 {
554                         /* Good sensing */
555                         if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
556
557                         /* Done */
558                         break;
559                 }
560         }
561
562         /*** Sense everything ***/
563
564         /* Check everything */
565         for (i = 0; i < INVEN_TOTAL; i++)
566         {
567                 bool okay = FALSE;
568
569                 o_ptr = &inventory[i];
570
571                 /* Skip empty slots */
572                 if (!o_ptr->k_idx) continue;
573
574                 /* Valid "tval" codes */
575                 switch (o_ptr->tval)
576                 {
577                         case TV_RING:
578                         case TV_AMULET:
579                         case TV_LITE:
580                         case TV_FIGURINE:
581                         {
582                                 okay = TRUE;
583                                 break;
584                         }
585                 }
586
587                 /* Skip non-sense machines */
588                 if (!okay) continue;
589
590                 /* Occasional failure on inventory items */
591                 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
592
593                 sense_inventory_aux(i, TRUE);
594         }
595 }
596
597 /*!
598  * @brief パターン終点到達時のテレポート処理を行う
599  * @return なし
600  */
601 static void pattern_teleport(void)
602 {
603         int min_level = 0;
604         int max_level = 99;
605
606         /* Ask for level */
607         if (get_check(_("他の階にテレポートしますか?", "Teleport level? ")))
608         {
609                 char    ppp[80];
610                 char    tmp_val[160];
611
612                 /* Only downward in ironman mode */
613                 if (ironman_downward)
614                         min_level = dun_level;
615
616                 /* Maximum level */
617                 if (dungeon_type == DUNGEON_ANGBAND)
618                 {
619                         if (dun_level > 100)
620                                 max_level = MAX_DEPTH - 1;
621                         else if (dun_level == 100)
622                                 max_level = 100;
623                 }
624                 else
625                 {
626                         max_level = d_info[dungeon_type].maxdepth;
627                         min_level = d_info[dungeon_type].mindepth;
628                 }
629
630                 /* Prompt */
631                 sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), min_level, max_level);
632
633                 /* Default */
634                 sprintf(tmp_val, "%d", dun_level);
635
636                 /* Ask for a level */
637                 if (!get_string(ppp, tmp_val, 10)) return;
638
639                 /* Extract request */
640                 command_arg = atoi(tmp_val);
641         }
642         else if (get_check(_("通常テレポート?", "Normal teleport? ")))
643         {
644                 teleport_player(200, 0L);
645                 return;
646         }
647         else
648         {
649                 return;
650         }
651
652         /* Paranoia */
653         if (command_arg < min_level) command_arg = min_level;
654
655         /* Paranoia */
656         if (command_arg > max_level) command_arg = max_level;
657
658         /* Accept request */
659         msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg);
660
661         if (autosave_l) do_cmd_save_game(TRUE);
662
663         /* Change level */
664         dun_level = command_arg;
665
666         leave_quest_check();
667
668         if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
669
670         p_ptr->inside_quest = 0;
671         p_ptr->energy_use = 0;
672
673         /*
674          * Clear all saved floors
675          * and create a first saved floor
676          */
677         prepare_change_floor_mode(CFM_FIRST_FLOOR);
678
679         /* Leaving */
680         p_ptr->leaving = TRUE;
681 }
682
683 /*!
684  * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
685  * @return なし
686  */
687 static void wreck_the_pattern(void)
688 {
689         int to_ruin = 0, r_y, r_x;
690         int pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
691
692         if (pattern_type == PATTERN_TILE_WRECKED)
693         {
694                 /* Ruined already */
695                 return;
696         }
697
698         msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
699         msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
700
701         if (!IS_INVULN())
702                 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
703
704         to_ruin = randint1(45) + 35;
705
706         while (to_ruin--)
707         {
708                 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
709
710                 if (pattern_tile(r_y, r_x) &&
711                     (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
712                 {
713                         cave_set_feat(r_y, r_x, feat_pattern_corrupted);
714                 }
715         }
716
717         cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
718 }
719
720 /*!
721  * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
722  * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
723  */
724 static bool pattern_effect(void)
725 {
726         int pattern_type;
727
728         if (!pattern_tile(p_ptr->y, p_ptr->x)) return FALSE;
729
730         if ((prace_is_(RACE_AMBERITE)) &&
731             (p_ptr->cut > 0) && one_in_(10))
732         {
733                 wreck_the_pattern();
734         }
735
736         pattern_type = f_info[cave[p_ptr->y][p_ptr->x].feat].subtype;
737
738         switch (pattern_type)
739         {
740         case PATTERN_TILE_END:
741                 (void)set_poisoned(0);
742                 (void)set_image(0);
743                 (void)set_stun(0);
744                 (void)set_cut(0);
745                 (void)set_blind(0);
746                 (void)set_afraid(0);
747                 (void)do_res_stat(A_STR);
748                 (void)do_res_stat(A_INT);
749                 (void)do_res_stat(A_WIS);
750                 (void)do_res_stat(A_DEX);
751                 (void)do_res_stat(A_CON);
752                 (void)do_res_stat(A_CHR);
753                 (void)restore_level();
754                 (void)hp_player(1000);
755
756                 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_old);
757                 msg_print(_("「パターン」のこの部分は他の部分より強力でないようだ。", "This section of the Pattern looks less powerful."));
758
759                 /*
760                  * We could make the healing effect of the
761                  * Pattern center one-time only to avoid various kinds
762                  * of abuse, like luring the win monster into fighting you
763                  * in the middle of the pattern...
764                  */
765                 break;
766
767         case PATTERN_TILE_OLD:
768                 /* No effect */
769                 break;
770
771         case PATTERN_TILE_TELEPORT:
772                 pattern_teleport();
773                 break;
774
775         case PATTERN_TILE_WRECKED:
776                 if (!IS_INVULN())
777                         take_hit(DAMAGE_NOESCAPE, 200, _("壊れた「パターン」を歩いたダメージ", "walking the corrupted Pattern"), -1);
778                 break;
779
780         default:
781                 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
782                         return TRUE;
783                 else if (!IS_INVULN())
784                         take_hit(DAMAGE_NOESCAPE, damroll(1, 3), _("「パターン」を歩いたダメージ", "walking the Pattern"), -1);
785                 break;
786         }
787
788         return TRUE;
789 }
790
791
792 /*!
793  * @brief プレイヤーのHP自然回復処理 / Regenerate hit points -RAK-
794  * @param percent 回復比率
795  * @return なし
796  */
797 static void regenhp(int percent)
798 {
799         s32b new_chp;
800         u32b new_chp_frac;
801         s32b old_chp;
802
803         if (p_ptr->special_defense & KATA_KOUKIJIN) return;
804         if (p_ptr->action == ACTION_HAYAGAKE) return;
805
806         /* Save the old hitpoints */
807         old_chp = p_ptr->chp;
808
809         /*
810          * Extract the new hitpoints
811          *
812          * 'percent' is the Regen factor in unit (1/2^16)
813          */
814         new_chp = 0;
815         new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
816
817         /* Convert the unit (1/2^16) to (1/2^32) */
818         s64b_LSHIFT(new_chp, new_chp_frac, 16);
819
820         /* Regenerating */
821         s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
822
823
824         /* Fully healed */
825         if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
826         {
827                 p_ptr->chp = p_ptr->mhp;
828                 p_ptr->chp_frac = 0;
829         }
830
831         /* Notice changes */
832         if (old_chp != p_ptr->chp)
833         {
834                 /* Redraw */
835                 p_ptr->redraw |= (PR_HP);
836
837                 /* Window stuff */
838                 p_ptr->window |= (PW_PLAYER);
839
840                 wild_regen = 20;
841         }
842 }
843
844
845 /*!
846  * @brief プレイヤーのMP自然回復処理(regen_magic()のサブセット) / Regenerate mana points
847  * @param upkeep_factor ペット維持によるMPコスト量
848  * @param regen_amount 回復量
849  * @return なし
850  */
851 static void regenmana(int upkeep_factor, int regen_amount)
852 {
853         s32b old_csp = p_ptr->csp;
854         s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
855
856         /*
857          * Excess mana will decay 32 times faster than normal
858          * regeneration rate.
859          */
860         if (p_ptr->csp > p_ptr->msp)
861         {
862                 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
863                 s32b decay = 0;
864                 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
865
866                 /* Convert the unit (1/2^16) to (1/2^32) */
867                 s64b_LSHIFT(decay, decay_frac, 16);
868
869                 /* Decay */
870                 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
871
872                 /* Stop decaying */
873                 if (p_ptr->csp < p_ptr->msp)
874                 {
875                         p_ptr->csp = p_ptr->msp;
876                         p_ptr->csp_frac = 0;
877                 }
878         }
879
880         /* Regenerating mana (unless the player has excess mana) */
881         else if (regen_rate > 0)
882         {
883                 /* (percent/100) is the Regen factor in unit (1/2^16) */
884                 s32b new_mana = 0;
885                 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
886
887                 /* Convert the unit (1/2^16) to (1/2^32) */
888                 s64b_LSHIFT(new_mana, new_mana_frac, 16);
889
890                 /* Regenerate */
891                 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
892
893                 /* Must set frac to zero even if equal */
894                 if (p_ptr->csp >= p_ptr->msp)
895                 {
896                         p_ptr->csp = p_ptr->msp;
897                         p_ptr->csp_frac = 0;
898                 }
899         }
900
901
902         /* Reduce mana (even when the player has excess mana) */
903         if (regen_rate < 0)
904         {
905                 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
906                 s32b reduce_mana = 0;
907                 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
908
909                 /* Convert the unit (1/2^16) to (1/2^32) */
910                 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
911
912                 /* Reduce mana */
913                 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
914
915                 /* Check overflow */
916                 if (p_ptr->csp < 0)
917                 {
918                         p_ptr->csp = 0;
919                         p_ptr->csp_frac = 0;
920                 }
921         }
922
923
924         /* Redraw mana */
925         if (old_csp != p_ptr->csp)
926         {
927                 /* Redraw */
928                 p_ptr->redraw |= (PR_MANA);
929
930                 /* Window stuff */
931                 p_ptr->window |= (PW_PLAYER);
932                 p_ptr->window |= (PW_SPELL);
933
934                 wild_regen = 20;
935         }
936 }
937
938 /*!
939  * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
940  * @param regen_amount 回復量
941  * @return なし
942  */
943 static void regenmagic(int regen_amount)
944 {
945         s32b new_mana;
946         int i;
947         int dev = 30;
948         int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
949
950         for (i = 0; i < EATER_EXT*2; i++)
951         {
952                 if (!p_ptr->magic_num2[i]) continue;
953                 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
954
955                 /* Increase remaining charge number like float value */
956                 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
957                 p_ptr->magic_num1[i] += new_mana;
958
959                 /* Check maximum charge */
960                 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
961                 {
962                         p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
963                 }
964                 wild_regen = 20;
965         }
966         for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
967         {
968                 if (!p_ptr->magic_num1[i]) continue;
969                 if (!p_ptr->magic_num2[i]) continue;
970
971                 /* Decrease remaining period for charging */
972                 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE) 
973                                         / (dev * 16 * PY_REGEN_NORMAL); 
974                 p_ptr->magic_num1[i] -= new_mana;
975
976                 /* Check minimum remaining period for charging */
977                 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
978                 wild_regen = 20;
979         }
980 }
981
982
983 /*!
984  * @brief 100ゲームターン毎のモンスターのHP自然回復処理 / Regenerate the monsters (once per 100 game turns)
985  * @return なし
986  * @note XXX XXX XXX Should probably be done during monster turns.
987  */
988 static void regen_monsters(void)
989 {
990         int i, frac;
991
992
993         /* Regenerate everyone */
994         for (i = 1; i < m_max; i++)
995         {
996                 /* Check the i'th monster */
997                 monster_type *m_ptr = &m_list[i];
998                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
999
1000
1001                 /* Skip dead monsters */
1002                 if (!m_ptr->r_idx) continue;
1003
1004                 /* Allow regeneration (if needed) */
1005                 if (m_ptr->hp < m_ptr->maxhp)
1006                 {
1007                         /* Hack -- Base regeneration */
1008                         frac = m_ptr->maxhp / 100;
1009
1010                         /* Hack -- Minimal regeneration rate */
1011                         if (!frac) if (one_in_(2)) frac = 1;
1012
1013                         /* Hack -- Some monsters regenerate quickly */
1014                         if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1015
1016                         /* Hack -- Regenerate */
1017                         m_ptr->hp += frac;
1018
1019                         /* Do not over-regenerate */
1020                         if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1021
1022                         /* Redraw (later) if needed */
1023                         if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1024                         if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1025                 }
1026         }
1027 }
1028
1029
1030 /*!
1031  * @brief 30ゲームターン毎のボール中モンスターのHP自然回復処理 / Regenerate the captured monsters (once per 30 game turns)
1032  * @return なし
1033  * @note XXX XXX XXX Should probably be done during monster turns.
1034  */
1035 static void regen_captured_monsters(void)
1036 {
1037         int i, frac;
1038         bool heal = FALSE;
1039
1040         /* Regenerate everyone */
1041         for (i = 0; i < INVEN_TOTAL; i++)
1042         {
1043                 monster_race *r_ptr;
1044                 object_type *o_ptr = &inventory[i];
1045
1046                 if (!o_ptr->k_idx) continue;
1047                 if (o_ptr->tval != TV_CAPTURE) continue;
1048                 if (!o_ptr->pval) continue;
1049
1050                 heal = TRUE;
1051
1052                 r_ptr = &r_info[o_ptr->pval];
1053
1054                 /* Allow regeneration (if needed) */
1055                 if (o_ptr->xtra4 < o_ptr->xtra5)
1056                 {
1057                         /* Hack -- Base regeneration */
1058                         frac = o_ptr->xtra5 / 100;
1059
1060                         /* Hack -- Minimal regeneration rate */
1061                         if (!frac) if (one_in_(2)) frac = 1;
1062
1063                         /* Hack -- Some monsters regenerate quickly */
1064                         if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1065
1066                         /* Hack -- Regenerate */
1067                         o_ptr->xtra4 += frac;
1068
1069                         /* Do not over-regenerate */
1070                         if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1071                 }
1072         }
1073
1074         if (heal)
1075         {
1076                 /* Combine pack */
1077                 p_ptr->notice |= (PN_COMBINE);
1078
1079                 /* Window stuff */
1080                 p_ptr->window |= (PW_INVEN);
1081                 p_ptr->window |= (PW_EQUIP);
1082                 wild_regen = 20;
1083         }
1084 }
1085
1086 /*!
1087  * @brief 寿命つき光源の警告メッセージ処理
1088  * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
1089  * @return なし
1090  */
1091 static void notice_lite_change(object_type *o_ptr)
1092 {
1093         /* Hack -- notice interesting fuel steps */
1094         if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1095         {
1096                 /* Window stuff */
1097                 p_ptr->window |= (PW_EQUIP);
1098         }
1099
1100         /* Hack -- Special treatment when blind */
1101         if (p_ptr->blind)
1102         {
1103                 /* Hack -- save some light for later */
1104                 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1105         }
1106
1107         /* The light is now out */
1108         else if (o_ptr->xtra4 == 0)
1109         {
1110                 disturb(0, 1);
1111                 msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
1112
1113                 /* Recalculate torch radius */
1114                 p_ptr->update |= (PU_TORCH);
1115
1116                 /* Some ego light lose its effects without fuel */
1117                 p_ptr->update |= (PU_BONUS);
1118         }
1119
1120         /* The light is getting dim */
1121         else if (o_ptr->name2 == EGO_LITE_LONG)
1122         {
1123                 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1124                     && (turn % (TURNS_PER_TICK*2)))
1125                 {
1126                         if (disturb_minor) disturb(0, 1);
1127                         msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1128                 }
1129         }
1130
1131         /* The light is getting dim */
1132         else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1133         {
1134                 if (disturb_minor) disturb(0, 1);
1135                         msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
1136         }
1137 }
1138
1139 /*!
1140  * @brief クエスト階層から離脱する際の処理
1141  * @return なし
1142  */
1143 void leave_quest_check(void)
1144 {
1145         /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1146         leaving_quest = p_ptr->inside_quest;
1147
1148         /* Leaving an 'only once' quest marks it as failed */
1149         if (leaving_quest)
1150         {       
1151                 quest_type* const q_ptr = &quest[leaving_quest];
1152                 
1153             if(((q_ptr->flags & QUEST_FLAG_ONCE)  || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1154                (q_ptr->status == QUEST_STATUS_TAKEN))
1155                 {
1156                         q_ptr->status = QUEST_STATUS_FAILED;
1157                         q_ptr->complev = (byte)p_ptr->lev;
1158                         update_playtime();
1159                         q_ptr->comptime = playtime;
1160
1161                         /* Additional settings */
1162                         switch (q_ptr->type)
1163                         {
1164                           case QUEST_TYPE_TOWER:
1165                                 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1166                                 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1167                                 break;
1168                           case QUEST_TYPE_FIND_ARTIFACT:
1169                                 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1170                                 break;
1171                           case QUEST_TYPE_RANDOM:
1172                                 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1173
1174                                 /* Floor of random quest will be blocked */
1175                                 prepare_change_floor_mode(CFM_NO_RETURN);
1176                                 break;
1177                         }
1178
1179                         /* Record finishing a quest */
1180                         if (q_ptr->type == QUEST_TYPE_RANDOM)
1181                         {
1182                                 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1183                         }
1184                         else
1185                         {
1186                                 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1187                         }
1188                 }
1189         }
1190 }
1191
1192 /*!
1193  * @brief 「塔」クエストの各階層から離脱する際の処理
1194  * @return なし
1195  */
1196 void leave_tower_check(void)
1197 {
1198         leaving_quest = p_ptr->inside_quest;
1199         /* Check for Tower Quest */
1200         if (leaving_quest &&
1201                 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1202                 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1203         {
1204                 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1205                 {
1206                         quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1207                         quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1208                         update_playtime();
1209                         quest[QUEST_TOWER1].comptime = playtime;
1210                 }
1211         }
1212 }
1213
1214 /*!
1215  * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1216  * @return なし
1217  * @todo mind.cにこの関数を移動させるべき。
1218  * @note
1219  * currently this function allows pseudo-id of any object,
1220  * including silly ones like potions & scrolls, which always
1221  * get '{average}'. This should be changed, either to stop such
1222  * items from being pseudo-id'd, or to allow psychometry to
1223  * detect whether the unidentified potion/scroll/etc is
1224  * good (Cure Light Wounds, Restore Strength, etc) or
1225  * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1226  */
1227 bool psychometry(void)
1228 {
1229         int             item;
1230         object_type     *o_ptr;
1231         char            o_name[MAX_NLEN];
1232         byte            feel;
1233         cptr            q, s;
1234         bool okay = FALSE;
1235
1236         item_tester_no_ryoute = TRUE;
1237         /* Get an item */
1238         q = _("どのアイテムを調べますか?", "Meditate on which item? ");
1239         s = _("調べるアイテムがありません。", "You have nothing appropriate.");
1240
1241         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1242
1243         /* Get the item (in the pack) */
1244         if (item >= 0)
1245         {
1246                 o_ptr = &inventory[item];
1247         }
1248
1249         /* Get the item (on the floor) */
1250         else
1251         {
1252                 o_ptr = &o_list[0 - item];
1253         }
1254
1255         /* It is fully known, no information needed */
1256         if (object_is_known(o_ptr))
1257         {
1258                 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
1259                 return TRUE;
1260         }
1261
1262         /* Check for a feeling */
1263         feel = value_check_aux1(o_ptr);
1264
1265         /* Get an object description */
1266         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1267
1268         /* Skip non-feelings */
1269         if (!feel)
1270         {
1271                 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
1272                 return TRUE;
1273         }
1274
1275 #ifdef JP
1276 msg_format("%sは%sという感じがする...",
1277     o_name,  game_inscriptions[feel]);
1278 #else
1279         msg_format("You feel that the %s %s %s...",
1280                            o_name, ((o_ptr->number == 1) ? "is" : "are"),
1281                            game_inscriptions[feel]);
1282 #endif
1283
1284
1285         /* We have "felt" it */
1286         o_ptr->ident |= (IDENT_SENSE);
1287
1288         /* "Inscribe" it */
1289         o_ptr->feeling = feel;
1290
1291         /* Player touches it */
1292         o_ptr->marked |= OM_TOUCHED;
1293
1294         /* Combine / Reorder the pack (later) */
1295         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1296
1297         /* Window stuff */
1298         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1299
1300         /* Valid "tval" codes */
1301         switch (o_ptr->tval)
1302         {
1303         case TV_SHOT:
1304         case TV_ARROW:
1305         case TV_BOLT:
1306         case TV_BOW:
1307         case TV_DIGGING:
1308         case TV_HAFTED:
1309         case TV_POLEARM:
1310         case TV_SWORD:
1311         case TV_BOOTS:
1312         case TV_GLOVES:
1313         case TV_HELM:
1314         case TV_CROWN:
1315         case TV_SHIELD:
1316         case TV_CLOAK:
1317         case TV_SOFT_ARMOR:
1318         case TV_HARD_ARMOR:
1319         case TV_DRAG_ARMOR:
1320         case TV_CARD:
1321         case TV_RING:
1322         case TV_AMULET:
1323         case TV_LITE:
1324         case TV_FIGURINE:
1325                 okay = TRUE;
1326                 break;
1327         }
1328
1329         /* Auto-inscription/destroy */
1330         autopick_alter_item(item, (bool)(okay && destroy_feeling));
1331
1332         /* Something happened */
1333         return (TRUE);
1334 }
1335
1336 /*!
1337  * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1338  * @param o_ptr 対象オブジェクトの構造体参照ポインタ
1339  * @return なし
1340  */
1341 static void recharged_notice(object_type *o_ptr)
1342 {
1343         char o_name[MAX_NLEN];
1344
1345         cptr s;
1346
1347         /* No inscription */
1348         if (!o_ptr->inscription) return;
1349
1350         /* Find a '!' */
1351         s = my_strchr(quark_str(o_ptr->inscription), '!');
1352
1353         /* Process notification request. */
1354         while (s)
1355         {
1356                 /* Find another '!' */
1357                 if (s[1] == '!')
1358                 {
1359                         /* Describe (briefly) */
1360                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1361
1362                         /* Notify the player */
1363 #ifdef JP
1364                         msg_format("%sは再充填された。", o_name);
1365 #else
1366                         if (o_ptr->number > 1)
1367                                 msg_format("Your %s are recharged.", o_name);
1368                         else
1369                                 msg_format("Your %s is recharged.", o_name);
1370 #endif
1371
1372                         disturb(0, 0);
1373
1374                         /* Done. */
1375                         return;
1376                 }
1377
1378                 /* Keep looking for '!'s */
1379                 s = my_strchr(s + 1, '!');
1380         }
1381 }
1382
1383 /*!
1384  * @brief プレイヤーの歌に関する継続処理
1385  * @return なし
1386  */
1387 static void check_music(void)
1388 {
1389         const magic_type *s_ptr;
1390         int spell;
1391         s32b need_mana;
1392         u32b need_mana_frac;
1393
1394         /* Music singed by player */
1395         if (p_ptr->pclass != CLASS_BARD) return;
1396         if (!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return;
1397
1398         if (p_ptr->anti_magic)
1399         {
1400                 stop_singing();
1401                 return;
1402         }
1403
1404         spell = p_ptr->magic_num2[0];
1405         s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1406
1407         need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1408         need_mana_frac = 0;
1409
1410         /* Divide by 2 */
1411         s64b_RSHIFT(need_mana, need_mana_frac, 1);
1412
1413         if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1414         {
1415                 stop_singing();
1416                 return;
1417         }
1418         else
1419         {
1420                 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1421
1422                 p_ptr->redraw |= PR_MANA;
1423                 if (p_ptr->magic_num1[1])
1424                 {
1425                         p_ptr->magic_num1[0] = p_ptr->magic_num1[1];
1426                         p_ptr->magic_num1[1] = 0;
1427                         msg_print(_("歌を再開した。", "You restart singing."));
1428                         p_ptr->action = ACTION_SING;
1429
1430                         /* Recalculate bonuses */
1431                         p_ptr->update |= (PU_BONUS | PU_HP);
1432
1433                         /* Redraw map and status bar */
1434                         p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1435
1436                         /* Update monsters */
1437                         p_ptr->update |= (PU_MONSTERS);
1438
1439                         /* Window stuff */
1440                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1441                 }
1442         }
1443         if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1444                 p_ptr->spell_exp[spell] += 5;
1445         else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1446         { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1447         else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1448         { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1449         else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1450         { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1451
1452         /* Do any effects of continual song */
1453         do_spell(REALM_MUSIC, spell, SPELL_CONT);
1454 }
1455
1456 /*!
1457  * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag
1458  * @param flag 探し出したい呪いフラグ配列
1459  * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
1460  * 呪いがない場合NULLを返す。
1461  */
1462 static object_type *choose_cursed_obj_name(u32b flag)
1463 {
1464         int i;
1465         int choices[INVEN_TOTAL-INVEN_RARM];
1466         int number = 0;
1467
1468         /* Paranoia -- Player has no warning-item */
1469         if (!(p_ptr->cursed & flag)) return NULL;
1470
1471         /* Search Inventry */
1472         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1473         {
1474                 object_type *o_ptr = &inventory[i];
1475
1476                 if (o_ptr->curse_flags & flag)
1477                 {
1478                         choices[number] = i;
1479                         number++;
1480                 }
1481                 else if ((flag == TRC_ADD_L_CURSE) || 
1482                                         (flag == TRC_ADD_H_CURSE) || 
1483                                         (flag == TRC_DRAIN_HP) || 
1484                                         (flag == TRC_DRAIN_MANA) || 
1485                                         (flag == TRC_CALL_ANIMAL) || 
1486                                         (flag == TRC_CALL_DEMON) || 
1487                                         (flag == TRC_CALL_DRAGON) || 
1488                                         (flag == TRC_CALL_UNDEAD) || 
1489                                         (flag == TRC_COWARDICE) || 
1490                                         (flag == TRC_LOW_MELEE) || 
1491                                         (flag == TRC_LOW_AC) || 
1492                                         (flag == TRC_LOW_MAGIC) || 
1493                                         (flag == TRC_FAST_DIGEST) || 
1494                                         (flag == TRC_SLOW_REGEN) )
1495                 {
1496                         u32b cf;
1497                         u32b flgs[TR_FLAG_SIZE];
1498                         object_flags(o_ptr, flgs);
1499                         switch (flag)
1500                         {
1501                           case TRC_ADD_L_CURSE  : cf = TR_ADD_L_CURSE; break;
1502                           case TRC_ADD_H_CURSE  : cf = TR_ADD_H_CURSE; break;
1503                           case TRC_DRAIN_HP             : cf = TR_DRAIN_HP; break;
1504                           case TRC_DRAIN_MANA   : cf = TR_DRAIN_MANA; break;
1505                           case TRC_CALL_ANIMAL  : cf = TR_CALL_ANIMAL; break;
1506                           case TRC_CALL_DEMON   : cf = TR_CALL_DEMON; break;
1507                           case TRC_CALL_DRAGON  : cf = TR_CALL_DRAGON; break;
1508                           case TRC_CALL_UNDEAD  : cf = TR_CALL_UNDEAD; break;
1509                           case TRC_COWARDICE    : cf = TR_COWARDICE; break;
1510                           case TRC_LOW_MELEE    : cf = TR_LOW_MELEE; break;
1511                           case TRC_LOW_AC               : cf = TR_LOW_AC; break;
1512                           case TRC_LOW_MAGIC    : cf = TR_LOW_MAGIC; break;
1513                           case TRC_FAST_DIGEST  : cf = TR_FAST_DIGEST; break;
1514                           case TRC_SLOW_REGEN   : cf = TR_SLOW_REGEN; break;
1515                           default                               : break;
1516                         }
1517                         if (have_flag(flgs, cf))
1518                         {
1519                                 choices[number] = i;
1520                                 number++;
1521                         }
1522                 }
1523         }
1524
1525         /* Choice one of them */
1526         return (&inventory[choices[randint0(number)]]);
1527 }
1528
1529 /*!
1530  * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
1531  *  / Handle timed damage and regeneration every 10 game turns
1532  * @return なし
1533  */
1534 static void process_world_aux_hp_and_sp(void)
1535 {
1536         feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
1537         bool cave_no_regen = FALSE;
1538         int upkeep_factor = 0;
1539
1540         /* Default regeneration */
1541         int regen_amount = PY_REGEN_NORMAL;
1542
1543
1544         /*** Damage over Time ***/
1545
1546         /* Take damage from poison */
1547         if (p_ptr->poisoned && !IS_INVULN())
1548         {
1549                 /* Take damage */
1550                 take_hit(DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
1551         }
1552
1553         /* Take damage from cuts */
1554         if (p_ptr->cut && !IS_INVULN())
1555         {
1556                 int dam;
1557
1558                 /* Mortal wound or Deep Gash */
1559                 if (p_ptr->cut > 1000)
1560                 {
1561                         dam = 200;
1562                 }
1563
1564                 else if (p_ptr->cut > 200)
1565                 {
1566                         dam = 80;
1567                 }
1568
1569                 /* Severe cut */
1570                 else if (p_ptr->cut > 100)
1571                 {
1572                         dam = 32;
1573                 }
1574
1575                 else if (p_ptr->cut > 50)
1576                 {
1577                         dam = 16;
1578                 }
1579
1580                 else if (p_ptr->cut > 25)
1581                 {
1582                         dam = 7;
1583                 }
1584
1585                 else if (p_ptr->cut > 10)
1586                 {
1587                         dam = 3;
1588                 }
1589
1590                 /* Other cuts */
1591                 else
1592                 {
1593                         dam = 1;
1594                 }
1595
1596                 /* Take damage */
1597                 take_hit(DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
1598         }
1599
1600
1601         /* (Vampires) Take damage from sunlight */
1602         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1603         {
1604                 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1605                 {
1606                         if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1607                         {
1608                                 /* Take damage */
1609                                 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
1610                                 take_hit(DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
1611
1612                                 cave_no_regen = TRUE;
1613                         }
1614                 }
1615
1616                 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1617                     !p_ptr->resist_lite)
1618                 {
1619                         object_type * o_ptr = &inventory[INVEN_LITE];
1620                         char o_name [MAX_NLEN];
1621                         char ouch [MAX_NLEN+40];
1622
1623                         /* Get an object description */
1624                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1625                         msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
1626
1627                         cave_no_regen = TRUE;
1628
1629                         /* Get an object description */
1630                         object_desc(o_name, o_ptr, OD_NAME_ONLY);
1631                         sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
1632
1633                         if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1634                 }
1635         }
1636
1637         if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1638         {
1639                 int damage = 0;
1640
1641                 if (have_flag(f_ptr->flags, FF_DEEP))
1642                 {
1643                         damage = 6000 + randint0(4000);
1644                 }
1645                 else if (!p_ptr->levitation)
1646                 {
1647                         damage = 3000 + randint0(2000);
1648                 }
1649
1650                 if (damage)
1651                 {
1652                         if (prace_is_(RACE_ENT)) damage += damage / 3;
1653                         if (p_ptr->resist_fire) damage = damage / 3;
1654                         if (IS_OPPOSE_FIRE()) damage = damage / 3;
1655
1656                         if (p_ptr->levitation) damage = damage / 5;
1657
1658                         damage = damage / 100 + (randint0(100) < (damage % 100));
1659
1660                         if (p_ptr->levitation)
1661                         {
1662                                 msg_print(_("熱で火傷した!", "The heat burns you!"));
1663                                 take_hit(DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), 
1664                                                                 f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name), -1);
1665                         }
1666                         else
1667                         {
1668                                 cptr name = f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name;
1669                                 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
1670                                 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1671                         }
1672
1673                         cave_no_regen = TRUE;
1674                 }
1675         }
1676
1677         if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1678             !p_ptr->levitation && !p_ptr->can_swim)
1679         {
1680                 if (p_ptr->total_weight > weight_limit())
1681                 {
1682                         /* Take damage */
1683                         msg_print(_("溺れている!", "You are drowning!"));
1684                         take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), _("溺れ", "drowning"), -1);
1685                         cave_no_regen = TRUE;
1686                 }
1687         }
1688
1689         if (p_ptr->riding)
1690         {
1691                 int damage;
1692                 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1693                 {
1694                         damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1695                         if (prace_is_(RACE_ENT)) damage += damage / 3;
1696                         if (p_ptr->resist_fire) damage = damage / 3;
1697                         if (IS_OPPOSE_FIRE()) damage = damage / 3;
1698                         msg_print(_("熱い!", "It's hot!"));
1699                         take_hit(DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
1700                 }
1701                 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1702                 {
1703                         damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1704                         if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1705                         if (p_ptr->resist_elec) damage = damage / 3;
1706                         if (IS_OPPOSE_ELEC()) damage = damage / 3;
1707                         msg_print(_("痛い!", "It hurts!"));
1708                         take_hit(DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
1709                 }
1710                 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1711                 {
1712                         damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1713                         if (p_ptr->resist_cold) damage = damage / 3;
1714                         if (IS_OPPOSE_COLD()) damage = damage / 3;
1715                         msg_print(_("冷たい!", "It's cold!"));
1716                         take_hit(DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
1717                 }
1718         }
1719
1720         /* Spectres -- take damage when moving through walls */
1721         /*
1722          * Added: ANYBODY takes damage if inside through walls
1723          * without wraith form -- NOTE: Spectres will never be
1724          * reduced below 0 hp by being inside a stone wall; others
1725          * WILL BE!
1726          */
1727         if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1728         {
1729                 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1730                     ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1731                 {
1732                         cptr dam_desc;
1733
1734                         cave_no_regen = TRUE;
1735
1736                         if (p_ptr->pass_wall)
1737                         {
1738                                 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
1739                                 dam_desc = _("密度", "density");
1740                         }
1741                         else
1742                         {
1743                                 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
1744                                 dam_desc = _("硬い岩", "solid rock");
1745                         }
1746
1747                         take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1748                 }
1749         }
1750
1751
1752         /*** handle regeneration ***/
1753
1754         /* Getting Weak */
1755         if (p_ptr->food < PY_FOOD_WEAK)
1756         {
1757                 /* Lower regeneration */
1758                 if (p_ptr->food < PY_FOOD_STARVE)
1759                 {
1760                         regen_amount = 0;
1761                 }
1762                 else if (p_ptr->food < PY_FOOD_FAINT)
1763                 {
1764                         regen_amount = PY_REGEN_FAINT;
1765                 }
1766                 else
1767                 {
1768                         regen_amount = PY_REGEN_WEAK;
1769                 }
1770         }
1771
1772         /* Are we walking the pattern? */
1773         if (pattern_effect())
1774         {
1775                 cave_no_regen = TRUE;
1776         }
1777         else
1778         {
1779                 /* Regeneration ability */
1780                 if (p_ptr->regenerate)
1781                 {
1782                         regen_amount = regen_amount * 2;
1783                 }
1784                 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1785                 {
1786                         regen_amount /= 2;
1787                 }
1788                 if (p_ptr->cursed & TRC_SLOW_REGEN)
1789                 {
1790                         regen_amount /= 5;
1791                 }
1792         }
1793
1794
1795         /* Searching or Resting */
1796         if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1797         {
1798                 regen_amount = regen_amount * 2;
1799         }
1800
1801         upkeep_factor = calculate_upkeep();
1802
1803         /* No regeneration while special action */
1804         if ((p_ptr->action == ACTION_LEARN) ||
1805             (p_ptr->action == ACTION_HAYAGAKE) ||
1806             (p_ptr->special_defense & KATA_KOUKIJIN))
1807         {
1808                 upkeep_factor += 100;
1809         }
1810
1811         /* Regenerate the mana */
1812         regenmana(upkeep_factor, regen_amount);
1813
1814
1815         /* Recharge magic eater's power */
1816         if (p_ptr->pclass == CLASS_MAGIC_EATER)
1817         {
1818                 regenmagic(regen_amount);
1819         }
1820
1821         if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1822         {
1823                 while (upkeep_factor > 100)
1824                 {
1825                         msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
1826                         msg_print(NULL);
1827                         do_cmd_pet_dismiss();
1828
1829                         upkeep_factor = calculate_upkeep();
1830
1831                         msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
1832                         msg_print(NULL);
1833                 }
1834         }
1835
1836         /* Poisoned or cut yields no healing */
1837         if (p_ptr->poisoned) regen_amount = 0;
1838         if (p_ptr->cut) regen_amount = 0;
1839
1840         /* Special floor -- Pattern, in a wall -- yields no healing */
1841         if (cave_no_regen) regen_amount = 0;
1842
1843         regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1844
1845         /* Regenerate Hit Points if needed */
1846         if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1847         {
1848                 regenhp(regen_amount);
1849         }
1850 }
1851
1852 /*!
1853  * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理
1854  * / Handle timeout every 10 game turns
1855  * @return なし
1856  */
1857 static void process_world_aux_timeout(void)
1858 {
1859         const int dec_count = (easy_band ? 2 : 1);
1860
1861         /*** Timeout Various Things ***/
1862
1863         /* Mimic */
1864         if (p_ptr->tim_mimic)
1865         {
1866                 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
1867         }
1868
1869         /* Hack -- Hallucinating */
1870         if (p_ptr->image)
1871         {
1872                 (void)set_image(p_ptr->image - dec_count);
1873         }
1874
1875         /* Blindness */
1876         if (p_ptr->blind)
1877         {
1878                 (void)set_blind(p_ptr->blind - dec_count);
1879         }
1880
1881         /* Times see-invisible */
1882         if (p_ptr->tim_invis)
1883         {
1884                 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
1885         }
1886
1887         if (multi_rew)
1888         {
1889                 multi_rew = FALSE;
1890         }
1891
1892         /* Timed esp */
1893         if (p_ptr->tim_esp)
1894         {
1895                 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
1896         }
1897
1898         /* Timed temporary elemental brands. -LM- */
1899         if (p_ptr->ele_attack)
1900         {
1901                 p_ptr->ele_attack--;
1902
1903                 /* Clear all temporary elemental brands. */
1904                 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
1905         }
1906
1907         /* Timed temporary elemental immune. -LM- */
1908         if (p_ptr->ele_immune)
1909         {
1910                 p_ptr->ele_immune--;
1911
1912                 /* Clear all temporary elemental brands. */
1913                 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
1914         }
1915
1916         /* Timed infra-vision */
1917         if (p_ptr->tim_infra)
1918         {
1919                 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
1920         }
1921
1922         /* Timed stealth */
1923         if (p_ptr->tim_stealth)
1924         {
1925                 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
1926         }
1927
1928         /* Timed levitation */
1929         if (p_ptr->tim_levitation)
1930         {
1931                 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
1932         }
1933
1934         /* Timed sh_touki */
1935         if (p_ptr->tim_sh_touki)
1936         {
1937                 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
1938         }
1939
1940         /* Timed sh_fire */
1941         if (p_ptr->tim_sh_fire)
1942         {
1943                 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
1944         }
1945
1946         /* Timed sh_holy */
1947         if (p_ptr->tim_sh_holy)
1948         {
1949                 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
1950         }
1951
1952         /* Timed eyeeye */
1953         if (p_ptr->tim_eyeeye)
1954         {
1955                 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
1956         }
1957
1958         /* Timed resist-magic */
1959         if (p_ptr->resist_magic)
1960         {
1961                 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
1962         }
1963
1964         /* Timed regeneration */
1965         if (p_ptr->tim_regen)
1966         {
1967                 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
1968         }
1969
1970         /* Timed resist nether */
1971         if (p_ptr->tim_res_nether)
1972         {
1973                 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
1974         }
1975
1976         /* Timed resist time */
1977         if (p_ptr->tim_res_time)
1978         {
1979                 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
1980         }
1981
1982         /* Timed reflect */
1983         if (p_ptr->tim_reflect)
1984         {
1985                 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
1986         }
1987
1988         /* Multi-shadow */
1989         if (p_ptr->multishadow)
1990         {
1991                 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
1992         }
1993
1994         /* Timed Robe of dust */
1995         if (p_ptr->dustrobe)
1996         {
1997                 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
1998         }
1999
2000         /* Timed infra-vision */
2001         if (p_ptr->kabenuke)
2002         {
2003                 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2004         }
2005
2006         /* Paralysis */
2007         if (p_ptr->paralyzed)
2008         {
2009                 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2010         }
2011
2012         /* Confusion */
2013         if (p_ptr->confused)
2014         {
2015                 (void)set_confused(p_ptr->confused - dec_count);
2016         }
2017
2018         /* Afraid */
2019         if (p_ptr->afraid)
2020         {
2021                 (void)set_afraid(p_ptr->afraid - dec_count);
2022         }
2023
2024         /* Fast */
2025         if (p_ptr->fast)
2026         {
2027                 (void)set_fast(p_ptr->fast - 1, TRUE);
2028         }
2029
2030         /* Slow */
2031         if (p_ptr->slow)
2032         {
2033                 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2034         }
2035
2036         /* Protection from evil */
2037         if (p_ptr->protevil)
2038         {
2039                 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2040         }
2041
2042         /* Invulnerability */
2043         if (p_ptr->invuln)
2044         {
2045                 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2046         }
2047
2048         /* Wraith form */
2049         if (p_ptr->wraith_form)
2050         {
2051                 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2052         }
2053
2054         /* Heroism */
2055         if (p_ptr->hero)
2056         {
2057                 (void)set_hero(p_ptr->hero - 1, TRUE);
2058         }
2059
2060         /* Super Heroism */
2061         if (p_ptr->shero)
2062         {
2063                 (void)set_shero(p_ptr->shero - 1, TRUE);
2064         }
2065
2066         /* Blessed */
2067         if (p_ptr->blessed)
2068         {
2069                 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2070         }
2071
2072         /* Shield */
2073         if (p_ptr->shield)
2074         {
2075                 (void)set_shield(p_ptr->shield - 1, TRUE);
2076         }
2077
2078         /* Tsubureru */
2079         if (p_ptr->tsubureru)
2080         {
2081                 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2082         }
2083
2084         /* Magicdef */
2085         if (p_ptr->magicdef)
2086         {
2087                 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2088         }
2089
2090         /* Tsuyoshi */
2091         if (p_ptr->tsuyoshi)
2092         {
2093                 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2094         }
2095
2096         /* Oppose Acid */
2097         if (p_ptr->oppose_acid)
2098         {
2099                 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2100         }
2101
2102         /* Oppose Lightning */
2103         if (p_ptr->oppose_elec)
2104         {
2105                 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2106         }
2107
2108         /* Oppose Fire */
2109         if (p_ptr->oppose_fire)
2110         {
2111                 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2112         }
2113
2114         /* Oppose Cold */
2115         if (p_ptr->oppose_cold)
2116         {
2117                 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2118         }
2119
2120         /* Oppose Poison */
2121         if (p_ptr->oppose_pois)
2122         {
2123                 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2124         }
2125
2126         if (p_ptr->ult_res)
2127         {
2128                 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2129         }
2130
2131         /*** Poison and Stun and Cut ***/
2132
2133         /* Poison */
2134         if (p_ptr->poisoned)
2135         {
2136                 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2137
2138                 /* Apply some healing */
2139                 (void)set_poisoned(p_ptr->poisoned - adjust);
2140         }
2141
2142         /* Stun */
2143         if (p_ptr->stun)
2144         {
2145                 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2146
2147                 /* Apply some healing */
2148                 (void)set_stun(p_ptr->stun - adjust);
2149         }
2150
2151         /* Cut */
2152         if (p_ptr->cut)
2153         {
2154                 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2155
2156                 /* Hack -- Truly "mortal" wound */
2157                 if (p_ptr->cut > 1000) adjust = 0;
2158
2159                 /* Apply some healing */
2160                 (void)set_cut(p_ptr->cut - adjust);
2161         }
2162 }
2163
2164
2165 /*!
2166  * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
2167  * / Handle burning fuel every 10 game turns
2168  * @return なし
2169  */
2170 static void process_world_aux_light(void)
2171 {
2172         /* Check for light being wielded */
2173         object_type *o_ptr = &inventory[INVEN_LITE];
2174
2175         /* Burn some fuel in the current lite */
2176         if (o_ptr->tval == TV_LITE)
2177         {
2178                 /* Hack -- Use some fuel (except on artifacts) */
2179                 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2180                 {
2181                         /* Decrease life-span */
2182                         if (o_ptr->name2 == EGO_LITE_LONG)
2183                         {
2184                                 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2185                         }
2186                         else o_ptr->xtra4--;
2187
2188                         /* Notice interesting fuel steps */
2189                         notice_lite_change(o_ptr);
2190                 }
2191         }
2192 }
2193
2194
2195 /*!
2196  * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
2197  * / Handle mutation effects once every 10 game turns
2198  * @return なし
2199  */
2200 static void process_world_aux_mutation(void)
2201 {
2202         /* No mutation with effects */
2203         if (!p_ptr->muta2) return;
2204
2205         /* No effect on monster arena */
2206         if (p_ptr->inside_battle) return;
2207
2208         /* No effect on the global map */
2209         if (p_ptr->wild_mode) return;
2210
2211
2212         if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2213         {
2214                 disturb(0, 1);
2215                 msg_print(_("ウガァァア!", "RAAAAGHH!"));
2216                 msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
2217
2218                 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2219                 (void)set_afraid(0);
2220         }
2221
2222         if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2223         {
2224                 if (!p_ptr->resist_fear)
2225                 {
2226                         disturb(0, 1);
2227                         msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2228                         set_afraid(p_ptr->afraid + 13 + randint1(26));
2229                 }
2230         }
2231
2232         if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2233         {
2234                 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2235                     !p_ptr->anti_tele)
2236                 {
2237                         disturb(0, 1);
2238
2239                         /* Teleport player */
2240                         msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
2241                         msg_print(NULL);
2242                         teleport_player(40, TELEPORT_PASSIVE);
2243                 }
2244         }
2245
2246         if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2247         {
2248                 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2249                 {
2250                         disturb(0, 1);
2251                         p_ptr->redraw |= PR_EXTRA;
2252                         msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
2253                 }
2254
2255                 if (!p_ptr->resist_conf)
2256                 {
2257                         (void)set_confused(p_ptr->confused + randint0(20) + 15);
2258                 }
2259
2260                 if (!p_ptr->resist_chaos)
2261                 {
2262                         if (one_in_(20))
2263                         {
2264                                 msg_print(NULL);
2265                                 if (one_in_(3)) lose_all_info();
2266                                 else wiz_dark();
2267                                 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2268                                 wiz_dark();
2269                                 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
2270                                 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!"));
2271                         }
2272                         else
2273                         {
2274                                 if (one_in_(3))
2275                                 {
2276                                         msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
2277                                         (void)set_image(p_ptr->image + randint0(150) + 150);
2278                                 }
2279                         }
2280                 }
2281         }
2282
2283         if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2284         {
2285                 if (!p_ptr->resist_chaos)
2286                 {
2287                         disturb(0, 1);
2288                         p_ptr->redraw |= PR_EXTRA;
2289                         (void)set_image(p_ptr->image + randint0(50) + 20);
2290                 }
2291         }
2292
2293         if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2294         {
2295                 disturb(0, 1);
2296
2297                 msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
2298
2299                 msg_print(NULL);
2300                 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2301         }
2302
2303         if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2304             !p_ptr->anti_magic && one_in_(9000))
2305         {
2306                 int dire = 0;
2307                 disturb(0, 1);
2308                 msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!", 
2309                                                 "Magical energy flows through you! You must release it!"));
2310
2311                 flush();
2312                 msg_print(NULL);
2313                 (void)get_hack_dir(&dire);
2314                 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2315         }
2316
2317         if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2318             !p_ptr->anti_magic && (randint1(6666) == 666))
2319         {
2320                 bool pet = one_in_(6);
2321                 u32b mode = PM_ALLOW_GROUP;
2322
2323                 if (pet) mode |= PM_FORCE_PET;
2324                 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2325
2326                 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x,
2327                                     dun_level, SUMMON_DEMON, mode))
2328                 {
2329                         msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
2330                         disturb(0, 1);
2331                 }
2332         }
2333
2334         if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2335         {
2336                 disturb(0, 1);
2337                 if (one_in_(2))
2338                 {
2339                         msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
2340
2341                         if (p_ptr->fast > 0)
2342                         {
2343                                 set_fast(0, TRUE);
2344                         }
2345                         else
2346                         {
2347                                 set_slow(randint1(30) + 10, FALSE);
2348                         }
2349                 }
2350                 else
2351                 {
2352                         msg_print(_("精力的になった気がする。", "You feel more energetic."));
2353
2354                         if (p_ptr->slow > 0)
2355                         {
2356                                 set_slow(0, TRUE);
2357                         }
2358                         else
2359                         {
2360                                 set_fast(randint1(30) + 10, FALSE);
2361                         }
2362                 }
2363                 msg_print(NULL);
2364         }
2365         if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2366         {
2367                 disturb(0, 1);
2368                 msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
2369
2370                 banish_monsters(100);
2371                 if (!dun_level && p_ptr->town_num)
2372                 {
2373                         int n;
2374
2375                         /* Pick a random shop (except home) */
2376                         do
2377                         {
2378                                 n = randint0(MAX_STORES);
2379                         }
2380                         while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2381
2382                         msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
2383                         store_shuffle(n);
2384                 }
2385                 msg_print(NULL);
2386         }
2387
2388         if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2389         {
2390                 object_type *o_ptr;
2391
2392                 msg_print(_("影につつまれた。", "A shadow passes over you."));
2393                 msg_print(NULL);
2394
2395                 /* Absorb light from the current possition */
2396                 if ((cave[p_ptr->y][p_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2397                 {
2398                         hp_player(10);
2399                 }
2400
2401                 o_ptr = &inventory[INVEN_LITE];
2402
2403                 /* Absorb some fuel in the current lite */
2404                 if (o_ptr->tval == TV_LITE)
2405                 {
2406                         /* Use some fuel (except on artifacts) */
2407                         if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2408                         {
2409                                 /* Heal the player a bit */
2410                                 hp_player(o_ptr->xtra4 / 20);
2411
2412                                 /* Decrease life-span of lite */
2413                                 o_ptr->xtra4 /= 2;
2414                                 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
2415
2416                                 /* Notice interesting fuel steps */
2417                                 notice_lite_change(o_ptr);
2418                         }
2419                 }
2420
2421                 /*
2422                  * Unlite the area (radius 10) around player and
2423                  * do 50 points damage to every affected monster
2424                  */
2425                 unlite_area(50, 10);
2426         }
2427
2428         if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2429             !p_ptr->anti_magic && one_in_(7000))
2430         {
2431                 bool pet = one_in_(3);
2432                 u32b mode = PM_ALLOW_GROUP;
2433
2434                 if (pet) mode |= PM_FORCE_PET;
2435                 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2436
2437                 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL, mode))
2438                 {
2439                         msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
2440                         disturb(0, 1);
2441                 }
2442         }
2443
2444         if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2445             !p_ptr->anti_magic && one_in_(8000))
2446         {
2447                 disturb(0, 1);
2448                 msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
2449
2450                 msg_print(NULL);
2451                 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2452         }
2453         if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2454         {
2455                 if (!lose_mutation(0))
2456                         msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
2457         }
2458         if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2459         {
2460                 disturb(0, 1);
2461                 msg_print(_("非物質化した!", "You feel insubstantial!"));
2462
2463                 msg_print(NULL);
2464                 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2465         }
2466         if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2467         {
2468                 do_poly_wounds();
2469         }
2470         if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2471         {
2472                 int which_stat = randint0(6);
2473                 int sustained = FALSE;
2474
2475                 switch (which_stat)
2476                 {
2477                 case A_STR:
2478                         if (p_ptr->sustain_str) sustained = TRUE;
2479                         break;
2480                 case A_INT:
2481                         if (p_ptr->sustain_int) sustained = TRUE;
2482                         break;
2483                 case A_WIS:
2484                         if (p_ptr->sustain_wis) sustained = TRUE;
2485                         break;
2486                 case A_DEX:
2487                         if (p_ptr->sustain_dex) sustained = TRUE;
2488                         break;
2489                 case A_CON:
2490                         if (p_ptr->sustain_con) sustained = TRUE;
2491                         break;
2492                 case A_CHR:
2493                         if (p_ptr->sustain_chr) sustained = TRUE;
2494                         break;
2495                 default:
2496                         msg_print(_("不正な状態!", "Invalid stat chosen!"));
2497                         sustained = TRUE;
2498                 }
2499
2500                 if (!sustained)
2501                 {
2502                         disturb(0, 1);
2503                         msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
2504                         msg_print(NULL);
2505                         (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2506                 }
2507         }
2508         if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2509             !p_ptr->anti_magic && one_in_(3000))
2510         {
2511                 bool pet = one_in_(5);
2512                 u32b mode = PM_ALLOW_GROUP;
2513
2514                 if (pet) mode |= PM_FORCE_PET;
2515                 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2516
2517                 if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON, mode))
2518                 {
2519                         msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
2520                         disturb(0, 1);
2521                 }
2522         }
2523         if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2524             one_in_(3000))
2525         {
2526                 if (p_ptr->tim_esp > 0)
2527                 {
2528                         msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
2529                         set_tim_esp(0, TRUE);
2530                 }
2531                 else
2532                 {
2533                         msg_print(_("精神が広がった!", "Your mind expands!"));
2534                         set_tim_esp(p_ptr->lev, FALSE);
2535                 }
2536         }
2537         if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2538             one_in_(9000))
2539         {
2540                 disturb(0, 1);
2541                 msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
2542                 msg_print(NULL);
2543                 set_food(PY_FOOD_WEAK);
2544                 if (music_singing_any()) stop_singing();
2545                 if (hex_spelling_any()) stop_hex_spell_all();
2546         }
2547
2548         if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2549             !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2550         {
2551                 alter_reality();
2552         }
2553
2554         if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2555         {
2556                 int danger_amount = 0;
2557                 int monster;
2558
2559                 for (monster = 0; monster < m_max; monster++)
2560                 {
2561                         monster_type    *m_ptr = &m_list[monster];
2562                         monster_race    *r_ptr = &r_info[m_ptr->r_idx];
2563
2564                         /* Paranoia -- Skip dead monsters */
2565                         if (!m_ptr->r_idx) continue;
2566
2567                         if (r_ptr->level >= p_ptr->lev)
2568                         {
2569                                 danger_amount += r_ptr->level - p_ptr->lev + 1;
2570                         }
2571                 }
2572
2573                 if (danger_amount > 100)
2574                         msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
2575                 else if (danger_amount > 50)
2576                         msg_print(_("恐ろしい気がする!", "You feel terrified!"));
2577                 else if (danger_amount > 20)
2578                         msg_print(_("非常に心配な気がする!", "You feel very worried!"));
2579                 else if (danger_amount > 10)
2580                         msg_print(_("心配な気がする!", "You feel paranoid!"));
2581                 else if (danger_amount > 5)
2582                         msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
2583                 else
2584                         msg_print(_("寂しい気がする。", "You feel lonely."));
2585         }
2586         if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2587             one_in_(5000))
2588         {
2589                 disturb(0, 1);
2590                 msg_print(_("無敵な気がする!", "You feel invincible!"));
2591                 msg_print(NULL);
2592                 (void)set_invuln(randint1(8) + 8, FALSE);
2593         }
2594         if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2595         {
2596                 int wounds = p_ptr->mhp - p_ptr->chp;
2597
2598                 if (wounds > 0)
2599                 {
2600                         int healing = p_ptr->csp;
2601
2602                         if (healing > wounds)
2603                         {
2604                                 healing = wounds;
2605                         }
2606
2607                         hp_player(healing);
2608                         p_ptr->csp -= healing;
2609
2610                         /* Redraw mana */
2611                         p_ptr->redraw |= (PR_MANA);
2612                 }
2613         }
2614         if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2615             one_in_(4000))
2616         {
2617                 int wounds = p_ptr->msp - p_ptr->csp;
2618
2619                 if (wounds > 0)
2620                 {
2621                         int healing = p_ptr->chp;
2622
2623                         if (healing > wounds)
2624                         {
2625                                 healing = wounds;
2626                         }
2627
2628                         p_ptr->csp += healing;
2629
2630                         /* Redraw mana */
2631                         p_ptr->redraw |= (PR_MANA);
2632                         take_hit(DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
2633                 }
2634         }
2635         if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2636         {
2637                 int slot = 0;
2638                 object_type *o_ptr = NULL;
2639
2640                 disturb(0, 1);
2641                 msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
2642                 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), _("転倒", "tripping"), -1);
2643
2644                 msg_print(NULL);
2645                 if (buki_motteruka(INVEN_RARM))
2646                 {
2647                         slot = INVEN_RARM;
2648                         o_ptr = &inventory[INVEN_RARM];
2649
2650                         if (buki_motteruka(INVEN_LARM) && one_in_(2))
2651                         {
2652                                 o_ptr = &inventory[INVEN_LARM];
2653                                 slot = INVEN_LARM;
2654                         }
2655                 }
2656                 else if (buki_motteruka(INVEN_LARM))
2657                 {
2658                         o_ptr = &inventory[INVEN_LARM];
2659                         slot = INVEN_LARM;
2660                 }
2661
2662                 if (slot && !object_is_cursed(o_ptr))
2663                 {
2664                         msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
2665                         inven_drop(slot, 1);
2666                 }
2667         }
2668 }
2669
2670 /*!
2671  * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理
2672  * / Handle curse effects once every 10 game turns
2673  * @return なし
2674  */
2675 static void process_world_aux_curse(void)
2676 {
2677         if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2678         {
2679                 /*
2680                  * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2681                  * can actually be useful!
2682                  */
2683                 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2684                 {
2685                         char o_name[MAX_NLEN];
2686                         object_type *o_ptr;
2687                         int i, i_keep = 0, count = 0;
2688
2689                         /* Scan the equipment with random teleport ability */
2690                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2691                         {
2692                                 u32b flgs[TR_FLAG_SIZE];
2693                                 o_ptr = &inventory[i];
2694
2695                                 /* Skip non-objects */
2696                                 if (!o_ptr->k_idx) continue;
2697
2698                                 /* Extract the item flags */
2699                                 object_flags(o_ptr, flgs);
2700
2701                                 if (have_flag(flgs, TR_TELEPORT))
2702                                 {
2703                                         /* {.} will stop random teleportation. */
2704                                         if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
2705                                         {
2706                                                 count++;
2707                                                 if (one_in_(count)) i_keep = i;
2708                                         }
2709                                 }
2710                         }
2711
2712                         o_ptr = &inventory[i_keep];
2713                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2714                         msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
2715                         if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
2716                         {
2717                                 disturb(0, 1);
2718                                 teleport_player(50, 0L);
2719                         }
2720                         else
2721                         {
2722                                 msg_format(_("%sに{.}(ピリオド)と銘を刻むと発動を抑制できます。", 
2723                                                          "You can inscribe {.} on your %s to disable random teleportation. "), o_name);
2724                                 disturb(1, 1);
2725                         }
2726                 }
2727                 /* Make a chainsword noise */
2728                 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
2729                 {
2730                         char noise[1024];
2731                         if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
2732                                 msg_print(noise);
2733                         disturb(FALSE, FALSE);
2734                 }
2735                 /* TY Curse */
2736                 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
2737                 {
2738                         int count = 0;
2739                         (void)activate_ty_curse(FALSE, &count);
2740                 }
2741                 /* Handle experience draining */
2742                 if (p_ptr->prace != RACE_ANDROID && 
2743                         ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
2744                 {
2745                         p_ptr->exp -= (p_ptr->lev+1)/2;
2746                         if (p_ptr->exp < 0) p_ptr->exp = 0;
2747                         p_ptr->max_exp -= (p_ptr->lev+1)/2;
2748                         if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
2749                         check_experience();
2750                 }
2751                 /* Add light curse (Later) */
2752                 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
2753                 {
2754                         u32b new_curse;
2755                         object_type *o_ptr;
2756
2757                         o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
2758
2759                         new_curse = get_curse(0, o_ptr);
2760                         if (!(o_ptr->curse_flags & new_curse))
2761                         {
2762                                 char o_name[MAX_NLEN];
2763
2764                                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2765
2766                                 o_ptr->curse_flags |= new_curse;
2767                                 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2768
2769                                 o_ptr->feeling = FEEL_NONE;
2770
2771                                 p_ptr->update |= (PU_BONUS);
2772                         }
2773                 }
2774                 /* Add heavy curse (Later) */
2775                 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
2776                 {
2777                         u32b new_curse;
2778                         object_type *o_ptr;
2779
2780                         o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
2781
2782                         new_curse = get_curse(1, o_ptr);
2783                         if (!(o_ptr->curse_flags & new_curse))
2784                         {
2785                                 char o_name[MAX_NLEN];
2786
2787                                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2788
2789                                 o_ptr->curse_flags |= new_curse;
2790                                 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
2791                                 o_ptr->feeling = FEEL_NONE;
2792
2793                                 p_ptr->update |= (PU_BONUS);
2794                         }
2795                 }
2796                 /* Call animal */
2797                 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
2798                 {
2799                         if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_ANIMAL,
2800                             (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2801                         {
2802                                 char o_name[MAX_NLEN];
2803
2804                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2805                                 msg_format(_("%sが動物を引き寄せた!", "Your %s have attracted an animal!"), o_name);
2806                                 disturb(0, 1);
2807                         }
2808                 }
2809                 /* Call demon */
2810                 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
2811                 {
2812                         if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2813                         {
2814                                 char o_name[MAX_NLEN];
2815
2816                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2817                                 msg_format(_("%sが悪魔を引き寄せた!", "Your %s have attracted a demon!"), o_name);
2818                                 disturb(0, 1);
2819                         }
2820                 }
2821                 /* Call dragon */
2822                 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
2823                 {
2824                         if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DRAGON,
2825                             (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2826                         {
2827                                 char o_name[MAX_NLEN];
2828
2829                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2830                                 msg_format(_("%sがドラゴンを引き寄せた!", "Your %s have attracted an dragon!"), o_name);
2831                                 disturb(0, 1);
2832                         }
2833                 }
2834                 /* Call undead */
2835                 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
2836                 {
2837                         if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD,
2838                             (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2839                         {
2840                                 char o_name[MAX_NLEN];
2841
2842                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2843                                 msg_format(_("%sが死霊を引き寄せた!", "Your %s have attracted an undead!"), o_name);
2844                                 disturb(0, 1);
2845                         }
2846                 }
2847                 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
2848                 {
2849                         if (!p_ptr->resist_fear)
2850                         {
2851                                 disturb(0, 1);
2852                                 msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
2853                                 set_afraid(p_ptr->afraid + 13 + randint1(26));
2854                         }
2855                 }
2856                 /* Teleport player */
2857                 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
2858                 {
2859                         disturb(0, 1);
2860
2861                         /* Teleport player */
2862                         teleport_player(40, TELEPORT_PASSIVE);
2863                 }
2864                 /* Handle HP draining */
2865                 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
2866                 {
2867                         char o_name[MAX_NLEN];
2868
2869                         object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2870                         msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
2871                         take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
2872                 }
2873                 /* Handle mana draining */
2874                 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
2875                 {
2876                         char o_name[MAX_NLEN];
2877
2878                         object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
2879                         msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
2880                         p_ptr->csp -= MIN(p_ptr->lev, 50);
2881                         if (p_ptr->csp < 0)
2882                         {
2883                                 p_ptr->csp = 0;
2884                                 p_ptr->csp_frac = 0;
2885                         }
2886                         p_ptr->redraw |= PR_MANA;
2887                 }
2888         }
2889
2890         /* Rarely, take damage from the Jewel of Judgement */
2891         if (one_in_(999) && !p_ptr->anti_magic)
2892         {
2893                 object_type *o_ptr = &inventory[INVEN_LITE];
2894
2895                 if (o_ptr->name1 == ART_JUDGE)
2896                 {
2897 #ifdef JP
2898                         if (object_is_known(o_ptr))
2899                                 msg_print("『審判の宝石』はあなたの体力を吸収した!");
2900                         else
2901                                 msg_print("なにかがあなたの体力を吸収した!");
2902                         take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
2903 #else
2904                         if (object_is_known(o_ptr))
2905                                 msg_print("The Jewel of Judgement drains life from you!");
2906                         else
2907                                 msg_print("Something drains life from you!");
2908                         take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
2909 #endif
2910                 }
2911         }
2912 }
2913
2914
2915 /*!
2916  * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
2917  * / Handle recharging objects once every 10 game turns
2918  * @return なし
2919  */
2920 static void process_world_aux_recharge(void)
2921 {
2922         int i;
2923         bool changed;
2924
2925         /* Process equipment */
2926         for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2927         {
2928                 /* Get the object */
2929                 object_type *o_ptr = &inventory[i];
2930
2931                 /* Skip non-objects */
2932                 if (!o_ptr->k_idx) continue;
2933
2934                 /* Recharge activatable objects */
2935                 if (o_ptr->timeout > 0)
2936                 {
2937                         /* Recharge */
2938                         o_ptr->timeout--;
2939
2940                         /* Notice changes */
2941                         if (!o_ptr->timeout)
2942                         {
2943                                 recharged_notice(o_ptr);
2944                                 changed = TRUE;
2945                         }
2946                 }
2947         }
2948
2949         /* Notice changes */
2950         if (changed)
2951         {
2952                 /* Window stuff */
2953                 p_ptr->window |= (PW_EQUIP);
2954                 wild_regen = 20;
2955         }
2956
2957         /*
2958          * Recharge rods.  Rods now use timeout to control charging status,
2959          * and each charging rod in a stack decreases the stack's timeout by
2960          * one per turn. -LM-
2961          */
2962         for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
2963         {
2964                 object_type *o_ptr = &inventory[i];
2965                 object_kind *k_ptr = &k_info[o_ptr->k_idx];
2966
2967                 /* Skip non-objects */
2968                 if (!o_ptr->k_idx) continue;
2969
2970                 /* Examine all charging rods or stacks of charging rods. */
2971                 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
2972                 {
2973                         /* Determine how many rods are charging. */
2974                         int temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
2975                         if (temp > o_ptr->number) temp = o_ptr->number;
2976
2977                         /* Decrease timeout by that number. */
2978                         o_ptr->timeout -= temp;
2979
2980                         /* Boundary control. */
2981                         if (o_ptr->timeout < 0) o_ptr->timeout = 0;
2982
2983                         /* Notice changes, provide message if object is inscribed. */
2984                         if (!(o_ptr->timeout))
2985                         {
2986                                 recharged_notice(o_ptr);
2987                                 changed = TRUE;
2988                         }
2989
2990                         /* One of the stack of rod is charged */
2991                         else if (o_ptr->timeout % k_ptr->pval)
2992                         {
2993                                 changed = TRUE;
2994                         }
2995                 }
2996         }
2997
2998         /* Notice changes */
2999         if (changed)
3000         {
3001                 /* Window stuff */
3002                 p_ptr->window |= (PW_INVEN);
3003                 wild_regen = 20;
3004         }
3005
3006         /* Process objects on floor */
3007         for (i = 1; i < o_max; i++)
3008         {
3009                 /* Access object */
3010                 object_type *o_ptr = &o_list[i];
3011
3012                 /* Skip dead objects */
3013                 if (!o_ptr->k_idx) continue;
3014
3015                 /* Recharge rods on the ground.  No messages. */
3016                 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3017                 {
3018                         /* Charge it */
3019                         o_ptr->timeout -= o_ptr->number;
3020
3021                         /* Boundary control. */
3022                         if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3023                 }
3024         }
3025 }
3026
3027
3028 /*!
3029  * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
3030  * / Handle involuntary movement once every 10 game turns
3031  * @return なし
3032  */
3033 static void process_world_aux_movement(void)
3034 {
3035         /* Delayed Word-of-Recall */
3036         if (p_ptr->word_recall)
3037         {
3038                 /*
3039                  * HACK: Autosave BEFORE resetting the recall counter (rr9)
3040                  * The player is yanked up/down as soon as
3041                  * he loads the autosaved game.
3042                  */
3043                 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3044                         do_cmd_save_game(TRUE);
3045
3046                 /* Count down towards recall */
3047                 p_ptr->word_recall--;
3048
3049                 p_ptr->redraw |= (PR_STATUS);
3050
3051                 /* Activate the recall */
3052                 if (!p_ptr->word_recall)
3053                 {
3054                         /* Disturbing! */
3055                         disturb(0, 1);
3056
3057                         /* Determine the level */
3058                         if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3059                         {
3060                                 msg_print(_("上に引っ張りあげられる感じがする!",
3061                                                         "You feel yourself yanked upwards!"));
3062
3063                                 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3064                                 if (record_stair)
3065                                         do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3066
3067                                 dun_level = 0;
3068                                 dungeon_type = 0;
3069
3070                                 leave_quest_check();
3071                                 leave_tower_check();
3072
3073                                 p_ptr->inside_quest = 0;
3074
3075                                 p_ptr->leaving = TRUE;
3076                         }
3077                         else
3078                         {
3079                                 msg_print(_("下に引きずり降ろされる感じがする!",
3080                                                         "You feel yourself yanked downwards!"));
3081
3082                                 dungeon_type = p_ptr->recall_dungeon;
3083
3084                                 if (record_stair)
3085                                         do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3086
3087                                 /* New depth */
3088                                 dun_level = max_dlv[dungeon_type];
3089                                 if (dun_level < 1) dun_level = 1;
3090
3091                                 /* Nightmare mode makes recall more dangerous */
3092                                 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3093                                 {
3094                                         if (dun_level < 50)
3095                                         {
3096                                                 dun_level *= 2;
3097                                         }
3098                                         else if (dun_level < 99)
3099                                         {
3100                                                 dun_level = (dun_level + 99) / 2;
3101                                         }
3102                                         else if (dun_level > 100)
3103                                         {
3104                                                 dun_level = d_info[dungeon_type].maxdepth - 1;
3105                                         }
3106                                 }
3107
3108                                 if (p_ptr->wild_mode)
3109                                 {
3110                                         p_ptr->wilderness_y = p_ptr->y;
3111                                         p_ptr->wilderness_x = p_ptr->x;
3112                                 }
3113                                 else
3114                                 {
3115                                         /* Save player position */
3116                                         p_ptr->oldpx = p_ptr->x;
3117                                         p_ptr->oldpy = p_ptr->y;
3118                                 }
3119                                 p_ptr->wild_mode = FALSE;
3120
3121                                 /*
3122                                  * Clear all saved floors
3123                                  * and create a first saved floor
3124                                  */
3125                                 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3126
3127                                 /* Leaving */
3128                                 p_ptr->leaving = TRUE;
3129
3130                                 if (dungeon_type == DUNGEON_ANGBAND)
3131                                 {
3132                                         int i;
3133
3134                                         for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3135                                         {
3136                                                 quest_type* const q_ptr = &quest[i];
3137
3138                                                 
3139                                                 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3140                                                     (q_ptr->status == QUEST_STATUS_TAKEN) &&
3141                                                     (q_ptr->level < dun_level))
3142                                                 {
3143                                                         q_ptr->status = QUEST_STATUS_FAILED;
3144                                                         q_ptr->complev = (byte)p_ptr->lev;
3145                                                         update_playtime();
3146                                                         q_ptr->comptime = playtime;
3147                                                         r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3148                                                 }
3149                                         }
3150                                 }
3151                         }
3152
3153                         /* Sound */
3154                         sound(SOUND_TPLEVEL);
3155                 }
3156         }
3157
3158
3159         /* Delayed Alter reality */
3160         if (p_ptr->alter_reality)
3161         {
3162                 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3163                         do_cmd_save_game(TRUE);
3164
3165                 /* Count down towards alter */
3166                 p_ptr->alter_reality--;
3167
3168                 p_ptr->redraw |= (PR_STATUS);
3169
3170                 /* Activate the alter reality */
3171                 if (!p_ptr->alter_reality)
3172                 {
3173                         /* Disturbing! */
3174                         disturb(0, 1);
3175
3176                         /* Determine the level */
3177                         if (!quest_number(dun_level) && dun_level)
3178                         {
3179                                 msg_print(_("世界が変わった!", "The world changes!"));
3180
3181                                 /*
3182                                  * Clear all saved floors
3183                                  * and create a first saved floor
3184                                  */
3185                                 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3186
3187                                 /* Leaving */
3188                                 p_ptr->leaving = TRUE;
3189                         }
3190                         else
3191                         {
3192                                 msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
3193                         }
3194
3195                         /* Sound */
3196                         sound(SOUND_TPLEVEL);
3197                 }
3198         }
3199 }
3200
3201
3202 /*!
3203  * @brief 指定したモンスターに隣接しているモンスターの数を返す。
3204  * / Count number of adjacent monsters
3205  * @param m_idx 隣接数を調べたいモンスターのID
3206  * @return 隣接しているモンスターの数
3207  */
3208 static int get_monster_crowd_number(int m_idx)
3209 {
3210         monster_type *m_ptr = &m_list[m_idx];
3211         int my = m_ptr->fy;
3212         int mx = m_ptr->fx;
3213         int i;
3214         int count = 0;
3215
3216         for (i = 0; i < 7; i++)
3217         {
3218                 int ay = my + ddy_ddd[i];
3219                 int ax = mx + ddx_ddd[i];
3220
3221                 if (!in_bounds(ay, ax)) continue;
3222
3223                 /* Count number of monsters */
3224                 if (cave[ay][ax].m_idx > 0) count++;
3225         }
3226
3227         return count;
3228 }
3229
3230
3231
3232 /*!
3233  * ダンジョンの雰囲気を計算するための非線形基準値 / Dungeon rating is no longer linear
3234  */
3235 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3236
3237 /*!
3238  * @brief ダンジョンの雰囲気を算出する。
3239  * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3240  * @return 算出されたダンジョンの雰囲気ランク
3241  */
3242 static byte get_dungeon_feeling(void)
3243 {
3244         const int base = 10;
3245         int rating = 0;
3246         int i;
3247
3248         /* Hack -- no feeling in the town */
3249         if (!dun_level) return 0;
3250
3251         /* Examine each monster */
3252         for (i = 1; i < m_max; i++)
3253         {
3254                 monster_type *m_ptr = &m_list[i];
3255                 monster_race *r_ptr;
3256                 int delta = 0;
3257
3258                 /* Skip dead monsters */
3259                 if (!m_ptr->r_idx) continue;
3260
3261                 /* Ignore pet */
3262                 if (is_pet(m_ptr)) continue;
3263
3264                 r_ptr = &r_info[m_ptr->r_idx];
3265
3266                 /* Unique monsters */
3267                 if (r_ptr->flags1 & (RF1_UNIQUE))
3268                 {
3269                         /* Nearly out-of-depth unique monsters */
3270                         if (r_ptr->level + 10 > dun_level)
3271                         {
3272                                 /* Boost rating by twice delta-depth */
3273                                 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3274                         }
3275                 }
3276                 else
3277                 {
3278                         /* Out-of-depth monsters */
3279                         if (r_ptr->level > dun_level)
3280                         {
3281                                 /* Boost rating by delta-depth */
3282                                 delta += (r_ptr->level - dun_level) * base;
3283                         }
3284                 }
3285
3286                 /* Unusually crowded monsters get a little bit of rating boost */
3287                 if (r_ptr->flags1 & RF1_FRIENDS)
3288                 {
3289                         if (5 <= get_monster_crowd_number(i)) delta += 1;
3290                 }
3291                 else
3292                 {
3293                         if (2 <= get_monster_crowd_number(i)) delta += 1;
3294                 }
3295
3296
3297                 rating += RATING_BOOST(delta);
3298         }
3299
3300         /* Examine each unidentified object */
3301         for (i = 1; i < o_max; i++)
3302         {
3303                 object_type *o_ptr = &o_list[i];
3304                 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3305                 int delta = 0;
3306
3307                 /* Skip dead objects */
3308                 if (!o_ptr->k_idx) continue;
3309
3310                 /* Skip known objects */
3311                 if (object_is_known(o_ptr))
3312                 {
3313                         /* Touched? */
3314                         if (o_ptr->marked & OM_TOUCHED) continue;
3315                 }
3316
3317                 /* Skip pseudo-known objects */
3318                 if (o_ptr->ident & IDENT_SENSE) continue;
3319
3320                 /* Ego objects */
3321                 if (object_is_ego(o_ptr))
3322                 {
3323                         ego_item_type *e_ptr = &e_info[o_ptr->name2];
3324
3325                         delta += e_ptr->rating * base;
3326                 }
3327
3328                 /* Artifacts */
3329                 if (object_is_artifact(o_ptr))
3330                 {
3331                         s32b cost = object_value_real(o_ptr);
3332
3333                         delta += 10 * base;
3334                         if (cost > 10000L) delta += 10 * base;
3335                         if (cost > 50000L) delta += 10 * base;
3336                         if (cost > 100000L) delta += 10 * base;
3337
3338                         /* Special feeling */
3339                         if (!preserve_mode) return 1;
3340                 }
3341
3342                 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3343                 if (o_ptr->tval == TV_SHIELD &&
3344                     o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3345                 if (o_ptr->tval == TV_GLOVES &&
3346                     o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3347                 if (o_ptr->tval == TV_BOOTS &&
3348                     o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3349                 if (o_ptr->tval == TV_HELM &&
3350                     o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3351                 if (o_ptr->tval == TV_RING &&
3352                     o_ptr->sval == SV_RING_SPEED &&
3353                     !object_is_cursed(o_ptr)) delta += 25 * base;
3354                 if (o_ptr->tval == TV_RING &&
3355                     o_ptr->sval == SV_RING_LORDLY &&
3356                     !object_is_cursed(o_ptr)) delta += 15 * base;
3357                 if (o_ptr->tval == TV_AMULET &&
3358                     o_ptr->sval == SV_AMULET_THE_MAGI &&
3359                     !object_is_cursed(o_ptr)) delta += 15 * base;
3360
3361                 /* Out-of-depth objects */
3362                 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3363                     k_ptr->level > dun_level)
3364                 {
3365                         /* Rating increase */
3366                         delta += (k_ptr->level - dun_level) * base;
3367                 }
3368
3369                 rating += RATING_BOOST(delta);
3370         }
3371
3372
3373         if (rating > RATING_BOOST(1000)) return 2;
3374         if (rating > RATING_BOOST(800)) return 3;
3375         if (rating > RATING_BOOST(600)) return 4;
3376         if (rating > RATING_BOOST(400)) return 5;
3377         if (rating > RATING_BOOST(300)) return 6;
3378         if (rating > RATING_BOOST(200)) return 7;
3379         if (rating > RATING_BOOST(100)) return 8;
3380         if (rating > RATING_BOOST(0)) return 9;
3381
3382         return 10;
3383 }
3384
3385 /*!
3386  * @brief ダンジョンの雰囲気を更新し、変化があった場合メッセージを表示する
3387  * / Update dungeon feeling, and announce it if changed
3388  * @return なし
3389  */
3390 static void update_dungeon_feeling(void)
3391 {
3392         byte new_feeling;
3393         int quest_num;
3394         int delay;
3395
3396         /* No feeling on the surface */
3397         if (!dun_level) return;
3398
3399         /* No feeling in the arena */
3400         if (p_ptr->inside_battle) return;
3401
3402         /* Extract delay time */
3403         delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3404
3405         /* Not yet felt anything */
3406         if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3407
3408         /* Extract quest number (if any) */
3409         quest_num = quest_number(dun_level);
3410
3411         /* No feeling in a quest */
3412         if (quest_num &&
3413             (is_fixed_quest_idx(quest_num) &&
3414              !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3415                !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3416
3417
3418         /* Get new dungeon feeling */
3419         new_feeling = get_dungeon_feeling();
3420
3421         /* Remember last time updated */
3422         p_ptr->feeling_turn = turn;
3423
3424         /* No change */
3425         if (p_ptr->feeling == new_feeling) return;
3426
3427         /* Dungeon feeling is changed */
3428         p_ptr->feeling = new_feeling;
3429
3430         /* Announce feeling */
3431         do_cmd_feeling();
3432
3433         select_floor_music();
3434
3435         /* Update the level indicator */
3436         p_ptr->redraw |= (PR_DEPTH);
3437
3438         /* Disturb */
3439         if (disturb_minor) disturb(0, 0);
3440 }
3441
3442 /*!
3443  * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
3444  * / Handle certain things once every 10 game turns
3445  * @return なし
3446  */
3447 static void process_world(void)
3448 {
3449         int day, hour, min;
3450
3451         const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3452         s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3453         int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3454         
3455         extract_day_hour_min(&day, &hour, &min);
3456
3457         /* Update dungeon feeling, and announce it if changed */
3458         update_dungeon_feeling();
3459
3460         /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/
3461         if (ironman_downward && (dungeon_type != DUNGEON_ANGBAND && dungeon_type != 0))
3462         {
3463                 dun_level = 0;
3464                 dungeon_type = 0;
3465                 prepare_change_floor_mode(CFM_FIRST_FLOOR | CFM_RAND_PLACE);
3466                 p_ptr->inside_arena = FALSE;
3467                 p_ptr->wild_mode = FALSE;
3468                 p_ptr->leaving = TRUE;
3469         }
3470
3471         /*** Check monster arena ***/
3472         if (p_ptr->inside_battle && !p_ptr->leaving)
3473         {
3474                 int i2, j2;
3475                 int win_m_idx = 0;
3476                 int number_mon = 0;
3477
3478                 /* Count all hostile monsters */
3479                 for (i2 = 0; i2 < cur_wid; ++i2)
3480                         for (j2 = 0; j2 < cur_hgt; j2++)
3481                         {
3482                                 cave_type *c_ptr = &cave[j2][i2];
3483
3484                                 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3485                                 {
3486                                         number_mon++;
3487                                         win_m_idx = c_ptr->m_idx;
3488                                 }
3489                         }
3490
3491                 if (number_mon == 0)
3492                 {
3493                         msg_print(_("相打ちに終わりました。", "They have kill each other at the same time."));
3494                         msg_print(NULL);
3495                         p_ptr->energy_need = 0;
3496                         battle_monsters();
3497                 }
3498                 else if ((number_mon-1) == 0)
3499                 {
3500                         char m_name[80];
3501                         monster_type *wm_ptr;
3502
3503                         wm_ptr = &m_list[win_m_idx];
3504
3505                         monster_desc(m_name, wm_ptr, 0);
3506                         msg_format(_("%sが勝利した!", "%s is winner!"), m_name);
3507                         msg_print(NULL);
3508
3509                         if (win_m_idx == (sel_monster+1))
3510                         {
3511                                 msg_print(_("おめでとうございます。", "Congratulations."));
3512                                 msg_format(_("%d$を受け取った。", "You received %d gold."), battle_odds);
3513                                 p_ptr->au += battle_odds;
3514                         }
3515                         else
3516                         {
3517                                 msg_print(_("残念でした。", "You lost gold."));
3518                         }
3519                         msg_print(NULL);
3520                         p_ptr->energy_need = 0;
3521                         battle_monsters();
3522                 }
3523                 else if (turn - old_turn == 150*TURNS_PER_TICK)
3524                 {
3525                         msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
3526                         p_ptr->au += kakekin;
3527                         msg_print(NULL);
3528                         p_ptr->energy_need = 0;
3529                         battle_monsters();
3530                 }
3531         }
3532
3533         /* Every 10 game turns */
3534         if (turn % TURNS_PER_TICK) return;
3535
3536         /*** Check the Time and Load ***/
3537
3538         if (!(turn % (50*TURNS_PER_TICK)))
3539         {
3540                 /* Check time and load */
3541                 if ((0 != check_time()) || (0 != check_load()))
3542                 {
3543                         /* Warning */
3544                         if (closing_flag <= 2)
3545                         {
3546                                 /* Disturb */
3547                                 disturb(0, 1);
3548
3549                                 /* Count warnings */
3550                                 closing_flag++;
3551
3552                                 /* Message */
3553                                 msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
3554                                 msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
3555
3556                         }
3557
3558                         /* Slam the gate */
3559                         else
3560                         {
3561                                 /* Message */
3562                                 msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
3563
3564                                 /* Stop playing */
3565                                 p_ptr->playing = FALSE;
3566
3567                                 /* Leaving */
3568                                 p_ptr->leaving = TRUE;
3569                         }
3570                 }
3571         }
3572
3573         /*** Attempt timed autosave ***/
3574         if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3575         {
3576                 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3577                         do_cmd_save_game(TRUE);
3578         }
3579
3580         if (mon_fight && !ignore_unview)
3581         {
3582                 msg_print(_("何かが聞こえた。", "You hear noise."));
3583         }
3584
3585         /*** Handle the wilderness/town (sunshine) ***/
3586
3587         /* While in town/wilderness */
3588         if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3589         {
3590                 /* Hack -- Daybreak/Nighfall in town */
3591                 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3592                 {
3593                         bool dawn;
3594
3595                         /* Check for dawn */
3596                         dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3597
3598                         /* Day breaks */
3599                         if (dawn)
3600                         {
3601                                 int y, x;
3602
3603                                 /* Message */
3604                                 msg_print(_("夜が明けた。", "The sun has risen."));
3605
3606                                 if (!p_ptr->wild_mode)
3607                                 {
3608                                         /* Hack -- Scan the town */
3609                                         for (y = 0; y < cur_hgt; y++)
3610                                         {
3611                                                 for (x = 0; x < cur_wid; x++)
3612                                                 {
3613                                                         /* Get the cave grid */
3614                                                         cave_type *c_ptr = &cave[y][x];
3615
3616                                                         /* Assume lit */
3617                                                         c_ptr->info |= (CAVE_GLOW);
3618
3619                                                         /* Hack -- Memorize lit grids if allowed */
3620                                                         if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3621
3622                                                         /* Hack -- Notice spot */
3623                                                         note_spot(y, x);
3624                                                 }
3625                                         }
3626                                 }
3627                         }
3628
3629                         /* Night falls */
3630                         else
3631                         {
3632                                 int y, x;
3633
3634                                 /* Message */
3635                                 msg_print(_("日が沈んだ。", "The sun has fallen."));
3636
3637                                 if (!p_ptr->wild_mode)
3638                                 {
3639                                         /* Hack -- Scan the town */
3640                                         for (y = 0; y < cur_hgt; y++)
3641                                         {
3642                                                 for (x = 0; x < cur_wid; x++)
3643                                                 {
3644                                                         /* Get the cave grid */
3645                                                         cave_type *c_ptr = &cave[y][x];
3646
3647                                                         /* Feature code (applying "mimic" field) */
3648                                                         feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
3649
3650                                                         if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
3651                                                             !have_flag(f_ptr->flags, FF_ENTRANCE))
3652                                                         {
3653                                                                 /* Assume dark */
3654                                                                 c_ptr->info &= ~(CAVE_GLOW);
3655
3656                                                                 if (!have_flag(f_ptr->flags, FF_REMEMBER))
3657                                                                 {
3658                                                                         /* Forget the normal floor grid */
3659                                                                         c_ptr->info &= ~(CAVE_MARK);
3660
3661                                                                         /* Hack -- Notice spot */
3662                                                                         note_spot(y, x);
3663                                                                 }
3664                                                         }
3665                                                 }
3666
3667                                                 /* Glow deep lava and building entrances */
3668                                                 glow_deep_lava_and_bldg();
3669                                         }
3670                                 }
3671                         }
3672
3673                         /* Update the monsters */
3674                         p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
3675
3676                         /* Redraw map */
3677                         p_ptr->redraw |= (PR_MAP);
3678
3679                         /* Window stuff */
3680                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
3681
3682                         if (p_ptr->special_defense & NINJA_S_STEALTH)
3683                         {
3684                                 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
3685                         }
3686                 }
3687         }
3688
3689         /* While in the dungeon (vanilla_town or lite_town mode only) */
3690         else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
3691         {
3692                 /*** Shuffle the Storekeepers ***/
3693
3694                 /* Chance is only once a day (while in dungeon) */
3695                 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
3696                 {
3697                         /* Sometimes, shuffle the shop-keepers */
3698                         if (one_in_(STORE_SHUFFLE))
3699                         {
3700                                 int n, i;
3701
3702                                 /* Pick a random shop (except home and museum) */
3703                                 do
3704                                 {
3705                                         n = randint0(MAX_STORES);
3706                                 }
3707                                 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
3708
3709                                 /* Check every feature */
3710                                 for (i = 1; i < max_f_idx; i++)
3711                                 {
3712                                         /* Access the index */
3713                                         feature_type *f_ptr = &f_info[i];
3714
3715                                         /* Skip empty index */
3716                                         if (!f_ptr->name) continue;
3717
3718                                         /* Skip non-store features */
3719                                         if (!have_flag(f_ptr->flags, FF_STORE)) continue;
3720
3721                                         /* Verify store type */
3722                                         if (f_ptr->subtype == n)
3723                                         {
3724                                                 /* Message */
3725                                                 if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name);
3726
3727                                                 /* Shuffle it */
3728                                                 store_shuffle(n);
3729
3730                                                 break;
3731                                         }
3732                                 }
3733                         }
3734                 }
3735         }
3736
3737
3738         /*** Process the monsters ***/
3739
3740         /* Check for creature generation. */
3741         if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
3742             !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
3743         {
3744                 /* Make a new monster */
3745                 (void)alloc_monster(MAX_SIGHT + 5, 0);
3746         }
3747
3748         /* Hack -- Check for creature regeneration */
3749         if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
3750         if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
3751
3752         if (!p_ptr->leaving)
3753         {
3754                 int i;
3755
3756                 /* Hack -- Process the counters of monsters if needed */
3757                 for (i = 0; i < MAX_MTIMED; i++)
3758                 {
3759                         if (mproc_max[i] > 0) process_monsters_mtimed(i);
3760                 }
3761         }
3762
3763
3764         /* Date changes */
3765         if (!hour && !min)
3766         {
3767                 if (min != prev_min)
3768                 {
3769                         do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
3770                         determine_today_mon(FALSE);
3771                 }
3772         }
3773
3774         /*
3775          * Nightmare mode activates the TY_CURSE at midnight
3776          *
3777          * Require exact minute -- Don't activate multiple times in a minute
3778          */
3779         if (ironman_nightmare && (min != prev_min))
3780         {
3781                 /* Every 15 minutes after 11:00 pm */
3782                 if ((hour == 23) && !(min % 15))
3783                 {
3784                         /* Disturbing */
3785                         disturb(0, 1);
3786
3787                         switch (min / 15)
3788                         {
3789                         case 0:
3790                                 msg_print(_("遠くで不気味な鐘の音が鳴った。", "You hear a distant bell toll ominously."));
3791                                 break;
3792
3793                         case 1:
3794                                 msg_print(_("遠くで鐘が二回鳴った。", "A distant bell sounds twice."));
3795                                 break;
3796
3797                         case 2:
3798                                 msg_print(_("遠くで鐘が三回鳴った。", "A distant bell sounds three times."));
3799                                 break;
3800
3801                         case 3:
3802                                 msg_print(_("遠くで鐘が四回鳴った。", "A distant bell tolls four times."));
3803                                 break;
3804                         }
3805                 }
3806
3807                 /* TY_CURSE activates at midnight! */
3808                 if (!hour && !min)
3809                 {
3810                         int count = 0;
3811
3812                         disturb(1, 1);
3813                         msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
3814                         activate_ty_curse(FALSE, &count);
3815                 }
3816         }
3817
3818
3819         /*** Check the Food, and Regenerate ***/
3820
3821         if (!p_ptr->inside_battle)
3822         {
3823                 /* Digest quickly when gorged */
3824                 if (p_ptr->food >= PY_FOOD_MAX)
3825                 {
3826                         /* Digest a lot of food */
3827                         (void)set_food(p_ptr->food - 100);
3828                 }
3829
3830                 /* Digest normally -- Every 50 game turns */
3831                 else if (!(turn % (TURNS_PER_TICK*5)))
3832                 {
3833                         /* Basic digestion rate based on speed */
3834                         int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
3835
3836                         /* Regeneration takes more food */
3837                         if (p_ptr->regenerate)
3838                                 digestion += 20;
3839                         if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
3840                                 digestion += 20;
3841                         if (p_ptr->cursed & TRC_FAST_DIGEST)
3842                                 digestion += 30;
3843
3844                         /* Slow digestion takes less food */
3845                         if (p_ptr->slow_digest)
3846                                 digestion -= 5;
3847
3848                         /* Minimal digestion */
3849                         if (digestion < 1) digestion = 1;
3850                         /* Maximal digestion */
3851                         if (digestion > 100) digestion = 100;
3852
3853                         /* Digest some food */
3854                         (void)set_food(p_ptr->food - digestion);
3855                 }
3856
3857
3858                 /* Getting Faint */
3859                 if ((p_ptr->food < PY_FOOD_FAINT))
3860                 {
3861                         /* Faint occasionally */
3862                         if (!p_ptr->paralyzed && (randint0(100) < 10))
3863                         {
3864                                 /* Message */
3865                                 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
3866                                 disturb(1, 1);
3867
3868                                 /* Hack -- faint (bypass free action) */
3869                                 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
3870                         }
3871
3872                         /* Starve to death (slowly) */
3873                         if (p_ptr->food < PY_FOOD_STARVE)
3874                         {
3875                                 /* Calculate damage */
3876                                 int dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
3877
3878                                 /* Take damage */
3879                                 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
3880                         }
3881                 }
3882         }
3883
3884
3885
3886         /* Process timed damage and regeneration */
3887         process_world_aux_hp_and_sp();
3888
3889         /* Process timeout */
3890         process_world_aux_timeout();
3891
3892         /* Process light */
3893         process_world_aux_light();
3894
3895         /* Process mutation effects */
3896         process_world_aux_mutation();
3897
3898         /* Process curse effects */
3899         process_world_aux_curse();
3900
3901         /* Process recharging */
3902         process_world_aux_recharge();
3903
3904         /* Feel the inventory */
3905         sense_inventory1();
3906         sense_inventory2();
3907
3908         /* Involuntary Movement */
3909         process_world_aux_movement();
3910 }
3911
3912 /*!
3913  * @brief ウィザードモードへの導入処理
3914  * / Verify use of "wizard" mode
3915  * @return 実際にウィザードモードへ移行したらTRUEを返す。
3916  */
3917 static bool enter_wizard_mode(void)
3918 {
3919         /* Ask first time */
3920         if (!p_ptr->noscore)
3921         {
3922                 /* Wizard mode is not permitted */
3923                 if (!allow_debug_opts || arg_wizard)
3924                 {
3925                         msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
3926                         return FALSE;
3927                 }
3928
3929                 /* Mention effects */
3930                 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
3931                 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
3932                 msg_print(NULL);
3933
3934                 /* Verify request */
3935                 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? ")))
3936                 {
3937                         return (FALSE);
3938                 }
3939
3940                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
3941                 /* Mark savefile */
3942                 p_ptr->noscore |= 0x0002;
3943         }
3944
3945         /* Success */
3946         return (TRUE);
3947 }
3948
3949
3950 #ifdef ALLOW_WIZARD
3951
3952 /*!
3953  * @brief デバッグコマンドへの導入処理
3954  * / Verify use of "debug" commands
3955  * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
3956  */
3957 static bool enter_debug_mode(void)
3958 {
3959         /* Ask first time */
3960         if (!p_ptr->noscore)
3961         {
3962                 /* Debug mode is not permitted */
3963                 if (!allow_debug_opts)
3964                 {
3965                         msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
3966                         return FALSE;
3967                 }
3968
3969                 /* Mention effects */
3970                 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
3971                 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
3972
3973                 msg_print(NULL);
3974
3975                 /* Verify request */
3976                 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? ")))
3977                 {
3978                         return (FALSE);
3979                 }
3980
3981                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
3982                 /* Mark savefile */
3983                 p_ptr->noscore |= 0x0008;
3984         }
3985
3986         /* Success */
3987         return (TRUE);
3988 }
3989
3990 /*
3991  * Hack -- Declare the Debug Routines
3992  */
3993 extern void do_cmd_debug(void);
3994
3995 #endif /* ALLOW_WIZARD */
3996
3997
3998 #ifdef ALLOW_BORG
3999
4000 /*!
4001  * @brief ボーグコマンドへの導入処理
4002  * / Verify use of "borg" commands
4003  * @return 実際にボーグコマンドへ移行したらTRUEを返す。
4004  */
4005 static bool enter_borg_mode(void)
4006 {
4007         /* Ask first time */
4008         if (!(p_ptr->noscore & 0x0010))
4009         {
4010                 /* Mention effects */
4011                 msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting."));
4012                 msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands."));
4013
4014                 msg_print(NULL);
4015
4016                 /* Verify request */
4017                 if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? ")))
4018                 {
4019                         return (FALSE);
4020                 }
4021
4022                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands."));
4023                 /* Mark savefile */
4024                 p_ptr->noscore |= 0x0010;
4025         }
4026
4027         /* Success */
4028         return (TRUE);
4029 }
4030
4031 /*
4032  * Hack -- Declare the Ben Borg
4033  */
4034 extern void do_cmd_borg(void);
4035
4036 #endif /* ALLOW_BORG */
4037
4038
4039 /*!
4040  * @brief プレイヤーから受けた入力コマンドの分岐処理。
4041  * / Parse and execute the current command Give "Warning" on illegal commands.
4042  * @todo XXX XXX XXX Make some "blocks"
4043  * @return なし
4044  */
4045 static void process_command(void)
4046 {
4047         int old_now_message = now_message;
4048
4049 #ifdef ALLOW_REPEAT /* TNB */
4050
4051         /* Handle repeating the last command */
4052         repeat_check();
4053
4054 #endif /* ALLOW_REPEAT -- TNB */
4055
4056         now_message = 0;
4057
4058         /* Sniper */
4059         if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4060                 reset_concent = TRUE;
4061
4062         /* Parse the command */
4063         switch (command_cmd)
4064         {
4065                 /* Ignore */
4066                 case ESCAPE:
4067                 case ' ':
4068                 {
4069                         break;
4070                 }
4071
4072                 /* Ignore return */
4073                 case '\r':
4074                 case '\n':
4075                 {
4076                         break;
4077                 }
4078
4079                 /*** Wizard Commands ***/
4080
4081                 /* Toggle Wizard Mode */
4082                 case KTRL('W'):
4083                 {
4084                         if (p_ptr->wizard)
4085                         {
4086                                 p_ptr->wizard = FALSE;
4087                                 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
4088                         }
4089                         else if (enter_wizard_mode())
4090                         {
4091                                 p_ptr->wizard = TRUE;
4092                                 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
4093                         }
4094
4095                         /* Update monsters */
4096                         p_ptr->update |= (PU_MONSTERS);
4097
4098                         /* Redraw "title" */
4099                         p_ptr->redraw |= (PR_TITLE);
4100
4101                         break;
4102                 }
4103
4104
4105 #ifdef ALLOW_WIZARD
4106
4107                 /* Special "debug" commands */
4108                 case KTRL('A'):
4109                 {
4110                         /* Enter debug mode */
4111                         if (enter_debug_mode())
4112                         {
4113                                 do_cmd_debug();
4114                         }
4115                         break;
4116                 }
4117
4118 #endif /* ALLOW_WIZARD */
4119
4120
4121 #ifdef ALLOW_BORG
4122
4123                 /* Special "borg" commands */
4124                 case KTRL('Z'):
4125                 {
4126                         /* Enter borg mode */
4127                         if (enter_borg_mode())
4128                         {
4129                                 if (!p_ptr->wild_mode) do_cmd_borg();
4130                         }
4131
4132                         break;
4133                 }
4134
4135 #endif /* ALLOW_BORG */
4136
4137
4138
4139                 /*** Inventory Commands ***/
4140
4141                 /* Wear/wield equipment */
4142                 case 'w':
4143                 {
4144                         if (!p_ptr->wild_mode) do_cmd_wield();
4145                         break;
4146                 }
4147
4148                 /* Take off equipment */
4149                 case 't':
4150                 {
4151                         if (!p_ptr->wild_mode) do_cmd_takeoff();
4152                         break;
4153                 }
4154
4155                 /* Drop an item */
4156                 case 'd':
4157                 {
4158                         if (!p_ptr->wild_mode) do_cmd_drop();
4159                         break;
4160                 }
4161
4162                 /* Destroy an item */
4163                 case 'k':
4164                 {
4165                         do_cmd_destroy();
4166                         break;
4167                 }
4168
4169                 /* Equipment list */
4170                 case 'e':
4171                 {
4172                         do_cmd_equip();
4173                         break;
4174                 }
4175
4176                 /* Inventory list */
4177                 case 'i':
4178                 {
4179                         do_cmd_inven();
4180                         break;
4181                 }
4182
4183
4184                 /*** Various commands ***/
4185
4186                 /* Identify an object */
4187                 case 'I':
4188                 {
4189                         do_cmd_observe();
4190                         break;
4191                 }
4192
4193                 /* Hack -- toggle windows */
4194                 case KTRL('I'):
4195                 {
4196                         toggle_inven_equip();
4197                         break;
4198                 }
4199
4200
4201                 /*** Standard "Movement" Commands ***/
4202
4203                 /* Alter a grid */
4204                 case '+':
4205                 {
4206                         if (!p_ptr->wild_mode) do_cmd_alter();
4207                         break;
4208                 }
4209
4210                 /* Dig a tunnel */
4211                 case 'T':
4212                 {
4213                         if (!p_ptr->wild_mode) do_cmd_tunnel();
4214                         break;
4215                 }
4216
4217                 /* Move (usually pick up things) */
4218                 case ';':
4219                 {
4220 #ifdef ALLOW_EASY_DISARM /* TNB */
4221
4222                         do_cmd_walk(FALSE);
4223
4224 #else /* ALLOW_EASY_DISARM -- TNB */
4225
4226                         do_cmd_walk(always_pickup);
4227
4228 #endif /* ALLOW_EASY_DISARM -- TNB */
4229
4230                         break;
4231                 }
4232
4233                 /* Move (usually do not pick up) */
4234                 case '-':
4235                 {
4236 #ifdef ALLOW_EASY_DISARM /* TNB */
4237
4238                         do_cmd_walk(TRUE);
4239
4240 #else /* ALLOW_EASY_DISARM -- TNB */
4241
4242                         do_cmd_walk(!always_pickup);
4243
4244 #endif /* ALLOW_EASY_DISARM -- TNB */
4245
4246                         break;
4247                 }
4248
4249
4250                 /*** Running, Resting, Searching, Staying */
4251
4252                 /* Begin Running -- Arg is Max Distance */
4253                 case '.':
4254                 {
4255                         if (!p_ptr->wild_mode) do_cmd_run();
4256                         break;
4257                 }
4258
4259                 /* Stay still (usually pick things up) */
4260                 case ',':
4261                 {
4262                         do_cmd_stay(always_pickup);
4263                         break;
4264                 }
4265
4266                 /* Stay still (usually do not pick up) */
4267                 case 'g':
4268                 {
4269                         do_cmd_stay(!always_pickup);
4270                         break;
4271                 }
4272
4273                 /* Rest -- Arg is time */
4274                 case 'R':
4275                 {
4276                         do_cmd_rest();
4277                         break;
4278                 }
4279
4280                 /* Search for traps/doors */
4281                 case 's':
4282                 {
4283                         do_cmd_search();
4284                         break;
4285                 }
4286
4287                 /* Toggle search mode */
4288                 case 'S':
4289                 {
4290                         if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4291                         else set_action(ACTION_SEARCH);
4292                         break;
4293                 }
4294
4295
4296                 /*** Stairs and Doors and Chests and Traps ***/
4297
4298                 /* Enter store */
4299                 case SPECIAL_KEY_STORE:
4300                 {
4301                         if (!p_ptr->wild_mode) do_cmd_store();
4302                         break;
4303                 }
4304
4305                 /* Enter building -KMW- */
4306                 case SPECIAL_KEY_BUILDING:
4307                 {
4308                         if (!p_ptr->wild_mode) do_cmd_bldg();
4309                         break;
4310                 }
4311
4312                 /* Enter quest level -KMW- */
4313                 case SPECIAL_KEY_QUEST:
4314                 {
4315                         if (!p_ptr->wild_mode) do_cmd_quest();
4316                         break;
4317                 }
4318
4319                 /* Go up staircase */
4320                 case '<':
4321                 {
4322                         if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4323                         {
4324                                 if (vanilla_town) break;
4325
4326                                 if (ambush_flag)
4327                                 {
4328                                         msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
4329                                         break;
4330                                 }
4331
4332                                 if (p_ptr->food < PY_FOOD_WEAK)
4333                                 {
4334                                         msg_print(_("その前に食事をとらないと。", "You must eat something here."));
4335                                         break;
4336                                 }
4337
4338                                 change_wild_mode();
4339                         }
4340                         else
4341                                 do_cmd_go_up();
4342                         break;
4343                 }
4344
4345                 /* Go down staircase */
4346                 case '>':
4347                 {
4348                         if (p_ptr->wild_mode)
4349                                 change_wild_mode();
4350                         else
4351                                 do_cmd_go_down();
4352
4353                         break;
4354                 }
4355
4356                 /* Open a door or chest */
4357                 case 'o':
4358                 {
4359                         if (!p_ptr->wild_mode) do_cmd_open();
4360                         break;
4361                 }
4362
4363                 /* Close a door */
4364                 case 'c':
4365                 {
4366                         if (!p_ptr->wild_mode) do_cmd_close();
4367                         break;
4368                 }
4369
4370                 /* Jam a door with spikes */
4371                 case 'j':
4372                 {
4373                         if (!p_ptr->wild_mode) do_cmd_spike();
4374                         break;
4375                 }
4376
4377                 /* Bash a door */
4378                 case 'B':
4379                 {
4380                         if (!p_ptr->wild_mode) do_cmd_bash();
4381                         break;
4382                 }
4383
4384                 /* Disarm a trap or chest */
4385                 case 'D':
4386                 {
4387                         if (!p_ptr->wild_mode) do_cmd_disarm();
4388                         break;
4389                 }
4390
4391
4392                 /*** Magic and Prayers ***/
4393
4394                 /* Gain new spells/prayers */
4395                 case 'G':
4396                 {
4397                         if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4398                                 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
4399                         else if (p_ptr->pclass == CLASS_SAMURAI)
4400                                 do_cmd_gain_hissatsu();
4401                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4402                                 gain_magic();
4403                         else
4404                                 do_cmd_study();
4405                         break;
4406                 }
4407
4408                 /* Browse a book */
4409                 case 'b':
4410                 {
4411                         if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4412                              (p_ptr->pclass == CLASS_BERSERKER) ||
4413                              (p_ptr->pclass == CLASS_NINJA) ||
4414                              (p_ptr->pclass == CLASS_MIRROR_MASTER) 
4415                              ) do_cmd_mind_browse();
4416                         else if (p_ptr->pclass == CLASS_SMITH)
4417                                 do_cmd_kaji(TRUE);
4418                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4419                                 do_cmd_magic_eater(TRUE, FALSE);
4420                         else if (p_ptr->pclass == CLASS_SNIPER)
4421                                 do_cmd_snipe_browse();
4422                         else do_cmd_browse();
4423                         break;
4424                 }
4425
4426                 /* Cast a spell */
4427                 case 'm':
4428                 {
4429                         /* -KMW- */
4430                         if (!p_ptr->wild_mode)
4431                         {
4432                                 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4433                                 {
4434                                         msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
4435                                 }
4436                                 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4437                                 {
4438                                         msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
4439                                         msg_print(NULL);
4440                                 }
4441                                 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4442                                 {
4443                                         cptr which_power = _("魔法", "magic");
4444                                         if (p_ptr->pclass == CLASS_MINDCRAFTER)
4445                                                 which_power = _("超能力", "psionic powers");
4446                                         else if (p_ptr->pclass == CLASS_IMITATOR)
4447                                                 which_power = _("ものまね", "imitation");
4448                                         else if (p_ptr->pclass == CLASS_SAMURAI)
4449                                                 which_power = _("必殺剣", "hissatsu");
4450                                         else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4451                                                 which_power = _("鏡魔法", "mirror magic");
4452                                         else if (p_ptr->pclass == CLASS_NINJA)
4453                                                 which_power = _("忍術", "ninjutsu");
4454                                         else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4455                                                 which_power = _("祈り", "prayer");
4456
4457                                         msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
4458                                         p_ptr->energy_use = 0;
4459                                 }
4460                                 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4461                                 {
4462                                         msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
4463                                         p_ptr->energy_use = 0;
4464                                 }
4465                                 else
4466                                 {
4467                                         if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4468                                             (p_ptr->pclass == CLASS_BERSERKER) ||
4469                                             (p_ptr->pclass == CLASS_NINJA) ||
4470                                             (p_ptr->pclass == CLASS_MIRROR_MASTER)
4471                                             )
4472                                                 do_cmd_mind();
4473                                         else if (p_ptr->pclass == CLASS_IMITATOR)
4474                                                 do_cmd_mane(FALSE);
4475                                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4476                                                 do_cmd_magic_eater(FALSE, FALSE);
4477                                         else if (p_ptr->pclass == CLASS_SAMURAI)
4478                                                 do_cmd_hissatsu();
4479                                         else if (p_ptr->pclass == CLASS_BLUE_MAGE)
4480                                                 do_cmd_cast_learned();
4481                                         else if (p_ptr->pclass == CLASS_SMITH)
4482                                                 do_cmd_kaji(FALSE);
4483                                         else if (p_ptr->pclass == CLASS_SNIPER)
4484                                                 do_cmd_snipe();
4485                                         else
4486                                                 do_cmd_cast();
4487                                 }
4488                         }
4489                         break;
4490                 }
4491
4492                 /* Issue a pet command */
4493                 case 'p':
4494                 {
4495                         if (!p_ptr->wild_mode) do_cmd_pet();
4496                         break;
4497                 }
4498
4499                 /*** Use various objects ***/
4500
4501                 /* Inscribe an object */
4502                 case '{':
4503                 {
4504                         do_cmd_inscribe();
4505                         break;
4506                 }
4507
4508                 /* Uninscribe an object */
4509                 case '}':
4510                 {
4511                         do_cmd_uninscribe();
4512                         break;
4513                 }
4514
4515                 /* Activate an artifact */
4516                 case 'A':
4517                 {
4518                         if (!p_ptr->wild_mode)
4519                         {
4520                         if (!p_ptr->inside_arena)
4521                                 do_cmd_activate();
4522                         else
4523                         {
4524                                 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4525                                 msg_print(NULL);
4526                         }
4527                         }
4528                         break;
4529                 }
4530
4531                 /* Eat some food */
4532                 case 'E':
4533                 {
4534                         do_cmd_eat_food();
4535                         break;
4536                 }
4537
4538                 /* Fuel your lantern/torch */
4539                 case 'F':
4540                 {
4541                         do_cmd_refill();
4542                         break;
4543                 }
4544
4545                 /* Fire an item */
4546                 case 'f':
4547                 {
4548                         if (!p_ptr->wild_mode) do_cmd_fire();
4549                         break;
4550                 }
4551
4552                 /* Throw an item */
4553                 case 'v':
4554                 {
4555                         if (!p_ptr->wild_mode)
4556                         {
4557                                 do_cmd_throw();
4558                         }
4559                         break;
4560                 }
4561
4562                 /* Aim a wand */
4563                 case 'a':
4564                 {
4565                         if (!p_ptr->wild_mode)
4566                         {
4567                         if (!p_ptr->inside_arena)
4568                                 do_cmd_aim_wand();
4569                         else
4570                         {
4571                                 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4572                                 msg_print(NULL);
4573                         }
4574                         }
4575                         break;
4576                 }
4577
4578                 /* Zap a rod */
4579                 case 'z':
4580                 {
4581                         if (!p_ptr->wild_mode)
4582                         {
4583                         if (p_ptr->inside_arena)
4584                         {
4585                                 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4586                                 msg_print(NULL);
4587                         }
4588                         else if (use_command && rogue_like_commands)
4589                         {
4590                                 do_cmd_use();
4591                         }
4592                         else
4593                         {
4594                                 do_cmd_zap_rod();
4595                         }
4596                         }
4597                         break;
4598                 }
4599
4600                 /* Quaff a potion */
4601                 case 'q':
4602                 {
4603                         if (!p_ptr->wild_mode)
4604                         {
4605                         if (!p_ptr->inside_arena)
4606                                 do_cmd_quaff_potion();
4607                         else
4608                         {
4609                                 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4610                                 msg_print(NULL);
4611                         }
4612                         }
4613                         break;
4614                 }
4615
4616                 /* Read a scroll */
4617                 case 'r':
4618                 {
4619                         if (!p_ptr->wild_mode)
4620                         {
4621                         if (!p_ptr->inside_arena)
4622                                 do_cmd_read_scroll();
4623                         else
4624                         {
4625                                 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4626                                 msg_print(NULL);
4627                         }
4628                         }
4629                         break;
4630                 }
4631
4632                 /* Use a staff */
4633                 case 'u':
4634                 {
4635                         if (!p_ptr->wild_mode)
4636                         {
4637                         if (p_ptr->inside_arena)
4638                         {
4639                                 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
4640                                 msg_print(NULL);
4641                         }
4642                         else if (use_command && !rogue_like_commands)
4643                         {
4644                                 do_cmd_use();
4645                         }
4646                         else
4647                                 do_cmd_use_staff();
4648                         }
4649                         break;
4650                 }
4651
4652                 /* Use racial power */
4653                 case 'U':
4654                 {
4655                         if (!p_ptr->wild_mode) do_cmd_racial_power();
4656                         break;
4657                 }
4658
4659
4660                 /*** Looking at Things (nearby or on map) ***/
4661
4662                 /* Full dungeon map */
4663                 case 'M':
4664                 {
4665                         do_cmd_view_map();
4666                         break;
4667                 }
4668
4669                 /* Locate player on map */
4670                 case 'L':
4671                 {
4672                         do_cmd_locate();
4673                         break;
4674                 }
4675
4676                 /* Look around */
4677                 case 'l':
4678                 {
4679                         do_cmd_look();
4680                         break;
4681                 }
4682
4683                 /* Target monster or location */
4684                 case '*':
4685                 {
4686                         if (!p_ptr->wild_mode) do_cmd_target();
4687                         break;
4688                 }
4689
4690
4691
4692                 /*** Help and Such ***/
4693
4694                 /* Help */
4695                 case '?':
4696                 {
4697                         do_cmd_help();
4698                         break;
4699                 }
4700
4701                 /* Identify symbol */
4702                 case '/':
4703                 {
4704                         do_cmd_query_symbol();
4705                         break;
4706                 }
4707
4708                 /* Character description */
4709                 case 'C':
4710                 {
4711                         do_cmd_change_name();
4712                         break;
4713                 }
4714
4715
4716                 /*** System Commands ***/
4717
4718                 /* Hack -- User interface */
4719                 case '!':
4720                 {
4721                         (void)Term_user(0);
4722                         break;
4723                 }
4724
4725                 /* Single line from a pref file */
4726                 case '"':
4727                 {
4728                         do_cmd_pref();
4729                         break;
4730                 }
4731
4732                 case '$':
4733                 {
4734                         do_cmd_reload_autopick();
4735                         break;
4736                 }
4737
4738                 case '_':
4739                 {
4740                         do_cmd_edit_autopick();
4741                         break;
4742                 }
4743
4744                 /* Interact with macros */
4745                 case '@':
4746                 {
4747                         do_cmd_macros();
4748                         break;
4749                 }
4750
4751                 /* Interact with visuals */
4752                 case '%':
4753                 {
4754                         do_cmd_visuals();
4755                         do_cmd_redraw();
4756                         break;
4757                 }
4758
4759                 /* Interact with colors */
4760                 case '&':
4761                 {
4762                         do_cmd_colors();
4763                         do_cmd_redraw();
4764                         break;
4765                 }
4766
4767                 /* Interact with options */
4768                 case '=':
4769                 {
4770                         do_cmd_options();
4771                         (void)combine_and_reorder_home(STORE_HOME);
4772                         do_cmd_redraw();
4773                         break;
4774                 }
4775
4776                 /*** Misc Commands ***/
4777
4778                 /* Take notes */
4779                 case ':':
4780                 {
4781                         do_cmd_note();
4782                         break;
4783                 }
4784
4785                 /* Version info */
4786                 case 'V':
4787                 {
4788                         do_cmd_version();
4789                         break;
4790                 }
4791
4792                 /* Repeat level feeling */
4793                 case KTRL('F'):
4794                 {
4795                         if (!p_ptr->wild_mode) do_cmd_feeling();
4796                         break;
4797                 }
4798
4799                 /* Show previous message */
4800                 case KTRL('O'):
4801                 {
4802                         do_cmd_message_one();
4803                         break;
4804                 }
4805
4806                 /* Show previous messages */
4807                 case KTRL('P'):
4808                 {
4809                         do_cmd_messages(old_now_message);
4810                         break;
4811                 }
4812
4813                 /* Show quest status -KMW- */
4814                 case KTRL('Q'):
4815                 {
4816                         do_cmd_checkquest();
4817                         break;
4818                 }
4819
4820                 /* Redraw the screen */
4821                 case KTRL('R'):
4822                 {
4823                         now_message = old_now_message;
4824                         do_cmd_redraw();
4825                         break;
4826                 }
4827
4828 #ifndef VERIFY_SAVEFILE
4829
4830                 /* Hack -- Save and don't quit */
4831                 case KTRL('S'):
4832                 {
4833                         do_cmd_save_game(FALSE);
4834                         break;
4835                 }
4836
4837 #endif /* VERIFY_SAVEFILE */
4838
4839                 case KTRL('T'):
4840                 {
4841                         do_cmd_time();
4842                         break;
4843                 }
4844
4845                 /* Save and quit */
4846                 case KTRL('X'):
4847                 case SPECIAL_KEY_QUIT:
4848                 {
4849                         do_cmd_save_and_exit();
4850                         break;
4851                 }
4852
4853                 /* Quit (commit suicide) */
4854                 case 'Q':
4855                 {
4856                         do_cmd_suicide();
4857                         break;
4858                 }
4859
4860                 case '|':
4861                 {
4862                         do_cmd_nikki();
4863                         break;
4864                 }
4865
4866                 /* Check artifacts, uniques, objects */
4867                 case '~':
4868                 {
4869                         do_cmd_knowledge();
4870                         break;
4871                 }
4872
4873                 /* Load "screen dump" */
4874                 case '(':
4875                 {
4876                         do_cmd_load_screen();
4877                         break;
4878                 }
4879
4880                 /* Save "screen dump" */
4881                 case ')':
4882                 {
4883                         do_cmd_save_screen();
4884                         break;
4885                 }
4886
4887                 /* Record/stop "Movie" */
4888                 case ']':
4889                 {
4890                         prepare_movie_hooks();
4891                         break;
4892                 }
4893
4894                 /* Make random artifact list */
4895                 case KTRL('V'):
4896                 {
4897                         spoil_random_artifact("randifact.txt");
4898                         break;
4899                 }
4900
4901 #ifdef TRAVEL
4902                 case '`':
4903                 {
4904                         if (!p_ptr->wild_mode) do_cmd_travel();
4905                         if (p_ptr->special_defense & KATA_MUSOU)
4906                         {
4907                                 set_action(ACTION_NONE);
4908                         }
4909                         break;
4910                 }
4911 #endif
4912
4913                 /* Hack -- Unknown command */
4914                 default:
4915                 {
4916                         if (flush_failure) flush();
4917                         if (one_in_(2))
4918                         {
4919                                 char error_m[1024];
4920                                 sound(SOUND_ILLEGAL);
4921                                 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
4922                                         msg_print(error_m);
4923                         }
4924                         else
4925                         {
4926                                 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
4927                         }
4928
4929                         break;
4930                 }
4931         }
4932         if (!p_ptr->energy_use && !now_message)
4933                 now_message = old_now_message;
4934 }
4935
4936 /*!
4937  * @brief モンスター種族が釣れる種族かどうかを判定する。
4938  * @param r_idx 判定したいモンスター種族のID
4939  * @return 釣れる対象ならばTRUEを返す
4940  */
4941 static bool monster_tsuri(int r_idx)
4942 {
4943         monster_race *r_ptr = &r_info[r_idx];
4944
4945         if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
4946                 return TRUE;
4947         else
4948                 return FALSE;
4949 }
4950
4951
4952 /*!
4953  * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow
4954  * @return なし
4955  */
4956 static void pack_overflow(void)
4957 {
4958         if (inventory[INVEN_PACK].k_idx)
4959         {
4960                 char o_name[MAX_NLEN];
4961                 object_type *o_ptr;
4962
4963                 /* Is auto-destroy done? */
4964                 notice_stuff();
4965                 if (!inventory[INVEN_PACK].k_idx) return;
4966
4967                 /* Access the slot to be dropped */
4968                 o_ptr = &inventory[INVEN_PACK];
4969
4970                 /* Disturbing */
4971                 disturb(0, 1);
4972
4973                 /* Warning */
4974                 msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!"));
4975
4976                 /* Describe */
4977                 object_desc(o_name, o_ptr, 0);
4978
4979                 /* Message */
4980                 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK));
4981
4982                 /* Drop it (carefully) near the player */
4983                 (void)drop_near(o_ptr, 0, p_ptr->y, p_ptr->x);
4984
4985                 /* Modify, Describe, Optimize */
4986                 inven_item_increase(INVEN_PACK, -255);
4987                 inven_item_describe(INVEN_PACK);
4988                 inven_item_optimize(INVEN_PACK);
4989
4990                 /* Handle "p_ptr->notice" */
4991                 notice_stuff();
4992
4993                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
4994                 handle_stuff();
4995         }
4996 }
4997
4998 /*!
4999  * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理  / process the effects per 100 energy at player speed.
5000  * @return なし
5001  */
5002 static void process_upkeep_with_speed(void)
5003 {
5004         /* Give the player some energy */
5005         if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5006         {
5007                 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5008         }
5009         
5010         /* No turn yet */
5011         if (p_ptr->enchant_energy_need > 0) return;
5012         
5013         while (p_ptr->enchant_energy_need <= 0)
5014         {
5015                 /* Handle the player song */
5016                 if (!load) check_music();
5017
5018                 /* Hex - Handle the hex spells */
5019                 if (!load) check_hex();
5020                 if (!load) revenge_spell();
5021                 
5022                 /* There is some randomness of needed energy */
5023                 p_ptr->enchant_energy_need += ENERGY_NEED();
5024         }
5025 }
5026
5027 /*!
5028  * @brief プレイヤーの行動処理 / Process the player
5029  * @return なし
5030  * @note
5031  * Notice the annoying code to handle "pack overflow", which\n
5032  * must come first just in case somebody manages to corrupt\n
5033  * the savefiles by clever use of menu commands or something.\n
5034  */
5035 static void process_player(void)
5036 {
5037         int i;
5038
5039         /*** Apply energy ***/
5040
5041         if (hack_mutation)
5042         {
5043                 msg_print(_("何か変わった気がする!", "You feel different!"));
5044
5045                 (void)gain_random_mutation(0);
5046                 hack_mutation = FALSE;
5047         }
5048
5049         if (p_ptr->inside_battle)
5050         {
5051                 for(i = 1; i < m_max; i++)
5052                 {
5053                         monster_type *m_ptr = &m_list[i];
5054
5055                         if (!m_ptr->r_idx) continue;
5056
5057                         /* Hack -- Detect monster */
5058                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5059
5060                         /* Update the monster */
5061                         update_mon(i, FALSE);
5062                 }
5063                 prt_time();
5064         }
5065
5066         /* Give the player some energy */
5067         else if (!(load && p_ptr->energy_need <= 0))
5068         {
5069                 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5070         }
5071
5072         /* No turn yet */
5073         if (p_ptr->energy_need > 0) return;
5074         if (!command_rep) prt_time();
5075
5076         /*** Check for interupts ***/
5077
5078         /* Complete resting */
5079         if (resting < 0)
5080         {
5081                 /* Basic resting */
5082                 if (resting == -1)
5083                 {
5084                         /* Stop resting */
5085                         if ((p_ptr->chp == p_ptr->mhp) &&
5086                             (p_ptr->csp >= p_ptr->msp))
5087                         {
5088                                 set_action(ACTION_NONE);
5089                         }
5090                 }
5091
5092                 /* Complete resting */
5093                 else if (resting == -2)
5094                 {
5095                         /* Stop resting */
5096                         if ((p_ptr->chp == p_ptr->mhp) &&
5097                             (p_ptr->csp >= p_ptr->msp) &&
5098                             !p_ptr->blind && !p_ptr->confused &&
5099                             !p_ptr->poisoned && !p_ptr->afraid &&
5100                             !p_ptr->stun && !p_ptr->cut &&
5101                             !p_ptr->slow && !p_ptr->paralyzed &&
5102                             !p_ptr->image && !p_ptr->word_recall &&
5103                             !p_ptr->alter_reality)
5104                         {
5105                                 set_action(ACTION_NONE);
5106                         }
5107                 }
5108         }
5109
5110         if (p_ptr->action == ACTION_FISH)
5111         {
5112                 /* Delay */
5113                 Term_xtra(TERM_XTRA_DELAY, 10);
5114                 if (one_in_(1000))
5115                 {
5116                         int r_idx;
5117                         bool success = FALSE;
5118                         get_mon_num_prep(monster_tsuri,NULL);
5119                         r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5120                         msg_print(NULL);
5121                         if (r_idx && one_in_(2))
5122                         {
5123                                 int y, x;
5124                                 y = p_ptr->y+ddy[tsuri_dir];
5125                                 x = p_ptr->x+ddx[tsuri_dir];
5126                                 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5127                                 {
5128                                         char m_name[80];
5129                                         monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5130                                         msg_format(_("%sが釣れた!", "You have a good catch!"), m_name);
5131                                         success = TRUE;
5132                                 }
5133                         }
5134                         if (!success)
5135                         {
5136                                 msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn!  The fish stole your bait!"));
5137                         }
5138                         disturb(0, 1);
5139                 }
5140         }
5141
5142         /* Handle "abort" */
5143         if (check_abort)
5144         {
5145                 /* Check for "player abort" (semi-efficiently for resting) */
5146                 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5147                 {
5148                         /* Do not wait */
5149                         inkey_scan = TRUE;
5150
5151                         /* Check for a key */
5152                         if (inkey())
5153                         {
5154                                 /* Flush input */
5155                                 flush();
5156
5157                                 /* Disturb */
5158                                 disturb(0, 1);
5159
5160                                 /* Hack -- Show a Message */
5161                                 msg_print(_("中断しました。", "Canceled."));
5162                         }
5163                 }
5164         }
5165
5166         if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5167         {
5168                 monster_type *m_ptr = &m_list[p_ptr->riding];
5169                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5170
5171                 if (MON_CSLEEP(m_ptr))
5172                 {
5173                         char m_name[80];
5174
5175                         /* Recover fully */
5176                         (void)set_monster_csleep(p_ptr->riding, 0);
5177
5178                         /* Acquire the monster name */
5179                         monster_desc(m_name, m_ptr, 0);
5180                         msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
5181                 }
5182
5183                 if (MON_STUNNED(m_ptr))
5184                 {
5185                         /* Hack -- Recover from stun */
5186                         if (set_monster_stunned(p_ptr->riding,
5187                                 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5188                         {
5189                                 char m_name[80];
5190
5191                                 /* Acquire the monster name */
5192                                 monster_desc(m_name, m_ptr, 0);
5193
5194                                 /* Dump a message */
5195                                 msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
5196                         }
5197                 }
5198
5199                 if (MON_CONFUSED(m_ptr))
5200                 {
5201                         /* Hack -- Recover from confusion */
5202                         if (set_monster_confused(p_ptr->riding,
5203                                 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5204                         {
5205                                 char m_name[80];
5206
5207                                 /* Acquire the monster name */
5208                                 monster_desc(m_name, m_ptr, 0);
5209
5210                                 /* Dump a message */
5211                                 msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
5212                         }
5213                 }
5214
5215                 if (MON_MONFEAR(m_ptr))
5216                 {
5217                         /* Hack -- Recover from fear */
5218                         if (set_monster_monfear(p_ptr->riding,
5219                                 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5220                         {
5221                                 char m_name[80];
5222
5223                                 /* Acquire the monster name */
5224                                 monster_desc(m_name, m_ptr, 0);
5225
5226                                 /* Dump a message */
5227                                 msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
5228                         }
5229                 }
5230
5231                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5232                 handle_stuff();
5233         }
5234         
5235         load = FALSE;
5236
5237         /* Fast */
5238         if (p_ptr->lightspeed)
5239         {
5240                 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5241         }
5242         if ((p_ptr->pclass == CLASS_FORCETRAINER) && (p_ptr->magic_num1[0]))
5243         {
5244                 if (p_ptr->magic_num1[0] < 40)
5245                 {
5246                         p_ptr->magic_num1[0] = 0;
5247                 }
5248                 else p_ptr->magic_num1[0] -= 40;
5249                 p_ptr->update |= (PU_BONUS);
5250         }
5251         if (p_ptr->action == ACTION_LEARN)
5252         {
5253                 s32b cost = 0L;
5254                 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5255
5256                 /* Convert the unit (1/2^16) to (1/2^32) */
5257                 s64b_LSHIFT(cost, cost_frac, 16);
5258
5259  
5260                 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5261                 {
5262                         /* Mana run out */
5263                         p_ptr->csp = 0;
5264                         p_ptr->csp_frac = 0;
5265                         set_action(ACTION_NONE);
5266                 }
5267                 else
5268                 {
5269                         /* Reduce mana */
5270                         s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5271                 }
5272                 p_ptr->redraw |= PR_MANA;
5273         }
5274
5275         if (p_ptr->special_defense & KATA_MASK)
5276         {
5277                 if (p_ptr->special_defense & KATA_MUSOU)
5278                 {
5279                         if (p_ptr->csp < 3)
5280                         {
5281                                 set_action(ACTION_NONE);
5282                         }
5283                         else
5284                         {
5285                                 p_ptr->csp -= 2;
5286                                 p_ptr->redraw |= (PR_MANA);
5287                         }
5288                 }
5289         }
5290
5291         /*** Handle actual user input ***/
5292
5293         /* Repeat until out of energy */
5294         while (p_ptr->energy_need <= 0)
5295         {
5296                 p_ptr->window |= PW_PLAYER;
5297                 p_ptr->sutemi = FALSE;
5298                 p_ptr->counter = FALSE;
5299                 now_damaged = FALSE;
5300
5301                 /* Handle "p_ptr->notice" */
5302                 notice_stuff();
5303
5304                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5305                 handle_stuff();
5306
5307                 /* Place the cursor on the player */
5308                 move_cursor_relative(p_ptr->y, p_ptr->x);
5309
5310                 /* Refresh (optional) */
5311                 if (fresh_before) Term_fresh();
5312
5313
5314                 /* Hack -- Pack Overflow */
5315                 pack_overflow();
5316
5317
5318                 /* Hack -- cancel "lurking browse mode" */
5319                 if (!command_new) command_see = FALSE;
5320
5321
5322                 /* Assume free turn */
5323                 p_ptr->energy_use = 0;
5324
5325
5326                 if (p_ptr->inside_battle)
5327                 {
5328                         /* Place the cursor on the player */
5329                         move_cursor_relative(p_ptr->y, p_ptr->x);
5330
5331                         command_cmd = SPECIAL_KEY_BUILDING;
5332
5333                         /* Process the command */
5334                         process_command();
5335                 }
5336
5337                 /* Paralyzed or Knocked Out */
5338                 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5339                 {
5340                         /* Take a turn */
5341                         p_ptr->energy_use = 100;
5342                 }
5343
5344                 /* Resting */
5345                 else if (p_ptr->action == ACTION_REST)
5346                 {
5347                         /* Timed rest */
5348                         if (resting > 0)
5349                         {
5350                                 /* Reduce rest count */
5351                                 resting--;
5352
5353                                 if (!resting) set_action(ACTION_NONE);
5354
5355                                 /* Redraw the state */
5356                                 p_ptr->redraw |= (PR_STATE);
5357                         }
5358
5359                         /* Take a turn */
5360                         p_ptr->energy_use = 100;
5361                 }
5362
5363                 /* Fishing */
5364                 else if (p_ptr->action == ACTION_FISH)
5365                 {
5366                         /* Take a turn */
5367                         p_ptr->energy_use = 100;
5368                 }
5369
5370                 /* Running */
5371                 else if (running)
5372                 {
5373                         /* Take a step */
5374                         run_step(0);
5375                 }
5376
5377 #ifdef TRAVEL
5378                 /* Traveling */
5379                 else if (travel.run)
5380                 {
5381                         /* Take a step */
5382                         travel_step();
5383                 }
5384 #endif
5385
5386                 /* Repeated command */
5387                 else if (command_rep)
5388                 {
5389                         /* Count this execution */
5390                         command_rep--;
5391
5392                         /* Redraw the state */
5393                         p_ptr->redraw |= (PR_STATE);
5394
5395                         /* Redraw stuff */
5396                         redraw_stuff();
5397
5398                         /* Hack -- Assume messages were seen */
5399                         msg_flag = FALSE;
5400
5401                         /* Clear the top line */
5402                         prt("", 0, 0);
5403
5404                         /* Process the command */
5405                         process_command();
5406                 }
5407
5408                 /* Normal command */
5409                 else
5410                 {
5411                         /* Place the cursor on the player */
5412                         move_cursor_relative(p_ptr->y, p_ptr->x);
5413
5414                         can_save = TRUE;
5415                         /* Get a command (normal) */
5416                         request_command(FALSE);
5417                         can_save = FALSE;
5418
5419                         /* Process the command */
5420                         process_command();
5421                 }
5422
5423
5424                 /* Hack -- Pack Overflow */
5425                 pack_overflow();
5426
5427
5428                 /*** Clean up ***/
5429
5430                 /* Significant */
5431                 if (p_ptr->energy_use)
5432                 {
5433                         /* Use some energy */
5434                         if (world_player || p_ptr->energy_use > 400)
5435                         {
5436                                 /* The Randomness is irrelevant */
5437                                 p_ptr->energy_need += p_ptr->energy_use * TURNS_PER_TICK / 10;
5438                         }
5439                         else
5440                         {
5441                                 /* There is some randomness of needed energy */
5442                                 p_ptr->energy_need += (s16b)((s32b)p_ptr->energy_use * ENERGY_NEED() / 100L);
5443                         }
5444
5445                         /* Hack -- constant hallucination */
5446                         if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
5447
5448
5449                         /* Shimmer monsters if needed */
5450                         if (shimmer_monsters)
5451                         {
5452                                 /* Clear the flag */
5453                                 shimmer_monsters = FALSE;
5454
5455                                 /* Shimmer multi-hued monsters */
5456                                 for (i = 1; i < m_max; i++)
5457                                 {
5458                                         monster_type *m_ptr;
5459                                         monster_race *r_ptr;
5460
5461                                         /* Access monster */
5462                                         m_ptr = &m_list[i];
5463
5464                                         /* Skip dead monsters */
5465                                         if (!m_ptr->r_idx) continue;
5466
5467                                         /* Skip unseen monsters */
5468                                         if (!m_ptr->ml) continue;
5469
5470                                         /* Access the monster race */
5471                                         r_ptr = &r_info[m_ptr->ap_r_idx];
5472
5473                                         /* Skip non-multi-hued monsters */
5474                                         if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
5475                                                 continue;
5476
5477                                         /* Reset the flag */
5478                                         shimmer_monsters = TRUE;
5479
5480                                         /* Redraw regardless */
5481                                         lite_spot(m_ptr->fy, m_ptr->fx);
5482                                 }
5483                         }
5484
5485
5486                         /* Handle monster detection */
5487                         if (repair_monsters)
5488                         {
5489                                 /* Reset the flag */
5490                                 repair_monsters = FALSE;
5491
5492                                 /* Rotate detection flags */
5493                                 for (i = 1; i < m_max; i++)
5494                                 {
5495                                         monster_type *m_ptr;
5496
5497                                         /* Access monster */
5498                                         m_ptr = &m_list[i];
5499
5500                                         /* Skip dead monsters */
5501                                         if (!m_ptr->r_idx) continue;
5502
5503                                         /* Nice monsters get mean */
5504                                         if (m_ptr->mflag & MFLAG_NICE)
5505                                         {
5506                                                 /* Nice monsters get mean */
5507                                                 m_ptr->mflag &= ~(MFLAG_NICE);
5508                                         }
5509
5510                                         /* Handle memorized monsters */
5511                                         if (m_ptr->mflag2 & MFLAG2_MARK)
5512                                         {
5513                                                 /* Maintain detection */
5514                                                 if (m_ptr->mflag2 & MFLAG2_SHOW)
5515                                                 {
5516                                                         /* Forget flag */
5517                                                         m_ptr->mflag2 &= ~(MFLAG2_SHOW);
5518
5519                                                         /* Still need repairs */
5520                                                         repair_monsters = TRUE;
5521                                                 }
5522
5523                                                 /* Remove detection */
5524                                                 else
5525                                                 {
5526                                                         /* Forget flag */
5527                                                         m_ptr->mflag2 &= ~(MFLAG2_MARK);
5528
5529                                                         /* Assume invisible */
5530                                                         m_ptr->ml = FALSE;
5531
5532                                                         /* Update the monster */
5533                                                         update_mon(i, FALSE);
5534
5535                                                         if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
5536                                                         if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
5537
5538                                                         /* Redraw regardless */
5539                                                         lite_spot(m_ptr->fy, m_ptr->fx);
5540                                                 }
5541                                         }
5542                                 }
5543                         }
5544                         if (p_ptr->pclass == CLASS_IMITATOR)
5545                         {
5546                                 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
5547                                 {
5548                                         p_ptr->mane_num--;
5549                                         for (i = 0; i < p_ptr->mane_num; i++)
5550                                         {
5551                                                 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
5552                                                 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
5553                                         }
5554                                 }
5555                                 new_mane = FALSE;
5556                                 p_ptr->redraw |= (PR_IMITATION);
5557                         }
5558                         if (p_ptr->action == ACTION_LEARN)
5559                         {
5560                                 new_mane = FALSE;
5561                                 p_ptr->redraw |= (PR_STATE);
5562                         }
5563
5564                         if (world_player && (p_ptr->energy_need > - 1000))
5565                         {
5566                                 /* Redraw map */
5567                                 p_ptr->redraw |= (PR_MAP);
5568
5569                                 /* Update monsters */
5570                                 p_ptr->update |= (PU_MONSTERS);
5571
5572                                 /* Window stuff */
5573                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5574
5575                                 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
5576                                 msg_print(NULL);
5577                                 world_player = FALSE;
5578                                 p_ptr->energy_need = ENERGY_NEED();
5579
5580                                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5581                                 handle_stuff();
5582                         }
5583                 }
5584
5585                 /* Hack -- notice death */
5586                 if (!p_ptr->playing || p_ptr->is_dead)
5587                 {
5588                         world_player = FALSE;
5589                         break;
5590                 }
5591
5592                 /* Sniper */
5593                 if (p_ptr->energy_use && reset_concent) reset_concentration(TRUE);
5594
5595                 /* Handle "leaving" */
5596                 if (p_ptr->leaving) break;
5597         }
5598
5599         /* Update scent trail */
5600         update_smell();
5601 }
5602
5603 /*!
5604  * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
5605  * @return なし
5606  * @note
5607  * This function will not exit until the level is completed,\n
5608  * the user dies, or the game is terminated.\n
5609  */
5610 static void dungeon(bool load_game)
5611 {
5612         int quest_num = 0;
5613
5614         /* Set the base level */
5615         base_level = dun_level;
5616
5617         /* Reset various flags */
5618         hack_mind = FALSE;
5619
5620         /* Not leaving */
5621         p_ptr->leaving = FALSE;
5622
5623         /* Reset the "command" vars */
5624         command_cmd = 0;
5625
5626 #if 0 /* Don't reset here --- It's used for Arena */
5627         command_new = 0;
5628 #endif
5629
5630         command_rep = 0;
5631         command_arg = 0;
5632         command_dir = 0;
5633
5634
5635         /* Cancel the target */
5636         target_who = 0;
5637         pet_t_m_idx = 0;
5638         riding_t_m_idx = 0;
5639         ambush_flag = FALSE;
5640
5641         /* Cancel the health bar */
5642         health_track(0);
5643
5644         /* Check visual effects */
5645         shimmer_monsters = TRUE;
5646         shimmer_objects = TRUE;
5647         repair_monsters = TRUE;
5648         repair_objects = TRUE;
5649
5650
5651         /* Disturb */
5652         disturb(1, 1);
5653
5654         /* Get index of current quest (if any) */
5655         quest_num = quest_number(dun_level);
5656
5657         /* Inside a quest? */
5658         if (quest_num)
5659         {
5660                 /* Mark the quest monster */
5661                 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
5662         }
5663
5664         /* Track maximum player level */
5665         if (p_ptr->max_plv < p_ptr->lev)
5666         {
5667                 p_ptr->max_plv = p_ptr->lev;
5668         }
5669
5670
5671         /* Track maximum dungeon level (if not in quest -KMW-) */
5672         if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
5673         {
5674                 max_dlv[dungeon_type] = dun_level;
5675                 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
5676         }
5677
5678         (void)calculate_upkeep();
5679
5680         /* Validate the panel */
5681         panel_bounds_center();
5682
5683         /* Verify the panel */
5684         verify_panel();
5685
5686         /* Flush messages */
5687         msg_print(NULL);
5688
5689
5690         /* Enter "xtra" mode */
5691         character_xtra = TRUE;
5692
5693         /* Window stuff */
5694         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
5695
5696         /* Redraw dungeon */
5697         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5698
5699         /* Redraw map */
5700         p_ptr->redraw |= (PR_MAP);
5701
5702         /* Update stuff */
5703         p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5704
5705         /* Update lite/view */
5706         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
5707
5708         /* Update monsters */
5709         p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
5710
5711         /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5712         handle_stuff();
5713
5714         /* Leave "xtra" mode */
5715         character_xtra = FALSE;
5716
5717         /* Update stuff */
5718         p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5719
5720         /* Combine / Reorder the pack */
5721         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5722
5723         /* Handle "p_ptr->notice" */
5724         notice_stuff();
5725
5726         /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5727         handle_stuff();
5728
5729         /* Refresh */
5730         Term_fresh();
5731
5732         if (quest_num && (is_fixed_quest_idx(quest_num) &&
5733             !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
5734             !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
5735
5736         if (p_ptr->inside_battle)
5737         {
5738                 if (load_game)
5739                 {
5740                         p_ptr->energy_need = 0;
5741                         battle_monsters();
5742                 }
5743                 else
5744                 {
5745                         msg_print(_("試合開始!", "Ready..Fight!"));
5746                         msg_print(NULL);
5747                 }
5748         }
5749
5750         if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] > MUSIC_DETECT))
5751                 p_ptr->magic_num1[0] = MUSIC_DETECT;
5752
5753         /* Hack -- notice death or departure */
5754         if (!p_ptr->playing || p_ptr->is_dead) return;
5755
5756         /* Print quest message if appropriate */
5757         if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
5758         {
5759                 quest_discovery(random_quest_number(dun_level));
5760                 p_ptr->inside_quest = random_quest_number(dun_level);
5761         }
5762         if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
5763         {
5764                 if (r_info[d_info[dungeon_type].final_guardian].max_num)
5765 #ifdef JP
5766                         msg_format("この階には%sの主である%sが棲んでいる。",
5767                                    d_name+d_info[dungeon_type].name, 
5768                                    r_name+r_info[d_info[dungeon_type].final_guardian].name);
5769 #else
5770                         msg_format("%^s lives in this level as the keeper of %s.",
5771                                            r_name+r_info[d_info[dungeon_type].final_guardian].name, 
5772                                            d_name+d_info[dungeon_type].name);
5773 #endif
5774         }
5775
5776         if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
5777
5778         /*** Process this dungeon level ***/
5779
5780         /* Reset the monster generation level */
5781         monster_level = base_level;
5782
5783         /* Reset the object generation level */
5784         object_level = base_level;
5785
5786         hack_mind = TRUE;
5787
5788         if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
5789             (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
5790                 p_ptr->energy_need = 0;
5791
5792         /* Not leaving dungeon */
5793         p_ptr->leaving_dungeon = FALSE;
5794
5795         /* Initialize monster process */
5796         mproc_init();
5797
5798         /* Main loop */
5799         while (TRUE)
5800         {
5801                 /* Hack -- Compact the monster list occasionally */
5802                 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
5803
5804                 /* Hack -- Compress the monster list occasionally */
5805                 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
5806
5807
5808                 /* Hack -- Compact the object list occasionally */
5809                 if (o_cnt + 32 > max_o_idx) compact_objects(64);
5810
5811                 /* Hack -- Compress the object list occasionally */
5812                 if (o_cnt + 32 < o_max) compact_objects(0);
5813
5814                 
5815                 /* Process the player */
5816                 process_player();
5817                 
5818                 process_upkeep_with_speed();
5819
5820                 /* Handle "p_ptr->notice" */
5821                 notice_stuff();
5822
5823                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5824                 handle_stuff();
5825
5826                 /* Hack -- Hilite the player */
5827                 move_cursor_relative(p_ptr->y, p_ptr->x);
5828
5829                 /* Optional fresh */
5830                 if (fresh_after) Term_fresh();
5831
5832                 /* Hack -- Notice death or departure */
5833                 if (!p_ptr->playing || p_ptr->is_dead) break;
5834
5835                 /* Process all of the monsters */
5836                 process_monsters();
5837
5838                 /* Handle "p_ptr->notice" */
5839                 notice_stuff();
5840
5841                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5842                 handle_stuff();
5843
5844                 /* Hack -- Hilite the player */
5845                 move_cursor_relative(p_ptr->y, p_ptr->x);
5846
5847                 /* Optional fresh */
5848                 if (fresh_after) Term_fresh();
5849
5850                 /* Hack -- Notice death or departure */
5851                 if (!p_ptr->playing || p_ptr->is_dead) break;
5852
5853
5854                 /* Process the world */
5855                 process_world();
5856
5857                 /* Handle "p_ptr->notice" */
5858                 notice_stuff();
5859
5860                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5861                 handle_stuff();
5862
5863                 /* Hack -- Hilite the player */
5864                 move_cursor_relative(p_ptr->y, p_ptr->x);
5865
5866                 /* Optional fresh */
5867                 if (fresh_after) Term_fresh();
5868
5869                 /* Hack -- Notice death or departure */
5870                 if (!p_ptr->playing || p_ptr->is_dead) break;
5871
5872                 /* Handle "leaving" */
5873                 if (p_ptr->leaving) break;
5874
5875                 /* Count game turns */
5876                 turn++;
5877
5878                 if (dungeon_turn < dungeon_turn_limit)
5879                 {
5880                         if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
5881                         else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
5882                 }
5883
5884                 prevent_turn_overflow();
5885
5886                 if (wild_regen) wild_regen--;
5887         }
5888
5889         /* Inside a quest and non-unique questor? */
5890         if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
5891         {
5892                 /* Un-mark the quest monster */
5893                 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
5894         }
5895
5896         /* Not save-and-quit and not dead? */
5897         if (p_ptr->playing && !p_ptr->is_dead)
5898         {
5899                 /*
5900                  * Maintain Unique monsters and artifact, save current
5901                  * floor, then prepare next floor
5902                  */
5903                 leave_floor();
5904
5905                 /* Forget the flag */
5906                 reinit_wilderness = FALSE;
5907         }
5908
5909         /* Write about current level on the play record once per level */
5910         write_level = TRUE;
5911 }
5912
5913
5914 /*!
5915  * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
5916  * @return なし
5917  * @note
5918  * Modified by Arcum Dagsson to support
5919  * separate macro files for different realms.
5920  */
5921 static void load_all_pref_files(void)
5922 {
5923         char buf[1024];
5924
5925         /* Access the "user" pref file */
5926         sprintf(buf, "user.prf");
5927
5928         /* Process that file */
5929         process_pref_file(buf);
5930
5931         /* Access the "user" system pref file */
5932         sprintf(buf, "user-%s.prf", ANGBAND_SYS);
5933
5934         /* Process that file */
5935         process_pref_file(buf);
5936
5937         /* Access the "race" pref file */
5938         sprintf(buf, "%s.prf", rp_ptr->title);
5939
5940         /* Process that file */
5941         process_pref_file(buf);
5942
5943         /* Access the "class" pref file */
5944         sprintf(buf, "%s.prf", cp_ptr->title);
5945
5946         /* Process that file */
5947         process_pref_file(buf);
5948
5949         /* Access the "character" pref file */
5950         sprintf(buf, "%s.prf", player_base);
5951
5952         /* Process that file */
5953         process_pref_file(buf);
5954
5955         /* Access the "realm 1" pref file */
5956         if (p_ptr->realm1 != REALM_NONE)
5957         {
5958                 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
5959
5960                 /* Process that file */
5961                 process_pref_file(buf);
5962         }
5963
5964         /* Access the "realm 2" pref file */
5965         if (p_ptr->realm2 != REALM_NONE)
5966         {
5967                 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
5968
5969                 /* Process that file */
5970                 process_pref_file(buf);
5971         }
5972
5973
5974         /* Load an autopick preference file */
5975         autopick_load_pref(FALSE);
5976 }
5977
5978
5979 /*!
5980  * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
5981  * @return なし
5982  */
5983 void extract_option_vars(void)
5984 {
5985         int i;
5986
5987         for (i = 0; option_info[i].o_desc; i++)
5988         {
5989                 int os = option_info[i].o_set;
5990                 int ob = option_info[i].o_bit;
5991
5992                 /* Set the "default" options */
5993                 if (option_info[i].o_var)
5994                 {
5995                         /* Set */
5996                         if (option_flag[os] & (1L << ob))
5997                         {
5998                                 /* Set */
5999                                 (*option_info[i].o_var) = TRUE;
6000                         }
6001
6002                         /* Clear */
6003                         else
6004                         {
6005                                 /* Clear */
6006                                 (*option_info[i].o_var) = FALSE;
6007                         }
6008                 }
6009         }
6010 }
6011
6012
6013 /*!
6014  * @brief 賞金首となるユニークを確定する / Determine bounty uniques
6015  * @return なし
6016  */
6017 void determine_bounty_uniques(void)
6018 {
6019         int          i, j, tmp;
6020         monster_race *r_ptr;
6021
6022         get_mon_num_prep(NULL, NULL);
6023         for (i = 0; i < MAX_KUBI; i++)
6024         {
6025                 while (1)
6026                 {
6027                         kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6028                         r_ptr = &r_info[kubi_r_idx[i]];
6029
6030                         if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6031
6032                         if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6033
6034                         if (r_ptr->rarity > 100) continue;
6035
6036                         if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6037
6038                         for (j = 0; j < i; j++)
6039                                 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6040
6041                         if (j == i) break;
6042                 }
6043         }
6044
6045         /* Sort them */
6046         for (i = 0; i < MAX_KUBI - 1; i++)
6047         {
6048                 for (j = i; j < MAX_KUBI; j++)
6049                 {
6050                         if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6051                         {
6052                                 tmp = kubi_r_idx[i];
6053                                 kubi_r_idx[i] = kubi_r_idx[j];
6054                                 kubi_r_idx[j] = tmp;
6055                         }
6056                 }
6057         }
6058 }
6059
6060
6061 /*!
6062  * @brief 今日の賞金首を確定する / Determine today's bounty monster
6063  * @return なし
6064  * @note conv_old is used if loaded 0.0.3 or older save file
6065  */
6066 void determine_today_mon(bool conv_old)
6067 {
6068         int max_dl = 3, i;
6069         bool old_inside_battle = p_ptr->inside_battle;
6070         monster_race *r_ptr;
6071
6072         if (!conv_old)
6073         {
6074                 for (i = 0; i < max_d_idx; i++)
6075                 {
6076                         if (max_dlv[i] < d_info[i].mindepth) continue;
6077                         if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6078                 }
6079         }
6080         else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6081
6082         p_ptr->inside_battle = TRUE;
6083         get_mon_num_prep(NULL, NULL);
6084
6085         while (1)
6086         {
6087                 today_mon = get_mon_num(max_dl);
6088                 r_ptr = &r_info[today_mon];
6089
6090                 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6091                 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6092                 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6093                 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6094                 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6095                 if (r_ptr->rarity > 10) continue;
6096                 break;
6097         }
6098
6099         p_ptr->today_mon = 0;
6100         p_ptr->inside_battle = old_inside_battle;
6101 }
6102
6103 /*!
6104  * @brief 1ゲームプレイの主要ルーチン / Actually play a game
6105  * @return なし
6106  * @note
6107  * If the "new_game" parameter is true, then, after loading the
6108  * savefile, we will commit suicide, if necessary, to allow the
6109  * player to start a new game.
6110  */
6111 void play_game(bool new_game)
6112 {
6113         int i;
6114         bool load_game = TRUE;
6115         bool init_random_seed = FALSE;
6116
6117 #ifdef CHUUKEI
6118         if (chuukei_client)
6119         {
6120                 reset_visuals();
6121                 browse_chuukei();
6122                 return;
6123         }
6124
6125         else if (chuukei_server)
6126         {
6127                 prepare_chuukei_hooks();
6128         }
6129 #endif
6130
6131         if (browsing_movie)
6132         {
6133                 reset_visuals();
6134                 browse_movie();
6135                 return;
6136         }
6137
6138         hack_mutation = FALSE;
6139
6140         /* Hack -- Character is "icky" */
6141         character_icky = TRUE;
6142
6143         /* Make sure main term is active */
6144         Term_activate(angband_term[0]);
6145
6146         /* Initialise the resize hooks */
6147         angband_term[0]->resize_hook = resize_map;
6148
6149         for (i = 1; i < 8; i++)
6150         {
6151                 /* Does the term exist? */
6152                 if (angband_term[i])
6153                 {
6154                         /* Add the redraw on resize hook */
6155                         angband_term[i]->resize_hook = redraw_window;
6156                 }
6157         }
6158
6159         /* Hack -- turn off the cursor */
6160         (void)Term_set_cursor(0);
6161
6162
6163         /* Attempt to load */
6164         if (!load_player())
6165         {
6166                 /* Oops */
6167                 quit(_("セーブファイルが壊れています", "broken savefile"));
6168         }
6169
6170         /* Extract the options */
6171         extract_option_vars();
6172
6173         /* Report waited score */
6174         if (p_ptr->wait_report_score)
6175         {
6176                 char buf[1024];
6177                 bool success;
6178
6179                 if (!get_check_strict(_("待機していたスコア登録を今行ないますか?", "Do you register score now? "), CHECK_NO_HISTORY))
6180                         quit(0);
6181
6182                 /* Update stuff */
6183                 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6184
6185                 /* Update stuff */
6186                 update_stuff();
6187
6188                 p_ptr->is_dead = TRUE;
6189
6190                 start_time = time(NULL);
6191
6192                 /* No suspending now */
6193                 signals_ignore_tstp();
6194                 
6195                 /* Hack -- Character is now "icky" */
6196                 character_icky = TRUE;
6197
6198                 /* Build the filename */
6199                 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6200
6201                 /* Open the high score file, for reading/writing */
6202                 highscore_fd = fd_open(buf, O_RDWR);
6203
6204                 /* Handle score, show Top scores */
6205                 success = send_world_score(TRUE);
6206
6207                 if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
6208                 {
6209                         prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0);
6210                         (void)inkey();
6211                 }
6212                 else
6213                 {
6214                         p_ptr->wait_report_score = FALSE;
6215                         top_twenty();
6216                         if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6217                 }
6218                 /* Shut the high score file */
6219                 (void)fd_close(highscore_fd);
6220
6221                 /* Forget the high score fd */
6222                 highscore_fd = -1;
6223                 
6224                 /* Allow suspending now */
6225                 signals_handle_tstp();
6226
6227                 quit(0);
6228         }
6229
6230         creating_savefile = new_game;
6231
6232         /* Nothing loaded */
6233         if (!character_loaded)
6234         {
6235                 /* Make new player */
6236                 new_game = TRUE;
6237
6238                 /* The dungeon is not ready */
6239                 character_dungeon = FALSE;
6240
6241                 /* Prepare to init the RNG */
6242                 init_random_seed = TRUE;
6243
6244                 /* Initialize the saved floors data */
6245                 init_saved_floors(FALSE);
6246         }
6247
6248         /* Old game is loaded.  But new game is requested. */
6249         else if (new_game)
6250         {
6251                 /* Initialize the saved floors data */
6252                 init_saved_floors(TRUE);
6253         }
6254
6255         /* Process old character */
6256         if (!new_game)
6257         {
6258                 /* Process the player name */
6259                 process_player_name(FALSE);
6260         }
6261
6262         /* Init the RNG */
6263         if (init_random_seed)
6264         {
6265                 Rand_state_init();
6266         }
6267
6268         /* Roll new character */
6269         if (new_game)
6270         {
6271                 /* The dungeon is not ready */
6272                 character_dungeon = FALSE;
6273
6274                 /* Start in town */
6275                 dun_level = 0;
6276                 p_ptr->inside_quest = 0;
6277                 p_ptr->inside_arena = FALSE;
6278                 p_ptr->inside_battle = FALSE;
6279
6280                 write_level = TRUE;
6281
6282                 /* Hack -- seed for flavors */
6283                 seed_flavor = randint0(0x10000000);
6284
6285                 /* Hack -- seed for town layout */
6286                 seed_town = randint0(0x10000000);
6287
6288                 /* Roll up a new character */
6289                 player_birth();
6290
6291                 counts_write(2,0);
6292                 p_ptr->count = 0;
6293
6294                 load = FALSE;
6295
6296                 determine_bounty_uniques();
6297                 determine_today_mon(FALSE);
6298
6299                 /* Initialize object array */
6300                 wipe_o_list();
6301         }
6302         else
6303         {
6304                 write_level = FALSE;
6305
6306                 do_cmd_write_nikki(NIKKI_GAMESTART, 1, 
6307                                           _("                            ----ゲーム再開----",
6308                                                 "                            ---- Restart Game ----"));
6309
6310 /*
6311  * 1.0.9 以前はセーブ前に p_ptr->riding = -1 としていたので、再設定が必要だった。
6312  * もう不要だが、以前のセーブファイルとの互換のために残しておく。
6313  */
6314                 if (p_ptr->riding == -1)
6315                 {
6316                         p_ptr->riding = 0;
6317                         for (i = m_max; i > 0; i--)
6318                         {
6319                                 if (player_bold(m_list[i].fy, m_list[i].fx))
6320                                 {
6321                                         p_ptr->riding = i;
6322                                         break;
6323                                 }
6324                         }
6325                 }
6326         }
6327
6328         creating_savefile = FALSE;
6329
6330         p_ptr->teleport_town = FALSE;
6331         p_ptr->sutemi = FALSE;
6332         world_monster = FALSE;
6333         now_damaged = FALSE;
6334         now_message = 0;
6335         start_time = time(NULL) - 1;
6336         record_o_name[0] = '\0';
6337
6338         /* Reset map panel */
6339         panel_row_min = cur_hgt;
6340         panel_col_min = cur_wid;
6341
6342         /* Sexy gal gets bonus to maximum weapon skill of whip */
6343         if (p_ptr->pseikaku == SEIKAKU_SEXY)
6344                 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6345
6346         /* Fill the arrays of floors and walls in the good proportions */
6347         set_floor_and_wall(dungeon_type);
6348
6349         /* Flavor the objects */
6350         flavor_init();
6351
6352         /* Flash a message */
6353         prt(_("お待ち下さい...", "Please wait..."), 0, 0);
6354
6355         /* Flush the message */
6356         Term_fresh();
6357
6358
6359         /* Hack -- Enter wizard mode */
6360         if (arg_wizard)
6361         {
6362                 if (enter_wizard_mode())
6363                 {
6364                         p_ptr->wizard = TRUE;
6365
6366                         if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x)
6367                         {
6368                                 /* Initialize the saved floors data */
6369                                 init_saved_floors(TRUE);
6370
6371                                 /* Avoid crash */
6372                                 p_ptr->inside_quest = 0;
6373
6374                                 /* Avoid crash in update_view() */
6375                                 p_ptr->y = p_ptr->x = 10;
6376                         }
6377                 }
6378                 else if (p_ptr->is_dead)
6379                 {
6380                         quit("Already dead.");
6381                 }
6382         }
6383
6384         /* Initialize the town-buildings if necessary */
6385         if (!dun_level && !p_ptr->inside_quest)
6386         {
6387                 /* Init the wilderness */
6388
6389                 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
6390
6391                 /* Init the town */
6392                 init_flags = INIT_ONLY_BUILDINGS;
6393
6394                 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
6395
6396                 select_floor_music();
6397         }
6398
6399
6400         /* Generate a dungeon level if needed */
6401         if (!character_dungeon)
6402         {
6403                 change_floor();
6404         }
6405
6406         else
6407         {
6408                 /* HACK -- Restore from panic-save */
6409                 if (p_ptr->panic_save)
6410                 {
6411                         /* No player?  -- Try to regenerate floor */
6412                         if (!p_ptr->y || !p_ptr->x)
6413                         {
6414                                 msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location.  Regenerate the dungeon floor."));
6415                                 change_floor();
6416                         }
6417
6418                         /* Still no player?  -- Try to locate random place */
6419                         if (!p_ptr->y || !p_ptr->x) p_ptr->y = p_ptr->x = 10;
6420
6421                         /* No longer in panic */
6422                         p_ptr->panic_save = 0;
6423                 }
6424         }
6425
6426         /* Character is now "complete" */
6427         character_generated = TRUE;
6428
6429
6430         /* Hack -- Character is no longer "icky" */
6431         character_icky = FALSE;
6432
6433
6434         if (new_game)
6435         {
6436                 char buf[80];
6437                 sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name());
6438                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
6439         }
6440
6441
6442         /* Start game */
6443         p_ptr->playing = TRUE;
6444
6445         /* Reset the visual mappings */
6446         reset_visuals();
6447
6448         /* Load the "pref" files */
6449         load_all_pref_files();
6450
6451         /* Give startup outfit (after loading pref files) */
6452         if (new_game)
6453         {
6454                 player_outfit();
6455         }
6456
6457         /* React to changes */
6458         Term_xtra(TERM_XTRA_REACT, 0);
6459
6460         /* Window stuff */
6461         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
6462
6463         /* Window stuff */
6464         p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
6465
6466         /* Window stuff */
6467         window_stuff();
6468
6469
6470         /* Set or clear "rogue_like_commands" if requested */
6471         if (arg_force_original) rogue_like_commands = FALSE;
6472         if (arg_force_roguelike) rogue_like_commands = TRUE;
6473
6474         /* Hack -- Enforce "delayed death" */
6475         if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
6476
6477         if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
6478
6479         if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
6480         {
6481                 monster_type *m_ptr;
6482                 int pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
6483                 monster_race *r_ptr = &r_info[pet_r_idx];
6484                 place_monster_aux(0, p_ptr->y, p_ptr->x - 1, pet_r_idx,
6485                                   (PM_FORCE_PET | PM_NO_KAGE));
6486                 m_ptr = &m_list[hack_m_idx_ii];
6487                 m_ptr->mspeed = r_ptr->speed;
6488                 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
6489                 m_ptr->max_maxhp = m_ptr->maxhp;
6490                 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
6491                 m_ptr->dealt_damage = 0;
6492                 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
6493         }
6494
6495         (void)combine_and_reorder_home(STORE_HOME);
6496         (void)combine_and_reorder_home(STORE_MUSEUM);
6497
6498         select_floor_music();
6499
6500         /* Process */
6501         while (TRUE)
6502         {
6503                 /* Process the level */
6504                 dungeon(load_game);
6505
6506                 /* Handle "p_ptr->notice" */
6507                 notice_stuff();
6508
6509                 /* Hack -- prevent "icky" message */
6510                 character_xtra = TRUE;
6511
6512                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6513                 handle_stuff();
6514
6515                 character_xtra = FALSE;
6516
6517                 /* Cancel the target */
6518                 target_who = 0;
6519
6520                 /* Cancel the health bar */
6521                 health_track(0);
6522
6523
6524                 /* Forget the lite */
6525                 forget_lite();
6526
6527                 /* Forget the view */
6528                 forget_view();
6529
6530                 /* Forget the view */
6531                 clear_mon_lite();
6532
6533                 /* Handle "quit and save" */
6534                 if (!p_ptr->playing && !p_ptr->is_dead) break;
6535
6536                 /* Erase the old cave */
6537                 wipe_o_list();
6538                 if (!p_ptr->is_dead) wipe_m_list();
6539
6540
6541                 /* XXX XXX XXX */
6542                 msg_print(NULL);
6543
6544                 load_game = FALSE;
6545
6546                 /* Accidental Death */
6547                 if (p_ptr->playing && p_ptr->is_dead)
6548                 {
6549                         if (p_ptr->inside_arena)
6550                         {
6551                                 p_ptr->inside_arena = FALSE;
6552                                 if (p_ptr->arena_number > MAX_ARENA_MONS)
6553                                         p_ptr->arena_number++;
6554                                 else
6555                                         p_ptr->arena_number = -1 - p_ptr->arena_number;
6556                                 p_ptr->is_dead = FALSE;
6557                                 p_ptr->chp = 0;
6558                                 p_ptr->chp_frac = 0;
6559                                 p_ptr->exit_bldg = TRUE;
6560                                 reset_tim_flags();
6561
6562                                 /* Leave through the exit */
6563                                 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
6564
6565                                 /* prepare next floor */
6566                                 leave_floor();
6567                         }
6568                         else
6569                         {
6570                                 /* Mega-Hack -- Allow player to cheat death */
6571                                 if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
6572                                 {
6573                                         /* Mark social class, reset age, if needed */
6574                                         if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
6575
6576                                         /* Increase age */
6577                                         p_ptr->age++;
6578
6579                                         /* Mark savefile */
6580                                         p_ptr->noscore |= 0x0001;
6581
6582                                         /* Message */
6583                                         msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
6584                                         msg_print(NULL);
6585
6586                                         /* Restore hit points */
6587                                         p_ptr->chp = p_ptr->mhp;
6588                                         p_ptr->chp_frac = 0;
6589
6590                                         if (p_ptr->pclass == CLASS_MAGIC_EATER)
6591                                         {
6592                                                 for (i = 0; i < EATER_EXT*2; i++)
6593                                                 {
6594                                                         p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
6595                                                 }
6596                                                 for (; i < EATER_EXT*3; i++)
6597                                                 {
6598                                                         p_ptr->magic_num1[i] = 0;
6599                                                 }
6600                                         }
6601                                         /* Restore spell points */
6602                                         p_ptr->csp = p_ptr->msp;
6603                                         p_ptr->csp_frac = 0;
6604
6605                                         /* Hack -- cancel recall */
6606                                         if (p_ptr->word_recall)
6607                                         {
6608                                                 /* Message */
6609                                                 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
6610                                                 msg_print(NULL);
6611
6612                                                 /* Hack -- Prevent recall */
6613                                                 p_ptr->word_recall = 0;
6614                                                 p_ptr->redraw |= (PR_STATUS);
6615                                         }
6616
6617                                         /* Hack -- cancel alter */
6618                                         if (p_ptr->alter_reality)
6619                                         {
6620                                                 /* Hack -- Prevent alter */
6621                                                 p_ptr->alter_reality = 0;
6622                                                 p_ptr->redraw |= (PR_STATUS);
6623                                         }
6624
6625                                         /* Note cause of death XXX XXX XXX */
6626                                         (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
6627
6628                                         /* Do not die */
6629                                         p_ptr->is_dead = FALSE;
6630
6631                                         /* Hack -- Healing */
6632                                         (void)set_blind(0);
6633                                         (void)set_confused(0);
6634                                         (void)set_poisoned(0);
6635                                         (void)set_afraid(0);
6636                                         (void)set_paralyzed(0);
6637                                         (void)set_image(0);
6638                                         (void)set_stun(0);
6639                                         (void)set_cut(0);
6640
6641                                         /* Hack -- Prevent starvation */
6642                                         (void)set_food(PY_FOOD_MAX - 1);
6643
6644                                         dun_level = 0;
6645                                         p_ptr->inside_arena = FALSE;
6646                                         p_ptr->inside_battle = FALSE;
6647                                         leaving_quest = 0;
6648                                         p_ptr->inside_quest = 0;
6649                                         if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
6650                                         dungeon_type = 0;
6651                                         if (lite_town || vanilla_town)
6652                                         {
6653                                                 p_ptr->wilderness_y = 1;
6654                                                 p_ptr->wilderness_x = 1;
6655                                                 if (vanilla_town)
6656                                                 {
6657                                                         p_ptr->oldpy = 10;
6658                                                         p_ptr->oldpx = 34;
6659                                                 }
6660                                                 else
6661                                                 {
6662                                                         p_ptr->oldpy = 33;
6663                                                         p_ptr->oldpx = 131;
6664                                                 }
6665                                         }
6666                                         else
6667                                         {
6668                                                 p_ptr->wilderness_y = 48;
6669                                                 p_ptr->wilderness_x = 5;
6670                                                 p_ptr->oldpy = 33;
6671                                                 p_ptr->oldpx = 131;
6672                                         }
6673
6674                                         /* Leaving */
6675                                         p_ptr->wild_mode = FALSE;
6676                                         p_ptr->leaving = TRUE;
6677
6678                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 1, 
6679                                                                 _("                            しかし、生き返った。", 
6680                                                                   "                            but revived."));
6681
6682                                         /* Prepare next floor */
6683                                         leave_floor();
6684                                         wipe_m_list();
6685                                 }
6686                         }
6687                 }
6688
6689                 /* Handle "death" */
6690                 if (p_ptr->is_dead) break;
6691
6692                 /* Make a new level */
6693                 change_floor();
6694         }
6695
6696         /* Close stuff */
6697         close_game();
6698
6699         /* Quit */
6700         quit(NULL);
6701 }
6702
6703 /*!
6704  * @brief ゲームターンからの実時間換算を行うための補正をかける
6705  * @param hoge ゲームターン
6706  * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
6707  * @return 修正をかけた後のゲームターン
6708  */
6709 s32b turn_real(s32b hoge)
6710 {
6711         switch (p_ptr->start_race)
6712         {
6713         case RACE_VAMPIRE:
6714         case RACE_SKELETON:
6715         case RACE_ZOMBIE:
6716         case RACE_SPECTRE:
6717                 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
6718         default:
6719                 return hoge;
6720         }
6721 }
6722
6723 /*!
6724  * @brief ターンのオーバーフローに対する対処
6725  * @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
6726  * @return 修正をかけた後のゲームターン
6727  */
6728 void prevent_turn_overflow(void)
6729 {
6730         int rollback_days, i, j;
6731         s32b rollback_turns;
6732
6733         if (turn < turn_limit) return;
6734
6735         rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
6736         rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
6737
6738         if (turn > rollback_turns) turn -= rollback_turns;
6739         else turn = 1; /* Paranoia */
6740         if (old_turn > rollback_turns) old_turn -= rollback_turns;
6741         else old_turn = 1;
6742         if (old_battle > rollback_turns) old_battle -= rollback_turns;
6743         else old_battle = 1;
6744         if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
6745         else p_ptr->feeling_turn = 1;
6746
6747         for (i = 1; i < max_towns; i++)
6748         {
6749                 for (j = 0; j < MAX_STORES; j++)
6750                 {
6751                         store_type *st_ptr = &town[i].store[j];
6752
6753                         if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
6754                         {
6755                                 st_ptr->last_visit -= rollback_turns;
6756                                 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6757                         }
6758
6759                         if (st_ptr->store_open)
6760                         {
6761                                 st_ptr->store_open -= rollback_turns;
6762                                 if (st_ptr->store_open < 1) st_ptr->store_open = 1;
6763                         }
6764                 }
6765         }
6766 }