OSDN Git Service

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