OSDN Git Service

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