OSDN Git Service

0b763c2aaa1f0672ee7222030dd559d2905f0fa1
[hengbandforosx/hengbandosx.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_ffall = 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                 m_list[p_ptr->riding].fast = 0;
223                 m_list[p_ptr->riding].slow = 0;
224                 m_list[p_ptr->riding].invulner = 0;
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
1569
1570
1571         /* Handle stuff */
1572         handle_stuff();
1573
1574         /* Result */
1575         return (TRUE);
1576
1577 }
1578
1579
1580 /*
1581  * Set "p_ptr->invuln", notice observable changes
1582  */
1583 bool set_invuln(int v, bool do_dec)
1584 {
1585         bool notice = FALSE;
1586
1587         /* Hack -- Force good values */
1588         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1589
1590         if (p_ptr->is_dead) return FALSE;
1591
1592         /* Open */
1593         if (v)
1594         {
1595                 if (p_ptr->invuln && !do_dec)
1596                 {
1597                         if (p_ptr->invuln > v) return FALSE;
1598                 }
1599                 else if (!IS_INVULN())
1600                 {
1601 #ifdef JP
1602 msg_print("̵Ũ¤À¡ª");
1603 #else
1604                         msg_print("Invulnerability!");
1605 #endif
1606
1607                         notice = TRUE;
1608
1609                         chg_virtue(V_UNLIFE, -2);
1610                         chg_virtue(V_HONOUR, -2);
1611                         chg_virtue(V_SACRIFICE, -3);
1612                         chg_virtue(V_VALOUR, -5);
1613
1614                         /* Redraw map */
1615                         p_ptr->redraw |= (PR_MAP);
1616
1617                         /* Update monsters */
1618                         p_ptr->update |= (PU_MONSTERS);
1619
1620                         /* Window stuff */
1621                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1622                 }
1623         }
1624
1625         /* Shut */
1626         else
1627         {
1628                 if (p_ptr->invuln && !music_singing(MUSIC_INVULN))
1629                 {
1630 #ifdef JP
1631 msg_print("̵Ũ¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
1632 #else
1633                         msg_print("The invulnerability wears off.");
1634 #endif
1635
1636                         notice = TRUE;
1637
1638                         /* Redraw map */
1639                         p_ptr->redraw |= (PR_MAP);
1640
1641                         /* Update monsters */
1642                         p_ptr->update |= (PU_MONSTERS);
1643
1644                         /* Window stuff */
1645                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1646
1647                         p_ptr->energy_need += ENERGY_NEED();
1648                 }
1649         }
1650
1651         /* Use the value */
1652         p_ptr->invuln = v;
1653
1654         /* Redraw status bar */
1655         p_ptr->redraw |= (PR_STATUS);
1656
1657         /* Nothing to notice */
1658         if (!notice) return (FALSE);
1659
1660         /* Disturb */
1661         if (disturb_state) disturb(0, 0);
1662
1663         /* Recalculate bonuses */
1664         p_ptr->update |= (PU_BONUS);
1665
1666         /* Handle stuff */
1667         handle_stuff();
1668
1669         /* Result */
1670         return (TRUE);
1671 }
1672
1673
1674 /*
1675  * Set "p_ptr->tim_esp", notice observable changes
1676  */
1677 bool set_tim_esp(int v, bool do_dec)
1678 {
1679         bool notice = FALSE;
1680
1681         /* Hack -- Force good values */
1682         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1683
1684         if (p_ptr->is_dead) return FALSE;
1685
1686         /* Open */
1687         if (v)
1688         {
1689                 if (p_ptr->tim_esp && !do_dec)
1690                 {
1691                         if (p_ptr->tim_esp > v) return FALSE;
1692                 }
1693                 else if (!IS_TIM_ESP())
1694                 {
1695 #ifdef JP
1696 msg_print("°Õ¼±¤¬¹­¤¬¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1697 #else
1698                         msg_print("You feel your consciousness expand!");
1699 #endif
1700
1701                         notice = TRUE;
1702                 }
1703         }
1704
1705         /* Shut */
1706         else
1707         {
1708                 if (p_ptr->tim_esp && !music_singing(MUSIC_MIND))
1709                 {
1710 #ifdef JP
1711 msg_print("°Õ¼±¤Ï¸µ¤ËÌá¤Ã¤¿¡£");
1712 #else
1713                         msg_print("Your consciousness contracts again.");
1714 #endif
1715
1716                         notice = TRUE;
1717                 }
1718         }
1719
1720         /* Use the value */
1721         p_ptr->tim_esp = v;
1722
1723         /* Redraw status bar */
1724         p_ptr->redraw |= (PR_STATUS);
1725
1726         /* Nothing to notice */
1727         if (!notice) return (FALSE);
1728
1729         /* Disturb */
1730         if (disturb_state) disturb(0, 0);
1731
1732         /* Recalculate bonuses */
1733         p_ptr->update |= (PU_BONUS);
1734
1735         /* Update the monsters */
1736         p_ptr->update |= (PU_MONSTERS);
1737
1738         /* Handle stuff */
1739         handle_stuff();
1740
1741         /* Result */
1742         return (TRUE);
1743 }
1744
1745
1746 /*
1747  * Set "p_ptr->tim_invis", notice observable changes
1748  */
1749 bool set_tim_invis(int v, bool do_dec)
1750 {
1751         bool notice = FALSE;
1752
1753         /* Hack -- Force good values */
1754         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1755
1756         if (p_ptr->is_dead) return FALSE;
1757
1758         /* Open */
1759         if (v)
1760         {
1761                 if (p_ptr->tim_invis && !do_dec)
1762                 {
1763                         if (p_ptr->tim_invis > v) return FALSE;
1764                 }
1765                 else if (!p_ptr->tim_invis)
1766                 {
1767 #ifdef JP
1768 msg_print("Ìܤ¬Èó¾ï¤ËÉÒ´¶¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1769 #else
1770                         msg_print("Your eyes feel very sensitive!");
1771 #endif
1772
1773                         notice = TRUE;
1774                 }
1775         }
1776
1777         /* Shut */
1778         else
1779         {
1780                 if (p_ptr->tim_invis)
1781                 {
1782 #ifdef JP
1783 msg_print("ÌܤÎÉÒ´¶¤µ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
1784 #else
1785                         msg_print("Your eyes feel less sensitive.");
1786 #endif
1787
1788                         notice = TRUE;
1789                 }
1790         }
1791
1792         /* Use the value */
1793         p_ptr->tim_invis = v;
1794
1795         /* Redraw status bar */
1796         p_ptr->redraw |= (PR_STATUS);
1797
1798         /* Nothing to notice */
1799         if (!notice) return (FALSE);
1800
1801         /* Disturb */
1802         if (disturb_state) disturb(0, 0);
1803
1804         /* Recalculate bonuses */
1805         p_ptr->update |= (PU_BONUS);
1806
1807         /* Update the monsters */
1808         p_ptr->update |= (PU_MONSTERS);
1809
1810         /* Handle stuff */
1811         handle_stuff();
1812
1813         /* Result */
1814         return (TRUE);
1815 }
1816
1817
1818 /*
1819  * Set "p_ptr->tim_infra", notice observable changes
1820  */
1821 bool set_tim_infra(int v, bool do_dec)
1822 {
1823         bool notice = FALSE;
1824
1825         /* Hack -- Force good values */
1826         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1827
1828         if (p_ptr->is_dead) return FALSE;
1829
1830         /* Open */
1831         if (v)
1832         {
1833                 if (p_ptr->tim_infra && !do_dec)
1834                 {
1835                         if (p_ptr->tim_infra > v) return FALSE;
1836                 }
1837                 else if (!p_ptr->tim_infra)
1838                 {
1839 #ifdef JP
1840 msg_print("Ìܤ¬¥é¥ó¥é¥ó¤Èµ±¤­»Ï¤á¤¿¡ª");
1841 #else
1842                         msg_print("Your eyes begin to tingle!");
1843 #endif
1844
1845                         notice = TRUE;
1846                 }
1847         }
1848
1849         /* Shut */
1850         else
1851         {
1852                 if (p_ptr->tim_infra)
1853                 {
1854 #ifdef JP
1855 msg_print("Ìܤ層­¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1856 #else
1857                         msg_print("Your eyes stop tingling.");
1858 #endif
1859
1860                         notice = TRUE;
1861                 }
1862         }
1863
1864         /* Use the value */
1865         p_ptr->tim_infra = v;
1866
1867         /* Redraw status bar */
1868         p_ptr->redraw |= (PR_STATUS);
1869
1870         /* Nothing to notice */
1871         if (!notice) return (FALSE);
1872
1873         /* Disturb */
1874         if (disturb_state) disturb(0, 0);
1875
1876         /* Recalculate bonuses */
1877         p_ptr->update |= (PU_BONUS);
1878
1879         /* Update the monsters */
1880         p_ptr->update |= (PU_MONSTERS);
1881
1882         /* Handle stuff */
1883         handle_stuff();
1884
1885         /* Result */
1886         return (TRUE);
1887 }
1888
1889
1890 /*
1891  * Set "p_ptr->tim_regen", notice observable changes
1892  */
1893 bool set_tim_regen(int v, bool do_dec)
1894 {
1895         bool notice = FALSE;
1896
1897         /* Hack -- Force good values */
1898         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1899
1900         if (p_ptr->is_dead) return FALSE;
1901
1902         /* Open */
1903         if (v)
1904         {
1905                 if (p_ptr->tim_regen && !do_dec)
1906                 {
1907                         if (p_ptr->tim_regen > v) return FALSE;
1908                 }
1909                 else if (!p_ptr->tim_regen)
1910                 {
1911 #ifdef JP
1912 msg_print("²óÉüÎϤ¬¾å¤¬¤Ã¤¿¡ª");
1913 #else
1914                         msg_print("You feel yourself regenerating quickly!");
1915 #endif
1916
1917                         notice = TRUE;
1918                 }
1919         }
1920
1921         /* Shut */
1922         else
1923         {
1924                 if (p_ptr->tim_regen)
1925                 {
1926 #ifdef JP
1927 msg_print("ÁÇÁ᤯²óÉü¤¹¤ë´¶¤¸¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1928 #else
1929                         msg_print("You feel yourself regenerating slowly.");
1930 #endif
1931
1932                         notice = TRUE;
1933                 }
1934         }
1935
1936         /* Use the value */
1937         p_ptr->tim_regen = v;
1938
1939         /* Redraw status bar */
1940         p_ptr->redraw |= (PR_STATUS);
1941
1942         /* Nothing to notice */
1943         if (!notice) return (FALSE);
1944
1945         /* Disturb */
1946         if (disturb_state) disturb(0, 0);
1947
1948         /* Recalculate bonuses */
1949         p_ptr->update |= (PU_BONUS);
1950
1951         /* Handle stuff */
1952         handle_stuff();
1953
1954         /* Result */
1955         return (TRUE);
1956 }
1957
1958
1959 /*
1960  * Set "p_ptr->tim_stealth", notice observable changes
1961  */
1962 bool set_tim_stealth(int v, bool do_dec)
1963 {
1964         bool notice = FALSE;
1965
1966         /* Hack -- Force good values */
1967         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1968
1969         if (p_ptr->is_dead) return FALSE;
1970
1971         /* Open */
1972         if (v)
1973         {
1974                 if (p_ptr->tim_stealth && !do_dec)
1975                 {
1976                         if (p_ptr->tim_stealth > v) return FALSE;
1977                 }
1978                 else if (!IS_TIM_STEALTH())
1979                 {
1980 #ifdef JP
1981 msg_print("­²»¤¬¾®¤µ¤¯¤Ê¤Ã¤¿¡ª");
1982 #else
1983                         msg_print("You begin to walk silently!");
1984 #endif
1985
1986                         notice = TRUE;
1987                 }
1988         }
1989
1990         /* Shut */
1991         else
1992         {
1993                 if (p_ptr->tim_stealth && !music_singing(MUSIC_STEALTH))
1994                 {
1995 #ifdef JP
1996 msg_print("­²»¤¬Â礭¤¯¤Ê¤Ã¤¿¡£");
1997 #else
1998                         msg_print("You no longer walk silently.");
1999 #endif
2000
2001                         notice = TRUE;
2002                 }
2003         }
2004
2005         /* Use the value */
2006         p_ptr->tim_stealth = v;
2007
2008         /* Redraw status bar */
2009         p_ptr->redraw |= (PR_STATUS);
2010
2011         /* Nothing to notice */
2012         if (!notice) return (FALSE);
2013
2014         /* Disturb */
2015         if (disturb_state) disturb(0, 0);
2016
2017         /* Recalculate bonuses */
2018         p_ptr->update |= (PU_BONUS);
2019
2020         /* Handle stuff */
2021         handle_stuff();
2022
2023         /* Result */
2024         return (TRUE);
2025 }
2026
2027
2028 bool set_superstealth(bool set)
2029 {
2030         bool notice = FALSE;
2031
2032         if (p_ptr->is_dead) return FALSE;
2033
2034         /* Open */
2035         if (set)
2036         {
2037                 if (!(p_ptr->special_defense & NINJA_S_STEALTH))
2038                 {
2039                         if (cave[py][px].info & CAVE_MNLT)
2040                         {
2041 #ifdef JP
2042                                 msg_print("Ũ¤ÎÌܤ«¤éÇö¤¤±Æ¤ÎÃæ¤Ëʤ¤¤±£¤µ¤ì¤¿¡£");
2043 #else
2044                                 msg_print("You are mantled in weak shadow from ordinary eyes.");
2045 #endif
2046                                 p_ptr->monlite = p_ptr->old_monlite = TRUE;
2047                         }
2048                         else
2049                         {
2050 #ifdef JP
2051                                 msg_print("Ũ¤ÎÌܤ«¤é±Æ¤ÎÃæ¤Ëʤ¤¤±£¤µ¤ì¤¿¡ª");
2052 #else
2053                                 msg_print("You are mantled in shadow from ordinary eyes!");
2054 #endif
2055                                 p_ptr->monlite = p_ptr->old_monlite = FALSE;
2056                         }
2057
2058                         notice = TRUE;
2059
2060                         /* Use the value */
2061                         p_ptr->special_defense |= NINJA_S_STEALTH;
2062                 }
2063         }
2064
2065         /* Shut */
2066         else
2067         {
2068                 if (p_ptr->special_defense & NINJA_S_STEALTH)
2069                 {
2070 #ifdef JP
2071                         msg_print("ºÆ¤ÓŨ¤ÎÌܤˤµ¤é¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
2072 #else
2073                         msg_print("You are exposed to common sight once more.");
2074 #endif
2075
2076                         notice = TRUE;
2077
2078                         /* Use the value */
2079                         p_ptr->special_defense &= ~(NINJA_S_STEALTH);
2080                 }
2081         }
2082
2083         /* Nothing to notice */
2084         if (!notice) return (FALSE);
2085
2086         /* Redraw status bar */
2087         p_ptr->redraw |= (PR_STATUS);
2088
2089         /* Disturb */
2090         if (disturb_state) disturb(0, 0);
2091
2092         /* Result */
2093         return (TRUE);
2094 }
2095
2096
2097 /*
2098  * Set "p_ptr->tim_ffall", notice observable changes
2099  */
2100 bool set_tim_ffall(int v, bool do_dec)
2101 {
2102         bool notice = FALSE;
2103
2104         /* Hack -- Force good values */
2105         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2106
2107         if (p_ptr->is_dead) return FALSE;
2108
2109         /* Open */
2110         if (v)
2111         {
2112                 if (p_ptr->tim_ffall && !do_dec)
2113                 {
2114                         if (p_ptr->tim_ffall > v) return FALSE;
2115                 }
2116                 else if (!p_ptr->tim_ffall)
2117                 {
2118 #ifdef JP
2119 msg_print("ÂΤ¬Ãè¤ËÉ⤭»Ï¤á¤¿¡£");
2120 #else
2121                         msg_print("You begin to fly!");
2122 #endif
2123
2124                         notice = TRUE;
2125                 }
2126         }
2127
2128         /* Shut */
2129         else
2130         {
2131                 if (p_ptr->tim_ffall)
2132                 {
2133 #ifdef JP
2134 msg_print("¤â¤¦Ãè¤ËÉ⤫¤Ù¤Ê¤¯¤Ê¤Ã¤¿¡£");
2135 #else
2136                         msg_print("You stop flying.");
2137 #endif
2138
2139                         notice = TRUE;
2140                 }
2141         }
2142
2143         /* Use the value */
2144         p_ptr->tim_ffall = v;
2145
2146         /* Redraw status bar */
2147         p_ptr->redraw |= (PR_STATUS);
2148
2149         /* Nothing to notice */
2150         if (!notice) return (FALSE);
2151
2152         /* Disturb */
2153         if (disturb_state) disturb(0, 0);
2154
2155         /* Recalculate bonuses */
2156         p_ptr->update |= (PU_BONUS);
2157
2158         /* Handle stuff */
2159         handle_stuff();
2160
2161         /* Result */
2162         return (TRUE);
2163 }
2164
2165
2166 /*
2167  * Set "p_ptr->tim_sh_touki", notice observable changes
2168  */
2169 bool set_tim_sh_touki(int v, bool do_dec)
2170 {
2171         bool notice = FALSE;
2172
2173         /* Hack -- Force good values */
2174         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2175
2176         if (p_ptr->is_dead) return FALSE;
2177
2178         /* Open */
2179         if (v)
2180         {
2181                 if (p_ptr->tim_sh_touki && !do_dec)
2182                 {
2183                         if (p_ptr->tim_sh_touki > v) return FALSE;
2184                 }
2185                 else if (!p_ptr->tim_sh_touki)
2186                 {
2187 #ifdef JP
2188 msg_print("ÂΤ¬Æ®µ¤¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2189 #else
2190                         msg_print("You have enveloped by the aura of the Force!");
2191 #endif
2192
2193                         notice = TRUE;
2194                 }
2195         }
2196
2197         /* Shut */
2198         else
2199         {
2200                 if (p_ptr->tim_sh_touki)
2201                 {
2202 #ifdef JP
2203 msg_print("Æ®µ¤¤¬¾Ã¤¨¤¿¡£");
2204 #else
2205                         msg_print("Aura of the Force disappeared.");
2206 #endif
2207
2208                         notice = TRUE;
2209                 }
2210         }
2211
2212         /* Use the value */
2213         p_ptr->tim_sh_touki = v;
2214
2215         /* Redraw status bar */
2216         p_ptr->redraw |= (PR_STATUS);
2217
2218         /* Nothing to notice */
2219         if (!notice) return (FALSE);
2220
2221         /* Disturb */
2222         if (disturb_state) disturb(0, 0);
2223
2224         /* Handle stuff */
2225         handle_stuff();
2226
2227         /* Result */
2228         return (TRUE);
2229 }
2230
2231
2232 /*
2233  * Set "p_ptr->tim_sh_fire", notice observable changes
2234  */
2235 bool set_tim_sh_fire(int v, bool do_dec)
2236 {
2237         bool notice = FALSE;
2238
2239         /* Hack -- Force good values */
2240         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2241
2242         if (p_ptr->is_dead) return FALSE;
2243
2244         /* Open */
2245         if (v)
2246         {
2247                 if (p_ptr->tim_sh_fire && !do_dec)
2248                 {
2249                         if (p_ptr->tim_sh_fire > v) return FALSE;
2250                 }
2251                 else if (!p_ptr->tim_sh_fire)
2252                 {
2253 #ifdef JP
2254 msg_print("ÂΤ¬±ê¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2255 #else
2256                         msg_print("You have enveloped by fiery aura!");
2257 #endif
2258
2259                         notice = TRUE;
2260                 }
2261         }
2262
2263         /* Shut */
2264         else
2265         {
2266                 if (p_ptr->tim_sh_fire)
2267                 {
2268 #ifdef JP
2269 msg_print("±ê¤Î¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2270 #else
2271                         msg_print("Fiery aura disappeared.");
2272 #endif
2273
2274                         notice = TRUE;
2275                 }
2276         }
2277
2278         /* Use the value */
2279         p_ptr->tim_sh_fire = v;
2280
2281         /* Redraw status bar */
2282         p_ptr->redraw |= (PR_STATUS);
2283
2284         /* Nothing to notice */
2285         if (!notice) return (FALSE);
2286
2287         /* Disturb */
2288         if (disturb_state) disturb(0, 0);
2289
2290         /* Recalculate bonuses */
2291         p_ptr->update |= (PU_BONUS);
2292
2293         /* Handle stuff */
2294         handle_stuff();
2295
2296         /* Result */
2297         return (TRUE);
2298 }
2299
2300
2301 /*
2302  * Set "p_ptr->tim_sh_holy", notice observable changes
2303  */
2304 bool set_tim_sh_holy(int v, bool do_dec)
2305 {
2306         bool notice = FALSE;
2307
2308         /* Hack -- Force good values */
2309         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2310
2311         if (p_ptr->is_dead) return FALSE;
2312
2313         /* Open */
2314         if (v)
2315         {
2316                 if (p_ptr->tim_sh_holy && !do_dec)
2317                 {
2318                         if (p_ptr->tim_sh_holy > v) return FALSE;
2319                 }
2320                 else if (!p_ptr->tim_sh_holy)
2321                 {
2322 #ifdef JP
2323 msg_print("ÂΤ¬À»¤Ê¤ë¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2324 #else
2325                         msg_print("You have enveloped by holy aura!");
2326 #endif
2327
2328                         notice = TRUE;
2329                 }
2330         }
2331
2332         /* Shut */
2333         else
2334         {
2335                 if (p_ptr->tim_sh_holy)
2336                 {
2337 #ifdef JP
2338 msg_print("À»¤Ê¤ë¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2339 #else
2340                         msg_print("Holy aura disappeared.");
2341 #endif
2342
2343                         notice = TRUE;
2344                 }
2345         }
2346
2347         /* Use the value */
2348         p_ptr->tim_sh_holy = v;
2349
2350         /* Redraw status bar */
2351         p_ptr->redraw |= (PR_STATUS);
2352
2353         /* Nothing to notice */
2354         if (!notice) return (FALSE);
2355
2356         /* Disturb */
2357         if (disturb_state) disturb(0, 0);
2358
2359         /* Recalculate bonuses */
2360         p_ptr->update |= (PU_BONUS);
2361
2362         /* Handle stuff */
2363         handle_stuff();
2364
2365         /* Result */
2366         return (TRUE);
2367 }
2368
2369
2370
2371 /*
2372  * Set "p_ptr->tim_eyeeye", notice observable changes
2373  */
2374 bool set_tim_eyeeye(int v, bool do_dec)
2375 {
2376         bool notice = FALSE;
2377
2378         /* Hack -- Force good values */
2379         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2380
2381         if (p_ptr->is_dead) return FALSE;
2382
2383         /* Open */
2384         if (v)
2385         {
2386                 if (p_ptr->tim_eyeeye && !do_dec)
2387                 {
2388                         if (p_ptr->tim_eyeeye > v) return FALSE;
2389                 }
2390                 else if (!p_ptr->tim_eyeeye)
2391                 {
2392 #ifdef JP
2393 msg_print("Ë¡¤Î¼é¤ê¼ê¤Ë¤Ê¤Ã¤¿µ¤¤¬¤·¤¿¡ª");
2394 #else
2395                         msg_print("You feel like a keeper of commandments!");
2396 #endif
2397
2398                         notice = TRUE;
2399                 }
2400         }
2401
2402         /* Shut */
2403         else
2404         {
2405                 if (p_ptr->tim_eyeeye)
2406                 {
2407 #ifdef JP
2408 msg_print("Ĩȳ¤ò¼¹¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2409 #else
2410                         msg_print("You no longer feel like a keeper.");
2411 #endif
2412
2413                         notice = TRUE;
2414                 }
2415         }
2416
2417         /* Use the value */
2418         p_ptr->tim_eyeeye = v;
2419
2420         /* Redraw status bar */
2421         p_ptr->redraw |= (PR_STATUS);
2422
2423         /* Nothing to notice */
2424         if (!notice) return (FALSE);
2425
2426         /* Disturb */
2427         if (disturb_state) disturb(0, 0);
2428
2429         /* Recalculate bonuses */
2430         p_ptr->update |= (PU_BONUS);
2431
2432         /* Handle stuff */
2433         handle_stuff();
2434
2435         /* Result */
2436         return (TRUE);
2437 }
2438
2439
2440
2441 /*
2442  * Set "p_ptr->resist_magic", notice observable changes
2443  */
2444 bool set_resist_magic(int v, bool do_dec)
2445 {
2446         bool notice = FALSE;
2447
2448         /* Hack -- Force good values */
2449         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2450
2451         if (p_ptr->is_dead) return FALSE;
2452
2453         /* Open */
2454         if (v)
2455         {
2456                 if (p_ptr->resist_magic && !do_dec)
2457                 {
2458                         if (p_ptr->resist_magic > v) return FALSE;
2459                 }
2460                 else if (!p_ptr->resist_magic)
2461                 {
2462 #ifdef JP
2463 msg_print("ËâË¡¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿¡£");
2464 #else
2465                         msg_print("You have been protected from magic!");
2466 #endif
2467
2468                         notice = TRUE;
2469                 }
2470         }
2471
2472         /* Shut */
2473         else
2474         {
2475                 if (p_ptr->resist_magic)
2476                 {
2477 #ifdef JP
2478 msg_print("ËâË¡¤Ë¼å¤¯¤Ê¤Ã¤¿¡£");
2479 #else
2480 msg_print("You are no longer protected from magic.");
2481 #endif
2482
2483                         notice = TRUE;
2484                 }
2485         }
2486
2487         /* Use the value */
2488         p_ptr->resist_magic = v;
2489
2490         /* Redraw status bar */
2491         p_ptr->redraw |= (PR_STATUS);
2492
2493         /* Nothing to notice */
2494         if (!notice) return (FALSE);
2495
2496         /* Disturb */
2497         if (disturb_state) disturb(0, 0);
2498
2499         /* Recalculate bonuses */
2500         p_ptr->update |= (PU_BONUS);
2501
2502         /* Handle stuff */
2503         handle_stuff();
2504
2505         /* Result */
2506         return (TRUE);
2507 }
2508
2509
2510 /*
2511  * Set "p_ptr->tim_reflect", notice observable changes
2512  */
2513 bool set_tim_reflect(int v, bool do_dec)
2514 {
2515         bool notice = FALSE;
2516
2517         /* Hack -- Force good values */
2518         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2519
2520         if (p_ptr->is_dead) return FALSE;
2521
2522         /* Open */
2523         if (v)
2524         {
2525                 if (p_ptr->tim_reflect && !do_dec)
2526                 {
2527                         if (p_ptr->tim_reflect > v) return FALSE;
2528                 }
2529                 else if (!p_ptr->tim_reflect)
2530                 {
2531 #ifdef JP
2532 msg_print("ÂΤÎɽÌ̤¬³ê¤«¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
2533 #else
2534                         msg_print("Your body becames smooth.");
2535 #endif
2536
2537                         notice = TRUE;
2538                 }
2539         }
2540
2541         /* Shut */
2542         else
2543         {
2544                 if (p_ptr->tim_reflect)
2545                 {
2546 #ifdef JP
2547 msg_print("ÂΤÎɽÌ̤¬³ê¤«¤Ç¤Ê¤¯¤Ê¤Ã¤¿¡£");
2548 #else
2549                         msg_print("Your body is no longer smooth.");
2550 #endif
2551
2552                         notice = TRUE;
2553                 }
2554         }
2555
2556         /* Use the value */
2557         p_ptr->tim_reflect = v;
2558
2559         /* Redraw status bar */
2560         p_ptr->redraw |= (PR_STATUS);
2561
2562         /* Nothing to notice */
2563         if (!notice) return (FALSE);
2564
2565         /* Disturb */
2566         if (disturb_state) disturb(0, 0);
2567
2568         /* Recalculate bonuses */
2569         p_ptr->update |= (PU_BONUS);
2570
2571         /* Handle stuff */
2572         handle_stuff();
2573
2574         /* Result */
2575         return (TRUE);
2576 }
2577
2578
2579 /*
2580  * Set "p_ptr->multishadow", notice observable changes
2581  */
2582 bool set_multishadow(int v, bool do_dec)
2583 {
2584         bool notice = FALSE;
2585
2586         /* Hack -- Force good values */
2587         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2588
2589         if (p_ptr->is_dead) return FALSE;
2590
2591         /* Open */
2592         if (v)
2593         {
2594                 if (p_ptr->multishadow && !do_dec)
2595                 {
2596                         if (p_ptr->multishadow > v) return FALSE;
2597                 }
2598                 else if (!p_ptr->multishadow)
2599                 {
2600 #ifdef JP
2601 msg_print("¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¸¸±Æ¤¬À¸¤Þ¤ì¤¿¡£");
2602 #else
2603                         msg_print("Your Shadow enveloped you.");
2604 #endif
2605
2606                         notice = TRUE;
2607                 }
2608         }
2609
2610         /* Shut */
2611         else
2612         {
2613                 if (p_ptr->multishadow)
2614                 {
2615 #ifdef JP
2616 msg_print("¸¸±Æ¤¬¾Ã¤¨¤¿¡£");
2617 #else
2618                         msg_print("Your Shadow disappears.");
2619 #endif
2620
2621                         notice = TRUE;
2622                 }
2623         }
2624
2625         /* Use the value */
2626         p_ptr->multishadow = v;
2627
2628         /* Redraw status bar */
2629         p_ptr->redraw |= (PR_STATUS);
2630
2631         /* Nothing to notice */
2632         if (!notice) return (FALSE);
2633
2634         /* Disturb */
2635         if (disturb_state) disturb(0, 0);
2636
2637         /* Recalculate bonuses */
2638         p_ptr->update |= (PU_BONUS);
2639
2640         /* Handle stuff */
2641         handle_stuff();
2642
2643         /* Result */
2644         return (TRUE);
2645 }
2646
2647
2648 /*
2649  * Set "p_ptr->dustrobe", notice observable changes
2650  */
2651 bool set_dustrobe(int v, bool do_dec)
2652 {
2653         bool notice = FALSE;
2654
2655         /* Hack -- Force good values */
2656         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2657
2658         if (p_ptr->is_dead) return FALSE;
2659
2660         /* Open */
2661         if (v)
2662         {
2663                 if (p_ptr->dustrobe && !do_dec)
2664                 {
2665                         if (p_ptr->dustrobe > v) return FALSE;
2666                 }
2667                 else if (!p_ptr->dustrobe)
2668                 {
2669 #ifdef JP
2670 msg_print("ÂΤ¬¶À¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2671 #else
2672                         msg_print("You were enveloped by mirror shards.");
2673 #endif
2674
2675                         notice = TRUE;
2676                 }
2677         }
2678
2679         /* Shut */
2680         else
2681         {
2682                 if (p_ptr->dustrobe)
2683                 {
2684 #ifdef JP
2685 msg_print("¶À¤Î¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2686 #else
2687                         msg_print("The mirror shards disappear.");
2688 #endif
2689
2690                         notice = TRUE;
2691                 }
2692         }
2693
2694         /* Use the value */
2695         p_ptr->dustrobe = v;
2696
2697         /* Redraw status bar */
2698         p_ptr->redraw |= (PR_STATUS);
2699
2700         /* Nothing to notice */
2701         if (!notice) return (FALSE);
2702
2703         /* Disturb */
2704         if (disturb_state) disturb(0, 0);
2705
2706         /* Recalculate bonuses */
2707         p_ptr->update |= (PU_BONUS);
2708
2709         /* Handle stuff */
2710         handle_stuff();
2711
2712         /* Result */
2713         return (TRUE);
2714 }
2715
2716
2717 /*
2718  * Set "p_ptr->tim_regen", notice observable changes
2719  */
2720 bool set_kabenuke(int v, bool do_dec)
2721 {
2722         bool notice = FALSE;
2723
2724         /* Hack -- Force good values */
2725         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2726
2727         if (p_ptr->is_dead) return FALSE;
2728
2729         /* Open */
2730         if (v)
2731         {
2732                 if (p_ptr->kabenuke && !do_dec)
2733                 {
2734                         if (p_ptr->kabenuke > v) return FALSE;
2735                 }
2736                 else if (!p_ptr->kabenuke)
2737                 {
2738 #ifdef JP
2739 msg_print("ÂΤ¬È¾Êª¼Á¤Î¾õÂ֤ˤʤä¿¡£");
2740 #else
2741                         msg_print("You became ethereal form.");
2742 #endif
2743
2744                         notice = TRUE;
2745                 }
2746         }
2747
2748         /* Shut */
2749         else
2750         {
2751                 if (p_ptr->kabenuke)
2752                 {
2753 #ifdef JP
2754 msg_print("ÂΤ¬Êª¼Á²½¤·¤¿¡£");
2755 #else
2756                         msg_print("You are no longer in an ethereal form.");
2757 #endif
2758
2759                         notice = TRUE;
2760                 }
2761         }
2762
2763         /* Use the value */
2764         p_ptr->kabenuke = v;
2765
2766         /* Redraw status bar */
2767         p_ptr->redraw |= (PR_STATUS);
2768
2769         /* Nothing to notice */
2770         if (!notice) return (FALSE);
2771
2772         /* Disturb */
2773         if (disturb_state) disturb(0, 0);
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                         p_ptr->wilderness_x = px;
4071                         p_ptr->wilderness_y = py;
4072                         p_ptr->energy_need = 0;
4073                         change_wild_mode();
4074                 }
4075
4076                 /* Change */
4077                 notice = TRUE;
4078         }
4079
4080         /* Use the value */
4081         p_ptr->food = v;
4082
4083         /* Nothing to notice */
4084         if (!notice) return (FALSE);
4085
4086         /* Disturb */
4087         if (disturb_state) disturb(0, 0);
4088
4089         /* Recalculate bonuses */
4090         p_ptr->update |= (PU_BONUS);
4091
4092         /* Redraw hunger */
4093         p_ptr->redraw |= (PR_HUNGER);
4094
4095         /* Handle stuff */
4096         handle_stuff();
4097
4098         /* Result */
4099         return (TRUE);
4100 }
4101
4102 /*
4103  * Increases a stat by one randomized level             -RAK-
4104  *
4105  * Note that this function (used by stat potions) now restores
4106  * the stat BEFORE increasing it.
4107  */
4108 bool inc_stat(int stat)
4109 {
4110         int value, gain;
4111
4112         /* Then augment the current/max stat */
4113         value = p_ptr->stat_cur[stat];
4114
4115         /* Cannot go above 18/100 */
4116         if (value < p_ptr->stat_max_max[stat])
4117         {
4118                 /* Gain one (sometimes two) points */
4119                 if (value < 18)
4120                 {
4121                         gain = ((randint0(100) < 75) ? 1 : 2);
4122                         value += gain;
4123                 }
4124
4125                 /* Gain 1/6 to 1/3 of distance to 18/100 */
4126                 else if (value < (p_ptr->stat_max_max[stat]-2))
4127                 {
4128                         /* Approximate gain value */
4129                         gain = (((p_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
4130
4131                         /* Paranoia */
4132                         if (gain < 1) gain = 1;
4133
4134                         /* Apply the bonus */
4135                         value += randint1(gain) + gain / 2;
4136
4137                         /* Maximal value */
4138                         if (value > (p_ptr->stat_max_max[stat]-1)) value = p_ptr->stat_max_max[stat]-1;
4139                 }
4140
4141                 /* Gain one point at a time */
4142                 else
4143                 {
4144                         value++;
4145                 }
4146
4147                 /* Save the new value */
4148                 p_ptr->stat_cur[stat] = value;
4149
4150                 /* Bring up the maximum too */
4151                 if (value > p_ptr->stat_max[stat])
4152                 {
4153                         p_ptr->stat_max[stat] = value;
4154                 }
4155
4156                 /* Recalculate bonuses */
4157                 p_ptr->update |= (PU_BONUS);
4158
4159                 /* Success */
4160                 return (TRUE);
4161         }
4162
4163         /* Nothing to gain */
4164         return (FALSE);
4165 }
4166
4167
4168
4169 /*
4170  * Decreases a stat by an amount indended to vary from 0 to 100 percent.
4171  *
4172  * Amount could be a little higher in extreme cases to mangle very high
4173  * stats from massive assaults.  -CWS
4174  *
4175  * Note that "permanent" means that the *given* amount is permanent,
4176  * not that the new value becomes permanent.  This may not work exactly
4177  * as expected, due to "weirdness" in the algorithm, but in general,
4178  * if your stat is already drained, the "max" value will not drop all
4179  * the way down to the "cur" value.
4180  */
4181 bool dec_stat(int stat, int amount, int permanent)
4182 {
4183         int cur, max, loss, same, res = FALSE;
4184
4185
4186         /* Acquire current value */
4187         cur = p_ptr->stat_cur[stat];
4188         max = p_ptr->stat_max[stat];
4189
4190         /* Note when the values are identical */
4191         same = (cur == max);
4192
4193         /* Damage "current" value */
4194         if (cur > 3)
4195         {
4196                 /* Handle "low" values */
4197                 if (cur <= 18)
4198                 {
4199                         if (amount > 90) cur--;
4200                         if (amount > 50) cur--;
4201                         if (amount > 20) cur--;
4202                         cur--;
4203                 }
4204
4205                 /* Handle "high" values */
4206                 else
4207                 {
4208                         /* Hack -- Decrement by a random amount between one-quarter */
4209                         /* and one-half of the stat bonus times the percentage, with a */
4210                         /* minimum damage of half the percentage. -CWS */
4211                         loss = (((cur-18) / 2 + 1) / 2 + 1);
4212
4213                         /* Paranoia */
4214                         if (loss < 1) loss = 1;
4215
4216                         /* Randomize the loss */
4217                         loss = ((randint1(loss) + loss) * amount) / 100;
4218
4219                         /* Maximal loss */
4220                         if (loss < amount/2) loss = amount/2;
4221
4222                         /* Lose some points */
4223                         cur = cur - loss;
4224
4225                         /* Hack -- Only reduce stat to 17 sometimes */
4226                         if (cur < 18) cur = (amount <= 20) ? 18 : 17;
4227                 }
4228
4229                 /* Prevent illegal values */
4230                 if (cur < 3) cur = 3;
4231
4232                 /* Something happened */
4233                 if (cur != p_ptr->stat_cur[stat]) res = TRUE;
4234         }
4235
4236         /* Damage "max" value */
4237         if (permanent && (max > 3))
4238         {
4239                 chg_virtue(V_SACRIFICE, 1);
4240                 if (stat == A_WIS || stat == A_INT)
4241                         chg_virtue(V_ENLIGHTEN, -2);
4242
4243                 /* Handle "low" values */
4244                 if (max <= 18)
4245                 {
4246                         if (amount > 90) max--;
4247                         if (amount > 50) max--;
4248                         if (amount > 20) max--;
4249                         max--;
4250                 }
4251
4252                 /* Handle "high" values */
4253                 else
4254                 {
4255                         /* Hack -- Decrement by a random amount between one-quarter */
4256                         /* and one-half of the stat bonus times the percentage, with a */
4257                         /* minimum damage of half the percentage. -CWS */
4258                         loss = (((max-18) / 2 + 1) / 2 + 1);
4259                         loss = ((randint1(loss) + loss) * amount) / 100;
4260                         if (loss < amount/2) loss = amount/2;
4261
4262                         /* Lose some points */
4263                         max = max - loss;
4264
4265                         /* Hack -- Only reduce stat to 17 sometimes */
4266                         if (max < 18) max = (amount <= 20) ? 18 : 17;
4267                 }
4268
4269                 /* Hack -- keep it clean */
4270                 if (same || (max < cur)) max = cur;
4271
4272                 /* Something happened */
4273                 if (max != p_ptr->stat_max[stat]) res = TRUE;
4274         }
4275
4276         /* Apply changes */
4277         if (res)
4278         {
4279                 /* Actually set the stat to its new value. */
4280                 p_ptr->stat_cur[stat] = cur;
4281                 p_ptr->stat_max[stat] = max;
4282
4283                 /* Redisplay the stats later */
4284                 p_ptr->redraw |= (PR_STATS);
4285
4286                 /* Recalculate bonuses */
4287                 p_ptr->update |= (PU_BONUS);
4288         }
4289
4290         /* Done */
4291         return (res);
4292 }
4293
4294
4295 /*
4296  * Restore a stat.  Return TRUE only if this actually makes a difference.
4297  */
4298 bool res_stat(int stat)
4299 {
4300         /* Restore if needed */
4301         if (p_ptr->stat_cur[stat] != p_ptr->stat_max[stat])
4302         {
4303                 /* Restore */
4304                 p_ptr->stat_cur[stat] = p_ptr->stat_max[stat];
4305
4306                 /* Recalculate bonuses */
4307                 p_ptr->update |= (PU_BONUS);
4308
4309                 /* Redisplay the stats later */
4310                 p_ptr->redraw |= (PR_STATS);
4311
4312                 /* Success */
4313                 return (TRUE);
4314         }
4315
4316         /* Nothing to restore */
4317         return (FALSE);
4318 }
4319
4320
4321 /*
4322  * Increase players hit points, notice effects
4323  */
4324 bool hp_player(int num)
4325 {
4326         int vir;
4327         vir = virtue_number(V_VITALITY);
4328         if (vir)
4329         {
4330                 num = num * (p_ptr->virtues[vir - 1] + 1250) / 1250;
4331         }
4332         /* Healing needed */
4333         if (p_ptr->chp < p_ptr->mhp)
4334         {
4335                 if ((num > 0) && (p_ptr->chp < (p_ptr->mhp/3)))
4336                         chg_virtue(V_TEMPERANCE, 1);
4337                 /* Gain hitpoints */
4338                 p_ptr->chp += num;
4339
4340                 /* Enforce maximum */
4341                 if (p_ptr->chp >= p_ptr->mhp)
4342                 {
4343                         p_ptr->chp = p_ptr->mhp;
4344                         p_ptr->chp_frac = 0;
4345                 }
4346
4347                 /* Redraw */
4348                 p_ptr->redraw |= (PR_HP);
4349
4350                 /* Window stuff */
4351                 p_ptr->window |= (PW_PLAYER);
4352
4353                 /* Heal 0-4 */
4354                 if (num < 5)
4355                 {
4356 #ifdef JP
4357 msg_print("¾¯¤·µ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4358 #else
4359                         msg_print("You feel a little better.");
4360 #endif
4361
4362                 }
4363
4364                 /* Heal 5-14 */
4365                 else if (num < 15)
4366                 {
4367 #ifdef JP
4368 msg_print("µ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4369 #else
4370                         msg_print("You feel better.");
4371 #endif
4372
4373                 }
4374
4375                 /* Heal 15-34 */
4376                 else if (num < 35)
4377                 {
4378 #ifdef JP
4379 msg_print("¤È¤Æ¤âµ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4380 #else
4381                         msg_print("You feel much better.");
4382 #endif
4383
4384                 }
4385
4386                 /* Heal 35+ */
4387                 else
4388                 {
4389 #ifdef JP
4390 msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4391 #else
4392                         msg_print("You feel very good.");
4393 #endif
4394
4395                 }
4396
4397                 /* Notice */
4398                 return (TRUE);
4399         }
4400
4401         /* Ignore */
4402         return (FALSE);
4403 }
4404
4405
4406 /*
4407  * Array of stat "descriptions"
4408  */
4409 static cptr desc_stat_pos[] =
4410 {
4411 #ifdef JP
4412 "¶¯¤¯",
4413 #else
4414         "strong",
4415 #endif
4416
4417 #ifdef JP
4418 "ÃÎŪ¤Ë",
4419 #else
4420         "smart",
4421 #endif
4422
4423 #ifdef JP
4424 "¸­¤¯",
4425 #else
4426         "wise",
4427 #endif
4428
4429 #ifdef JP
4430 "´ïÍѤË",
4431 #else
4432         "dextrous",
4433 #endif
4434
4435 #ifdef JP
4436 "·ò¹¯¤Ë",
4437 #else
4438         "healthy",
4439 #endif
4440
4441 #ifdef JP
4442 "Èþ¤·¤¯"
4443 #else
4444         "cute"
4445 #endif
4446
4447 };
4448
4449
4450 /*
4451  * Array of stat "descriptions"
4452  */
4453 static cptr desc_stat_neg[] =
4454 {
4455 #ifdef JP
4456 "¼å¤¯",
4457 "̵ÃΤË",
4458 "¶ò¤«¤Ë",
4459 "ÉÔ´ïÍѤË",
4460 "ÉÔ·ò¹¯¤Ë",
4461 "½¹¤¯"
4462 #else
4463         "weak",
4464         "stupid",
4465         "naive",
4466         "clumsy",
4467         "sickly",
4468         "ugly"
4469 #endif
4470
4471 };
4472
4473
4474 /*
4475  * Lose a "point"
4476  */
4477 bool do_dec_stat(int stat)
4478 {
4479         bool sust = FALSE;
4480
4481         /* Access the "sustain" */
4482         switch (stat)
4483         {
4484                 case A_STR: if (p_ptr->sustain_str) sust = TRUE; break;
4485                 case A_INT: if (p_ptr->sustain_int) sust = TRUE; break;
4486                 case A_WIS: if (p_ptr->sustain_wis) sust = TRUE; break;
4487                 case A_DEX: if (p_ptr->sustain_dex) sust = TRUE; break;
4488                 case A_CON: if (p_ptr->sustain_con) sust = TRUE; break;
4489                 case A_CHR: if (p_ptr->sustain_chr) sust = TRUE; break;
4490         }
4491
4492         /* Sustain */
4493         if (sust && (!ironman_nightmare || randint0(13)))
4494         {
4495                 /* Message */
4496 #ifdef JP
4497 msg_format("%s¤Ê¤Ã¤¿µ¤¤¬¤·¤¿¤¬¡¢¤¹¤°¤Ë¸µ¤ËÌá¤Ã¤¿¡£",
4498 #else
4499                 msg_format("You feel %s for a moment, but the feeling passes.",
4500 #endif
4501
4502                                 desc_stat_neg[stat]);
4503
4504                 /* Notice effect */
4505                 return (TRUE);
4506         }
4507
4508         /* Attempt to reduce the stat */
4509         if (dec_stat(stat, 10, (ironman_nightmare && !randint0(13))))
4510         {
4511                 /* Message */
4512 #ifdef JP
4513 msg_format("¤Ò¤É¤¯%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_neg[stat]);
4514 #else
4515                 msg_format("You feel very %s.", desc_stat_neg[stat]);
4516 #endif
4517
4518
4519                 /* Notice effect */
4520                 return (TRUE);
4521         }
4522
4523         /* Nothing obvious */
4524         return (FALSE);
4525 }
4526
4527
4528 /*
4529  * Restore lost "points" in a stat
4530  */
4531 bool do_res_stat(int stat)
4532 {
4533         /* Attempt to increase */
4534         if (res_stat(stat))
4535         {
4536                 /* Message */
4537 #ifdef JP
4538 msg_format("¸µÄ̤ê¤Ë%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_pos[stat]);
4539 #else
4540                 msg_format("You feel less %s.", desc_stat_neg[stat]);
4541 #endif
4542
4543
4544                 /* Notice */
4545                 return (TRUE);
4546         }
4547
4548         /* Nothing obvious */
4549         return (FALSE);
4550 }
4551
4552
4553 /*
4554  * Gain a "point" in a stat
4555  */
4556 bool do_inc_stat(int stat)
4557 {
4558         bool res;
4559
4560         /* Restore strength */
4561         res = res_stat(stat);
4562
4563         /* Attempt to increase */
4564         if (inc_stat(stat))
4565         {
4566                 if (stat == A_WIS)
4567                 {
4568                         chg_virtue(V_ENLIGHTEN, 1);
4569                         chg_virtue(V_FAITH, 1);
4570                 }
4571                 else if (stat == A_INT)
4572                 {
4573                         chg_virtue(V_KNOWLEDGE, 1);
4574                         chg_virtue(V_ENLIGHTEN, 1);
4575                 }
4576                 else if (stat == A_CON)
4577                         chg_virtue(V_VITALITY, 1);
4578
4579                 /* Message */
4580 #ifdef JP
4581 msg_format("¥ï¡¼¥ª¡ª¤È¤Æ¤â%s¤Ê¤Ã¤¿¡ª", desc_stat_pos[stat]);
4582 #else
4583                 msg_format("Wow!  You feel very %s!", desc_stat_pos[stat]);
4584 #endif
4585
4586
4587                 /* Notice */
4588                 return (TRUE);
4589         }
4590
4591         /* Restoration worked */
4592         if (res)
4593         {
4594                 /* Message */
4595 #ifdef JP
4596 msg_format("¸µÄ̤ê¤Ë%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_pos[stat]);
4597 #else
4598                 msg_format("You feel less %s.", desc_stat_neg[stat]);
4599 #endif
4600
4601
4602                 /* Notice */
4603                 return (TRUE);
4604         }
4605
4606         /* Nothing obvious */
4607         return (FALSE);
4608 }
4609
4610
4611 /*
4612  * Restores any drained experience
4613  */
4614 bool restore_level(void)
4615 {
4616         /* Restore experience */
4617         if (p_ptr->exp < p_ptr->max_exp)
4618         {
4619                 /* Message */
4620 #ifdef JP
4621 msg_print("À¸Ì¿ÎϤ¬Ìá¤Ã¤Æ¤­¤¿µ¤¤¬¤¹¤ë¡£");
4622 #else
4623                 msg_print("You feel your life energies returning.");
4624 #endif
4625
4626
4627                 /* Restore the experience */
4628                 p_ptr->exp = p_ptr->max_exp;
4629
4630                 /* Check the experience */
4631                 check_experience();
4632
4633                 /* Did something */
4634                 return (TRUE);
4635         }
4636
4637         /* No effect */
4638         return (FALSE);
4639 }
4640
4641
4642 /*
4643  * Forget everything
4644  */
4645 bool lose_all_info(void)
4646 {
4647         int i;
4648
4649         chg_virtue(V_KNOWLEDGE, -5);
4650         chg_virtue(V_ENLIGHTEN, -5);
4651
4652         /* Forget info about objects */
4653         for (i = 0; i < INVEN_TOTAL; i++)
4654         {
4655                 object_type *o_ptr = &inventory[i];
4656
4657                 /* Skip non-objects */
4658                 if (!o_ptr->k_idx) continue;
4659
4660                 /* Allow "protection" by the MENTAL flag */
4661                 if (o_ptr->ident & (IDENT_MENTAL)) continue;
4662
4663                 /* Remove "default inscriptions" */
4664                 o_ptr->feeling = FEEL_NONE;
4665
4666                 /* Hack -- Clear the "empty" flag */
4667                 o_ptr->ident &= ~(IDENT_EMPTY);
4668
4669                 /* Hack -- Clear the "known" flag */
4670                 o_ptr->ident &= ~(IDENT_KNOWN);
4671
4672                 /* Hack -- Clear the "felt" flag */
4673                 o_ptr->ident &= ~(IDENT_SENSE);
4674         }
4675
4676         /* Recalculate bonuses */
4677         p_ptr->update |= (PU_BONUS);
4678
4679         /* Combine / Reorder the pack (later) */
4680         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
4681
4682         /* Window stuff */
4683         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4684
4685         /* Mega-Hack -- Forget the map */
4686         wiz_dark();
4687
4688         /* It worked */
4689         return (TRUE);
4690 }
4691
4692
4693 void do_poly_wounds(void)
4694 {
4695         /* Changed to always provide at least _some_ healing */
4696         s16b wounds = p_ptr->cut;
4697         s16b hit_p = (p_ptr->mhp - p_ptr->chp);
4698         s16b change = damroll(p_ptr->lev, 5);
4699         bool Nasty_effect = one_in_(5);
4700
4701         if (!(wounds || hit_p || Nasty_effect)) return;
4702
4703 #ifdef JP
4704 msg_print("½ý¤¬¤è¤ê·Ú¤¤¤â¤Î¤ËÊѲ½¤·¤¿¡£");
4705 #else
4706         msg_print("Your wounds are polymorphed into less serious ones.");
4707 #endif
4708
4709         hp_player(change);
4710         if (Nasty_effect)
4711         {
4712 #ifdef JP
4713 msg_print("¿·¤¿¤Ê½ý¤¬¤Ç¤­¤¿¡ª");
4714 take_hit(DAMAGE_LOSELIFE, change / 2, "ÊѲ½¤·¤¿½ý", -1);
4715 #else
4716                 msg_print("A new wound was created!");
4717                 take_hit(DAMAGE_LOSELIFE, change / 2, "a polymorphed wound", -1);
4718 #endif
4719
4720                 set_cut(change);
4721         }
4722         else
4723         {
4724                 set_cut(p_ptr->cut - (change / 2));
4725         }
4726 }
4727
4728
4729 void do_poly_self(void)
4730 {
4731         int power = p_ptr->lev;
4732
4733 #ifdef JP
4734 msg_print("¤¢¤Ê¤¿¤ÏÊѲ½¤Îˬ¤ì¤ò´¶¤¸¤¿...");
4735 #else
4736         msg_print("You feel a change coming over you...");
4737 #endif
4738
4739         chg_virtue(V_CHANCE, 1);
4740
4741         if ((power > randint0(20)) && one_in_(3) && (p_ptr->prace != RACE_ANDROID))
4742         {
4743                 char effect_msg[80] = "";
4744                 int new_race, expfact, goalexpfact, h_percent;
4745
4746                 /* Some form of racial polymorph... */
4747                 power -= 10;
4748
4749                 if ((power > randint0(5)) && one_in_(4))
4750                 {
4751                         /* sex change */
4752                         power -= 2;
4753
4754                         if (p_ptr->psex == SEX_MALE)
4755                         {
4756                                 p_ptr->psex = SEX_FEMALE;
4757                                 sp_ptr = &sex_info[p_ptr->psex];
4758 #ifdef JP
4759 sprintf(effect_msg, "½÷À­¤Î");
4760 #else
4761                                 sprintf(effect_msg, "female ");
4762 #endif
4763
4764                         }
4765                         else
4766                         {
4767                                 p_ptr->psex = SEX_MALE;
4768                                 sp_ptr = &sex_info[p_ptr->psex];
4769 #ifdef JP
4770 sprintf(effect_msg, "ÃËÀ­¤Î");
4771 #else
4772                                 sprintf(effect_msg, "male ");
4773 #endif
4774
4775                         }
4776                 }
4777
4778                 if ((power > randint0(30)) && one_in_(5))
4779                 {
4780                         int tmp = 0;
4781
4782                         /* Harmful deformity */
4783                         power -= 15;
4784
4785                         while (tmp < 6)
4786                         {
4787                                 if (one_in_(2))
4788                                 {
4789                                         (void)dec_stat(tmp, randint1(6) + 6, one_in_(3));
4790                                         power -= 1;
4791                                 }
4792                                 tmp++;
4793                         }
4794
4795                         /* Deformities are discriminated against! */
4796                         (void)dec_stat(A_CHR, randint1(6), TRUE);
4797
4798                         if (effect_msg[0])
4799                         {
4800                                 char tmp_msg[10];
4801 #ifdef JP
4802                                 sprintf(tmp_msg,"%s",effect_msg);
4803                                 sprintf(effect_msg,"´ñ·Á¤Î%s",tmp_msg);
4804 #else
4805                                 sprintf(tmp_msg,"%s ",effect_msg);
4806                                 sprintf(effect_msg,"deformed %s ",tmp_msg);
4807 #endif
4808
4809                         }
4810                         else
4811                         {
4812 #ifdef JP
4813                                 sprintf(effect_msg,"´ñ·Á¤Î");
4814 #else
4815                                 sprintf(effect_msg,"deformed ");
4816 #endif
4817
4818                         }
4819                 }
4820
4821                 while ((power > randint0(20)) && one_in_(10))
4822                 {
4823                         /* Polymorph into a less mutated form */
4824                         power -= 10;
4825
4826                         if (!lose_mutation(0))
4827 #ifdef JP
4828 msg_print("´ñ̯¤Ê¤¯¤é¤¤ÉáÄ̤ˤʤ俵¤¤¬¤¹¤ë¡£");
4829 #else
4830                                 msg_print("You feel oddly normal.");
4831 #endif
4832
4833                 }
4834
4835                 /*
4836                  * Restrict the race choices by exp penalty so
4837                  * weak polymorph always means weak race
4838                  */
4839                 if (power < 0)
4840                         goalexpfact = 100;
4841                 else
4842                         goalexpfact = 100 + 3 * randint0(power);
4843
4844                 do
4845                 {
4846                         new_race = randint0(MAX_RACES);
4847                         expfact = race_info[new_race].r_exp;
4848                 }
4849                 while (((new_race == p_ptr->prace) && (expfact > goalexpfact)) || (new_race == RACE_ANDROID));
4850
4851 #ifdef JP
4852                 msg_format("¤¢¤Ê¤¿¤Ï%s%s¤ËÊѲ½¤·¤¿¡ª", effect_msg,
4853                                 race_info[new_race].title);
4854 #else
4855                 if (effect_msg[0])
4856                 {
4857                         msg_format("You turn into a%s %s!",
4858                                 ((new_race == RACE_AMBERITE || new_race == RACE_ELF
4859                                 || new_race == RACE_IMP) ? "n" : ""),
4860                                 race_info[new_race].title);
4861                 }
4862                 else
4863                 {
4864                         msg_format("You turn into a %s%s!", effect_msg,
4865                                 race_info[new_race].title);
4866                 }
4867 #endif
4868
4869                 chg_virtue(V_CHANCE, 2);
4870
4871                 if (p_ptr->prace < 32)
4872                 {
4873                         p_ptr->old_race1 |= 1L << p_ptr->prace;
4874                 }
4875                 else
4876                 {
4877                         p_ptr->old_race2 = 1L << (p_ptr->prace-32);
4878                 }
4879                 p_ptr->prace = new_race;
4880                 rp_ptr = &race_info[p_ptr->prace];
4881
4882                 /* Experience factor */
4883                 p_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
4884
4885                 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)))
4886                         p_ptr->expfact -= 15;
4887
4888
4889                 /* Calculate the height/weight for males */
4890                 if (p_ptr->psex == SEX_MALE)
4891                 {
4892                         p_ptr->ht = randnor(rp_ptr->m_b_ht, rp_ptr->m_m_ht);
4893                         h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->m_b_ht);
4894                         p_ptr->wt = randnor((int)(rp_ptr->m_b_wt) * h_percent /100
4895                                             , (int)(rp_ptr->m_m_wt) * h_percent / 300 );
4896                 }
4897
4898                 /* Calculate the height/weight for females */
4899                 else if (p_ptr->psex == SEX_FEMALE)
4900                 {
4901                         p_ptr->ht = randnor(rp_ptr->f_b_ht, rp_ptr->f_m_ht);
4902                         h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->f_b_ht);
4903                         p_ptr->wt = randnor((int)(rp_ptr->f_b_wt) * h_percent /100
4904                                             , (int)(rp_ptr->f_m_wt) * h_percent / 300 );
4905                 }
4906
4907                 check_experience();
4908
4909                 /* Hitdice */
4910                 if (p_ptr->pclass == CLASS_SORCERER)
4911                         p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
4912                 else
4913                         p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
4914
4915                 do_cmd_rerate(FALSE);
4916
4917                 p_ptr->redraw |= (PR_BASIC);
4918
4919                 p_ptr->update |= (PU_BONUS);
4920
4921                 handle_stuff();
4922                 lite_spot(py, px);
4923         }
4924
4925         if ((power > randint0(30)) && one_in_(6))
4926         {
4927                 int tmp = 0;
4928
4929                 /* Abomination! */
4930                 power -= 20;
4931
4932 #ifdef JP
4933 msg_format("%s¤Î¹½À®¤¬ÊѲ½¤·¤¿¡ª", p_ptr->prace == RACE_ANDROID ? "µ¡³£" : "Æâ¡");
4934 #else
4935                 msg_print("Your internal organs are rearranged!");
4936 #endif
4937
4938                 while (tmp < 6)
4939                 {
4940                         (void)dec_stat(tmp, randint1(6) + 6, one_in_(3));
4941                         tmp++;
4942                 }
4943                 if (one_in_(6))
4944                 {
4945 #ifdef JP
4946 msg_print("¸½ºß»Ñ¤ÇÀ¸¤­¤Æ¤¤¤¯¤Î¤Ïº¤Æñ¤Ê¤è¤¦¤À¡ª");
4947 take_hit(DAMAGE_LOSELIFE, damroll(randint1(10), p_ptr->lev), "Ã×̿Ū¤ÊÆÍÁ³ÊÑ°Û", -1);
4948 #else
4949                         msg_print("You find living difficult in your present form!");
4950                         take_hit(DAMAGE_LOSELIFE, damroll(randint1(10), p_ptr->lev), "a lethal mutation", -1);
4951 #endif
4952
4953                         power -= 10;
4954                 }
4955         }
4956
4957         if ((power > randint0(20)) && one_in_(4))
4958         {
4959                 power -= 10;
4960
4961                 get_max_stats();
4962                 do_cmd_rerate(FALSE);
4963         }
4964
4965         while ((power > randint0(15)) && one_in_(3))
4966         {
4967                 power -= 7;
4968                 (void)gain_random_mutation(0);
4969         }
4970
4971         if (power > randint0(5))
4972         {
4973                 power -= 5;
4974                 do_poly_wounds();
4975         }
4976
4977         /* Note: earlier deductions may have left power < 0 already. */
4978         while (power > 0)
4979         {
4980                 mutate_player();
4981                 power--;
4982         }
4983 }
4984
4985
4986 /*
4987  * Decreases players hit points and sets death flag if necessary
4988  *
4989  * XXX XXX XXX Invulnerability needs to be changed into a "shield"
4990  *
4991  * XXX XXX XXX Hack -- this function allows the user to save (or quit)
4992  * the game when he dies, since the "You die." message is shown before
4993  * setting the player to "dead".
4994  */
4995 int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
4996 {
4997         int old_chp = p_ptr->chp;
4998
4999         char death_message[1024];
5000         char tmp[80];
5001
5002         int warning = (p_ptr->mhp * hitpoint_warn / 10);
5003
5004         /* Paranoia */
5005         if (p_ptr->is_dead) return 0;
5006
5007         if (p_ptr->sutemi) damage *= 2;
5008         if (p_ptr->special_defense & KATA_IAI) damage += (damage + 4) / 5;
5009
5010         if (easy_band) damage = (damage+1)/2;
5011
5012         if (damage_type != DAMAGE_USELIFE)
5013         {
5014                 /* Disturb */
5015                 disturb(1, 0);
5016                 if (auto_more)
5017                 {
5018                         now_damaged = TRUE;
5019                 }
5020         }
5021
5022         if (monspell >= 0) learn_spell(monspell);
5023
5024         /* Mega-Hack -- Apply "invulnerability" */
5025         if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE))
5026         {
5027                 if (IS_INVULN() && (damage < 9000))
5028                 {
5029                         if (damage_type == DAMAGE_FORCE)
5030                         {
5031 #ifdef JP
5032                                 msg_print("¥Ð¥ê¥¢¤¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
5033 #else
5034                                 msg_print("The attack cuts your shield of invulnerability open!");
5035 #endif
5036                         }
5037                         else if (one_in_(PENETRATE_INVULNERABILITY))
5038                         {
5039 #ifdef JP
5040                                 msg_print("̵Ũ¤Î¥Ð¥ê¥¢¤òÇˤäƹ¶·â¤µ¤ì¤¿¡ª");
5041 #else
5042                                 msg_print("The attack penetrates your shield of invulnerability!");
5043 #endif
5044                         }
5045                         else
5046                         {
5047                                 return 0;
5048                         }
5049                 }
5050
5051                 /* Multishadow effects is determined by turn */
5052                 if (p_ptr->multishadow && (turn & 1))
5053                 {
5054                         if (damage_type == DAMAGE_FORCE)
5055                         {
5056 #ifdef JP
5057                                 msg_print("¸¸±Æ¤â¤í¤È¤âÂΤ¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
5058 #else
5059                                 msg_print("The attack hits Shadow together with you!");
5060 #endif
5061                         }
5062                         else if (damage_type == DAMAGE_ATTACK)
5063                         {
5064 #ifdef JP
5065                                 msg_print("¹¶·â¤Ï¸¸±Æ¤ËÌ¿Ã椷¡¢¤¢¤Ê¤¿¤Ë¤ÏÆϤ«¤Ê¤«¤Ã¤¿¡£");
5066 #else
5067                                 msg_print("The attack hits Shadow, you are unharmed!");
5068 #endif
5069                                 return 0;
5070                         }
5071                 }
5072
5073                 if (p_ptr->wraith_form)
5074                 {
5075                         if (damage_type == DAMAGE_FORCE)
5076                         {
5077 #ifdef JP
5078                                 msg_print("Ⱦʪ¼Á¤ÎÂΤ¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
5079 #else
5080                                 msg_print("The attack cuts through your ethereal body!");
5081 #endif
5082                         }
5083                         else
5084                         {
5085                                 damage /= 2;
5086                                 if ((damage == 0) && one_in_(2)) damage = 1;
5087                         }
5088                 }
5089
5090                 if (p_ptr->special_defense & KATA_MUSOU)
5091                 {
5092                         damage /= 2;
5093                         if ((damage == 0) && one_in_(2)) damage = 1;
5094                 }
5095         } /* not if LOSELIFE USELIFE */
5096
5097         /* Hurt the player */
5098         p_ptr->chp -= damage;
5099         if(damage_type == DAMAGE_GENO && p_ptr->chp < 0)
5100         {
5101                 damage += p_ptr->chp;
5102                 p_ptr->chp = 0;
5103         }
5104
5105         /* Display the hitpoints */
5106         p_ptr->redraw |= (PR_HP);
5107
5108         /* Window stuff */
5109         p_ptr->window |= (PW_PLAYER);
5110
5111         handle_stuff();
5112
5113         if (damage_type != DAMAGE_GENO && p_ptr->chp == 0)
5114         {
5115                 chg_virtue(V_SACRIFICE, 1);
5116                 chg_virtue(V_CHANCE, 2);
5117         }
5118
5119         /* Dead player */
5120         if (p_ptr->chp < 0)
5121         {
5122                 char buf[10];
5123                 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
5124
5125 #ifdef JP       /* »à¤ó¤À»þ¤Ë¶¯À©½ªÎ»¤·¤Æ»à¤ò²óÈò¤Ç¤­¤Ê¤¯¤·¤Æ¤ß¤¿ by Habu */
5126                 if (!cheat_save)
5127                         if(!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
5128 #endif
5129
5130                 /* Sound */
5131                 sound(SOUND_DEATH);
5132
5133                 chg_virtue(V_SACRIFICE, 10);
5134
5135                 /* Leaving */
5136                 p_ptr->leaving = TRUE;
5137
5138                 /* Note death */
5139                 p_ptr->is_dead = TRUE;
5140
5141                 if (p_ptr->inside_arena)
5142                 {
5143                         cptr m_name = r_name+r_info[arena_info[p_ptr->arena_number].r_idx].name;
5144 #ifdef JP
5145                         msg_format("¤¢¤Ê¤¿¤Ï%s¤ÎÁ°¤ËÇÔ¤ìµî¤Ã¤¿¡£", m_name);
5146 #else
5147                         msg_format("You are beaten by %s.", m_name);
5148 #endif
5149                         msg_print(NULL);
5150                         if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, -1 - p_ptr->arena_number, m_name);
5151                 }
5152                 else
5153                 {
5154                         int q_idx = quest_number(dun_level);
5155
5156 #ifdef WORLD_SCORE
5157                         /* Make screen dump */
5158                         screen_dump = make_screen_dump();
5159 #endif
5160
5161                         /* Note cause of death */
5162 #ifdef JP
5163                         sprintf(p_ptr->died_from, "%s%s%s", !p_ptr->paralyzed ? "" : p_ptr->free_act ? "ĦÁü¾õÂÖ¤Ç":"Ëãáã¾õÂÖ¤Ç", p_ptr->image ? "¸¸³Ð¤ËÏĤó¤À" : "", hit_from);
5164 #else
5165                         sprintf(p_ptr->died_from, "%s%s", hit_from, !p_ptr->paralyzed ? "" : " while helpless");
5166 #endif
5167
5168                         /* No longer a winner */
5169                         p_ptr->total_winner = FALSE;
5170
5171                         if (p_ptr->inside_arena)
5172 #ifdef JP
5173                                 strcpy(buf,"¥¢¥ê¡¼¥Ê");
5174 #else
5175                                 strcpy(buf,"in the Arena");
5176 #endif
5177                         else if (!dun_level)
5178 #ifdef JP
5179                                 strcpy(buf,"ÃϾå");
5180 #else
5181                                 strcpy(buf,"on the surface");
5182 #endif
5183                         else if (q_idx && (is_fixed_quest_idx(q_idx) &&
5184                                  !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
5185 #ifdef JP
5186                                 strcpy(buf,"¥¯¥¨¥¹¥È");
5187 #else
5188                                 strcpy(buf,"in a quest");
5189 #endif
5190                         else
5191 #ifdef JP
5192                                 sprintf(buf,"%d³¬", dun_level);
5193 #else
5194                                 sprintf(buf,"level %d", dun_level);
5195 #endif
5196 #ifdef JP
5197                         sprintf(tmp,"%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£",buf, p_ptr->died_from);
5198 #else
5199                         sprintf(tmp,"killed by %s %s.", p_ptr->died_from, buf);
5200 #endif
5201                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
5202 #ifdef JP
5203                         do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5204 #else
5205                         do_cmd_write_nikki(NIKKI_GAMESTART, 1, "--------   Game  Over   --------");
5206 #endif
5207                         do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5208
5209                         flush();
5210
5211 #ifdef JP
5212 if (get_check_strict("²èÌ̤òÊݸ¤·¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
5213 #else
5214                         if (get_check_strict("Dump the screen? ", CHECK_NO_HISTORY))
5215 #endif
5216
5217                         {
5218                                 do_cmd_save_screen();
5219                         }
5220
5221                         flush();
5222
5223                         /* Hack -- Note death */
5224                         if (!last_words)
5225                         {
5226 #ifdef JP
5227 msg_format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë");
5228 #else
5229                                 msg_print(android ? "You are broken." : "You die.");
5230 #endif
5231
5232                                 msg_print(NULL);
5233                         }
5234                         else
5235                         {
5236                                 if (streq(p_ptr->died_from, "Seppuku"))
5237                                 {
5238 #ifdef JP
5239                                   get_rnd_line("seppuku_j.txt", 0, death_message);
5240 #else
5241                                         get_rnd_line("seppuku.txt", 0, death_message);
5242 #endif
5243                                 }
5244                                 else
5245                                 {
5246 #ifdef JP
5247 get_rnd_line("death_j.txt", 0, death_message);
5248 #else
5249                                         get_rnd_line("death.txt", 0, death_message);
5250 #endif
5251                                 }
5252 #ifdef JP
5253                                 while (!get_string(streq(p_ptr->died_from, "Seppuku") ? "¼­À¤¤Î¶ç: " : "ÃÇËöËâ¤Î¶«¤Ó: ", death_message, 1024)) ;
5254 #else
5255                                 while (!get_string("Last word: ", death_message, 1024)) ;
5256 #endif
5257                                 if (death_message[0] == '\0')
5258                                 {
5259 #ifdef JP
5260                                         strcpy(death_message, format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë"));
5261 #else
5262                                         strcpy(death_message, android ? "You are broken." : "You die.");
5263 #endif
5264                                 }
5265                                 if (streq(p_ptr->died_from, "Seppuku"))
5266                                 {
5267 #ifdef JP
5268                                   int i, len;
5269                                   int w = Term->wid;
5270                                   int h = Term->hgt;
5271                                   int msg_pos_x[9] = {  5,  7,  9, 12,  14,  17,  19,  21, 23};
5272                                   int msg_pos_y[9] = {  3,  4,  5,  4,   5,   4,   5,   6,  4};
5273                                   cptr str;
5274                                   char* str2;
5275
5276                                   Term_clear();
5277
5278                                   /* ºù»¶¤ë */
5279                                   for (i = 0; i < 40; i++) 
5280                                     Term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "¦Ô");
5281
5282                                   str = death_message;
5283                                   if (strncmp(str, "¡Ö", 2) == 0) str += 2;
5284
5285                                   str2 = strstr_j(str, "¡×");
5286                                   if (str2 != NULL) *str2 = '\0';
5287
5288                                   i = 0;
5289                                   while (i < 9)
5290                                   {
5291                                     str2 = strstr_j(str, " ");
5292                                     if (str2 == NULL) len = strlen(str);
5293                                     else len = str2 - str;
5294
5295                                     if (len != 0)
5296                                     {
5297                                       Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len,
5298                                                   TERM_WHITE, str);
5299                                       if (str2 == NULL) break;
5300                                       i++;
5301                                     }
5302                                     str = str2 + 1;
5303                                     if (*str == 0) break;
5304                                   }
5305
5306                                   /* Hide cursor */
5307                                   Term_putstr(w-1, h-1, 1, TERM_WHITE, " ");
5308
5309                                   flush();
5310 #ifdef WORLD_SCORE
5311                                   /* Make screen dump */
5312                                   screen_dump = make_screen_dump();
5313 #endif
5314
5315                                   /* Wait a key press */
5316                                   (void)inkey();
5317 #else
5318                                         msg_print(death_message);
5319 #endif
5320                                 }
5321                                 else
5322                                         msg_print(death_message);
5323                         }
5324                 }
5325
5326                 /* Dead */
5327                 return damage;
5328         }
5329
5330         /* Hitpoint warning */
5331         if (p_ptr->chp < warning)
5332         {
5333                 /* Hack -- bell on first notice */
5334                 if (alert_hitpoint && (old_chp > warning)) bell();
5335
5336                 sound(SOUND_WARN);
5337
5338                 if (record_danger && (old_chp > warning))
5339                 {
5340                         if (p_ptr->image && damage_type == DAMAGE_ATTACK)
5341 #ifdef JP
5342                                 hit_from = "²¿¤«";
5343 #else
5344                                 hit_from = "something";
5345 #endif
5346
5347 #ifdef JP
5348                         sprintf(tmp,"%s¤Ë¤è¤Ã¤Æ¥Ô¥ó¥Á¤Ë´Ù¤¤¤Ã¤¿¡£",hit_from);
5349 #else
5350                         sprintf(tmp,"A critical situation because of %s.",hit_from);
5351 #endif
5352                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
5353                 }
5354
5355                 if (auto_more)
5356                 {
5357                         /* stop auto_more even if DAMAGE_USELIFE */
5358                         now_damaged = TRUE;
5359                 }
5360
5361                 /* Message */
5362 #ifdef JP
5363 msg_print("*** ·Ù¹ð:Äã¥Ò¥Ã¥È¡¦¥Ý¥¤¥ó¥È¡ª ***");
5364 #else
5365                 msg_print("*** LOW HITPOINT WARNING! ***");
5366 #endif
5367
5368                 msg_print(NULL);
5369                 flush();
5370         }
5371         if (p_ptr->wild_mode && !p_ptr->leaving && (p_ptr->chp < MAX(warning, p_ptr->mhp/5)))
5372         {
5373                 p_ptr->wilderness_x = px;
5374                 p_ptr->wilderness_y = py;
5375                 p_ptr->energy_need = 0;
5376                 change_wild_mode();
5377         }
5378         return damage;
5379 }
5380
5381
5382 /*
5383  * Gain experience
5384  */
5385 void gain_exp(s32b amount)
5386 {
5387         if (p_ptr->is_dead) return;
5388
5389         if (p_ptr->prace == RACE_ANDROID) return;
5390
5391         /* Gain some experience */
5392         p_ptr->exp += amount;
5393
5394         /* Slowly recover from experience drainage */
5395         if (p_ptr->exp < p_ptr->max_exp)
5396         {
5397                 /* Gain max experience (20%) (was 10%) */
5398                 p_ptr->max_exp += amount / 5;
5399         }
5400
5401         /* Check Experience */
5402         check_experience();
5403 }
5404
5405
5406 void calc_android_exp(void)
5407 {
5408         int i;
5409         u32b total_exp = 0;
5410         if (p_ptr->is_dead) return;
5411
5412         if (p_ptr->prace != RACE_ANDROID) return;
5413
5414         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
5415         {
5416                 object_type *o_ptr = &inventory[i];
5417                 object_type forge;
5418                 object_type *q_ptr = &forge;
5419                 u32b value, exp;
5420                 int level = MAX(get_object_level(o_ptr) - 8, 1);
5421
5422                 if ((i == INVEN_RIGHT) || (i == INVEN_LEFT) || (i == INVEN_NECK) || (i == INVEN_LITE)) continue;
5423                 if (!o_ptr->k_idx) continue;
5424
5425                 /* Wipe the object */
5426                 object_wipe(q_ptr);
5427
5428                 object_copy(q_ptr, o_ptr);
5429                 q_ptr->discount = 0;
5430                 q_ptr->curse_flags = 0L;
5431
5432                 if (o_ptr->name1)
5433                 {
5434                         level = (level + MAX(a_info[o_ptr->name1].level - 8, 5)) / 2;
5435                         level += MIN(20, a_info[o_ptr->name1].rarity/(a_info[o_ptr->name1].gen_flags & TRG_INSTA_ART ? 10 : 3));
5436                 }
5437                 else if (o_ptr->name2)
5438                 {
5439                         level += MAX(3, (e_info[o_ptr->name2].rating - 5)/2);
5440                 }
5441                 else if (o_ptr->art_name)
5442                 {
5443                         s32b total_flags = flag_cost(o_ptr, o_ptr->pval);
5444                         int fake_level;
5445
5446                         if (o_ptr->tval >= TV_BOOTS)
5447                         {
5448                                 /* For armors */
5449                                 if (total_flags < 15000) fake_level = 10;
5450                                 else if (total_flags < 35000) fake_level = 25;
5451                                 else fake_level = 40;
5452                         }
5453                         else
5454                         {
5455                                 /* For weapons */
5456                                 if (total_flags < 20000) fake_level = 10;
5457                                 else if (total_flags < 45000) fake_level = 25;
5458                                 else fake_level = 40;
5459                         }
5460
5461                         level = MAX(level, (level + MAX(fake_level - 8, 5)) / 2 + 3);
5462                 }
5463
5464                 value = object_value_real(q_ptr);
5465
5466                 if (value <= 0) continue;
5467                 if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI) && (p_ptr->pseikaku != SEIKAKU_SEXY)) value /= 32;
5468                 if (value > 5000000L) value = 5000000L;
5469                 if ((o_ptr->tval == TV_DRAG_ARMOR) || (o_ptr->tval == TV_CARD)) level /= 2;
5470
5471                 if (o_ptr->name1 || o_ptr->name2 || o_ptr->art_name ||
5472                     (o_ptr->tval == TV_DRAG_ARMOR) ||
5473                     ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
5474                     ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
5475                     ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
5476                     ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)) ||
5477                     ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
5478                 {
5479                         if (level > 65) level = 35 + (level - 65) / 5;
5480                         else if (level > 35) level = 25 + (level - 35) / 3;
5481                         else if (level > 15) level = 15 + (level - 15) / 2;
5482                         exp = MIN(100000L, value) * level * level / 2;
5483                         if (value > 100000L)
5484                                 exp += (value - 100000L) * level * level / 8;
5485                 }
5486                 else
5487                 {
5488                         exp = MIN(100000L, value) * level;
5489                         if (value > 100000L)
5490                                 exp += (value - 100000L) * level / 4;
5491                 }
5492                 if ((((i == INVEN_RARM) || (i == INVEN_LARM)) && (buki_motteruka(i))) || (i == INVEN_BOW)) total_exp += exp / 48;
5493                 else total_exp += exp / 16;
5494                 if (i == INVEN_BODY) total_exp += exp / 32;
5495         }
5496         p_ptr->exp = p_ptr->max_exp = total_exp;
5497
5498         /* Check Experience */
5499         check_experience();
5500 }
5501
5502
5503 /*
5504  * Lose experience
5505  */
5506 void lose_exp(s32b amount)
5507 {
5508         if (p_ptr->prace == RACE_ANDROID) return;
5509
5510         /* Never drop below zero experience */
5511         if (amount > p_ptr->exp) amount = p_ptr->exp;
5512
5513         /* Lose some experience */
5514         p_ptr->exp -= amount;
5515
5516         /* Check Experience */
5517         check_experience();
5518 }
5519
5520
5521 /*
5522  * Drain experience
5523  * If resisted to draining, return FALSE
5524  */
5525 bool drain_exp(s32b drain, s32b slip, int hold_life_prob)
5526 {
5527         /* Androids and their mimics are never drained */
5528         if (p_ptr->prace == RACE_ANDROID) return FALSE;
5529
5530         if (p_ptr->hold_life && (randint0(100) < hold_life_prob))
5531         {
5532                 /* Hold experience */
5533 #ifdef JP
5534                 msg_print("¤·¤«¤·¼«¸Ê¤ÎÀ¸Ì¿ÎϤò¼é¤ê¤­¤Ã¤¿¡ª");
5535 #else
5536                 msg_print("You keep hold of your life force!");
5537 #endif
5538                 return FALSE;
5539         }
5540
5541         /* Hold experience failed */
5542         if (p_ptr->hold_life)
5543         {
5544 #ifdef JP
5545                 msg_print("À¸Ì¿ÎϤò¾¯¤·µÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
5546 #else
5547                 msg_print("You feel your life slipping away!");
5548 #endif
5549                 lose_exp(slip);
5550         }
5551         else
5552         {
5553 #ifdef JP
5554                 msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
5555 #else
5556                 msg_print("You feel your life draining away!");
5557 #endif
5558                 lose_exp(drain);
5559         }
5560
5561         return TRUE;
5562 }
5563
5564
5565 bool set_ultimate_res(int v, bool do_dec)
5566 {
5567         bool notice = FALSE;
5568
5569         /* Hack -- Force good values */
5570         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5571
5572         if (p_ptr->is_dead) return FALSE;
5573
5574         /* Open */
5575         if (v)
5576         {
5577                 if (p_ptr->ult_res && !do_dec)
5578                 {
5579                         if (p_ptr->ult_res > v) return FALSE;
5580                 }
5581                 else if (!p_ptr->ult_res)
5582                 {
5583 #ifdef JP
5584 msg_print("¤¢¤é¤æ¤ë¤³¤È¤ËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5585 #else
5586                         msg_print("You feel resistant!");
5587 #endif
5588
5589                         notice = TRUE;
5590                 }
5591         }
5592
5593         /* Shut */
5594         else
5595         {
5596                 if (p_ptr->ult_res)
5597                 {
5598 #ifdef JP
5599 msg_print("¤¢¤é¤æ¤ë¤³¤È¤ËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5600 #else
5601                         msg_print("You feel less resistant");
5602 #endif
5603
5604                         notice = TRUE;
5605                 }
5606         }
5607
5608         /* Use the value */
5609         p_ptr->ult_res = v;
5610
5611         /* Redraw status bar */
5612         p_ptr->redraw |= (PR_STATUS);
5613
5614         /* Nothing to notice */
5615         if (!notice) return (FALSE);
5616
5617         /* Disturb */
5618         if (disturb_state) disturb(0, 0);
5619
5620         /* Recalculate bonuses */
5621         p_ptr->update |= (PU_BONUS);
5622
5623         /* Handle stuff */
5624         handle_stuff();
5625
5626         /* Result */
5627         return (TRUE);
5628 }
5629
5630 bool set_tim_res_nether(int v, bool do_dec)
5631 {
5632         bool notice = FALSE;
5633
5634         /* Hack -- Force good values */
5635         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5636
5637         if (p_ptr->is_dead) return FALSE;
5638
5639         /* Open */
5640         if (v)
5641         {
5642                 if (p_ptr->tim_res_nether && !do_dec)
5643                 {
5644                         if (p_ptr->tim_res_nether > v) return FALSE;
5645                 }
5646                 else if (!p_ptr->tim_res_nether)
5647                 {
5648 #ifdef JP
5649 msg_print("ÃϹö¤ÎÎϤËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5650 #else
5651                         msg_print("You feel nether resistant!");
5652 #endif
5653
5654                         notice = TRUE;
5655                 }
5656         }
5657
5658         /* Shut */
5659         else
5660         {
5661                 if (p_ptr->tim_res_nether)
5662                 {
5663 #ifdef JP
5664 msg_print("ÃϹö¤ÎÎϤËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5665 #else
5666                         msg_print("You feel less nether resistant");
5667 #endif
5668
5669                         notice = TRUE;
5670                 }
5671         }
5672
5673         /* Use the value */
5674         p_ptr->tim_res_nether = v;
5675
5676         /* Redraw status bar */
5677         p_ptr->redraw |= (PR_STATUS);
5678
5679         /* Nothing to notice */
5680         if (!notice) return (FALSE);
5681
5682         /* Disturb */
5683         if (disturb_state) disturb(0, 0);
5684
5685         /* Recalculate bonuses */
5686         p_ptr->update |= (PU_BONUS);
5687
5688         /* Handle stuff */
5689         handle_stuff();
5690
5691         /* Result */
5692         return (TRUE);
5693 }
5694
5695 bool set_tim_res_time(int v, bool do_dec)
5696 {
5697         bool notice = FALSE;
5698
5699         /* Hack -- Force good values */
5700         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5701
5702         if (p_ptr->is_dead) return FALSE;
5703
5704         /* Open */
5705         if (v)
5706         {
5707                 if (p_ptr->tim_res_time && !do_dec)
5708                 {
5709                         if (p_ptr->tim_res_time > v) return FALSE;
5710                 }
5711                 else if (!p_ptr->tim_res_time)
5712                 {
5713 #ifdef JP
5714 msg_print("»þ´ÖµÕž¤ÎÎϤËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5715 #else
5716                         msg_print("You feel time resistant!");
5717 #endif
5718
5719                         notice = TRUE;
5720                 }
5721         }
5722
5723         /* Shut */
5724         else
5725         {
5726                 if (p_ptr->tim_res_time)
5727                 {
5728 #ifdef JP
5729 msg_print("»þ´ÖµÕž¤ÎÎϤËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5730 #else
5731                         msg_print("You feel less time resistant");
5732 #endif
5733
5734                         notice = TRUE;
5735                 }
5736         }
5737
5738         /* Use the value */
5739         p_ptr->tim_res_time = v;
5740
5741         /* Redraw status bar */
5742         p_ptr->redraw |= (PR_STATUS);
5743
5744         /* Nothing to notice */
5745         if (!notice) return (FALSE);
5746
5747         /* Disturb */
5748         if (disturb_state) disturb(0, 0);
5749
5750         /* Recalculate bonuses */
5751         p_ptr->update |= (PU_BONUS);
5752
5753         /* Handle stuff */
5754         handle_stuff();
5755
5756         /* Result */
5757         return (TRUE);
5758 }
5759
5760
5761 /*
5762  * Choose a warrior-mage elemental attack. -LM-
5763  */
5764 bool choose_ele_attack(void)
5765 {
5766         int num;
5767
5768         char choice;
5769
5770         /* Save screen */
5771         screen_save();
5772
5773         num = (p_ptr->lev - 20) / 5;
5774
5775 #ifdef JP
5776                       c_prt(TERM_RED,    "        a) ¾Æ´þ", 2, 14);
5777 #else
5778                       c_prt(TERM_RED,    "        a) Fire Brand", 2, 14);
5779 #endif
5780
5781 #ifdef JP
5782         if (num >= 2) c_prt(TERM_L_WHITE,"        b) Åà·ë", 3, 14);
5783 #else
5784         if (num >= 2) c_prt(TERM_L_WHITE,"        b) Cold Brand", 3, 14);
5785 #endif
5786         else prt("", 3, 14);
5787
5788 #ifdef JP
5789         if (num >= 3) c_prt(TERM_GREEN,  "        c) ÆÇ»¦", 4, 14);
5790 #else
5791         if (num >= 3) c_prt(TERM_GREEN,  "        c) Poison Brand", 4, 14);
5792 #endif
5793         else prt("", 4, 14);
5794
5795 #ifdef JP
5796         if (num >= 4) c_prt(TERM_L_DARK, "        d) Íϲò", 5, 14);
5797 #else
5798         if (num >= 4) c_prt(TERM_L_DARK, "        d) Acid Brand", 5, 14);
5799 #endif
5800         else prt("", 5, 14);
5801
5802 #ifdef JP
5803         if (num >= 5) c_prt(TERM_BLUE,   "        e) ÅÅ·â", 6, 14);
5804 #else
5805         if (num >= 5) c_prt(TERM_BLUE,   "        e) Elec Brand", 6, 14);
5806 #endif
5807         else prt("", 6, 14);
5808
5809         prt("", 7, 14);
5810         prt("", 8, 14);
5811         prt("", 9, 14);
5812
5813         prt("", 1, 0);
5814 #ifdef JP
5815         prt("        ¤É¤Î¸µÁǹ¶·â¤ò¤·¤Þ¤¹¤«¡©", 1, 14);
5816 #else
5817         prt("        Choose a temporary elemental brand ", 1, 14);
5818 #endif
5819
5820         choice = inkey();
5821
5822         if ((choice == 'a') || (choice == 'A')) 
5823                 set_ele_attack(ATTACK_FIRE, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5824         else if (((choice == 'b') || (choice == 'B')) && (num >= 2))
5825                 set_ele_attack(ATTACK_COLD, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5826         else if (((choice == 'c') || (choice == 'C')) && (num >= 3))
5827                 set_ele_attack(ATTACK_POIS, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5828         else if (((choice == 'd') || (choice == 'D')) && (num >= 4))
5829                 set_ele_attack(ATTACK_ACID, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5830         else if (((choice == 'e') || (choice == 'E')) && (num >= 5))
5831                 set_ele_attack(ATTACK_ELEC, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5832         else
5833         {
5834 #ifdef JP
5835                 msg_print("ËâË¡·õ¤ò»È¤¦¤Î¤ò¤ä¤á¤¿¡£");
5836 #else
5837                 msg_print("You cancel the temporary branding.");
5838 #endif
5839                 screen_load();
5840                 return FALSE;
5841         }
5842         /* Load screen */
5843         screen_load();
5844         return TRUE;
5845 }
5846
5847
5848 /*
5849  * Choose a elemental immune. -LM-
5850  */
5851 bool choose_ele_immune(int turn)
5852 {
5853         char choice;
5854
5855         /* Save screen */
5856         screen_save();
5857
5858 #ifdef JP
5859         c_prt(TERM_RED,    "        a) ²Ð±ê", 2, 14);
5860 #else
5861         c_prt(TERM_RED,    "        a) Immune Fire", 2, 14);
5862 #endif
5863
5864 #ifdef JP
5865         c_prt(TERM_L_WHITE,"        b) Î䵤", 3, 14);
5866 #else
5867         c_prt(TERM_L_WHITE,"        b) Immune Cold", 3, 14);
5868 #endif
5869
5870 #ifdef JP
5871         c_prt(TERM_L_DARK, "        c) »À", 4, 14);
5872 #else
5873         c_prt(TERM_L_DARK, "        c) Immune Acid", 4, 14);
5874 #endif
5875
5876 #ifdef JP
5877         c_prt(TERM_BLUE,   "        d) ÅÅ·â", 5, 14);
5878 #else
5879         c_prt(TERM_BLUE,   "        d) Immune Elec", 5, 14);
5880 #endif
5881
5882
5883         prt("", 6, 14);
5884         prt("", 7, 14);
5885         prt("", 8, 14);
5886         prt("", 9, 14);
5887
5888         prt("", 1, 0);
5889 #ifdef JP
5890         prt("        ¤É¤Î¸µÁǤÎÌȱ֤ò¤Ä¤±¤Þ¤¹¤«¡©", 1, 14);
5891 #else
5892         prt("        Choose a temporary elemental immune ", 1, 14);
5893 #endif
5894
5895         choice = inkey();
5896
5897         if ((choice == 'a') || (choice == 'A')) 
5898                 set_ele_immune(DEFENSE_FIRE, turn);
5899         else if ((choice == 'b') || (choice == 'B'))
5900                 set_ele_immune(DEFENSE_COLD, turn);
5901         else if ((choice == 'c') || (choice == 'C'))
5902                 set_ele_immune(DEFENSE_ACID, turn);
5903         else if ((choice == 'd') || (choice == 'D'))
5904                 set_ele_immune(DEFENSE_ELEC, turn);
5905         else
5906         {
5907 #ifdef JP
5908                 msg_print("Ìȱ֤òÉÕ¤±¤ë¤Î¤ò¤ä¤á¤¿¡£");
5909 #else
5910                 msg_print("You cancel the temporary immune.");
5911 #endif
5912                 screen_load();
5913                 return FALSE;
5914         }
5915         /* Load screen */
5916         screen_load();
5917         return TRUE;
5918 }