OSDN Git Service

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