OSDN Git Service

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