OSDN Git Service

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