OSDN Git Service

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