OSDN Git Service

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