OSDN Git Service

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