OSDN Git Service

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