OSDN Git Service

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