OSDN Git Service

[Fix] 投げたオブジェクトの軌跡が残る
[hengband/hengband.git] / src / status / element-resistance.c
1 #include "status/element-resistance.h"
2 #include "core/disturbance.h"
3 #include "core/player-redraw-types.h"
4 #include "core/stuff-handler.h"
5 #include "game-option/disturbance-options.h"
6 #include "player/player-race.h"
7 #include "player/special-defense-types.h"
8 #include "realm/realm-song-numbers.h"
9 #include "view/display-messages.h"
10
11 /*!
12  * @brief 一時的酸耐性の継続時間をセットする / Set "oppose_acid", notice observable changes
13  * @param v 継続時間
14  * @param do_dec 現在の継続時間より長い値のみ上書きする
15  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
16  */
17 bool set_oppose_acid(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
18 {
19     bool notice = FALSE;
20     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
21     if (creature_ptr->is_dead)
22         return FALSE;
23
24     if (v) {
25         if (creature_ptr->oppose_acid && !do_dec) {
26             if (creature_ptr->oppose_acid > v)
27                 return FALSE;
28         } else if (!is_oppose_acid(creature_ptr)) {
29             msg_print(_("酸への耐性がついた気がする!", "You feel resistant to acid!"));
30             notice = TRUE;
31         }
32     } else {
33         if (creature_ptr->oppose_acid && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) {
34             msg_print(_("酸への耐性が薄れた気がする。", "You feel less resistant to acid."));
35             notice = TRUE;
36         }
37     }
38
39     creature_ptr->oppose_acid = v;
40
41     if (!notice)
42         return FALSE;
43     creature_ptr->redraw |= (PR_STATUS);
44
45     if (disturb_state)
46         disturb(creature_ptr, FALSE, FALSE);
47     handle_stuff(creature_ptr);
48     return TRUE;
49 }
50
51 /*!
52  * @brief 一時的電撃耐性の継続時間をセットする / Set "oppose_elec", notice observable changes
53  * @param v 継続時間
54  * @param do_dec 現在の継続時間より長い値のみ上書きする
55  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
56  */
57 bool set_oppose_elec(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
58 {
59     bool notice = FALSE;
60     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
61
62     if (creature_ptr->is_dead)
63         return FALSE;
64
65     if (v) {
66         if (creature_ptr->oppose_elec && !do_dec) {
67             if (creature_ptr->oppose_elec > v)
68                 return FALSE;
69         } else if (!is_oppose_elec(creature_ptr)) {
70             msg_print(_("電撃への耐性がついた気がする!", "You feel resistant to electricity!"));
71             notice = TRUE;
72         }
73     } else {
74         if (creature_ptr->oppose_elec && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) {
75             msg_print(_("電撃への耐性が薄れた気がする。", "You feel less resistant to electricity."));
76             notice = TRUE;
77         }
78     }
79
80     creature_ptr->oppose_elec = v;
81
82     if (!notice)
83         return FALSE;
84     creature_ptr->redraw |= (PR_STATUS);
85
86     if (disturb_state)
87         disturb(creature_ptr, FALSE, FALSE);
88     handle_stuff(creature_ptr);
89     return TRUE;
90 }
91
92 /*!
93  * @brief 一時的火炎耐性の継続時間をセットする / Set "oppose_fire", notice observable changes
94  * @param v 継続時間
95  * @param do_dec 現在の継続時間より長い値のみ上書きする
96  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
97  */
98 bool set_oppose_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
99 {
100     bool notice = FALSE;
101     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
102     if (creature_ptr->is_dead)
103         return FALSE;
104
105     if ((is_specific_player_race(creature_ptr, RACE_BALROG) && (creature_ptr->lev > 44)) || (creature_ptr->mimic_form == MIMIC_DEMON))
106         v = 1;
107     if (v) {
108         if (creature_ptr->oppose_fire && !do_dec) {
109             if (creature_ptr->oppose_fire > v)
110                 return FALSE;
111         } else if (!is_oppose_fire(creature_ptr)) {
112             msg_print(_("火への耐性がついた気がする!", "You feel resistant to fire!"));
113             notice = TRUE;
114         }
115     } else {
116         if (creature_ptr->oppose_fire && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) {
117             msg_print(_("火への耐性が薄れた気がする。", "You feel less resistant to fire."));
118             notice = TRUE;
119         }
120     }
121
122     creature_ptr->oppose_fire = v;
123
124     if (!notice)
125         return FALSE;
126     creature_ptr->redraw |= (PR_STATUS);
127
128     if (disturb_state)
129         disturb(creature_ptr, FALSE, FALSE);
130     handle_stuff(creature_ptr);
131     return TRUE;
132 }
133
134 /*!
135  * @brief 一時的冷気耐性の継続時間をセットする / Set "oppose_cold", notice observable changes
136  * @param v 継続時間
137  * @param do_dec 現在の継続時間より長い値のみ上書きする
138  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
139  */
140 bool set_oppose_cold(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
141 {
142     bool notice = FALSE;
143     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
144     if (creature_ptr->is_dead)
145         return FALSE;
146
147     if (v) {
148         if (creature_ptr->oppose_cold && !do_dec) {
149             if (creature_ptr->oppose_cold > v)
150                 return FALSE;
151         } else if (!is_oppose_cold(creature_ptr)) {
152             msg_print(_("冷気への耐性がついた気がする!", "You feel resistant to cold!"));
153             notice = TRUE;
154         }
155     } else {
156         if (creature_ptr->oppose_cold && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) {
157             msg_print(_("冷気への耐性が薄れた気がする。", "You feel less resistant to cold."));
158             notice = TRUE;
159         }
160     }
161
162     creature_ptr->oppose_cold = v;
163
164     if (!notice)
165         return FALSE;
166     creature_ptr->redraw |= (PR_STATUS);
167
168     if (disturb_state)
169         disturb(creature_ptr, FALSE, FALSE);
170     handle_stuff(creature_ptr);
171     return TRUE;
172 }
173
174 /*!
175  * @brief 一時的毒耐性の継続時間をセットする / Set "oppose_pois", notice observable changes
176  * @param v 継続時間
177  * @param do_dec 現在の継続時間より長い値のみ上書きする
178  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
179  */
180 bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
181 {
182     bool notice = FALSE;
183     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
184     if ((creature_ptr->pclass == CLASS_NINJA) && (creature_ptr->lev > 44))
185         v = 1;
186     if (creature_ptr->is_dead)
187         return FALSE;
188
189     if (v) {
190         if (creature_ptr->oppose_pois && !do_dec) {
191             if (creature_ptr->oppose_pois > v)
192                 return FALSE;
193         } else if (!is_oppose_pois(creature_ptr)) {
194             msg_print(_("毒への耐性がついた気がする!", "You feel resistant to poison!"));
195             notice = TRUE;
196         }
197     } else {
198         if (creature_ptr->oppose_pois && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) {
199             msg_print(_("毒への耐性が薄れた気がする。", "You feel less resistant to poison."));
200             notice = TRUE;
201         }
202     }
203
204     creature_ptr->oppose_pois = v;
205     if (!notice)
206         return FALSE;
207     creature_ptr->redraw |= (PR_STATUS);
208
209     if (disturb_state)
210         disturb(creature_ptr, FALSE, FALSE);
211     handle_stuff(creature_ptr);
212     return TRUE;
213 }
214
215 bool is_oppose_acid(player_type *creature_ptr)
216 {
217     return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
218 }
219
220 bool is_oppose_elec(player_type *creature_ptr)
221 {
222     return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
223 }
224
225 bool is_oppose_fire(player_type *creature_ptr)
226 {
227     return creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU ||
228         (creature_ptr->mimic_form == MIMIC_DEMON) || (is_specific_player_race(creature_ptr, RACE_BALROG) && creature_ptr->lev > 44));
229 }
230
231 bool is_oppose_cold(player_type *creature_ptr)
232 {
233     return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
234 }
235
236 bool is_oppose_pois(player_type *creature_ptr)
237 {
238     return creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU ||
239         (creature_ptr->pclass == CLASS_NINJA && creature_ptr->lev > 44) );
240 }