OSDN Git Service

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