OSDN Git Service

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