OSDN Git Service

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