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"
12 * @brief 一時的酸耐性の継続時間をセットする / Set "oppose_acid", notice observable changes
14 * @param do_dec 現在の継続時間より長い値のみ上書きする
15 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
17 bool set_oppose_acid(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
20 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
21 if (creature_ptr->is_dead)
25 if (creature_ptr->oppose_acid && !do_dec) {
26 if (creature_ptr->oppose_acid > v)
28 } else if (!is_oppose_acid(creature_ptr)) {
29 msg_print(_("酸への耐性がついた気がする!", "You feel resistant to acid!"));
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."));
39 creature_ptr->oppose_acid = v;
43 creature_ptr->redraw |= (PR_STATUS);
46 disturb(creature_ptr, FALSE, FALSE);
47 handle_stuff(creature_ptr);
52 * @brief 一時的電撃耐性の継続時間をセットする / Set "oppose_elec", notice observable changes
54 * @param do_dec 現在の継続時間より長い値のみ上書きする
55 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
57 bool set_oppose_elec(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
60 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
62 if (creature_ptr->is_dead)
66 if (creature_ptr->oppose_elec && !do_dec) {
67 if (creature_ptr->oppose_elec > v)
69 } else if (!is_oppose_elec(creature_ptr)) {
70 msg_print(_("電撃への耐性がついた気がする!", "You feel resistant to electricity!"));
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."));
80 creature_ptr->oppose_elec = v;
84 creature_ptr->redraw |= (PR_STATUS);
87 disturb(creature_ptr, FALSE, FALSE);
88 handle_stuff(creature_ptr);
93 * @brief 一時的火炎耐性の継続時間をセットする / Set "oppose_fire", notice observable changes
95 * @param do_dec 現在の継続時間より長い値のみ上書きする
96 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
98 bool set_oppose_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
101 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
102 if (creature_ptr->is_dead)
105 if ((is_specific_player_race(creature_ptr, RACE_BALROG) && (creature_ptr->lev > 44)) || (creature_ptr->mimic_form == MIMIC_DEMON))
108 if (creature_ptr->oppose_fire && !do_dec) {
109 if (creature_ptr->oppose_fire > v)
111 } else if (!is_oppose_fire(creature_ptr)) {
112 msg_print(_("火への耐性がついた気がする!", "You feel resistant to fire!"));
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."));
122 creature_ptr->oppose_fire = v;
126 creature_ptr->redraw |= (PR_STATUS);
129 disturb(creature_ptr, FALSE, FALSE);
130 handle_stuff(creature_ptr);
135 * @brief 一時的冷気耐性の継続時間をセットする / Set "oppose_cold", notice observable changes
137 * @param do_dec 現在の継続時間より長い値のみ上書きする
138 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
140 bool set_oppose_cold(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
143 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
144 if (creature_ptr->is_dead)
148 if (creature_ptr->oppose_cold && !do_dec) {
149 if (creature_ptr->oppose_cold > v)
151 } else if (!is_oppose_cold(creature_ptr)) {
152 msg_print(_("冷気への耐性がついた気がする!", "You feel resistant to cold!"));
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."));
162 creature_ptr->oppose_cold = v;
166 creature_ptr->redraw |= (PR_STATUS);
169 disturb(creature_ptr, FALSE, FALSE);
170 handle_stuff(creature_ptr);
175 * @brief 一時的毒耐性の継続時間をセットする / Set "oppose_pois", notice observable changes
177 * @param do_dec 現在の継続時間より長い値のみ上書きする
178 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
180 bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
183 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
184 if ((creature_ptr->pclass == CLASS_NINJA) && (creature_ptr->lev > 44))
186 if (creature_ptr->is_dead)
190 if (creature_ptr->oppose_pois && !do_dec) {
191 if (creature_ptr->oppose_pois > v)
193 } else if (!is_oppose_pois(creature_ptr)) {
194 msg_print(_("毒への耐性がついた気がする!", "You feel resistant to poison!"));
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."));
204 creature_ptr->oppose_pois = v;
207 creature_ptr->redraw |= (PR_STATUS);
210 disturb(creature_ptr, FALSE, FALSE);
211 handle_stuff(creature_ptr);
215 bool is_oppose_acid(player_type *creature_ptr)
217 return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
220 bool is_oppose_elec(player_type *creature_ptr)
222 return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
225 bool is_oppose_fire(player_type *creature_ptr)
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));
231 bool is_oppose_cold(player_type *creature_ptr)
233 return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
236 bool is_oppose_pois(player_type *creature_ptr)
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) );