OSDN Git Service

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