OSDN Git Service

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