OSDN Git Service

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