OSDN Git Service

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