OSDN Git Service

Merge remote-tracking branch 'remotes/origin/For2.2.2-Fix-Hourier' into For2.2.2...
[hengband/hengband.git] / src / status / temporary-resistance.c
1 #include "status/temporary-resistance.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 "view/display-messages.h"
8
9 /*!
10  * @brief 一時的浮遊の継続時間をセットする / Set "tim_levitation", notice observable changes
11  * @param v 継続時間
12  * @param do_dec 現在の継続時間より長い値のみ上書きする
13  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
14  */
15 bool set_tim_levitation(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
16 {
17     bool notice = FALSE;
18     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
19
20     if (creature_ptr->is_dead)
21         return FALSE;
22
23     if (v) {
24         if (creature_ptr->tim_levitation && !do_dec) {
25             if (creature_ptr->tim_levitation > v)
26                 return FALSE;
27         } else if (!creature_ptr->tim_levitation) {
28             msg_print(_("体が宙に浮き始めた。", "You begin to fly!"));
29             notice = TRUE;
30         }
31     } else {
32         if (creature_ptr->tim_levitation) {
33             msg_print(_("もう宙に浮かべなくなった。", "You stop flying."));
34             notice = TRUE;
35         }
36     }
37
38     creature_ptr->tim_levitation = v;
39     creature_ptr->redraw |= (PR_STATUS);
40
41     if (!notice)
42         return FALSE;
43
44     if (disturb_state)
45         disturb(creature_ptr, FALSE, FALSE);
46     creature_ptr->update |= (PU_BONUS);
47     handle_stuff(creature_ptr);
48     return TRUE;
49 }
50
51 bool set_ultimate_res(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
52 {
53     bool notice = FALSE;
54     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
55
56     if (creature_ptr->is_dead)
57         return FALSE;
58
59     if (v) {
60         if (creature_ptr->ult_res && !do_dec) {
61             if (creature_ptr->ult_res > v)
62                 return FALSE;
63         } else if (!creature_ptr->ult_res) {
64             msg_print(_("あらゆることに対して耐性がついた気がする!", "You feel resistant!"));
65             notice = TRUE;
66         }
67     }
68
69     else {
70         if (creature_ptr->ult_res) {
71             msg_print(_("あらゆることに対する耐性が薄れた気がする。", "You feel less resistant"));
72             notice = TRUE;
73         }
74     }
75
76     creature_ptr->ult_res = v;
77     creature_ptr->redraw |= (PR_STATUS);
78
79     if (!notice)
80         return FALSE;
81
82     if (disturb_state)
83         disturb(creature_ptr, FALSE, FALSE);
84     creature_ptr->update |= (PU_BONUS);
85     handle_stuff(creature_ptr);
86
87     return TRUE;
88 }
89
90 bool set_tim_res_nether(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
91 {
92     bool notice = FALSE;
93     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
94
95     if (creature_ptr->is_dead)
96         return FALSE;
97
98     if (v) {
99         if (creature_ptr->tim_res_nether && !do_dec) {
100             if (creature_ptr->tim_res_nether > v)
101                 return FALSE;
102         } else if (!creature_ptr->tim_res_nether) {
103             msg_print(_("地獄の力に対して耐性がついた気がする!", "You feel nether resistant!"));
104             notice = TRUE;
105         }
106     }
107
108     else {
109         if (creature_ptr->tim_res_nether) {
110             msg_print(_("地獄の力に対する耐性が薄れた気がする。", "You feel less nether resistant"));
111             notice = TRUE;
112         }
113     }
114
115     creature_ptr->tim_res_nether = v;
116     creature_ptr->redraw |= (PR_STATUS);
117
118     if (!notice)
119         return FALSE;
120
121     if (disturb_state)
122         disturb(creature_ptr, FALSE, FALSE);
123     creature_ptr->update |= (PU_BONUS);
124     handle_stuff(creature_ptr);
125     return TRUE;
126 }
127
128 bool set_tim_res_time(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
129 {
130     bool notice = FALSE;
131     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
132     if (creature_ptr->is_dead)
133         return FALSE;
134
135     if (v) {
136         if (creature_ptr->tim_res_time && !do_dec) {
137             if (creature_ptr->tim_res_time > v)
138                 return FALSE;
139         } else if (!creature_ptr->tim_res_time) {
140             msg_print(_("時間逆転の力に対して耐性がついた気がする!", "You feel time resistant!"));
141             notice = TRUE;
142         }
143     } else {
144         if (creature_ptr->tim_res_time) {
145             msg_print(_("時間逆転の力に対する耐性が薄れた気がする。", "You feel less time resistant"));
146             notice = TRUE;
147         }
148     }
149
150     creature_ptr->tim_res_time = v;
151     creature_ptr->redraw |= (PR_STATUS);
152     if (!notice)
153         return FALSE;
154
155     if (disturb_state)
156         disturb(creature_ptr, FALSE, FALSE);
157     creature_ptr->update |= (PU_BONUS);
158     handle_stuff(creature_ptr);
159     return TRUE;
160 }