OSDN Git Service

Fix the English messages to select an item with the polish shield spell.
[hengbandforosx/hengbandosx.git] / src / spell-realm / spells-craft.c
1 #include "spell-realm/spells-craft.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 "flavor/flavor-describer.h"
7 #include "flavor/object-flavor-types.h"
8 #include "floor/floor-object.h"
9 #include "game-option/disturbance-options.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "io/input-key-acceptor.h"
12 #include "object-enchant/object-ego.h"
13 #include "object-hook/hook-checker.h"
14 #include "object-hook/hook-enchant.h"
15 #include "object/item-use-flags.h"
16 #include "object/object-flags.h"
17 #include "player/attack-defense-types.h"
18 #include "player-info/avatar.h"
19 #include "player/special-defense-types.h"
20 #include "racial/racial-android.h"
21 #include "spell/spells-object.h"
22 #include "sv-definition/sv-protector-types.h"
23 #include "system/object-type-definition.h"
24 #include "term/screen-processor.h"
25 #include "term/term-color-types.h"
26 #include "view/display-messages.h"
27
28 /*!
29  * @brief 一時的元素スレイの継続時間をセットする / Set a temporary elemental brand. Clear all other brands. Print status messages. -LM-
30  * @param attack_type スレイのタイプID
31  * @param v 継続時間
32  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
33  */
34 bool set_ele_attack(player_type *creature_ptr, u32b attack_type, TIME_EFFECT v)
35 {
36     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
37
38     if ((creature_ptr->special_attack & (ATTACK_ACID)) && (attack_type != ATTACK_ACID)) {
39         creature_ptr->special_attack &= ~(ATTACK_ACID);
40         msg_print(_("酸で攻撃できなくなった。", "Your temporary acidic brand fades away."));
41     }
42
43     if ((creature_ptr->special_attack & (ATTACK_ELEC)) && (attack_type != ATTACK_ELEC)) {
44         creature_ptr->special_attack &= ~(ATTACK_ELEC);
45         msg_print(_("電撃で攻撃できなくなった。", "Your temporary electrical brand fades away."));
46     }
47
48     if ((creature_ptr->special_attack & (ATTACK_FIRE)) && (attack_type != ATTACK_FIRE)) {
49         creature_ptr->special_attack &= ~(ATTACK_FIRE);
50         msg_print(_("火炎で攻撃できなくなった。", "Your temporary fiery brand fades away."));
51     }
52
53     if ((creature_ptr->special_attack & (ATTACK_COLD)) && (attack_type != ATTACK_COLD)) {
54         creature_ptr->special_attack &= ~(ATTACK_COLD);
55         msg_print(_("冷気で攻撃できなくなった。", "Your temporary frost brand fades away."));
56     }
57
58     if ((creature_ptr->special_attack & (ATTACK_POIS)) && (attack_type != ATTACK_POIS)) {
59         creature_ptr->special_attack &= ~(ATTACK_POIS);
60         msg_print(_("毒で攻撃できなくなった。", "Your temporary poison brand fades away."));
61     }
62
63     if ((v) && (attack_type)) {
64         creature_ptr->special_attack |= (attack_type);
65         creature_ptr->ele_attack = v;
66 #ifdef JP
67         msg_format("%sで攻撃できるようになった!",
68             ((attack_type == ATTACK_ACID)
69                     ? "酸"
70                     : ((attack_type == ATTACK_ELEC)
71                             ? "電撃"
72                             : ((attack_type == ATTACK_FIRE) ? "火炎"
73                                                             : ((attack_type == ATTACK_COLD) ? "冷気" : ((attack_type == ATTACK_POIS) ? "毒" : "(なし)"))))));
74 #else
75         msg_format("For a while, the blows you deal will %s",
76             ((attack_type == ATTACK_ACID)
77                     ? "melt with acid!"
78                     : ((attack_type == ATTACK_ELEC)
79                             ? "shock your foes!"
80                             : ((attack_type == ATTACK_FIRE)
81                                     ? "burn with fire!"
82                                     : ((attack_type == ATTACK_COLD) ? "chill to the bone!"
83                                                                     : ((attack_type == ATTACK_POIS) ? "poison your enemies!" : "do nothing special."))))));
84 #endif
85     }
86
87     if (disturb_state)
88         disturb(creature_ptr, FALSE, FALSE);
89     creature_ptr->redraw |= (PR_STATUS);
90     creature_ptr->update |= (PU_BONUS);
91     handle_stuff(creature_ptr);
92
93     return TRUE;
94 }
95
96 /*!
97  * @brief 一時的元素免疫の継続時間をセットする / Set a temporary elemental brand.  Clear all other brands.  Print status messages. -LM-
98  * @param immune_type 免疫のタイプID
99  * @param v 継続時間
100  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
101  */
102 bool set_ele_immune(player_type *creature_ptr, u32b immune_type, TIME_EFFECT v)
103 {
104     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
105
106     if ((creature_ptr->special_defense & (DEFENSE_ACID)) && (immune_type != DEFENSE_ACID)) {
107         creature_ptr->special_defense &= ~(DEFENSE_ACID);
108         msg_print(_("酸の攻撃で傷つけられるようになった。。", "You are no longer immune to acid."));
109     }
110
111     if ((creature_ptr->special_defense & (DEFENSE_ELEC)) && (immune_type != DEFENSE_ELEC)) {
112         creature_ptr->special_defense &= ~(DEFENSE_ELEC);
113         msg_print(_("電撃の攻撃で傷つけられるようになった。。", "You are no longer immune to electricity."));
114     }
115
116     if ((creature_ptr->special_defense & (DEFENSE_FIRE)) && (immune_type != DEFENSE_FIRE)) {
117         creature_ptr->special_defense &= ~(DEFENSE_FIRE);
118         msg_print(_("火炎の攻撃で傷つけられるようになった。。", "You are no longer immune to fire."));
119     }
120
121     if ((creature_ptr->special_defense & (DEFENSE_COLD)) && (immune_type != DEFENSE_COLD)) {
122         creature_ptr->special_defense &= ~(DEFENSE_COLD);
123         msg_print(_("冷気の攻撃で傷つけられるようになった。。", "You are no longer immune to cold."));
124     }
125
126     if ((creature_ptr->special_defense & (DEFENSE_POIS)) && (immune_type != DEFENSE_POIS)) {
127         creature_ptr->special_defense &= ~(DEFENSE_POIS);
128         msg_print(_("毒の攻撃で傷つけられるようになった。。", "You are no longer immune to poison."));
129     }
130
131     if ((v) && (immune_type)) {
132         creature_ptr->special_defense |= (immune_type);
133         creature_ptr->ele_immune = v;
134         msg_format(_("%sの攻撃を受けつけなくなった!", "For a while, you are immune to %s"),
135             ((immune_type == DEFENSE_ACID)
136                     ? _("酸", "acid!")
137                     : ((immune_type == DEFENSE_ELEC)
138                             ? _("電撃", "electricity!")
139                             : ((immune_type == DEFENSE_FIRE)
140                                     ? _("火炎", "fire!")
141                                     : ((immune_type == DEFENSE_COLD)
142                                             ? _("冷気", "cold!")
143                                             : ((immune_type == DEFENSE_POIS) ? _("毒", "poison!") : _("(なし)", "nothing special.")))))));
144     }
145
146     if (disturb_state)
147         disturb(creature_ptr, FALSE, FALSE);
148     creature_ptr->redraw |= (PR_STATUS);
149     creature_ptr->update |= (PU_BONUS);
150     handle_stuff(creature_ptr);
151
152     return TRUE;
153 }
154
155 /*
156  * Choose a warrior-mage elemental attack. -LM-
157  */
158 bool choose_ele_attack(player_type *creature_ptr)
159 {
160     if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
161         msg_format(_("武器を持たないと魔法剣は使えない。", "You cannot use temporary branding with no weapon."));
162         return FALSE;
163     }
164
165     screen_save();
166     int num = (creature_ptr->lev - 20) / 5;
167     c_prt(TERM_RED, _("        a) 焼棄", "        a) Fire Brand"), 2, 14);
168
169     if (num >= 2)
170         c_prt(TERM_L_WHITE, _("        b) 凍結", "        b) Cold Brand"), 3, 14);
171     else
172         prt("", 3, 14);
173
174     if (num >= 3)
175         c_prt(TERM_GREEN, _("        c) 毒殺", "        c) Poison Brand"), 4, 14);
176     else
177         prt("", 4, 14);
178
179     if (num >= 4)
180         c_prt(TERM_L_DARK, _("        d) 溶解", "        d) Acid Brand"), 5, 14);
181     else
182         prt("", 5, 14);
183
184     if (num >= 5)
185         c_prt(TERM_BLUE, _("        e) 電撃", "        e) Elec Brand"), 6, 14);
186     else
187         prt("", 6, 14);
188
189     prt("", 7, 14);
190     prt("", 8, 14);
191     prt("", 9, 14);
192
193     prt("", 1, 0);
194     prt(_("        どの元素攻撃をしますか?", "        Choose a temporary elemental brand "), 1, 14);
195
196     char choice = inkey();
197
198     if ((choice == 'a') || (choice == 'A'))
199         set_ele_attack(creature_ptr, ATTACK_FIRE, creature_ptr->lev / 2 + randint1(creature_ptr->lev / 2));
200     else if (((choice == 'b') || (choice == 'B')) && (num >= 2))
201         set_ele_attack(creature_ptr, ATTACK_COLD, creature_ptr->lev / 2 + randint1(creature_ptr->lev / 2));
202     else if (((choice == 'c') || (choice == 'C')) && (num >= 3))
203         set_ele_attack(creature_ptr, ATTACK_POIS, creature_ptr->lev / 2 + randint1(creature_ptr->lev / 2));
204     else if (((choice == 'd') || (choice == 'D')) && (num >= 4))
205         set_ele_attack(creature_ptr, ATTACK_ACID, creature_ptr->lev / 2 + randint1(creature_ptr->lev / 2));
206     else if (((choice == 'e') || (choice == 'E')) && (num >= 5))
207         set_ele_attack(creature_ptr, ATTACK_ELEC, creature_ptr->lev / 2 + randint1(creature_ptr->lev / 2));
208     else {
209         msg_print(_("魔法剣を使うのをやめた。", "You cancel the temporary branding."));
210         screen_load();
211         return FALSE;
212     }
213
214     screen_load();
215     return TRUE;
216 }
217 /*
218  * Choose a elemental immune. -LM-
219  */
220 bool choose_ele_immune(player_type *creature_ptr, TIME_EFFECT immune_turn)
221 {
222     screen_save();
223
224     c_prt(TERM_RED, _("        a) 火炎", "        a) Immunity to fire"), 2, 14);
225     c_prt(TERM_L_WHITE, _("        b) 冷気", "        b) Immunity to cold"), 3, 14);
226     c_prt(TERM_L_DARK, _("        c) 酸", "        c) Immunity to acid"), 4, 14);
227     c_prt(TERM_BLUE, _("        d) 電撃", "        d) Immunity to elec"), 5, 14);
228
229     prt("", 6, 14);
230     prt("", 7, 14);
231     prt("", 8, 14);
232     prt("", 9, 14);
233
234     prt("", 1, 0);
235     prt(_("        どの元素の免疫をつけますか?", "        Choose a temporary elemental immunity "), 1, 14);
236
237     char choice = inkey();
238
239     if ((choice == 'a') || (choice == 'A'))
240         set_ele_immune(creature_ptr, DEFENSE_FIRE, immune_turn);
241     else if ((choice == 'b') || (choice == 'B'))
242         set_ele_immune(creature_ptr, DEFENSE_COLD, immune_turn);
243     else if ((choice == 'c') || (choice == 'C'))
244         set_ele_immune(creature_ptr, DEFENSE_ACID, immune_turn);
245     else if ((choice == 'd') || (choice == 'D'))
246         set_ele_immune(creature_ptr, DEFENSE_ELEC, immune_turn);
247     else {
248         msg_print(_("免疫を付けるのをやめた。", "You cancel the temporary immunity."));
249         screen_load();
250         return FALSE;
251     }
252
253     screen_load();
254     return TRUE;
255 }
256
257 /*!
258  * @brief 盾磨き処理 /
259  * pulish shield
260  * @return ターン消費を要する処理を行ったならばTRUEを返す
261  */
262 bool pulish_shield(player_type *caster_ptr)
263 {
264     concptr q = _("どの盾を磨きますか?", "Polish which shield? ");
265     concptr s = _("磨く盾がありません。", "You have no shield to polish.");
266
267     OBJECT_IDX item;
268     object_type *o_ptr = choose_object(caster_ptr, &item, q, s, USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT, TV_SHIELD);
269     if (o_ptr == NULL)
270         return FALSE;
271
272     GAME_TEXT o_name[MAX_NLEN];
273     describe_flavor(caster_ptr, o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY);
274     BIT_FLAGS flgs[TR_FLAG_SIZE];
275     object_flags(caster_ptr, o_ptr, flgs);
276
277     bool is_pulish_successful = o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr);
278     is_pulish_successful &= !object_is_cursed(o_ptr);
279     is_pulish_successful &= (o_ptr->sval != SV_MIRROR_SHIELD);
280     if (is_pulish_successful) {
281 #ifdef JP
282         msg_format("%sは輝いた!", o_name);
283 #else
284         msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
285 #endif
286         o_ptr->name2 = EGO_REFLECTION;
287         enchant(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOAC);
288         o_ptr->discount = 99;
289         chg_virtue(caster_ptr, V_ENCHANT, 2);
290         return TRUE;
291     }
292
293     if (flush_failure)
294         flush();
295
296     msg_print(_("失敗した。", "Failed."));
297     chg_virtue(caster_ptr, V_ENCHANT, -2);
298     calc_android_exp(caster_ptr);
299     return FALSE;
300 }