OSDN Git Service

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