OSDN Git Service

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