OSDN Git Service

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