OSDN Git Service

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