OSDN Git Service

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