OSDN Git Service

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