OSDN Git Service

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