OSDN Git Service

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