OSDN Git Service

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