OSDN Git Service

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