OSDN Git Service

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