OSDN Git Service

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