OSDN Git Service

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