OSDN Git Service

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