OSDN Git Service

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