OSDN Git Service

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