OSDN Git Service

Reworded English description for the sniper's SP_DOUBLE ability.
[hengband/hengband.git] / src / mutation / mutation-investor-remover.c
1 #include "mutation/mutation-investor-remover.h"
2 #include "core/player-update-types.h"
3 #include "core/stuff-handler.h"
4 #include "mutation/gain-mutation-switcher.h"
5 #include "mutation/lose-mutation-switcher.h"
6 #include "mutation/mutation-flag-types.h"
7 #include "mutation/mutation-util.h"
8 #include "mutation/mutation-calculator.h" // todo calc_mutant_regenerate_mod() が相互依存している、後で消す.
9 #include "player-info/avatar.h"
10 #include "view/display-messages.h"
11
12 static void sweep_gain_mutation(player_type *creature_ptr, glm_type *gm_ptr)
13 {
14     int attempts_left = 20;
15     if (gm_ptr->choose_mut)
16         attempts_left = 1;
17
18     while (attempts_left--) {
19         switch_gain_mutation(creature_ptr, gm_ptr);
20         if ((gm_ptr->muta_class != NULL) && (gm_ptr->muta_which != 0) && ((*gm_ptr->muta_class & gm_ptr->muta_which) == 0))
21             gm_ptr->muta_chosen = TRUE;
22
23         if (gm_ptr->muta_chosen)
24             break;
25     }
26 }
27
28 static void race_dependent_mutation(player_type *creature_ptr, glm_type *gm_ptr)
29 {
30     if (gm_ptr->choose_mut != 0)
31         return;
32
33     if (creature_ptr->prace == RACE_VAMPIRE && !(creature_ptr->muta1 & MUT1_HYPN_GAZE) && (randint1(10) < 7)) {
34         gm_ptr->muta_class = &(creature_ptr->muta1);
35         gm_ptr->muta_which = MUT1_HYPN_GAZE;
36         gm_ptr->muta_desc = _("眼が幻惑的になった...", "Your eyes look mesmerizing...");
37         return;
38     }
39
40     if (creature_ptr->prace == RACE_IMP && !(creature_ptr->muta2 & MUT2_HORNS) && (randint1(10) < 7)) {
41         gm_ptr->muta_class = &(creature_ptr->muta2);
42         gm_ptr->muta_which = MUT2_HORNS;
43         gm_ptr->muta_desc = _("角が額から生えてきた!", "Horns pop forth into your forehead!");
44         return;
45     }
46
47     if (creature_ptr->prace == RACE_YEEK && !(creature_ptr->muta1 & MUT1_SHRIEK) && (randint1(10) < 7)) {
48         gm_ptr->muta_class = &(creature_ptr->muta1);
49         gm_ptr->muta_which = MUT1_SHRIEK;
50         gm_ptr->muta_desc = _("声質がかなり強くなった。", "Your vocal cords get much tougher.");
51         return;
52     }
53
54     if (creature_ptr->prace == RACE_BEASTMAN && !(creature_ptr->muta1 & MUT1_POLYMORPH) && (randint1(10) < 2)) {
55         gm_ptr->muta_class = &(creature_ptr->muta1);
56         gm_ptr->muta_which = MUT1_POLYMORPH;
57         gm_ptr->muta_desc = _("あなたの肉体は変化できるようになった、", "Your body seems mutable.");
58         return;
59     }
60
61     if (creature_ptr->prace == RACE_MIND_FLAYER && !(creature_ptr->muta2 & MUT2_TENTACLES) && (randint1(10) < 7)) {
62         gm_ptr->muta_class = &(creature_ptr->muta2);
63         gm_ptr->muta_which = MUT2_TENTACLES;
64         gm_ptr->muta_desc = _("邪悪な触手が口の周りに生えた。", "Evil-looking tentacles sprout from your mouth.");
65     }
66 }
67
68 static void neutralize_base_status(player_type *creature_ptr, glm_type *gm_ptr)
69 {
70     if (gm_ptr->muta_which == MUT3_PUNY) {
71         if (creature_ptr->muta3 & MUT3_HYPER_STR) {
72             msg_print(_("あなたはもう超人的に強くはない!", "You no longer feel super-strong!"));
73             creature_ptr->muta3 &= ~(MUT3_HYPER_STR);
74         }
75
76         return;
77     }
78
79     if (gm_ptr->muta_which == MUT3_HYPER_STR) {
80         if (creature_ptr->muta3 & MUT3_PUNY) {
81             msg_print(_("あなたはもう虚弱ではない!", "You no longer feel puny!"));
82             creature_ptr->muta3 &= ~(MUT3_PUNY);
83         }
84
85         return;
86     }
87
88     if (gm_ptr->muta_which == MUT3_MORONIC) {
89         if (creature_ptr->muta3 & MUT3_HYPER_INT) {
90             msg_print(_("あなたの脳はもう生体コンピュータではない。", "Your brain is no longer a living computer."));
91             creature_ptr->muta3 &= ~(MUT3_HYPER_INT);
92         }
93
94         return;
95     }
96
97     if (gm_ptr->muta_which == MUT3_HYPER_INT) {
98         if (creature_ptr->muta3 & MUT3_MORONIC) {
99             msg_print(_("あなたはもう精神薄弱ではない。", "You are no longer moronic."));
100             creature_ptr->muta3 &= ~(MUT3_MORONIC);
101         }
102
103         return;
104     }
105
106     if (gm_ptr->muta_which == MUT3_IRON_SKIN) {
107         if (creature_ptr->muta3 & MUT3_SCALES) {
108             msg_print(_("鱗がなくなった。", "You lose your scales."));
109             creature_ptr->muta3 &= ~(MUT3_SCALES);
110         }
111
112         if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
113             msg_print(_("肉体が腐乱しなくなった。", "Your flesh rots no longer."));
114             creature_ptr->muta3 &= ~(MUT3_FLESH_ROT);
115         }
116
117         if (creature_ptr->muta3 & MUT3_WART_SKIN) {
118             msg_print(_("肌のイボイボがなくなった。", "You lose your warts."));
119             creature_ptr->muta3 &= ~(MUT3_WART_SKIN);
120         }
121
122         return;
123     }
124
125     if (gm_ptr->muta_which == MUT3_WART_SKIN || gm_ptr->muta_which == MUT3_SCALES || gm_ptr->muta_which == MUT3_FLESH_ROT) {
126         if (creature_ptr->muta3 & MUT3_IRON_SKIN) {
127             msg_print(_("あなたの肌はもう鉄ではない。", "Your skin is no longer made of steel."));
128             creature_ptr->muta3 &= ~(MUT3_IRON_SKIN);
129         }
130
131         return;
132     }
133
134     if (gm_ptr->muta_which == MUT3_FEARLESS) {
135         if (creature_ptr->muta2 & MUT2_COWARDICE) {
136             msg_print(_("臆病でなくなった。", "You are no longer cowardly."));
137             creature_ptr->muta2 &= ~(MUT2_COWARDICE);
138         }
139
140         return;
141     }
142
143     if (gm_ptr->muta_which == MUT3_FLESH_ROT) {
144         if (creature_ptr->muta3 & MUT3_REGEN) {
145             msg_print(_("急速に回復しなくなった。", "You stop regenerating."));
146             creature_ptr->muta3 &= ~(MUT3_REGEN);
147         }
148
149         return;
150     }
151
152     if (gm_ptr->muta_which == MUT3_REGEN) {
153         if (creature_ptr->muta3 & MUT3_FLESH_ROT) {
154             msg_print(_("肉体が腐乱しなくなった。", "Your flesh stops rotting."));
155             creature_ptr->muta3 &= ~(MUT3_FLESH_ROT);
156         }
157
158         return;
159     }
160
161     if (gm_ptr->muta_which == MUT3_LIMBER) {
162         if (creature_ptr->muta3 & MUT3_ARTHRITIS) {
163             msg_print(_("関節が痛くなくなった。", "Your joints stop hurting."));
164             creature_ptr->muta3 &= ~(MUT3_ARTHRITIS);
165         }
166
167         return;
168     }
169
170     if (gm_ptr->muta_which == MUT3_ARTHRITIS) {
171         if (creature_ptr->muta3 & MUT3_LIMBER) {
172             msg_print(_("あなたはしなやかでなくなった。", "You no longer feel limber."));
173             creature_ptr->muta3 &= ~(MUT3_LIMBER);
174         }
175
176         return;
177     }
178 }
179
180 static void neutralize_other_status(player_type *creature_ptr, glm_type *gm_ptr)
181 {
182     if (gm_ptr->muta_which == MUT2_COWARDICE) {
183         if (creature_ptr->muta3 & MUT3_FEARLESS) {
184             msg_print(_("恐れ知らずでなくなった。", "You no longer feel fearless."));
185             creature_ptr->muta3 &= ~(MUT3_FEARLESS);
186         }
187     }
188
189     if (gm_ptr->muta_which == MUT2_BEAK) {
190         if (creature_ptr->muta2 & MUT2_TRUNK) {
191             msg_print(_("あなたの鼻はもう象の鼻のようではなくなった。", "Your nose is no longer elephantine."));
192             creature_ptr->muta2 &= ~(MUT2_TRUNK);
193         }
194     }
195
196     if (gm_ptr->muta_which == MUT2_TRUNK) {
197         if (creature_ptr->muta2 & MUT2_BEAK) {
198             msg_print(_("硬いクチバシがなくなった。", "You no longer have a hard beak."));
199             creature_ptr->muta2 &= ~(MUT2_BEAK);
200         }
201     }
202 }
203
204 /*!
205  * @brief プレイヤーに突然変異を与える
206  * @param choose_mut 与えたい突然変異のID、0ならばランダムに選択
207  * @return なし
208  */
209 bool gain_mutation(player_type *creature_ptr, MUTATION_IDX choose_mut)
210 {
211     glm_type tmp_gm;
212     glm_type *gm_ptr = initialize_glm_type(&tmp_gm, choose_mut);
213     sweep_gain_mutation(creature_ptr, gm_ptr);
214     if (!gm_ptr->muta_chosen) {
215         msg_print(_("普通になった気がする。", "You feel normal."));
216         return FALSE;
217     }
218
219     chg_virtue(creature_ptr, V_CHANCE, 1);
220     race_dependent_mutation(creature_ptr, gm_ptr);
221     msg_print(_("突然変異した!", "You mutate!"));
222     msg_print(gm_ptr->muta_desc);
223     if (gm_ptr->muta_class != NULL)
224         *gm_ptr->muta_class |= gm_ptr->muta_which;
225
226     if (gm_ptr->muta_class == &(creature_ptr->muta3)) {
227         neutralize_base_status(creature_ptr, gm_ptr);
228     } else if (gm_ptr->muta_class == &(creature_ptr->muta2)) {
229         neutralize_other_status(creature_ptr, gm_ptr);
230     }
231
232     creature_ptr->mutant_regenerate_mod = calc_mutant_regenerate_mod(creature_ptr);
233     creature_ptr->update |= PU_BONUS;
234     handle_stuff(creature_ptr);
235     return TRUE;
236 }
237
238 static void sweep_lose_mutation(player_type *creature_ptr, glm_type *glm_ptr)
239 {
240     int attempts_left = 20;
241     if (glm_ptr->choose_mut)
242         attempts_left = 1;
243
244     while (attempts_left--) {
245         switch_lose_mutation(creature_ptr, glm_ptr);
246         if (glm_ptr->muta_class && glm_ptr->muta_which) {
247             if (*(glm_ptr->muta_class) & glm_ptr->muta_which) {
248                 glm_ptr->muta_chosen = TRUE;
249             }
250         }
251
252         if (glm_ptr->muta_chosen)
253             break;
254     }
255 }
256
257 /*!
258  * @brief プレイヤーから突然変異を取り除く
259  * @param choose_mut 取り除きたい突然変異のID、0ならばランダムに消去
260  * @return なし
261  */
262 bool lose_mutation(player_type *creature_ptr, MUTATION_IDX choose_mut)
263 {
264     glm_type tmp_glm;
265     glm_type *glm_ptr = initialize_glm_type(&tmp_glm, choose_mut);
266     sweep_lose_mutation(creature_ptr, glm_ptr);
267     if (!glm_ptr->muta_chosen)
268         return FALSE;
269
270     msg_print(glm_ptr->muta_desc);
271     if (glm_ptr->muta_class != NULL)
272         *glm_ptr->muta_class &= ~(glm_ptr->muta_which);
273
274     creature_ptr->update |= PU_BONUS;
275     handle_stuff(creature_ptr);
276     creature_ptr->mutant_regenerate_mod = calc_mutant_regenerate_mod(creature_ptr);
277     return TRUE;
278 }
279
280 void lose_all_mutations(player_type *creature_ptr)
281 {
282     if (creature_ptr->muta1 || creature_ptr->muta2 || creature_ptr->muta3) {
283         chg_virtue(creature_ptr, V_CHANCE, -5);
284         msg_print(_("全ての突然変異が治った。", "You are cured of all mutations."));
285         creature_ptr->muta1 = creature_ptr->muta2 = creature_ptr->muta3 = 0;
286         creature_ptr->update |= PU_BONUS;
287         handle_stuff(creature_ptr);
288         creature_ptr->mutant_regenerate_mod = calc_mutant_regenerate_mod(creature_ptr);
289     }
290 }