OSDN Git Service

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