OSDN Git Service

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