OSDN Git Service

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