OSDN Git Service

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