OSDN Git Service

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