OSDN Git Service

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