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