OSDN Git Service

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