OSDN Git Service

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