OSDN Git Service

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