OSDN Git Service

fea21a84c261bfa4ba85ccc05fcee978c6ffcd5e
[hengband/hengband.git] / src / dungeon.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
15 #define TY_CURSE_CHANCE 200 /*!<ÂÀ¸Å¤Î±åÇ°¤Î1¥¿¡¼¥óËè¤Îȯư³ÎΨ(1/n)*/
16 #define CHAINSWORD_NOISE 100 /*!<¥Á¥§¥ó¥½¡¼¤Î1¥¿¡¼¥óËè¤Îȯư³ÎΨ(1/n)*/
17
18 static bool load = TRUE; /*!<¥í¡¼¥É½èÍýÃæ¤Îʬ´ô¥Õ¥é¥°*/
19 static int wild_regen = 20; /*!<¹­°è¥Þ¥Ã¥×°ÜÆ°»þ¤Î¼«Á³²óÉü½èÍý¥«¥¦¥ó¥¿¡Ê¹­°è¥Þ¥Ã¥×1¥Þ¥¹Ëè¤Ë20²ó½èÍý¤ò´ðËܤȤ¹¤ë¡Ë*/
20
21 /*!
22  * @brief ½ÅÅÙµ¼»÷´ÕÄê¤ÎȽÃǽèÍý / Return a "feeling" (or NULL) about an item.  Method 1 (Heavy).
23  * @param o_ptr µ¼»÷´ÕÄê¤ò¹Ô¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¥Ý¥¤¥ó¥¿¡£
24  * @return µ¼»÷´ÕÄê·ë²Ì¤ÎID¤òÊÖ¤¹¡£
25  */
26 static byte value_check_aux1(object_type *o_ptr)
27 {
28         /* Artifacts */
29         if (object_is_artifact(o_ptr))
30         {
31                 /* Cursed/Broken */
32                 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
33
34                 /* Normal */
35                 return FEEL_SPECIAL;
36         }
37
38         /* Ego-Items */
39         if (object_is_ego(o_ptr))
40         {
41                 /* Cursed/Broken */
42                 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
43
44                 /* Normal */
45                 return FEEL_EXCELLENT;
46         }
47
48         /* Cursed items */
49         if (object_is_cursed(o_ptr)) return FEEL_CURSED;
50
51         /* Broken items */
52         if (object_is_broken(o_ptr)) return FEEL_BROKEN;
53
54         if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
55
56         /* Good "armor" bonus */
57         if (o_ptr->to_a > 0) return FEEL_GOOD;
58
59         /* Good "weapon" bonus */
60         if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
61
62         /* Default to "average" */
63         return FEEL_AVERAGE;
64 }
65
66 /*!
67  * @brief ·ÚÅÙµ¼»÷´ÕÄê¤ÎȽÃǽèÍý / Return a "feeling" (or NULL) about an item.  Method 2 (Light).
68  * @param o_ptr µ¼»÷´ÕÄê¤ò¹Ô¤¦¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¥Ý¥¤¥ó¥¿¡£
69  * @return µ¼»÷´ÕÄê·ë²Ì¤ÎID¤òÊÖ¤¹¡£
70  */
71 static byte value_check_aux2(object_type *o_ptr)
72 {
73         /* Cursed items (all of them) */
74         if (object_is_cursed(o_ptr)) return FEEL_CURSED;
75
76         /* Broken items (all of them) */
77         if (object_is_broken(o_ptr)) return FEEL_BROKEN;
78
79         /* Artifacts -- except cursed/broken ones */
80         if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
81
82         /* Ego-Items -- except cursed/broken ones */
83         if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
84
85         /* Good armor bonus */
86         if (o_ptr->to_a > 0) return FEEL_UNCURSED;
87
88         /* Good weapon bonuses */
89         if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
90
91         /* No feeling */
92         return FEEL_NONE;
93 }
94
95
96 /*!
97  * @brief µ¼»÷´ÕÄê¤ò¼ÂºÝ¤Ë¹Ô¤¤È½Äê¤òÈ¿±Ç¤¹¤ë
98  * @param slot µ¼»÷´ÕÄê¤ò¹Ô¤¦¥×¥ì¥¤¥ä¡¼¤Î½ê»ý¥ê¥¹¥ÈID
99  * @param heavy ½ÅÅ٤ε¼»÷´ÕÄê¤ò¹Ô¤¦¤Ê¤é¤ÐTRUE
100  * @return ¤Ê¤·
101  */
102 static void sense_inventory_aux(int slot, bool heavy)
103 {
104         byte        feel;
105         object_type *o_ptr = &inventory[slot];
106         char        o_name[MAX_NLEN];
107
108         /* We know about it already, do not tell us again */
109         if (o_ptr->ident & (IDENT_SENSE))return;
110
111         /* It is fully known, no information needed */
112         if (object_is_known(o_ptr)) return;
113
114         /* Check for a feeling */
115         feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
116
117         /* Skip non-feelings */
118         if (!feel) return;
119
120         /* Bad luck */
121         if ((p_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13))
122         {
123                 switch (feel)
124                 {
125                         case FEEL_TERRIBLE:
126                         {
127                                 feel = FEEL_SPECIAL;
128                                 break;
129                         }
130                         case FEEL_WORTHLESS:
131                         {
132                                 feel = FEEL_EXCELLENT;
133                                 break;
134                         }
135                         case FEEL_CURSED:
136                         {
137                                 if (heavy)
138                                         feel = randint0(3) ? FEEL_GOOD : FEEL_AVERAGE;
139                                 else
140                                         feel = FEEL_UNCURSED;
141                                 break;
142                         }
143                         case FEEL_AVERAGE:
144                         {
145                                 feel = randint0(2) ? FEEL_CURSED : FEEL_GOOD;
146                                 break;
147                         }
148                         case FEEL_GOOD:
149                         {
150                                 if (heavy)
151                                         feel = randint0(3) ? FEEL_CURSED : FEEL_AVERAGE;
152                                 else
153                                         feel = FEEL_CURSED;
154                                 break;
155                         }
156                         case FEEL_EXCELLENT:
157                         {
158                                 feel = FEEL_WORTHLESS;
159                                 break;
160                         }
161                         case FEEL_SPECIAL:
162                         {
163                                 feel = FEEL_TERRIBLE;
164                                 break;
165                         }
166                 }
167         }
168
169         /* Stop everything */
170         if (disturb_minor) disturb(0, 0);
171
172         /* Get an object description */
173         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
174
175         /* Message (equipment) */
176         if (slot >= INVEN_RARM)
177         {
178 #ifdef JP
179 msg_format("%s%s(%c)¤Ï%s¤È¤¤¤¦´¶¤¸¤¬¤¹¤ë...",
180 describe_use(slot),o_name, index_to_label(slot),game_inscriptions[feel]);
181 #else
182                 msg_format("You feel the %s (%c) you are %s %s %s...",
183                            o_name, index_to_label(slot), describe_use(slot),
184                            ((o_ptr->number == 1) ? "is" : "are"),
185                                    game_inscriptions[feel]);
186 #endif
187
188         }
189
190         /* Message (inventory) */
191         else
192         {
193 #ifdef JP
194 msg_format("¥¶¥Ã¥¯¤ÎÃæ¤Î%s(%c)¤Ï%s¤È¤¤¤¦´¶¤¸¤¬¤¹¤ë...",
195 o_name, index_to_label(slot),game_inscriptions[feel]);
196 #else
197                 msg_format("You feel the %s (%c) in your pack %s %s...",
198                            o_name, index_to_label(slot),
199                            ((o_ptr->number == 1) ? "is" : "are"),
200                                    game_inscriptions[feel]);
201 #endif
202
203         }
204
205         /* We have "felt" it */
206         o_ptr->ident |= (IDENT_SENSE);
207
208         /* Set the "inscription" */
209         o_ptr->feeling = feel;
210
211         /* Auto-inscription/destroy */
212         autopick_alter_item(slot, destroy_feeling);
213
214         /* Combine / Reorder the pack (later) */
215         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
216
217         /* Window stuff */
218         p_ptr->window |= (PW_INVEN | PW_EQUIP);
219 }
220
221
222
223 /*!
224  * @brief 1¥×¥ì¥¤¥ä¡¼¥¿¡¼¥óËè¤ËÉð´ï¡¢Ëɶñ¤Îµ¼»÷´ÕÄ꤬¹Ô¤ï¤ì¤ë¤«¤òȽÄꤹ¤ë¡£
225  * @return ¤Ê¤·
226  * @details
227  * Sense the inventory\n
228  *\n
229  *   Class 0 = Warrior --> fast and heavy\n
230  *   Class 1 = Mage    --> slow and light\n
231  *   Class 2 = Priest  --> fast but light\n
232  *   Class 3 = Rogue   --> okay and heavy\n
233  *   Class 4 = Ranger  --> slow but heavy  (changed!)\n
234  *   Class 5 = Paladin --> slow but heavy\n
235  */
236 static void sense_inventory1(void)
237 {
238         int         i;
239         int         plev = p_ptr->lev;
240         bool        heavy = FALSE;
241         object_type *o_ptr;
242
243
244         /*** Check for "sensing" ***/
245
246         /* No sensing when confused */
247         if (p_ptr->confused) return;
248
249         /* Analyze the class */
250         switch (p_ptr->pclass)
251         {
252                 case CLASS_WARRIOR:
253                 case CLASS_ARCHER:
254                 case CLASS_SAMURAI:
255                 case CLASS_CAVALRY:
256                 {
257                         /* Good sensing */
258                         if (0 != randint0(9000L / (plev * plev + 40))) return;
259
260                         /* Heavy sensing */
261                         heavy = TRUE;
262
263                         /* Done */
264                         break;
265                 }
266
267                 case CLASS_SMITH:
268                 {
269                         /* Good sensing */
270                         if (0 != randint0(6000L / (plev * plev + 50))) return;
271
272                         /* Heavy sensing */
273                         heavy = TRUE;
274
275                         /* Done */
276                         break;
277                 }
278
279                 case CLASS_MAGE:
280                 case CLASS_HIGH_MAGE:
281                 case CLASS_SORCERER:
282                 case CLASS_MAGIC_EATER:
283                 {
284                         /* Very bad (light) sensing */
285                         if (0 != randint0(240000L / (plev + 5))) return;
286
287                         /* Done */
288                         break;
289                 }
290
291                 case CLASS_PRIEST:
292                 case CLASS_BARD:
293                 {
294                         /* Good (light) sensing */
295                         if (0 != randint0(10000L / (plev * plev + 40))) return;
296
297                         /* Done */
298                         break;
299                 }
300
301                 case CLASS_ROGUE:
302                 case CLASS_NINJA:
303                 {
304                         /* Okay sensing */
305                         if (0 != randint0(20000L / (plev * plev + 40))) return;
306
307                         /* Heavy sensing */
308                         heavy = TRUE;
309
310                         /* Done */
311                         break;
312                 }
313
314                 case CLASS_RANGER:
315                 {
316                         /* Bad sensing */
317                         if (0 != randint0(95000L / (plev * plev + 40))) return;
318
319                         /* Changed! */
320                         heavy = TRUE;
321
322                         /* Done */
323                         break;
324                 }
325
326                 case CLASS_PALADIN:
327                 case CLASS_SNIPER:
328                 {
329                         /* Bad sensing */
330                         if (0 != randint0(77777L / (plev * plev + 40))) return;
331
332                         /* Heavy sensing */
333                         heavy = TRUE;
334
335                         /* Done */
336                         break;
337                 }
338
339                 case CLASS_WARRIOR_MAGE:
340                 case CLASS_RED_MAGE:
341                 {
342                         /* Bad sensing */
343                         if (0 != randint0(75000L / (plev * plev + 40))) return;
344
345                         /* Done */
346                         break;
347                 }
348
349                 case CLASS_MINDCRAFTER:
350                 case CLASS_IMITATOR:
351                 case CLASS_BLUE_MAGE:
352                 case CLASS_MIRROR_MASTER:
353                 {
354                         /* Bad sensing */
355                         if (0 != randint0(55000L / (plev * plev + 40))) return;
356
357                         /* Done */
358                         break;
359                 }
360
361                 case CLASS_CHAOS_WARRIOR:
362                 {
363                         /* Bad sensing */
364                         if (0 != randint0(80000L / (plev * plev + 40))) return;
365
366                         /* Changed! */
367                         heavy = TRUE;
368
369                         /* Done */
370                         break;
371                 }
372
373                 case CLASS_MONK:
374                 case CLASS_FORCETRAINER:
375                 {
376                         /* Okay sensing */
377                         if (0 != randint0(20000L / (plev * plev + 40))) return;
378
379                         /* Done */
380                         break;
381                 }
382
383                 case CLASS_TOURIST:
384                 {
385                         /* Good sensing */
386                         if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
387
388                         /* Heavy sensing */
389                         heavy = TRUE;
390
391                         /* Done */
392                         break;
393                 }
394
395                 case CLASS_BEASTMASTER:
396                 {
397                         /* Bad sensing */
398                         if (0 != randint0(65000L / (plev * plev + 40))) return;
399
400                         /* Done */
401                         break;
402                 }
403                 case CLASS_BERSERKER:
404                 {
405                         /* Heavy sensing */
406                         heavy = TRUE;
407
408                         /* Done */
409                         break;
410                 }
411         }
412
413         if (compare_virtue(V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE;
414
415         /*** Sense everything ***/
416
417         /* Check everything */
418         for (i = 0; i < INVEN_TOTAL; i++)
419         {
420                 bool okay = FALSE;
421
422                 o_ptr = &inventory[i];
423
424                 /* Skip empty slots */
425                 if (!o_ptr->k_idx) continue;
426
427                 /* Valid "tval" codes */
428                 switch (o_ptr->tval)
429                 {
430                         case TV_SHOT:
431                         case TV_ARROW:
432                         case TV_BOLT:
433                         case TV_BOW:
434                         case TV_DIGGING:
435                         case TV_HAFTED:
436                         case TV_POLEARM:
437                         case TV_SWORD:
438                         case TV_BOOTS:
439                         case TV_GLOVES:
440                         case TV_HELM:
441                         case TV_CROWN:
442                         case TV_SHIELD:
443                         case TV_CLOAK:
444                         case TV_SOFT_ARMOR:
445                         case TV_HARD_ARMOR:
446                         case TV_DRAG_ARMOR:
447                         case TV_CARD:
448                         {
449                                 okay = TRUE;
450                                 break;
451                         }
452                 }
453
454                 /* Skip non-sense machines */
455                 if (!okay) continue;
456
457                 /* Occasional failure on inventory items */
458                 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
459
460                 /* Good luck */
461                 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13))
462                 {
463                         heavy = TRUE;
464                 }
465
466                 sense_inventory_aux(i, heavy);
467         }
468 }
469
470 /*!
471  * @brief 1¥×¥ì¥¤¥ä¡¼¥¿¡¼¥óËè¤ËÉð´ï¡¢Ëɶñ°Ê³°¤Îµ¼»÷´ÕÄ꤬¹Ô¤ï¤ì¤ë¤«¤òȽÄꤹ¤ë¡£
472  * @return ¤Ê¤·
473  */
474 static void sense_inventory2(void)
475 {
476         int         i;
477         int         plev = p_ptr->lev;
478         object_type *o_ptr;
479
480
481         /*** Check for "sensing" ***/
482
483         /* No sensing when confused */
484         if (p_ptr->confused) return;
485
486         /* Analyze the class */
487         switch (p_ptr->pclass)
488         {
489                 case CLASS_WARRIOR:
490                 case CLASS_ARCHER:
491                 case CLASS_SAMURAI:
492                 case CLASS_CAVALRY:
493                 case CLASS_BERSERKER:
494                 case CLASS_SNIPER:
495                 {
496                         return;
497                 }
498
499                 case CLASS_SMITH:
500                 case CLASS_PALADIN:
501                 case CLASS_CHAOS_WARRIOR:
502                 case CLASS_IMITATOR:
503                 case CLASS_BEASTMASTER:
504                 case CLASS_NINJA:
505                 {
506                         /* Very bad (light) sensing */
507                         if (0 != randint0(240000L / (plev + 5))) return;
508
509                         /* Done */
510                         break;
511                 }
512
513                 case CLASS_RANGER:
514                 case CLASS_WARRIOR_MAGE:
515                 case CLASS_RED_MAGE:
516                 case CLASS_MONK:
517                 {
518                         /* Bad sensing */
519                         if (0 != randint0(95000L / (plev * plev + 40))) return;
520
521                         /* Done */
522                         break;
523                 }
524
525                 case CLASS_PRIEST:
526                 case CLASS_BARD:
527                 case CLASS_ROGUE:
528                 case CLASS_FORCETRAINER:
529                 case CLASS_MINDCRAFTER:
530                 {
531                         /* Good sensing */
532                         if (0 != randint0(20000L / (plev * plev + 40))) return;
533
534                         /* Done */
535                         break;
536                 }
537
538                 case CLASS_MAGE:
539                 case CLASS_HIGH_MAGE:
540                 case CLASS_SORCERER:
541                 case CLASS_MAGIC_EATER:
542                 case CLASS_MIRROR_MASTER:
543                 case CLASS_BLUE_MAGE:
544                 {
545                         /* Good sensing */
546                         if (0 != randint0(9000L / (plev * plev + 40))) return;
547
548                         /* Done */
549                         break;
550                 }
551
552                 case CLASS_TOURIST:
553                 {
554                         /* Good sensing */
555                         if (0 != randint0(20000L / ((plev+50)*(plev+50)))) return;
556
557                         /* Done */
558                         break;
559                 }
560         }
561
562         /*** Sense everything ***/
563
564         /* Check everything */
565         for (i = 0; i < INVEN_TOTAL; i++)
566         {
567                 bool okay = FALSE;
568
569                 o_ptr = &inventory[i];
570
571                 /* Skip empty slots */
572                 if (!o_ptr->k_idx) continue;
573
574                 /* Valid "tval" codes */
575                 switch (o_ptr->tval)
576                 {
577                         case TV_RING:
578                         case TV_AMULET:
579                         case TV_LITE:
580                         case TV_FIGURINE:
581                         {
582                                 okay = TRUE;
583                                 break;
584                         }
585                 }
586
587                 /* Skip non-sense machines */
588                 if (!okay) continue;
589
590                 /* Occasional failure on inventory items */
591                 if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
592
593                 sense_inventory_aux(i, TRUE);
594         }
595 }
596
597 /*!
598  * @brief ¥Ñ¥¿¡¼¥ó½ªÅÀÅþã»þ¤Î¥Æ¥ì¥Ý¡¼¥È½èÍý¤ò¹Ô¤¦
599  * @return ¤Ê¤·
600  */
601 static void pattern_teleport(void)
602 {
603         int min_level = 0;
604         int max_level = 99;
605
606         /* Ask for level */
607 #ifdef JP
608         if (get_check("¾¤Î³¬¤Ë¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©"))
609 #else
610         if (get_check("Teleport level? "))
611 #endif
612
613         {
614                 char    ppp[80];
615                 char    tmp_val[160];
616
617                 /* Only downward in ironman mode */
618                 if (ironman_downward)
619                         min_level = dun_level;
620
621                 /* Maximum level */
622                 if (dungeon_type == DUNGEON_ANGBAND)
623                 {
624                         if (dun_level > 100)
625                                 max_level = MAX_DEPTH - 1;
626                         else if (dun_level == 100)
627                                 max_level = 100;
628                 }
629                 else
630                 {
631                         max_level = d_info[dungeon_type].maxdepth;
632                         min_level = d_info[dungeon_type].mindepth;
633                 }
634
635                 /* Prompt */
636 #ifdef JP
637                 sprintf(ppp, "¥Æ¥ì¥Ý¡¼¥ÈÀè:(%d-%d)", min_level, max_level);
638 #else
639                 sprintf(ppp, "Teleport to level (%d-%d): ", min_level, max_level);
640 #endif
641
642
643                 /* Default */
644                 sprintf(tmp_val, "%d", dun_level);
645
646                 /* Ask for a level */
647                 if (!get_string(ppp, tmp_val, 10)) return;
648
649                 /* Extract request */
650                 command_arg = atoi(tmp_val);
651         }
652 #ifdef JP
653         else if (get_check("Ä̾ï¥Æ¥ì¥Ý¡¼¥È¡©"))
654 #else
655         else if (get_check("Normal teleport? "))
656 #endif
657         {
658                 teleport_player(200, 0L);
659                 return;
660         }
661         else
662         {
663                 return;
664         }
665
666         /* Paranoia */
667         if (command_arg < min_level) command_arg = min_level;
668
669         /* Paranoia */
670         if (command_arg > max_level) command_arg = max_level;
671
672         /* Accept request */
673 #ifdef JP
674         msg_format("%d ³¬¤Ë¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤·¤¿¡£", command_arg);
675 #else
676         msg_format("You teleport to dungeon level %d.", command_arg);
677 #endif
678
679
680         if (autosave_l) do_cmd_save_game(TRUE);
681
682         /* Change level */
683         dun_level = command_arg;
684
685         leave_quest_check();
686
687         if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE,0,NULL);
688
689         p_ptr->inside_quest = 0;
690         energy_use = 0;
691
692         /*
693          * Clear all saved floors
694          * and create a first saved floor
695          */
696         prepare_change_floor_mode(CFM_FIRST_FLOOR);
697
698         /* Leaving */
699         p_ptr->leaving = TRUE;
700 }
701
702 /*!
703  * @brief ¼ï²¥¢¥ó¥Ð¥é¥¤¥È¤¬½Ð·ì»þ¥Ñ¥¿¡¼¥ó¤Î¾å¤Ë¾è¤Ã¤¿ºÝ¤Î¥Ú¥Ê¥ë¥Æ¥£½èÍý
704  * @return ¤Ê¤·
705  */
706 static void wreck_the_pattern(void)
707 {
708         int to_ruin = 0, r_y, r_x;
709         int pattern_type = f_info[cave[py][px].feat].subtype;
710
711         if (pattern_type == PATTERN_TILE_WRECKED)
712         {
713                 /* Ruined already */
714                 return;
715         }
716
717 #ifdef JP
718         msg_print("¥Ñ¥¿¡¼¥ó¤ò·ì¤Ç±ø¤·¤Æ¤·¤Þ¤Ã¤¿¡ª");
719         msg_print("²¿¤«¶²¤í¤·¤¤»ö¤¬µ¯¤³¤Ã¤¿¡ª");
720 #else
721         msg_print("You bleed on the Pattern!");
722         msg_print("Something terrible happens!");
723 #endif
724
725         if (!IS_INVULN())
726 #ifdef JP
727                 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), "¥Ñ¥¿¡¼¥ó»²õ", -1);
728 #else
729                 take_hit(DAMAGE_NOESCAPE, damroll(10, 8), "corrupting the Pattern", -1);
730 #endif
731
732         to_ruin = randint1(45) + 35;
733
734         while (to_ruin--)
735         {
736                 scatter(&r_y, &r_x, py, px, 4, 0);
737
738                 if (pattern_tile(r_y, r_x) &&
739                     (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
740                 {
741                         cave_set_feat(r_y, r_x, feat_pattern_corrupted);
742                 }
743         }
744
745         cave_set_feat(py, px, feat_pattern_corrupted);
746 }
747
748 /*!
749  * @brief ³Æ¼ï¥Ñ¥¿¡¼¥óÃÏ·Á¾å¤ÎÆÃÊ̤ʽèÍý / Returns TRUE if we are on the Pattern...
750  * @return ¼ÂºÝ¤Ë¥Ñ¥¿¡¼¥óÃÏ·Á¾å¤Ë¥×¥ì¥¤¥ä¡¼¤¬µï¤¿¾ì¹ç¤ÏTRUE¤òÊÖ¤¹¡£
751  */
752 static bool pattern_effect(void)
753 {
754         int pattern_type;
755
756         if (!pattern_tile(py, px)) return FALSE;
757
758         if ((prace_is_(RACE_AMBERITE)) &&
759             (p_ptr->cut > 0) && one_in_(10))
760         {
761                 wreck_the_pattern();
762         }
763
764         pattern_type = f_info[cave[py][px].feat].subtype;
765
766         switch (pattern_type)
767         {
768         case PATTERN_TILE_END:
769                 (void)set_poisoned(0);
770                 (void)set_image(0);
771                 (void)set_stun(0);
772                 (void)set_cut(0);
773                 (void)set_blind(0);
774                 (void)set_afraid(0);
775                 (void)do_res_stat(A_STR);
776                 (void)do_res_stat(A_INT);
777                 (void)do_res_stat(A_WIS);
778                 (void)do_res_stat(A_DEX);
779                 (void)do_res_stat(A_CON);
780                 (void)do_res_stat(A_CHR);
781                 (void)restore_level();
782                 (void)hp_player(1000);
783
784                 cave_set_feat(py, px, feat_pattern_old);
785
786 #ifdef JP
787                 msg_print("¡Ö¥Ñ¥¿¡¼¥ó¡×¤Î¤³¤ÎÉôʬ¤Ï¾¤ÎÉôʬ¤è¤ê¶¯ÎϤǤʤ¤¤è¤¦¤À¡£");
788 #else
789                 msg_print("This section of the Pattern looks less powerful.");
790 #endif
791
792                 /*
793                  * We could make the healing effect of the
794                  * Pattern center one-time only to avoid various kinds
795                  * of abuse, like luring the win monster into fighting you
796                  * in the middle of the pattern...
797                  */
798                 break;
799
800         case PATTERN_TILE_OLD:
801                 /* No effect */
802                 break;
803
804         case PATTERN_TILE_TELEPORT:
805                 pattern_teleport();
806                 break;
807
808         case PATTERN_TILE_WRECKED:
809                 if (!IS_INVULN())
810 #ifdef JP
811                         take_hit(DAMAGE_NOESCAPE, 200, "²õ¤ì¤¿¡Ö¥Ñ¥¿¡¼¥ó¡×¤òÊ⤤¤¿¥À¥á¡¼¥¸", -1);
812 #else
813                         take_hit(DAMAGE_NOESCAPE, 200, "walking the corrupted Pattern", -1);
814 #endif
815                 break;
816
817         default:
818                 if (prace_is_(RACE_AMBERITE) && !one_in_(2))
819                         return TRUE;
820                 else if (!IS_INVULN())
821 #ifdef JP
822                         take_hit(DAMAGE_NOESCAPE, damroll(1, 3), "¡Ö¥Ñ¥¿¡¼¥ó¡×¤òÊ⤤¤¿¥À¥á¡¼¥¸", -1);
823 #else
824                         take_hit(DAMAGE_NOESCAPE, damroll(1, 3), "walking the Pattern", -1);
825 #endif
826                 break;
827         }
828
829         return TRUE;
830 }
831
832
833 /*!
834  * @brief ¥×¥ì¥¤¥ä¡¼¤ÎHP¼«Á³²óÉü½èÍý / Regenerate hit points -RAK-
835  * @param percent ²óÉüÈæΨ
836  * @return ¤Ê¤·
837  */
838 static void regenhp(int percent)
839 {
840         s32b new_chp;
841         u32b new_chp_frac;
842         s32b old_chp;
843
844         if (p_ptr->special_defense & KATA_KOUKIJIN) return;
845         if (p_ptr->action == ACTION_HAYAGAKE) return;
846
847         /* Save the old hitpoints */
848         old_chp = p_ptr->chp;
849
850         /*
851          * Extract the new hitpoints
852          *
853          * 'percent' is the Regen factor in unit (1/2^16)
854          */
855         new_chp = 0;
856         new_chp_frac = (p_ptr->mhp * percent + PY_REGEN_HPBASE);
857
858         /* Convert the unit (1/2^16) to (1/2^32) */
859         s64b_LSHIFT(new_chp, new_chp_frac, 16);
860
861         /* Regenerating */
862         s64b_add(&(p_ptr->chp), &(p_ptr->chp_frac), new_chp, new_chp_frac);
863
864
865         /* Fully healed */
866         if (0 < s64b_cmp(p_ptr->chp, p_ptr->chp_frac, p_ptr->mhp, 0))
867         {
868                 p_ptr->chp = p_ptr->mhp;
869                 p_ptr->chp_frac = 0;
870         }
871
872         /* Notice changes */
873         if (old_chp != p_ptr->chp)
874         {
875                 /* Redraw */
876                 p_ptr->redraw |= (PR_HP);
877
878                 /* Window stuff */
879                 p_ptr->window |= (PW_PLAYER);
880
881                 wild_regen = 20;
882         }
883 }
884
885
886 /*!
887  * @brief ¥×¥ì¥¤¥ä¡¼¤ÎMP¼«Á³²óÉü½èÍý(regen_magic()¤Î¥µ¥Ö¥»¥Ã¥È) / Regenerate mana points
888  * @param upkeep_factor ¥Ú¥Ã¥È°Ý»ý¤Ë¤è¤ëMP¥³¥¹¥ÈÎÌ
889  * @param regen_amount ²óÉüÎÌ
890  * @return ¤Ê¤·
891  */
892 static void regenmana(int upkeep_factor, int regen_amount)
893 {
894         s32b old_csp = p_ptr->csp;
895         s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
896
897         /*
898          * Excess mana will decay 32 times faster than normal
899          * regeneration rate.
900          */
901         if (p_ptr->csp > p_ptr->msp)
902         {
903                 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
904                 s32b decay = 0;
905                 u32b decay_frac = (p_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
906
907                 /* Convert the unit (1/2^16) to (1/2^32) */
908                 s64b_LSHIFT(decay, decay_frac, 16);
909
910                 /* Decay */
911                 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), decay, decay_frac);
912
913                 /* Stop decaying */
914                 if (p_ptr->csp < p_ptr->msp)
915                 {
916                         p_ptr->csp = p_ptr->msp;
917                         p_ptr->csp_frac = 0;
918                 }
919         }
920
921         /* Regenerating mana (unless the player has excess mana) */
922         else if (regen_rate > 0)
923         {
924                 /* (percent/100) is the Regen factor in unit (1/2^16) */
925                 s32b new_mana = 0;
926                 u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
927
928                 /* Convert the unit (1/2^16) to (1/2^32) */
929                 s64b_LSHIFT(new_mana, new_mana_frac, 16);
930
931                 /* Regenerate */
932                 s64b_add(&(p_ptr->csp), &(p_ptr->csp_frac), new_mana, new_mana_frac);
933
934                 /* Must set frac to zero even if equal */
935                 if (p_ptr->csp >= p_ptr->msp)
936                 {
937                         p_ptr->csp = p_ptr->msp;
938                         p_ptr->csp_frac = 0;
939                 }
940         }
941
942
943         /* Reduce mana (even when the player has excess mana) */
944         if (regen_rate < 0)
945         {
946                 /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
947                 s32b reduce_mana = 0;
948                 u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
949
950                 /* Convert the unit (1/2^16) to (1/2^32) */
951                 s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
952
953                 /* Reduce mana */
954                 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), reduce_mana, reduce_mana_frac);
955
956                 /* Check overflow */
957                 if (p_ptr->csp < 0)
958                 {
959                         p_ptr->csp = 0;
960                         p_ptr->csp_frac = 0;
961                 }
962         }
963
964
965         /* Redraw mana */
966         if (old_csp != p_ptr->csp)
967         {
968                 /* Redraw */
969                 p_ptr->redraw |= (PR_MANA);
970
971                 /* Window stuff */
972                 p_ptr->window |= (PW_PLAYER);
973                 p_ptr->window |= (PW_SPELL);
974
975                 wild_regen = 20;
976         }
977 }
978
979 /*!
980  * @brief ¥×¥ì¥¤¥ä¡¼¤ÎMP¼«Á³²óÉü½èÍý / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
981  * @param regen_amount ²óÉüÎÌ
982  * @return ¤Ê¤·
983  */
984 static void regenmagic(int regen_amount)
985 {
986         s32b new_mana;
987         int i;
988         int dev = 30;
989         int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
990
991         for (i = 0; i < EATER_EXT*2; i++)
992         {
993                 if (!p_ptr->magic_num2[i]) continue;
994                 if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
995
996                 /* Increase remaining charge number like float value */
997                 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
998                 p_ptr->magic_num1[i] += new_mana;
999
1000                 /* Check maximum charge */
1001                 if (p_ptr->magic_num1[i] > (p_ptr->magic_num2[i] << 16))
1002                 {
1003                         p_ptr->magic_num1[i] = ((long)p_ptr->magic_num2[i] << 16);
1004                 }
1005                 wild_regen = 20;
1006         }
1007         for (i = EATER_EXT*2; i < EATER_EXT*3; i++)
1008         {
1009                 if (!p_ptr->magic_num1[i]) continue;
1010                 if (!p_ptr->magic_num2[i]) continue;
1011
1012                 /* Decrease remaining period for charging */
1013                 new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE) 
1014                                         / (dev * 16 * PY_REGEN_NORMAL); 
1015                 p_ptr->magic_num1[i] -= new_mana;
1016
1017                 /* Check minimum remaining period for charging */
1018                 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
1019                 wild_regen = 20;
1020         }
1021 }
1022
1023
1024 /*!
1025  * @brief 100¥²¡¼¥à¥¿¡¼¥óËè¤Î¥â¥ó¥¹¥¿¡¼¤ÎHP¼«Á³²óÉü½èÍý / Regenerate the monsters (once per 100 game turns)
1026  * @return ¤Ê¤·
1027  * @note XXX XXX XXX Should probably be done during monster turns.
1028  */
1029 static void regen_monsters(void)
1030 {
1031         int i, frac;
1032
1033
1034         /* Regenerate everyone */
1035         for (i = 1; i < m_max; i++)
1036         {
1037                 /* Check the i'th monster */
1038                 monster_type *m_ptr = &m_list[i];
1039                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1040
1041
1042                 /* Skip dead monsters */
1043                 if (!m_ptr->r_idx) continue;
1044
1045                 /* Allow regeneration (if needed) */
1046                 if (m_ptr->hp < m_ptr->maxhp)
1047                 {
1048                         /* Hack -- Base regeneration */
1049                         frac = m_ptr->maxhp / 100;
1050
1051                         /* Hack -- Minimal regeneration rate */
1052                         if (!frac) if (one_in_(2)) frac = 1;
1053
1054                         /* Hack -- Some monsters regenerate quickly */
1055                         if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1056
1057                         /* Hack -- Regenerate */
1058                         m_ptr->hp += frac;
1059
1060                         /* Do not over-regenerate */
1061                         if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
1062
1063                         /* Redraw (later) if needed */
1064                         if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
1065                         if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
1066                 }
1067         }
1068 }
1069
1070
1071 /*!
1072  * @brief 30¥²¡¼¥à¥¿¡¼¥óËè¤Î¥Ü¡¼¥ëÃæ¥â¥ó¥¹¥¿¡¼¤ÎHP¼«Á³²óÉü½èÍý / Regenerate the captured monsters (once per 30 game turns)
1073  * @return ¤Ê¤·
1074  * @note XXX XXX XXX Should probably be done during monster turns.
1075  */
1076 static void regen_captured_monsters(void)
1077 {
1078         int i, frac;
1079         bool heal = FALSE;
1080
1081         /* Regenerate everyone */
1082         for (i = 0; i < INVEN_TOTAL; i++)
1083         {
1084                 monster_race *r_ptr;
1085                 object_type *o_ptr = &inventory[i];
1086
1087                 if (!o_ptr->k_idx) continue;
1088                 if (o_ptr->tval != TV_CAPTURE) continue;
1089                 if (!o_ptr->pval) continue;
1090
1091                 heal = TRUE;
1092
1093                 r_ptr = &r_info[o_ptr->pval];
1094
1095                 /* Allow regeneration (if needed) */
1096                 if (o_ptr->xtra4 < o_ptr->xtra5)
1097                 {
1098                         /* Hack -- Base regeneration */
1099                         frac = o_ptr->xtra5 / 100;
1100
1101                         /* Hack -- Minimal regeneration rate */
1102                         if (!frac) if (one_in_(2)) frac = 1;
1103
1104                         /* Hack -- Some monsters regenerate quickly */
1105                         if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
1106
1107                         /* Hack -- Regenerate */
1108                         o_ptr->xtra4 += frac;
1109
1110                         /* Do not over-regenerate */
1111                         if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
1112                 }
1113         }
1114
1115         if (heal)
1116         {
1117                 /* Combine pack */
1118                 p_ptr->notice |= (PN_COMBINE);
1119
1120                 /* Window stuff */
1121                 p_ptr->window |= (PW_INVEN);
1122                 p_ptr->window |= (PW_EQUIP);
1123                 wild_regen = 20;
1124         }
1125 }
1126
1127 /*!
1128  * @brief ¼÷Ì¿¤Ä¤­¸÷¸»¤Î·Ù¹ð¥á¥Ã¥»¡¼¥¸½èÍý
1129  * @param o_ptr ¸½ºß¸÷¸»¤È¤·¤Æ»È¤Ã¤Æ¤¤¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1130  * @return ¤Ê¤·
1131  */
1132 static void notice_lite_change(object_type *o_ptr)
1133 {
1134         /* Hack -- notice interesting fuel steps */
1135         if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100)))
1136         {
1137                 /* Window stuff */
1138                 p_ptr->window |= (PW_EQUIP);
1139         }
1140
1141         /* Hack -- Special treatment when blind */
1142         if (p_ptr->blind)
1143         {
1144                 /* Hack -- save some light for later */
1145                 if (o_ptr->xtra4 == 0) o_ptr->xtra4++;
1146         }
1147
1148         /* The light is now out */
1149         else if (o_ptr->xtra4 == 0)
1150         {
1151                 disturb(0, 1);
1152 #ifdef JP
1153 msg_print("ÌÀ¤«¤ê¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
1154 #else
1155                 msg_print("Your light has gone out!");
1156 #endif
1157
1158                 /* Recalculate torch radius */
1159                 p_ptr->update |= (PU_TORCH);
1160
1161                 /* Some ego light lose its effects without fuel */
1162                 p_ptr->update |= (PU_BONUS);
1163         }
1164
1165         /* The light is getting dim */
1166         else if (o_ptr->name2 == EGO_LITE_LONG)
1167         {
1168                 if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
1169                     && (turn % (TURNS_PER_TICK*2)))
1170                 {
1171                         if (disturb_minor) disturb(0, 1);
1172 #ifdef JP
1173 msg_print("ÌÀ¤«¤ê¤¬Èù¤«¤Ë¤Ê¤Ã¤Æ¤­¤Æ¤¤¤ë¡£");
1174 #else
1175                         msg_print("Your light is growing faint.");
1176 #endif
1177
1178                 }
1179         }
1180
1181         /* The light is getting dim */
1182         else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
1183         {
1184                 if (disturb_minor) disturb(0, 1);
1185 #ifdef JP
1186 msg_print("ÌÀ¤«¤ê¤¬Èù¤«¤Ë¤Ê¤Ã¤Æ¤­¤Æ¤¤¤ë¡£");
1187 #else
1188                 msg_print("Your light is growing faint.");
1189 #endif
1190
1191         }
1192 }
1193
1194 /*!
1195  * @brief ¥¯¥¨¥¹¥È³¬Áؤ«¤éΥ椹¤ëºÝ¤Î½èÍý
1196  * @return ¤Ê¤·
1197  */
1198 void leave_quest_check(void)
1199 {
1200         /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
1201         leaving_quest = p_ptr->inside_quest;
1202
1203         /* Leaving an 'only once' quest marks it as failed */
1204         if (leaving_quest)
1205         {       
1206                 quest_type* const q_ptr = &quest[leaving_quest];
1207                 
1208             if(((q_ptr->flags & QUEST_FLAG_ONCE)  || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
1209                (q_ptr->status == QUEST_STATUS_TAKEN))
1210                 {
1211                         q_ptr->status = QUEST_STATUS_FAILED;
1212                         q_ptr->complev = (byte)p_ptr->lev;
1213                         update_playtime();
1214                         q_ptr->comptime = playtime;
1215
1216                         /* Additional settings */
1217                         switch (q_ptr->type)
1218                         {
1219                           case QUEST_TYPE_TOWER:
1220                                 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1221                                 quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1222                                 break;
1223                           case QUEST_TYPE_FIND_ARTIFACT:
1224                                 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
1225                                 break;
1226                           case QUEST_TYPE_RANDOM:
1227                                 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
1228
1229                                 /* Floor of random quest will be blocked */
1230                                 prepare_change_floor_mode(CFM_NO_RETURN);
1231                                 break;
1232                         }
1233
1234                         /* Record finishing a quest */
1235                         if (q_ptr->type == QUEST_TYPE_RANDOM)
1236                         {
1237                                 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
1238                         }
1239                         else
1240                         {
1241                                 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
1242                         }
1243                 }
1244         }
1245 }
1246
1247 /*!
1248  * @brief ¡ÖÅã¡×¥¯¥¨¥¹¥È¤Î³Æ³¬Áؤ«¤éΥ椹¤ëºÝ¤Î½èÍý
1249  * @return ¤Ê¤·
1250  */
1251 void leave_tower_check(void)
1252 {
1253         leaving_quest = p_ptr->inside_quest;
1254         /* Check for Tower Quest */
1255         if (leaving_quest &&
1256                 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
1257                 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
1258         {
1259                 if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
1260                 {
1261                         quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
1262                         quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
1263                         update_playtime();
1264                         quest[QUEST_TOWER1].comptime = playtime;
1265                 }
1266         }
1267 }
1268
1269 /*!
1270  * @brief Ä¶Ç½ÎϼԤΥµ¥¤¥³¥á¥È¥ê¡¼½èÍý/ Forcibly pseudo-identify an object in the inventory (or on the floor)
1271  * @return ¤Ê¤·
1272  * @todo mind.c¤Ë¤³¤Î´Ø¿ô¤ò°ÜÆ°¤µ¤»¤ë¤Ù¤­¡£
1273  * @note
1274  * currently this function allows pseudo-id of any object,
1275  * including silly ones like potions & scrolls, which always
1276  * get '{average}'. This should be changed, either to stop such
1277  * items from being pseudo-id'd, or to allow psychometry to
1278  * detect whether the unidentified potion/scroll/etc is
1279  * good (Cure Light Wounds, Restore Strength, etc) or
1280  * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
1281  */
1282 bool psychometry(void)
1283 {
1284         int             item;
1285         object_type     *o_ptr;
1286         char            o_name[MAX_NLEN];
1287         byte            feel;
1288         cptr            q, s;
1289         bool okay = FALSE;
1290
1291         item_tester_no_ryoute = TRUE;
1292         /* Get an item */
1293 #ifdef JP
1294 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤Þ¤¹¤«¡©";
1295 s = "Ä´¤Ù¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
1296 #else
1297         q = "Meditate on which item? ";
1298         s = "You have nothing appropriate.";
1299 #endif
1300
1301         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
1302
1303         /* Get the item (in the pack) */
1304         if (item >= 0)
1305         {
1306                 o_ptr = &inventory[item];
1307         }
1308
1309         /* Get the item (on the floor) */
1310         else
1311         {
1312                 o_ptr = &o_list[0 - item];
1313         }
1314
1315         /* It is fully known, no information needed */
1316         if (object_is_known(o_ptr))
1317         {
1318 #ifdef JP
1319 msg_print("²¿¤â¿·¤·¤¤¤³¤È¤ÏȽ¤é¤Ê¤«¤Ã¤¿¡£");
1320 #else
1321                 msg_print("You cannot find out anything more about that.");
1322 #endif
1323
1324                 return TRUE;
1325         }
1326
1327         /* Check for a feeling */
1328         feel = value_check_aux1(o_ptr);
1329
1330         /* Get an object description */
1331         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1332
1333         /* Skip non-feelings */
1334         if (!feel)
1335         {
1336 #ifdef JP
1337 msg_format("%s¤«¤é¤ÏÆäËÊѤï¤Ã¤¿»ö¤Ï´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿¡£", o_name);
1338 #else
1339                 msg_format("You do not perceive anything unusual about the %s.", o_name);
1340 #endif
1341
1342                 return TRUE;
1343         }
1344
1345 #ifdef JP
1346 msg_format("%s¤Ï%s¤È¤¤¤¦´¶¤¸¤¬¤¹¤ë...",
1347     o_name,  game_inscriptions[feel]);
1348 #else
1349         msg_format("You feel that the %s %s %s...",
1350                            o_name, ((o_ptr->number == 1) ? "is" : "are"),
1351                            game_inscriptions[feel]);
1352 #endif
1353
1354
1355         /* We have "felt" it */
1356         o_ptr->ident |= (IDENT_SENSE);
1357
1358         /* "Inscribe" it */
1359         o_ptr->feeling = feel;
1360
1361         /* Player touches it */
1362         o_ptr->marked |= OM_TOUCHED;
1363
1364         /* Combine / Reorder the pack (later) */
1365         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1366
1367         /* Window stuff */
1368         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1369
1370         /* Valid "tval" codes */
1371         switch (o_ptr->tval)
1372         {
1373         case TV_SHOT:
1374         case TV_ARROW:
1375         case TV_BOLT:
1376         case TV_BOW:
1377         case TV_DIGGING:
1378         case TV_HAFTED:
1379         case TV_POLEARM:
1380         case TV_SWORD:
1381         case TV_BOOTS:
1382         case TV_GLOVES:
1383         case TV_HELM:
1384         case TV_CROWN:
1385         case TV_SHIELD:
1386         case TV_CLOAK:
1387         case TV_SOFT_ARMOR:
1388         case TV_HARD_ARMOR:
1389         case TV_DRAG_ARMOR:
1390         case TV_CARD:
1391         case TV_RING:
1392         case TV_AMULET:
1393         case TV_LITE:
1394         case TV_FIGURINE:
1395                 okay = TRUE;
1396                 break;
1397         }
1398
1399         /* Auto-inscription/destroy */
1400         autopick_alter_item(item, (bool)(okay && destroy_feeling));
1401
1402         /* Something happened */
1403         return (TRUE);
1404 }
1405
1406 /*!
1407  * @brief !!¤ò¹ï¤ó¤ÀËâÆ»¶ñ¤Î»þ´Ö·Ð²á¤Ë¤è¤ëºÆ½¼Å¶¤òÃΤ餻¤ë½èÍý / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
1408  * @param o_ptr Âоݥª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1409  * @return ¤Ê¤·
1410  */
1411 static void recharged_notice(object_type *o_ptr)
1412 {
1413         char o_name[MAX_NLEN];
1414
1415         cptr s;
1416
1417         /* No inscription */
1418         if (!o_ptr->inscription) return;
1419
1420         /* Find a '!' */
1421         s = my_strchr(quark_str(o_ptr->inscription), '!');
1422
1423         /* Process notification request. */
1424         while (s)
1425         {
1426                 /* Find another '!' */
1427                 if (s[1] == '!')
1428                 {
1429                         /* Describe (briefly) */
1430                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1431
1432                         /* Notify the player */
1433 #ifdef JP
1434                         msg_format("%s¤ÏºÆ½¼Å¶¤µ¤ì¤¿¡£", o_name);
1435 #else
1436                         if (o_ptr->number > 1)
1437                                 msg_format("Your %s are recharged.", o_name);
1438                         else
1439                                 msg_format("Your %s is recharged.", o_name);
1440 #endif
1441
1442                         disturb(0, 0);
1443
1444                         /* Done. */
1445                         return;
1446                 }
1447
1448                 /* Keep looking for '!'s */
1449                 s = my_strchr(s + 1, '!');
1450         }
1451 }
1452
1453 /*!
1454  * @brief ¥×¥ì¥¤¥ä¡¼¤Î²Î¤Ë´Ø¤¹¤ë·Ñ³½èÍý
1455  * @return ¤Ê¤·
1456  */
1457 static void check_music(void)
1458 {
1459         const magic_type *s_ptr;
1460         int spell;
1461         s32b need_mana;
1462         u32b need_mana_frac;
1463
1464         /* Music singed by player */
1465         if (p_ptr->pclass != CLASS_BARD) return;
1466         if (!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return;
1467
1468         if (p_ptr->anti_magic)
1469         {
1470                 stop_singing();
1471                 return;
1472         }
1473
1474         spell = p_ptr->magic_num2[0];
1475         s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
1476
1477         need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
1478         need_mana_frac = 0;
1479
1480         /* Divide by 2 */
1481         s64b_RSHIFT(need_mana, need_mana_frac, 1);
1482
1483         if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
1484         {
1485                 stop_singing();
1486                 return;
1487         }
1488         else
1489         {
1490                 s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
1491
1492                 p_ptr->redraw |= PR_MANA;
1493                 if (p_ptr->magic_num1[1])
1494                 {
1495                         p_ptr->magic_num1[0] = p_ptr->magic_num1[1];
1496                         p_ptr->magic_num1[1] = 0;
1497 #ifdef JP
1498                         msg_print("²Î¤òºÆ³«¤·¤¿¡£");
1499 #else
1500                         msg_print("You restart singing.");
1501 #endif
1502                         p_ptr->action = ACTION_SING;
1503
1504                         /* Recalculate bonuses */
1505                         p_ptr->update |= (PU_BONUS | PU_HP);
1506
1507                         /* Redraw map and status bar */
1508                         p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
1509
1510                         /* Update monsters */
1511                         p_ptr->update |= (PU_MONSTERS);
1512
1513                         /* Window stuff */
1514                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1515                 }
1516         }
1517         if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
1518                 p_ptr->spell_exp[spell] += 5;
1519         else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
1520         { if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
1521         else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
1522         { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1523         else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
1524         { if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
1525
1526         /* Do any effects of continual song */
1527         do_spell(REALM_MUSIC, spell, SPELL_CONT);
1528 }
1529
1530 /*!
1531  * @brief ¸½ºß¼ö¤¤¤òÊÝ»ý¤·¤Æ¤¤¤ëÁõÈ÷Éʤò°ì¤Ä¥é¥ó¥À¥à¤Ëõ¤·½Ð¤¹ / Choose one of items that have cursed flag
1532  * @param flag Ãµ¤·½Ð¤·¤¿¤¤¼ö¤¤¥Õ¥é¥°ÇÛÎó
1533  * @return ³ºÅö¤Î¼ö¤¤¤¬°ì¤Ä¤Ç¤â¤¢¤Ã¤¿¾ì¹ç¤Ë¥é¥ó¥À¥à¤ËÁª¤Ð¤ì¤¿ÁõÈ÷ÉʤΥª¥Ö¥¸¥§¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£\n
1534  * ¼ö¤¤¤¬¤Ê¤¤¾ì¹çNULL¤òÊÖ¤¹¡£
1535  */
1536 static object_type *choose_cursed_obj_name(u32b flag)
1537 {
1538         int i;
1539         int choices[INVEN_TOTAL-INVEN_RARM];
1540         int number = 0;
1541
1542         /* Paranoia -- Player has no warning-item */
1543         if (!(p_ptr->cursed & flag)) return NULL;
1544
1545         /* Search Inventry */
1546         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1547         {
1548                 object_type *o_ptr = &inventory[i];
1549
1550                 if (o_ptr->curse_flags & flag)
1551                 {
1552                         choices[number] = i;
1553                         number++;
1554                 }
1555                 else if ((flag == TRC_ADD_L_CURSE) || 
1556                                         (flag == TRC_ADD_H_CURSE) || 
1557                                         (flag == TRC_DRAIN_HP) || 
1558                                         (flag == TRC_DRAIN_MANA) || 
1559                                         (flag == TRC_CALL_ANIMAL) || 
1560                                         (flag == TRC_CALL_DEMON) || 
1561                                         (flag == TRC_CALL_DRAGON) || 
1562                                         (flag == TRC_CALL_UNDEAD) || 
1563                                         (flag == TRC_COWARDICE) || 
1564                                         (flag == TRC_LOW_MELEE) || 
1565                                         (flag == TRC_LOW_AC) || 
1566                                         (flag == TRC_LOW_MAGIC) || 
1567                                         (flag == TRC_FAST_DIGEST) || 
1568                                         (flag == TRC_SLOW_REGEN) )
1569                 {
1570                         u32b cf;
1571                         u32b flgs[TR_FLAG_SIZE];
1572                         object_flags(o_ptr, flgs);
1573                         switch (flag)
1574                         {
1575                           case TRC_ADD_L_CURSE  : cf = TR_ADD_L_CURSE; break;
1576                           case TRC_ADD_H_CURSE  : cf = TR_ADD_H_CURSE; break;
1577                           case TRC_DRAIN_HP             : cf = TR_DRAIN_HP; break;
1578                           case TRC_DRAIN_MANA   : cf = TR_DRAIN_MANA; break;
1579                           case TRC_CALL_ANIMAL  : cf = TR_CALL_ANIMAL; break;
1580                           case TRC_CALL_DEMON   : cf = TR_CALL_DEMON; break;
1581                           case TRC_CALL_DRAGON  : cf = TR_CALL_DRAGON; break;
1582                           case TRC_CALL_UNDEAD  : cf = TR_CALL_UNDEAD; break;
1583                           case TRC_COWARDICE    : cf = TR_COWARDICE; break;
1584                           case TRC_LOW_MELEE    : cf = TR_LOW_MELEE; break;
1585                           case TRC_LOW_AC               : cf = TR_LOW_AC; break;
1586                           case TRC_LOW_MAGIC    : cf = TR_LOW_MAGIC; break;
1587                           case TRC_FAST_DIGEST  : cf = TR_FAST_DIGEST; break;
1588                           case TRC_SLOW_REGEN   : cf = TR_SLOW_REGEN; break;
1589                           default                               : break;
1590                         }
1591                         if (have_flag(flgs, cf))
1592                         {
1593                                 choices[number] = i;
1594                                 number++;
1595                         }
1596                 }
1597         }
1598
1599         /* Choice one of them */
1600         return (&inventory[choices[randint0(number)]]);
1601 }
1602
1603 /*!
1604  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ë¤´¤È¤Ë¥×¥ì¥¤¥ä¡¼¤ÎHP¤ÈMP¤ÎÁý¸º½èÍý¤ò¹Ô¤¦¡£
1605  *  / Handle timed damage and regeneration every 10 game turns
1606  * @return ¤Ê¤·
1607  */
1608 static void process_world_aux_hp_and_sp(void)
1609 {
1610         feature_type *f_ptr = &f_info[cave[py][px].feat];
1611         bool cave_no_regen = FALSE;
1612         int upkeep_factor = 0;
1613
1614         /* Default regeneration */
1615         int regen_amount = PY_REGEN_NORMAL;
1616
1617
1618         /*** Damage over Time ***/
1619
1620         /* Take damage from poison */
1621         if (p_ptr->poisoned && !IS_INVULN())
1622         {
1623                 /* Take damage */
1624 #ifdef JP
1625                 take_hit(DAMAGE_NOESCAPE, 1, "ÆÇ", -1);
1626 #else
1627                 take_hit(DAMAGE_NOESCAPE, 1, "poison", -1);
1628 #endif
1629
1630         }
1631
1632         /* Take damage from cuts */
1633         if (p_ptr->cut && !IS_INVULN())
1634         {
1635                 int dam;
1636
1637                 /* Mortal wound or Deep Gash */
1638                 if (p_ptr->cut > 1000)
1639                 {
1640                         dam = 200;
1641                 }
1642
1643                 else if (p_ptr->cut > 200)
1644                 {
1645                         dam = 80;
1646                 }
1647
1648                 /* Severe cut */
1649                 else if (p_ptr->cut > 100)
1650                 {
1651                         dam = 32;
1652                 }
1653
1654                 else if (p_ptr->cut > 50)
1655                 {
1656                         dam = 16;
1657                 }
1658
1659                 else if (p_ptr->cut > 25)
1660                 {
1661                         dam = 7;
1662                 }
1663
1664                 else if (p_ptr->cut > 10)
1665                 {
1666                         dam = 3;
1667                 }
1668
1669                 /* Other cuts */
1670                 else
1671                 {
1672                         dam = 1;
1673                 }
1674
1675                 /* Take damage */
1676 #ifdef JP
1677                 take_hit(DAMAGE_NOESCAPE, dam, "Ã×Ì¿½ý", -1);
1678 #else
1679                 take_hit(DAMAGE_NOESCAPE, dam, "a fatal wound", -1);
1680 #endif
1681
1682         }
1683
1684
1685         /* (Vampires) Take damage from sunlight */
1686         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
1687         {
1688                 if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
1689                 {
1690                         if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
1691                         {
1692                                 /* Take damage */
1693 #ifdef JP
1694 msg_print("Æü¸÷¤¬¤¢¤Ê¤¿¤Î¥¢¥ó¥Ç¥Ã¥É¤ÎÆùÂΤò¾Æ¤­¾Ç¤¬¤·¤¿¡ª");
1695 take_hit(DAMAGE_NOESCAPE, 1, "Æü¸÷", -1);
1696 #else
1697                                 msg_print("The sun's rays scorch your undead flesh!");
1698                                 take_hit(DAMAGE_NOESCAPE, 1, "sunlight", -1);
1699 #endif
1700
1701                                 cave_no_regen = TRUE;
1702                         }
1703                 }
1704
1705                 if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
1706                     !p_ptr->resist_lite)
1707                 {
1708                         object_type * o_ptr = &inventory[INVEN_LITE];
1709                         char o_name [MAX_NLEN];
1710                         char ouch [MAX_NLEN+40];
1711
1712                         /* Get an object description */
1713                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1714
1715 #ifdef JP
1716 msg_format("%s¤¬¤¢¤Ê¤¿¤Î¥¢¥ó¥Ç¥Ã¥É¤ÎÆùÂΤò¾Æ¤­¾Ç¤¬¤·¤¿¡ª", o_name);
1717 #else
1718                         msg_format("The %s scorches your undead flesh!", o_name);
1719 #endif
1720
1721
1722                         cave_no_regen = TRUE;
1723
1724                         /* Get an object description */
1725                         object_desc(o_name, o_ptr, OD_NAME_ONLY);
1726
1727 #ifdef JP
1728 sprintf(ouch, "%s¤òÁõÈ÷¤·¤¿¥À¥á¡¼¥¸", o_name);
1729 #else
1730                         sprintf(ouch, "wielding %s", o_name);
1731 #endif
1732
1733                         if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, 1, ouch, -1);
1734                 }
1735         }
1736
1737         if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN() && !p_ptr->immune_fire)
1738         {
1739                 int damage = 0;
1740
1741                 if (have_flag(f_ptr->flags, FF_DEEP))
1742                 {
1743                         damage = 6000 + randint0(4000);
1744                 }
1745                 else if (!p_ptr->levitation)
1746                 {
1747                         damage = 3000 + randint0(2000);
1748                 }
1749
1750                 if (damage)
1751                 {
1752                         if (prace_is_(RACE_ENT)) damage += damage / 3;
1753                         if (p_ptr->resist_fire) damage = damage / 3;
1754                         if (IS_OPPOSE_FIRE()) damage = damage / 3;
1755
1756                         if (p_ptr->levitation) damage = damage / 5;
1757
1758                         damage = damage / 100 + (randint0(100) < (damage % 100));
1759
1760                         if (p_ptr->levitation)
1761                         {
1762 #ifdef JP
1763                                 msg_print("Ç®¤Ç²Ð½ý¤·¤¿¡ª");
1764                                 take_hit(DAMAGE_NOESCAPE, damage, format("%s¤Î¾å¤ËÉâÍ·¤·¤¿¥À¥á¡¼¥¸", f_name + f_info[get_feat_mimic(&cave[py][px])].name), -1);
1765 #else
1766                                 msg_print("The heat burns you!");
1767                                 take_hit(DAMAGE_NOESCAPE, damage, format("flying over %s", f_name + f_info[get_feat_mimic(&cave[py][px])].name), -1);
1768 #endif
1769                         }
1770                         else
1771                         {
1772                                 cptr name = f_name + f_info[get_feat_mimic(&cave[py][px])].name;
1773 #ifdef JP
1774                                 msg_format("%s¤Ç²Ð½ý¤·¤¿¡ª", name);
1775 #else
1776                                 msg_format("The %s burns you!", name);
1777 #endif
1778                                 take_hit(DAMAGE_NOESCAPE, damage, name, -1);
1779                         }
1780
1781                         cave_no_regen = TRUE;
1782                 }
1783         }
1784
1785         if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1786             !p_ptr->levitation && !p_ptr->can_swim)
1787         {
1788                 if (p_ptr->total_weight > weight_limit())
1789                 {
1790                         /* Take damage */
1791 #ifdef JP
1792                         msg_print("Å®¤ì¤Æ¤¤¤ë¡ª");
1793                         take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), "Å®¤ì", -1);
1794 #else
1795                         msg_print("You are drowning!");
1796                         take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->lev), "drowning", -1);
1797 #endif
1798
1799                         cave_no_regen = TRUE;
1800                 }
1801         }
1802
1803         if (p_ptr->riding)
1804         {
1805                 int damage;
1806                 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
1807                 {
1808                         damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1809                         if (prace_is_(RACE_ENT)) damage += damage / 3;
1810                         if (p_ptr->resist_fire) damage = damage / 3;
1811                         if (IS_OPPOSE_FIRE()) damage = damage / 3;
1812 #ifdef JP
1813 msg_print("Ç®¤¤¡ª");
1814 take_hit(DAMAGE_NOESCAPE, damage, "±ê¤Î¥ª¡¼¥é", -1);
1815 #else
1816                         msg_print("It's hot!");
1817                         take_hit(DAMAGE_NOESCAPE, damage, "Fire aura", -1);
1818 #endif
1819                 }
1820                 if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !p_ptr->immune_elec)
1821                 {
1822                         damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1823                         if (prace_is_(RACE_ANDROID)) damage += damage / 3;
1824                         if (p_ptr->resist_elec) damage = damage / 3;
1825                         if (IS_OPPOSE_ELEC()) damage = damage / 3;
1826 #ifdef JP
1827 msg_print("Äˤ¤¡ª");
1828 take_hit(DAMAGE_NOESCAPE, damage, "Åŵ¤¤Î¥ª¡¼¥é", -1);
1829 #else
1830                         msg_print("It hurts!");
1831                         take_hit(DAMAGE_NOESCAPE, damage, "Elec aura", -1);
1832 #endif
1833                 }
1834                 if ((r_info[m_list[p_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !p_ptr->immune_cold)
1835                 {
1836                         damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
1837                         if (p_ptr->resist_cold) damage = damage / 3;
1838                         if (IS_OPPOSE_COLD()) damage = damage / 3;
1839 #ifdef JP
1840 msg_print("Î䤿¤¤¡ª");
1841 take_hit(DAMAGE_NOESCAPE, damage, "Î䵤¤Î¥ª¡¼¥é", -1);
1842 #else
1843                         msg_print("It's cold!");
1844                         take_hit(DAMAGE_NOESCAPE, damage, "Cold aura", -1);
1845 #endif
1846                 }
1847         }
1848
1849         /* Spectres -- take damage when moving through walls */
1850         /*
1851          * Added: ANYBODY takes damage if inside through walls
1852          * without wraith form -- NOTE: Spectres will never be
1853          * reduced below 0 hp by being inside a stone wall; others
1854          * WILL BE!
1855          */
1856         if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1857         {
1858                 if (!IS_INVULN() && !p_ptr->wraith_form && !p_ptr->kabenuke &&
1859                     ((p_ptr->chp > (p_ptr->lev / 5)) || !p_ptr->pass_wall))
1860                 {
1861                         cptr dam_desc;
1862
1863                         cave_no_regen = TRUE;
1864
1865                         if (p_ptr->pass_wall)
1866                         {
1867 #ifdef JP
1868                                 msg_print("ÂΤÎʬ»Ò¤¬Ê¬²ò¤·¤¿µ¤¤¬¤¹¤ë¡ª");
1869                                 dam_desc = "Ì©ÅÙ";
1870 #else
1871                                 msg_print("Your molecules feel disrupted!");
1872                                 dam_desc = "density";
1873 #endif
1874                         }
1875                         else
1876                         {
1877 #ifdef JP
1878                                 msg_print("Êø¤ì¤¿´ä¤Ë²¡¤·ÄÙ¤µ¤ì¤¿¡ª");
1879                                 dam_desc = "¹Å¤¤´ä";
1880 #else
1881                                 msg_print("You are being crushed!");
1882                                 dam_desc = "solid rock";
1883 #endif
1884                         }
1885
1886                         take_hit(DAMAGE_NOESCAPE, 1 + (p_ptr->lev / 5), dam_desc, -1);
1887                 }
1888         }
1889
1890
1891         /*** handle regeneration ***/
1892
1893         /* Getting Weak */
1894         if (p_ptr->food < PY_FOOD_WEAK)
1895         {
1896                 /* Lower regeneration */
1897                 if (p_ptr->food < PY_FOOD_STARVE)
1898                 {
1899                         regen_amount = 0;
1900                 }
1901                 else if (p_ptr->food < PY_FOOD_FAINT)
1902                 {
1903                         regen_amount = PY_REGEN_FAINT;
1904                 }
1905                 else
1906                 {
1907                         regen_amount = PY_REGEN_WEAK;
1908                 }
1909         }
1910
1911         /* Are we walking the pattern? */
1912         if (pattern_effect())
1913         {
1914                 cave_no_regen = TRUE;
1915         }
1916         else
1917         {
1918                 /* Regeneration ability */
1919                 if (p_ptr->regenerate)
1920                 {
1921                         regen_amount = regen_amount * 2;
1922                 }
1923                 if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
1924                 {
1925                         regen_amount /= 2;
1926                 }
1927                 if (p_ptr->cursed & TRC_SLOW_REGEN)
1928                 {
1929                         regen_amount /= 5;
1930                 }
1931         }
1932
1933
1934         /* Searching or Resting */
1935         if ((p_ptr->action == ACTION_SEARCH) || (p_ptr->action == ACTION_REST))
1936         {
1937                 regen_amount = regen_amount * 2;
1938         }
1939
1940         upkeep_factor = calculate_upkeep();
1941
1942         /* No regeneration while special action */
1943         if ((p_ptr->action == ACTION_LEARN) ||
1944             (p_ptr->action == ACTION_HAYAGAKE) ||
1945             (p_ptr->special_defense & KATA_KOUKIJIN))
1946         {
1947                 upkeep_factor += 100;
1948         }
1949
1950         /* Regenerate the mana */
1951         regenmana(upkeep_factor, regen_amount);
1952
1953
1954         /* Recharge magic eater's power */
1955         if (p_ptr->pclass == CLASS_MAGIC_EATER)
1956         {
1957                 regenmagic(regen_amount);
1958         }
1959
1960         if ((p_ptr->csp == 0) && (p_ptr->csp_frac == 0))
1961         {
1962                 while (upkeep_factor > 100)
1963                 {
1964 #ifdef JP
1965                         msg_print("¤³¤ó¤Ê¤Ë¿¤¯¤Î¥Ú¥Ã¥È¤òÀ©¸æ¤Ç¤­¤Ê¤¤¡ª");
1966 #else
1967                         msg_print("Too many pets to control at once!");
1968 #endif
1969                         msg_print(NULL);
1970                         do_cmd_pet_dismiss();
1971
1972                         upkeep_factor = calculate_upkeep();
1973
1974 #ifdef JP
1975                         msg_format("°Ý»ý£Í£Ð¤Ï %d%%", upkeep_factor);
1976 #else
1977                         msg_format("Upkeep: %d%% mana.", upkeep_factor);
1978 #endif
1979                         msg_print(NULL);
1980                 }
1981         }
1982
1983         /* Poisoned or cut yields no healing */
1984         if (p_ptr->poisoned) regen_amount = 0;
1985         if (p_ptr->cut) regen_amount = 0;
1986
1987         /* Special floor -- Pattern, in a wall -- yields no healing */
1988         if (cave_no_regen) regen_amount = 0;
1989
1990         regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
1991
1992         /* Regenerate Hit Points if needed */
1993         if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
1994         {
1995                 regenhp(regen_amount);
1996         }
1997 }
1998
1999 /*!
2000  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ë¤´¤È¤ËËâË¡¸ú²Ì¤Î»Ä¤ê¥¿¡¼¥ó¤ò¸º¤é¤·¤Æ¤¤¤¯½èÍý
2001  * / Handle timeout every 10 game turns
2002  * @return ¤Ê¤·
2003  */
2004 static void process_world_aux_timeout(void)
2005 {
2006         const int dec_count = (easy_band ? 2 : 1);
2007
2008         /*** Timeout Various Things ***/
2009
2010         /* Mimic */
2011         if (p_ptr->tim_mimic)
2012         {
2013                 (void)set_mimic(p_ptr->tim_mimic - 1, p_ptr->mimic_form, TRUE);
2014         }
2015
2016         /* Hack -- Hallucinating */
2017         if (p_ptr->image)
2018         {
2019                 (void)set_image(p_ptr->image - dec_count);
2020         }
2021
2022         /* Blindness */
2023         if (p_ptr->blind)
2024         {
2025                 (void)set_blind(p_ptr->blind - dec_count);
2026         }
2027
2028         /* Times see-invisible */
2029         if (p_ptr->tim_invis)
2030         {
2031                 (void)set_tim_invis(p_ptr->tim_invis - 1, TRUE);
2032         }
2033
2034         if (multi_rew)
2035         {
2036                 multi_rew = FALSE;
2037         }
2038
2039         /* Timed esp */
2040         if (p_ptr->tim_esp)
2041         {
2042                 (void)set_tim_esp(p_ptr->tim_esp - 1, TRUE);
2043         }
2044
2045         /* Timed temporary elemental brands. -LM- */
2046         if (p_ptr->ele_attack)
2047         {
2048                 p_ptr->ele_attack--;
2049
2050                 /* Clear all temporary elemental brands. */
2051                 if (!p_ptr->ele_attack) set_ele_attack(0, 0);
2052         }
2053
2054         /* Timed temporary elemental immune. -LM- */
2055         if (p_ptr->ele_immune)
2056         {
2057                 p_ptr->ele_immune--;
2058
2059                 /* Clear all temporary elemental brands. */
2060                 if (!p_ptr->ele_immune) set_ele_immune(0, 0);
2061         }
2062
2063         /* Timed infra-vision */
2064         if (p_ptr->tim_infra)
2065         {
2066                 (void)set_tim_infra(p_ptr->tim_infra - 1, TRUE);
2067         }
2068
2069         /* Timed stealth */
2070         if (p_ptr->tim_stealth)
2071         {
2072                 (void)set_tim_stealth(p_ptr->tim_stealth - 1, TRUE);
2073         }
2074
2075         /* Timed levitation */
2076         if (p_ptr->tim_levitation)
2077         {
2078                 (void)set_tim_levitation(p_ptr->tim_levitation - 1, TRUE);
2079         }
2080
2081         /* Timed sh_touki */
2082         if (p_ptr->tim_sh_touki)
2083         {
2084                 (void)set_tim_sh_touki(p_ptr->tim_sh_touki - 1, TRUE);
2085         }
2086
2087         /* Timed sh_fire */
2088         if (p_ptr->tim_sh_fire)
2089         {
2090                 (void)set_tim_sh_fire(p_ptr->tim_sh_fire - 1, TRUE);
2091         }
2092
2093         /* Timed sh_holy */
2094         if (p_ptr->tim_sh_holy)
2095         {
2096                 (void)set_tim_sh_holy(p_ptr->tim_sh_holy - 1, TRUE);
2097         }
2098
2099         /* Timed eyeeye */
2100         if (p_ptr->tim_eyeeye)
2101         {
2102                 (void)set_tim_eyeeye(p_ptr->tim_eyeeye - 1, TRUE);
2103         }
2104
2105         /* Timed resist-magic */
2106         if (p_ptr->resist_magic)
2107         {
2108                 (void)set_resist_magic(p_ptr->resist_magic - 1, TRUE);
2109         }
2110
2111         /* Timed regeneration */
2112         if (p_ptr->tim_regen)
2113         {
2114                 (void)set_tim_regen(p_ptr->tim_regen - 1, TRUE);
2115         }
2116
2117         /* Timed resist nether */
2118         if (p_ptr->tim_res_nether)
2119         {
2120                 (void)set_tim_res_nether(p_ptr->tim_res_nether - 1, TRUE);
2121         }
2122
2123         /* Timed resist time */
2124         if (p_ptr->tim_res_time)
2125         {
2126                 (void)set_tim_res_time(p_ptr->tim_res_time - 1, TRUE);
2127         }
2128
2129         /* Timed reflect */
2130         if (p_ptr->tim_reflect)
2131         {
2132                 (void)set_tim_reflect(p_ptr->tim_reflect - 1, TRUE);
2133         }
2134
2135         /* Multi-shadow */
2136         if (p_ptr->multishadow)
2137         {
2138                 (void)set_multishadow(p_ptr->multishadow - 1, TRUE);
2139         }
2140
2141         /* Timed Robe of dust */
2142         if (p_ptr->dustrobe)
2143         {
2144                 (void)set_dustrobe(p_ptr->dustrobe - 1, TRUE);
2145         }
2146
2147         /* Timed infra-vision */
2148         if (p_ptr->kabenuke)
2149         {
2150                 (void)set_kabenuke(p_ptr->kabenuke - 1, TRUE);
2151         }
2152
2153         /* Paralysis */
2154         if (p_ptr->paralyzed)
2155         {
2156                 (void)set_paralyzed(p_ptr->paralyzed - dec_count);
2157         }
2158
2159         /* Confusion */
2160         if (p_ptr->confused)
2161         {
2162                 (void)set_confused(p_ptr->confused - dec_count);
2163         }
2164
2165         /* Afraid */
2166         if (p_ptr->afraid)
2167         {
2168                 (void)set_afraid(p_ptr->afraid - dec_count);
2169         }
2170
2171         /* Fast */
2172         if (p_ptr->fast)
2173         {
2174                 (void)set_fast(p_ptr->fast - 1, TRUE);
2175         }
2176
2177         /* Slow */
2178         if (p_ptr->slow)
2179         {
2180                 (void)set_slow(p_ptr->slow - dec_count, TRUE);
2181         }
2182
2183         /* Protection from evil */
2184         if (p_ptr->protevil)
2185         {
2186                 (void)set_protevil(p_ptr->protevil - 1, TRUE);
2187         }
2188
2189         /* Invulnerability */
2190         if (p_ptr->invuln)
2191         {
2192                 (void)set_invuln(p_ptr->invuln - 1, TRUE);
2193         }
2194
2195         /* Wraith form */
2196         if (p_ptr->wraith_form)
2197         {
2198                 (void)set_wraith_form(p_ptr->wraith_form - 1, TRUE);
2199         }
2200
2201         /* Heroism */
2202         if (p_ptr->hero)
2203         {
2204                 (void)set_hero(p_ptr->hero - 1, TRUE);
2205         }
2206
2207         /* Super Heroism */
2208         if (p_ptr->shero)
2209         {
2210                 (void)set_shero(p_ptr->shero - 1, TRUE);
2211         }
2212
2213         /* Blessed */
2214         if (p_ptr->blessed)
2215         {
2216                 (void)set_blessed(p_ptr->blessed - 1, TRUE);
2217         }
2218
2219         /* Shield */
2220         if (p_ptr->shield)
2221         {
2222                 (void)set_shield(p_ptr->shield - 1, TRUE);
2223         }
2224
2225         /* Tsubureru */
2226         if (p_ptr->tsubureru)
2227         {
2228                 (void)set_tsubureru(p_ptr->tsubureru - 1, TRUE);
2229         }
2230
2231         /* Magicdef */
2232         if (p_ptr->magicdef)
2233         {
2234                 (void)set_magicdef(p_ptr->magicdef - 1, TRUE);
2235         }
2236
2237         /* Tsuyoshi */
2238         if (p_ptr->tsuyoshi)
2239         {
2240                 (void)set_tsuyoshi(p_ptr->tsuyoshi - 1, TRUE);
2241         }
2242
2243         /* Oppose Acid */
2244         if (p_ptr->oppose_acid)
2245         {
2246                 (void)set_oppose_acid(p_ptr->oppose_acid - 1, TRUE);
2247         }
2248
2249         /* Oppose Lightning */
2250         if (p_ptr->oppose_elec)
2251         {
2252                 (void)set_oppose_elec(p_ptr->oppose_elec - 1, TRUE);
2253         }
2254
2255         /* Oppose Fire */
2256         if (p_ptr->oppose_fire)
2257         {
2258                 (void)set_oppose_fire(p_ptr->oppose_fire - 1, TRUE);
2259         }
2260
2261         /* Oppose Cold */
2262         if (p_ptr->oppose_cold)
2263         {
2264                 (void)set_oppose_cold(p_ptr->oppose_cold - 1, TRUE);
2265         }
2266
2267         /* Oppose Poison */
2268         if (p_ptr->oppose_pois)
2269         {
2270                 (void)set_oppose_pois(p_ptr->oppose_pois - 1, TRUE);
2271         }
2272
2273         if (p_ptr->ult_res)
2274         {
2275                 (void)set_ultimate_res(p_ptr->ult_res - 1, TRUE);
2276         }
2277
2278         /*** Poison and Stun and Cut ***/
2279
2280         /* Poison */
2281         if (p_ptr->poisoned)
2282         {
2283                 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2284
2285                 /* Apply some healing */
2286                 (void)set_poisoned(p_ptr->poisoned - adjust);
2287         }
2288
2289         /* Stun */
2290         if (p_ptr->stun)
2291         {
2292                 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2293
2294                 /* Apply some healing */
2295                 (void)set_stun(p_ptr->stun - adjust);
2296         }
2297
2298         /* Cut */
2299         if (p_ptr->cut)
2300         {
2301                 int adjust = adj_con_fix[p_ptr->stat_ind[A_CON]] + 1;
2302
2303                 /* Hack -- Truly "mortal" wound */
2304                 if (p_ptr->cut > 1000) adjust = 0;
2305
2306                 /* Apply some healing */
2307                 (void)set_cut(p_ptr->cut - adjust);
2308         }
2309 }
2310
2311
2312 /*!
2313  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ëËè¤Ë¸÷¸»¤Î¼÷Ì¿¤ò¸º¤é¤¹½èÍý
2314  * / Handle burning fuel every 10 game turns
2315  * @return ¤Ê¤·
2316  */
2317 static void process_world_aux_light(void)
2318 {
2319         /* Check for light being wielded */
2320         object_type *o_ptr = &inventory[INVEN_LITE];
2321
2322         /* Burn some fuel in the current lite */
2323         if (o_ptr->tval == TV_LITE)
2324         {
2325                 /* Hack -- Use some fuel (except on artifacts) */
2326                 if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0))
2327                 {
2328                         /* Decrease life-span */
2329                         if (o_ptr->name2 == EGO_LITE_LONG)
2330                         {
2331                                 if (turn % (TURNS_PER_TICK*2)) o_ptr->xtra4--;
2332                         }
2333                         else o_ptr->xtra4--;
2334
2335                         /* Notice interesting fuel steps */
2336                         notice_lite_change(o_ptr);
2337                 }
2338         }
2339 }
2340
2341
2342 /*!
2343  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ë¤´¤È¤ËÆÍÁ³ÊÑ°Û¤ÎȯưȽÄê¤ò¹Ô¤¦½èÍý
2344  * / Handle mutation effects once every 10 game turns
2345  * @return ¤Ê¤·
2346  */
2347 static void process_world_aux_mutation(void)
2348 {
2349         /* No mutation with effects */
2350         if (!p_ptr->muta2) return;
2351
2352         /* No effect on monster arena */
2353         if (p_ptr->inside_battle) return;
2354
2355         /* No effect on the global map */
2356         if (p_ptr->wild_mode) return;
2357
2358
2359         if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
2360         {
2361                 disturb(0, 1);
2362 #ifdef JP
2363                 msg_print("¥¦¥¬¥¡¥¡¥¢¡ª");
2364                 msg_print("·ãÅܤÎȯºî¤Ë½±¤ï¤ì¤¿¡ª");
2365 #else
2366                 msg_print("RAAAAGHH!");
2367                 msg_print("You feel a fit of rage coming over you!");
2368 #endif
2369
2370                 (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
2371                 (void)set_afraid(0);
2372         }
2373
2374         if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
2375         {
2376                 if (!p_ptr->resist_fear)
2377                 {
2378                         disturb(0, 1);
2379 #ifdef JP
2380                         msg_print("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª");
2381 #else
2382                         msg_print("It's so dark... so scary!");
2383 #endif
2384
2385                         set_afraid(p_ptr->afraid + 13 + randint1(26));
2386                 }
2387         }
2388
2389         if ((p_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88))
2390         {
2391                 if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
2392                     !p_ptr->anti_tele)
2393                 {
2394                         disturb(0, 1);
2395
2396                         /* Teleport player */
2397 #ifdef JP
2398                         msg_print("¤¢¤Ê¤¿¤Î°ÌÃÖ¤ÏÆÍÁ³¤Ò¤¸¤ç¤¦¤ËÉÔ³ÎÄê¤Ë¤Ê¤Ã¤¿...");
2399 #else
2400                         msg_print("Your position suddenly seems very uncertain...");
2401 #endif
2402
2403                         msg_print(NULL);
2404                         teleport_player(40, TELEPORT_PASSIVE);
2405                 }
2406         }
2407
2408         if ((p_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321))
2409         {
2410                 if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
2411                 {
2412                         disturb(0, 1);
2413                         p_ptr->redraw |= PR_EXTRA;
2414 #ifdef JP
2415                         msg_print("¤¤¤Ò¤­¤¬¤â¡¼¤í¡¼¤È¤Ò¤Æ¤­¤¿¤­¤¬¤Õ¤ë...¥Ò¥Ã¥¯¡ª");
2416 #else
2417                         msg_print("You feel a SSSCHtupor cOmINg over yOu... *HIC*!");
2418 #endif
2419
2420                 }
2421
2422                 if (!p_ptr->resist_conf)
2423                 {
2424                         (void)set_confused(p_ptr->confused + randint0(20) + 15);
2425                 }
2426
2427                 if (!p_ptr->resist_chaos)
2428                 {
2429                         if (one_in_(20))
2430                         {
2431                                 msg_print(NULL);
2432                                 if (one_in_(3)) lose_all_info();
2433                                 else wiz_dark();
2434                                 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2435                                 wiz_dark();
2436 #ifdef JP
2437                                 msg_print("¤¢¤Ê¤¿¤Ï¸«ÃΤé¤Ì¾ì½ê¤ÇÌܤ¬Àä᤿...Ƭ¤¬Äˤ¤¡£");
2438                                 msg_print("²¿¤â³Ð¤¨¤Æ¤¤¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ËÍ褿¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
2439 #else
2440                                 msg_print("You wake up somewhere with a sore head...");
2441                                 msg_print("You can't remember a thing, or how you got here!");
2442 #endif
2443
2444                         }
2445                         else
2446                         {
2447                                 if (one_in_(3))
2448                                 {
2449 #ifdef JP
2450                                         msg_print("¤­¡Á¤ì¤¤¤Ê¤Á¤ç¤ª¤Á¤ç¤é¤È¤ó¤ì¤¤¤ë¡Á");
2451 #else
2452                                         msg_print("Thishcischs GooDSChtuff!");
2453 #endif
2454
2455                                         (void)set_image(p_ptr->image + randint0(150) + 150);
2456                                 }
2457                         }
2458                 }
2459         }
2460
2461         if ((p_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42))
2462         {
2463                 if (!p_ptr->resist_chaos)
2464                 {
2465                         disturb(0, 1);
2466                         p_ptr->redraw |= PR_EXTRA;
2467                         (void)set_image(p_ptr->image + randint0(50) + 20);
2468                 }
2469         }
2470
2471         if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
2472         {
2473                 disturb(0, 1);
2474
2475 #ifdef JP
2476                 msg_print("¥Ö¥¥¡¼¡¼¥Ã¡ª¤ª¤Ã¤È¡£");
2477 #else
2478                 msg_print("BRRAAAP! Oops.");
2479 #endif
2480
2481                 msg_print(NULL);
2482                 fire_ball(GF_POIS, 0, p_ptr->lev, 3);
2483         }
2484
2485         if ((p_ptr->muta2 & MUT2_PROD_MANA) &&
2486             !p_ptr->anti_magic && one_in_(9000))
2487         {
2488                 int dire = 0;
2489                 disturb(0, 1);
2490 #ifdef JP
2491                 msg_print("ËâË¡¤Î¥¨¥Í¥ë¥®¡¼¤¬ÆÍÁ³¤¢¤Ê¤¿¤ÎÃæ¤Ëή¤ì¹þ¤ó¤Ç¤­¤¿¡ª¥¨¥Í¥ë¥®¡¼¤ò²òÊü¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡ª");
2492 #else
2493                 msg_print("Magical energy flows through you! You must release it!");
2494 #endif
2495
2496                 flush();
2497                 msg_print(NULL);
2498                 (void)get_hack_dir(&dire);
2499                 fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
2500         }
2501
2502         if ((p_ptr->muta2 & MUT2_ATT_DEMON) &&
2503             !p_ptr->anti_magic && (randint1(6666) == 666))
2504         {
2505                 bool pet = one_in_(6);
2506                 u32b mode = PM_ALLOW_GROUP;
2507
2508                 if (pet) mode |= PM_FORCE_PET;
2509                 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2510
2511                 if (summon_specific((pet ? -1 : 0), py, px,
2512                                     dun_level, SUMMON_DEMON, mode))
2513                 {
2514 #ifdef JP
2515                         msg_print("¤¢¤Ê¤¿¤Ï¥Ç¡¼¥â¥ó¤ò°ú¤­´ó¤»¤¿¡ª");
2516 #else
2517                         msg_print("You have attracted a demon!");
2518 #endif
2519
2520                         disturb(0, 1);
2521                 }
2522         }
2523
2524         if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
2525         {
2526                 disturb(0, 1);
2527                 if (one_in_(2))
2528                 {
2529 #ifdef JP
2530                         msg_print("ÀºÎÏŪ¤Ç¤Ê¤¯¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
2531 #else
2532                         msg_print("You feel less energetic.");
2533 #endif
2534
2535                         if (p_ptr->fast > 0)
2536                         {
2537                                 set_fast(0, TRUE);
2538                         }
2539                         else
2540                         {
2541                                 set_slow(randint1(30) + 10, FALSE);
2542                         }
2543                 }
2544                 else
2545                 {
2546 #ifdef JP
2547                         msg_print("ÀºÎÏŪ¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
2548 #else
2549                         msg_print("You feel more energetic.");
2550 #endif
2551
2552                         if (p_ptr->slow > 0)
2553                         {
2554                                 set_slow(0, TRUE);
2555                         }
2556                         else
2557                         {
2558                                 set_fast(randint1(30) + 10, FALSE);
2559                         }
2560                 }
2561                 msg_print(NULL);
2562         }
2563         if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
2564         {
2565                 disturb(0, 1);
2566 #ifdef JP
2567                 msg_print("ÆÍÁ³¤Û¤È¤ó¤É¸ÉÆȤˤʤ俵¤¤¬¤¹¤ë¡£");
2568 #else
2569                 msg_print("You suddenly feel almost lonely.");
2570 #endif
2571
2572                 banish_monsters(100);
2573                 if (!dun_level && p_ptr->town_num)
2574                 {
2575                         int n;
2576
2577                         /* Pick a random shop (except home) */
2578                         do
2579                         {
2580                                 n = randint0(MAX_STORES);
2581                         }
2582                         while ((n == STORE_HOME) || (n == STORE_MUSEUM));
2583
2584 #ifdef JP
2585                         msg_print("Ź¤Î¼ç¿Í¤¬µÖ¤Ë¸þ¤«¤Ã¤ÆÁö¤Ã¤Æ¤¤¤ë¡ª");
2586 #else
2587                         msg_print("You see one of the shopkeepers running for the hills!");
2588 #endif
2589
2590                         store_shuffle(n);
2591                 }
2592                 msg_print(NULL);
2593         }
2594
2595         if ((p_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000))
2596         {
2597                 object_type *o_ptr;
2598
2599 #ifdef JP
2600                 msg_print("±Æ¤Ë¤Ä¤Ä¤Þ¤ì¤¿¡£");
2601 #else
2602                 msg_print("A shadow passes over you.");
2603 #endif
2604
2605                 msg_print(NULL);
2606
2607                 /* Absorb light from the current possition */
2608                 if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
2609                 {
2610                         hp_player(10);
2611                 }
2612
2613                 o_ptr = &inventory[INVEN_LITE];
2614
2615                 /* Absorb some fuel in the current lite */
2616                 if (o_ptr->tval == TV_LITE)
2617                 {
2618                         /* Use some fuel (except on artifacts) */
2619                         if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0))
2620                         {
2621                                 /* Heal the player a bit */
2622                                 hp_player(o_ptr->xtra4 / 20);
2623
2624                                 /* Decrease life-span of lite */
2625                                 o_ptr->xtra4 /= 2;
2626
2627 #ifdef JP
2628                                 msg_print("¸÷¸»¤«¤é¥¨¥Í¥ë¥®¡¼¤òµÛ¼ý¤·¤¿¡ª");
2629 #else
2630                                 msg_print("You absorb energy from your light!");
2631 #endif
2632
2633
2634                                 /* Notice interesting fuel steps */
2635                                 notice_lite_change(o_ptr);
2636                         }
2637                 }
2638
2639                 /*
2640                  * Unlite the area (radius 10) around player and
2641                  * do 50 points damage to every affected monster
2642                  */
2643                 unlite_area(50, 10);
2644         }
2645
2646         if ((p_ptr->muta2 & MUT2_ATT_ANIMAL) &&
2647             !p_ptr->anti_magic && one_in_(7000))
2648         {
2649                 bool pet = one_in_(3);
2650                 u32b mode = PM_ALLOW_GROUP;
2651
2652                 if (pet) mode |= PM_FORCE_PET;
2653                 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2654
2655                 if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_ANIMAL, mode))
2656                 {
2657 #ifdef JP
2658                         msg_print("ưʪ¤ò°ú¤­´ó¤»¤¿¡ª");
2659 #else
2660                         msg_print("You have attracted an animal!");
2661 #endif
2662
2663                         disturb(0, 1);
2664                 }
2665         }
2666
2667         if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
2668             !p_ptr->anti_magic && one_in_(8000))
2669         {
2670                 disturb(0, 1);
2671 #ifdef JP
2672                 msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ëµ¤¤¬¤¹¤ë¡ª");
2673 #else
2674                 msg_print("You feel the world warping around you!");
2675 #endif
2676
2677                 msg_print(NULL);
2678                 fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
2679         }
2680         if ((p_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000))
2681         {
2682                 if (!lose_mutation(0))
2683 #ifdef JP
2684                         msg_print("´ñ̯¤Ê¤¯¤é¤¤ÉáÄ̤ˤʤ俵¤¤¬¤¹¤ë¡£");
2685 #else
2686                 msg_print("You feel oddly normal.");
2687 #endif
2688
2689         }
2690         if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
2691         {
2692                 disturb(0, 1);
2693 #ifdef JP
2694                 msg_print("Èóʪ¼Á²½¤·¤¿¡ª");
2695 #else
2696                 msg_print("You feel insubstantial!");
2697 #endif
2698
2699                 msg_print(NULL);
2700                 set_wraith_form(randint1(p_ptr->lev / 2) + (p_ptr->lev / 2), FALSE);
2701         }
2702         if ((p_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000))
2703         {
2704                 do_poly_wounds();
2705         }
2706         if ((p_ptr->muta2 & MUT2_WASTING) && one_in_(3000))
2707         {
2708                 int which_stat = randint0(6);
2709                 int sustained = FALSE;
2710
2711                 switch (which_stat)
2712                 {
2713                 case A_STR:
2714                         if (p_ptr->sustain_str) sustained = TRUE;
2715                         break;
2716                 case A_INT:
2717                         if (p_ptr->sustain_int) sustained = TRUE;
2718                         break;
2719                 case A_WIS:
2720                         if (p_ptr->sustain_wis) sustained = TRUE;
2721                         break;
2722                 case A_DEX:
2723                         if (p_ptr->sustain_dex) sustained = TRUE;
2724                         break;
2725                 case A_CON:
2726                         if (p_ptr->sustain_con) sustained = TRUE;
2727                         break;
2728                 case A_CHR:
2729                         if (p_ptr->sustain_chr) sustained = TRUE;
2730                         break;
2731                 default:
2732 #ifdef JP
2733                         msg_print("ÉÔÀµ¤Ê¾õÂÖ¡ª");
2734 #else
2735                         msg_print("Invalid stat chosen!");
2736 #endif
2737
2738                         sustained = TRUE;
2739                 }
2740
2741                 if (!sustained)
2742                 {
2743                         disturb(0, 1);
2744 #ifdef JP
2745                         msg_print("¼«Ê¬¤¬¿ê¼å¤·¤Æ¤¤¤¯¤Î¤¬Ê¬¤«¤ë¡ª");
2746 #else
2747                         msg_print("You can feel yourself wasting away!");
2748 #endif
2749
2750                         msg_print(NULL);
2751                         (void)dec_stat(which_stat, randint1(6) + 6, one_in_(3));
2752                 }
2753         }
2754         if ((p_ptr->muta2 & MUT2_ATT_DRAGON) &&
2755             !p_ptr->anti_magic && one_in_(3000))
2756         {
2757                 bool pet = one_in_(5);
2758                 u32b mode = PM_ALLOW_GROUP;
2759
2760                 if (pet) mode |= PM_FORCE_PET;
2761                 else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2762
2763                 if (summon_specific((pet ? -1 : 0), py, px, dun_level, SUMMON_DRAGON, mode))
2764                 {
2765 #ifdef JP
2766                         msg_print("¥É¥é¥´¥ó¤ò°ú¤­´ó¤»¤¿¡ª");
2767 #else
2768                         msg_print("You have attracted a dragon!");
2769 #endif
2770
2771                         disturb(0, 1);
2772                 }
2773         }
2774         if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
2775             one_in_(3000))
2776         {
2777                 if (p_ptr->tim_esp > 0)
2778                 {
2779 #ifdef JP
2780                         msg_print("Àº¿À¤Ë¤â¤ä¤¬¤«¤«¤Ã¤¿¡ª");
2781 #else
2782                         msg_print("Your mind feels cloudy!");
2783 #endif
2784
2785                         set_tim_esp(0, TRUE);
2786                 }
2787                 else
2788                 {
2789 #ifdef JP
2790                         msg_print("Àº¿À¤¬¹­¤¬¤Ã¤¿¡ª");
2791 #else
2792                         msg_print("Your mind expands!");
2793 #endif
2794
2795                         set_tim_esp(p_ptr->lev, FALSE);
2796                 }
2797         }
2798         if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
2799             one_in_(9000))
2800         {
2801                 disturb(0, 1);
2802 #ifdef JP
2803                 msg_print("°ß¤¬áÛÚ»¤·¡¢¿©»ö¤ò¼º¤Ã¤¿¡ª");
2804 #else
2805                 msg_print("Your stomach roils, and you lose your lunch!");
2806 #endif
2807
2808                 msg_print(NULL);
2809                 set_food(PY_FOOD_WEAK);
2810                 if (music_singing_any()) stop_singing();
2811                 if (hex_spelling_any()) stop_hex_spell_all();
2812         }
2813
2814         if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
2815             !p_ptr->anti_magic && one_in_(12000) && !p_ptr->inside_arena)
2816         {
2817                 alter_reality();
2818         }
2819
2820         if ((p_ptr->muta2 & MUT2_WARNING) && one_in_(1000))
2821         {
2822                 int danger_amount = 0;
2823                 int monster;
2824
2825                 for (monster = 0; monster < m_max; monster++)
2826                 {
2827                         monster_type    *m_ptr = &m_list[monster];
2828                         monster_race    *r_ptr = &r_info[m_ptr->r_idx];
2829
2830                         /* Paranoia -- Skip dead monsters */
2831                         if (!m_ptr->r_idx) continue;
2832
2833                         if (r_ptr->level >= p_ptr->lev)
2834                         {
2835                                 danger_amount += r_ptr->level - p_ptr->lev + 1;
2836                         }
2837                 }
2838
2839                 if (danger_amount > 100)
2840 #ifdef JP
2841                         msg_print("Èó¾ï¤Ë¶²¤í¤·¤¤µ¤¤¬¤¹¤ë¡ª");
2842 #else
2843                 msg_print("You feel utterly terrified!");
2844 #endif
2845
2846                 else if (danger_amount > 50)
2847 #ifdef JP
2848                         msg_print("¶²¤í¤·¤¤µ¤¤¬¤¹¤ë¡ª");
2849 #else
2850                 msg_print("You feel terrified!");
2851 #endif
2852
2853                 else if (danger_amount > 20)
2854 #ifdef JP
2855                         msg_print("Èó¾ï¤Ë¿´Çۤʵ¤¤¬¤¹¤ë¡ª");
2856 #else
2857                 msg_print("You feel very worried!");
2858 #endif
2859
2860                 else if (danger_amount > 10)
2861 #ifdef JP
2862                         msg_print("¿´Çۤʵ¤¤¬¤¹¤ë¡ª");
2863 #else
2864                 msg_print("You feel paranoid!");
2865 #endif
2866
2867                 else if (danger_amount > 5)
2868 #ifdef JP
2869                         msg_print("¤Û¤È¤ó¤É°ÂÁ´¤Êµ¤¤¬¤¹¤ë¡£");
2870 #else
2871                 msg_print("You feel almost safe.");
2872 #endif
2873
2874                 else
2875 #ifdef JP
2876                         msg_print("¼ä¤·¤¤µ¤¤¬¤¹¤ë¡£");
2877 #else
2878                 msg_print("You feel lonely.");
2879 #endif
2880
2881         }
2882         if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
2883             one_in_(5000))
2884         {
2885                 disturb(0, 1);
2886 #ifdef JP
2887                 msg_print("̵Ũ¤Êµ¤¤¬¤¹¤ë¡ª");
2888 #else
2889                 msg_print("You feel invincible!");
2890 #endif
2891
2892                 msg_print(NULL);
2893                 (void)set_invuln(randint1(8) + 8, FALSE);
2894         }
2895         if ((p_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000))
2896         {
2897                 int wounds = p_ptr->mhp - p_ptr->chp;
2898
2899                 if (wounds > 0)
2900                 {
2901                         int healing = p_ptr->csp;
2902
2903                         if (healing > wounds)
2904                         {
2905                                 healing = wounds;
2906                         }
2907
2908                         hp_player(healing);
2909                         p_ptr->csp -= healing;
2910
2911                         /* Redraw mana */
2912                         p_ptr->redraw |= (PR_MANA);
2913                 }
2914         }
2915         if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
2916             one_in_(4000))
2917         {
2918                 int wounds = p_ptr->msp - p_ptr->csp;
2919
2920                 if (wounds > 0)
2921                 {
2922                         int healing = p_ptr->chp;
2923
2924                         if (healing > wounds)
2925                         {
2926                                 healing = wounds;
2927                         }
2928
2929                         p_ptr->csp += healing;
2930
2931                         /* Redraw mana */
2932                         p_ptr->redraw |= (PR_MANA);
2933 #ifdef JP
2934                         take_hit(DAMAGE_LOSELIFE, healing, "Ƭ¤Ë¾º¤Ã¤¿·ì", -1);
2935 #else
2936                         take_hit(DAMAGE_LOSELIFE, healing, "blood rushing to the head", -1);
2937 #endif
2938
2939                 }
2940         }
2941         if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
2942         {
2943                 int slot = 0;
2944                 object_type *o_ptr = NULL;
2945
2946                 disturb(0, 1);
2947 #ifdef JP
2948                 msg_print("­¤¬¤â¤Ä¤ì¤Æž¤ó¤À¡ª");
2949                 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), "žÅÝ", -1);
2950 #else
2951                 msg_print("You trip over your own feet!");
2952                 take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), "tripping", -1);
2953 #endif
2954
2955                 msg_print(NULL);
2956                 if (buki_motteruka(INVEN_RARM))
2957                 {
2958                         slot = INVEN_RARM;
2959                         o_ptr = &inventory[INVEN_RARM];
2960
2961                         if (buki_motteruka(INVEN_LARM) && one_in_(2))
2962                         {
2963                                 o_ptr = &inventory[INVEN_LARM];
2964                                 slot = INVEN_LARM;
2965                         }
2966                 }
2967                 else if (buki_motteruka(INVEN_LARM))
2968                 {
2969                         o_ptr = &inventory[INVEN_LARM];
2970                         slot = INVEN_LARM;
2971                 }
2972
2973                 if (slot && !object_is_cursed(o_ptr))
2974                 {
2975 #ifdef JP
2976                         msg_print("Éð´ï¤òÍî¤È¤·¤Æ¤·¤Þ¤Ã¤¿¡ª");
2977 #else
2978                         msg_print("You drop your weapon!");
2979 #endif
2980                         inven_drop(slot, 1);
2981                 }
2982         }
2983 }
2984
2985 /*!
2986  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ë¤´¤È¤ËÁõÈ÷¸ú²Ì¤ÎȯưȽÄê¤ò¹Ô¤¦½èÍý
2987  * / Handle curse effects once every 10 game turns
2988  * @return ¤Ê¤·
2989  */
2990 static void process_world_aux_curse(void)
2991 {
2992         if ((p_ptr->cursed & TRC_P_FLAG_MASK) && !p_ptr->inside_battle && !p_ptr->wild_mode)
2993         {
2994                 /*
2995                  * Hack: Uncursed teleporting items (e.g. Trump Weapons)
2996                  * can actually be useful!
2997                  */
2998                 if ((p_ptr->cursed & TRC_TELEPORT_SELF) && one_in_(200))
2999                 {
3000                         char o_name[MAX_NLEN];
3001                         object_type *o_ptr;
3002                         int i, i_keep = 0, count = 0;
3003
3004                         /* Scan the equipment with random teleport ability */
3005                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3006                         {
3007                                 u32b flgs[TR_FLAG_SIZE];
3008                                 o_ptr = &inventory[i];
3009
3010                                 /* Skip non-objects */
3011                                 if (!o_ptr->k_idx) continue;
3012
3013                                 /* Extract the item flags */
3014                                 object_flags(o_ptr, flgs);
3015
3016                                 if (have_flag(flgs, TR_TELEPORT))
3017                                 {
3018                                         /* {.} will stop random teleportation. */
3019                                         if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
3020                                         {
3021                                                 count++;
3022                                                 if (one_in_(count)) i_keep = i;
3023                                         }
3024                                 }
3025                         }
3026
3027                         o_ptr = &inventory[i_keep];
3028                         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3029
3030 #ifdef JP
3031                         msg_format("%s¤¬¥Æ¥ì¥Ý¡¼¥È¤ÎǽÎϤòȯư¤µ¤»¤è¤¦¤È¤·¤Æ¤¤¤ë¡£", o_name);
3032 #else
3033                         msg_format("Your %s is activating teleportation.", o_name);
3034 #endif
3035
3036 #ifdef JP
3037                         if (get_check_strict("¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
3038 #else
3039                         if (get_check_strict("Teleport? ", CHECK_OKAY_CANCEL))
3040 #endif
3041                         {
3042                                 disturb(0, 1);
3043                                 teleport_player(50, 0L);
3044                         }
3045                         else
3046                         {
3047 #ifdef JP
3048                                 msg_format("%s¤Ë{.}(¥Ô¥ê¥ª¥É)¤ÈÌäò¹ï¤à¤Èȯư¤òÍÞÀ©¤Ç¤­¤Þ¤¹¡£", o_name);
3049 #else
3050                                 msg_format("You can inscribe {.} on your %s to disable random teleportation. ", o_name);
3051 #endif
3052                                 disturb(1, 1);
3053                         }
3054                 }
3055                 /* Make a chainsword noise */
3056                 if ((p_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE))
3057                 {
3058                         char noise[1024];
3059                         if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, noise))
3060                                 msg_print(noise);
3061                         disturb(FALSE, FALSE);
3062                 }
3063                 /* TY Curse */
3064                 if ((p_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE))
3065                 {
3066                         int count = 0;
3067                         (void)activate_ty_curse(FALSE, &count);
3068                 }
3069                 /* Handle experience draining */
3070                 if (p_ptr->prace != RACE_ANDROID && 
3071                         ((p_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4)))
3072                 {
3073                         p_ptr->exp -= (p_ptr->lev+1)/2;
3074                         if (p_ptr->exp < 0) p_ptr->exp = 0;
3075                         p_ptr->max_exp -= (p_ptr->lev+1)/2;
3076                         if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
3077                         check_experience();
3078                 }
3079                 /* Add light curse (Later) */
3080                 if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
3081                 {
3082                         u32b new_curse;
3083                         object_type *o_ptr;
3084
3085                         o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
3086
3087                         new_curse = get_curse(0, o_ptr);
3088                         if (!(o_ptr->curse_flags & new_curse))
3089                         {
3090                                 char o_name[MAX_NLEN];
3091
3092                                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3093
3094                                 o_ptr->curse_flags |= new_curse;
3095                                 msg_format(_("°­°Õ¤ËËþ¤Á¤¿¹õ¤¤¥ª¡¼¥é¤¬%s¤ò¤È¤ê¤Þ¤¤¤¿...", "There is a malignant black aura surrounding your %s..."), o_name);
3096
3097                                 o_ptr->feeling = FEEL_NONE;
3098
3099                                 p_ptr->update |= (PU_BONUS);
3100                         }
3101                 }
3102                 /* Add heavy curse (Later) */
3103                 if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
3104                 {
3105                         u32b new_curse;
3106                         object_type *o_ptr;
3107
3108                         o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
3109
3110                         new_curse = get_curse(1, o_ptr);
3111                         if (!(o_ptr->curse_flags & new_curse))
3112                         {
3113                                 char o_name[MAX_NLEN];
3114
3115                                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3116
3117                                 o_ptr->curse_flags |= new_curse;
3118                                 msg_format(_("°­°Õ¤ËËþ¤Á¤¿¹õ¤¤¥ª¡¼¥é¤¬%s¤ò¤È¤ê¤Þ¤¤¤¿...", "There is a malignant black aura surrounding your %s..."), o_name);
3119                                 o_ptr->feeling = FEEL_NONE;
3120
3121                                 p_ptr->update |= (PU_BONUS);
3122                         }
3123                 }
3124                 /* Call animal */
3125                 if ((p_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500))
3126                 {
3127                         if (summon_specific(0, py, px, dun_level, SUMMON_ANIMAL,
3128                             (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
3129                         {
3130                                 char o_name[MAX_NLEN];
3131
3132                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY));
3133                                 msg_format(_("%s¤¬Æ°Êª¤ò°ú¤­´ó¤»¤¿¡ª", "Your %s have attracted an animal!"), o_name);
3134                                 disturb(0, 1);
3135                         }
3136                 }
3137                 /* Call demon */
3138                 if ((p_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111))
3139                 {
3140                         if (summon_specific(0, py, px, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
3141                         {
3142                                 char o_name[MAX_NLEN];
3143
3144                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
3145                                 msg_format(_("%s¤¬°­Ëâ¤ò°ú¤­´ó¤»¤¿¡ª", "Your %s have attracted a demon!"), o_name);
3146                                 disturb(0, 1);
3147                         }
3148                 }
3149                 /* Call dragon */
3150                 if ((p_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800))
3151                 {
3152                         if (summon_specific(0, py, px, dun_level, SUMMON_DRAGON,
3153                             (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
3154                         {
3155                                 char o_name[MAX_NLEN];
3156
3157                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY));
3158                                 msg_format(_("%s¤¬¥É¥é¥´¥ó¤ò°ú¤­´ó¤»¤¿¡ª", "Your %s have attracted an dragon!"), o_name);
3159                                 disturb(0, 1);
3160                         }
3161                 }
3162                 /* Call undead */
3163                 if ((p_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111))
3164                 {
3165                         if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD,
3166                             (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
3167                         {
3168                                 char o_name[MAX_NLEN];
3169
3170                                 object_desc(o_name, choose_cursed_obj_name(TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY));
3171                                 msg_format(_("%s¤¬»àÎî¤ò°ú¤­´ó¤»¤¿¡ª", "Your %s have attracted an undead!"), o_name);
3172                                 disturb(0, 1);
3173                         }
3174                 }
3175                 if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
3176                 {
3177                         if (!p_ptr->resist_fear)
3178                         {
3179                                 disturb(0, 1);
3180                                 msg_print(_("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª", "It's so dark... so scary!"));
3181                                 set_afraid(p_ptr->afraid + 13 + randint1(26));
3182                         }
3183                 }
3184                 /* Teleport player */
3185                 if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
3186                 {
3187                         disturb(0, 1);
3188
3189                         /* Teleport player */
3190                         teleport_player(40, TELEPORT_PASSIVE);
3191                 }
3192                 /* Handle HP draining */
3193                 if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
3194                 {
3195                         char o_name[MAX_NLEN];
3196
3197                         object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
3198                         msg_format(_("%s¤Ï¤¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª", "Your %s drains HP from you!"), o_name);
3199                         take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
3200                 }
3201                 /* Handle mana draining */
3202                 if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
3203                 {
3204                         char o_name[MAX_NLEN];
3205
3206                         object_desc(o_name, choose_cursed_obj_name(TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
3207                         msg_format(_("%s¤Ï¤¢¤Ê¤¿¤ÎËâÎϤòµÛ¼ý¤·¤¿¡ª", "Your %s drains mana from you!"), o_name);
3208                         p_ptr->csp -= MIN(p_ptr->lev, 50);
3209                         if (p_ptr->csp < 0)
3210                         {
3211                                 p_ptr->csp = 0;
3212                                 p_ptr->csp_frac = 0;
3213                         }
3214                         p_ptr->redraw |= PR_MANA;
3215                 }
3216         }
3217
3218         /* Rarely, take damage from the Jewel of Judgement */
3219         if (one_in_(999) && !p_ptr->anti_magic)
3220         {
3221                 object_type *o_ptr = &inventory[INVEN_LITE];
3222
3223                 if (o_ptr->name1 == ART_JUDGE)
3224                 {
3225 #ifdef JP
3226                         if (object_is_known(o_ptr))
3227                                 msg_print("¡Ø¿³È½¤ÎÊõÀС٤Ϥ¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª");
3228                         else
3229                                 msg_print("¤Ê¤Ë¤«¤¬¤¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¼ý¤·¤¿¡ª");
3230                         take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "¿³È½¤ÎÊõÀÐ", -1);
3231 #else
3232                         if (object_is_known(o_ptr))
3233                                 msg_print("The Jewel of Judgement drains life from you!");
3234                         else
3235                                 msg_print("Something drains life from you!");
3236                         take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
3237 #endif
3238                 }
3239         }
3240 }
3241
3242
3243 /*!
3244  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ë¤´¤È¤ËËâÆ»¶ñ¤Î¼«Á³½¼Å¶¤ò¹Ô¤¦½èÍý
3245  * / Handle recharging objects once every 10 game turns
3246  * @return ¤Ê¤·
3247  */
3248 static void process_world_aux_recharge(void)
3249 {
3250         int i;
3251         bool changed;
3252
3253         /* Process equipment */
3254         for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
3255         {
3256                 /* Get the object */
3257                 object_type *o_ptr = &inventory[i];
3258
3259                 /* Skip non-objects */
3260                 if (!o_ptr->k_idx) continue;
3261
3262                 /* Recharge activatable objects */
3263                 if (o_ptr->timeout > 0)
3264                 {
3265                         /* Recharge */
3266                         o_ptr->timeout--;
3267
3268                         /* Notice changes */
3269                         if (!o_ptr->timeout)
3270                         {
3271                                 recharged_notice(o_ptr);
3272                                 changed = TRUE;
3273                         }
3274                 }
3275         }
3276
3277         /* Notice changes */
3278         if (changed)
3279         {
3280                 /* Window stuff */
3281                 p_ptr->window |= (PW_EQUIP);
3282                 wild_regen = 20;
3283         }
3284
3285         /*
3286          * Recharge rods.  Rods now use timeout to control charging status,
3287          * and each charging rod in a stack decreases the stack's timeout by
3288          * one per turn. -LM-
3289          */
3290         for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
3291         {
3292                 object_type *o_ptr = &inventory[i];
3293                 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3294
3295                 /* Skip non-objects */
3296                 if (!o_ptr->k_idx) continue;
3297
3298                 /* Examine all charging rods or stacks of charging rods. */
3299                 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3300                 {
3301                         /* Determine how many rods are charging. */
3302                         int temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
3303                         if (temp > o_ptr->number) temp = o_ptr->number;
3304
3305                         /* Decrease timeout by that number. */
3306                         o_ptr->timeout -= temp;
3307
3308                         /* Boundary control. */
3309                         if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3310
3311                         /* Notice changes, provide message if object is inscribed. */
3312                         if (!(o_ptr->timeout))
3313                         {
3314                                 recharged_notice(o_ptr);
3315                                 changed = TRUE;
3316                         }
3317
3318                         /* One of the stack of rod is charged */
3319                         else if (o_ptr->timeout % k_ptr->pval)
3320                         {
3321                                 changed = TRUE;
3322                         }
3323                 }
3324         }
3325
3326         /* Notice changes */
3327         if (changed)
3328         {
3329                 /* Window stuff */
3330                 p_ptr->window |= (PW_INVEN);
3331                 wild_regen = 20;
3332         }
3333
3334         /* Process objects on floor */
3335         for (i = 1; i < o_max; i++)
3336         {
3337                 /* Access object */
3338                 object_type *o_ptr = &o_list[i];
3339
3340                 /* Skip dead objects */
3341                 if (!o_ptr->k_idx) continue;
3342
3343                 /* Recharge rods on the ground.  No messages. */
3344                 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
3345                 {
3346                         /* Charge it */
3347                         o_ptr->timeout -= o_ptr->number;
3348
3349                         /* Boundary control. */
3350                         if (o_ptr->timeout < 0) o_ptr->timeout = 0;
3351                 }
3352         }
3353 }
3354
3355
3356 /*!
3357  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ë¤´¤È¤Ëµ¢´Ô¤ä¸½¼ÂÊÑÍƤʤɤλĤê»þ´Ö¥«¥¦¥ó¥È¥À¥¦¥ó¤Èȯư¤ò½èÍý¤¹¤ë¡£
3358  * / Handle involuntary movement once every 10 game turns
3359  * @return ¤Ê¤·
3360  */
3361 static void process_world_aux_movement(void)
3362 {
3363         /* Delayed Word-of-Recall */
3364         if (p_ptr->word_recall)
3365         {
3366                 /*
3367                  * HACK: Autosave BEFORE resetting the recall counter (rr9)
3368                  * The player is yanked up/down as soon as
3369                  * he loads the autosaved game.
3370                  */
3371                 if (autosave_l && (p_ptr->word_recall == 1) && !p_ptr->inside_battle)
3372                         do_cmd_save_game(TRUE);
3373
3374                 /* Count down towards recall */
3375                 p_ptr->word_recall--;
3376
3377                 p_ptr->redraw |= (PR_STATUS);
3378
3379                 /* Activate the recall */
3380                 if (!p_ptr->word_recall)
3381                 {
3382                         /* Disturbing! */
3383                         disturb(0, 1);
3384
3385                         /* Determine the level */
3386                         if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
3387                         {
3388                                 msg_print(_("¾å¤Ë°ú¤ÃÄ¥¤ê¤¢¤²¤é¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª",
3389                                                         "You feel yourself yanked upwards!"));
3390
3391                                 if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
3392                                 if (record_stair)
3393                                         do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3394
3395                                 dun_level = 0;
3396                                 dungeon_type = 0;
3397
3398                                 leave_quest_check();
3399                                 leave_tower_check();
3400
3401                                 p_ptr->inside_quest = 0;
3402
3403                                 p_ptr->leaving = TRUE;
3404                         }
3405                         else
3406                         {
3407                                 msg_print(_("²¼¤Ë°ú¤­¤º¤ê¹ß¤í¤µ¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª",
3408                                                         "You feel yourself yanked downwards!"));
3409
3410                                 dungeon_type = p_ptr->recall_dungeon;
3411
3412                                 if (record_stair)
3413                                         do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
3414
3415                                 /* New depth */
3416                                 dun_level = max_dlv[dungeon_type];
3417                                 if (dun_level < 1) dun_level = 1;
3418
3419                                 /* Nightmare mode makes recall more dangerous */
3420                                 if (ironman_nightmare && !randint0(666) && (dungeon_type == DUNGEON_ANGBAND))
3421                                 {
3422                                         if (dun_level < 50)
3423                                         {
3424                                                 dun_level *= 2;
3425                                         }
3426                                         else if (dun_level < 99)
3427                                         {
3428                                                 dun_level = (dun_level + 99) / 2;
3429                                         }
3430                                         else if (dun_level > 100)
3431                                         {
3432                                                 dun_level = d_info[dungeon_type].maxdepth - 1;
3433                                         }
3434                                 }
3435
3436                                 if (p_ptr->wild_mode)
3437                                 {
3438                                         p_ptr->wilderness_y = py;
3439                                         p_ptr->wilderness_x = px;
3440                                 }
3441                                 else
3442                                 {
3443                                         /* Save player position */
3444                                         p_ptr->oldpx = px;
3445                                         p_ptr->oldpy = py;
3446                                 }
3447                                 p_ptr->wild_mode = FALSE;
3448
3449                                 /*
3450                                  * Clear all saved floors
3451                                  * and create a first saved floor
3452                                  */
3453                                 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3454
3455                                 /* Leaving */
3456                                 p_ptr->leaving = TRUE;
3457
3458                                 if (dungeon_type == DUNGEON_ANGBAND)
3459                                 {
3460                                         int i;
3461
3462                                         for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
3463                                         {
3464                                                 quest_type* const q_ptr = &quest[i];
3465
3466                                                 
3467                                                 if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
3468                                                     (q_ptr->status == QUEST_STATUS_TAKEN) &&
3469                                                     (q_ptr->level < dun_level))
3470                                                 {
3471                                                         q_ptr->status = QUEST_STATUS_FAILED;
3472                                                         q_ptr->complev = (byte)p_ptr->lev;
3473                                                         update_playtime();
3474                                                         q_ptr->comptime = playtime;
3475                                                         r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
3476                                                 }
3477                                         }
3478                                 }
3479                         }
3480
3481                         /* Sound */
3482                         sound(SOUND_TPLEVEL);
3483                 }
3484         }
3485
3486
3487         /* Delayed Alter reality */
3488         if (p_ptr->alter_reality)
3489         {
3490                 if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
3491                         do_cmd_save_game(TRUE);
3492
3493                 /* Count down towards alter */
3494                 p_ptr->alter_reality--;
3495
3496                 p_ptr->redraw |= (PR_STATUS);
3497
3498                 /* Activate the alter reality */
3499                 if (!p_ptr->alter_reality)
3500                 {
3501                         /* Disturbing! */
3502                         disturb(0, 1);
3503
3504                         /* Determine the level */
3505                         if (!quest_number(dun_level) && dun_level)
3506                         {
3507 #ifdef JP
3508                                 msg_print("À¤³¦¤¬ÊѤï¤Ã¤¿¡ª");
3509 #else
3510                                 msg_print("The world changes!");
3511 #endif
3512
3513                                 /*
3514                                  * Clear all saved floors
3515                                  * and create a first saved floor
3516                                  */
3517                                 prepare_change_floor_mode(CFM_FIRST_FLOOR);
3518
3519                                 /* Leaving */
3520                                 p_ptr->leaving = TRUE;
3521                         }
3522                         else
3523                         {
3524 #ifdef JP
3525                                 msg_print("À¤³¦¤¬¾¯¤·¤Î´ÖÊѲ½¤·¤¿¤è¤¦¤À¡£");
3526 #else
3527                                 msg_print("The world seems to change for a moment!");
3528 #endif
3529                         }
3530
3531                         /* Sound */
3532                         sound(SOUND_TPLEVEL);
3533                 }
3534         }
3535 }
3536
3537
3538 /*!
3539  * @brief »ØÄꤷ¤¿¥â¥ó¥¹¥¿¡¼¤ËÎÙÀܤ·¤Æ¤¤¤ë¥â¥ó¥¹¥¿¡¼¤Î¿ô¤òÊÖ¤¹¡£
3540  * / Count number of adjacent monsters
3541  * @param m_idx ÎÙÀÜ¿ô¤òÄ´¤Ù¤¿¤¤¥â¥ó¥¹¥¿¡¼¤ÎID
3542  * @return ÎÙÀܤ·¤Æ¤¤¤ë¥â¥ó¥¹¥¿¡¼¤Î¿ô
3543  */
3544 static int get_monster_crowd_number(int m_idx)
3545 {
3546         monster_type *m_ptr = &m_list[m_idx];
3547         int my = m_ptr->fy;
3548         int mx = m_ptr->fx;
3549         int i;
3550         int count = 0;
3551
3552         for (i = 0; i < 7; i++)
3553         {
3554                 int ay = my + ddy_ddd[i];
3555                 int ax = mx + ddx_ddd[i];
3556
3557                 if (!in_bounds(ay, ax)) continue;
3558
3559                 /* Count number of monsters */
3560                 if (cave[ay][ax].m_idx > 0) count++;
3561         }
3562
3563         return count;
3564 }
3565
3566
3567
3568 /*!
3569  * ¥À¥ó¥¸¥ç¥ó¤ÎÊ·°Ïµ¤¤ò·×»»¤¹¤ë¤¿¤á¤ÎÈóÀþ·Á´ð½àÃÍ / Dungeon rating is no longer linear
3570  */
3571 #define RATING_BOOST(delta) (delta * delta + 50 * delta)
3572
3573 /*!
3574  * @brief ¥À¥ó¥¸¥ç¥ó¤ÎÊ·°Ïµ¤¤ò»»½Ð¤¹¤ë¡£
3575  * / Examine all monsters and unidentified objects, and get the feeling of current dungeon floor
3576  * @return »»½Ð¤µ¤ì¤¿¥À¥ó¥¸¥ç¥ó¤ÎÊ·°Ïµ¤¥é¥ó¥¯
3577  */
3578 static byte get_dungeon_feeling(void)
3579 {
3580         const int base = 10;
3581         int rating = 0;
3582         int i;
3583
3584         /* Hack -- no feeling in the town */
3585         if (!dun_level) return 0;
3586
3587         /* Examine each monster */
3588         for (i = 1; i < m_max; i++)
3589         {
3590                 monster_type *m_ptr = &m_list[i];
3591                 monster_race *r_ptr;
3592                 int delta = 0;
3593
3594                 /* Skip dead monsters */
3595                 if (!m_ptr->r_idx) continue;
3596
3597                 /* Ignore pet */
3598                 if (is_pet(m_ptr)) continue;
3599
3600                 r_ptr = &r_info[m_ptr->r_idx];
3601
3602                 /* Unique monsters */
3603                 if (r_ptr->flags1 & (RF1_UNIQUE))
3604                 {
3605                         /* Nearly out-of-depth unique monsters */
3606                         if (r_ptr->level + 10 > dun_level)
3607                         {
3608                                 /* Boost rating by twice delta-depth */
3609                                 delta += (r_ptr->level + 10 - dun_level) * 2 * base;
3610                         }
3611                 }
3612                 else
3613                 {
3614                         /* Out-of-depth monsters */
3615                         if (r_ptr->level > dun_level)
3616                         {
3617                                 /* Boost rating by delta-depth */
3618                                 delta += (r_ptr->level - dun_level) * base;
3619                         }
3620                 }
3621
3622                 /* Unusually crowded monsters get a little bit of rating boost */
3623                 if (r_ptr->flags1 & RF1_FRIENDS)
3624                 {
3625                         if (5 <= get_monster_crowd_number(i)) delta += 1;
3626                 }
3627                 else
3628                 {
3629                         if (2 <= get_monster_crowd_number(i)) delta += 1;
3630                 }
3631
3632
3633                 rating += RATING_BOOST(delta);
3634         }
3635
3636         /* Examine each unidentified object */
3637         for (i = 1; i < o_max; i++)
3638         {
3639                 object_type *o_ptr = &o_list[i];
3640                 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3641                 int delta = 0;
3642
3643                 /* Skip dead objects */
3644                 if (!o_ptr->k_idx) continue;
3645
3646                 /* Skip known objects */
3647                 if (object_is_known(o_ptr))
3648                 {
3649                         /* Touched? */
3650                         if (o_ptr->marked & OM_TOUCHED) continue;
3651                 }
3652
3653                 /* Skip pseudo-known objects */
3654                 if (o_ptr->ident & IDENT_SENSE) continue;
3655
3656                 /* Ego objects */
3657                 if (object_is_ego(o_ptr))
3658                 {
3659                         ego_item_type *e_ptr = &e_info[o_ptr->name2];
3660
3661                         delta += e_ptr->rating * base;
3662                 }
3663
3664                 /* Artifacts */
3665                 if (object_is_artifact(o_ptr))
3666                 {
3667                         s32b cost = object_value_real(o_ptr);
3668
3669                         delta += 10 * base;
3670                         if (cost > 10000L) delta += 10 * base;
3671                         if (cost > 50000L) delta += 10 * base;
3672                         if (cost > 100000L) delta += 10 * base;
3673
3674                         /* Special feeling */
3675                         if (!preserve_mode) return 1;
3676                 }
3677
3678                 if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
3679                 if (o_ptr->tval == TV_SHIELD &&
3680                     o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
3681                 if (o_ptr->tval == TV_GLOVES &&
3682                     o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
3683                 if (o_ptr->tval == TV_BOOTS &&
3684                     o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
3685                 if (o_ptr->tval == TV_HELM &&
3686                     o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
3687                 if (o_ptr->tval == TV_RING &&
3688                     o_ptr->sval == SV_RING_SPEED &&
3689                     !object_is_cursed(o_ptr)) delta += 25 * base;
3690                 if (o_ptr->tval == TV_RING &&
3691                     o_ptr->sval == SV_RING_LORDLY &&
3692                     !object_is_cursed(o_ptr)) delta += 15 * base;
3693                 if (o_ptr->tval == TV_AMULET &&
3694                     o_ptr->sval == SV_AMULET_THE_MAGI &&
3695                     !object_is_cursed(o_ptr)) delta += 15 * base;
3696
3697                 /* Out-of-depth objects */
3698                 if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
3699                     k_ptr->level > dun_level)
3700                 {
3701                         /* Rating increase */
3702                         delta += (k_ptr->level - dun_level) * base;
3703                 }
3704
3705                 rating += RATING_BOOST(delta);
3706         }
3707
3708
3709         if (rating > RATING_BOOST(1000)) return 2;
3710         if (rating > RATING_BOOST(800)) return 3;
3711         if (rating > RATING_BOOST(600)) return 4;
3712         if (rating > RATING_BOOST(400)) return 5;
3713         if (rating > RATING_BOOST(300)) return 6;
3714         if (rating > RATING_BOOST(200)) return 7;
3715         if (rating > RATING_BOOST(100)) return 8;
3716         if (rating > RATING_BOOST(0)) return 9;
3717
3718         return 10;
3719 }
3720
3721 /*!
3722  * @brief ¥À¥ó¥¸¥ç¥ó¤ÎÊ·°Ïµ¤¤ò¹¹¿·¤·¡¢ÊѲ½¤¬¤¢¤Ã¤¿¾ì¹ç¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë
3723  * / Update dungeon feeling, and announce it if changed
3724  * @return ¤Ê¤·
3725  */
3726 static void update_dungeon_feeling(void)
3727 {
3728         byte new_feeling;
3729         int quest_num;
3730         int delay;
3731
3732         /* No feeling on the surface */
3733         if (!dun_level) return;
3734
3735         /* No feeling in the arena */
3736         if (p_ptr->inside_battle) return;
3737
3738         /* Extract delay time */
3739         delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
3740
3741         /* Not yet felt anything */
3742         if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
3743
3744         /* Extract quest number (if any) */
3745         quest_num = quest_number(dun_level);
3746
3747         /* No feeling in a quest */
3748         if (quest_num &&
3749             (is_fixed_quest_idx(quest_num) &&
3750              !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
3751                !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
3752
3753
3754         /* Get new dungeon feeling */
3755         new_feeling = get_dungeon_feeling();
3756
3757         /* Remember last time updated */
3758         p_ptr->feeling_turn = turn;
3759
3760         /* No change */
3761         if (p_ptr->feeling == new_feeling) return;
3762
3763         /* Dungeon feeling is changed */
3764         p_ptr->feeling = new_feeling;
3765
3766         /* Announce feeling */
3767         do_cmd_feeling();
3768
3769         select_floor_music();
3770
3771         /* Update the level indicator */
3772         p_ptr->redraw |= (PR_DEPTH);
3773
3774         /* Disturb */
3775         if (disturb_minor) disturb(0, 0);
3776 }
3777
3778 /*!
3779  * @brief 10¥²¡¼¥à¥¿¡¼¥ó¤¬¿Ê¹Ô¤¹¤ëËè¤Ë¥²¡¼¥àÀ¤³¦Á´ÂΤνèÍý¤ò¹Ô¤¦¡£
3780  * / Handle certain things once every 10 game turns
3781  * @return ¤Ê¤·
3782  */
3783 static void process_world(void)
3784 {
3785         int day, hour, min;
3786
3787         const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
3788         s32b prev_turn_in_today = ((turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY;
3789         int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60;
3790         
3791         extract_day_hour_min(&day, &hour, &min);
3792
3793         /* Update dungeon feeling, and announce it if changed */
3794         update_dungeon_feeling();
3795
3796         /*** Check monster arena ***/
3797         if (p_ptr->inside_battle && !p_ptr->leaving)
3798         {
3799                 int i2, j2;
3800                 int win_m_idx = 0;
3801                 int number_mon = 0;
3802
3803                 /* Count all hostile monsters */
3804                 for (i2 = 0; i2 < cur_wid; ++i2)
3805                         for (j2 = 0; j2 < cur_hgt; j2++)
3806                         {
3807                                 cave_type *c_ptr = &cave[j2][i2];
3808
3809                                 if ((c_ptr->m_idx > 0) && (c_ptr->m_idx != p_ptr->riding))
3810                                 {
3811                                         number_mon++;
3812                                         win_m_idx = c_ptr->m_idx;
3813                                 }
3814                         }
3815
3816                 if (number_mon == 0)
3817                 {
3818 #ifdef JP
3819                         msg_print("ÁêÂǤÁ¤Ë½ª¤ï¤ê¤Þ¤·¤¿¡£");
3820 #else
3821                         msg_print("They have kill each other at the same time.");
3822 #endif
3823                         msg_print(NULL);
3824                         p_ptr->energy_need = 0;
3825                         battle_monsters();
3826                 }
3827                 else if ((number_mon-1) == 0)
3828                 {
3829                         char m_name[80];
3830                         monster_type *wm_ptr;
3831
3832                         wm_ptr = &m_list[win_m_idx];
3833
3834                         monster_desc(m_name, wm_ptr, 0);
3835 #ifdef JP
3836                         msg_format("%s¤¬¾¡Íø¤·¤¿¡ª", m_name);
3837 #else
3838                         msg_format("%s is winner!", m_name);
3839 #endif
3840                         msg_print(NULL);
3841
3842                         if (win_m_idx == (sel_monster+1))
3843                         {
3844 #ifdef JP
3845                                 msg_print("¤ª¤á¤Ç¤È¤¦¤´¤¶¤¤¤Þ¤¹¡£");
3846 #else
3847                                 msg_print("Congratulations.");
3848 #endif
3849 #ifdef JP
3850                                 msg_format("%d¡ð¤ò¼õ¤±¼è¤Ã¤¿¡£", battle_odds);
3851 #else
3852                                 msg_format("You received %d gold.", battle_odds);
3853 #endif
3854                                 p_ptr->au += battle_odds;
3855                         }
3856                         else
3857                         {
3858 #ifdef JP
3859                                 msg_print("»ÄÇ°¤Ç¤·¤¿¡£");
3860 #else
3861                                 msg_print("You lost gold.");
3862 #endif
3863                         }
3864                         msg_print(NULL);
3865                         p_ptr->energy_need = 0;
3866                         battle_monsters();
3867                 }
3868                 else if (turn - old_turn == 150*TURNS_PER_TICK)
3869                 {
3870 #ifdef JP
3871                         msg_print("¿½¤·Ê¬¤±¤¢¤ê¤Þ¤»¤ó¤¬¡¢¤³¤Î¾¡Éé¤Ï°ú¤­Ê¬¤±¤È¤µ¤»¤Æ¤¤¤¿¤À¤­¤Þ¤¹¡£");
3872 #else
3873                         msg_format("This battle have ended in a draw.");
3874 #endif
3875                         p_ptr->au += kakekin;
3876                         msg_print(NULL);
3877                         p_ptr->energy_need = 0;
3878                         battle_monsters();
3879                 }
3880         }
3881
3882         /* Every 10 game turns */
3883         if (turn % TURNS_PER_TICK) return;
3884
3885         /*** Check the Time and Load ***/
3886
3887         if (!(turn % (50*TURNS_PER_TICK)))
3888         {
3889                 /* Check time and load */
3890                 if ((0 != check_time()) || (0 != check_load()))
3891                 {
3892                         /* Warning */
3893                         if (closing_flag <= 2)
3894                         {
3895                                 /* Disturb */
3896                                 disturb(0, 1);
3897
3898                                 /* Count warnings */
3899                                 closing_flag++;
3900
3901                                 /* Message */
3902 #ifdef JP
3903 msg_print("¥¢¥ó¥°¥Ð¥ó¥É¤Ø¤ÎÌ礬ÊĤ¸¤«¤«¤Ã¤Æ¤¤¤Þ¤¹...");
3904 msg_print("¥²¡¼¥à¤ò½ªÎ»¤¹¤ë¤«¥»¡¼¥Ö¤¹¤ë¤«¤·¤Æ²¼¤µ¤¤¡£");
3905 #else
3906                                 msg_print("The gates to ANGBAND are closing...");
3907                                 msg_print("Please finish up and/or save your game.");
3908 #endif
3909
3910                         }
3911
3912                         /* Slam the gate */
3913                         else
3914                         {
3915                                 /* Message */
3916 #ifdef JP
3917 msg_print("º£¡¢¥¢¥ó¥°¥Ð¥ó¥É¤Ø¤ÎÌ礬ÊĤ¶¤µ¤ì¤Þ¤·¤¿¡£");
3918 #else
3919                                 msg_print("The gates to ANGBAND are now closed.");
3920 #endif
3921
3922
3923                                 /* Stop playing */
3924                                 p_ptr->playing = FALSE;
3925
3926                                 /* Leaving */
3927                                 p_ptr->leaving = TRUE;
3928                         }
3929                 }
3930         }
3931
3932         /*** Attempt timed autosave ***/
3933         if (autosave_t && autosave_freq && !p_ptr->inside_battle)
3934         {
3935                 if (!(turn % ((s32b)autosave_freq * TURNS_PER_TICK)))
3936                         do_cmd_save_game(TRUE);
3937         }
3938
3939         if (mon_fight && !ignore_unview)
3940         {
3941 #ifdef JP
3942                 msg_print("²¿¤«¤¬Ê¹¤³¤¨¤¿¡£");
3943 #else
3944                 msg_print("You hear noise.");
3945 #endif
3946         }
3947
3948         /*** Handle the wilderness/town (sunshine) ***/
3949
3950         /* While in town/wilderness */
3951         if (!dun_level && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)
3952         {
3953                 /* Hack -- Daybreak/Nighfall in town */
3954                 if (!(turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2)))
3955                 {
3956                         bool dawn;
3957
3958                         /* Check for dawn */
3959                         dawn = (!(turn % (TURNS_PER_TICK * TOWN_DAWN)));
3960
3961                         /* Day breaks */
3962                         if (dawn)
3963                         {
3964                                 int y, x;
3965
3966                                 /* Message */
3967 #ifdef JP
3968                                 msg_print("Ì뤬ÌÀ¤±¤¿¡£");
3969 #else
3970                                 msg_print("The sun has risen.");
3971 #endif
3972
3973                                 if (!p_ptr->wild_mode)
3974                                 {
3975                                         /* Hack -- Scan the town */
3976                                         for (y = 0; y < cur_hgt; y++)
3977                                         {
3978                                                 for (x = 0; x < cur_wid; x++)
3979                                                 {
3980                                                         /* Get the cave grid */
3981                                                         cave_type *c_ptr = &cave[y][x];
3982
3983                                                         /* Assume lit */
3984                                                         c_ptr->info |= (CAVE_GLOW);
3985
3986                                                         /* Hack -- Memorize lit grids if allowed */
3987                                                         if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
3988
3989                                                         /* Hack -- Notice spot */
3990                                                         note_spot(y, x);
3991                                                 }
3992                                         }
3993                                 }
3994                         }
3995
3996                         /* Night falls */
3997                         else
3998                         {
3999                                 int y, x;
4000
4001                                 /* Message */
4002 #ifdef JP
4003                                 msg_print("Æü¤¬ÄÀ¤ó¤À¡£");
4004 #else
4005                                 msg_print("The sun has fallen.");
4006 #endif
4007
4008                                 if (!p_ptr->wild_mode)
4009                                 {
4010                                         /* Hack -- Scan the town */
4011                                         for (y = 0; y < cur_hgt; y++)
4012                                         {
4013                                                 for (x = 0; x < cur_wid; x++)
4014                                                 {
4015                                                         /* Get the cave grid */
4016                                                         cave_type *c_ptr = &cave[y][x];
4017
4018                                                         /* Feature code (applying "mimic" field) */
4019                                                         feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
4020
4021                                                         if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
4022                                                             !have_flag(f_ptr->flags, FF_ENTRANCE))
4023                                                         {
4024                                                                 /* Assume dark */
4025                                                                 c_ptr->info &= ~(CAVE_GLOW);
4026
4027                                                                 if (!have_flag(f_ptr->flags, FF_REMEMBER))
4028                                                                 {
4029                                                                         /* Forget the normal floor grid */
4030                                                                         c_ptr->info &= ~(CAVE_MARK);
4031
4032                                                                         /* Hack -- Notice spot */
4033                                                                         note_spot(y, x);
4034                                                                 }
4035                                                         }
4036                                                 }
4037
4038                                                 /* Glow deep lava and building entrances */
4039                                                 glow_deep_lava_and_bldg();
4040                                         }
4041                                 }
4042                         }
4043
4044                         /* Update the monsters */
4045                         p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
4046
4047                         /* Redraw map */
4048                         p_ptr->redraw |= (PR_MAP);
4049
4050                         /* Window stuff */
4051                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4052
4053                         if (p_ptr->special_defense & NINJA_S_STEALTH)
4054                         {
4055                                 if (cave[py][px].info & CAVE_GLOW) set_superstealth(FALSE);
4056                         }
4057                 }
4058         }
4059
4060         /* While in the dungeon (vanilla_town or lite_town mode only) */
4061         else if ((vanilla_town || (lite_town && !p_ptr->inside_quest && !p_ptr->inside_battle && !p_ptr->inside_arena)) && dun_level)
4062         {
4063                 /*** Shuffle the Storekeepers ***/
4064
4065                 /* Chance is only once a day (while in dungeon) */
4066                 if (!(turn % (TURNS_PER_TICK * STORE_TICKS)))
4067                 {
4068                         /* Sometimes, shuffle the shop-keepers */
4069                         if (one_in_(STORE_SHUFFLE))
4070                         {
4071                                 int n, i;
4072
4073                                 /* Pick a random shop (except home and museum) */
4074                                 do
4075                                 {
4076                                         n = randint0(MAX_STORES);
4077                                 }
4078                                 while ((n == STORE_HOME) || (n == STORE_MUSEUM));
4079
4080                                 /* Check every feature */
4081                                 for (i = 1; i < max_f_idx; i++)
4082                                 {
4083                                         /* Access the index */
4084                                         feature_type *f_ptr = &f_info[i];
4085
4086                                         /* Skip empty index */
4087                                         if (!f_ptr->name) continue;
4088
4089                                         /* Skip non-store features */
4090                                         if (!have_flag(f_ptr->flags, FF_STORE)) continue;
4091
4092                                         /* Verify store type */
4093                                         if (f_ptr->subtype == n)
4094                                         {
4095                                                 /* Message */
4096 #ifdef JP
4097                                                 if (cheat_xtra) msg_format("%s¤ÎŹ¼ç¤ò¥·¥ã¥Ã¥Õ¥ë¤·¤Þ¤¹¡£", f_name + f_ptr->name);
4098 #else
4099                                                 if (cheat_xtra) msg_format("Shuffle a Shopkeeper of %s.", f_name + f_ptr->name);
4100 #endif
4101
4102                                                 /* Shuffle it */
4103                                                 store_shuffle(n);
4104
4105                                                 break;
4106                                         }
4107                                 }
4108                         }
4109                 }
4110         }
4111
4112
4113         /*** Process the monsters ***/
4114
4115         /* Check for creature generation. */
4116         if (one_in_(d_info[dungeon_type].max_m_alloc_chance) &&
4117             !p_ptr->inside_arena && !p_ptr->inside_quest && !p_ptr->inside_battle)
4118         {
4119                 /* Make a new monster */
4120                 (void)alloc_monster(MAX_SIGHT + 5, 0);
4121         }
4122
4123         /* Hack -- Check for creature regeneration */
4124         if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
4125         if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
4126
4127         if (!p_ptr->leaving)
4128         {
4129                 int i;
4130
4131                 /* Hack -- Process the counters of monsters if needed */
4132                 for (i = 0; i < MAX_MTIMED; i++)
4133                 {
4134                         if (mproc_max[i] > 0) process_monsters_mtimed(i);
4135                 }
4136         }
4137
4138
4139         /* Date changes */
4140         if (!hour && !min)
4141         {
4142                 if (min != prev_min)
4143                 {
4144                         do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
4145                         determine_today_mon(FALSE);
4146                 }
4147         }
4148
4149         /*
4150          * Nightmare mode activates the TY_CURSE at midnight
4151          *
4152          * Require exact minute -- Don't activate multiple times in a minute
4153          */
4154         if (ironman_nightmare && (min != prev_min))
4155         {
4156                 /* Every 15 minutes after 11:00 pm */
4157                 if ((hour == 23) && !(min % 15))
4158                 {
4159                         /* Disturbing */
4160                         disturb(0, 1);
4161
4162                         switch (min / 15)
4163                         {
4164                         case 0:
4165 #ifdef JP
4166                                 msg_print("±ó¤¯¤ÇÉÔµ¤Ì£¤Ê¾â¤Î²»¤¬ÌĤä¿¡£");
4167 #else
4168                                 msg_print("You hear a distant bell toll ominously.");
4169 #endif
4170                                 break;
4171
4172                         case 1:
4173 #ifdef JP
4174                                 msg_print("±ó¤¯¤Ç¾â¤¬Æó²óÌĤä¿¡£");
4175 #else
4176                                 msg_print("A distant bell sounds twice.");
4177 #endif
4178                                 break;
4179
4180                         case 2:
4181 #ifdef JP
4182                                 msg_print("±ó¤¯¤Ç¾â¤¬»°²óÌĤä¿¡£");
4183 #else
4184                                 msg_print("A distant bell sounds three times.");
4185 #endif
4186                                 break;
4187
4188                         case 3:
4189 #ifdef JP
4190                                 msg_print("±ó¤¯¤Ç¾â¤¬»Í²óÌĤä¿¡£");
4191 #else
4192                                 msg_print("A distant bell tolls four times.");
4193 #endif
4194                                 break;
4195                         }
4196                 }
4197
4198                 /* TY_CURSE activates at midnight! */
4199                 if (!hour && !min)
4200                 {
4201                         int count = 0;
4202
4203                         disturb(1, 1);
4204 #ifdef JP
4205                         msg_print("±ó¤¯¤Ç¾â¤¬²¿²ó¤âÌĤꡢ»à¤ó¤À¤è¤¦¤ÊÀŤ±¤µ¤ÎÃæ¤Ø¾Ã¤¨¤Æ¤¤¤Ã¤¿¡£");
4206 #else
4207                         msg_print("A distant bell tolls many times, fading into an deathly silence.");
4208 #endif
4209
4210                         activate_ty_curse(FALSE, &count);
4211                 }
4212         }
4213
4214
4215         /*** Check the Food, and Regenerate ***/
4216
4217         if (!p_ptr->inside_battle)
4218         {
4219                 /* Digest quickly when gorged */
4220                 if (p_ptr->food >= PY_FOOD_MAX)
4221                 {
4222                         /* Digest a lot of food */
4223                         (void)set_food(p_ptr->food - 100);
4224                 }
4225
4226                 /* Digest normally -- Every 50 game turns */
4227                 else if (!(turn % (TURNS_PER_TICK*5)))
4228                 {
4229                         /* Basic digestion rate based on speed */
4230                         int digestion = SPEED_TO_ENERGY(p_ptr->pspeed);
4231
4232                         /* Regeneration takes more food */
4233                         if (p_ptr->regenerate)
4234                                 digestion += 20;
4235                         if (p_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
4236                                 digestion += 20;
4237                         if (p_ptr->cursed & TRC_FAST_DIGEST)
4238                                 digestion += 30;
4239
4240                         /* Slow digestion takes less food */
4241                         if (p_ptr->slow_digest)
4242                                 digestion -= 5;
4243
4244                         /* Minimal digestion */
4245                         if (digestion < 1) digestion = 1;
4246                         /* Maximal digestion */
4247                         if (digestion > 100) digestion = 100;
4248
4249                         /* Digest some food */
4250                         (void)set_food(p_ptr->food - digestion);
4251                 }
4252
4253
4254                 /* Getting Faint */
4255                 if ((p_ptr->food < PY_FOOD_FAINT))
4256                 {
4257                         /* Faint occasionally */
4258                         if (!p_ptr->paralyzed && (randint0(100) < 10))
4259                         {
4260                                 /* Message */
4261 #ifdef JP
4262                                 msg_print("¤¢¤Þ¤ê¤Ë¤â¶õÊ¢¤Çµ¤À䤷¤Æ¤·¤Þ¤Ã¤¿¡£");
4263 #else
4264                                 msg_print("You faint from the lack of food.");
4265 #endif
4266
4267                                 disturb(1, 1);
4268
4269                                 /* Hack -- faint (bypass free action) */
4270                                 (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
4271                         }
4272
4273                         /* Starve to death (slowly) */
4274                         if (p_ptr->food < PY_FOOD_STARVE)
4275                         {
4276                                 /* Calculate damage */
4277                                 int dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
4278
4279                                 /* Take damage */
4280 #ifdef JP
4281                                 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, "¶õÊ¢", -1);
4282 #else
4283                                 if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, "starvation", -1);
4284 #endif
4285                         }
4286                 }
4287         }
4288
4289
4290
4291         /* Process timed damage and regeneration */
4292         process_world_aux_hp_and_sp();
4293
4294         /* Process timeout */
4295         process_world_aux_timeout();
4296
4297         /* Process light */
4298         process_world_aux_light();
4299
4300         /* Process mutation effects */
4301         process_world_aux_mutation();
4302
4303         /* Process curse effects */
4304         process_world_aux_curse();
4305
4306         /* Process recharging */
4307         process_world_aux_recharge();
4308
4309         /* Feel the inventory */
4310         sense_inventory1();
4311         sense_inventory2();
4312
4313         /* Involuntary Movement */
4314         process_world_aux_movement();
4315 }
4316
4317 /*!
4318  * @brief ¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤Ø¤ÎƳÆþ½èÍý
4319  * / Verify use of "wizard" mode
4320  * @return ¼ÂºÝ¤Ë¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤Ø°Ü¹Ô¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
4321  */
4322 static bool enter_wizard_mode(void)
4323 {
4324         /* Ask first time */
4325         if (!p_ptr->noscore)
4326         {
4327                 /* Wizard mode is not permitted */
4328                 if (!allow_debug_opts || arg_wizard)
4329                 {
4330 #ifdef JP
4331                         msg_print("¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤Ïµö²Ä¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ ");
4332 #else
4333                         msg_print("Wizard mode is not permitted.");
4334 #endif
4335                         return FALSE;
4336                 }
4337
4338                 /* Mention effects */
4339 #ifdef JP
4340                 msg_print("¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤Ï¥Ç¥Ð¥Ã¥°¤È¼Â¸³¤Î¤¿¤á¤Î¥â¡¼¥É¤Ç¤¹¡£ ");
4341                 msg_print("°ìÅÙ¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤ËÆþ¤ë¤È¥¹¥³¥¢¤Ïµ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
4342 #else
4343                 msg_print("Wizard mode is for debugging and experimenting.");
4344                 msg_print("The game will not be scored if you enter wizard mode.");
4345 #endif
4346
4347                 msg_print(NULL);
4348
4349                 /* Verify request */
4350 #ifdef JP
4351                 if (!get_check("ËÜÅö¤Ë¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤ËÆþ¤ê¤¿¤¤¤Î¤Ç¤¹¤«? "))
4352 #else
4353                 if (!get_check("Are you sure you want to enter wizard mode? "))
4354 #endif
4355                 {
4356                         return (FALSE);
4357                 }
4358
4359 #ifdef JP
4360                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤ËÆÍÆþ¤·¤Æ¥¹¥³¥¢¤ò»Ä¤»¤Ê¤¯¤Ê¤Ã¤¿¡£");
4361 #else
4362                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up recording score to enter wizard mode.");
4363 #endif
4364                 /* Mark savefile */
4365                 p_ptr->noscore |= 0x0002;
4366         }
4367
4368         /* Success */
4369         return (TRUE);
4370 }
4371
4372
4373 #ifdef ALLOW_WIZARD
4374
4375 /*!
4376  * @brief ¥Ç¥Ð¥Ã¥°¥³¥Þ¥ó¥É¤Ø¤ÎƳÆþ½èÍý
4377  * / Verify use of "debug" commands
4378  * @return ¼ÂºÝ¤Ë¥Ç¥Ð¥Ã¥°¥³¥Þ¥ó¥É¤Ø°Ü¹Ô¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
4379  */
4380 static bool enter_debug_mode(void)
4381 {
4382         /* Ask first time */
4383         if (!p_ptr->noscore)
4384         {
4385                 /* Debug mode is not permitted */
4386                 if (!allow_debug_opts)
4387                 {
4388 #ifdef JP
4389                         msg_print("¥Ç¥Ð¥Ã¥°¥³¥Þ¥ó¥É¤Ïµö²Ä¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£ ");
4390 #else
4391                         msg_print("Use of debug command is not permitted.");
4392 #endif
4393                         return FALSE;
4394                 }
4395
4396                 /* Mention effects */
4397 #ifdef JP
4398                 msg_print("¥Ç¥Ð¥Ã¥°¡¦¥³¥Þ¥ó¥É¤Ï¥Ç¥Ð¥Ã¥°¤È¼Â¸³¤Î¤¿¤á¤Î¥³¥Þ¥ó¥É¤Ç¤¹¡£ ");
4399                 msg_print("¥Ç¥Ð¥Ã¥°¡¦¥³¥Þ¥ó¥É¤ò»È¤¦¤È¥¹¥³¥¢¤Ïµ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
4400 #else
4401                 msg_print("The debug commands are for debugging and experimenting.");
4402                 msg_print("The game will not be scored if you use debug commands.");
4403 #endif
4404
4405                 msg_print(NULL);
4406
4407                 /* Verify request */
4408 #ifdef JP
4409                 if (!get_check("ËÜÅö¤Ë¥Ç¥Ð¥Ã¥°¡¦¥³¥Þ¥ó¥É¤ò»È¤¤¤Þ¤¹¤«? "))
4410 #else
4411                 if (!get_check("Are you sure you want to use debug commands? "))
4412 #endif
4413                 {
4414                         return (FALSE);
4415                 }
4416
4417 #ifdef JP
4418                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥Ç¥Ð¥Ã¥°¥â¡¼¥É¤ËÆÍÆþ¤·¤Æ¥¹¥³¥¢¤ò»Ä¤»¤Ê¤¯¤Ê¤Ã¤¿¡£");
4419 #else
4420                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up sending score to use debug commands.");
4421 #endif
4422                 /* Mark savefile */
4423                 p_ptr->noscore |= 0x0008;
4424         }
4425
4426         /* Success */
4427         return (TRUE);
4428 }
4429
4430 /*
4431  * Hack -- Declare the Debug Routines
4432  */
4433 extern void do_cmd_debug(void);
4434
4435 #endif /* ALLOW_WIZARD */
4436
4437
4438 #ifdef ALLOW_BORG
4439
4440 /*!
4441  * @brief ¥Ü¡¼¥°¥³¥Þ¥ó¥É¤Ø¤ÎƳÆþ½èÍý
4442  * / Verify use of "borg" commands
4443  * @return ¼ÂºÝ¤Ë¥Ü¡¼¥°¥³¥Þ¥ó¥É¤Ø°Ü¹Ô¤·¤¿¤éTRUE¤òÊÖ¤¹¡£
4444  */
4445 static bool enter_borg_mode(void)
4446 {
4447         /* Ask first time */
4448         if (!(p_ptr->noscore & 0x0010))
4449         {
4450                 /* Mention effects */
4451 #ifdef JP
4452                 msg_print("¥Ü¡¼¥°¡¦¥³¥Þ¥ó¥É¤Ï¥Ç¥Ð¥Ã¥°¤È¼Â¸³¤Î¤¿¤á¤Î¥³¥Þ¥ó¥É¤Ç¤¹¡£ ");
4453                 msg_print("¥Ü¡¼¥°¡¦¥³¥Þ¥ó¥É¤ò»È¤¦¤È¥¹¥³¥¢¤Ïµ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
4454 #else
4455                 msg_print("The borg commands are for debugging and experimenting.");
4456                 msg_print("The game will not be scored if you use borg commands.");
4457 #endif
4458
4459                 msg_print(NULL);
4460
4461                 /* Verify request */
4462 #ifdef JP
4463                 if (!get_check("ËÜÅö¤Ë¥Ü¡¼¥°¡¦¥³¥Þ¥ó¥É¤ò»È¤¤¤Þ¤¹¤«? "))
4464 #else
4465                 if (!get_check("Are you sure you want to use borg commands? "))
4466 #endif
4467                 {
4468                         return (FALSE);
4469                 }
4470
4471 #ifdef JP
4472                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥Ü¡¼¥°¡¦¥³¥Þ¥ó¥É¤ò»ÈÍѤ·¤Æ¥¹¥³¥¢¤ò»Ä¤»¤Ê¤¯¤Ê¤Ã¤¿¡£");
4473 #else
4474                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up recording score to use borg commands.");
4475 #endif
4476                 /* Mark savefile */
4477                 p_ptr->noscore |= 0x0010;
4478         }
4479
4480         /* Success */
4481         return (TRUE);
4482 }
4483
4484 /*
4485  * Hack -- Declare the Ben Borg
4486  */
4487 extern void do_cmd_borg(void);
4488
4489 #endif /* ALLOW_BORG */
4490
4491
4492 /*!
4493  * @brief ¥×¥ì¥¤¥ä¡¼¤«¤é¼õ¤±¤¿ÆþÎÏ¥³¥Þ¥ó¥É¤Îʬ´ô½èÍý¡£
4494  * / Parse and execute the current command Give "Warning" on illegal commands.
4495  * @todo XXX XXX XXX Make some "blocks"
4496  * @return ¤Ê¤·
4497  */
4498 static void process_command(void)
4499 {
4500         int old_now_message = now_message;
4501
4502 #ifdef ALLOW_REPEAT /* TNB */
4503
4504         /* Handle repeating the last command */
4505         repeat_check();
4506
4507 #endif /* ALLOW_REPEAT -- TNB */
4508
4509         now_message = 0;
4510
4511         /* Sniper */
4512         if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
4513                 reset_concent = TRUE;
4514
4515         /* Parse the command */
4516         switch (command_cmd)
4517         {
4518                 /* Ignore */
4519                 case ESCAPE:
4520                 case ' ':
4521                 {
4522                         break;
4523                 }
4524
4525                 /* Ignore return */
4526                 case '\r':
4527                 case '\n':
4528                 {
4529                         break;
4530                 }
4531
4532                 /*** Wizard Commands ***/
4533
4534                 /* Toggle Wizard Mode */
4535                 case KTRL('W'):
4536                 {
4537                         if (p_ptr->wizard)
4538                         {
4539                                 p_ptr->wizard = FALSE;
4540 #ifdef JP
4541 msg_print("¥¦¥£¥¶¡¼¥É¥â¡¼¥É²ò½ü¡£");
4542 #else
4543                                 msg_print("Wizard mode off.");
4544 #endif
4545
4546                         }
4547                         else if (enter_wizard_mode())
4548                         {
4549                                 p_ptr->wizard = TRUE;
4550 #ifdef JP
4551 msg_print("¥¦¥£¥¶¡¼¥É¥â¡¼¥ÉÆÍÆþ¡£");
4552 #else
4553                                 msg_print("Wizard mode on.");
4554 #endif
4555
4556                         }
4557
4558                         /* Update monsters */
4559                         p_ptr->update |= (PU_MONSTERS);
4560
4561                         /* Redraw "title" */
4562                         p_ptr->redraw |= (PR_TITLE);
4563
4564                         break;
4565                 }
4566
4567
4568 #ifdef ALLOW_WIZARD
4569
4570                 /* Special "debug" commands */
4571                 case KTRL('A'):
4572                 {
4573                         /* Enter debug mode */
4574                         if (enter_debug_mode())
4575                         {
4576                                 do_cmd_debug();
4577                         }
4578                         break;
4579                 }
4580
4581 #endif /* ALLOW_WIZARD */
4582
4583
4584 #ifdef ALLOW_BORG
4585
4586                 /* Special "borg" commands */
4587                 case KTRL('Z'):
4588                 {
4589                         /* Enter borg mode */
4590                         if (enter_borg_mode())
4591                         {
4592                                 if (!p_ptr->wild_mode) do_cmd_borg();
4593                         }
4594
4595                         break;
4596                 }
4597
4598 #endif /* ALLOW_BORG */
4599
4600
4601
4602                 /*** Inventory Commands ***/
4603
4604                 /* Wear/wield equipment */
4605                 case 'w':
4606                 {
4607                         if (!p_ptr->wild_mode) do_cmd_wield();
4608                         break;
4609                 }
4610
4611                 /* Take off equipment */
4612                 case 't':
4613                 {
4614                         if (!p_ptr->wild_mode) do_cmd_takeoff();
4615                         break;
4616                 }
4617
4618                 /* Drop an item */
4619                 case 'd':
4620                 {
4621                         if (!p_ptr->wild_mode) do_cmd_drop();
4622                         break;
4623                 }
4624
4625                 /* Destroy an item */
4626                 case 'k':
4627                 {
4628                         do_cmd_destroy();
4629                         break;
4630                 }
4631
4632                 /* Equipment list */
4633                 case 'e':
4634                 {
4635                         do_cmd_equip();
4636                         break;
4637                 }
4638
4639                 /* Inventory list */
4640                 case 'i':
4641                 {
4642                         do_cmd_inven();
4643                         break;
4644                 }
4645
4646
4647                 /*** Various commands ***/
4648
4649                 /* Identify an object */
4650                 case 'I':
4651                 {
4652                         do_cmd_observe();
4653                         break;
4654                 }
4655
4656                 /* Hack -- toggle windows */
4657                 case KTRL('I'):
4658                 {
4659                         toggle_inven_equip();
4660                         break;
4661                 }
4662
4663
4664                 /*** Standard "Movement" Commands ***/
4665
4666                 /* Alter a grid */
4667                 case '+':
4668                 {
4669                         if (!p_ptr->wild_mode) do_cmd_alter();
4670                         break;
4671                 }
4672
4673                 /* Dig a tunnel */
4674                 case 'T':
4675                 {
4676                         if (!p_ptr->wild_mode) do_cmd_tunnel();
4677                         break;
4678                 }
4679
4680                 /* Move (usually pick up things) */
4681                 case ';':
4682                 {
4683 #ifdef ALLOW_EASY_DISARM /* TNB */
4684
4685                         do_cmd_walk(FALSE);
4686
4687 #else /* ALLOW_EASY_DISARM -- TNB */
4688
4689                         do_cmd_walk(always_pickup);
4690
4691 #endif /* ALLOW_EASY_DISARM -- TNB */
4692
4693                         break;
4694                 }
4695
4696                 /* Move (usually do not pick up) */
4697                 case '-':
4698                 {
4699 #ifdef ALLOW_EASY_DISARM /* TNB */
4700
4701                         do_cmd_walk(TRUE);
4702
4703 #else /* ALLOW_EASY_DISARM -- TNB */
4704
4705                         do_cmd_walk(!always_pickup);
4706
4707 #endif /* ALLOW_EASY_DISARM -- TNB */
4708
4709                         break;
4710                 }
4711
4712
4713                 /*** Running, Resting, Searching, Staying */
4714
4715                 /* Begin Running -- Arg is Max Distance */
4716                 case '.':
4717                 {
4718                         if (!p_ptr->wild_mode) do_cmd_run();
4719                         break;
4720                 }
4721
4722                 /* Stay still (usually pick things up) */
4723                 case ',':
4724                 {
4725                         do_cmd_stay(always_pickup);
4726                         break;
4727                 }
4728
4729                 /* Stay still (usually do not pick up) */
4730                 case 'g':
4731                 {
4732                         do_cmd_stay(!always_pickup);
4733                         break;
4734                 }
4735
4736                 /* Rest -- Arg is time */
4737                 case 'R':
4738                 {
4739                         do_cmd_rest();
4740                         break;
4741                 }
4742
4743                 /* Search for traps/doors */
4744                 case 's':
4745                 {
4746                         do_cmd_search();
4747                         break;
4748                 }
4749
4750                 /* Toggle search mode */
4751                 case 'S':
4752                 {
4753                         if (p_ptr->action == ACTION_SEARCH) set_action(ACTION_NONE);
4754                         else set_action(ACTION_SEARCH);
4755                         break;
4756                 }
4757
4758
4759                 /*** Stairs and Doors and Chests and Traps ***/
4760
4761                 /* Enter store */
4762                 case SPECIAL_KEY_STORE:
4763                 {
4764                         if (!p_ptr->wild_mode) do_cmd_store();
4765                         break;
4766                 }
4767
4768                 /* Enter building -KMW- */
4769                 case SPECIAL_KEY_BUILDING:
4770                 {
4771                         if (!p_ptr->wild_mode) do_cmd_bldg();
4772                         break;
4773                 }
4774
4775                 /* Enter quest level -KMW- */
4776                 case SPECIAL_KEY_QUEST:
4777                 {
4778                         if (!p_ptr->wild_mode) do_cmd_quest();
4779                         break;
4780                 }
4781
4782                 /* Go up staircase */
4783                 case '<':
4784                 {
4785                         if (!p_ptr->wild_mode && !dun_level && !p_ptr->inside_arena && !p_ptr->inside_quest)
4786                         {
4787                                 if (vanilla_town) break;
4788
4789                                 if (ambush_flag)
4790                                 {
4791 #ifdef JP
4792                                         msg_print("½±·â¤«¤éƨ¤²¤ë¤Ë¤Ï¥Þ¥Ã¥×¤Îü¤Þ¤Ç°ÜÆ°¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£");
4793 #else
4794                                         msg_print("To flee the ambush you have to reach the edge of the map.");
4795 #endif
4796                                         break;
4797                                 }
4798
4799                                 if (p_ptr->food < PY_FOOD_WEAK)
4800                                 {
4801 #ifdef JP
4802                                         msg_print("¤½¤ÎÁ°¤Ë¿©»ö¤ò¤È¤é¤Ê¤¤¤È¡£");
4803 #else
4804                                         msg_print("You must eat something here.");
4805 #endif
4806                                         break;
4807                                 }
4808
4809                                 change_wild_mode();
4810                         }
4811                         else
4812                                 do_cmd_go_up();
4813                         break;
4814                 }
4815
4816                 /* Go down staircase */
4817                 case '>':
4818                 {
4819                         if (p_ptr->wild_mode)
4820                                 change_wild_mode();
4821                         else
4822                                 do_cmd_go_down();
4823
4824                         break;
4825                 }
4826
4827                 /* Open a door or chest */
4828                 case 'o':
4829                 {
4830                         if (!p_ptr->wild_mode) do_cmd_open();
4831                         break;
4832                 }
4833
4834                 /* Close a door */
4835                 case 'c':
4836                 {
4837                         if (!p_ptr->wild_mode) do_cmd_close();
4838                         break;
4839                 }
4840
4841                 /* Jam a door with spikes */
4842                 case 'j':
4843                 {
4844                         if (!p_ptr->wild_mode) do_cmd_spike();
4845                         break;
4846                 }
4847
4848                 /* Bash a door */
4849                 case 'B':
4850                 {
4851                         if (!p_ptr->wild_mode) do_cmd_bash();
4852                         break;
4853                 }
4854
4855                 /* Disarm a trap or chest */
4856                 case 'D':
4857                 {
4858                         if (!p_ptr->wild_mode) do_cmd_disarm();
4859                         break;
4860                 }
4861
4862
4863                 /*** Magic and Prayers ***/
4864
4865                 /* Gain new spells/prayers */
4866                 case 'G':
4867                 {
4868                         if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4869 #ifdef JP
4870                                 msg_print("¼öʸ¤ò³Ø½¬¤¹¤ëɬÍפϤʤ¤¡ª");
4871 #else
4872                                 msg_print("You don't have to learn spells!");
4873 #endif
4874                         else if (p_ptr->pclass == CLASS_SAMURAI)
4875                                 do_cmd_gain_hissatsu();
4876                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4877                                 gain_magic();
4878                         else
4879                                 do_cmd_study();
4880                         break;
4881                 }
4882
4883                 /* Browse a book */
4884                 case 'b':
4885                 {
4886                         if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4887                              (p_ptr->pclass == CLASS_BERSERKER) ||
4888                              (p_ptr->pclass == CLASS_NINJA) ||
4889                              (p_ptr->pclass == CLASS_MIRROR_MASTER) 
4890                              ) do_cmd_mind_browse();
4891                         else if (p_ptr->pclass == CLASS_SMITH)
4892                                 do_cmd_kaji(TRUE);
4893                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4894                                 do_cmd_magic_eater(TRUE, FALSE);
4895                         else if (p_ptr->pclass == CLASS_SNIPER)
4896                                 do_cmd_snipe_browse();
4897                         else do_cmd_browse();
4898                         break;
4899                 }
4900
4901                 /* Cast a spell */
4902                 case 'm':
4903                 {
4904                         /* -KMW- */
4905                         if (!p_ptr->wild_mode)
4906                         {
4907                                 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_CAVALRY))
4908                                 {
4909 #ifdef JP
4910                                         msg_print("¼öʸ¤ò¾§¤¨¤é¤ì¤Ê¤¤¡ª");
4911 #else
4912                                         msg_print("You cannot cast spells!");
4913 #endif
4914                                 }
4915                                 else if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4916                                 {
4917 #ifdef JP
4918                                         msg_print("¥À¥ó¥¸¥ç¥ó¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
4919 #else
4920                                         msg_print("The dungeon absorbs all attempted magic!");
4921 #endif
4922                                         msg_print(NULL);
4923                                 }
4924                                 else if (p_ptr->anti_magic && (p_ptr->pclass != CLASS_BERSERKER) && (p_ptr->pclass != CLASS_SMITH))
4925                                 {
4926 #ifdef JP
4927
4928                                         cptr which_power = "ËâË¡";
4929 #else
4930                                         cptr which_power = "magic";
4931 #endif
4932                                         if (p_ptr->pclass == CLASS_MINDCRAFTER)
4933 #ifdef JP
4934                                                 which_power = "ĶǽÎÏ";
4935 #else
4936                                                 which_power = "psionic powers";
4937 #endif
4938                                         else if (p_ptr->pclass == CLASS_IMITATOR)
4939 #ifdef JP
4940                                                 which_power = "¤â¤Î¤Þ¤Í";
4941 #else
4942                                                 which_power = "imitation";
4943 #endif
4944                                         else if (p_ptr->pclass == CLASS_SAMURAI)
4945 #ifdef JP
4946                                                 which_power = "ɬ»¦·õ";
4947 #else
4948                                                 which_power = "hissatsu";
4949 #endif
4950                                         else if (p_ptr->pclass == CLASS_MIRROR_MASTER)
4951 #ifdef JP
4952                                                 which_power = "¶ÀËâË¡";
4953 #else
4954                                                 which_power = "mirror magic";
4955 #endif
4956                                         else if (p_ptr->pclass == CLASS_NINJA)
4957 #ifdef JP
4958                                                 which_power = "Ǧ½Ñ";
4959 #else
4960                                                 which_power = "ninjutsu";
4961 #endif
4962                                         else if (mp_ptr->spell_book == TV_LIFE_BOOK)
4963 #ifdef JP
4964                                                 which_power = "µ§¤ê";
4965 #else
4966                                                 which_power = "prayer";
4967 #endif
4968
4969 #ifdef JP
4970                                         msg_format("È¿ËâË¡¥Ð¥ê¥¢¤¬%s¤ò¼ÙË⤷¤¿¡ª", which_power);
4971 #else
4972                                         msg_format("An anti-magic shell disrupts your %s!", which_power);
4973 #endif
4974                                         energy_use = 0;
4975                                 }
4976                                 else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
4977                                 {
4978 #ifdef JP
4979                                         msg_format("¶¸Àï»Î²½¤·¤Æ¤¤¤ÆƬ¤¬²ó¤é¤Ê¤¤¡ª");
4980 #else
4981                                         msg_format("You cannot think directly!");
4982 #endif
4983                                         energy_use = 0;
4984                                 }
4985                                 else
4986                                 {
4987                                         if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4988                                             (p_ptr->pclass == CLASS_BERSERKER) ||
4989                                             (p_ptr->pclass == CLASS_NINJA) ||
4990                                             (p_ptr->pclass == CLASS_MIRROR_MASTER)
4991                                             )
4992                                                 do_cmd_mind();
4993                                         else if (p_ptr->pclass == CLASS_IMITATOR)
4994                                                 do_cmd_mane(FALSE);
4995                                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4996                                                 do_cmd_magic_eater(FALSE, FALSE);
4997                                         else if (p_ptr->pclass == CLASS_SAMURAI)
4998                                                 do_cmd_hissatsu();
4999                                         else if (p_ptr->pclass == CLASS_BLUE_MAGE)
5000                                                 do_cmd_cast_learned();
5001                                         else if (p_ptr->pclass == CLASS_SMITH)
5002                                                 do_cmd_kaji(FALSE);
5003                                         else if (p_ptr->pclass == CLASS_SNIPER)
5004                                                 do_cmd_snipe();
5005                                         else
5006                                                 do_cmd_cast();
5007                                 }
5008                         }
5009                         break;
5010                 }
5011
5012                 /* Issue a pet command */
5013                 case 'p':
5014                 {
5015                         if (!p_ptr->wild_mode) do_cmd_pet();
5016                         break;
5017                 }
5018
5019                 /*** Use various objects ***/
5020
5021                 /* Inscribe an object */
5022                 case '{':
5023                 {
5024                         do_cmd_inscribe();
5025                         break;
5026                 }
5027
5028                 /* Uninscribe an object */
5029                 case '}':
5030                 {
5031                         do_cmd_uninscribe();
5032                         break;
5033                 }
5034
5035                 /* Activate an artifact */
5036                 case 'A':
5037                 {
5038                         if (!p_ptr->wild_mode)
5039                         {
5040                         if (!p_ptr->inside_arena)
5041                                 do_cmd_activate();
5042                         else
5043                         {
5044 #ifdef JP
5045 msg_print("¥¢¥ê¡¼¥Ê¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
5046 #else
5047                                 msg_print("The arena absorbs all attempted magic!");
5048 #endif
5049
5050                                 msg_print(NULL);
5051                         }
5052                         }
5053                         break;
5054                 }
5055
5056                 /* Eat some food */
5057                 case 'E':
5058                 {
5059                         do_cmd_eat_food();
5060                         break;
5061                 }
5062
5063                 /* Fuel your lantern/torch */
5064                 case 'F':
5065                 {
5066                         do_cmd_refill();
5067                         break;
5068                 }
5069
5070                 /* Fire an item */
5071                 case 'f':
5072                 {
5073                         if (!p_ptr->wild_mode) do_cmd_fire();
5074                         break;
5075                 }
5076
5077                 /* Throw an item */
5078                 case 'v':
5079                 {
5080                         if (!p_ptr->wild_mode)
5081                         {
5082                                 do_cmd_throw();
5083                         }
5084                         break;
5085                 }
5086
5087                 /* Aim a wand */
5088                 case 'a':
5089                 {
5090                         if (!p_ptr->wild_mode)
5091                         {
5092                         if (!p_ptr->inside_arena)
5093                                 do_cmd_aim_wand();
5094                         else
5095                         {
5096 #ifdef JP
5097 msg_print("¥¢¥ê¡¼¥Ê¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
5098 #else
5099                                 msg_print("The arena absorbs all attempted magic!");
5100 #endif
5101
5102                                 msg_print(NULL);
5103                         }
5104                         }
5105                         break;
5106                 }
5107
5108                 /* Zap a rod */
5109                 case 'z':
5110                 {
5111                         if (!p_ptr->wild_mode)
5112                         {
5113                         if (p_ptr->inside_arena)
5114                         {
5115 #ifdef JP
5116 msg_print("¥¢¥ê¡¼¥Ê¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
5117 #else
5118                                 msg_print("The arena absorbs all attempted magic!");
5119 #endif
5120
5121                                 msg_print(NULL);
5122                         }
5123                         else if (use_command && rogue_like_commands)
5124                         {
5125                                 do_cmd_use();
5126                         }
5127                         else
5128                         {
5129                                 do_cmd_zap_rod();
5130                         }
5131                         }
5132                         break;
5133                 }
5134
5135                 /* Quaff a potion */
5136                 case 'q':
5137                 {
5138                         if (!p_ptr->wild_mode)
5139                         {
5140                         if (!p_ptr->inside_arena)
5141                                 do_cmd_quaff_potion();
5142                         else
5143                         {
5144 #ifdef JP
5145 msg_print("¥¢¥ê¡¼¥Ê¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
5146 #else
5147                                 msg_print("The arena absorbs all attempted magic!");
5148 #endif
5149
5150                                 msg_print(NULL);
5151                         }
5152                         }
5153                         break;
5154                 }
5155
5156                 /* Read a scroll */
5157                 case 'r':
5158                 {
5159                         if (!p_ptr->wild_mode)
5160                         {
5161                         if (!p_ptr->inside_arena)
5162                                 do_cmd_read_scroll();
5163                         else
5164                         {
5165 #ifdef JP
5166 msg_print("¥¢¥ê¡¼¥Ê¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
5167 #else
5168                                 msg_print("The arena absorbs all attempted magic!");
5169 #endif
5170
5171                                 msg_print(NULL);
5172                         }
5173                         }
5174                         break;
5175                 }
5176
5177                 /* Use a staff */
5178                 case 'u':
5179                 {
5180                         if (!p_ptr->wild_mode)
5181                         {
5182                         if (p_ptr->inside_arena)
5183                         {
5184 #ifdef JP
5185 msg_print("¥¢¥ê¡¼¥Ê¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
5186 #else
5187                                 msg_print("The arena absorbs all attempted magic!");
5188 #endif
5189
5190                                 msg_print(NULL);
5191                         }
5192                         else if (use_command && !rogue_like_commands)
5193                         {
5194                                 do_cmd_use();
5195                         }
5196                         else
5197                                 do_cmd_use_staff();
5198                         }
5199                         break;
5200                 }
5201
5202                 /* Use racial power */
5203                 case 'U':
5204                 {
5205                         if (!p_ptr->wild_mode) do_cmd_racial_power();
5206                         break;
5207                 }
5208
5209
5210                 /*** Looking at Things (nearby or on map) ***/
5211
5212                 /* Full dungeon map */
5213                 case 'M':
5214                 {
5215                         do_cmd_view_map();
5216                         break;
5217                 }
5218
5219                 /* Locate player on map */
5220                 case 'L':
5221                 {
5222                         do_cmd_locate();
5223                         break;
5224                 }
5225
5226                 /* Look around */
5227                 case 'l':
5228                 {
5229                         do_cmd_look();
5230                         break;
5231                 }
5232
5233                 /* Target monster or location */
5234                 case '*':
5235                 {
5236                         if (!p_ptr->wild_mode) do_cmd_target();
5237                         break;
5238                 }
5239
5240
5241
5242                 /*** Help and Such ***/
5243
5244                 /* Help */
5245                 case '?':
5246                 {
5247                         do_cmd_help();
5248                         break;
5249                 }
5250
5251                 /* Identify symbol */
5252                 case '/':
5253                 {
5254                         do_cmd_query_symbol();
5255                         break;
5256                 }
5257
5258                 /* Character description */
5259                 case 'C':
5260                 {
5261                         do_cmd_change_name();
5262                         break;
5263                 }
5264
5265
5266                 /*** System Commands ***/
5267
5268                 /* Hack -- User interface */
5269                 case '!':
5270                 {
5271                         (void)Term_user(0);
5272                         break;
5273                 }
5274
5275                 /* Single line from a pref file */
5276                 case '"':
5277                 {
5278                         do_cmd_pref();
5279                         break;
5280                 }
5281
5282                 case '$':
5283                 {
5284                         do_cmd_reload_autopick();
5285                         break;
5286                 }
5287
5288                 case '_':
5289                 {
5290                         do_cmd_edit_autopick();
5291                         break;
5292                 }
5293
5294                 /* Interact with macros */
5295                 case '@':
5296                 {
5297                         do_cmd_macros();
5298                         break;
5299                 }
5300
5301                 /* Interact with visuals */
5302                 case '%':
5303                 {
5304                         do_cmd_visuals();
5305                         do_cmd_redraw();
5306                         break;
5307                 }
5308
5309                 /* Interact with colors */
5310                 case '&':
5311                 {
5312                         do_cmd_colors();
5313                         do_cmd_redraw();
5314                         break;
5315                 }
5316
5317                 /* Interact with options */
5318                 case '=':
5319                 {
5320                         do_cmd_options();
5321                         (void)combine_and_reorder_home(STORE_HOME);
5322                         do_cmd_redraw();
5323                         break;
5324                 }
5325
5326                 /*** Misc Commands ***/
5327
5328                 /* Take notes */
5329                 case ':':
5330                 {
5331                         do_cmd_note();
5332                         break;
5333                 }
5334
5335                 /* Version info */
5336                 case 'V':
5337                 {
5338                         do_cmd_version();
5339                         break;
5340                 }
5341
5342                 /* Repeat level feeling */
5343                 case KTRL('F'):
5344                 {
5345                         if (!p_ptr->wild_mode) do_cmd_feeling();
5346                         break;
5347                 }
5348
5349                 /* Show previous message */
5350                 case KTRL('O'):
5351                 {
5352                         do_cmd_message_one();
5353                         break;
5354                 }
5355
5356                 /* Show previous messages */
5357                 case KTRL('P'):
5358                 {
5359                         do_cmd_messages(old_now_message);
5360                         break;
5361                 }
5362
5363                 /* Show quest status -KMW- */
5364                 case KTRL('Q'):
5365                 {
5366                         do_cmd_checkquest();
5367                         break;
5368                 }
5369
5370                 /* Redraw the screen */
5371                 case KTRL('R'):
5372                 {
5373                         now_message = old_now_message;
5374                         do_cmd_redraw();
5375                         break;
5376                 }
5377
5378 #ifndef VERIFY_SAVEFILE
5379
5380                 /* Hack -- Save and don't quit */
5381                 case KTRL('S'):
5382                 {
5383                         do_cmd_save_game(FALSE);
5384                         break;
5385                 }
5386
5387 #endif /* VERIFY_SAVEFILE */
5388
5389                 case KTRL('T'):
5390                 {
5391                         do_cmd_time();
5392                         break;
5393                 }
5394
5395                 /* Save and quit */
5396                 case KTRL('X'):
5397                 case SPECIAL_KEY_QUIT:
5398                 {
5399                         do_cmd_save_and_exit();
5400                         break;
5401                 }
5402
5403                 /* Quit (commit suicide) */
5404                 case 'Q':
5405                 {
5406                         do_cmd_suicide();
5407                         break;
5408                 }
5409
5410                 case '|':
5411                 {
5412                         do_cmd_nikki();
5413                         break;
5414                 }
5415
5416                 /* Check artifacts, uniques, objects */
5417                 case '~':
5418                 {
5419                         do_cmd_knowledge();
5420                         break;
5421                 }
5422
5423                 /* Load "screen dump" */
5424                 case '(':
5425                 {
5426                         do_cmd_load_screen();
5427                         break;
5428                 }
5429
5430                 /* Save "screen dump" */
5431                 case ')':
5432                 {
5433                         do_cmd_save_screen();
5434                         break;
5435                 }
5436
5437                 /* Record/stop "Movie" */
5438                 case ']':
5439                 {
5440                         prepare_movie_hooks();
5441                         break;
5442                 }
5443
5444                 /* Make random artifact list */
5445                 case KTRL('V'):
5446                 {
5447                         spoil_random_artifact("randifact.txt");
5448                         break;
5449                 }
5450
5451 #ifdef TRAVEL
5452                 case '`':
5453                 {
5454                         if (!p_ptr->wild_mode) do_cmd_travel();
5455                         if (p_ptr->special_defense & KATA_MUSOU)
5456                         {
5457                                 set_action(ACTION_NONE);
5458                         }
5459                         break;
5460                 }
5461 #endif
5462
5463                 /* Hack -- Unknown command */
5464                 default:
5465                 {
5466                         if (flush_failure) flush();
5467                         if (one_in_(2))
5468                         {
5469                                 char error_m[1024];
5470                                 sound(SOUND_ILLEGAL);
5471 #ifdef JP
5472                                 if (!get_rnd_line("error_j.txt", 0, error_m))
5473 #else
5474                                 if (!get_rnd_line("error.txt", 0, error_m))
5475 #endif
5476
5477                                         msg_print(error_m);
5478                         }
5479                         else
5480 #ifdef JP
5481 prt(" '?' ¤Ç¥Ø¥ë¥×¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£", 0, 0);
5482 #else
5483                                 prt("Type '?' for help.", 0, 0);
5484 #endif
5485
5486                         break;
5487                 }
5488         }
5489         if (!energy_use && !now_message)
5490                 now_message = old_now_message;
5491 }
5492
5493 /*!
5494  * @brief ¥â¥ó¥¹¥¿¡¼¼ï²¤¬Äà¤ì¤ë¼ï²¤«¤É¤¦¤«¤òȽÄꤹ¤ë¡£
5495  * @param r_idx È½Äꤷ¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²¤ÎID
5496  * @return Äà¤ì¤ëÂоݤʤé¤ÐTRUE¤òÊÖ¤¹
5497  */
5498 static bool monster_tsuri(int r_idx)
5499 {
5500         monster_race *r_ptr = &r_info[r_idx];
5501
5502         if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
5503                 return TRUE;
5504         else
5505                 return FALSE;
5506 }
5507
5508
5509 /*!
5510  * @brief ¥¢¥¤¥Æ¥à¤Î½ê»ý¼ïÎà¿ô¤¬Ä¶¤¨¤¿¾ì¹ç¤Ë¥¢¥¤¥Æ¥à¤ò¾²¤ËÍî¤È¤¹½èÍý / Hack -- Pack Overflow
5511  * @return ¤Ê¤·
5512  */
5513 static void pack_overflow(void)
5514 {
5515         if (inventory[INVEN_PACK].k_idx)
5516         {
5517                 char o_name[MAX_NLEN];
5518                 object_type *o_ptr;
5519
5520                 /* Is auto-destroy done? */
5521                 notice_stuff();
5522                 if (!inventory[INVEN_PACK].k_idx) return;
5523
5524                 /* Access the slot to be dropped */
5525                 o_ptr = &inventory[INVEN_PACK];
5526
5527                 /* Disturbing */
5528                 disturb(0, 1);
5529
5530                 /* Warning */
5531 #ifdef JP
5532                 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤¿¡ª");
5533 #else
5534                 msg_print("Your pack overflows!");
5535 #endif
5536
5537                 /* Describe */
5538                 object_desc(o_name, o_ptr, 0);
5539
5540                 /* Message */
5541 #ifdef JP
5542                 msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(INVEN_PACK));
5543 #else
5544                 msg_format("You drop %s (%c).", o_name, index_to_label(INVEN_PACK));
5545 #endif
5546
5547                 /* Drop it (carefully) near the player */
5548                 (void)drop_near(o_ptr, 0, py, px);
5549
5550                 /* Modify, Describe, Optimize */
5551                 inven_item_increase(INVEN_PACK, -255);
5552                 inven_item_describe(INVEN_PACK);
5553                 inven_item_optimize(INVEN_PACK);
5554
5555                 /* Handle "p_ptr->notice" */
5556                 notice_stuff();
5557
5558                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5559                 handle_stuff();
5560         }
5561 }
5562
5563 /*!
5564  * @brief ¥×¥ì¥¤¥ä¡¼¤Î¹ÔÆ°¥¨¥Í¥ë¥®¡¼¤¬½¼Å¶¤µ¤ì¤ë¡Ê¡á¥×¥ì¥¤¥ä¡¼¤Î¥¿¡¼¥ó¤¬²ó¤ë¡ËËè¤Ë¹Ô¤ï¤ì¤ë½èÍý  / process the effects per 100 energy at player speed.
5565  * @return ¤Ê¤·
5566  */
5567 static void process_upkeep_with_speed(void)
5568 {
5569         /* Give the player some energy */
5570         if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
5571         {
5572                 p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5573         }
5574         
5575         /* No turn yet */
5576         if (p_ptr->enchant_energy_need > 0) return;
5577         
5578         while (p_ptr->enchant_energy_need <= 0)
5579         {
5580                 /* Handle the player song */
5581                 if (!load) check_music();
5582
5583                 /* Hex - Handle the hex spells */
5584                 if (!load) check_hex();
5585                 if (!load) revenge_spell();
5586                 
5587                 /* There is some randomness of needed energy */
5588                 p_ptr->enchant_energy_need += ENERGY_NEED();
5589         }
5590 }
5591
5592 /*!
5593  * @brief ¥×¥ì¥¤¥ä¡¼¤Î¹ÔÆ°½èÍý / Process the player
5594  * @return ¤Ê¤·
5595  * @note
5596  * Notice the annoying code to handle "pack overflow", which\n
5597  * must come first just in case somebody manages to corrupt\n
5598  * the savefiles by clever use of menu commands or something.\n
5599  */
5600 static void process_player(void)
5601 {
5602         int i;
5603
5604         /*** Apply energy ***/
5605
5606         if (hack_mutation)
5607         {
5608 #ifdef JP
5609 msg_print("²¿¤«ÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
5610 #else
5611                 msg_print("You feel different!");
5612 #endif
5613
5614                 (void)gain_random_mutation(0);
5615                 hack_mutation = FALSE;
5616         }
5617
5618         if (p_ptr->inside_battle)
5619         {
5620                 for(i = 1; i < m_max; i++)
5621                 {
5622                         monster_type *m_ptr = &m_list[i];
5623
5624                         if (!m_ptr->r_idx) continue;
5625
5626                         /* Hack -- Detect monster */
5627                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
5628
5629                         /* Update the monster */
5630                         update_mon(i, FALSE);
5631                 }
5632                 prt_time();
5633         }
5634
5635         /* Give the player some energy */
5636         else if (!(load && p_ptr->energy_need <= 0))
5637         {
5638                 p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
5639         }
5640
5641         /* No turn yet */
5642         if (p_ptr->energy_need > 0) return;
5643         if (!command_rep) prt_time();
5644
5645         /*** Check for interupts ***/
5646
5647         /* Complete resting */
5648         if (resting < 0)
5649         {
5650                 /* Basic resting */
5651                 if (resting == -1)
5652                 {
5653                         /* Stop resting */
5654                         if ((p_ptr->chp == p_ptr->mhp) &&
5655                             (p_ptr->csp >= p_ptr->msp))
5656                         {
5657                                 set_action(ACTION_NONE);
5658                         }
5659                 }
5660
5661                 /* Complete resting */
5662                 else if (resting == -2)
5663                 {
5664                         /* Stop resting */
5665                         if ((p_ptr->chp == p_ptr->mhp) &&
5666                             (p_ptr->csp >= p_ptr->msp) &&
5667                             !p_ptr->blind && !p_ptr->confused &&
5668                             !p_ptr->poisoned && !p_ptr->afraid &&
5669                             !p_ptr->stun && !p_ptr->cut &&
5670                             !p_ptr->slow && !p_ptr->paralyzed &&
5671                             !p_ptr->image && !p_ptr->word_recall &&
5672                             !p_ptr->alter_reality)
5673                         {
5674                                 set_action(ACTION_NONE);
5675                         }
5676                 }
5677         }
5678
5679         if (p_ptr->action == ACTION_FISH)
5680         {
5681                 /* Delay */
5682                 Term_xtra(TERM_XTRA_DELAY, 10);
5683                 if (one_in_(1000))
5684                 {
5685                         int r_idx;
5686                         bool success = FALSE;
5687                         get_mon_num_prep(monster_tsuri,NULL);
5688                         r_idx = get_mon_num(dun_level ? dun_level : wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level);
5689                         msg_print(NULL);
5690                         if (r_idx && one_in_(2))
5691                         {
5692                                 int y, x;
5693                                 y = py+ddy[tsuri_dir];
5694                                 x = px+ddx[tsuri_dir];
5695                                 if (place_monster_aux(0, y, x, r_idx, PM_NO_KAGE))
5696                                 {
5697                                         char m_name[80];
5698                                         monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5699 #ifdef JP
5700                                         msg_format("%s¤¬Äà¤ì¤¿¡ª", m_name);
5701 #else
5702                                         msg_format("You have a good catch!", m_name);
5703 #endif
5704                                         success = TRUE;
5705                                 }
5706                         }
5707                         if (!success)
5708                         {
5709 #ifdef JP
5710                                 msg_print("±Â¤À¤±¿©¤ï¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª¤¯¤Ã¤½¡Á¡ª");
5711 #else
5712                                 msg_print("Damn!  The fish stole your bait!");
5713 #endif
5714                         }
5715                         disturb(0, 1);
5716                 }
5717         }
5718
5719         /* Handle "abort" */
5720         if (check_abort)
5721         {
5722                 /* Check for "player abort" (semi-efficiently for resting) */
5723                 if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
5724                 {
5725                         /* Do not wait */
5726                         inkey_scan = TRUE;
5727
5728                         /* Check for a key */
5729                         if (inkey())
5730                         {
5731                                 /* Flush input */
5732                                 flush();
5733
5734                                 /* Disturb */
5735                                 disturb(0, 1);
5736
5737                                 /* Hack -- Show a Message */
5738 #ifdef JP
5739 msg_print("ÃæÃǤ·¤Þ¤·¤¿¡£");
5740 #else
5741                                 msg_print("Canceled.");
5742 #endif
5743
5744                         }
5745                 }
5746         }
5747
5748         if (p_ptr->riding && !p_ptr->confused && !p_ptr->blind)
5749         {
5750                 monster_type *m_ptr = &m_list[p_ptr->riding];
5751                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5752
5753                 if (MON_CSLEEP(m_ptr))
5754                 {
5755                         char m_name[80];
5756
5757                         /* Recover fully */
5758                         (void)set_monster_csleep(p_ptr->riding, 0);
5759
5760                         /* Acquire the monster name */
5761                         monster_desc(m_name, m_ptr, 0);
5762 #ifdef JP
5763                         msg_format("%^s¤òµ¯¤³¤·¤¿¡£", m_name);
5764 #else
5765                         msg_format("You have waked %s up.", m_name);
5766 #endif
5767                 }
5768
5769                 if (MON_STUNNED(m_ptr))
5770                 {
5771                         /* Hack -- Recover from stun */
5772                         if (set_monster_stunned(p_ptr->riding,
5773                                 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
5774                         {
5775                                 char m_name[80];
5776
5777                                 /* Acquire the monster name */
5778                                 monster_desc(m_name, m_ptr, 0);
5779
5780                                 /* Dump a message */
5781 #ifdef JP
5782                                 msg_format("%^s¤òÛ¯Û°¾õÂÖ¤«¤éΩ¤Áľ¤é¤»¤¿¡£", m_name);
5783 #else
5784                                 msg_format("%^s is no longer stunned.", m_name);
5785 #endif
5786                         }
5787                 }
5788
5789                 if (MON_CONFUSED(m_ptr))
5790                 {
5791                         /* Hack -- Recover from confusion */
5792                         if (set_monster_confused(p_ptr->riding,
5793                                 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
5794                         {
5795                                 char m_name[80];
5796
5797                                 /* Acquire the monster name */
5798                                 monster_desc(m_name, m_ptr, 0);
5799
5800                                 /* Dump a message */
5801 #ifdef JP
5802                                 msg_format("%^s¤òº®Íð¾õÂÖ¤«¤éΩ¤Áľ¤é¤»¤¿¡£", m_name);
5803 #else
5804                                 msg_format("%^s is no longer confused.", m_name);
5805 #endif
5806                         }
5807                 }
5808
5809                 if (MON_MONFEAR(m_ptr))
5810                 {
5811                         /* Hack -- Recover from fear */
5812                         if (set_monster_monfear(p_ptr->riding,
5813                                 (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
5814                         {
5815                                 char m_name[80];
5816
5817                                 /* Acquire the monster name */
5818                                 monster_desc(m_name, m_ptr, 0);
5819
5820                                 /* Dump a message */
5821 #ifdef JP
5822                                 msg_format("%^s¤ò¶²Éݤ«¤éΩ¤Áľ¤é¤»¤¿¡£", m_name);
5823 #else
5824                                 msg_format("%^s is no longer fear.", m_name);
5825 #endif
5826                         }
5827                 }
5828
5829                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5830                 handle_stuff();
5831         }
5832         
5833         load = FALSE;
5834
5835         /* Fast */
5836         if (p_ptr->lightspeed)
5837         {
5838                 (void)set_lightspeed(p_ptr->lightspeed - 1, TRUE);
5839         }
5840         if ((p_ptr->pclass == CLASS_FORCETRAINER) && (p_ptr->magic_num1[0]))
5841         {
5842                 if (p_ptr->magic_num1[0] < 40)
5843                 {
5844                         p_ptr->magic_num1[0] = 0;
5845                 }
5846                 else p_ptr->magic_num1[0] -= 40;
5847                 p_ptr->update |= (PU_BONUS);
5848         }
5849         if (p_ptr->action == ACTION_LEARN)
5850         {
5851                 s32b cost = 0L;
5852                 u32b cost_frac = (p_ptr->msp + 30L) * 256L;
5853
5854                 /* Convert the unit (1/2^16) to (1/2^32) */
5855                 s64b_LSHIFT(cost, cost_frac, 16);
5856
5857  
5858                 if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, cost, cost_frac) < 0)
5859                 {
5860                         /* Mana run out */
5861                         p_ptr->csp = 0;
5862                         p_ptr->csp_frac = 0;
5863                         set_action(ACTION_NONE);
5864                 }
5865                 else
5866                 {
5867                         /* Reduce mana */
5868                         s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), cost, cost_frac);
5869                 }
5870                 p_ptr->redraw |= PR_MANA;
5871         }
5872
5873         if (p_ptr->special_defense & KATA_MASK)
5874         {
5875                 if (p_ptr->special_defense & KATA_MUSOU)
5876                 {
5877                         if (p_ptr->csp < 3)
5878                         {
5879                                 set_action(ACTION_NONE);
5880                         }
5881                         else
5882                         {
5883                                 p_ptr->csp -= 2;
5884                                 p_ptr->redraw |= (PR_MANA);
5885                         }
5886                 }
5887         }
5888
5889         /*** Handle actual user input ***/
5890
5891         /* Repeat until out of energy */
5892         while (p_ptr->energy_need <= 0)
5893         {
5894                 p_ptr->window |= PW_PLAYER;
5895                 p_ptr->sutemi = FALSE;
5896                 p_ptr->counter = FALSE;
5897                 now_damaged = FALSE;
5898
5899                 /* Handle "p_ptr->notice" */
5900                 notice_stuff();
5901
5902                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
5903                 handle_stuff();
5904
5905                 /* Place the cursor on the player */
5906                 move_cursor_relative(py, px);
5907
5908                 /* Refresh (optional) */
5909                 if (fresh_before) Term_fresh();
5910
5911
5912                 /* Hack -- Pack Overflow */
5913                 pack_overflow();
5914
5915
5916                 /* Hack -- cancel "lurking browse mode" */
5917                 if (!command_new) command_see = FALSE;
5918
5919
5920                 /* Assume free turn */
5921                 energy_use = 0;
5922
5923
5924                 if (p_ptr->inside_battle)
5925                 {
5926                         /* Place the cursor on the player */
5927                         move_cursor_relative(py, px);
5928
5929                         command_cmd = SPECIAL_KEY_BUILDING;
5930
5931                         /* Process the command */
5932                         process_command();
5933                 }
5934
5935                 /* Paralyzed or Knocked Out */
5936                 else if (p_ptr->paralyzed || (p_ptr->stun >= 100))
5937                 {
5938                         /* Take a turn */
5939                         energy_use = 100;
5940                 }
5941
5942                 /* Resting */
5943                 else if (p_ptr->action == ACTION_REST)
5944                 {
5945                         /* Timed rest */
5946                         if (resting > 0)
5947                         {
5948                                 /* Reduce rest count */
5949                                 resting--;
5950
5951                                 if (!resting) set_action(ACTION_NONE);
5952
5953                                 /* Redraw the state */
5954                                 p_ptr->redraw |= (PR_STATE);
5955                         }
5956
5957                         /* Take a turn */
5958                         energy_use = 100;
5959                 }
5960
5961                 /* Fishing */
5962                 else if (p_ptr->action == ACTION_FISH)
5963                 {
5964                         /* Take a turn */
5965                         energy_use = 100;
5966                 }
5967
5968                 /* Running */
5969                 else if (running)
5970                 {
5971                         /* Take a step */
5972                         run_step(0);
5973                 }
5974
5975 #ifdef TRAVEL
5976                 /* Traveling */
5977                 else if (travel.run)
5978                 {
5979                         /* Take a step */
5980                         travel_step();
5981                 }
5982 #endif
5983
5984                 /* Repeated command */
5985                 else if (command_rep)
5986                 {
5987                         /* Count this execution */
5988                         command_rep--;
5989
5990                         /* Redraw the state */
5991                         p_ptr->redraw |= (PR_STATE);
5992
5993                         /* Redraw stuff */
5994                         redraw_stuff();
5995
5996                         /* Hack -- Assume messages were seen */
5997                         msg_flag = FALSE;
5998
5999                         /* Clear the top line */
6000                         prt("", 0, 0);
6001
6002                         /* Process the command */
6003                         process_command();
6004                 }
6005
6006                 /* Normal command */
6007                 else
6008                 {
6009                         /* Place the cursor on the player */
6010                         move_cursor_relative(py, px);
6011
6012                         can_save = TRUE;
6013                         /* Get a command (normal) */
6014                         request_command(FALSE);
6015                         can_save = FALSE;
6016
6017                         /* Process the command */
6018                         process_command();
6019                 }
6020
6021
6022                 /* Hack -- Pack Overflow */
6023                 pack_overflow();
6024
6025
6026                 /*** Clean up ***/
6027
6028                 /* Significant */
6029                 if (energy_use)
6030                 {
6031                         /* Use some energy */
6032                         if (world_player || energy_use > 400)
6033                         {
6034                                 /* The Randomness is irrelevant */
6035                                 p_ptr->energy_need += energy_use * TURNS_PER_TICK / 10;
6036                         }
6037                         else
6038                         {
6039                                 /* There is some randomness of needed energy */
6040                                 p_ptr->energy_need += (s16b)((s32b)energy_use * ENERGY_NEED() / 100L);
6041                         }
6042
6043                         /* Hack -- constant hallucination */
6044                         if (p_ptr->image) p_ptr->redraw |= (PR_MAP);
6045
6046
6047                         /* Shimmer monsters if needed */
6048                         if (shimmer_monsters)
6049                         {
6050                                 /* Clear the flag */
6051                                 shimmer_monsters = FALSE;
6052
6053                                 /* Shimmer multi-hued monsters */
6054                                 for (i = 1; i < m_max; i++)
6055                                 {
6056                                         monster_type *m_ptr;
6057                                         monster_race *r_ptr;
6058
6059                                         /* Access monster */
6060                                         m_ptr = &m_list[i];
6061
6062                                         /* Skip dead monsters */
6063                                         if (!m_ptr->r_idx) continue;
6064
6065                                         /* Skip unseen monsters */
6066                                         if (!m_ptr->ml) continue;
6067
6068                                         /* Access the monster race */
6069                                         r_ptr = &r_info[m_ptr->ap_r_idx];
6070
6071                                         /* Skip non-multi-hued monsters */
6072                                         if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
6073                                                 continue;
6074
6075                                         /* Reset the flag */
6076                                         shimmer_monsters = TRUE;
6077
6078                                         /* Redraw regardless */
6079                                         lite_spot(m_ptr->fy, m_ptr->fx);
6080                                 }
6081                         }
6082
6083
6084                         /* Handle monster detection */
6085                         if (repair_monsters)
6086                         {
6087                                 /* Reset the flag */
6088                                 repair_monsters = FALSE;
6089
6090                                 /* Rotate detection flags */
6091                                 for (i = 1; i < m_max; i++)
6092                                 {
6093                                         monster_type *m_ptr;
6094
6095                                         /* Access monster */
6096                                         m_ptr = &m_list[i];
6097
6098                                         /* Skip dead monsters */
6099                                         if (!m_ptr->r_idx) continue;
6100
6101                                         /* Nice monsters get mean */
6102                                         if (m_ptr->mflag & MFLAG_NICE)
6103                                         {
6104                                                 /* Nice monsters get mean */
6105                                                 m_ptr->mflag &= ~(MFLAG_NICE);
6106                                         }
6107
6108                                         /* Handle memorized monsters */
6109                                         if (m_ptr->mflag2 & MFLAG2_MARK)
6110                                         {
6111                                                 /* Maintain detection */
6112                                                 if (m_ptr->mflag2 & MFLAG2_SHOW)
6113                                                 {
6114                                                         /* Forget flag */
6115                                                         m_ptr->mflag2 &= ~(MFLAG2_SHOW);
6116
6117                                                         /* Still need repairs */
6118                                                         repair_monsters = TRUE;
6119                                                 }
6120
6121                                                 /* Remove detection */
6122                                                 else
6123                                                 {
6124                                                         /* Forget flag */
6125                                                         m_ptr->mflag2 &= ~(MFLAG2_MARK);
6126
6127                                                         /* Assume invisible */
6128                                                         m_ptr->ml = FALSE;
6129
6130                                                         /* Update the monster */
6131                                                         update_mon(i, FALSE);
6132
6133                                                         if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
6134                                                         if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
6135
6136                                                         /* Redraw regardless */
6137                                                         lite_spot(m_ptr->fy, m_ptr->fx);
6138                                                 }
6139                                         }
6140                                 }
6141                         }
6142                         if (p_ptr->pclass == CLASS_IMITATOR)
6143                         {
6144                                 if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
6145                                 {
6146                                         p_ptr->mane_num--;
6147                                         for (i = 0; i < p_ptr->mane_num; i++)
6148                                         {
6149                                                 p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
6150                                                 p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
6151                                         }
6152                                 }
6153                                 new_mane = FALSE;
6154                                 p_ptr->redraw |= (PR_IMITATION);
6155                         }
6156                         if (p_ptr->action == ACTION_LEARN)
6157                         {
6158                                 new_mane = FALSE;
6159                                 p_ptr->redraw |= (PR_STATE);
6160                         }
6161
6162                         if (world_player && (p_ptr->energy_need > - 1000))
6163                         {
6164                                 /* Redraw map */
6165                                 p_ptr->redraw |= (PR_MAP);
6166
6167                                 /* Update monsters */
6168                                 p_ptr->update |= (PU_MONSTERS);
6169
6170                                 /* Window stuff */
6171                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
6172
6173 #ifdef JP
6174                                 msg_print("¡Ö»þ¤ÏÆ°¤­¤À¤¹¡Ä¡×");
6175 #else
6176                                 msg_print("You feel time flowing around you once more.");
6177 #endif
6178                                 msg_print(NULL);
6179                                 world_player = FALSE;
6180                                 p_ptr->energy_need = ENERGY_NEED();
6181
6182                                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6183                                 handle_stuff();
6184                         }
6185                 }
6186
6187                 /* Hack -- notice death */
6188                 if (!p_ptr->playing || p_ptr->is_dead)
6189                 {
6190                         world_player = FALSE;
6191                         break;
6192                 }
6193
6194                 /* Sniper */
6195                 if (energy_use && reset_concent) reset_concentration(TRUE);
6196
6197                 /* Handle "leaving" */
6198                 if (p_ptr->leaving) break;
6199         }
6200
6201         /* Update scent trail */
6202         update_smell();
6203 }
6204
6205 /*!
6206  * @brief ¸½ºß¥×¥ì¥¤¥ä¡¼¤¬¤¤¤ë¥À¥ó¥¸¥ç¥ó¤ÎÁ´ÂνèÍý / Interact with the current dungeon level.
6207  * @return ¤Ê¤·
6208  * @note
6209  * This function will not exit until the level is completed,\n
6210  * the user dies, or the game is terminated.\n
6211  */
6212 static void dungeon(bool load_game)
6213 {
6214         int quest_num = 0;
6215
6216         /* Set the base level */
6217         base_level = dun_level;
6218
6219         /* Reset various flags */
6220         hack_mind = FALSE;
6221
6222         /* Not leaving */
6223         p_ptr->leaving = FALSE;
6224
6225         /* Reset the "command" vars */
6226         command_cmd = 0;
6227
6228 #if 0 /* Don't reset here --- It's used for Arena */
6229         command_new = 0;
6230 #endif
6231
6232         command_rep = 0;
6233         command_arg = 0;
6234         command_dir = 0;
6235
6236
6237         /* Cancel the target */
6238         target_who = 0;
6239         pet_t_m_idx = 0;
6240         riding_t_m_idx = 0;
6241         ambush_flag = FALSE;
6242
6243         /* Cancel the health bar */
6244         health_track(0);
6245
6246         /* Check visual effects */
6247         shimmer_monsters = TRUE;
6248         shimmer_objects = TRUE;
6249         repair_monsters = TRUE;
6250         repair_objects = TRUE;
6251
6252
6253         /* Disturb */
6254         disturb(1, 1);
6255
6256         /* Get index of current quest (if any) */
6257         quest_num = quest_number(dun_level);
6258
6259         /* Inside a quest? */
6260         if (quest_num)
6261         {
6262                 /* Mark the quest monster */
6263                 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
6264         }
6265
6266         /* Track maximum player level */
6267         if (p_ptr->max_plv < p_ptr->lev)
6268         {
6269                 p_ptr->max_plv = p_ptr->lev;
6270         }
6271
6272
6273         /* Track maximum dungeon level (if not in quest -KMW-) */
6274         if ((max_dlv[dungeon_type] < dun_level) && !p_ptr->inside_quest)
6275         {
6276                 max_dlv[dungeon_type] = dun_level;
6277                 if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
6278         }
6279
6280         (void)calculate_upkeep();
6281
6282         /* Validate the panel */
6283         panel_bounds_center();
6284
6285         /* Verify the panel */
6286         verify_panel();
6287
6288         /* Flush messages */
6289         msg_print(NULL);
6290
6291
6292         /* Enter "xtra" mode */
6293         character_xtra = TRUE;
6294
6295         /* Window stuff */
6296         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
6297
6298         /* Redraw dungeon */
6299         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
6300
6301         /* Redraw map */
6302         p_ptr->redraw |= (PR_MAP);
6303
6304         /* Update stuff */
6305         p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6306
6307         /* Update lite/view */
6308         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
6309
6310         /* Update monsters */
6311         p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
6312
6313         /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6314         handle_stuff();
6315
6316         /* Leave "xtra" mode */
6317         character_xtra = FALSE;
6318
6319         /* Update stuff */
6320         p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6321
6322         /* Combine / Reorder the pack */
6323         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6324
6325         /* Handle "p_ptr->notice" */
6326         notice_stuff();
6327
6328         /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6329         handle_stuff();
6330
6331         /* Refresh */
6332         Term_fresh();
6333
6334         if (quest_num && (is_fixed_quest_idx(quest_num) &&
6335             !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
6336             !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
6337
6338         if (p_ptr->inside_battle)
6339         {
6340                 if (load_game)
6341                 {
6342                         p_ptr->energy_need = 0;
6343                         battle_monsters();
6344                 }
6345                 else
6346                 {
6347 #ifdef JP
6348 msg_print("»î¹ç³«»Ï¡ª");
6349 #else
6350                         msg_format("Ready..Fight!");
6351 #endif
6352                         msg_print(NULL);
6353                 }
6354         }
6355
6356         if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] > MUSIC_DETECT))
6357                 p_ptr->magic_num1[0] = MUSIC_DETECT;
6358
6359         /* Hack -- notice death or departure */
6360         if (!p_ptr->playing || p_ptr->is_dead) return;
6361
6362         /* Print quest message if appropriate */
6363         if (!p_ptr->inside_quest && (dungeon_type == DUNGEON_ANGBAND))
6364         {
6365                 quest_discovery(random_quest_number(dun_level));
6366                 p_ptr->inside_quest = random_quest_number(dun_level);
6367         }
6368         if ((dun_level == d_info[dungeon_type].maxdepth) && d_info[dungeon_type].final_guardian)
6369         {
6370                 if (r_info[d_info[dungeon_type].final_guardian].max_num)
6371 #ifdef JP
6372                         msg_format("¤³¤Î³¬¤Ë¤Ï%s¤Î¼ç¤Ç¤¢¤ë%s¤¬À³¤ó¤Ç¤¤¤ë¡£",
6373                                    d_name+d_info[dungeon_type].name, 
6374                                    r_name+r_info[d_info[dungeon_type].final_guardian].name);
6375 #else
6376                         msg_format("%^s lives in this level as the keeper of %s.",
6377                                            r_name+r_info[d_info[dungeon_type].final_guardian].name, 
6378                                            d_name+d_info[dungeon_type].name);
6379 #endif
6380         }
6381
6382         if (!load_game && (p_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(FALSE);
6383
6384         /*** Process this dungeon level ***/
6385
6386         /* Reset the monster generation level */
6387         monster_level = base_level;
6388
6389         /* Reset the object generation level */
6390         object_level = base_level;
6391
6392         hack_mind = TRUE;
6393
6394         if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
6395             (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
6396                 p_ptr->energy_need = 0;
6397
6398         /* Not leaving dungeon */
6399         p_ptr->leaving_dungeon = FALSE;
6400
6401         /* Initialize monster process */
6402         mproc_init();
6403
6404         /* Main loop */
6405         while (TRUE)
6406         {
6407                 /* Hack -- Compact the monster list occasionally */
6408                 if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
6409
6410                 /* Hack -- Compress the monster list occasionally */
6411                 if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
6412
6413
6414                 /* Hack -- Compact the object list occasionally */
6415                 if (o_cnt + 32 > max_o_idx) compact_objects(64);
6416
6417                 /* Hack -- Compress the object list occasionally */
6418                 if (o_cnt + 32 < o_max) compact_objects(0);
6419
6420                 
6421                 /* Process the player */
6422                 process_player();
6423                 
6424                 process_upkeep_with_speed();
6425
6426                 /* Handle "p_ptr->notice" */
6427                 notice_stuff();
6428
6429                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6430                 handle_stuff();
6431
6432                 /* Hack -- Hilite the player */
6433                 move_cursor_relative(py, px);
6434
6435                 /* Optional fresh */
6436                 if (fresh_after) Term_fresh();
6437
6438                 /* Hack -- Notice death or departure */
6439                 if (!p_ptr->playing || p_ptr->is_dead) break;
6440
6441                 /* Process all of the monsters */
6442                 process_monsters();
6443
6444                 /* Handle "p_ptr->notice" */
6445                 notice_stuff();
6446
6447                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6448                 handle_stuff();
6449
6450                 /* Hack -- Hilite the player */
6451                 move_cursor_relative(py, px);
6452
6453                 /* Optional fresh */
6454                 if (fresh_after) Term_fresh();
6455
6456                 /* Hack -- Notice death or departure */
6457                 if (!p_ptr->playing || p_ptr->is_dead) break;
6458
6459
6460                 /* Process the world */
6461                 process_world();
6462
6463                 /* Handle "p_ptr->notice" */
6464                 notice_stuff();
6465
6466                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
6467                 handle_stuff();
6468
6469                 /* Hack -- Hilite the player */
6470                 move_cursor_relative(py, px);
6471
6472                 /* Optional fresh */
6473                 if (fresh_after) Term_fresh();
6474
6475                 /* Hack -- Notice death or departure */
6476                 if (!p_ptr->playing || p_ptr->is_dead) break;
6477
6478                 /* Handle "leaving" */
6479                 if (p_ptr->leaving) break;
6480
6481                 /* Count game turns */
6482                 turn++;
6483
6484                 if (dungeon_turn < dungeon_turn_limit)
6485                 {
6486                         if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
6487                         else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
6488                 }
6489
6490                 prevent_turn_overflow();
6491
6492                 if (wild_regen) wild_regen--;
6493         }
6494
6495         /* Inside a quest and non-unique questor? */
6496         if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
6497         {
6498                 /* Un-mark the quest monster */
6499                 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
6500         }
6501
6502         /* Not save-and-quit and not dead? */
6503         if (p_ptr->playing && !p_ptr->is_dead)
6504         {
6505                 /*
6506                  * Maintain Unique monsters and artifact, save current
6507                  * floor, then prepare next floor
6508                  */
6509                 leave_floor();
6510
6511                 /* Forget the flag */
6512                 reinit_wilderness = FALSE;
6513         }
6514
6515         /* Write about current level on the play record once per level */
6516         write_level = TRUE;
6517 }
6518
6519
6520 /*!
6521  * @brief Á´¥æ¡¼¥¶¥×¥í¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤¹¤ë / Load some "user pref files"
6522  * @return ¤Ê¤·
6523  * @note
6524  * Modified by Arcum Dagsson to support
6525  * separate macro files for different realms.
6526  */
6527 static void load_all_pref_files(void)
6528 {
6529         char buf[1024];
6530
6531         /* Access the "user" pref file */
6532         sprintf(buf, "user.prf");
6533
6534         /* Process that file */
6535         process_pref_file(buf);
6536
6537         /* Access the "user" system pref file */
6538         sprintf(buf, "user-%s.prf", ANGBAND_SYS);
6539
6540         /* Process that file */
6541         process_pref_file(buf);
6542
6543         /* Access the "race" pref file */
6544         sprintf(buf, "%s.prf", rp_ptr->title);
6545
6546         /* Process that file */
6547         process_pref_file(buf);
6548
6549         /* Access the "class" pref file */
6550         sprintf(buf, "%s.prf", cp_ptr->title);
6551
6552         /* Process that file */
6553         process_pref_file(buf);
6554
6555         /* Access the "character" pref file */
6556         sprintf(buf, "%s.prf", player_base);
6557
6558         /* Process that file */
6559         process_pref_file(buf);
6560
6561         /* Access the "realm 1" pref file */
6562         if (p_ptr->realm1 != REALM_NONE)
6563         {
6564                 sprintf(buf, "%s.prf", realm_names[p_ptr->realm1]);
6565
6566                 /* Process that file */
6567                 process_pref_file(buf);
6568         }
6569
6570         /* Access the "realm 2" pref file */
6571         if (p_ptr->realm2 != REALM_NONE)
6572         {
6573                 sprintf(buf, "%s.prf", realm_names[p_ptr->realm2]);
6574
6575                 /* Process that file */
6576                 process_pref_file(buf);
6577         }
6578
6579
6580         /* Load an autopick preference file */
6581         autopick_load_pref(FALSE);
6582 }
6583
6584
6585 /*!
6586  * @brief ¥Ó¥Ã¥È¥»¥Ã¥È¤«¤é¥²¡¼¥à¥ª¥×¥·¥ç¥ó¤òŸ³«¤¹¤ë / Extract option variables from bit sets
6587  * @return ¤Ê¤·
6588  */
6589 void extract_option_vars(void)
6590 {
6591         int i;
6592
6593         for (i = 0; option_info[i].o_desc; i++)
6594         {
6595                 int os = option_info[i].o_set;
6596                 int ob = option_info[i].o_bit;
6597
6598                 /* Set the "default" options */
6599                 if (option_info[i].o_var)
6600                 {
6601                         /* Set */
6602                         if (option_flag[os] & (1L << ob))
6603                         {
6604                                 /* Set */
6605                                 (*option_info[i].o_var) = TRUE;
6606                         }
6607
6608                         /* Clear */
6609                         else
6610                         {
6611                                 /* Clear */
6612                                 (*option_info[i].o_var) = FALSE;
6613                         }
6614                 }
6615         }
6616 }
6617
6618
6619 /*!
6620  * @brief ¾Þ¶â¼ó¤È¤Ê¤ë¥æ¥Ë¡¼¥¯¤ò³ÎÄꤹ¤ë / Determine bounty uniques
6621  * @return ¤Ê¤·
6622  */
6623 void determine_bounty_uniques(void)
6624 {
6625         int          i, j, tmp;
6626         monster_race *r_ptr;
6627
6628         get_mon_num_prep(NULL, NULL);
6629         for (i = 0; i < MAX_KUBI; i++)
6630         {
6631                 while (1)
6632                 {
6633                         kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
6634                         r_ptr = &r_info[kubi_r_idx[i]];
6635
6636                         if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6637
6638                         if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
6639
6640                         if (r_ptr->rarity > 100) continue;
6641
6642                         if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
6643
6644                         for (j = 0; j < i; j++)
6645                                 if (kubi_r_idx[i] == kubi_r_idx[j]) break;
6646
6647                         if (j == i) break;
6648                 }
6649         }
6650
6651         /* Sort them */
6652         for (i = 0; i < MAX_KUBI - 1; i++)
6653         {
6654                 for (j = i; j < MAX_KUBI; j++)
6655                 {
6656                         if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
6657                         {
6658                                 tmp = kubi_r_idx[i];
6659                                 kubi_r_idx[i] = kubi_r_idx[j];
6660                                 kubi_r_idx[j] = tmp;
6661                         }
6662                 }
6663         }
6664 }
6665
6666
6667 /*!
6668  * @brief º£Æü¤Î¾Þ¶â¼ó¤ò³ÎÄꤹ¤ë / Determine today's bounty monster
6669  * @return ¤Ê¤·
6670  * @note conv_old is used if loaded 0.0.3 or older save file
6671  */
6672 void determine_today_mon(bool conv_old)
6673 {
6674         int max_dl = 3, i;
6675         bool old_inside_battle = p_ptr->inside_battle;
6676         monster_race *r_ptr;
6677
6678         if (!conv_old)
6679         {
6680                 for (i = 0; i < max_d_idx; i++)
6681                 {
6682                         if (max_dlv[i] < d_info[i].mindepth) continue;
6683                         if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
6684                 }
6685         }
6686         else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
6687
6688         p_ptr->inside_battle = TRUE;
6689         get_mon_num_prep(NULL, NULL);
6690
6691         while (1)
6692         {
6693                 today_mon = get_mon_num(max_dl);
6694                 r_ptr = &r_info[today_mon];
6695
6696                 if (r_ptr->flags1 & RF1_UNIQUE) continue;
6697                 if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
6698                 if (r_ptr->flags2 & RF2_MULTIPLY) continue;
6699                 if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
6700                 if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
6701                 if (r_ptr->rarity > 10) continue;
6702                 break;
6703         }
6704
6705         p_ptr->today_mon = 0;
6706         p_ptr->inside_battle = old_inside_battle;
6707 }
6708
6709 /*!
6710  * @brief 1¥²¡¼¥à¥×¥ì¥¤¤Î¼çÍץ롼¥Á¥ó / Actually play a game
6711  * @return ¤Ê¤·
6712  * @note
6713  * If the "new_game" parameter is true, then, after loading the
6714  * savefile, we will commit suicide, if necessary, to allow the
6715  * player to start a new game.
6716  */
6717 void play_game(bool new_game)
6718 {
6719         int i;
6720         bool load_game = TRUE;
6721         bool init_random_seed = FALSE;
6722
6723 #ifdef CHUUKEI
6724         if (chuukei_client)
6725         {
6726                 reset_visuals();
6727                 browse_chuukei();
6728                 return;
6729         }
6730
6731         else if (chuukei_server)
6732         {
6733                 prepare_chuukei_hooks();
6734         }
6735 #endif
6736
6737         if (browsing_movie)
6738         {
6739                 reset_visuals();
6740                 browse_movie();
6741                 return;
6742         }
6743
6744         hack_mutation = FALSE;
6745
6746         /* Hack -- Character is "icky" */
6747         character_icky = TRUE;
6748
6749         /* Make sure main term is active */
6750         Term_activate(angband_term[0]);
6751
6752         /* Initialise the resize hooks */
6753         angband_term[0]->resize_hook = resize_map;
6754
6755         for (i = 1; i < 8; i++)
6756         {
6757                 /* Does the term exist? */
6758                 if (angband_term[i])
6759                 {
6760                         /* Add the redraw on resize hook */
6761                         angband_term[i]->resize_hook = redraw_window;
6762                 }
6763         }
6764
6765         /* Hack -- turn off the cursor */
6766         (void)Term_set_cursor(0);
6767
6768
6769         /* Attempt to load */
6770         if (!load_player())
6771         {
6772                 /* Oops */
6773 #ifdef JP
6774 quit("¥»¡¼¥Ö¥Õ¥¡¥¤¥ë¤¬²õ¤ì¤Æ¤¤¤Þ¤¹");
6775 #else
6776                 quit("broken savefile");
6777 #endif
6778
6779         }
6780
6781         /* Extract the options */
6782         extract_option_vars();
6783
6784         /* Report waited score */
6785         if (p_ptr->wait_report_score)
6786         {
6787                 char buf[1024];
6788                 bool success;
6789
6790 #ifdef JP
6791                 if (!get_check_strict("ÂÔµ¡¤·¤Æ¤¤¤¿¥¹¥³¥¢ÅÐÏ¿¤òº£¹Ô¤Ê¤¤¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
6792 #else
6793                 if (!get_check_strict("Do you register score now? ", CHECK_NO_HISTORY))
6794 #endif
6795                         quit(0);
6796
6797                 /* Update stuff */
6798                 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
6799
6800                 /* Update stuff */
6801                 update_stuff();
6802
6803                 p_ptr->is_dead = TRUE;
6804
6805                 start_time = time(NULL);
6806
6807                 /* No suspending now */
6808                 signals_ignore_tstp();
6809                 
6810                 /* Hack -- Character is now "icky" */
6811                 character_icky = TRUE;
6812
6813                 /* Build the filename */
6814                 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6815
6816                 /* Open the high score file, for reading/writing */
6817                 highscore_fd = fd_open(buf, O_RDWR);
6818
6819                 /* Handle score, show Top scores */
6820                 success = send_world_score(TRUE);
6821
6822 #ifdef JP
6823                 if (!success && !get_check_strict("¥¹¥³¥¢ÅÐÏ¿¤òÄü¤á¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
6824 #else
6825                 if (!success && !get_check_strict("Do you give up score registration? ", CHECK_NO_HISTORY))
6826 #endif
6827                 {
6828 #ifdef JP
6829                         prt("°ú¤­Â³¤­ÂÔµ¡¤·¤Þ¤¹¡£", 0, 0);
6830 #else
6831                         prt("standing by for future registration...", 0, 0);
6832 #endif
6833                         (void)inkey();
6834                 }
6835                 else
6836                 {
6837                         p_ptr->wait_report_score = FALSE;
6838                         top_twenty();
6839 #ifdef JP
6840                         if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6841 #else
6842                         if (!save_player()) msg_print("death save failed!");
6843 #endif
6844                 }
6845                 /* Shut the high score file */
6846                 (void)fd_close(highscore_fd);
6847
6848                 /* Forget the high score fd */
6849                 highscore_fd = -1;
6850                 
6851                 /* Allow suspending now */
6852                 signals_handle_tstp();
6853
6854                 quit(0);
6855         }
6856
6857         creating_savefile = new_game;
6858
6859         /* Nothing loaded */
6860         if (!character_loaded)
6861         {
6862                 /* Make new player */
6863                 new_game = TRUE;
6864
6865                 /* The dungeon is not ready */
6866                 character_dungeon = FALSE;
6867
6868                 /* Prepare to init the RNG */
6869                 init_random_seed = TRUE;
6870
6871                 /* Initialize the saved floors data */
6872                 init_saved_floors(FALSE);
6873         }
6874
6875         /* Old game is loaded.  But new game is requested. */
6876         else if (new_game)
6877         {
6878                 /* Initialize the saved floors data */
6879                 init_saved_floors(TRUE);
6880         }
6881
6882         /* Process old character */
6883         if (!new_game)
6884         {
6885                 /* Process the player name */
6886                 process_player_name(FALSE);
6887         }
6888
6889         /* Init the RNG */
6890         if (init_random_seed)
6891         {
6892                 u32b seed;
6893
6894                 /* Basic seed */
6895                 seed = (time(NULL));
6896
6897 #ifdef SET_UID
6898
6899                 /* Mutate the seed on Unix machines */
6900                 seed = ((seed >> 3) * (getpid() << 1));
6901
6902 #endif
6903
6904                 /* Seed the RNG */
6905                 Rand_state_init(seed);
6906         }
6907
6908         /* Roll new character */
6909         if (new_game)
6910         {
6911                 /* The dungeon is not ready */
6912                 character_dungeon = FALSE;
6913
6914                 /* Start in town */
6915                 dun_level = 0;
6916                 p_ptr->inside_quest = 0;
6917                 p_ptr->inside_arena = FALSE;
6918                 p_ptr->inside_battle = FALSE;
6919
6920                 write_level = TRUE;
6921
6922                 /* Hack -- seed for flavors */
6923                 seed_flavor = randint0(0x10000000);
6924
6925                 /* Hack -- seed for town layout */
6926                 seed_town = randint0(0x10000000);
6927
6928                 /* Roll up a new character */
6929                 player_birth();
6930
6931                 counts_write(2,0);
6932                 p_ptr->count = 0;
6933
6934                 load = FALSE;
6935
6936                 determine_bounty_uniques();
6937                 determine_today_mon(FALSE);
6938
6939                 /* Initialize object array */
6940                 wipe_o_list();
6941         }
6942         else
6943         {
6944                 write_level = FALSE;
6945
6946 #ifdef JP
6947                 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "                            ----¥²¡¼¥àºÆ³«----");
6948 #else
6949                 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "                            ---- Restart Game ----");
6950 #endif
6951
6952 /*
6953  * 1.0.9 °ÊÁ°¤Ï¥»¡¼¥ÖÁ°¤Ë p_ptr->riding = -1 ¤È¤·¤Æ¤¤¤¿¤Î¤Ç¡¢ºÆÀßÄ꤬ɬÍפÀ¤Ã¤¿¡£
6954  * ¤â¤¦ÉÔÍפÀ¤¬¡¢°ÊÁ°¤Î¥»¡¼¥Ö¥Õ¥¡¥¤¥ë¤È¤Î¸ß´¹¤Î¤¿¤á¤Ë»Ä¤·¤Æ¤ª¤¯¡£
6955  */
6956                 if (p_ptr->riding == -1)
6957                 {
6958                         p_ptr->riding = 0;
6959                         for (i = m_max; i > 0; i--)
6960                         {
6961                                 if (player_bold(m_list[i].fy, m_list[i].fx))
6962                                 {
6963                                         p_ptr->riding = i;
6964                                         break;
6965                                 }
6966                         }
6967                 }
6968         }
6969
6970         creating_savefile = FALSE;
6971
6972         p_ptr->teleport_town = FALSE;
6973         p_ptr->sutemi = FALSE;
6974         world_monster = FALSE;
6975         now_damaged = FALSE;
6976         now_message = 0;
6977         start_time = time(NULL) - 1;
6978         record_o_name[0] = '\0';
6979
6980         /* Reset map panel */
6981         panel_row_min = cur_hgt;
6982         panel_col_min = cur_wid;
6983
6984         /* Sexy gal gets bonus to maximum weapon skill of whip */
6985         if (p_ptr->pseikaku == SEIKAKU_SEXY)
6986                 s_info[p_ptr->pclass].w_max[TV_HAFTED-TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER;
6987
6988         /* Fill the arrays of floors and walls in the good proportions */
6989         set_floor_and_wall(dungeon_type);
6990
6991         /* Flavor the objects */
6992         flavor_init();
6993
6994         /* Flash a message */
6995 #ifdef JP
6996 prt("¤ªÂÔ¤Á²¼¤µ¤¤...", 0, 0);
6997 #else
6998         prt("Please wait...", 0, 0);
6999 #endif
7000
7001
7002         /* Flush the message */
7003         Term_fresh();
7004
7005
7006         /* Hack -- Enter wizard mode */
7007         if (arg_wizard)
7008         {
7009                 if (enter_wizard_mode())
7010                 {
7011                         p_ptr->wizard = TRUE;
7012
7013                         if (p_ptr->is_dead || !py || !px)
7014                         {
7015                                 /* Initialize the saved floors data */
7016                                 init_saved_floors(TRUE);
7017
7018                                 /* Avoid crash */
7019                                 p_ptr->inside_quest = 0;
7020
7021                                 /* Avoid crash in update_view() */
7022                                 py = px = 10;
7023                         }
7024                 }
7025                 else if (p_ptr->is_dead)
7026                 {
7027                         quit("Already dead.");
7028                 }
7029         }
7030
7031         /* Initialize the town-buildings if necessary */
7032         if (!dun_level && !p_ptr->inside_quest)
7033         {
7034                 /* Init the wilderness */
7035
7036                 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
7037
7038                 /* Init the town */
7039                 init_flags = INIT_ONLY_BUILDINGS;
7040
7041                 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
7042
7043                 select_floor_music();
7044         }
7045
7046
7047         /* Generate a dungeon level if needed */
7048         if (!character_dungeon)
7049         {
7050                 change_floor();
7051         }
7052
7053         else
7054         {
7055                 /* HACK -- Restore from panic-save */
7056                 if (p_ptr->panic_save)
7057                 {
7058                         /* No player?  -- Try to regenerate floor */
7059                         if (!py || !px)
7060                         {
7061 #ifdef JP
7062                                 msg_print("¥×¥ì¥¤¥ä¡¼¤Î°ÌÃÖ¤¬¤ª¤«¤·¤¤¡£¥Õ¥í¥¢¤òºÆÀ¸À®¤·¤Þ¤¹¡£");
7063 #else
7064                                 msg_print("What a strange player location.  Regenerate the dungeon floor.");
7065 #endif
7066                                 change_floor();
7067                         }
7068
7069                         /* Still no player?  -- Try to locate random place */
7070                         if (!py || !px) py = px = 10;
7071
7072                         /* No longer in panic */
7073                         p_ptr->panic_save = 0;
7074                 }
7075         }
7076
7077         /* Character is now "complete" */
7078         character_generated = TRUE;
7079
7080
7081         /* Hack -- Character is no longer "icky" */
7082         character_icky = FALSE;
7083
7084
7085         if (new_game)
7086         {
7087                 char buf[80];
7088
7089 #ifdef JP
7090                 sprintf(buf, "%s¤Ë¹ß¤êΩ¤Ã¤¿¡£", map_name());
7091 #else
7092                 sprintf(buf, "You are standing in the %s.", map_name());
7093 #endif
7094                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
7095         }
7096
7097
7098         /* Start game */
7099         p_ptr->playing = TRUE;
7100
7101         /* Reset the visual mappings */
7102         reset_visuals();
7103
7104         /* Load the "pref" files */
7105         load_all_pref_files();
7106
7107         /* Give startup outfit (after loading pref files) */
7108         if (new_game)
7109         {
7110                 player_outfit();
7111         }
7112
7113         /* React to changes */
7114         Term_xtra(TERM_XTRA_REACT, 0);
7115
7116         /* Window stuff */
7117         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
7118
7119         /* Window stuff */
7120         p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
7121
7122         /* Window stuff */
7123         window_stuff();
7124
7125
7126         /* Set or clear "rogue_like_commands" if requested */
7127         if (arg_force_original) rogue_like_commands = FALSE;
7128         if (arg_force_roguelike) rogue_like_commands = TRUE;
7129
7130         /* Hack -- Enforce "delayed death" */
7131         if (p_ptr->chp < 0) p_ptr->is_dead = TRUE;
7132
7133         if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
7134
7135         if (new_game && ((p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BEASTMASTER)))
7136         {
7137                 monster_type *m_ptr;
7138                 int pet_r_idx = ((p_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE);
7139                 monster_race *r_ptr = &r_info[pet_r_idx];
7140                 place_monster_aux(0, py, px - 1, pet_r_idx,
7141                                   (PM_FORCE_PET | PM_NO_KAGE));
7142                 m_ptr = &m_list[hack_m_idx_ii];
7143                 m_ptr->mspeed = r_ptr->speed;
7144                 m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
7145                 m_ptr->max_maxhp = m_ptr->maxhp;
7146                 m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
7147                 m_ptr->dealt_damage = 0;
7148                 m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
7149         }
7150
7151         (void)combine_and_reorder_home(STORE_HOME);
7152         (void)combine_and_reorder_home(STORE_MUSEUM);
7153
7154         select_floor_music();
7155
7156         /* Process */
7157         while (TRUE)
7158         {
7159                 /* Process the level */
7160                 dungeon(load_game);
7161
7162                 /* Handle "p_ptr->notice" */
7163                 notice_stuff();
7164
7165                 /* Hack -- prevent "icky" message */
7166                 character_xtra = TRUE;
7167
7168                 /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
7169                 handle_stuff();
7170
7171                 character_xtra = FALSE;
7172
7173                 /* Cancel the target */
7174                 target_who = 0;
7175
7176                 /* Cancel the health bar */
7177                 health_track(0);
7178
7179
7180                 /* Forget the lite */
7181                 forget_lite();
7182
7183                 /* Forget the view */
7184                 forget_view();
7185
7186                 /* Forget the view */
7187                 clear_mon_lite();
7188
7189                 /* Handle "quit and save" */
7190                 if (!p_ptr->playing && !p_ptr->is_dead) break;
7191
7192                 /* Erase the old cave */
7193                 wipe_o_list();
7194                 if (!p_ptr->is_dead) wipe_m_list();
7195
7196
7197                 /* XXX XXX XXX */
7198                 msg_print(NULL);
7199
7200                 load_game = FALSE;
7201
7202                 /* Accidental Death */
7203                 if (p_ptr->playing && p_ptr->is_dead)
7204                 {
7205                         if (p_ptr->inside_arena)
7206                         {
7207                                 p_ptr->inside_arena = FALSE;
7208                                 if (p_ptr->arena_number > MAX_ARENA_MONS)
7209                                         p_ptr->arena_number++;
7210                                 else
7211                                         p_ptr->arena_number = -1 - p_ptr->arena_number;
7212                                 p_ptr->is_dead = FALSE;
7213                                 p_ptr->chp = 0;
7214                                 p_ptr->chp_frac = 0;
7215                                 p_ptr->exit_bldg = TRUE;
7216                                 reset_tim_flags();
7217
7218                                 /* Leave through the exit */
7219                                 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT);
7220
7221                                 /* prepare next floor */
7222                                 leave_floor();
7223                         }
7224                         else
7225                         {
7226                                 /* Mega-Hack -- Allow player to cheat death */
7227 #ifdef JP
7228                                 if ((p_ptr->wizard || cheat_live) && !get_check("»à¤Ë¤Þ¤¹¤«? "))
7229 #else
7230                                 if ((p_ptr->wizard || cheat_live) && !get_check("Die? "))
7231 #endif
7232                                 {
7233                                         /* Mark social class, reset age, if needed */
7234                                         if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
7235
7236                                         /* Increase age */
7237                                         p_ptr->age++;
7238
7239                                         /* Mark savefile */
7240                                         p_ptr->noscore |= 0x0001;
7241
7242                                         /* Message */
7243 #ifdef JP
7244                                         msg_print("¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤ËÇ°¤òÁ÷¤ê¡¢»à¤òµ½¤¤¤¿¡£");
7245 #else
7246                                         msg_print("You invoke wizard mode and cheat death.");
7247 #endif
7248                                         msg_print(NULL);
7249
7250                                         /* Restore hit points */
7251                                         p_ptr->chp = p_ptr->mhp;
7252                                         p_ptr->chp_frac = 0;
7253
7254                                         if (p_ptr->pclass == CLASS_MAGIC_EATER)
7255                                         {
7256                                                 for (i = 0; i < EATER_EXT*2; i++)
7257                                                 {
7258                                                         p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
7259                                                 }
7260                                                 for (; i < EATER_EXT*3; i++)
7261                                                 {
7262                                                         p_ptr->magic_num1[i] = 0;
7263                                                 }
7264                                         }
7265                                         /* Restore spell points */
7266                                         p_ptr->csp = p_ptr->msp;
7267                                         p_ptr->csp_frac = 0;
7268
7269                                         /* Hack -- cancel recall */
7270                                         if (p_ptr->word_recall)
7271                                         {
7272                                                 /* Message */
7273 #ifdef JP
7274                                                 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
7275 #else
7276                                                 msg_print("A tension leaves the air around you...");
7277 #endif
7278
7279                                                 msg_print(NULL);
7280
7281                                                 /* Hack -- Prevent recall */
7282                                                 p_ptr->word_recall = 0;
7283                                                 p_ptr->redraw |= (PR_STATUS);
7284                                         }
7285
7286                                         /* Hack -- cancel alter */
7287                                         if (p_ptr->alter_reality)
7288                                         {
7289                                                 /* Hack -- Prevent alter */
7290                                                 p_ptr->alter_reality = 0;
7291                                                 p_ptr->redraw |= (PR_STATUS);
7292                                         }
7293
7294                                         /* Note cause of death XXX XXX XXX */
7295 #ifdef JP
7296                                         (void)strcpy(p_ptr->died_from, "»à¤Îµ½¤­");
7297 #else
7298                                         (void)strcpy(p_ptr->died_from, "Cheating death");
7299 #endif
7300
7301                                         /* Do not die */
7302                                         p_ptr->is_dead = FALSE;
7303
7304                                         /* Hack -- Healing */
7305                                         (void)set_blind(0);
7306                                         (void)set_confused(0);
7307                                         (void)set_poisoned(0);
7308                                         (void)set_afraid(0);
7309                                         (void)set_paralyzed(0);
7310                                         (void)set_image(0);
7311                                         (void)set_stun(0);
7312                                         (void)set_cut(0);
7313
7314                                         /* Hack -- Prevent starvation */
7315                                         (void)set_food(PY_FOOD_MAX - 1);
7316
7317                                         dun_level = 0;
7318                                         p_ptr->inside_arena = FALSE;
7319                                         p_ptr->inside_battle = FALSE;
7320                                         leaving_quest = 0;
7321                                         p_ptr->inside_quest = 0;
7322                                         if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
7323                                         dungeon_type = 0;
7324                                         if (lite_town || vanilla_town)
7325                                         {
7326                                                 p_ptr->wilderness_y = 1;
7327                                                 p_ptr->wilderness_x = 1;
7328                                                 if (vanilla_town)
7329                                                 {
7330                                                         p_ptr->oldpy = 10;
7331                                                         p_ptr->oldpx = 34;
7332                                                 }
7333                                                 else
7334                                                 {
7335                                                         p_ptr->oldpy = 33;
7336                                                         p_ptr->oldpx = 131;
7337                                                 }
7338                                         }
7339                                         else
7340                                         {
7341                                                 p_ptr->wilderness_y = 48;
7342                                                 p_ptr->wilderness_x = 5;
7343                                                 p_ptr->oldpy = 33;
7344                                                 p_ptr->oldpx = 131;
7345                                         }
7346
7347                                         /* Leaving */
7348                                         p_ptr->wild_mode = FALSE;
7349                                         p_ptr->leaving = TRUE;
7350
7351 #ifdef JP
7352                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "                            ¤·¤«¤·¡¢À¸¤­Ê֤ä¿¡£");
7353 #else
7354                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "                            but revived.");
7355 #endif
7356
7357                                         /* Prepare next floor */
7358                                         leave_floor();
7359                                         wipe_m_list();
7360                                 }
7361                         }
7362                 }
7363
7364                 /* Handle "death" */
7365                 if (p_ptr->is_dead) break;
7366
7367                 /* Make a new level */
7368                 change_floor();
7369         }
7370
7371         /* Close stuff */
7372         close_game();
7373
7374         /* Quit */
7375         quit(NULL);
7376 }
7377
7378 /*!
7379  * @brief ¥²¡¼¥à¥¿¡¼¥ó¤«¤é¤Î¼Â»þ´Ö´¹»»¤ò¹Ô¤¦¤¿¤á¤ÎÊäÀµ¤ò¤«¤±¤ë
7380  * @param hoge ¥²¡¼¥à¥¿¡¼¥ó
7381  * @details ¥¢¥ó¥Ç¥Ã¥É¼ï²¤Ï18:00¤«¤é¥²¡¼¥à¤ò³«»Ï¤¹¤ë¤Î¤Ç¡¢¤³¤Î½¤Àµ¤òͽ¤á¹Ô¤¦¡£
7382  * @return ½¤Àµ¤ò¤«¤±¤¿¸å¤Î¥²¡¼¥à¥¿¡¼¥ó
7383  */
7384 s32b turn_real(s32b hoge)
7385 {
7386         switch (p_ptr->start_race)
7387         {
7388         case RACE_VAMPIRE:
7389         case RACE_SKELETON:
7390         case RACE_ZOMBIE:
7391         case RACE_SPECTRE:
7392                 return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
7393         default:
7394                 return hoge;
7395         }
7396 }
7397
7398 /*!
7399  * @brief ¥¿¡¼¥ó¤Î¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤ËÂФ¹¤ëÂнè
7400  * @details ¥¿¡¼¥óµÚ¤Ó¥¿¡¼¥ó¤òµ­Ï¿¤¹¤ëÊÑ¿ô¤ò¥¿¡¼¥ó¤Î¸Â³¦¤Î1ÆüÁ°¤Þ¤Ç´¬¤­Ì᤹.
7401  * @return ½¤Àµ¤ò¤«¤±¤¿¸å¤Î¥²¡¼¥à¥¿¡¼¥ó
7402  */
7403 void prevent_turn_overflow(void)
7404 {
7405         int rollback_days, i, j;
7406         s32b rollback_turns;
7407
7408         if (turn < turn_limit) return;
7409
7410         rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
7411         rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
7412
7413         if (turn > rollback_turns) turn -= rollback_turns;
7414         else turn = 1; /* Paranoia */
7415         if (old_turn > rollback_turns) old_turn -= rollback_turns;
7416         else old_turn = 1;
7417         if (old_battle > rollback_turns) old_battle -= rollback_turns;
7418         else old_battle = 1;
7419         if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
7420         else p_ptr->feeling_turn = 1;
7421
7422         for (i = 1; i < max_towns; i++)
7423         {
7424                 for (j = 0; j < MAX_STORES; j++)
7425                 {
7426                         store_type *st_ptr = &town[i].store[j];
7427
7428                         if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
7429                         {
7430                                 st_ptr->last_visit -= rollback_turns;
7431                                 if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
7432                         }
7433
7434                         if (st_ptr->store_open)
7435                         {
7436                                 st_ptr->store_open -= rollback_turns;
7437                                 if (st_ptr->store_open < 1) st_ptr->store_open = 1;
7438                         }
7439                 }
7440         }
7441 }