OSDN Git Service

make_screen_dump()を使うコードを #ifdef WORLD_SCORE に入れた。
[hengbandforosx/hengbandosx.git] / src / effects.c
1 /* File: effects.c */
2
3 /* Purpose: effects of various "objects" */
4
5 /*
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research, and
9  * not for profit purposes provided that this copyright and statement are
10  * included in all such copies.
11  */
12
13 #include "angband.h"
14
15 void set_action(int typ)
16 {
17         if (typ == p_ptr->action)
18         {
19                 return;
20         }
21         else
22         {
23                 switch(p_ptr->action)
24                 {
25                         case ACTION_SEARCH:
26                         {
27 #ifdef JP
28                                 msg_print("õº÷¤ò¤ä¤á¤¿¡£");
29 #else
30                                 msg_print("You no longer walk carefully.");
31 #endif
32                                 p_ptr->redraw |= (PR_SPEED);
33                                 break;
34                         }
35                         case ACTION_REST:
36                         {
37                                 resting = 0;
38                                 break;
39                         }
40                         case ACTION_LEARN:
41                         {
42 #ifdef JP
43                                 msg_print("³Ø½¬¤ò¤ä¤á¤¿¡£");
44 #else
45                                 msg_print("You stop Learning");
46 #endif
47                                 new_mane = FALSE;
48                                 break;
49                         }
50                         case ACTION_KAMAE:
51                         {
52 #ifdef JP
53                                 msg_print("¹½¤¨¤ò¤È¤¤¤¿¡£");
54 #else
55                                 msg_print("You stop assuming the posture.");
56 #endif
57                                 p_ptr->special_defense &= ~(KAMAE_MASK);
58                                 break;
59                         }
60                         case ACTION_KATA:
61                         {
62 #ifdef JP
63                                 msg_print("·¿¤òÊø¤·¤¿¡£");
64 #else
65                                 msg_print("You stop assuming the posture.");
66 #endif
67                                 p_ptr->special_defense &= ~(KATA_MASK);
68                                 p_ptr->update |= (PU_MONSTERS);
69                                 p_ptr->redraw |= (PR_STATUS);
70                                 break;
71                         }
72                         case ACTION_SING:
73                         {
74 #ifdef JP
75                                 msg_print("²Î¤¦¤Î¤ò¤ä¤á¤¿¡£");
76 #else
77                                 msg_print("You stop singing.");
78 #endif
79                                 break;
80                         }
81                         case ACTION_HAYAGAKE:
82                         {
83 #ifdef JP
84                                 msg_print("­¤¬½Å¤¯¤Ê¤Ã¤¿¡£");
85 #else
86                                 msg_print("You are no longer walking extremely fast.");
87 #endif
88                                 break;
89                         }
90                 }
91         }
92
93         p_ptr->action = typ;
94
95         switch(p_ptr->action)
96         {
97                 case ACTION_SEARCH:
98                 {
99 #ifdef JP
100                         msg_print("Ãí°Õ¿¼¤¯Ê⤭»Ï¤á¤¿¡£");
101 #else
102                         msg_print("You began to walk carefully.");
103 #endif
104                         p_ptr->redraw |= (PR_SPEED);
105                         break;
106                 }
107                 case ACTION_LEARN:
108                 {
109 #ifdef JP
110                         msg_print("³Ø½¬¤ò»Ï¤á¤¿¡£");
111 #else
112                         msg_print("You began Learning");
113 #endif
114                         break;
115                 }
116                 case ACTION_FISH:
117                 {
118 #ifdef JP
119                         msg_print("¿åÌ̤˻å¤ò¿â¤é¤·¤¿¡¥¡¥¡¥");
120 #else
121                         msg_print("You began fishing...");
122 #endif
123                         break;
124                 }
125                 case ACTION_HAYAGAKE:
126                 {
127 #ifdef JP
128                         msg_print("­¤¬±©¤Î¤è¤¦¤Ë·Ú¤¯¤Ê¤Ã¤¿¡£");
129 #else
130                         msg_print("You began to walk extremely fast.");
131 #endif
132                         break;
133                 }
134                 default:
135                 {
136                         break;
137                 }
138         }
139
140         /* Recalculate bonuses */
141         p_ptr->update |= (PU_BONUS);
142
143         /* Redraw the state */
144         p_ptr->redraw |= (PR_STATE);
145 }
146
147 /* reset timed flags */
148 void reset_tim_flags(void)
149 {
150         p_ptr->fast = 0;            /* Timed -- Fast */
151         p_ptr->lightspeed = 0;
152         p_ptr->slow = 0;            /* Timed -- Slow */
153         p_ptr->blind = 0;           /* Timed -- Blindness */
154         p_ptr->paralyzed = 0;       /* Timed -- Paralysis */
155         p_ptr->confused = 0;        /* Timed -- Confusion */
156         p_ptr->afraid = 0;          /* Timed -- Fear */
157         p_ptr->image = 0;           /* Timed -- Hallucination */
158         p_ptr->poisoned = 0;        /* Timed -- Poisoned */
159         p_ptr->cut = 0;             /* Timed -- Cut */
160         p_ptr->stun = 0;            /* Timed -- Stun */
161
162         p_ptr->protevil = 0;        /* Timed -- Protection */
163         p_ptr->invuln = 0;          /* Timed -- Invulnerable */
164         p_ptr->ult_res = 0;
165         p_ptr->hero = 0;            /* Timed -- Heroism */
166         p_ptr->shero = 0;           /* Timed -- Super Heroism */
167         p_ptr->shield = 0;          /* Timed -- Shield Spell */
168         p_ptr->blessed = 0;         /* Timed -- Blessed */
169         p_ptr->tim_invis = 0;       /* Timed -- Invisibility */
170         p_ptr->tim_infra = 0;       /* Timed -- Infra Vision */
171         p_ptr->tim_regen = 0;       /* Timed -- Regeneration */
172         p_ptr->tim_stealth = 0;     /* Timed -- Stealth */
173         p_ptr->tim_esp = 0;
174         p_ptr->tim_ffall = 0;
175         p_ptr->tim_sh_touki = 0;
176         p_ptr->tim_sh_fire = 0;
177         p_ptr->resist_magic = 0;
178         p_ptr->tsuyoshi = 0;
179         p_ptr->kabenuke = 0;
180         p_ptr->tim_res_nether = 0;
181         p_ptr->tim_res_time = 0;
182         p_ptr->tim_mimic = 0;
183         p_ptr->mimic_form = 0;
184         p_ptr->tim_reflect = 0;
185         p_ptr->multishadow = 0;
186         p_ptr->dustrobe = 0;
187         p_ptr->action = ACTION_NONE;
188
189
190         p_ptr->oppose_acid = 0;     /* Timed -- oppose acid */
191         p_ptr->oppose_elec = 0;     /* Timed -- oppose lightning */
192         p_ptr->oppose_fire = 0;     /* Timed -- oppose heat */
193         p_ptr->oppose_cold = 0;     /* Timed -- oppose cold */
194         p_ptr->oppose_pois = 0;     /* Timed -- oppose poison */
195
196         p_ptr->word_recall = FALSE;
197         p_ptr->sutemi = FALSE;
198         p_ptr->counter = FALSE;
199         p_ptr->ele_attack = 0;
200         p_ptr->ele_immune = 0;
201         p_ptr->special_attack = 0L;
202         p_ptr->special_defense = 0L;
203
204         while(p_ptr->energy > 99) p_ptr->energy -= 100;
205         world_player = FALSE;
206
207         if (prace_is_(RACE_DEMON) && (p_ptr->lev > 44)) p_ptr->oppose_fire = 1;
208         if ((p_ptr->pclass == CLASS_NINJA) && (p_ptr->lev > 44)) p_ptr->oppose_pois = 1;
209         if (p_ptr->pclass == CLASS_BERSERKER) p_ptr->shero = 1;
210
211         if (p_ptr->riding)
212         {
213                 m_list[p_ptr->riding].fast = 0;
214                 m_list[p_ptr->riding].slow = 0;
215                 m_list[p_ptr->riding].invulner = 0;
216         }
217
218         if (p_ptr->pclass == CLASS_BARD)
219         {
220                 p_ptr->magic_num1[0] = 0;
221                 p_ptr->magic_num2[0] = 0;
222         }
223 }
224
225
226 /*
227  * Set "p_ptr->tim_mimic", and "p_ptr->mimic_form",
228  * notice observable changes
229  */
230 bool set_mimic(int v, int p, bool do_dec)
231 {
232         bool notice = FALSE;
233
234         /* Hack -- Force good values */
235         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
236
237         if (death) return FALSE;
238
239         /* Open */
240         if (v)
241         {
242                 if (p_ptr->tim_mimic && (p_ptr->mimic_form == p) && !do_dec)
243                 {
244                         if (p_ptr->tim_mimic > v) return FALSE;
245                 }
246                 else if ((!p_ptr->tim_mimic) || (p_ptr->mimic_form != p))
247                 {
248 #ifdef JP
249                         msg_print("¼«Ê¬¤ÎÂΤ¬ÊѤï¤Ã¤Æ¤æ¤¯¤Î¤ò´¶¤¸¤¿¡£");
250 #else
251                         msg_print("You feel that your body change.");
252 #endif
253                         p_ptr->mimic_form=p;
254                         notice = TRUE;
255                 }
256         }
257
258         /* Shut */
259         else
260         {
261                 if (p_ptr->tim_mimic)
262                 {
263 #ifdef JP
264                         msg_print("ÊѿȤ¬²ò¤±¤¿¡£");
265 #else
266                         msg_print("You are no longer transformed.");
267 #endif
268                         if (p_ptr->mimic_form == MIMIC_DEMON) set_oppose_fire(0, TRUE);
269                         p_ptr->mimic_form=0;
270                         notice = TRUE;
271                         p = 0;
272                 }
273         }
274
275         /* Use the value */
276         p_ptr->tim_mimic = v;
277
278         /* Nothing to notice */
279         if (!notice)
280                 return (FALSE);
281
282         /* Disturb */
283         if (disturb_state)
284                 disturb(0, 0);
285
286         /* Redraw title */
287         p_ptr->redraw |= (PR_BASIC | PR_STATUS);
288
289         /* Recalculate bonuses */
290         p_ptr->update |= (PU_BONUS | PU_HP);
291
292         handle_stuff();
293
294         /* Result */
295         return (TRUE);
296 }
297
298 /*
299  * Set "p_ptr->blind", notice observable changes
300  *
301  * Note the use of "PU_UN_LITE" and "PU_UN_VIEW", which is needed to
302  * memorize any terrain features which suddenly become "visible".
303  * Note that blindness is currently the only thing which can affect
304  * "player_can_see_bold()".
305  */
306 bool set_blind(int v)
307 {
308         bool notice = FALSE;
309
310         /* Hack -- Force good values */
311         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
312
313         if (death) return FALSE;
314
315         /* Open */
316         if (v)
317         {
318                 if (!p_ptr->blind)
319                 {
320                         if (p_ptr->prace == RACE_ANDROID)
321                         {
322 #ifdef JP
323 msg_print("¥»¥ó¥µ¡¼¤ò¤ä¤é¤ì¤¿¡ª");
324 #else
325                                 msg_print("You are blind!");
326 #endif
327                         }
328                         else
329                         {
330 #ifdef JP
331 msg_print("Ìܤ¬¸«¤¨¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
332 #else
333                                 msg_print("You are blind!");
334 #endif
335                         }
336
337                         notice = TRUE;
338                         chg_virtue(V_ENLIGHTEN, -1);
339                 }
340         }
341
342         /* Shut */
343         else
344         {
345                 if (p_ptr->blind)
346                 {
347                         if (p_ptr->prace == RACE_ANDROID)
348                         {
349 #ifdef JP
350 msg_print("¥»¥ó¥µ¡¼¤¬Éüµì¤·¤¿¡£");
351 #else
352                                 msg_print("You can see again.");
353 #endif
354                         }
355                         else
356                         {
357 #ifdef JP
358 msg_print("¤ä¤Ã¤ÈÌܤ¬¸«¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
359 #else
360                                 msg_print("You can see again.");
361 #endif
362                         }
363
364                         notice = TRUE;
365                 }
366         }
367
368         /* Use the value */
369         p_ptr->blind = v;
370
371         /* Redraw status bar */
372         p_ptr->redraw |= (PR_STATUS);
373
374         /* Nothing to notice */
375         if (!notice) return (FALSE);
376
377         /* Disturb */
378         if (disturb_state) disturb(0, 0);
379
380         /* Fully update the visuals */
381         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_MONSTERS);
382
383         /* Redraw map */
384         p_ptr->redraw |= (PR_MAP);
385
386         /* Window stuff */
387         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
388
389         /* Handle stuff */
390         handle_stuff();
391
392         /* Result */
393         return (TRUE);
394 }
395
396
397 /*
398  * Set "p_ptr->confused", notice observable changes
399  */
400 bool set_confused(int v)
401 {
402         bool notice = FALSE;
403
404         /* Hack -- Force good values */
405         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
406
407         if (death) return FALSE;
408
409         /* Open */
410         if (v)
411         {
412                 if (!p_ptr->confused)
413                 {
414 #ifdef JP
415 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤¿¡ª");
416 #else
417                         msg_print("You are confused!");
418 #endif
419
420                         if (p_ptr->action == ACTION_KAMAE)
421                         {
422 #ifdef JP
423                                 msg_print("¹½¤¨¤¬¤È¤±¤¿¡£");
424 #else
425                                 msg_print("Your posture gets loose.");
426 #endif
427                                 p_ptr->special_defense &= ~(KAMAE_MASK);
428                                 p_ptr->update |= (PU_BONUS);
429                                 p_ptr->redraw |= (PR_STATE);
430                                 p_ptr->action = ACTION_NONE;
431                         }
432                         else if (p_ptr->action == ACTION_KATA)
433                         {
434 #ifdef JP
435                                 msg_print("·¿¤¬Êø¤ì¤¿¡£");
436 #else
437                                 msg_print("Your posture gets loose.");
438 #endif
439                                 p_ptr->special_defense &= ~(KATA_MASK);
440                                 p_ptr->update |= (PU_BONUS);
441                                 p_ptr->update |= (PU_MONSTERS);
442                                 p_ptr->redraw |= (PR_STATE);
443                                 p_ptr->redraw |= (PR_STATUS);
444                                 p_ptr->action = ACTION_NONE;
445                         }
446
447                         notice = TRUE;
448                         p_ptr->counter = FALSE;
449                         chg_virtue(V_HARMONY, -1);
450                 }
451         }
452
453         /* Shut */
454         else
455         {
456                 if (p_ptr->confused)
457                 {
458 #ifdef JP
459 msg_print("¤ä¤Ã¤Èº®Í𤬤ª¤µ¤Þ¤Ã¤¿¡£");
460 #else
461                         msg_print("You feel less confused now.");
462 #endif
463
464                         p_ptr->special_attack &= ~(ATTACK_SUIKEN);
465                         notice = TRUE;
466                 }
467         }
468
469         /* Use the value */
470         p_ptr->confused = v;
471
472         /* Redraw status bar */
473         p_ptr->redraw |= (PR_STATUS);
474
475         /* Nothing to notice */
476         if (!notice) return (FALSE);
477
478         /* Disturb */
479         if (disturb_state) disturb(0, 0);
480
481         /* Handle stuff */
482         handle_stuff();
483
484         /* Result */
485         return (TRUE);
486 }
487
488
489 /*
490  * Set "p_ptr->poisoned", notice observable changes
491  */
492 bool set_poisoned(int v)
493 {
494         bool notice = FALSE;
495
496         /* Hack -- Force good values */
497         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
498
499         if (death) return FALSE;
500
501         /* Open */
502         if (v)
503         {
504                 if (!p_ptr->poisoned)
505                 {
506 #ifdef JP
507 msg_print("ÆǤ˿¯¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
508 #else
509                         msg_print("You are poisoned!");
510 #endif
511
512                         notice = TRUE;
513                 }
514         }
515
516         /* Shut */
517         else
518         {
519                 if (p_ptr->poisoned)
520                 {
521 #ifdef JP
522 msg_print("¤ä¤Ã¤ÈÆǤÎÄˤߤ¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
523 #else
524                         msg_print("You are no longer poisoned.");
525 #endif
526
527                         notice = TRUE;
528                 }
529         }
530
531         /* Use the value */
532         p_ptr->poisoned = v;
533
534         /* Redraw status bar */
535         p_ptr->redraw |= (PR_STATUS);
536
537         /* Nothing to notice */
538         if (!notice) return (FALSE);
539
540         /* Disturb */
541         if (disturb_state) disturb(0, 0);
542
543         /* Handle stuff */
544         handle_stuff();
545
546         /* Result */
547         return (TRUE);
548 }
549
550
551 /*
552  * Set "p_ptr->afraid", notice observable changes
553  */
554 bool set_afraid(int v)
555 {
556         bool notice = FALSE;
557
558         /* Hack -- Force good values */
559         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
560
561         if (death) return FALSE;
562
563         /* Open */
564         if (v)
565         {
566                 if (!p_ptr->afraid)
567                 {
568 #ifdef JP
569 msg_print("²¿¤â¤«¤â¶²¤¯¤Ê¤Ã¤Æ¤­¤¿¡ª");
570 #else
571                         msg_print("You are terrified!");
572 #endif
573
574                         if (p_ptr->special_defense & KATA_MASK)
575                         {
576 #ifdef JP
577                                 msg_print("·¿¤¬Êø¤ì¤¿¡£");
578 #else
579                                 msg_print("Your posture gets loose.");
580 #endif
581                                 p_ptr->special_defense &= ~(KATA_MASK);
582                                 p_ptr->update |= (PU_BONUS);
583                                 p_ptr->update |= (PU_MONSTERS);
584                                 p_ptr->redraw |= (PR_STATE);
585                                 p_ptr->redraw |= (PR_STATUS);
586                                 p_ptr->action = ACTION_NONE;
587                         }
588
589                         notice = TRUE;
590                         p_ptr->counter = FALSE;
591                         chg_virtue(V_VALOUR, -1);
592                 }
593         }
594
595         /* Shut */
596         else
597         {
598                 if (p_ptr->afraid)
599                 {
600 #ifdef JP
601 msg_print("¤ä¤Ã¤È¶²Éݤò¿¶¤êʧ¤Ã¤¿¡£");
602 #else
603                         msg_print("You feel bolder now.");
604 #endif
605
606                         notice = TRUE;
607                 }
608         }
609
610         /* Use the value */
611         p_ptr->afraid = v;
612
613         /* Redraw status bar */
614         p_ptr->redraw |= (PR_STATUS);
615
616         /* Nothing to notice */
617         if (!notice) return (FALSE);
618
619         /* Disturb */
620         if (disturb_state) disturb(0, 0);
621
622         /* Handle stuff */
623         handle_stuff();
624
625         /* Result */
626         return (TRUE);
627 }
628
629
630 /*
631  * Set "p_ptr->paralyzed", notice observable changes
632  */
633 bool set_paralyzed(int v)
634 {
635         bool notice = FALSE;
636
637         /* Hack -- Force good values */
638         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
639
640         if (death) return FALSE;
641
642         /* Open */
643         if (v)
644         {
645                 if (!p_ptr->paralyzed)
646                 {
647 #ifdef JP
648 msg_print("ÂΤ¬Ëãá㤷¤Æ¤·¤Þ¤Ã¤¿¡ª");
649 #else
650                         msg_print("You are paralyzed!");
651 #endif
652
653                         p_ptr->counter = FALSE;
654                         notice = TRUE;
655                 }
656         }
657
658         /* Shut */
659         else
660         {
661                 if (p_ptr->paralyzed)
662                 {
663 #ifdef JP
664 msg_print("¤ä¤Ã¤ÈÆ°¤±¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
665 #else
666                         msg_print("You can move again.");
667 #endif
668
669                         notice = TRUE;
670                 }
671         }
672
673         /* Use the value */
674         p_ptr->paralyzed = v;
675
676         /* Redraw status bar */
677         p_ptr->redraw |= (PR_STATUS);
678
679         /* Nothing to notice */
680         if (!notice) return (FALSE);
681
682         /* Disturb */
683         if (disturb_state) disturb(0, 0);
684
685         /* Redraw the state */
686         p_ptr->redraw |= (PR_STATE);
687
688         /* Handle stuff */
689         handle_stuff();
690
691         /* Result */
692         return (TRUE);
693 }
694
695
696 /*
697  * Set "p_ptr->image", notice observable changes
698  *
699  * Note that we must redraw the map when hallucination changes.
700  */
701 bool set_image(int v)
702 {
703         bool notice = FALSE;
704
705         /* Hack -- Force good values */
706         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
707
708         if (death) return FALSE;
709
710
711         /* Open */
712         if (v)
713         {
714                 set_tsuyoshi(0, TRUE);
715                 if (!p_ptr->image)
716                 {
717 #ifdef JP
718 msg_print("¥ï¡¼¥ª¡ª²¿¤â¤«¤âÆú¿§¤Ë¸«¤¨¤ë¡ª");
719 #else
720                         msg_print("Oh, wow! Everything looks so cosmic now!");
721 #endif
722
723                         p_ptr->counter = FALSE;
724                         notice = TRUE;
725                 }
726         }
727
728         /* Shut */
729         else
730         {
731                 if (p_ptr->image)
732                 {
733 #ifdef JP
734 msg_print("¤ä¤Ã¤È¤Ï¤Ã¤­¤ê¤Èʪ¤¬¸«¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
735 #else
736                         msg_print("You can see clearly again.");
737 #endif
738
739                         notice = TRUE;
740                 }
741         }
742
743         /* Use the value */
744         p_ptr->image = v;
745
746         /* Redraw status bar */
747         p_ptr->redraw |= (PR_STATUS);
748
749         /* Nothing to notice */
750         if (!notice) return (FALSE);
751
752         /* Disturb */
753         if (disturb_state) disturb(0, 0);
754
755         /* Redraw map */
756         p_ptr->redraw |= (PR_MAP);
757
758         /* Update monsters */
759         p_ptr->update |= (PU_MONSTERS);
760
761         /* Window stuff */
762         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
763
764         /* Handle stuff */
765         handle_stuff();
766
767         /* Result */
768         return (TRUE);
769 }
770
771
772 /*
773  * Set "p_ptr->fast", notice observable changes
774  */
775 bool set_fast(int v, bool do_dec)
776 {
777         bool notice = FALSE;
778
779         /* Hack -- Force good values */
780         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
781
782         if (death) return FALSE;
783
784         /* Open */
785         if (v)
786         {
787                 if (p_ptr->fast && !do_dec)
788                 {
789                         if (p_ptr->fast > v) return FALSE;
790                 }
791                 else if (!p_ptr->fast && !p_ptr->lightspeed)
792                 {
793 #ifdef JP
794 msg_print("ÁÇÁ᤯ư¤±¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
795 #else
796                         msg_print("You feel yourself moving much faster!");
797 #endif
798
799                         notice = TRUE;
800                         chg_virtue(V_PATIENCE, -1);
801                         chg_virtue(V_DILIGENCE, 1);
802                 }
803         }
804
805         /* Shut */
806         else
807         {
808                 if (p_ptr->fast && !p_ptr->lightspeed && ((p_ptr->pclass != CLASS_BARD) || ((p_ptr->magic_num1[0] != MUSIC_SPEED) && (p_ptr->magic_num1[0] != MUSIC_SHERO))))
809                 {
810 #ifdef JP
811 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
812 #else
813                         msg_print("You feel yourself slow down.");
814 #endif
815
816                         notice = TRUE;
817                 }
818         }
819
820         /* Use the value */
821         p_ptr->fast = v;
822
823         /* Nothing to notice */
824         if (!notice) return (FALSE);
825
826         /* Disturb */
827         if (disturb_state) disturb(0, 0);
828
829         /* Recalculate bonuses */
830         p_ptr->update |= (PU_BONUS);
831
832         /* Handle stuff */
833         handle_stuff();
834
835         /* Result */
836         return (TRUE);
837 }
838
839
840 /*
841  * Set "p_ptr->lightspeed", notice observable changes
842  */
843 bool set_lightspeed(int v, bool do_dec)
844 {
845         bool notice = FALSE;
846
847         /* Hack -- Force good values */
848         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
849
850         if (death) return FALSE;
851
852         /* Open */
853         if (v)
854         {
855                 if (p_ptr->lightspeed && !do_dec)
856                 {
857                         if (p_ptr->lightspeed > v) return FALSE;
858                 }
859                 else if (!p_ptr->lightspeed)
860                 {
861 #ifdef JP
862 msg_print("Èó¾ï¤ËÁÇÁ᤯ư¤±¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
863 #else
864                         msg_print("You feel yourself moving faster!");
865 #endif
866
867                         notice = TRUE;
868                         chg_virtue(V_PATIENCE, -1);
869                         chg_virtue(V_DILIGENCE, 1);
870                 }
871         }
872
873         /* Shut */
874         else
875         {
876                 if (p_ptr->lightspeed)
877                 {
878 #ifdef JP
879 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
880 #else
881                         msg_print("You feel yourself slow down.");
882 #endif
883
884                         notice = TRUE;
885                 }
886         }
887
888         /* Use the value */
889         p_ptr->lightspeed = v;
890
891         /* Nothing to notice */
892         if (!notice) return (FALSE);
893
894         /* Disturb */
895         if (disturb_state) disturb(0, 0);
896
897         /* Recalculate bonuses */
898         p_ptr->update |= (PU_BONUS);
899
900         /* Handle stuff */
901         handle_stuff();
902
903         /* Result */
904         return (TRUE);
905 }
906
907
908 /*
909  * Set "p_ptr->slow", notice observable changes
910  */
911 bool set_slow(int v, bool do_dec)
912 {
913         bool notice = FALSE;
914
915         /* Hack -- Force good values */
916         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
917
918         if (death) return FALSE;
919
920         /* Open */
921         if (v)
922         {
923                 if (p_ptr->slow && !do_dec)
924                 {
925                         if (p_ptr->slow > v) return FALSE;
926                 }
927                 else if (!p_ptr->slow)
928                 {
929 #ifdef JP
930 msg_print("ÂΤÎÆ°¤­¤¬ÃÙ¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
931 #else
932                         msg_print("You feel yourself moving slower!");
933 #endif
934
935                         notice = TRUE;
936                 }
937         }
938
939         /* Shut */
940         else
941         {
942                 if (p_ptr->slow)
943                 {
944 #ifdef JP
945 msg_print("Æ°¤­¤ÎÃÙ¤µ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
946 #else
947                         msg_print("You feel yourself speed up.");
948 #endif
949
950                         notice = TRUE;
951                 }
952         }
953
954         /* Use the value */
955         p_ptr->slow = v;
956
957         /* Nothing to notice */
958         if (!notice) return (FALSE);
959
960         /* Disturb */
961         if (disturb_state) disturb(0, 0);
962
963         /* Recalculate bonuses */
964         p_ptr->update |= (PU_BONUS);
965
966         /* Handle stuff */
967         handle_stuff();
968
969         /* Result */
970         return (TRUE);
971 }
972
973
974 /*
975  * Set "p_ptr->shield", notice observable changes
976  */
977 bool set_shield(int v, bool do_dec)
978 {
979         bool notice = FALSE;
980
981         /* Hack -- Force good values */
982         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
983
984         if (death) return FALSE;
985
986         /* Open */
987         if (v)
988         {
989                 if (p_ptr->shield && !do_dec)
990                 {
991                         if (p_ptr->shield > v) return FALSE;
992                 }
993                 else if (!p_ptr->shield)
994                 {
995 #ifdef JP
996 msg_print("È©¤¬ÀФˤʤä¿¡£");
997 #else
998                         msg_print("Your skin turns to stone.");
999 #endif
1000
1001                         notice = TRUE;
1002                 }
1003         }
1004
1005         /* Shut */
1006         else
1007         {
1008                 if (p_ptr->shield)
1009                 {
1010 #ifdef JP
1011 msg_print("È©¤¬¸µ¤ËÌá¤Ã¤¿¡£");
1012 #else
1013                         msg_print("Your skin returns to normal.");
1014 #endif
1015
1016                         notice = TRUE;
1017                 }
1018         }
1019
1020         /* Use the value */
1021         p_ptr->shield = v;
1022
1023         /* Redraw status bar */
1024         p_ptr->redraw |= (PR_STATUS);
1025
1026         /* Nothing to notice */
1027         if (!notice) return (FALSE);
1028
1029         /* Disturb */
1030         if (disturb_state) disturb(0, 0);
1031
1032         /* Recalculate bonuses */
1033         p_ptr->update |= (PU_BONUS);
1034
1035         /* Handle stuff */
1036         handle_stuff();
1037
1038         /* Result */
1039         return (TRUE);
1040 }
1041
1042
1043
1044 /*
1045  * Set "p_ptr->tsubureru", notice observable changes
1046  */
1047 bool set_tsubureru(int v, bool do_dec)
1048 {
1049         bool notice = FALSE;
1050
1051         /* Hack -- Force good values */
1052         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1053
1054         if (death) return FALSE;
1055
1056         /* Open */
1057         if (v)
1058         {
1059                 if (p_ptr->tsubureru && !do_dec)
1060                 {
1061                         if (p_ptr->tsubureru > v) return FALSE;
1062                 }
1063                 else if (!p_ptr->tsubureru)
1064                 {
1065 #ifdef JP
1066 msg_print("²£¤Ë¿­¤Ó¤¿¡£");
1067 #else
1068                         msg_print("You have expand horizontally.");
1069 #endif
1070
1071                         notice = TRUE;
1072                 }
1073         }
1074
1075         /* Shut */
1076         else
1077         {
1078                 if (p_ptr->tsubureru)
1079                 {
1080 #ifdef JP
1081 msg_print("¤â¤¦²£¤Ë¿­¤Ó¤Æ¤¤¤Ê¤¤¡£");
1082 #else
1083                         msg_print("You are no longer expanded.");
1084 #endif
1085
1086                         notice = TRUE;
1087                 }
1088         }
1089
1090         /* Use the value */
1091         p_ptr->tsubureru = v;
1092
1093         /* Redraw status bar */
1094         p_ptr->redraw |= (PR_STATUS);
1095
1096         /* Nothing to notice */
1097         if (!notice) return (FALSE);
1098
1099         /* Disturb */
1100         if (disturb_state) disturb(0, 0);
1101
1102         /* Recalculate bonuses */
1103         p_ptr->update |= (PU_BONUS);
1104
1105         /* Handle stuff */
1106         handle_stuff();
1107
1108         /* Result */
1109         return (TRUE);
1110 }
1111
1112
1113
1114 /*
1115  * Set "p_ptr->magicdef", notice observable changes
1116  */
1117 bool set_magicdef(int v, bool do_dec)
1118 {
1119         bool notice = FALSE;
1120
1121         /* Hack -- Force good values */
1122         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1123
1124         if (death) return FALSE;
1125
1126         /* Open */
1127         if (v)
1128         {
1129                 if (p_ptr->magicdef && !do_dec)
1130                 {
1131                         if (p_ptr->magicdef > v) return FALSE;
1132                 }
1133                 else if (!p_ptr->magicdef)
1134                 {
1135 #ifdef JP
1136                         msg_print("ËâË¡¤ÎËɸæÎϤ¬Áý¤·¤¿¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1137 #else
1138                         msg_print("You feel your magical vulnerability diminish.");
1139 #endif
1140
1141                         notice = TRUE;
1142                 }
1143         }
1144
1145         /* Shut */
1146         else
1147         {
1148                 if (p_ptr->magicdef)
1149                 {
1150 #ifdef JP
1151                         msg_print("ËâË¡¤ÎËɸæÎϤ¬¸µ¤ËÌá¤Ã¤¿¡£");
1152 #else
1153                         msg_print("Your magical defences fall to their normal values.");
1154 #endif
1155
1156                         notice = TRUE;
1157                 }
1158         }
1159
1160         /* Use the value */
1161         p_ptr->magicdef = v;
1162
1163         /* Redraw status bar */
1164         p_ptr->redraw |= (PR_STATUS);
1165
1166         /* Nothing to notice */
1167         if (!notice) return (FALSE);
1168
1169         /* Disturb */
1170         if (disturb_state) disturb(0, 0);
1171
1172         /* Recalculate bonuses */
1173         p_ptr->update |= (PU_BONUS);
1174
1175         /* Handle stuff */
1176         handle_stuff();
1177
1178         /* Result */
1179         return (TRUE);
1180 }
1181
1182
1183
1184 /*
1185  * Set "p_ptr->blessed", notice observable changes
1186  */
1187 bool set_blessed(int v, bool do_dec)
1188 {
1189         bool notice = FALSE;
1190
1191         /* Hack -- Force good values */
1192         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1193
1194         if (death) return FALSE;
1195
1196         /* Open */
1197         if (v)
1198         {
1199                 if (p_ptr->blessed && !do_dec)
1200                 {
1201                         if (p_ptr->blessed > v) return FALSE;
1202                 }
1203                 else if (!p_ptr->blessed)
1204                 {
1205 #ifdef JP
1206 msg_print("¹â·é¤Êµ¤Ê¬¤Ë¤Ê¤Ã¤¿¡ª");
1207 #else
1208                         msg_print("You feel righteous!");
1209 #endif
1210
1211                         notice = TRUE;
1212                 }
1213         }
1214
1215         /* Shut */
1216         else
1217         {
1218                 if (p_ptr->blessed && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_BLESS)))
1219                 {
1220 #ifdef JP
1221 msg_print("¹â·é¤Êµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
1222 #else
1223                         msg_print("The prayer has expired.");
1224 #endif
1225
1226                         notice = TRUE;
1227                 }
1228         }
1229
1230         /* Use the value */
1231         p_ptr->blessed = v;
1232
1233         /* Redraw status bar */
1234         p_ptr->redraw |= (PR_STATUS);
1235
1236         /* Nothing to notice */
1237         if (!notice) return (FALSE);
1238
1239         /* Disturb */
1240         if (disturb_state) disturb(0, 0);
1241
1242         /* Recalculate bonuses */
1243         p_ptr->update |= (PU_BONUS);
1244
1245         /* Handle stuff */
1246         handle_stuff();
1247
1248         /* Result */
1249         return (TRUE);
1250 }
1251
1252
1253 /*
1254  * Set "p_ptr->hero", notice observable changes
1255  */
1256 bool set_hero(int v, bool do_dec)
1257 {
1258         bool notice = FALSE;
1259
1260         /* Hack -- Force good values */
1261         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1262
1263         if (death) return FALSE;
1264
1265         /* Open */
1266         if (v)
1267         {
1268                 if (p_ptr->hero && !do_dec)
1269                 {
1270                         if (p_ptr->hero > v) return FALSE;
1271                 }
1272                 else if (!p_ptr->hero)
1273                 {
1274 #ifdef JP
1275 msg_print("¥Ò¡¼¥í¡¼¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1276 #else
1277                         msg_print("You feel like a hero!");
1278 #endif
1279
1280                         notice = TRUE;
1281                 }
1282         }
1283
1284         /* Shut */
1285         else
1286         {
1287                 if (p_ptr->hero && ((p_ptr->pclass != CLASS_BARD) || ((p_ptr->magic_num1[0] != MUSIC_HERO) && (p_ptr->magic_num1[0] != MUSIC_SHERO))))
1288                 {
1289 #ifdef JP
1290 msg_print("¥Ò¡¼¥í¡¼¤Îµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
1291 #else
1292                         msg_print("The heroism wears off.");
1293 #endif
1294
1295                         notice = TRUE;
1296                 }
1297         }
1298
1299         /* Use the value */
1300         p_ptr->hero = v;
1301
1302         /* Redraw status bar */
1303         p_ptr->redraw |= (PR_STATUS);
1304
1305         /* Nothing to notice */
1306         if (!notice) return (FALSE);
1307
1308         /* Disturb */
1309         if (disturb_state) disturb(0, 0);
1310
1311         /* Recalculate bonuses */
1312         p_ptr->update |= (PU_BONUS);
1313
1314         /* Recalculate hitpoints */
1315         p_ptr->update |= (PU_HP);
1316
1317         /* Handle stuff */
1318         handle_stuff();
1319
1320         /* Result */
1321         return (TRUE);
1322 }
1323
1324
1325 /*
1326  * Set "p_ptr->shero", notice observable changes
1327  */
1328 bool set_shero(int v, bool do_dec)
1329 {
1330         bool notice = FALSE;
1331
1332         /* Hack -- Force good values */
1333         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1334
1335         if (death) return FALSE;
1336
1337         if (p_ptr->pclass == CLASS_BERSERKER) v = 1;
1338         /* Open */
1339         if (v)
1340         {
1341                 if (p_ptr->shero && !do_dec)
1342                 {
1343                         if (p_ptr->shero > v) return FALSE;
1344                 }
1345                 else if (!p_ptr->shero)
1346                 {
1347 #ifdef JP
1348 msg_print("»¦Ù¤¥Þ¥·¡¼¥ó¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1349 #else
1350                         msg_print("You feel like a killing machine!");
1351 #endif
1352
1353                         notice = TRUE;
1354                 }
1355         }
1356
1357         /* Shut */
1358         else
1359         {
1360                 if (p_ptr->shero)
1361                 {
1362 #ifdef JP
1363 msg_print("ÌîÈڤʵ¤»ý¤Á¤¬¾Ã¤¨¼º¤»¤¿¡£");
1364 #else
1365                         msg_print("You feel less Berserk.");
1366 #endif
1367
1368                         notice = TRUE;
1369                 }
1370         }
1371
1372         /* Use the value */
1373         p_ptr->shero = v;
1374
1375         /* Redraw status bar */
1376         p_ptr->redraw |= (PR_STATUS);
1377
1378         /* Nothing to notice */
1379         if (!notice) return (FALSE);
1380
1381         /* Disturb */
1382         if (disturb_state) disturb(0, 0);
1383
1384         /* Recalculate bonuses */
1385         p_ptr->update |= (PU_BONUS);
1386
1387         /* Recalculate hitpoints */
1388         p_ptr->update |= (PU_HP);
1389
1390         /* Handle stuff */
1391         handle_stuff();
1392
1393         /* Result */
1394         return (TRUE);
1395 }
1396
1397
1398 /*
1399  * Set "p_ptr->protevil", notice observable changes
1400  */
1401 bool set_protevil(int v, bool do_dec)
1402 {
1403         bool notice = FALSE;
1404
1405         /* Hack -- Force good values */
1406         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1407
1408         if (death) return FALSE;
1409
1410         /* Open */
1411         if (v)
1412         {
1413                 if (p_ptr->protevil && !do_dec)
1414                 {
1415                         if (p_ptr->protevil > v) return FALSE;
1416                 }
1417                 else if (!p_ptr->protevil)
1418                 {
1419 #ifdef JP
1420 msg_print("¼Ù°­¤Ê¤ë¸ºß¤«¤é¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Ê´¶¤¸¤¬¤¹¤ë¡ª");
1421 #else
1422                         msg_print("You feel safe from evil!");
1423 #endif
1424
1425                         notice = TRUE;
1426                 }
1427         }
1428
1429         /* Shut */
1430         else
1431         {
1432                 if (p_ptr->protevil)
1433                 {
1434 #ifdef JP
1435 msg_print("¼Ù°­¤Ê¤ë¸ºß¤«¤é¼é¤é¤ì¤Æ¤¤¤ë´¶¤¸¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1436 #else
1437                         msg_print("You no longer feel safe from evil.");
1438 #endif
1439
1440                         notice = TRUE;
1441                 }
1442         }
1443
1444         /* Use the value */
1445         p_ptr->protevil = v;
1446
1447         /* Redraw status bar */
1448         p_ptr->redraw |= (PR_STATUS);
1449
1450         /* Nothing to notice */
1451         if (!notice) return (FALSE);
1452
1453         /* Disturb */
1454         if (disturb_state) disturb(0, 0);
1455
1456         /* Handle stuff */
1457         handle_stuff();
1458
1459         /* Result */
1460         return (TRUE);
1461 }
1462
1463 /*
1464  * Set "p_ptr->wraith_form", notice observable changes
1465  */
1466 bool set_wraith_form(int v, bool do_dec)
1467 {
1468         bool notice = FALSE;
1469
1470         /* Hack -- Force good values */
1471         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1472
1473         if (death) return FALSE;
1474
1475         /* Open */
1476         if (v)
1477         {
1478                 if (p_ptr->wraith_form && !do_dec)
1479                 {
1480                         if (p_ptr->wraith_form > v) return FALSE;
1481                 }
1482                 else if (!p_ptr->wraith_form)
1483                 {
1484 #ifdef JP
1485 msg_print("ʪ¼Á³¦¤òÎ¥¤ì¤ÆÍ©µ´¤Î¤è¤¦¤Ê¸ºß¤Ë¤Ê¤Ã¤¿¡ª");
1486 #else
1487                         msg_print("You leave the physical world and turn into a wraith-being!");
1488 #endif
1489
1490                         notice = TRUE;
1491
1492                         chg_virtue(V_UNLIFE, 3);
1493                         chg_virtue(V_HONOUR, -2);
1494                         chg_virtue(V_SACRIFICE, -2);
1495                         chg_virtue(V_VALOUR, -5);
1496
1497                         /* Redraw map */
1498                         p_ptr->redraw |= (PR_MAP);
1499
1500                         /* Update monsters */
1501                         p_ptr->update |= (PU_MONSTERS);
1502
1503                         /* Window stuff */
1504                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1505                 }
1506         }
1507
1508         /* Shut */
1509         else
1510         {
1511                 if (p_ptr->wraith_form)
1512                 {
1513 #ifdef JP
1514 msg_print("ÉÔÆ©ÌÀ¤Ë¤Ê¤Ã¤¿´¶¤¸¤¬¤¹¤ë¡£");
1515 #else
1516                         msg_print("You feel opaque.");
1517 #endif
1518
1519                         notice = TRUE;
1520
1521                         /* Redraw map */
1522                         p_ptr->redraw |= (PR_MAP);
1523
1524                         /* Update monsters */
1525                         p_ptr->update |= (PU_MONSTERS);
1526
1527                         /* Window stuff */
1528                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1529                 }
1530         }
1531
1532         /* Use the value */
1533         p_ptr->wraith_form = v;
1534
1535         /* Redraw status bar */
1536         p_ptr->redraw |= (PR_STATUS);
1537
1538         /* Nothing to notice */
1539         if (!notice) return (FALSE);
1540
1541         /* Disturb */
1542         if (disturb_state) disturb(0, 0);
1543
1544         /* Recalculate bonuses */
1545         p_ptr->update |= (PU_BONUS);
1546
1547
1548
1549
1550         /* Handle stuff */
1551         handle_stuff();
1552
1553         /* Result */
1554         return (TRUE);
1555
1556 }
1557
1558
1559 /*
1560  * Set "p_ptr->invuln", notice observable changes
1561  */
1562 bool set_invuln(int v, bool do_dec)
1563 {
1564         bool notice = FALSE;
1565
1566         /* Hack -- Force good values */
1567         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1568
1569         if (death) return FALSE;
1570
1571         /* Open */
1572         if (v)
1573         {
1574                 if (p_ptr->invuln && !do_dec)
1575                 {
1576                         if (p_ptr->invuln > v) return FALSE;
1577                 }
1578                 else if (!p_ptr->invuln)
1579                 {
1580 #ifdef JP
1581 msg_print("̵Ũ¤À¡ª");
1582 #else
1583                         msg_print("Invulnerability!");
1584 #endif
1585
1586                         notice = TRUE;
1587
1588                         chg_virtue(V_UNLIFE, -2);
1589                         chg_virtue(V_HONOUR, -2);
1590                         chg_virtue(V_SACRIFICE, -3);
1591                         chg_virtue(V_VALOUR, -5);
1592
1593                         /* Redraw map */
1594                         p_ptr->redraw |= (PR_MAP);
1595
1596                         /* Update monsters */
1597                         p_ptr->update |= (PU_MONSTERS);
1598
1599                         /* Window stuff */
1600                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1601                 }
1602         }
1603
1604         /* Shut */
1605         else
1606         {
1607                 if (p_ptr->invuln && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_INVULN)))
1608                 {
1609 #ifdef JP
1610 msg_print("̵Ũ¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
1611 #else
1612                         msg_print("The invulnerability wears off.");
1613 #endif
1614
1615                         notice = TRUE;
1616
1617                         /* Redraw map */
1618                         p_ptr->redraw |= (PR_MAP);
1619
1620                         /* Update monsters */
1621                         p_ptr->update |= (PU_MONSTERS);
1622
1623                         /* Window stuff */
1624                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1625
1626                         p_ptr->energy -= 100;
1627                 }
1628         }
1629
1630         /* Use the value */
1631         p_ptr->invuln = v;
1632
1633         /* Redraw status bar */
1634         p_ptr->redraw |= (PR_STATUS);
1635
1636         /* Nothing to notice */
1637         if (!notice) return (FALSE);
1638
1639         /* Disturb */
1640         if (disturb_state) disturb(0, 0);
1641
1642         /* Recalculate bonuses */
1643         p_ptr->update |= (PU_BONUS);
1644
1645         /* Handle stuff */
1646         handle_stuff();
1647
1648         /* Result */
1649         return (TRUE);
1650 }
1651
1652
1653 /*
1654  * Set "p_ptr->tim_esp", notice observable changes
1655  */
1656 bool set_tim_esp(int v, bool do_dec)
1657 {
1658         bool notice = FALSE;
1659
1660         /* Hack -- Force good values */
1661         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1662
1663         if (death) return FALSE;
1664
1665         /* Open */
1666         if (v)
1667         {
1668                 if (p_ptr->tim_esp && !do_dec)
1669                 {
1670                         if (p_ptr->tim_esp > v) return FALSE;
1671                 }
1672                 else if (!p_ptr->tim_esp)
1673                 {
1674 #ifdef JP
1675 msg_print("°Õ¼±¤¬¹­¤¬¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1676 #else
1677                         msg_print("You feel your consciousness expand!");
1678 #endif
1679
1680                         notice = TRUE;
1681                 }
1682         }
1683
1684         /* Shut */
1685         else
1686         {
1687                 if (p_ptr->tim_esp && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_MIND)))
1688                 {
1689 #ifdef JP
1690 msg_print("°Õ¼±¤Ï¸µ¤ËÌá¤Ã¤¿¡£");
1691 #else
1692                         msg_print("Your consciousness contracts again.");
1693 #endif
1694
1695                         notice = TRUE;
1696                 }
1697         }
1698
1699         /* Use the value */
1700         p_ptr->tim_esp = v;
1701
1702         /* Redraw status bar */
1703         p_ptr->redraw |= (PR_STATUS);
1704
1705         /* Nothing to notice */
1706         if (!notice) return (FALSE);
1707
1708         /* Disturb */
1709         if (disturb_state) disturb(0, 0);
1710
1711         /* Recalculate bonuses */
1712         p_ptr->update |= (PU_BONUS);
1713
1714         /* Update the monsters */
1715         p_ptr->update |= (PU_MONSTERS);
1716
1717         /* Handle stuff */
1718         handle_stuff();
1719
1720         /* Result */
1721         return (TRUE);
1722 }
1723
1724
1725 /*
1726  * Set "p_ptr->tim_invis", notice observable changes
1727  */
1728 bool set_tim_invis(int v, bool do_dec)
1729 {
1730         bool notice = FALSE;
1731
1732         /* Hack -- Force good values */
1733         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1734
1735         if (death) return FALSE;
1736
1737         /* Open */
1738         if (v)
1739         {
1740                 if (p_ptr->tim_invis && !do_dec)
1741                 {
1742                         if (p_ptr->tim_invis > v) return FALSE;
1743                 }
1744                 else if (!p_ptr->tim_invis)
1745                 {
1746 #ifdef JP
1747 msg_print("Ìܤ¬Èó¾ï¤ËÉÒ´¶¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1748 #else
1749                         msg_print("Your eyes feel very sensitive!");
1750 #endif
1751
1752                         notice = TRUE;
1753                 }
1754         }
1755
1756         /* Shut */
1757         else
1758         {
1759                 if (p_ptr->tim_invis)
1760                 {
1761 #ifdef JP
1762 msg_print("ÌܤÎÉÒ´¶¤µ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
1763 #else
1764                         msg_print("Your eyes feel less sensitive.");
1765 #endif
1766
1767                         notice = TRUE;
1768                 }
1769         }
1770
1771         /* Use the value */
1772         p_ptr->tim_invis = v;
1773
1774         /* Redraw status bar */
1775         p_ptr->redraw |= (PR_STATUS);
1776
1777         /* Nothing to notice */
1778         if (!notice) return (FALSE);
1779
1780         /* Disturb */
1781         if (disturb_state) disturb(0, 0);
1782
1783         /* Recalculate bonuses */
1784         p_ptr->update |= (PU_BONUS);
1785
1786         /* Update the monsters */
1787         p_ptr->update |= (PU_MONSTERS);
1788
1789         /* Handle stuff */
1790         handle_stuff();
1791
1792         /* Result */
1793         return (TRUE);
1794 }
1795
1796
1797 /*
1798  * Set "p_ptr->tim_infra", notice observable changes
1799  */
1800 bool set_tim_infra(int v, bool do_dec)
1801 {
1802         bool notice = FALSE;
1803
1804         /* Hack -- Force good values */
1805         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1806
1807         if (death) return FALSE;
1808
1809         /* Open */
1810         if (v)
1811         {
1812                 if (p_ptr->tim_infra && !do_dec)
1813                 {
1814                         if (p_ptr->tim_infra > v) return FALSE;
1815                 }
1816                 else if (!p_ptr->tim_infra)
1817                 {
1818 #ifdef JP
1819 msg_print("Ìܤ¬¥é¥ó¥é¥ó¤Èµ±¤­»Ï¤á¤¿¡ª");
1820 #else
1821                         msg_print("Your eyes began to tingle!");
1822 #endif
1823
1824                         notice = TRUE;
1825                 }
1826         }
1827
1828         /* Shut */
1829         else
1830         {
1831                 if (p_ptr->tim_infra)
1832                 {
1833 #ifdef JP
1834 msg_print("Ìܤ層­¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1835 #else
1836                         msg_print("Your eyes stop tingling.");
1837 #endif
1838
1839                         notice = TRUE;
1840                 }
1841         }
1842
1843         /* Use the value */
1844         p_ptr->tim_infra = v;
1845
1846         /* Redraw status bar */
1847         p_ptr->redraw |= (PR_STATUS);
1848
1849         /* Nothing to notice */
1850         if (!notice) return (FALSE);
1851
1852         /* Disturb */
1853         if (disturb_state) disturb(0, 0);
1854
1855         /* Recalculate bonuses */
1856         p_ptr->update |= (PU_BONUS);
1857
1858         /* Update the monsters */
1859         p_ptr->update |= (PU_MONSTERS);
1860
1861         /* Handle stuff */
1862         handle_stuff();
1863
1864         /* Result */
1865         return (TRUE);
1866 }
1867
1868
1869 /*
1870  * Set "p_ptr->tim_regen", notice observable changes
1871  */
1872 bool set_tim_regen(int v, bool do_dec)
1873 {
1874         bool notice = FALSE;
1875
1876         /* Hack -- Force good values */
1877         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1878
1879         if (death) return FALSE;
1880
1881         /* Open */
1882         if (v)
1883         {
1884                 if (p_ptr->tim_regen && !do_dec)
1885                 {
1886                         if (p_ptr->tim_regen > v) return FALSE;
1887                 }
1888                 else if (!p_ptr->tim_regen)
1889                 {
1890 #ifdef JP
1891 msg_print("²óÉüÎϤ¬¾å¤¬¤Ã¤¿¡ª");
1892 #else
1893                         msg_print("You began to regenerate quicker!");
1894 #endif
1895
1896                         notice = TRUE;
1897                 }
1898         }
1899
1900         /* Shut */
1901         else
1902         {
1903                 if (p_ptr->tim_regen)
1904                 {
1905 #ifdef JP
1906 msg_print("ÁÇÁ᤯²óÉü¤¹¤ë´¶¤¸¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1907 #else
1908                         msg_print("You no longer regenerate quicker.");
1909 #endif
1910
1911                         notice = TRUE;
1912                 }
1913         }
1914
1915         /* Use the value */
1916         p_ptr->tim_regen = v;
1917
1918         /* Redraw status bar */
1919         p_ptr->redraw |= (PR_STATUS);
1920
1921         /* Nothing to notice */
1922         if (!notice) return (FALSE);
1923
1924         /* Disturb */
1925         if (disturb_state) disturb(0, 0);
1926
1927         /* Recalculate bonuses */
1928         p_ptr->update |= (PU_BONUS);
1929
1930         /* Handle stuff */
1931         handle_stuff();
1932
1933         /* Result */
1934         return (TRUE);
1935 }
1936
1937
1938 /*
1939  * Set "p_ptr->tim_stealth", notice observable changes
1940  */
1941 bool set_tim_stealth(int v, bool do_dec)
1942 {
1943         bool notice = FALSE;
1944
1945         /* Hack -- Force good values */
1946         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1947
1948         if (death) return FALSE;
1949
1950         /* Open */
1951         if (v)
1952         {
1953                 if (p_ptr->tim_stealth && !do_dec)
1954                 {
1955                         if (p_ptr->tim_stealth > v) return FALSE;
1956                 }
1957                 else if (!p_ptr->tim_stealth)
1958                 {
1959 #ifdef JP
1960 msg_print("­²»¤¬¾®¤µ¤¯¤Ê¤Ã¤¿¡ª");
1961 #else
1962                         msg_print("You began to walk silently!");
1963 #endif
1964
1965                         notice = TRUE;
1966                 }
1967         }
1968
1969         /* Shut */
1970         else
1971         {
1972                 if (p_ptr->tim_stealth && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_STEALTH)))
1973                 {
1974 #ifdef JP
1975 msg_print("­²»¤¬Â礭¤¯¤Ê¤Ã¤¿¡£");
1976 #else
1977                         msg_print("You no longer walk silently.");
1978 #endif
1979
1980                         notice = TRUE;
1981                 }
1982         }
1983
1984         /* Use the value */
1985         p_ptr->tim_stealth = v;
1986
1987         /* Redraw status bar */
1988         p_ptr->redraw |= (PR_STATUS);
1989
1990         /* Nothing to notice */
1991         if (!notice) return (FALSE);
1992
1993         /* Disturb */
1994         if (disturb_state) disturb(0, 0);
1995
1996         /* Recalculate bonuses */
1997         p_ptr->update |= (PU_BONUS);
1998
1999         /* Handle stuff */
2000         handle_stuff();
2001
2002         /* Result */
2003         return (TRUE);
2004 }
2005
2006
2007 bool set_superstealth(bool set)
2008 {
2009         bool notice = FALSE;
2010
2011         if (death) return FALSE;
2012
2013         /* Open */
2014         if (set)
2015         {
2016                 if (!(p_ptr->special_defense & NINJA_S_STEALTH))
2017                 {
2018                         if (cave[py][px].info & CAVE_MNLT)
2019                         {
2020 #ifdef JP
2021                                 msg_print("Ũ¤ÎÌܤ«¤éÇö¤¤±Æ¤ÎÃæ¤Ëʤ¤¤±£¤µ¤ì¤¿¡£");
2022 #else
2023                                 msg_print("You are mantled in weak shadow from ordinary eyes.");
2024 #endif
2025                                 p_ptr->monlite = p_ptr->old_monlite = TRUE;
2026                         }
2027                         else
2028                         {
2029 #ifdef JP
2030                                 msg_print("Ũ¤ÎÌܤ«¤é±Æ¤ÎÃæ¤Ëʤ¤¤±£¤µ¤ì¤¿¡ª");
2031 #else
2032                                 msg_print("You are mantled in shadow from ordinary eyes!");
2033 #endif
2034                                 p_ptr->monlite = p_ptr->old_monlite = FALSE;
2035                         }
2036
2037                         notice = TRUE;
2038
2039                         /* Use the value */
2040                         p_ptr->special_defense |= NINJA_S_STEALTH;
2041                 }
2042         }
2043
2044         /* Shut */
2045         else
2046         {
2047                 if (p_ptr->special_defense & NINJA_S_STEALTH)
2048                 {
2049 #ifdef JP
2050                         msg_print("ºÆ¤ÓŨ¤ÎÌܤˤµ¤é¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
2051 #else
2052                         msg_print("You are exposed to common sight once more.");
2053 #endif
2054
2055                         notice = TRUE;
2056
2057                         /* Use the value */
2058                         p_ptr->special_defense &= ~(NINJA_S_STEALTH);
2059                 }
2060         }
2061
2062         /* Nothing to notice */
2063         if (!notice) return (FALSE);
2064
2065         /* Redraw status bar */
2066         p_ptr->redraw |= (PR_STATUS);
2067
2068         /* Disturb */
2069         if (disturb_state) disturb(0, 0);
2070
2071         /* Result */
2072         return (TRUE);
2073 }
2074
2075
2076 /*
2077  * Set "p_ptr->tim_ffall", notice observable changes
2078  */
2079 bool set_tim_ffall(int v, bool do_dec)
2080 {
2081         bool notice = FALSE;
2082
2083         /* Hack -- Force good values */
2084         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2085
2086         if (death) return FALSE;
2087
2088         /* Open */
2089         if (v)
2090         {
2091                 if (p_ptr->tim_ffall && !do_dec)
2092                 {
2093                         if (p_ptr->tim_ffall > v) return FALSE;
2094                 }
2095                 else if (!p_ptr->tim_ffall)
2096                 {
2097 #ifdef JP
2098 msg_print("ÂΤ¬Ãè¤ËÉ⤭»Ï¤á¤¿¡£");
2099 #else
2100                         msg_print("You began to fly!");
2101 #endif
2102
2103                         notice = TRUE;
2104                 }
2105         }
2106
2107         /* Shut */
2108         else
2109         {
2110                 if (p_ptr->tim_ffall)
2111                 {
2112 #ifdef JP
2113 msg_print("¤â¤¦Ãè¤ËÉ⤫¤Ù¤Ê¤¯¤Ê¤Ã¤¿¡£");
2114 #else
2115                         msg_print("You no longer flying.");
2116 #endif
2117
2118                         notice = TRUE;
2119                 }
2120         }
2121
2122         /* Use the value */
2123         p_ptr->tim_ffall = v;
2124
2125         /* Redraw status bar */
2126         p_ptr->redraw |= (PR_STATUS);
2127
2128         /* Nothing to notice */
2129         if (!notice) return (FALSE);
2130
2131         /* Disturb */
2132         if (disturb_state) disturb(0, 0);
2133
2134         /* Recalculate bonuses */
2135         p_ptr->update |= (PU_BONUS);
2136
2137         /* Handle stuff */
2138         handle_stuff();
2139
2140         /* Result */
2141         return (TRUE);
2142 }
2143
2144
2145 /*
2146  * Set "p_ptr->tim_sh_touki", notice observable changes
2147  */
2148 bool set_tim_sh_touki(int v, bool do_dec)
2149 {
2150         bool notice = FALSE;
2151
2152         /* Hack -- Force good values */
2153         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2154
2155         if (death) return FALSE;
2156
2157         /* Open */
2158         if (v)
2159         {
2160                 if (p_ptr->tim_sh_touki && !do_dec)
2161                 {
2162                         if (p_ptr->tim_sh_touki > v) return FALSE;
2163                 }
2164                 else if (!p_ptr->tim_sh_touki)
2165                 {
2166 #ifdef JP
2167 msg_print("ÂΤ¬Æ®µ¤¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2168 #else
2169                         msg_print("You have enveloped by energy aura!");
2170 #endif
2171
2172                         notice = TRUE;
2173                 }
2174         }
2175
2176         /* Shut */
2177         else
2178         {
2179                 if (p_ptr->tim_sh_touki)
2180                 {
2181 #ifdef JP
2182 msg_print("Æ®µ¤¤¬¾Ã¤¨¤¿¡£");
2183 #else
2184                         msg_print("Aura of Force disappeared.");
2185 #endif
2186
2187                         notice = TRUE;
2188                 }
2189         }
2190
2191         /* Use the value */
2192         p_ptr->tim_sh_touki = v;
2193
2194         /* Redraw status bar */
2195         p_ptr->redraw |= (PR_STATUS);
2196
2197         /* Nothing to notice */
2198         if (!notice) return (FALSE);
2199
2200         /* Disturb */
2201         if (disturb_state) disturb(0, 0);
2202
2203         /* Handle stuff */
2204         handle_stuff();
2205
2206         /* Result */
2207         return (TRUE);
2208 }
2209
2210
2211 /*
2212  * Set "p_ptr->tim_sh_fire", notice observable changes
2213  */
2214 bool set_tim_sh_fire(int v, bool do_dec)
2215 {
2216         bool notice = FALSE;
2217
2218         /* Hack -- Force good values */
2219         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2220
2221         if (death) return FALSE;
2222
2223         /* Open */
2224         if (v)
2225         {
2226                 if (p_ptr->tim_sh_fire && !do_dec)
2227                 {
2228                         if (p_ptr->tim_sh_fire > v) return FALSE;
2229                 }
2230                 else if (!p_ptr->tim_sh_fire)
2231                 {
2232 #ifdef JP
2233 msg_print("ÂΤ¬±ê¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2234 #else
2235                         msg_print("You have enveloped by fiery aura!");
2236 #endif
2237
2238                         notice = TRUE;
2239                 }
2240         }
2241
2242         /* Shut */
2243         else
2244         {
2245                 if (p_ptr->tim_sh_fire)
2246                 {
2247 #ifdef JP
2248 msg_print("±ê¤Î¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2249 #else
2250                         msg_print("Fiery aura disappeared.");
2251 #endif
2252
2253                         notice = TRUE;
2254                 }
2255         }
2256
2257         /* Use the value */
2258         p_ptr->tim_sh_fire = v;
2259
2260         /* Redraw status bar */
2261         p_ptr->redraw |= (PR_STATUS);
2262
2263         /* Nothing to notice */
2264         if (!notice) return (FALSE);
2265
2266         /* Disturb */
2267         if (disturb_state) disturb(0, 0);
2268
2269         /* Recalculate bonuses */
2270         p_ptr->update |= (PU_BONUS);
2271
2272         /* Handle stuff */
2273         handle_stuff();
2274
2275         /* Result */
2276         return (TRUE);
2277 }
2278
2279
2280 /*
2281  * Set "p_ptr->resist_magic", notice observable changes
2282  */
2283 bool set_resist_magic(int v, bool do_dec)
2284 {
2285         bool notice = FALSE;
2286
2287         /* Hack -- Force good values */
2288         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2289
2290         if (death) return FALSE;
2291
2292         /* Open */
2293         if (v)
2294         {
2295                 if (p_ptr->resist_magic && !do_dec)
2296                 {
2297                         if (p_ptr->resist_magic > v) return FALSE;
2298                 }
2299                 else if (!p_ptr->resist_magic)
2300                 {
2301 #ifdef JP
2302 msg_print("ËâË¡¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿¡£");
2303 #else
2304                         msg_print("You have been protected from magic!");
2305 #endif
2306
2307                         notice = TRUE;
2308                 }
2309         }
2310
2311         /* Shut */
2312         else
2313         {
2314                 if (p_ptr->resist_magic)
2315                 {
2316 #ifdef JP
2317 msg_print("ËâË¡¤Ë¼å¤¯¤Ê¤Ã¤¿¡£");
2318 #else
2319 msg_print("You are no longer protected from magic.");
2320 #endif
2321
2322                         notice = TRUE;
2323                 }
2324         }
2325
2326         /* Use the value */
2327         p_ptr->resist_magic = v;
2328
2329         /* Redraw status bar */
2330         p_ptr->redraw |= (PR_STATUS);
2331
2332         /* Nothing to notice */
2333         if (!notice) return (FALSE);
2334
2335         /* Disturb */
2336         if (disturb_state) disturb(0, 0);
2337
2338         /* Recalculate bonuses */
2339         p_ptr->update |= (PU_BONUS);
2340
2341         /* Handle stuff */
2342         handle_stuff();
2343
2344         /* Result */
2345         return (TRUE);
2346 }
2347
2348
2349 /*
2350  * Set "p_ptr->tim_reflect", notice observable changes
2351  */
2352 bool set_tim_reflect(int v, bool do_dec)
2353 {
2354         bool notice = FALSE;
2355
2356         /* Hack -- Force good values */
2357         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2358
2359         if (death) return FALSE;
2360
2361         /* Open */
2362         if (v)
2363         {
2364                 if (p_ptr->tim_reflect && !do_dec)
2365                 {
2366                         if (p_ptr->tim_reflect > v) return FALSE;
2367                 }
2368                 else if (!p_ptr->tim_reflect)
2369                 {
2370 #ifdef JP
2371 msg_print("ÂΤÎɽÌ̤¬³ê¤«¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
2372 #else
2373                         msg_print("Your body becames smooth.");
2374 #endif
2375
2376                         notice = TRUE;
2377                 }
2378         }
2379
2380         /* Shut */
2381         else
2382         {
2383                 if (p_ptr->tim_reflect)
2384                 {
2385 #ifdef JP
2386 msg_print("ÂΤÎɽÌ̤¬³ê¤«¤Ç¤Ê¤¯¤Ê¤Ã¤¿¡£");
2387 #else
2388                         msg_print("Your body is no longer smooth.");
2389 #endif
2390
2391                         notice = TRUE;
2392                 }
2393         }
2394
2395         /* Use the value */
2396         p_ptr->tim_reflect = v;
2397
2398         /* Redraw status bar */
2399         p_ptr->redraw |= (PR_STATUS);
2400
2401         /* Nothing to notice */
2402         if (!notice) return (FALSE);
2403
2404         /* Disturb */
2405         if (disturb_state) disturb(0, 0);
2406
2407         /* Recalculate bonuses */
2408         p_ptr->update |= (PU_BONUS);
2409
2410         /* Handle stuff */
2411         handle_stuff();
2412
2413         /* Result */
2414         return (TRUE);
2415 }
2416
2417
2418 /*
2419  * Set "p_ptr->multishadow", notice observable changes
2420  */
2421 bool set_multishadow(int v, bool do_dec)
2422 {
2423         bool notice = FALSE;
2424
2425         /* Hack -- Force good values */
2426         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2427
2428         if (death) return FALSE;
2429
2430         /* Open */
2431         if (v)
2432         {
2433                 if (p_ptr->multishadow && !do_dec)
2434                 {
2435                         if (p_ptr->multishadow > v) return FALSE;
2436                 }
2437                 else if (!p_ptr->multishadow)
2438                 {
2439 #ifdef JP
2440 msg_print("¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¸¸±Æ¤¬À¸¤Þ¤ì¤¿¡£");
2441 #else
2442                         msg_print("Your Shadow enveloped you.");
2443 #endif
2444
2445                         notice = TRUE;
2446                 }
2447         }
2448
2449         /* Shut */
2450         else
2451         {
2452                 if (p_ptr->multishadow)
2453                 {
2454 #ifdef JP
2455 msg_print("¸¸±Æ¤¬¾Ã¤¨¤¿¡£");
2456 #else
2457                         msg_print("Your Shadow disappears.");
2458 #endif
2459
2460                         notice = TRUE;
2461                 }
2462         }
2463
2464         /* Use the value */
2465         p_ptr->multishadow = v;
2466
2467         /* Redraw status bar */
2468         p_ptr->redraw |= (PR_STATUS);
2469
2470         /* Nothing to notice */
2471         if (!notice) return (FALSE);
2472
2473         /* Disturb */
2474         if (disturb_state) disturb(0, 0);
2475
2476         /* Recalculate bonuses */
2477         p_ptr->update |= (PU_BONUS);
2478
2479         /* Handle stuff */
2480         handle_stuff();
2481
2482         /* Result */
2483         return (TRUE);
2484 }
2485
2486
2487 /*
2488  * Set "p_ptr->dustrobe", notice observable changes
2489  */
2490 bool set_dustrobe(int v, bool do_dec)
2491 {
2492         bool notice = FALSE;
2493
2494         /* Hack -- Force good values */
2495         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2496
2497         if (death) return FALSE;
2498
2499         /* Open */
2500         if (v)
2501         {
2502                 if (p_ptr->dustrobe && !do_dec)
2503                 {
2504                         if (p_ptr->dustrobe > v) return FALSE;
2505                 }
2506                 else if (!p_ptr->dustrobe)
2507                 {
2508 #ifdef JP
2509 msg_print("ÂΤ¬¶À¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2510 #else
2511                         msg_print("You were enveloped by mirror shards.");
2512 #endif
2513
2514                         notice = TRUE;
2515                 }
2516         }
2517
2518         /* Shut */
2519         else
2520         {
2521                 if (p_ptr->dustrobe)
2522                 {
2523 #ifdef JP
2524 msg_print("¶À¤Î¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2525 #else
2526                         msg_print("The mirror shards disappear.");
2527 #endif
2528
2529                         notice = TRUE;
2530                 }
2531         }
2532
2533         /* Use the value */
2534         p_ptr->dustrobe = v;
2535
2536         /* Redraw status bar */
2537         p_ptr->redraw |= (PR_STATUS);
2538
2539         /* Nothing to notice */
2540         if (!notice) return (FALSE);
2541
2542         /* Disturb */
2543         if (disturb_state) disturb(0, 0);
2544
2545         /* Recalculate bonuses */
2546         p_ptr->update |= (PU_BONUS);
2547
2548         /* Handle stuff */
2549         handle_stuff();
2550
2551         /* Result */
2552         return (TRUE);
2553 }
2554
2555
2556 /*
2557  * Set "p_ptr->tim_regen", notice observable changes
2558  */
2559 bool set_kabenuke(int v, bool do_dec)
2560 {
2561         bool notice = FALSE;
2562
2563         /* Hack -- Force good values */
2564         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2565
2566         if (death) return FALSE;
2567
2568         /* Open */
2569         if (v)
2570         {
2571                 if (p_ptr->kabenuke && !do_dec)
2572                 {
2573                         if (p_ptr->kabenuke > v) return FALSE;
2574                 }
2575                 else if (!p_ptr->kabenuke)
2576                 {
2577 #ifdef JP
2578 msg_print("ÂΤ¬È¾Êª¼Á¤Î¾õÂ֤ˤʤä¿¡£");
2579 #else
2580                         msg_print("You became ethereal form.");
2581 #endif
2582
2583                         notice = TRUE;
2584                 }
2585         }
2586
2587         /* Shut */
2588         else
2589         {
2590                 if (p_ptr->kabenuke)
2591                 {
2592 #ifdef JP
2593 msg_print("ÂΤ¬Êª¼Á²½¤·¤¿¡£");
2594 #else
2595                         msg_print("You are no longer in an ethereal form.");
2596 #endif
2597
2598                         notice = TRUE;
2599                 }
2600         }
2601
2602         /* Use the value */
2603         p_ptr->kabenuke = v;
2604
2605         /* Redraw status bar */
2606         p_ptr->redraw |= (PR_STATUS);
2607
2608         /* Nothing to notice */
2609         if (!notice) return (FALSE);
2610
2611         /* Disturb */
2612         if (disturb_state) disturb(0, 0);
2613
2614         /* Handle stuff */
2615         handle_stuff();
2616
2617         /* Result */
2618         return (TRUE);
2619 }
2620
2621
2622 bool set_tsuyoshi(int v, bool do_dec)
2623 {
2624         bool notice = FALSE;
2625
2626         /* Hack -- Force good values */
2627         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2628
2629         if (death) return FALSE;
2630
2631         /* Open */
2632         if (v)
2633         {
2634                 if (p_ptr->tsuyoshi && !do_dec)
2635                 {
2636                         if (p_ptr->tsuyoshi > v) return FALSE;
2637                 }
2638                 else if (!p_ptr->tsuyoshi)
2639                 {
2640 #ifdef JP
2641 msg_print("¡Ö¥ª¥¯¥ì·»¤µ¤ó¡ª¡×");
2642 #else
2643                         msg_print("Brother OKURE!");
2644 #endif
2645
2646                         notice = TRUE;
2647                         chg_virtue(V_VITALITY, 2);
2648                 }
2649         }
2650
2651         /* Shut */
2652         else
2653         {
2654                 if (p_ptr->tsuyoshi)
2655                 {
2656 #ifdef JP
2657 msg_print("ÆùÂΤ¬µÞ®¤Ë¤·¤Ü¤ó¤Ç¤¤¤Ã¤¿¡£");
2658 #else
2659                         msg_print("Your body had quickly shriveled.");
2660 #endif
2661
2662                         (void)dec_stat(A_CON, 20, TRUE);
2663                         (void)dec_stat(A_STR, 20, TRUE);
2664
2665                         notice = TRUE;
2666                         chg_virtue(V_VITALITY, -3);
2667                 }
2668         }
2669
2670         /* Use the value */
2671         p_ptr->tsuyoshi = v;
2672
2673         /* Redraw status bar */
2674         p_ptr->redraw |= (PR_STATUS);
2675
2676         /* Nothing to notice */
2677         if (!notice) return (FALSE);
2678
2679         /* Disturb */
2680         if (disturb_state) disturb(0, 0);
2681
2682         /* Recalculate bonuses */
2683         p_ptr->update |= (PU_BONUS);
2684
2685         /* Recalculate hitpoints */
2686         p_ptr->update |= (PU_HP);
2687
2688         /* Handle stuff */
2689         handle_stuff();
2690
2691         /* Result */
2692         return (TRUE);
2693 }
2694
2695
2696 /*
2697  * Set a temporary elemental brand.  Clear all other brands.  Print status 
2698  * messages. -LM-
2699  */
2700 bool set_ele_attack(u32b attack_type, int v)
2701 {
2702         /* Hack -- Force good values */
2703         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2704
2705         /* Clear all elemental attacks (only one is allowed at a time). */
2706         if ((p_ptr->special_attack & (ATTACK_ACID)) && (attack_type != ATTACK_ACID))
2707         {
2708                 p_ptr->special_attack &= ~(ATTACK_ACID);
2709 #ifdef JP
2710                 msg_print("»À¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2711 #else
2712                 msg_print("Your temporary acidic brand fades away.");
2713 #endif
2714         }
2715         if ((p_ptr->special_attack & (ATTACK_ELEC)) && (attack_type != ATTACK_ELEC))
2716         {
2717                 p_ptr->special_attack &= ~(ATTACK_ELEC);
2718 #ifdef JP
2719                 msg_print("ÅÅ·â¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2720 #else
2721                 msg_print("Your temporary electrical brand fades away.");
2722 #endif
2723         }
2724         if ((p_ptr->special_attack & (ATTACK_FIRE)) && (attack_type != ATTACK_FIRE))
2725         {
2726                 p_ptr->special_attack &= ~(ATTACK_FIRE);
2727 #ifdef JP
2728                 msg_print("²Ð±ê¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2729 #else
2730                 msg_print("Your temporary fiery brand fades away.");
2731 #endif
2732         }
2733         if ((p_ptr->special_attack & (ATTACK_COLD)) && (attack_type != ATTACK_COLD))
2734         {
2735                 p_ptr->special_attack &= ~(ATTACK_COLD);
2736 #ifdef JP
2737                 msg_print("Î䵤¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2738 #else
2739                 msg_print("Your temporary frost brand fades away.");
2740 #endif
2741         }
2742         if ((p_ptr->special_attack & (ATTACK_POIS)) && (attack_type != ATTACK_POIS))
2743         {
2744                 p_ptr->special_attack &= ~(ATTACK_POIS);
2745 #ifdef JP
2746                 msg_print("ÆǤǹ¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2747 #else
2748                 msg_print("Your temporary poison brand fades away.");
2749 #endif
2750         }
2751
2752         if ((v) && (attack_type))
2753         {
2754                 /* Set attack type. */
2755                 p_ptr->special_attack |= (attack_type);
2756
2757                 /* Set duration. */
2758                 p_ptr->ele_attack = v;
2759
2760                 /* Message. */
2761 #ifdef JP
2762                 msg_format("%s¤Ç¹¶·â¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª",
2763                              ((attack_type == ATTACK_ACID) ? "»À" :
2764                               ((attack_type == ATTACK_ELEC) ? "ÅÅ·â" :
2765                                ((attack_type == ATTACK_FIRE) ? "²Ð±ê" : 
2766                                 ((attack_type == ATTACK_COLD) ? "Î䵤" : 
2767                                  ((attack_type == ATTACK_POIS) ? "ÆÇ" : 
2768                                         "(¤Ê¤·)"))))));
2769 #else
2770                 msg_format("For a while, the blows you deal will %s",
2771                              ((attack_type == ATTACK_ACID) ? "melt with acid!" :
2772                               ((attack_type == ATTACK_ELEC) ? "shock your foes!" :
2773                                ((attack_type == ATTACK_FIRE) ? "burn with fire!" : 
2774                                 ((attack_type == ATTACK_COLD) ? "chill to the bone!" : 
2775                                  ((attack_type == ATTACK_POIS) ? "poison your enemies!" : 
2776                                         "do nothing special."))))));
2777 #endif
2778         }
2779
2780         /* Disturb */
2781         if (disturb_state) disturb(0, 0);
2782
2783         /* Redraw status bar */
2784         p_ptr->redraw |= (PR_STATUS);
2785
2786         p_ptr->update |= (PU_BONUS);
2787
2788         /* Handle stuff */
2789         handle_stuff();
2790
2791         return (TRUE);
2792 }
2793
2794
2795 /*
2796  * Set a temporary elemental brand.  Clear all other brands.  Print status 
2797  * messages. -LM-
2798  */
2799 bool set_ele_immune(u32b immune_type, int v)
2800 {
2801         /* Hack -- Force good values */
2802         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2803
2804         /* Clear all elemental attacks (only one is allowed at a time). */
2805         if ((p_ptr->special_defense & (DEFENSE_ACID)) && (immune_type != DEFENSE_ACID))
2806         {
2807                 p_ptr->special_defense &= ~(DEFENSE_ACID);
2808 #ifdef JP
2809                 msg_print("»À¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
2810 #else
2811                 msg_print("You are no longer immune to acid.");
2812 #endif
2813         }
2814         if ((p_ptr->special_defense & (DEFENSE_ELEC)) && (immune_type != DEFENSE_ELEC))
2815         {
2816                 p_ptr->special_defense &= ~(DEFENSE_ELEC);
2817 #ifdef JP
2818                 msg_print("ÅÅ·â¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
2819 #else
2820                 msg_print("You are no longer immune to electricity.");
2821 #endif
2822         }
2823         if ((p_ptr->special_defense & (DEFENSE_FIRE)) && (immune_type != DEFENSE_FIRE))
2824         {
2825                 p_ptr->special_defense &= ~(DEFENSE_FIRE);
2826 #ifdef JP
2827                 msg_print("²Ð±ê¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
2828 #else
2829                 msg_print("You are no longer immune to fire.");
2830 #endif
2831         }
2832         if ((p_ptr->special_defense & (DEFENSE_COLD)) && (immune_type != DEFENSE_COLD))
2833         {
2834                 p_ptr->special_defense &= ~(DEFENSE_COLD);
2835 #ifdef JP
2836                 msg_print("Î䵤¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
2837 #else
2838                 msg_print("You are no longer immune to cold.");
2839 #endif
2840         }
2841         if ((p_ptr->special_defense & (DEFENSE_POIS)) && (immune_type != DEFENSE_POIS))
2842         {
2843                 p_ptr->special_defense &= ~(DEFENSE_POIS);
2844 #ifdef JP
2845                 msg_print("ÆǤι¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
2846 #else
2847                 msg_print("You are no longer immune to poison.");
2848 #endif
2849         }
2850
2851         if ((v) && (immune_type))
2852         {
2853                 /* Set attack type. */
2854                 p_ptr->special_defense |= (immune_type);
2855
2856                 /* Set duration. */
2857                 p_ptr->ele_immune = v;
2858
2859                 /* Message. */
2860 #ifdef JP
2861                 msg_format("%s¤Î¹¶·â¤ò¼õ¤±¤Ä¤±¤Ê¤¯¤Ê¤Ã¤¿¡ª",
2862                              ((immune_type == DEFENSE_ACID) ? "»À" :
2863                               ((immune_type == DEFENSE_ELEC) ? "ÅÅ·â" :
2864                                ((immune_type == DEFENSE_FIRE) ? "²Ð±ê" : 
2865                                 ((immune_type == DEFENSE_COLD) ? "Î䵤" : 
2866                                  ((immune_type == DEFENSE_POIS) ? "ÆÇ" : 
2867                                         "(¤Ê¤·)"))))));
2868 #else
2869                 msg_format("For a while, You are immune to %s",
2870                              ((immune_type == DEFENSE_ACID) ? "acid!" :
2871                               ((immune_type == DEFENSE_ELEC) ? "electricity!" :
2872                                ((immune_type == DEFENSE_FIRE) ? "fire!" : 
2873                                 ((immune_type == DEFENSE_COLD) ? "cold!" : 
2874                                  ((immune_type == DEFENSE_POIS) ? "poison!" : 
2875                                         "do nothing special."))))));
2876 #endif
2877         }
2878
2879         /* Disturb */
2880         if (disturb_state) disturb(0, 0);
2881
2882         /* Redraw status bar */
2883         p_ptr->redraw |= (PR_STATUS);
2884
2885         p_ptr->update |= (PU_BONUS);
2886
2887         /* Handle stuff */
2888         handle_stuff();
2889
2890         return (TRUE);
2891 }
2892
2893
2894 /*
2895  * Set "p_ptr->oppose_acid", notice observable changes
2896  */
2897 bool set_oppose_acid(int v, bool do_dec)
2898 {
2899         bool notice = FALSE;
2900
2901         /* Hack -- Force good values */
2902         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2903
2904         if (death) return FALSE;
2905
2906         /* Open */
2907         if (v)
2908         {
2909                 if (p_ptr->oppose_acid && !do_dec)
2910                 {
2911                         if (p_ptr->oppose_acid > v) return FALSE;
2912                 }
2913                 else if (!p_ptr->oppose_acid)
2914                 {
2915 #ifdef JP
2916 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
2917 #else
2918                         msg_print("You feel resistant to acid!");
2919 #endif
2920
2921                         notice = TRUE;
2922                 }
2923         }
2924
2925         /* Shut */
2926         else
2927         {
2928                 if (p_ptr->oppose_acid && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
2929                 {
2930 #ifdef JP
2931 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
2932 #else
2933                         msg_print("You feel less resistant to acid.");
2934 #endif
2935
2936                         notice = TRUE;
2937                 }
2938         }
2939
2940         /* Use the value */
2941         p_ptr->oppose_acid = v;
2942
2943         /* Nothing to notice */
2944         if (!notice) return (FALSE);
2945
2946         /* Redraw status bar */
2947         p_ptr->redraw |= (PR_STATUS);
2948
2949         /* Disturb */
2950         if (disturb_state) disturb(0, 0);
2951
2952         /* Handle stuff */
2953         handle_stuff();
2954
2955         /* Result */
2956         return (TRUE);
2957 }
2958
2959
2960 /*
2961  * Set "p_ptr->oppose_elec", notice observable changes
2962  */
2963 bool set_oppose_elec(int v, bool do_dec)
2964 {
2965         bool notice = FALSE;
2966
2967         /* Hack -- Force good values */
2968         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2969
2970         if (death) return FALSE;
2971
2972         /* Open */
2973         if (v)
2974         {
2975                 if (p_ptr->oppose_elec && !do_dec)
2976                 {
2977                         if (p_ptr->oppose_elec > v) return FALSE;
2978                 }
2979                 else if (!p_ptr->oppose_elec)
2980                 {
2981 #ifdef JP
2982 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
2983 #else
2984                         msg_print("You feel resistant to electricity!");
2985 #endif
2986
2987                         notice = TRUE;
2988                 }
2989         }
2990
2991         /* Shut */
2992         else
2993         {
2994                 if (p_ptr->oppose_elec && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
2995                 {
2996 #ifdef JP
2997 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
2998 #else
2999                         msg_print("You feel less resistant to electricity.");
3000 #endif
3001
3002                         notice = TRUE;
3003                 }
3004         }
3005
3006         /* Use the value */
3007         p_ptr->oppose_elec = v;
3008
3009         /* Nothing to notice */
3010         if (!notice) return (FALSE);
3011
3012         /* Redraw status bar */
3013         p_ptr->redraw |= (PR_STATUS);
3014
3015         /* Disturb */
3016         if (disturb_state) disturb(0, 0);
3017
3018         /* Handle stuff */
3019         handle_stuff();
3020
3021         /* Result */
3022         return (TRUE);
3023 }
3024
3025
3026 /*
3027  * Set "p_ptr->oppose_fire", notice observable changes
3028  */
3029 bool set_oppose_fire(int v, bool do_dec)
3030 {
3031         bool notice = FALSE;
3032
3033         /* Hack -- Force good values */
3034         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3035
3036         if (death) return FALSE;
3037
3038         if ((prace_is_(RACE_DEMON) && (p_ptr->lev > 44)) || (p_ptr->mimic_form == MIMIC_DEMON)) v = 1;
3039         /* Open */
3040         if (v)
3041         {
3042                 if (p_ptr->oppose_fire && !do_dec)
3043                 {
3044                         if (p_ptr->oppose_fire > v) return FALSE;
3045                 }
3046                 else if (!p_ptr->oppose_fire)
3047                 {
3048 #ifdef JP
3049 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3050 #else
3051                         msg_print("You feel resistant to fire!");
3052 #endif
3053
3054                         notice = TRUE;
3055                 }
3056         }
3057
3058         /* Shut */
3059         else
3060         {
3061                 if (p_ptr->oppose_fire && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
3062                 {
3063 #ifdef JP
3064 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3065 #else
3066                         msg_print("You feel less resistant to fire.");
3067 #endif
3068
3069                         notice = TRUE;
3070                 }
3071         }
3072
3073         /* Use the value */
3074         p_ptr->oppose_fire = v;
3075
3076         /* Nothing to notice */
3077         if (!notice) return (FALSE);
3078
3079         /* Redraw status bar */
3080         p_ptr->redraw |= (PR_STATUS);
3081
3082         /* Disturb */
3083         if (disturb_state) disturb(0, 0);
3084
3085         /* Handle stuff */
3086         handle_stuff();
3087
3088         /* Result */
3089         return (TRUE);
3090 }
3091
3092
3093 /*
3094  * Set "p_ptr->oppose_cold", notice observable changes
3095  */
3096 bool set_oppose_cold(int v, bool do_dec)
3097 {
3098         bool notice = FALSE;
3099
3100         /* Hack -- Force good values */
3101         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3102
3103         if (death) return FALSE;
3104
3105         /* Open */
3106         if (v)
3107         {
3108                 if (p_ptr->oppose_cold && !do_dec)
3109                 {
3110                         if (p_ptr->oppose_cold > v) return FALSE;
3111                 }
3112                 else if (!p_ptr->oppose_cold)
3113                 {
3114 #ifdef JP
3115 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3116 #else
3117                         msg_print("You feel resistant to cold!");
3118 #endif
3119
3120                         notice = TRUE;
3121                 }
3122         }
3123
3124         /* Shut */
3125         else
3126         {
3127                 if (p_ptr->oppose_cold && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
3128                 {
3129 #ifdef JP
3130 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3131 #else
3132                         msg_print("You feel less resistant to cold.");
3133 #endif
3134
3135                         notice = TRUE;
3136                 }
3137         }
3138
3139         /* Use the value */
3140         p_ptr->oppose_cold = v;
3141
3142         /* Nothing to notice */
3143         if (!notice) return (FALSE);
3144
3145         /* Redraw status bar */
3146         p_ptr->redraw |= (PR_STATUS);
3147
3148         /* Disturb */
3149         if (disturb_state) disturb(0, 0);
3150
3151         /* Handle stuff */
3152         handle_stuff();
3153
3154         /* Result */
3155         return (TRUE);
3156 }
3157
3158
3159 /*
3160  * Set "p_ptr->oppose_pois", notice observable changes
3161  */
3162 bool set_oppose_pois(int v, bool do_dec)
3163 {
3164         bool notice = FALSE;
3165
3166         /* Hack -- Force good values */
3167         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3168
3169         if ((p_ptr->pclass == CLASS_NINJA) && (p_ptr->lev > 44)) v = 1;
3170         if (death) return FALSE;
3171
3172         /* Open */
3173         if (v)
3174         {
3175                 if (p_ptr->oppose_pois && !do_dec)
3176                 {
3177                         if (p_ptr->oppose_pois > v) return FALSE;
3178                 }
3179                 else if (!p_ptr->oppose_pois)
3180                 {
3181 #ifdef JP
3182 msg_print("ÆǤؤÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3183 #else
3184                         msg_print("You feel resistant to poison!");
3185 #endif
3186
3187                         notice = TRUE;
3188                 }
3189         }
3190
3191         /* Shut */
3192         else
3193         {
3194                 if (p_ptr->oppose_pois && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
3195                 {
3196 #ifdef JP
3197 msg_print("ÆǤؤÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3198 #else
3199                         msg_print("You feel less resistant to poison.");
3200 #endif
3201
3202                         notice = TRUE;
3203                 }
3204         }
3205
3206         /* Use the value */
3207         p_ptr->oppose_pois = v;
3208
3209         /* Nothing to notice */
3210         if (!notice) return (FALSE);
3211
3212         /* Redraw status bar */
3213         p_ptr->redraw |= (PR_STATUS);
3214
3215         /* Disturb */
3216         if (disturb_state) disturb(0, 0);
3217
3218         /* Handle stuff */
3219         handle_stuff();
3220
3221         /* Result */
3222         return (TRUE);
3223 }
3224
3225
3226 /*
3227  * Set "p_ptr->stun", notice observable changes
3228  *
3229  * Note the special code to only notice "range" changes.
3230  */
3231 bool set_stun(int v)
3232 {
3233         int old_aux, new_aux;
3234         bool notice = FALSE;
3235
3236
3237         /* Hack -- Force good values */
3238         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3239
3240         if (death) return FALSE;
3241
3242         if (prace_is_(RACE_GOLEM) || ((p_ptr->pclass == CLASS_BERSERKER) && (p_ptr->lev > 34))) v = 0;
3243
3244         /* Knocked out */
3245         if (p_ptr->stun > 100)
3246         {
3247                 old_aux = 3;
3248         }
3249
3250         /* Heavy stun */
3251         else if (p_ptr->stun > 50)
3252         {
3253                 old_aux = 2;
3254         }
3255
3256         /* Stun */
3257         else if (p_ptr->stun > 0)
3258         {
3259                 old_aux = 1;
3260         }
3261
3262         /* None */
3263         else
3264         {
3265                 old_aux = 0;
3266         }
3267
3268         /* Knocked out */
3269         if (v > 100)
3270         {
3271                 new_aux = 3;
3272         }
3273
3274         /* Heavy stun */
3275         else if (v > 50)
3276         {
3277                 new_aux = 2;
3278         }
3279
3280         /* Stun */
3281         else if (v > 0)
3282         {
3283                 new_aux = 1;
3284         }
3285
3286         /* None */
3287         else
3288         {
3289                 new_aux = 0;
3290         }
3291
3292         /* Increase cut */
3293         if (new_aux > old_aux)
3294         {
3295                 /* Describe the state */
3296                 switch (new_aux)
3297                 {
3298                         /* Stun */
3299                         case 1:
3300 #ifdef JP
3301 msg_print("°Õ¼±¤¬¤â¤¦¤í¤¦¤È¤·¤Æ¤­¤¿¡£");
3302 #else
3303                         msg_print("You have been stunned.");
3304 #endif
3305
3306                         break;
3307
3308                         /* Heavy stun */
3309                         case 2:
3310 #ifdef JP
3311 msg_print("°Õ¼±¤¬¤Ò¤É¤¯¤â¤¦¤í¤¦¤È¤·¤Æ¤­¤¿¡£");
3312 #else
3313                         msg_print("You have been heavily stunned.");
3314 #endif
3315
3316                         break;
3317
3318                         /* Knocked out */
3319                         case 3:
3320 #ifdef JP
3321 msg_print("Ƭ¤¬¥¯¥é¥¯¥é¤·¤Æ°Õ¼±¤¬±ó¤Î¤¤¤Æ¤­¤¿¡£");
3322 #else
3323                         msg_print("You have been knocked out.");
3324 #endif
3325
3326                         break;
3327                 }
3328
3329                 if (randint(1000) < v || randint(16) == 1)
3330                 {
3331 #ifdef JP
3332 msg_print("³ä¤ì¤ë¤è¤¦¤ÊƬÄˤ¬¤¹¤ë¡£");
3333 #else
3334                         msg_print("A vicious blow hits your head.");
3335 #endif
3336
3337                         if (randint(3) == 1)
3338                         {
3339                                 if (!p_ptr->sustain_int) (void)do_dec_stat(A_INT);
3340                                 if (!p_ptr->sustain_wis) (void)do_dec_stat(A_WIS);
3341                         }
3342                         else if (randint(2) == 1)
3343                         {
3344                                 if (!p_ptr->sustain_int) (void)do_dec_stat(A_INT);
3345                         }
3346                         else
3347                         {
3348                                 if (!p_ptr->sustain_wis) (void)do_dec_stat(A_WIS);
3349                         }
3350                 }
3351                 if (p_ptr->special_defense & KATA_MASK)
3352                 {
3353 #ifdef JP
3354                         msg_print("·¿¤¬Êø¤ì¤¿¡£");
3355 #else
3356                         msg_print("Your posture gets loose.");
3357 #endif
3358                         p_ptr->special_defense &= ~(KATA_MASK);
3359                         p_ptr->update |= (PU_BONUS);
3360                         p_ptr->update |= (PU_MONSTERS);
3361                         p_ptr->redraw |= (PR_STATE);
3362                         p_ptr->redraw |= (PR_STATUS);
3363                         p_ptr->action = ACTION_NONE;
3364                 }
3365
3366                 /* Notice */
3367                 notice = TRUE;
3368         }
3369
3370         /* Decrease cut */
3371         else if (new_aux < old_aux)
3372         {
3373                 /* Describe the state */
3374                 switch (new_aux)
3375                 {
3376                         /* None */
3377                         case 0:
3378 #ifdef JP
3379 msg_print("¤ä¤Ã¤ÈÛ¯Û°¾õÂÖ¤«¤é²óÉü¤·¤¿¡£");
3380 #else
3381                         msg_print("You are no longer stunned.");
3382 #endif
3383
3384                         if (disturb_state) disturb(0, 0);
3385                         break;
3386                 }
3387
3388                 /* Notice */
3389                 notice = TRUE;
3390         }
3391
3392         /* Use the value */
3393         p_ptr->stun = v;
3394
3395         /* No change */
3396         if (!notice) return (FALSE);
3397
3398         /* Disturb */
3399         if (disturb_state) disturb(0, 0);
3400
3401         /* Recalculate bonuses */
3402         p_ptr->update |= (PU_BONUS);
3403
3404         /* Redraw the "stun" */
3405         p_ptr->redraw |= (PR_STUN);
3406
3407         /* Handle stuff */
3408         handle_stuff();
3409
3410         /* Result */
3411         return (TRUE);
3412 }
3413
3414
3415 /*
3416  * Set "p_ptr->cut", notice observable changes
3417  *
3418  * Note the special code to only notice "range" changes.
3419  */
3420 bool set_cut(int v)
3421 {
3422         int old_aux, new_aux;
3423         bool notice = FALSE;
3424
3425         /* Hack -- Force good values */
3426         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3427
3428         if (death) return FALSE;
3429
3430         if ((p_ptr->prace == RACE_GOLEM ||
3431             p_ptr->prace == RACE_SKELETON ||
3432             p_ptr->prace == RACE_SPECTRE ||
3433                 (p_ptr->prace == RACE_ZOMBIE && p_ptr->lev > 11)) &&
3434             !p_ptr->mimic_form)
3435                 v = 0;
3436
3437         /* Mortal wound */
3438         if (p_ptr->cut > 1000)
3439         {
3440                 old_aux = 7;
3441         }
3442
3443         /* Deep gash */
3444         else if (p_ptr->cut > 200)
3445         {
3446                 old_aux = 6;
3447         }
3448
3449         /* Severe cut */
3450         else if (p_ptr->cut > 100)
3451         {
3452                 old_aux = 5;
3453         }
3454
3455         /* Nasty cut */
3456         else if (p_ptr->cut > 50)
3457         {
3458                 old_aux = 4;
3459         }
3460
3461         /* Bad cut */
3462         else if (p_ptr->cut > 25)
3463         {
3464                 old_aux = 3;
3465         }
3466
3467         /* Light cut */
3468         else if (p_ptr->cut > 10)
3469         {
3470                 old_aux = 2;
3471         }
3472
3473         /* Graze */
3474         else if (p_ptr->cut > 0)
3475         {
3476                 old_aux = 1;
3477         }
3478
3479         /* None */
3480         else
3481         {
3482                 old_aux = 0;
3483         }
3484
3485         /* Mortal wound */
3486         if (v > 1000)
3487         {
3488                 new_aux = 7;
3489         }
3490
3491         /* Deep gash */
3492         else if (v > 200)
3493         {
3494                 new_aux = 6;
3495         }
3496
3497         /* Severe cut */
3498         else if (v > 100)
3499         {
3500                 new_aux = 5;
3501         }
3502
3503         /* Nasty cut */
3504         else if (v > 50)
3505         {
3506                 new_aux = 4;
3507         }
3508
3509         /* Bad cut */
3510         else if (v > 25)
3511         {
3512                 new_aux = 3;
3513         }
3514
3515         /* Light cut */
3516         else if (v > 10)
3517         {
3518                 new_aux = 2;
3519         }
3520
3521         /* Graze */
3522         else if (v > 0)
3523         {
3524                 new_aux = 1;
3525         }
3526
3527         /* None */
3528         else
3529         {
3530                 new_aux = 0;
3531         }
3532
3533         /* Increase cut */
3534         if (new_aux > old_aux)
3535         {
3536                 /* Describe the state */
3537                 switch (new_aux)
3538                 {
3539                         /* Graze */
3540                         case 1:
3541 #ifdef JP
3542 msg_print("¤«¤¹¤ê½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3543 #else
3544                         msg_print("You have been given a graze.");
3545 #endif
3546
3547                         break;
3548
3549                         /* Light cut */
3550                         case 2:
3551 #ifdef JP
3552 msg_print("·Ú¤¤½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3553 #else
3554                         msg_print("You have been given a light cut.");
3555 #endif
3556
3557                         break;
3558
3559                         /* Bad cut */
3560                         case 3:
3561 #ifdef JP
3562 msg_print("¤Ò¤É¤¤½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3563 #else
3564                         msg_print("You have been given a bad cut.");
3565 #endif
3566
3567                         break;
3568
3569                         /* Nasty cut */
3570                         case 4:
3571 #ifdef JP
3572 msg_print("ÂçÊѤʽý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3573 #else
3574                         msg_print("You have been given a nasty cut.");
3575 #endif
3576
3577                         break;
3578
3579                         /* Severe cut */
3580                         case 5:
3581 #ifdef JP
3582 msg_print("½ÅÂç¤Ê½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3583 #else
3584                         msg_print("You have been given a severe cut.");
3585 #endif
3586
3587                         break;
3588
3589                         /* Deep gash */
3590                         case 6:
3591 #ifdef JP
3592 msg_print("¤Ò¤É¤¤¿¼¼ê¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3593 #else
3594                         msg_print("You have been given a deep gash.");
3595 #endif
3596
3597                         break;
3598
3599                         /* Mortal wound */
3600                         case 7:
3601 #ifdef JP
3602 msg_print("Ã×̿Ū¤Ê½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3603 #else
3604                         msg_print("You have been given a mortal wound.");
3605 #endif
3606
3607                         break;
3608                 }
3609
3610                 /* Notice */
3611                 notice = TRUE;
3612
3613                 if (randint(1000) < v || randint(16) == 1)
3614                 {
3615                         if (!p_ptr->sustain_chr)
3616                         {
3617 #ifdef JP
3618 msg_print("¤Ò¤É¤¤½ýÀפ¬»Ä¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3619 #else
3620                                 msg_print("You have been horribly scarred.");
3621 #endif
3622
3623
3624                                 do_dec_stat(A_CHR);
3625                         }
3626                 }
3627         }
3628
3629         /* Decrease cut */
3630         else if (new_aux < old_aux)
3631         {
3632                 /* Describe the state */
3633                 switch (new_aux)
3634                 {
3635                         /* None */
3636                         case 0:
3637 #ifdef JP
3638 msg_format("¤ä¤Ã¤È%s¡£", p_ptr->prace == RACE_ANDROID ? "²ø²æ¤¬Ä¾¤Ã¤¿" : "½Ð·ì¤¬»ß¤Þ¤Ã¤¿");
3639 #else
3640                         msg_print("You are no longer bleeding.");
3641 #endif
3642
3643                         if (disturb_state) disturb(0, 0);
3644                         break;
3645                 }
3646
3647                 /* Notice */
3648                 notice = TRUE;
3649         }
3650
3651         /* Use the value */
3652         p_ptr->cut = v;
3653
3654         /* No change */
3655         if (!notice) return (FALSE);
3656
3657         /* Disturb */
3658         if (disturb_state) disturb(0, 0);
3659
3660         /* Recalculate bonuses */
3661         p_ptr->update |= (PU_BONUS);
3662
3663         /* Redraw the "cut" */
3664         p_ptr->redraw |= (PR_CUT);
3665
3666         /* Handle stuff */
3667         handle_stuff();
3668
3669         /* Result */
3670         return (TRUE);
3671 }
3672
3673
3674 /*
3675  * Set "p_ptr->food", notice observable changes
3676  *
3677  * The "p_ptr->food" variable can get as large as 20000, allowing the
3678  * addition of the most "filling" item, Elvish Waybread, which adds
3679  * 7500 food units, without overflowing the 32767 maximum limit.
3680  *
3681  * Perhaps we should disturb the player with various messages,
3682  * especially messages about hunger status changes.  XXX XXX XXX
3683  *
3684  * Digestion of food is handled in "dungeon.c", in which, normally,
3685  * the player digests about 20 food units per 100 game turns, more
3686  * when "fast", more when "regenerating", less with "slow digestion",
3687  * but when the player is "gorged", he digests 100 food units per 10
3688  * game turns, or a full 1000 food units per 100 game turns.
3689  *
3690  * Note that the player's speed is reduced by 10 units while gorged,
3691  * so if the player eats a single food ration (5000 food units) when
3692  * full (15000 food units), he will be gorged for (5000/100)*10 = 500
3693  * game turns, or 500/(100/5) = 25 player turns (if nothing else is
3694  * affecting the player speed).
3695  */
3696 bool set_food(int v)
3697 {
3698         int old_aux, new_aux;
3699
3700         bool notice = FALSE;
3701
3702         /* Hack -- Force good values */
3703         v = (v > 20000) ? 20000 : (v < 0) ? 0 : v;
3704
3705         /* Fainting / Starving */
3706         if (p_ptr->food < PY_FOOD_FAINT)
3707         {
3708                 old_aux = 0;
3709         }
3710
3711         /* Weak */
3712         else if (p_ptr->food < PY_FOOD_WEAK)
3713         {
3714                 old_aux = 1;
3715         }
3716
3717         /* Hungry */
3718         else if (p_ptr->food < PY_FOOD_ALERT)
3719         {
3720                 old_aux = 2;
3721         }
3722
3723         /* Normal */
3724         else if (p_ptr->food < PY_FOOD_FULL)
3725         {
3726                 old_aux = 3;
3727         }
3728
3729         /* Full */
3730         else if (p_ptr->food < PY_FOOD_MAX)
3731         {
3732                 old_aux = 4;
3733         }
3734
3735         /* Gorged */
3736         else
3737         {
3738                 old_aux = 5;
3739         }
3740
3741         /* Fainting / Starving */
3742         if (v < PY_FOOD_FAINT)
3743         {
3744                 new_aux = 0;
3745         }
3746
3747         /* Weak */
3748         else if (v < PY_FOOD_WEAK)
3749         {
3750                 new_aux = 1;
3751         }
3752
3753         /* Hungry */
3754         else if (v < PY_FOOD_ALERT)
3755         {
3756                 new_aux = 2;
3757         }
3758
3759         /* Normal */
3760         else if (v < PY_FOOD_FULL)
3761         {
3762                 new_aux = 3;
3763         }
3764
3765         /* Full */
3766         else if (v < PY_FOOD_MAX)
3767         {
3768                 new_aux = 4;
3769         }
3770
3771         /* Gorged */
3772         else
3773         {
3774                 new_aux = 5;
3775         }
3776
3777         if (old_aux < 1 && new_aux > 0)
3778                 chg_virtue(V_PATIENCE, 2);
3779         else if (old_aux < 3 && (old_aux != new_aux))
3780                 chg_virtue(V_PATIENCE, 1);
3781         if (old_aux == 2)
3782                 chg_virtue(V_TEMPERANCE, 1);
3783         if (old_aux == 0)
3784                 chg_virtue(V_TEMPERANCE, -1);
3785
3786         /* Food increase */
3787         if (new_aux > old_aux)
3788         {
3789                 /* Describe the state */
3790                 switch (new_aux)
3791                 {
3792                         /* Weak */
3793                         case 1:
3794 #ifdef JP
3795 msg_print("¤Þ¤À¶õÊ¢¤ÇÅݤ줽¤¦¤À¡£");
3796 #else
3797                         msg_print("You are still weak.");
3798 #endif
3799
3800                         break;
3801
3802                         /* Hungry */
3803                         case 2:
3804 #ifdef JP
3805 msg_print("¤Þ¤À¶õÊ¢¤À¡£");
3806 #else
3807                         msg_print("You are still hungry.");
3808 #endif
3809
3810                         break;
3811
3812                         /* Normal */
3813                         case 3:
3814 #ifdef JP
3815 msg_print("¶õÊ¢´¶¤¬¤ª¤µ¤Þ¤Ã¤¿¡£");
3816 #else
3817                         msg_print("You are no longer hungry.");
3818 #endif
3819
3820                         break;
3821
3822                         /* Full */
3823                         case 4:
3824 #ifdef JP
3825 msg_print("ËþÊ¢¤À¡ª");
3826 #else
3827                         msg_print("You are full!");
3828 #endif
3829
3830                         break;
3831
3832                         /* Bloated */
3833                         case 5:
3834 #ifdef JP
3835 msg_print("¿©¤Ù²á¤®¤À¡ª");
3836 #else
3837                         msg_print("You have gorged yourself!");
3838 #endif
3839                         chg_virtue(V_HARMONY, -1);
3840                         chg_virtue(V_PATIENCE, -1);
3841                         chg_virtue(V_TEMPERANCE, -2);
3842
3843                         break;
3844                 }
3845
3846                 /* Change */
3847                 notice = TRUE;
3848         }
3849
3850         /* Food decrease */
3851         else if (new_aux < old_aux)
3852         {
3853                 /* Describe the state */
3854                 switch (new_aux)
3855                 {
3856                         /* Fainting / Starving */
3857                         case 0:
3858 #ifdef JP
3859 msg_print("¤¢¤Þ¤ê¤Ë¤â¶õÊ¢¤Çµ¤¤ò¼º¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3860 #else
3861                         msg_print("You are getting faint from hunger!");
3862 #endif
3863
3864                         break;
3865
3866                         /* Weak */
3867                         case 1:
3868 #ifdef JP
3869 msg_print("¤ªÊ¢¤¬¶õ¤¤¤ÆÅݤ줽¤¦¤À¡£");
3870 #else
3871                         msg_print("You are getting weak from hunger!");
3872 #endif
3873
3874                         break;
3875
3876                         /* Hungry */
3877                         case 2:
3878 #ifdef JP
3879 msg_print("¤ªÊ¢¤¬¶õ¤¤¤Æ¤­¤¿¡£");
3880 #else
3881                         msg_print("You are getting hungry.");
3882 #endif
3883
3884                         break;
3885
3886                         /* Normal */
3887                         case 3:
3888 #ifdef JP
3889 msg_print("ËþÊ¢´¶¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
3890 #else
3891                         msg_print("You are no longer full.");
3892 #endif
3893
3894                         break;
3895
3896                         /* Full */
3897                         case 4:
3898 #ifdef JP
3899 msg_print("¤ä¤Ã¤È¤ªÊ¢¤¬¤­¤Ä¤¯¤Ê¤¯¤Ê¤Ã¤¿¡£");
3900 #else
3901                         msg_print("You are no longer gorged.");
3902 #endif
3903
3904                         break;
3905                 }
3906
3907                 if (p_ptr->wild_mode && (new_aux < 2))
3908                 {
3909                         p_ptr->wilderness_x = px;
3910                         p_ptr->wilderness_y = py;
3911                         p_ptr->energy = 100;
3912                         change_wild_mode();
3913                 }
3914
3915                 /* Change */
3916                 notice = TRUE;
3917         }
3918
3919         /* Use the value */
3920         p_ptr->food = v;
3921
3922         /* Nothing to notice */
3923         if (!notice) return (FALSE);
3924
3925         /* Disturb */
3926         if (disturb_state) disturb(0, 0);
3927
3928         /* Recalculate bonuses */
3929         p_ptr->update |= (PU_BONUS);
3930
3931         /* Redraw hunger */
3932         p_ptr->redraw |= (PR_HUNGER);
3933
3934         /* Handle stuff */
3935         handle_stuff();
3936
3937         /* Result */
3938         return (TRUE);
3939 }
3940
3941 /*
3942  * Increases a stat by one randomized level             -RAK-
3943  *
3944  * Note that this function (used by stat potions) now restores
3945  * the stat BEFORE increasing it.
3946  */
3947 bool inc_stat(int stat)
3948 {
3949         int value, gain;
3950
3951         /* Then augment the current/max stat */
3952         value = p_ptr->stat_cur[stat];
3953
3954         /* Cannot go above 18/100 */
3955         if (value < p_ptr->stat_max_max[stat])
3956         {
3957                 /* Gain one (sometimes two) points */
3958                 if (value < 18)
3959                 {
3960                         gain = ((rand_int(100) < 75) ? 1 : 2);
3961                         value += gain;
3962                 }
3963
3964                 /* Gain 1/6 to 1/3 of distance to 18/100 */
3965                 else if (value < (p_ptr->stat_max_max[stat]-2))
3966                 {
3967                         /* Approximate gain value */
3968                         gain = (((p_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
3969
3970                         /* Paranoia */
3971                         if (gain < 1) gain = 1;
3972
3973                         /* Apply the bonus */
3974                         value += randint(gain) + gain / 2;
3975
3976                         /* Maximal value */
3977                         if (value > (p_ptr->stat_max_max[stat]-1)) value = p_ptr->stat_max_max[stat]-1;
3978                 }
3979
3980                 /* Gain one point at a time */
3981                 else
3982                 {
3983                         value++;
3984                 }
3985
3986                 /* Save the new value */
3987                 p_ptr->stat_cur[stat] = value;
3988
3989                 /* Bring up the maximum too */
3990                 if (value > p_ptr->stat_max[stat])
3991                 {
3992                         p_ptr->stat_max[stat] = value;
3993                 }
3994
3995                 /* Recalculate bonuses */
3996                 p_ptr->update |= (PU_BONUS);
3997
3998                 /* Success */
3999                 return (TRUE);
4000         }
4001
4002         /* Nothing to gain */
4003         return (FALSE);
4004 }
4005
4006
4007
4008 /*
4009  * Decreases a stat by an amount indended to vary from 0 to 100 percent.
4010  *
4011  * Amount could be a little higher in extreme cases to mangle very high
4012  * stats from massive assaults.  -CWS
4013  *
4014  * Note that "permanent" means that the *given* amount is permanent,
4015  * not that the new value becomes permanent.  This may not work exactly
4016  * as expected, due to "weirdness" in the algorithm, but in general,
4017  * if your stat is already drained, the "max" value will not drop all
4018  * the way down to the "cur" value.
4019  */
4020 bool dec_stat(int stat, int amount, int permanent)
4021 {
4022         int cur, max, loss, same, res = FALSE;
4023
4024
4025         /* Acquire current value */
4026         cur = p_ptr->stat_cur[stat];
4027         max = p_ptr->stat_max[stat];
4028
4029         /* Note when the values are identical */
4030         same = (cur == max);
4031
4032         /* Damage "current" value */
4033         if (cur > 3)
4034         {
4035                 /* Handle "low" values */
4036                 if (cur <= 18)
4037                 {
4038                         if (amount > 90) cur--;
4039                         if (amount > 50) cur--;
4040                         if (amount > 20) cur--;
4041                         cur--;
4042                 }
4043
4044                 /* Handle "high" values */
4045                 else
4046                 {
4047                         /* Hack -- Decrement by a random amount between one-quarter */
4048                         /* and one-half of the stat bonus times the percentage, with a */
4049                         /* minimum damage of half the percentage. -CWS */
4050                         loss = (((cur-18) / 2 + 1) / 2 + 1);
4051
4052                         /* Paranoia */
4053                         if (loss < 1) loss = 1;
4054
4055                         /* Randomize the loss */
4056                         loss = ((randint(loss) + loss) * amount) / 100;
4057
4058                         /* Maximal loss */
4059                         if (loss < amount/2) loss = amount/2;
4060
4061                         /* Lose some points */
4062                         cur = cur - loss;
4063
4064                         /* Hack -- Only reduce stat to 17 sometimes */
4065                         if (cur < 18) cur = (amount <= 20) ? 18 : 17;
4066                 }
4067
4068                 /* Prevent illegal values */
4069                 if (cur < 3) cur = 3;
4070
4071                 /* Something happened */
4072                 if (cur != p_ptr->stat_cur[stat]) res = TRUE;
4073         }
4074
4075         /* Damage "max" value */
4076         if (permanent && (max > 3))
4077         {
4078                 chg_virtue(V_SACRIFICE, 1);
4079                 if (stat == A_WIS || stat == A_INT)
4080                         chg_virtue(V_ENLIGHTEN, -2);
4081
4082                 /* Handle "low" values */
4083                 if (max <= 18)
4084                 {
4085                         if (amount > 90) max--;
4086                         if (amount > 50) max--;
4087                         if (amount > 20) max--;
4088                         max--;
4089                 }
4090
4091                 /* Handle "high" values */
4092                 else
4093                 {
4094                         /* Hack -- Decrement by a random amount between one-quarter */
4095                         /* and one-half of the stat bonus times the percentage, with a */
4096                         /* minimum damage of half the percentage. -CWS */
4097                         loss = (((max-18) / 2 + 1) / 2 + 1);
4098                         loss = ((randint(loss) + loss) * amount) / 100;
4099                         if (loss < amount/2) loss = amount/2;
4100
4101                         /* Lose some points */
4102                         max = max - loss;
4103
4104                         /* Hack -- Only reduce stat to 17 sometimes */
4105                         if (max < 18) max = (amount <= 20) ? 18 : 17;
4106                 }
4107
4108                 /* Hack -- keep it clean */
4109                 if (same || (max < cur)) max = cur;
4110
4111                 /* Something happened */
4112                 if (max != p_ptr->stat_max[stat]) res = TRUE;
4113         }
4114
4115         /* Apply changes */
4116         if (res)
4117         {
4118                 /* Actually set the stat to its new value. */
4119                 p_ptr->stat_cur[stat] = cur;
4120                 p_ptr->stat_max[stat] = max;
4121
4122                 /* Recalculate bonuses */
4123                 p_ptr->update |= (PU_BONUS);
4124         }
4125
4126         /* Done */
4127         return (res);
4128 }
4129
4130
4131 /*
4132  * Restore a stat.  Return TRUE only if this actually makes a difference.
4133  */
4134 bool res_stat(int stat)
4135 {
4136         /* Restore if needed */
4137         if (p_ptr->stat_cur[stat] != p_ptr->stat_max[stat])
4138         {
4139                 /* Restore */
4140                 p_ptr->stat_cur[stat] = p_ptr->stat_max[stat];
4141
4142                 /* Recalculate bonuses */
4143                 p_ptr->update |= (PU_BONUS);
4144
4145                 /* Success */
4146                 return (TRUE);
4147         }
4148
4149         /* Nothing to restore */
4150         return (FALSE);
4151 }
4152
4153
4154 /*
4155  * Increase players hit points, notice effects
4156  */
4157 bool hp_player(int num)
4158 {
4159         int vir;
4160         vir = virtue_number(V_VITALITY);
4161         if (vir)
4162         {
4163                 num = num * (p_ptr->virtues[vir - 1] + 1250) / 1250;
4164         }
4165         /* Healing needed */
4166         if (p_ptr->chp < p_ptr->mhp)
4167         {
4168                 if ((num > 0) && (p_ptr->chp < (p_ptr->mhp/3)))
4169                         chg_virtue(V_TEMPERANCE, 1);
4170                 /* Gain hitpoints */
4171                 p_ptr->chp += num;
4172
4173                 /* Enforce maximum */
4174                 if (p_ptr->chp >= p_ptr->mhp)
4175                 {
4176                         p_ptr->chp = p_ptr->mhp;
4177                         p_ptr->chp_frac = 0;
4178                 }
4179
4180                 /* Redraw */
4181                 p_ptr->redraw |= (PR_HP);
4182
4183                 /* Window stuff */
4184                 p_ptr->window |= (PW_PLAYER);
4185
4186                 /* Heal 0-4 */
4187                 if (num < 5)
4188                 {
4189 #ifdef JP
4190 msg_print("¾¯¤·µ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4191 #else
4192                         msg_print("You feel a little better.");
4193 #endif
4194
4195                 }
4196
4197                 /* Heal 5-14 */
4198                 else if (num < 15)
4199                 {
4200 #ifdef JP
4201 msg_print("µ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4202 #else
4203                         msg_print("You feel better.");
4204 #endif
4205
4206                 }
4207
4208                 /* Heal 15-34 */
4209                 else if (num < 35)
4210                 {
4211 #ifdef JP
4212 msg_print("¤È¤Æ¤âµ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4213 #else
4214                         msg_print("You feel much better.");
4215 #endif
4216
4217                 }
4218
4219                 /* Heal 35+ */
4220                 else
4221                 {
4222 #ifdef JP
4223 msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4224 #else
4225                         msg_print("You feel very good.");
4226 #endif
4227
4228                 }
4229
4230                 /* Notice */
4231                 return (TRUE);
4232         }
4233
4234         /* Ignore */
4235         return (FALSE);
4236 }
4237
4238
4239 /*
4240  * Array of stat "descriptions"
4241  */
4242 static cptr desc_stat_pos[] =
4243 {
4244 #ifdef JP
4245 "¶¯¤¯",
4246 #else
4247         "strong",
4248 #endif
4249
4250 #ifdef JP
4251 "ÃÎŪ¤Ë",
4252 #else
4253         "smart",
4254 #endif
4255
4256 #ifdef JP
4257 "¸­¤¯",
4258 #else
4259         "wise",
4260 #endif
4261
4262 #ifdef JP
4263 "´ïÍѤË",
4264 #else
4265         "dextrous",
4266 #endif
4267
4268 #ifdef JP
4269 "·ò¹¯¤Ë",
4270 #else
4271         "healthy",
4272 #endif
4273
4274 #ifdef JP
4275 "Èþ¤·¤¯"
4276 #else
4277         "cute"
4278 #endif
4279
4280 };
4281
4282
4283 /*
4284  * Array of stat "descriptions"
4285  */
4286 static cptr desc_stat_neg[] =
4287 {
4288 #ifdef JP
4289 "¼å¤¯",
4290 "̵ÃΤË",
4291 "¶ò¤«¤Ë",
4292 "ÉÔ´ïÍѤË",
4293 "ÉÔ·ò¹¯¤Ë",
4294 "½¹¤¯"
4295 #else
4296         "weak",
4297         "stupid",
4298         "naive",
4299         "clumsy",
4300         "sickly",
4301         "ugly"
4302 #endif
4303
4304 };
4305
4306
4307 /*
4308  * Lose a "point"
4309  */
4310 bool do_dec_stat(int stat)
4311 {
4312         bool sust = FALSE;
4313
4314         /* Access the "sustain" */
4315         switch (stat)
4316         {
4317                 case A_STR: if (p_ptr->sustain_str) sust = TRUE; break;
4318                 case A_INT: if (p_ptr->sustain_int) sust = TRUE; break;
4319                 case A_WIS: if (p_ptr->sustain_wis) sust = TRUE; break;
4320                 case A_DEX: if (p_ptr->sustain_dex) sust = TRUE; break;
4321                 case A_CON: if (p_ptr->sustain_con) sust = TRUE; break;
4322                 case A_CHR: if (p_ptr->sustain_chr) sust = TRUE; break;
4323         }
4324
4325         /* Sustain */
4326         if (sust && (!ironman_nightmare || rand_int(13)))
4327         {
4328                 /* Message */
4329 #ifdef JP
4330 msg_format("%s¤Ê¤Ã¤¿µ¤¤¬¤·¤¿¤¬¡¢¤¹¤°¤Ë¸µ¤ËÌá¤Ã¤¿¡£",
4331 #else
4332                 msg_format("You feel %s for a moment, but the feeling passes.",
4333 #endif
4334
4335                                 desc_stat_neg[stat]);
4336
4337                 /* Notice effect */
4338                 return (TRUE);
4339         }
4340
4341         /* Attempt to reduce the stat */
4342         if (dec_stat(stat, 10, (ironman_nightmare && !rand_int(13))))
4343         {
4344                 /* Message */
4345 #ifdef JP
4346 msg_format("¤Ò¤É¤¯%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_neg[stat]);
4347 #else
4348                 msg_format("You feel very %s.", desc_stat_neg[stat]);
4349 #endif
4350
4351
4352                 /* Notice effect */
4353                 return (TRUE);
4354         }
4355
4356         /* Nothing obvious */
4357         return (FALSE);
4358 }
4359
4360
4361 /*
4362  * Restore lost "points" in a stat
4363  */
4364 bool do_res_stat(int stat)
4365 {
4366         /* Attempt to increase */
4367         if (res_stat(stat))
4368         {
4369                 /* Message */
4370 #ifdef JP
4371 msg_format("¸µÄ̤ê¤Ë%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_pos[stat]);
4372 #else
4373                 msg_format("You feel less %s.", desc_stat_neg[stat]);
4374 #endif
4375
4376
4377                 /* Notice */
4378                 return (TRUE);
4379         }
4380
4381         /* Nothing obvious */
4382         return (FALSE);
4383 }
4384
4385
4386 /*
4387  * Gain a "point" in a stat
4388  */
4389 bool do_inc_stat(int stat)
4390 {
4391         bool res;
4392
4393         /* Restore strength */
4394         res = res_stat(stat);
4395
4396         /* Attempt to increase */
4397         if (inc_stat(stat))
4398         {
4399                 if (stat == A_WIS)
4400                 {
4401                         chg_virtue(V_ENLIGHTEN, 1);
4402                         chg_virtue(V_FAITH, 1);
4403                 }
4404                 else if (stat == A_INT)
4405                 {
4406                         chg_virtue(V_KNOWLEDGE, 1);
4407                         chg_virtue(V_ENLIGHTEN, 1);
4408                 }
4409                 else if (stat == A_CON)
4410                         chg_virtue(V_VITALITY, 1);
4411
4412                 /* Message */
4413 #ifdef JP
4414 msg_format("¥ï¡¼¥ª¡ª¤È¤Æ¤â%s¤Ê¤Ã¤¿¡ª", desc_stat_pos[stat]);
4415 #else
4416                 msg_format("Wow!  You feel very %s!", desc_stat_pos[stat]);
4417 #endif
4418
4419
4420                 /* Notice */
4421                 return (TRUE);
4422         }
4423
4424         /* Restoration worked */
4425         if (res)
4426         {
4427                 /* Message */
4428 #ifdef JP
4429 msg_format("¸µÄ̤ê¤Ë%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_pos[stat]);
4430 #else
4431                 msg_format("You feel less %s.", desc_stat_neg[stat]);
4432 #endif
4433
4434
4435                 /* Notice */
4436                 return (TRUE);
4437         }
4438
4439         /* Nothing obvious */
4440         return (FALSE);
4441 }
4442
4443
4444 /*
4445  * Restores any drained experience
4446  */
4447 bool restore_level(void)
4448 {
4449         /* Restore experience */
4450         if (p_ptr->exp < p_ptr->max_exp)
4451         {
4452                 /* Message */
4453 #ifdef JP
4454 msg_print("À¸Ì¿ÎϤ¬Ìá¤Ã¤Æ¤­¤¿µ¤¤¬¤¹¤ë¡£");
4455 #else
4456                 msg_print("You feel your life energies returning.");
4457 #endif
4458
4459
4460                 /* Restore the experience */
4461                 p_ptr->exp = p_ptr->max_exp;
4462
4463                 /* Check the experience */
4464                 check_experience();
4465
4466                 /* Did something */
4467                 return (TRUE);
4468         }
4469
4470         /* No effect */
4471         return (FALSE);
4472 }
4473
4474
4475 /*
4476  * Forget everything
4477  */
4478 bool lose_all_info(void)
4479 {
4480         int i;
4481
4482         chg_virtue(V_KNOWLEDGE, -5);
4483         chg_virtue(V_ENLIGHTEN, -5);
4484
4485         /* Forget info about objects */
4486         for (i = 0; i < INVEN_TOTAL; i++)
4487         {
4488                 object_type *o_ptr = &inventory[i];
4489
4490                 /* Skip non-objects */
4491                 if (!o_ptr->k_idx) continue;
4492
4493                 /* Allow "protection" by the MENTAL flag */
4494                 if (o_ptr->ident & (IDENT_MENTAL)) continue;
4495
4496                 /* Remove "default inscriptions" */
4497                 o_ptr->feeling = FEEL_NONE;
4498
4499                 /* Hack -- Clear the "empty" flag */
4500                 o_ptr->ident &= ~(IDENT_EMPTY);
4501
4502                 /* Hack -- Clear the "known" flag */
4503                 o_ptr->ident &= ~(IDENT_KNOWN);
4504
4505                 /* Hack -- Clear the "felt" flag */
4506                 o_ptr->ident &= ~(IDENT_SENSE);
4507         }
4508
4509         /* Recalculate bonuses */
4510         p_ptr->update |= (PU_BONUS);
4511
4512         /* Combine / Reorder the pack (later) */
4513         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
4514
4515         /* Window stuff */
4516         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4517
4518         /* Mega-Hack -- Forget the map */
4519         wiz_dark();
4520
4521         /* It worked */
4522         return (TRUE);
4523 }
4524
4525
4526 void do_poly_wounds(void)
4527 {
4528         /* Changed to always provide at least _some_ healing */
4529         s16b wounds = p_ptr->cut;
4530         s16b hit_p = (p_ptr->mhp - p_ptr->chp);
4531         s16b change = damroll(p_ptr->lev, 5);
4532         bool Nasty_effect = (randint(5) == 1);
4533
4534         if (!(wounds || hit_p || Nasty_effect)) return;
4535
4536 #ifdef JP
4537 msg_print("½ý¤¬¤è¤ê·Ú¤¤¤â¤Î¤ËÊѲ½¤·¤¿¡£");
4538 #else
4539         msg_print("Your wounds are polymorphed into less serious ones.");
4540 #endif
4541
4542         hp_player(change);
4543         if (Nasty_effect)
4544         {
4545 #ifdef JP
4546 msg_print("¿·¤¿¤Ê½ý¤¬¤Ç¤­¤¿¡ª");
4547 take_hit(DAMAGE_LOSELIFE, change / 2, "ÊѲ½¤·¤¿½ý", -1);
4548 #else
4549                 msg_print("A new wound was created!");
4550                 take_hit(DAMAGE_LOSELIFE, change / 2, "a polymorphed wound", -1);
4551 #endif
4552
4553                 set_cut(change);
4554         }
4555         else
4556         {
4557                 set_cut(p_ptr->cut - (change / 2));
4558         }
4559 }
4560
4561
4562 void do_poly_self(void)
4563 {
4564         int power = p_ptr->lev;
4565
4566 #ifdef JP
4567 msg_print("¤¢¤Ê¤¿¤ÏÊѲ½¤Îˬ¤ì¤ò´¶¤¸¤¿...");
4568 #else
4569         msg_print("You feel a change coming over you...");
4570 #endif
4571
4572         chg_virtue(V_CHANCE, 1);
4573
4574         if ((power > rand_int(20)) && (rand_int(3) == 1) && (p_ptr->prace != RACE_ANDROID))
4575         {
4576                 char effect_msg[80] = "";
4577                 int new_race, expfact, goalexpfact, h_percent;
4578
4579                 /* Some form of racial polymorph... */
4580                 power -= 10;
4581
4582                 if ((power > rand_int(5)) && (rand_int(4) == 1))
4583                 {
4584                         /* sex change */
4585                         power -= 2;
4586
4587                         if (p_ptr->psex == SEX_MALE)
4588                         {
4589                                 p_ptr->psex = SEX_FEMALE;
4590                                 sp_ptr = &sex_info[p_ptr->psex];
4591 #ifdef JP
4592 sprintf(effect_msg, "½÷À­¤Î");
4593 #else
4594                                 sprintf(effect_msg, "female ");
4595 #endif
4596
4597                         }
4598                         else
4599                         {
4600                                 p_ptr->psex = SEX_MALE;
4601                                 sp_ptr = &sex_info[p_ptr->psex];
4602 #ifdef JP
4603 sprintf(effect_msg, "ÃËÀ­¤Î");
4604 #else
4605                                 sprintf(effect_msg, "male ");
4606 #endif
4607
4608                         }
4609                 }
4610
4611                 if ((power > rand_int(30)) && (rand_int(5) == 1))
4612                 {
4613                         int tmp = 0;
4614
4615                         /* Harmful deformity */
4616                         power -= 15;
4617
4618                         while (tmp < 6)
4619                         {
4620                                 if (rand_int(2) == 1)
4621                                 {
4622                                         (void)dec_stat(tmp, randint(6) + 6, (randint(3) == 1));
4623                                         power -= 1;
4624                                 }
4625                                 tmp++;
4626                         }
4627
4628                         /* Deformities are discriminated against! */
4629                         (void)dec_stat(A_CHR, randint(6), TRUE);
4630
4631                         if (effect_msg[0])
4632                         {
4633                                 char tmp_msg[10];
4634 #ifdef JP
4635                                 sprintf(tmp_msg,"%s",effect_msg);
4636                                 sprintf(effect_msg,"´ñ·Á¤Î%s",tmp_msg);
4637 #else
4638                                 sprintf(tmp_msg,"%s ",effect_msg);
4639                                 sprintf(effect_msg,"deformed %s ",tmp_msg);
4640 #endif
4641
4642                         }
4643                         else
4644                         {
4645 #ifdef JP
4646                                 sprintf(effect_msg,"´ñ·Á¤Î");
4647 #else
4648                                 sprintf(effect_msg,"deformed ");
4649 #endif
4650
4651                         }
4652                 }
4653
4654                 while ((power > rand_int(20)) && (rand_int(10) == 1))
4655                 {
4656                         /* Polymorph into a less mutated form */
4657                         power -= 10;
4658
4659                         if (!lose_mutation(0))
4660 #ifdef JP
4661 msg_print("´ñ̯¤Ê¤¯¤é¤¤ÉáÄ̤ˤʤ俵¤¤¬¤¹¤ë¡£");
4662 #else
4663                                 msg_print("You feel oddly normal.");
4664 #endif
4665
4666                 }
4667
4668                 /*
4669                  * Restrict the race choices by exp penalty so
4670                  * weak polymorph always means weak race
4671                  */
4672                 if (power < 0)
4673                         goalexpfact = 100;
4674                 else
4675                         goalexpfact = 100 + 3 * rand_int(power);
4676
4677                 do
4678                 {
4679                         new_race = rand_int(MAX_RACES);
4680                         expfact = race_info[new_race].r_exp;
4681                 }
4682                 while (((new_race == p_ptr->prace) && (expfact > goalexpfact)) || (new_race == RACE_ANDROID));
4683
4684 #ifdef JP
4685                 msg_format("¤¢¤Ê¤¿¤Ï%s%s¤ËÊѲ½¤·¤¿¡ª", effect_msg,
4686                                 race_info[new_race].title);
4687 #else
4688                 if (effect_msg[0])
4689                 {
4690                         msg_format("You turn into a%s %s!",
4691                                 ((new_race == RACE_AMBERITE || new_race == RACE_ELF
4692                                 || new_race == RACE_IMP) ? "n" : ""),
4693                                 race_info[new_race].title);
4694                 }
4695                 else
4696                 {
4697                         msg_format("You turn into a %s%s!", effect_msg,
4698                                 race_info[new_race].title);
4699                 }
4700 #endif
4701
4702                 chg_virtue(V_CHANCE, 2);
4703
4704                 if (p_ptr->prace < 32)
4705                 {
4706                         p_ptr->old_race1 |= 1L << p_ptr->prace;
4707                 }
4708                 else
4709                 {
4710                         p_ptr->old_race2 = 1L << (p_ptr->prace-32);
4711                 }
4712                 p_ptr->prace = new_race;
4713                 rp_ptr = &race_info[p_ptr->prace];
4714
4715                 /* Experience factor */
4716                 p_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
4717
4718                 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && ((p_ptr->prace == RACE_KLACKON) || (p_ptr->prace == RACE_SPRITE)))
4719                         p_ptr->expfact -= 15;
4720
4721
4722                 /* Calculate the height/weight for males */
4723                 if (p_ptr->psex == SEX_MALE)
4724                 {
4725                         p_ptr->ht = randnor(rp_ptr->m_b_ht, rp_ptr->m_m_ht);
4726                         h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->m_b_ht);
4727                         p_ptr->wt = randnor((int)(rp_ptr->m_b_wt) * h_percent /100
4728                                             , (int)(rp_ptr->m_m_wt) * h_percent / 300 );
4729                 }
4730
4731                 /* Calculate the height/weight for females */
4732                 else if (p_ptr->psex == SEX_FEMALE)
4733                 {
4734                         p_ptr->ht = randnor(rp_ptr->f_b_ht, rp_ptr->f_m_ht);
4735                         h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->f_b_ht);
4736                         p_ptr->wt = randnor((int)(rp_ptr->f_b_wt) * h_percent /100
4737                                             , (int)(rp_ptr->f_m_wt) * h_percent / 300 );
4738                 }
4739
4740                 check_experience();
4741
4742                 /* Hitdice */
4743                 if (p_ptr->pclass == CLASS_SORCERER)
4744                         p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
4745                 else
4746                         p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
4747
4748                 do_cmd_rerate(FALSE);
4749
4750                 p_ptr->redraw |= (PR_BASIC);
4751
4752                 p_ptr->update |= (PU_BONUS);
4753
4754                 handle_stuff();
4755                 lite_spot(py, px);
4756         }
4757
4758         if ((power > rand_int(30)) && (rand_int(6) == 1))
4759         {
4760                 int tmp = 0;
4761
4762                 /* Abomination! */
4763                 power -= 20;
4764
4765 #ifdef JP
4766 msg_format("%s¤Î¹½À®¤¬ÊѲ½¤·¤¿¡ª", p_ptr->prace == RACE_ANDROID ? "µ¡³£" : "Æâ¡");
4767 #else
4768                 msg_print("Your internal organs are rearranged!");
4769 #endif
4770
4771                 while (tmp < 6)
4772                 {
4773                         (void)dec_stat(tmp, randint(6) + 6, (randint(3) == 1));
4774                         tmp++;
4775                 }
4776                 if (randint(6) == 1)
4777                 {
4778 #ifdef JP
4779 msg_print("¸½ºß»Ñ¤ÇÀ¸¤­¤Æ¤¤¤¯¤Î¤Ïº¤Æñ¤Ê¤è¤¦¤À¡ª");
4780 take_hit(DAMAGE_LOSELIFE, damroll(randint(10), p_ptr->lev), "Ã×̿Ū¤ÊÆÍÁ³ÊÑ°Û", -1);
4781 #else
4782                         msg_print("You find living difficult in your present form!");
4783                         take_hit(DAMAGE_LOSELIFE, damroll(randint(10), p_ptr->lev), "a lethal mutation", -1);
4784 #endif
4785
4786                         power -= 10;
4787                 }
4788         }
4789
4790         if ((power > rand_int(20)) && (rand_int(4) == 1))
4791         {
4792                 power -= 10;
4793
4794                 get_max_stats();
4795                 do_cmd_rerate(FALSE);
4796         }
4797
4798         while ((power > rand_int(15)) && (rand_int(3) == 1))
4799         {
4800                 power -= 7;
4801                 (void)gain_random_mutation(0);
4802         }
4803
4804         if (power > rand_int(5))
4805         {
4806                 power -= 5;
4807                 do_poly_wounds();
4808         }
4809
4810         /* Note: earlier deductions may have left power < 0 already. */
4811         while (power > 0)
4812         {
4813                 mutate_player();
4814                 power--;
4815         }
4816 }
4817
4818
4819 /*
4820  * Decreases players hit points and sets death flag if necessary
4821  *
4822  * XXX XXX XXX Invulnerability needs to be changed into a "shield"
4823  *
4824  * XXX XXX XXX Hack -- this function allows the user to save (or quit)
4825  * the game when he dies, since the "You die." message is shown before
4826  * setting the player to "dead".
4827  */
4828 bool take_hit(int damage_type, int damage, cptr hit_from, int monspell)
4829 {
4830         int old_chp = p_ptr->chp;
4831
4832         char death_message[1024];
4833         char tmp[80];
4834
4835         int warning = (p_ptr->mhp * hitpoint_warn / 10);
4836
4837         /* Paranoia */
4838         if (death) return FALSE;
4839
4840         if (p_ptr->sutemi) damage *= 2;
4841         if (p_ptr->special_defense & KATA_IAI) damage += (damage + 4) / 5;
4842
4843         if (easy_band) damage = (damage+1)/2;
4844
4845         if (damage_type != DAMAGE_USELIFE)
4846         {
4847                 /* Disturb */
4848                 disturb(1, 0);
4849                 if (auto_more)
4850                 {
4851                         now_damaged = TRUE;
4852                 }
4853         }
4854
4855         if (monspell >= 0) learn_spell(monspell);
4856
4857         /* Mega-Hack -- Apply "invulnerability" */
4858         if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE))
4859         {
4860                 if ((p_ptr->invuln || ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN))) && (damage < 9000))
4861                 {
4862                         if (damage_type == DAMAGE_FORCE)
4863                         {
4864 #ifdef JP
4865                                 msg_print("¥Ð¥ê¥¢¤¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
4866 #else
4867                                 msg_print("The attack cuts your shield of invulnerability open!");
4868 #endif
4869                         }
4870                         else if (randint(PENETRATE_INVULNERABILITY) == 1)
4871                         {
4872 #ifdef JP
4873                                 msg_print("̵Ũ¤Î¥Ð¥ê¥¢¤òÇˤäƹ¶·â¤µ¤ì¤¿¡ª");
4874 #else
4875                                 msg_print("The attack penetrates your shield of invulnerability!");
4876 #endif
4877                         }
4878                         else
4879                         {
4880                                 return FALSE;
4881                         }
4882                 }
4883  
4884                 /* Multishadow effects is determined by turn */
4885                 if (p_ptr->multishadow && (turn & 1))
4886                 {
4887                         if (damage_type == DAMAGE_FORCE)
4888                         {
4889 #ifdef JP
4890                                 msg_print("¸¸±Æ¤â¤í¤È¤âÂΤ¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
4891 #else
4892                                 msg_print("The attack hits Shadow together with you!");
4893 #endif
4894                         }
4895                         else if (damage_type == DAMAGE_ATTACK)
4896                         {
4897 #ifdef JP
4898                                 msg_print("¹¶·â¤Ï¸¸±Æ¤ËÌ¿Ã椷¡¢¤¢¤Ê¤¿¤Ë¤ÏÆϤ«¤Ê¤«¤Ã¤¿¡£");
4899 #else
4900                                 msg_print("The attack hits Shadow, you are unharmed!");
4901 #endif
4902                                 return FALSE;
4903                         }
4904                 }
4905                     
4906                 if (p_ptr->wraith_form)
4907                 {
4908                         if (damage_type == DAMAGE_FORCE)
4909                         {
4910 #ifdef JP
4911                                 msg_print("Ⱦʪ¼Á¤ÎÂΤ¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
4912 #else
4913                                 msg_print("The attack cuts through your ethereal body!");
4914 #endif
4915                         }
4916                         else
4917                         {
4918                                 damage /= 2;
4919                                 if ((damage == 0) && (randint(2) == 1)) damage = 1;
4920                         }
4921                 }
4922
4923                 if ((p_ptr->special_defense & KATA_MUSOU))
4924                 {
4925                         damage /= 2;
4926                         if ((damage == 0) && (randint(2) == 1)) damage = 1;
4927                 }
4928         } /* not if LOSELIFE USELIFE */
4929
4930         /* Hurt the player */
4931         p_ptr->chp -= damage;
4932         if(damage_type == DAMAGE_GENO && p_ptr->chp < 0)
4933         {
4934                 p_ptr->chp = 0;
4935         }
4936
4937         /* Display the hitpoints */
4938         p_ptr->redraw |= (PR_HP);
4939
4940         /* Window stuff */
4941         p_ptr->window |= (PW_PLAYER);
4942
4943         handle_stuff();
4944
4945         if (damage_type != DAMAGE_GENO && p_ptr->chp == 0)
4946         {
4947                 chg_virtue(V_SACRIFICE, 1);
4948                 chg_virtue(V_CHANCE, 2);
4949         }
4950
4951         /* Dead player */
4952         if (p_ptr->chp < 0)
4953         {
4954                 char buf[10];
4955                 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
4956
4957 #ifdef JP       /* »à¤ó¤À»þ¤Ë¶¯À©½ªÎ»¤·¤Æ»à¤ò²óÈò¤Ç¤­¤Ê¤¯¤·¤Æ¤ß¤¿ by Habu */
4958                 if (!munchkin_death)
4959                         if(!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
4960 #endif
4961
4962                 /* Sound */
4963                 sound(SOUND_DEATH);
4964
4965                 chg_virtue(V_SACRIFICE, 10);
4966
4967                 /* Leaving */
4968                 p_ptr->leaving = TRUE;
4969
4970                 /* Note death */
4971                 death = TRUE;
4972
4973                 if (p_ptr->inside_arena)
4974                 {
4975 #ifdef JP
4976 msg_format("¤¢¤Ê¤¿¤Ï%s¤ÎÁ°¤ËÇÔ¤ìµî¤Ã¤¿¡£", r_name+r_info[arena_monsters[p_ptr->arena_number]].name);
4977 #else
4978 msg_format("You are beaten by %s.", r_name+r_info[arena_monsters[p_ptr->arena_number]].name);
4979 #endif
4980                         msg_print(NULL);
4981                 }
4982                 else
4983                 {
4984 #ifdef WORLD_SCORE
4985                         /* Make screen dump */
4986                         screen_dump = make_screen_dump();
4987 #endif
4988
4989                         /* Note cause of death */
4990                         (void)strcpy(died_from, hit_from);
4991
4992                         if (p_ptr->image) strcat(died_from,"(?)");
4993
4994                         /* No longer a winner */
4995                         total_winner = FALSE;
4996
4997                         if (p_ptr->inside_arena)
4998 #ifdef JP
4999                                 strcpy(buf,"¥¢¥ê¡¼¥Ê");
5000 #else
5001                                 strcpy(buf,"in the Arena");
5002 #endif
5003                         else if (!dun_level)
5004 #ifdef JP
5005                                 strcpy(buf,"ÃϾå");
5006 #else
5007                                 strcpy(buf,"on The surface");
5008 #endif
5009                         else if (quest_number(dun_level) && ((quest_number(dun_level) < MIN_RANDOM_QUEST) && !(quest_number(dun_level) == QUEST_OBERON || quest_number(dun_level) == QUEST_SERPENT)))
5010 #ifdef JP
5011                                 strcpy(buf,"¥¯¥¨¥¹¥È");
5012 #else
5013                                 strcpy(buf,"in a quest");
5014 #endif
5015                         else
5016 #ifdef JP
5017                                 sprintf(buf,"%d³¬", dun_level);
5018 #else
5019                                 sprintf(buf,"level %d", dun_level);
5020 #endif
5021 #ifdef JP
5022                         sprintf(tmp,"%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£",buf, died_from);
5023 #else
5024                         sprintf(tmp,"killed by %s %s.", died_from, buf);
5025 #endif
5026                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
5027 #ifdef JP
5028                         do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5029 #else
5030                         do_cmd_write_nikki(NIKKI_GAMESTART, 1, "--------   Game  Over   --------");
5031 #endif
5032                         do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5033
5034                         flush();
5035
5036 #ifdef JP
5037 if (get_check("²èÌ̤òÊݸ¤·¤Þ¤¹¤«¡©"))
5038 #else
5039                         if (get_check("Dump the screen? "))
5040 #endif
5041
5042                         {
5043                                 do_cmd_save_screen();
5044                         }
5045
5046                         flush();
5047
5048                         /* Hack -- Note death */
5049                         if (!last_words)
5050                         {
5051 #ifdef JP
5052 msg_format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë");
5053 #else
5054                                 msg_print(android ? "You are broken." : "You die.");
5055 #endif
5056
5057                                 msg_print(NULL);
5058                         }
5059                         else
5060                         {
5061                                 if (streq(died_from, "Seppuku"))
5062                                 {
5063 #ifdef JP
5064                                   get_rnd_line("seppuku_j.txt", 0, death_message);
5065 #else
5066                                         get_rnd_line("seppuku.txt", 0, death_message);
5067 #endif
5068                                 }
5069                                 else
5070                                 {
5071 #ifdef JP
5072 get_rnd_line("death_j.txt", 0, death_message);
5073 #else
5074                                         get_rnd_line("death.txt", 0, death_message);
5075 #endif
5076                                 }
5077 #ifdef JP
5078                                 if (!get_string(streq(died_from, "Seppuku") ? "¼­À¤¤Î¶ç: " : "ÃÇËöËâ¤Î¶«¤Ó: ", death_message, 1024))
5079 #else
5080                                 if (!get_string("Last word: ", death_message, 1024))
5081 #endif
5082
5083                                 {
5084 #ifdef JP
5085                                         strcpy(death_message, format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë"));
5086 #else
5087                                         strcpy(death_message, android ? "You are broken." : "You die.");
5088 #endif
5089                                 }
5090                                 if (streq(died_from, "Seppuku"))
5091                                 {
5092 #ifdef JP
5093                                   int i, len;
5094                                   int w = Term->wid;
5095                                   int h = Term->hgt;
5096                                   int msg_pos_x[9] = {  5,  7,  9, 12,  14,  17,  19,  21, 23};
5097                                   int msg_pos_y[9] = {  3,  4,  5,  4,   5,   4,   5,   6,  4};
5098                                   cptr str;
5099                                   char* str2;
5100
5101                                   Term_clear();
5102
5103                                   /* ºù»¶¤ë */
5104                                   for (i = 0; i < 40; i++) 
5105                                     Term_putstr(rand_int(w / 2) * 2, rand_int(h), 2, TERM_VIOLET, "¦Ô");
5106
5107                                   str = death_message;
5108                                   if (strncmp(str, "¡Ö", 2) == 0) str += 2;
5109
5110                                   str2 = strstr_j(str, "¡×");
5111                                   if (str2 != NULL) str2 = '\0';
5112
5113                                   i = 0;
5114                                   while (i < 9)
5115                                   {
5116                                     str2 = strstr_j(str, " ");
5117                                     if (str2 == NULL) len = strlen(str);
5118                                     else len = str2 - str;
5119
5120                                     if (len != 0)
5121                                     {
5122                                       Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len,
5123                                                   TERM_WHITE, str);
5124                                       if (str2 == NULL) break;
5125                                       i++;
5126                                     }
5127                                     str = str2 + 1;
5128                                     if (*str == 0) break;
5129                                   }
5130                                   flush();
5131                                   (void)inkey();
5132 #else
5133                                         msg_print(death_message);
5134 #endif
5135                                 }
5136                                 else
5137                                         msg_print(death_message);
5138                         }
5139                 }
5140
5141                 /* Dead */
5142                 return TRUE;
5143         }
5144
5145         /* Hitpoint warning */
5146         if (p_ptr->chp < warning)
5147         {
5148                 /* Hack -- bell on first notice */
5149                 if (alert_hitpoint && (old_chp > warning)) bell();
5150
5151                 sound(SOUND_WARN);
5152
5153                 if (record_danger && (old_chp > warning))
5154                 {
5155 #ifdef JP
5156                         sprintf(tmp,"%s¤Ë¤è¤Ã¤Æ¥Ô¥ó¥Á¤Ë´Ù¤¤¤Ã¤¿¡£",hit_from);
5157 #else
5158                         sprintf(tmp,"A critical situation because of %s.",hit_from);
5159 #endif
5160                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
5161                 }
5162
5163                 if (auto_more)
5164                 {
5165                         /* stop auto_more even if DAMAGE_USELIFE */
5166                         now_damaged = TRUE;
5167                 }
5168
5169                 /* Message */
5170 #ifdef JP
5171 msg_print("*** ·Ù¹ð:Äã¥Ò¥Ã¥È¡¦¥Ý¥¤¥ó¥È¡ª ***");
5172 #else
5173                 msg_print("*** LOW HITPOINT WARNING! ***");
5174 #endif
5175
5176                 msg_print(NULL);
5177                 flush();
5178         }
5179         if (p_ptr->wild_mode && !p_ptr->leaving && (p_ptr->chp < MAX(warning, p_ptr->mhp/5)))
5180         {
5181                 p_ptr->wilderness_x = px;
5182                 p_ptr->wilderness_y = py;
5183                 p_ptr->energy = 100;
5184                 change_wild_mode();
5185         }
5186         return TRUE;
5187 }
5188
5189
5190 /*
5191  * Gain experience
5192  */
5193 void gain_exp(s32b amount)
5194 {
5195         if (death) return;
5196
5197         if (p_ptr->prace == RACE_ANDROID) return;
5198
5199         /* Gain some experience */
5200         p_ptr->exp += amount;
5201
5202         /* Slowly recover from experience drainage */
5203         if (p_ptr->exp < p_ptr->max_exp)
5204         {
5205                 /* Gain max experience (20%) (was 10%) */
5206                 p_ptr->max_exp += amount / 5;
5207         }
5208
5209         /* Check Experience */
5210         check_experience();
5211 }
5212
5213
5214 void calc_android_exp(void)
5215 {
5216         int i;
5217         u32b total_exp = 0;
5218         if (death) return;
5219
5220         if (p_ptr->prace != RACE_ANDROID) return;
5221
5222         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
5223         {
5224                 object_type *o_ptr = &inventory[i];
5225                 object_type forge;
5226                 object_type *q_ptr = &forge;
5227                 u32b value, exp;
5228                 int level = MAX(get_object_level(o_ptr) - 8, 1);
5229
5230                 if ((i == INVEN_RIGHT) || (i == INVEN_LEFT) || (i == INVEN_NECK) || (i == INVEN_LITE)) continue;
5231                 if (!o_ptr->k_idx) continue;
5232
5233                 /* Wipe the object */
5234                 object_wipe(q_ptr);
5235
5236                 object_copy(q_ptr, o_ptr);
5237                 q_ptr->discount = 0;
5238                 q_ptr->ident &= ~(IDENT_CURSED);
5239                 q_ptr->art_flags3 &= ~(TR3_CURSED | TR3_HEAVY_CURSE | TR3_PERMA_CURSE | TR3_TY_CURSE);
5240
5241                 if (o_ptr->name1)
5242                 {
5243                         level = (level + MAX(a_info[o_ptr->name1].level - 8, 5)) / 2;
5244                         level += MIN(20, a_info[o_ptr->name1].rarity/(a_info[o_ptr->name1].flags3 & TR3_INSTA_ART ? 10 : 3));
5245                 }
5246                 else if (o_ptr->name2) level += MAX(3, (e_info[o_ptr->name2].rating - 5)/2);
5247                 value = object_value_real(q_ptr);
5248
5249                 if (value <= 0) continue;
5250                 if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI) && (p_ptr->pseikaku != SEIKAKU_SEXY)) value /= 32;
5251                 if (value > 5000000L) value = 5000000L;
5252                 if ((o_ptr->tval == TV_DRAG_ARMOR) || (o_ptr->tval == TV_CARD)) level /= 2;
5253
5254                 if (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name ||
5255                     (o_ptr->tval == TV_DRAG_ARMOR) ||
5256                     ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
5257                     ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
5258                     ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
5259                     ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)) ||
5260                     ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
5261                 {
5262                         if (level > 65) level = 35 + (level - 65) / 5;
5263                         else if (level > 35) level = 25 + (level - 35) / 3;
5264                         else if (level > 15) level = 15 + (level - 15) / 2;
5265                         exp = MIN(100000L, value) * level * level / 2;
5266                         if (value > 100000L)
5267                                 exp += (value - 100000L) * level * level / 8;
5268                 }
5269                 else
5270                 {
5271                         exp = MIN(100000L, value) * level;
5272                         if (value > 100000L)
5273                                 exp += (value - 100000L) * level / 4;
5274                 }
5275                 if ((((i == INVEN_RARM) || (i == INVEN_LARM)) && (buki_motteruka(i))) || (i == INVEN_BOW)) total_exp += exp / 48;
5276                 else total_exp += exp / 16;
5277                 if (i == INVEN_BODY) total_exp += exp / 32;
5278         }
5279         p_ptr->exp = p_ptr->max_exp = total_exp;
5280
5281         /* Check Experience */
5282         check_experience();
5283 }
5284
5285
5286 /*
5287  * Lose experience
5288  */
5289 void lose_exp(s32b amount)
5290 {
5291         if (p_ptr->prace == RACE_ANDROID) return;
5292
5293         /* Never drop below zero experience */
5294         if (amount > p_ptr->exp) amount = p_ptr->exp;
5295
5296         /* Lose some experience */
5297         p_ptr->exp -= amount;
5298
5299         /* Check Experience */
5300         check_experience();
5301 }
5302
5303 bool set_ultimate_res(int v, bool do_dec)
5304 {
5305         bool notice = FALSE;
5306
5307         /* Hack -- Force good values */
5308         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5309
5310         if (death) return FALSE;
5311
5312         /* Open */
5313         if (v)
5314         {
5315                 if (p_ptr->ult_res && !do_dec)
5316                 {
5317                         if (p_ptr->ult_res > v) return FALSE;
5318                 }
5319                 else if (!p_ptr->ult_res)
5320                 {
5321 #ifdef JP
5322 msg_print("¤¢¤é¤æ¤ë¤³¤È¤ËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5323 #else
5324                         msg_print("You feel resistant!");
5325 #endif
5326
5327                         notice = TRUE;
5328                 }
5329         }
5330
5331         /* Shut */
5332         else
5333         {
5334                 if (p_ptr->ult_res)
5335                 {
5336 #ifdef JP
5337 msg_print("¤¢¤é¤æ¤ë¤³¤È¤ËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5338 #else
5339                         msg_print("You feel less resistant");
5340 #endif
5341
5342                         notice = TRUE;
5343                 }
5344         }
5345
5346         /* Use the value */
5347         p_ptr->ult_res = v;
5348
5349         /* Redraw status bar */
5350         p_ptr->redraw |= (PR_STATUS);
5351
5352         /* Nothing to notice */
5353         if (!notice) return (FALSE);
5354
5355         /* Disturb */
5356         if (disturb_state) disturb(0, 0);
5357
5358         /* Recalculate bonuses */
5359         p_ptr->update |= (PU_BONUS);
5360
5361         /* Handle stuff */
5362         handle_stuff();
5363
5364         /* Result */
5365         return (TRUE);
5366 }
5367
5368 bool set_tim_res_nether(int v, bool do_dec)
5369 {
5370         bool notice = FALSE;
5371
5372         /* Hack -- Force good values */
5373         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5374
5375         if (death) return FALSE;
5376
5377         /* Open */
5378         if (v)
5379         {
5380                 if (p_ptr->tim_res_nether && !do_dec)
5381                 {
5382                         if (p_ptr->tim_res_nether > v) return FALSE;
5383                 }
5384                 else if (!p_ptr->tim_res_nether)
5385                 {
5386 #ifdef JP
5387 msg_print("ÃϹö¤ÎÎϤËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5388 #else
5389                         msg_print("You feel nether resistant!");
5390 #endif
5391
5392                         notice = TRUE;
5393                 }
5394         }
5395
5396         /* Shut */
5397         else
5398         {
5399                 if (p_ptr->tim_res_nether)
5400                 {
5401 #ifdef JP
5402 msg_print("ÃϹö¤ÎÎϤËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5403 #else
5404                         msg_print("You feel less nether resistant");
5405 #endif
5406
5407                         notice = TRUE;
5408                 }
5409         }
5410
5411         /* Use the value */
5412         p_ptr->tim_res_nether = v;
5413
5414         /* Redraw status bar */
5415         p_ptr->redraw |= (PR_STATUS);
5416
5417         /* Nothing to notice */
5418         if (!notice) return (FALSE);
5419
5420         /* Disturb */
5421         if (disturb_state) disturb(0, 0);
5422
5423         /* Recalculate bonuses */
5424         p_ptr->update |= (PU_BONUS);
5425
5426         /* Handle stuff */
5427         handle_stuff();
5428
5429         /* Result */
5430         return (TRUE);
5431 }
5432
5433 bool set_tim_res_time(int v, bool do_dec)
5434 {
5435         bool notice = FALSE;
5436
5437         /* Hack -- Force good values */
5438         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5439
5440         if (death) return FALSE;
5441
5442         /* Open */
5443         if (v)
5444         {
5445                 if (p_ptr->tim_res_time && !do_dec)
5446                 {
5447                         if (p_ptr->tim_res_time > v) return FALSE;
5448                 }
5449                 else if (!p_ptr->tim_res_time)
5450                 {
5451 #ifdef JP
5452 msg_print("»þ´ÖµÕž¤ÎÎϤËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5453 #else
5454                         msg_print("You feel time resistant!");
5455 #endif
5456
5457                         notice = TRUE;
5458                 }
5459         }
5460
5461         /* Shut */
5462         else
5463         {
5464                 if (p_ptr->tim_res_time)
5465                 {
5466 #ifdef JP
5467 msg_print("»þ´ÖµÕž¤ÎÎϤËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5468 #else
5469                         msg_print("You feel less time resistant");
5470 #endif
5471
5472                         notice = TRUE;
5473                 }
5474         }
5475
5476         /* Use the value */
5477         p_ptr->tim_res_time = v;
5478
5479         /* Redraw status bar */
5480         p_ptr->redraw |= (PR_STATUS);
5481
5482         /* Nothing to notice */
5483         if (!notice) return (FALSE);
5484
5485         /* Disturb */
5486         if (disturb_state) disturb(0, 0);
5487
5488         /* Recalculate bonuses */
5489         p_ptr->update |= (PU_BONUS);
5490
5491         /* Handle stuff */
5492         handle_stuff();
5493
5494         /* Result */
5495         return (TRUE);
5496 }
5497
5498
5499 /*
5500  * Choose a warrior-mage elemental attack. -LM-
5501  */
5502 bool choose_ele_attack(void)
5503 {
5504         int num;
5505
5506         char choice;
5507
5508         /* Save screen */
5509         screen_save();
5510
5511         num = (p_ptr->lev - 20) / 5;
5512
5513 #ifdef JP
5514                       c_prt(TERM_RED,    "        a) ¾Æ´þ", 2, 14);
5515 #else
5516                       c_prt(TERM_RED,    "        a) Fire Brand", 2, 14);
5517 #endif
5518
5519 #ifdef JP
5520         if (num >= 2) c_prt(TERM_L_WHITE,"        b) Åà·ë", 3, 14);
5521 #else
5522         if (num >= 2) c_prt(TERM_L_WHITE,"        b) Cold Brand", 3, 14);
5523 #endif
5524         else prt("", 3, 14);
5525
5526 #ifdef JP
5527         if (num >= 3) c_prt(TERM_GREEN,  "        c) ÆÇ»¦", 4, 14);
5528 #else
5529         if (num >= 3) c_prt(TERM_GREEN,  "        c) Poison Brand", 4, 14);
5530 #endif
5531         else prt("", 4, 14);
5532
5533 #ifdef JP
5534         if (num >= 4) c_prt(TERM_L_DARK, "        d) Íϲò", 5, 14);
5535 #else
5536         if (num >= 4) c_prt(TERM_L_DARK, "        d) Acid Brand", 5, 14);
5537 #endif
5538         else prt("", 5, 14);
5539
5540 #ifdef JP
5541         if (num >= 5) c_prt(TERM_BLUE,   "        e) ÅÅ·â", 6, 14);
5542 #else
5543         if (num >= 5) c_prt(TERM_BLUE,   "        e) Elec Brand", 6, 14);
5544 #endif
5545         else prt("", 6, 14);
5546
5547         prt("", 7, 14);
5548         prt("", 8, 14);
5549         prt("", 9, 14);
5550
5551         prt("", 1, 0);
5552 #ifdef JP
5553         prt("        ¤É¤Î¸µÁǹ¶·â¤ò¤·¤Þ¤¹¤«¡©", 1, 14);
5554 #else
5555         prt("        Choose a temporary elemental brand ", 1, 14);
5556 #endif
5557
5558         choice = inkey();
5559
5560         if ((choice == 'a') || (choice == 'A')) 
5561                 set_ele_attack(ATTACK_FIRE, p_ptr->lev/2 + randint(p_ptr->lev/2));
5562         else if (((choice == 'b') || (choice == 'B')) && (num >= 2))
5563                 set_ele_attack(ATTACK_COLD, p_ptr->lev/2 + randint(p_ptr->lev/2));
5564         else if (((choice == 'c') || (choice == 'C')) && (num >= 3))
5565                 set_ele_attack(ATTACK_POIS, p_ptr->lev/2 + randint(p_ptr->lev/2));
5566         else if (((choice == 'd') || (choice == 'D')) && (num >= 4))
5567                 set_ele_attack(ATTACK_ACID, p_ptr->lev/2 + randint(p_ptr->lev/2));
5568         else if (((choice == 'e') || (choice == 'E')) && (num >= 5))
5569                 set_ele_attack(ATTACK_ELEC, p_ptr->lev/2 + randint(p_ptr->lev/2));
5570         else
5571         {
5572 #ifdef JP
5573                 msg_print("ËâË¡·õ¤ò»È¤¦¤Î¤ò¤ä¤á¤¿¡£");
5574 #else
5575                 msg_print("You cancel the temporary branding.");
5576 #endif
5577                 screen_load();
5578                 return FALSE;
5579         }
5580         /* Load screen */
5581         screen_load();
5582         return TRUE;
5583 }
5584
5585
5586 /*
5587  * Choose a elemental immune. -LM-
5588  */
5589 bool choose_ele_immune(int turn)
5590 {
5591         char choice;
5592
5593         /* Save screen */
5594         screen_save();
5595
5596 #ifdef JP
5597         c_prt(TERM_RED,    "        a) ²Ð±ê", 2, 14);
5598 #else
5599         c_prt(TERM_RED,    "        a) Immune Fire", 2, 14);
5600 #endif
5601
5602 #ifdef JP
5603         c_prt(TERM_L_WHITE,"        b) Î䵤", 3, 14);
5604 #else
5605         c_prt(TERM_L_WHITE,"        b) Immune Cold", 3, 14);
5606 #endif
5607
5608 #ifdef JP
5609         c_prt(TERM_L_DARK, "        c) »À", 4, 14);
5610 #else
5611         c_prt(TERM_L_DARK, "        c) Immune Acid", 4, 14);
5612 #endif
5613
5614 #ifdef JP
5615         c_prt(TERM_BLUE,   "        d) ÅÅ·â", 5, 14);
5616 #else
5617         c_prt(TERM_BLUE,   "        d) Immune Elec", 5, 14);
5618 #endif
5619
5620
5621         prt("", 6, 14);
5622         prt("", 7, 14);
5623         prt("", 8, 14);
5624         prt("", 9, 14);
5625
5626         prt("", 1, 0);
5627 #ifdef JP
5628         prt("        ¤É¤Î¸µÁǤÎÌȱ֤ò¤Ä¤±¤Þ¤¹¤«¡©", 1, 14);
5629 #else
5630         prt("        Choose a temporary elemental immune ", 1, 14);
5631 #endif
5632
5633         choice = inkey();
5634
5635         if ((choice == 'a') || (choice == 'A')) 
5636                 set_ele_immune(DEFENSE_FIRE, turn);
5637         else if ((choice == 'b') || (choice == 'B'))
5638                 set_ele_immune(DEFENSE_COLD, turn);
5639         else if ((choice == 'c') || (choice == 'C'))
5640                 set_ele_immune(DEFENSE_ACID, turn);
5641         else if ((choice == 'd') || (choice == 'D'))
5642                 set_ele_immune(DEFENSE_ELEC, turn);
5643         else
5644         {
5645 #ifdef JP
5646                 msg_print("Ìȱ֤òÉÕ¤±¤ë¤Î¤ò¤ä¤á¤¿¡£");
5647 #else
5648                 msg_print("You cancel the temporary immune.");
5649 #endif
5650                 screen_load();
5651                 return FALSE;
5652         }
5653         /* Load screen */
5654         screen_load();
5655         return TRUE;
5656 }