OSDN Git Service

[Fix] 投げたオブジェクトの軌跡が残る
[hengband/hengband.git] / src / status / sight-setter.c
1 #include "status/sight-setter.h"
2 #include "core/disturbance.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "game-option/disturbance-options.h"
7 #include "realm/realm-song-numbers.h"
8 #include "view/display-messages.h"
9
10 /*!
11  * @brief 時限ESPの継続時間をセットする / Set "tim_esp", notice observable changes
12  * @param v 継続時間
13  * @param do_dec 現在の継続時間より長い値のみ上書きする
14  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
15  */
16 bool set_tim_esp(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
17 {
18     bool notice = FALSE;
19     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
20
21     if (creature_ptr->is_dead)
22         return FALSE;
23
24     if (v) {
25         if (creature_ptr->tim_esp && !do_dec) {
26             if (creature_ptr->tim_esp > v)
27                 return FALSE;
28         } else if (!is_time_limit_esp(creature_ptr)) {
29             msg_print(_("意識が広がった気がする!", "You feel your consciousness expand!"));
30             notice = TRUE;
31         }
32     } else {
33         if (creature_ptr->tim_esp && !music_singing(creature_ptr, MUSIC_MIND)) {
34             msg_print(_("意識は元に戻った。", "Your consciousness contracts again."));
35             notice = TRUE;
36         }
37     }
38
39     creature_ptr->tim_esp = v;
40     creature_ptr->redraw |= (PR_STATUS);
41
42     if (!notice)
43         return FALSE;
44
45     if (disturb_state)
46         disturb(creature_ptr, FALSE, FALSE);
47     creature_ptr->update |= (PU_BONUS);
48     creature_ptr->update |= (PU_MONSTERS);
49     handle_stuff(creature_ptr);
50     return TRUE;
51 }
52
53 /*!
54  * @brief 時限透明視の継続時間をセットする / Set "tim_invis", notice observable changes
55  * @param v 継続時間
56  * @param do_dec 現在の継続時間より長い値のみ上書きする
57  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
58  */
59 bool set_tim_invis(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
60 {
61     bool notice = FALSE;
62     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
63
64     if (creature_ptr->is_dead)
65         return FALSE;
66
67     if (v) {
68         if (creature_ptr->tim_invis && !do_dec) {
69             if (creature_ptr->tim_invis > v)
70                 return FALSE;
71         } else if (!creature_ptr->tim_invis) {
72             msg_print(_("目が非常に敏感になった気がする!", "Your eyes feel very sensitive!"));
73             notice = TRUE;
74         }
75     } else {
76         if (creature_ptr->tim_invis) {
77             msg_print(_("目の敏感さがなくなったようだ。", "Your eyes feel less sensitive."));
78             notice = TRUE;
79         }
80     }
81
82     creature_ptr->tim_invis = v;
83     creature_ptr->redraw |= (PR_STATUS);
84
85     if (!notice)
86         return FALSE;
87
88     if (disturb_state)
89         disturb(creature_ptr, FALSE, FALSE);
90     creature_ptr->update |= (PU_BONUS);
91     creature_ptr->update |= (PU_MONSTERS);
92     handle_stuff(creature_ptr);
93     return TRUE;
94 }
95
96 /*!
97  * @brief 時限赤外線視力の継続時間をセットする / Set "tim_infra", notice observable changes
98  * @param v 継続時間
99  * @param do_dec 現在の継続時間より長い値のみ上書きする
100  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
101  */
102 bool set_tim_infra(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
103 {
104     bool notice = FALSE;
105     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
106
107     if (creature_ptr->is_dead)
108         return FALSE;
109
110     if (v) {
111         if (creature_ptr->tim_infra && !do_dec) {
112             if (creature_ptr->tim_infra > v)
113                 return FALSE;
114         } else if (!creature_ptr->tim_infra) {
115             msg_print(_("目がランランと輝き始めた!", "Your eyes begin to tingle!"));
116             notice = TRUE;
117         }
118     } else {
119         if (creature_ptr->tim_infra) {
120             msg_print(_("目の輝きがなくなった。", "Your eyes stop tingling."));
121             notice = TRUE;
122         }
123     }
124
125     creature_ptr->tim_infra = v;
126     creature_ptr->redraw |= (PR_STATUS);
127
128     if (!notice)
129         return FALSE;
130
131     if (disturb_state)
132         disturb(creature_ptr, FALSE, FALSE);
133     creature_ptr->update |= (PU_BONUS);
134     creature_ptr->update |= (PU_MONSTERS);
135     handle_stuff(creature_ptr);
136     return TRUE;
137 }