OSDN Git Service

[Refactor] #40399 Changed object_is_aware(), object_is_tried() and object_is_known...
[hengband/hengband.git] / src / cmd-item / cmd-smith.c
1 /*!
2  * @brief プレイヤーの鍛冶コマンド実装
3  * @date 2019/03/11
4  * @author deskull
5  */
6
7 #include "cmd-item/cmd-smith.h"
8 #include "util/util.h"
9 #include "term/gameterm.h"
10 #include "object/item-use-flags.h"
11 #include "object/object2.h"
12 #include "object/object-flavor.h"
13 #include "object/object-hook.h"
14 #include "object/object-ego.h"
15 #include "object/special-object-flags.h"
16 #include "player/player-status.h"
17 #include "cmd/cmd-basic.h"
18 #include "autopick/autopick.h"
19 #include "inventory/player-inventory.h"
20 #include "object/tr-types.h"
21 #include "object/trc-types.h"
22 #include "view/display-main-window.h"
23
24 /*!
25  * エッセンス情報の構造体 / A structure for smithing
26  */
27 typedef struct {
28         int add;       /* TR flag number or special essence id */
29         concptr add_name; /* Name of this ability */
30         ESSENCE_IDX type;      /* Menu number */
31         int essence;   /* Index for carrying essences */
32         int value;     /* Needed value to add this ability */
33 } essence_type;
34
35
36 /*!
37  * エッセンス情報テーブル Smithing type data for Weapon smith
38  */
39 #ifdef JP
40 static essence_type essence_info[] =
41 {
42         {TR_STR, "腕力", 4, TR_STR, 20},
43         {TR_INT, "知能", 4, TR_INT, 20},
44         {TR_WIS, "賢さ", 4, TR_WIS, 20},
45         {TR_DEX, "器用さ", 4, TR_DEX, 20},
46         {TR_CON, "耐久力", 4, TR_CON, 20},
47         {TR_CHR, "魅力", 4, TR_CHR, 20},
48         {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
49         {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
50         {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
51         {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
52         {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
53         {TR_SPEED, "スピード", 4, TR_SPEED, 12},
54         {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
55         {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
56         {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
57         {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
58         {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
59         {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
60         {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
61         {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
62         {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
63         {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
64         {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
65         {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
66         {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
67         {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
68         {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
69         {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
70         {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
71         {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
72         {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
73         {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
74         {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
75         {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
76         {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
77         {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
78         {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
79         {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
80         {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
81         {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
82         {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
83         {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
84         {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
85         {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
86         {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
87         {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
88         {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
89         {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
90         {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
91         {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
92         {TR_SH_FIRE, "", 0, -2, 0},
93         {TR_SH_ELEC, "", 0, -2, 0},
94         {TR_SH_COLD, "", 0, -2, 0},
95         {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
96         {TR_WARNING, "警告", 3, TR_WARNING, 20},
97         {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
98         {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
99         {TR_LITE_2, "", 0, -2, 0},
100         {TR_LITE_3, "", 0, -2, 0},
101         {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
102         {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
103         {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
104         {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
105         {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
106
107         {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
108         {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
109         {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
110         {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
111         {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
112         {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
113         {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
114         {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
115         {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
116         {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
117         {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
118         {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
119         {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
120         {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
121         {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
122         {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
123         {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
124         {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
125
126         {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
127         {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
128         {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
129         {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
130         {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
131         {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
132         {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
133         {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
134
135         {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
136         {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
137         {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
138         {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
139         {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
140         {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
141         {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
142         {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
143         {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
144         {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
145         {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
146         {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
147
148         {-1, NULL, 0, -1, 0}
149 };
150 #else
151 static essence_type essence_info[] =
152 {
153         {TR_STR, "strength", 4, TR_STR, 20},
154         {TR_INT, "intelligence", 4, TR_INT, 20},
155         {TR_WIS, "wisdom", 4, TR_WIS, 20},
156         {TR_DEX, "dexterity", 4, TR_DEX, 20},
157         {TR_CON, "constitution", 4, TR_CON, 20},
158         {TR_CHR, "charisma", 4, TR_CHR, 20},
159         {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
160         {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
161         {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
162         {TR_INFRA, "infravision", 4, TR_INFRA, 15},
163         {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
164         {TR_SPEED, "speed", 4, TR_SPEED, 12},
165         {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
166         {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
167         {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
168         {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
169         {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
170         {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
171         {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
172         {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
173         {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
174         {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
175         {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
176         {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
177         {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
178         {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
179         {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
180         {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
181         {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
182         {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
183         {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
184         {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
185         {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
186         {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
187         {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
188         {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
189         {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
190         {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
191         {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
192         {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
193         {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
194         {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
195         {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
196         {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
197         {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
198         {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
199         {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
200         {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
201         {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
202         {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
203         {TR_SH_FIRE, "", 0, -2, 0},
204         {TR_SH_ELEC, "", 0, -2, 0},
205         {TR_SH_COLD, "", 0, -2, 0},
206         {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
207         {TR_WARNING, "warning", 3, TR_WARNING, 20},
208         {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
209         {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
210         {TR_LITE_2, "", 0, -2, 0},
211         {TR_LITE_3, "", 0, -2, 0},
212         {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
213         {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
214         {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
215         {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
216         {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
217
218         {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
219         {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
220         {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
221         {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
222         {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
223         {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
224         {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
225         {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
226         {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
227         {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
228         {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
229         {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
230         {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
231         {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
232         {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
233         {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
234         {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
235         {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
236
237         {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
238         {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
239         {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
240         {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
241         {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
242         {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
243         {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
244         {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
245
246         {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
247         {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
248         {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
249         {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
250         {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
251         {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
252         {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
253         {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
254         {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
255         {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
256         {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
257         {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
258
259         {-1, NULL, 0, -1, 0}
260 };
261 #endif
262
263
264 /*!
265  * エッセンス名テーブル / Essense names for Weapon smith
266  */
267 #ifdef JP
268 concptr essence_name[] =
269 {
270         "腕力",
271         "知能",
272         "賢さ",
273         "器用さ",
274         "耐久力",
275         "魅力",
276         "魔力支配",
277         "",
278         "隠密",
279         "探索",
280         "赤外線視力",
281         "採掘",
282         "スピード",
283         "追加攻撃",
284         "カオス攻撃",
285         "吸血攻撃",
286         "動物倍打",
287         "邪悪倍打",
288         "不死倍打",
289         "悪魔倍打",
290         "オーク倍打",
291         "トロル倍打",
292         "巨人倍打",
293         "竜倍打",
294         "",
295         "",
296         "地震",
297         "毒殺",
298         "溶解",
299         "電撃",
300         "焼棄",
301         "凍結",
302         "能力維持",
303         "",
304         "",
305         "",
306         "",
307         "",
308         "",
309         "",
310         "免疫",
311         "",
312         "",
313         "",
314         "",
315         "反射",
316         "麻痺知らず",
317         "経験値維持",
318         "耐酸",
319         "耐電撃",
320         "耐火炎",
321         "耐冷気",
322         "耐毒",
323         "耐恐怖",
324         "耐閃光",
325         "耐暗黒",
326         "耐盲目",
327         "耐混乱",
328         "耐轟音",
329         "耐破片",
330         "耐地獄",
331         "耐因果混乱",
332         "耐カオス",
333         "耐劣化",
334         "",
335         "",
336         "人間倍打",
337         "",
338         "",
339         "反魔法",
340         "",
341         "",
342         "警告",
343         "",
344         "",
345         "",
346         "浮遊",
347         "永久光源",
348         "可視透明",
349         "テレパシー",
350         "遅消化",
351         "急速回復",
352         "",
353         "",
354         "",
355         "",
356         "",
357         "",
358         "",
359         "",
360         "テレポート",
361         "",
362         "",
363         "攻撃",
364         "防御",
365
366         NULL
367 };
368
369 #else
370
371 concptr essence_name[] =
372 {
373         "strength",
374         "intelligen.",
375         "wisdom",
376         "dexterity",
377         "constitut.",
378         "charisma",
379         "magic mast.",
380         "",
381         "stealth",
382         "serching",
383         "infravision",
384         "digging",
385         "speed",
386         "extra atk",
387         "chaos brand",
388         "vampiric",
389         "slay animal",
390         "slay evil",
391         "slay undead",
392         "slay demon",
393         "slay orc",
394         "slay troll",
395         "slay giant",
396         "slay dragon",
397         "",
398         "",
399         "quake",
400         "pois. brand",
401         "acid brand",
402         "elec. brand",
403         "fire brand",
404         "cold brand",
405         "sustain",
406         "",
407         "",
408         "",
409         "",
410         "",
411         "",
412         "",
413         "immunity",
414         "",
415         "",
416         "",
417         "",
418         "reflection",
419         "free action",
420         "hold exp",
421         "res. acid",
422         "res. elec.",
423         "res. fire",
424         "res. cold",
425         "res. poison",
426         "res. fear",
427         "res. light",
428         "res. dark",
429         "res. blind",
430         "res.confuse",
431         "res. sound",
432         "res. shard",
433         "res. nether",
434         "res. nexus",
435         "res. chaos",
436         "res. disen.",
437         "",
438         "",
439         "slay human",
440         "",
441         "",
442         "anti magic",
443         "",
444         "",
445         "warning",
446         "",
447         "",
448         "",
449         "levitation",
450         "perm. light",
451         "see invis.",
452         "telepathy",
453         "slow dige.",
454         "regen.",
455         "",
456         "",
457         "",
458         "",
459         "",
460         "",
461         "",
462         "",
463         "teleport",
464         "",
465         "",
466         "weapon enc.",
467         "armor enc.",
468
469         NULL
470 };
471 #endif
472
473 static concptr const kaji_tips[5] =
474 {
475 #ifdef JP
476         "現在持っているエッセンスの一覧を表示する。",
477         "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
478         "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
479         "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
480         "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
481 #else
482         "Display essences you have.",
483         "Extract essences from an item. The item become non magical.",
484         "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
485         "Add essences to an item. The improved items or artifacts cannot be reimprove.",
486         "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
487 #endif
488 };
489
490
491 /*!
492  * @brief 所持しているエッセンス一覧を表示する
493  * @return なし
494  */
495 static void display_essence(player_type *creature_ptr)
496 {
497         int i, num = 0;
498
499         screen_save();
500         for (i = 1; i < 22; i++)
501         {
502                 prt("", i, 0);
503         }
504         prt(_("エッセンス   個数     エッセンス   個数     エッセンス   個数",
505                 "Essence      Num      Essence      Num      Essence      Num "), 1, 8);
506         for (i = 0; essence_name[i]; i++)
507         {
508                 if (!essence_name[i][0]) continue;
509                 prt(format("%-11s %5d", essence_name[i], creature_ptr->magic_num1[i]), 2 + num % 21, 8 + num / 21 * 22);
510                 num++;
511         }
512         prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
513         (void)inkey();
514         screen_load();
515         return;
516 }
517
518 /*!
519  * @brief エッセンスの抽出処理
520  * @param creature_ptr プレーヤーへの参照ポインタ
521  * @return なし
522  */
523 static void drain_essence(player_type *creature_ptr)
524 {
525         int drain_value[sizeof(creature_ptr->magic_num1) / sizeof(s32b)];
526         size_t i;
527         OBJECT_IDX item;
528         int dec = 4;
529         bool observe = FALSE;
530         int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
531         TIME_EFFECT old_timeout;
532         BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
533         object_type *o_ptr;
534         concptr q, s;
535         POSITION iy, ix;
536         byte marked;
537         ITEM_NUMBER number;
538         OBJECT_IDX next_o_idx;
539         WEIGHT weight;
540
541         for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
542                 drain_value[i] = 0;
543
544         item_tester_hook = object_is_weapon_armour_ammo;
545
546         q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
547         s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
548
549         o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
550         if (!o_ptr) return;
551
552         if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
553         {
554                 GAME_TEXT o_name[MAX_NLEN];
555                 object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
556                 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
557         }
558
559         take_turn(creature_ptr, 100);
560
561         object_flags(o_ptr, old_flgs);
562         if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
563         if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
564         if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
565         if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
566         if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
567         if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
568         if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
569         if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
570         if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
571
572         old_to_a = o_ptr->to_a;
573         old_ac = o_ptr->ac;
574         old_to_h = o_ptr->to_h;
575         old_to_d = o_ptr->to_d;
576         old_ds = o_ptr->ds;
577         old_dd = o_ptr->dd;
578         old_pval = o_ptr->pval;
579         old_name2 = o_ptr->name2;
580         old_timeout = o_ptr->timeout;
581         if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
582         if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
583         if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
584         if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
585         if (have_flag(old_flgs, TR_NO_TELE)) dec--;
586         if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
587         if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
588         if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
589         if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
590         if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
591         if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
592         if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
593         if (have_flag(old_flgs, TR_COWARDICE)) dec--;
594         if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
595         if (have_flag(old_flgs, TR_LOW_AC)) dec--;
596         if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
597         if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
598         if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
599         if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
600
601         iy = o_ptr->iy;
602         ix = o_ptr->ix;
603         next_o_idx = o_ptr->next_o_idx;
604         marked = o_ptr->marked;
605         weight = o_ptr->weight;
606         number = o_ptr->number;
607
608         object_prep(o_ptr, o_ptr->k_idx);
609
610         o_ptr->iy = iy;
611         o_ptr->ix = ix;
612         o_ptr->next_o_idx = next_o_idx;
613         o_ptr->marked = marked;
614         o_ptr->number = number;
615         if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
616         if (item >= 0) creature_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight * number);
617         o_ptr->ident |= (IDENT_FULL_KNOWN);
618         object_aware(creature_ptr, o_ptr);
619         object_known(o_ptr);
620
621         object_flags(o_ptr, new_flgs);
622
623         for (i = 0; essence_info[i].add_name; i++)
624         {
625                 essence_type *es_ptr = &essence_info[i];
626                 PARAMETER_VALUE pval = 0;
627
628                 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
629                         pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
630
631                 if (es_ptr->add < TR_FLAG_MAX &&
632                         (!have_flag(new_flgs, es_ptr->add) || pval) &&
633                         have_flag(old_flgs, es_ptr->add))
634                 {
635                         if (pval)
636                         {
637                                 drain_value[es_ptr->essence] += 10 * pval;
638                         }
639                         else if (es_ptr->essence != -2)
640                         {
641                                 drain_value[es_ptr->essence] += 10;
642                         }
643                         else if (es_ptr->add == TR_SH_FIRE)
644                         {
645                                 drain_value[TR_BRAND_FIRE] += 10;
646                                 drain_value[TR_RES_FIRE] += 10;
647                         }
648                         else if (es_ptr->add == TR_SH_ELEC)
649                         {
650                                 drain_value[TR_BRAND_ELEC] += 10;
651                                 drain_value[TR_RES_ELEC] += 10;
652                         }
653                         else if (es_ptr->add == TR_SH_COLD)
654                         {
655                                 drain_value[TR_BRAND_COLD] += 10;
656                                 drain_value[TR_RES_COLD] += 10;
657                         }
658                         else if (es_ptr->add == TR_LITE_2)
659                         {
660                                 drain_value[TR_LITE_1] += 20;
661                         }
662                         else if (es_ptr->add == TR_LITE_3)
663                         {
664                                 drain_value[TR_LITE_1] += 30;
665                         }
666                 }
667         }
668
669         if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
670         {
671                 drain_value[TR_INT] += 5;
672                 drain_value[TR_WIS] += 5;
673         }
674         if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
675         {
676                 drain_value[TR_BRAND_POIS] += 5;
677                 drain_value[TR_BRAND_ACID] += 5;
678                 drain_value[TR_BRAND_ELEC] += 5;
679                 drain_value[TR_BRAND_FIRE] += 5;
680                 drain_value[TR_BRAND_COLD] += 5;
681         }
682         if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
683         {
684                 drain_value[TR_INT] += 10;
685         }
686         if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
687         {
688                 drain_value[TR_STR] += 10;
689         }
690         if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
691         {
692                 drain_value[TR_DEX] += 10;
693         }
694         if (old_name2 == EGO_2WEAPON)
695         {
696                 drain_value[TR_DEX] += 20;
697         }
698         if (object_is_weapon_ammo(o_ptr))
699         {
700                 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds - o_ptr->ds) * 10;
701
702                 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd - o_ptr->dd) * 10;
703         }
704         if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h - o_ptr->to_h) * 10;
705         if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d - o_ptr->to_d) * 10;
706         if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac - o_ptr->ac) * 10;
707         if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a - o_ptr->to_a) * 10;
708
709         for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
710         {
711                 drain_value[i] *= number;
712                 drain_value[i] = drain_value[i] * dec / 4;
713                 drain_value[i] = MAX(drain_value[i], 0);
714                 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
715                 if (drain_value[i])
716                 {
717                         observe = TRUE;
718                 }
719         }
720         if (!observe)
721         {
722                 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
723         }
724         else
725         {
726                 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
727
728                 for (i = 0; essence_name[i]; i++)
729                 {
730                         if (!essence_name[i][0]) continue;
731                         if (!drain_value[i]) continue;
732
733                         creature_ptr->magic_num1[i] += drain_value[i];
734                         creature_ptr->magic_num1[i] = MIN(20000, creature_ptr->magic_num1[i]);
735                         msg_print(NULL);
736                         msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
737                 }
738         }
739
740         /* Apply autodestroy/inscription to the drained item */
741         autopick_alter_item(creature_ptr, item, TRUE);
742         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
743         creature_ptr->window |= (PW_INVEN);
744 }
745
746 /*!
747  * @brief 付加するエッセンスの大別を選択する
748  * @return 選んだエッセンスの大別ID
749  */
750 static COMMAND_CODE choose_essence(void)
751 {
752         COMMAND_CODE mode = 0;
753         char choice;
754         COMMAND_CODE menu_line = (use_menu ? 1 : 0);
755
756 #ifdef JP
757         concptr menu_name[] = {
758                 "武器属性",
759                 "耐性",
760                 "能力",
761                 "数値",
762                 "スレイ",
763                 "ESP",
764                 "その他"
765         };
766 #else
767         concptr menu_name[] = {
768                 "Brand weapon",
769                 "Resistance",
770                 "Ability",
771                 "Magic number",
772                 "Slay",
773                 "ESP",
774                 "Others"
775         };
776 #endif
777         const COMMAND_CODE mode_max = 7;
778
779         if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
780                 return mode;
781         mode = 0;
782         if (use_menu)
783         {
784                 screen_save();
785
786                 while (!mode)
787                 {
788                         int i;
789                         for (i = 0; i < mode_max; i++)
790 #ifdef JP
791                                 prt(format(" %s %s", (menu_line == 1 + i) ? "》" : "  ", menu_name[i]), 2 + i, 14);
792                         prt("どの種類のエッセンス付加を行いますか?", 0, 0);
793 #else
794                                 prt(format(" %s %s", (menu_line == 1 + i) ? "> " : "  ", menu_name[i]), 2 + i, 14);
795                         prt("Choose from menu.", 0, 0);
796 #endif
797
798                         choice = inkey();
799                         switch (choice)
800                         {
801                         case ESCAPE:
802                         case 'z':
803                         case 'Z':
804                                 screen_load();
805                                 return 0;
806                         case '2':
807                         case 'j':
808                         case 'J':
809                                 menu_line++;
810                                 break;
811                         case '8':
812                         case 'k':
813                         case 'K':
814                                 menu_line += mode_max - 1;
815                                 break;
816                         case '\r':
817                         case '\n':
818                         case 'x':
819                         case 'X':
820                                 mode = menu_line;
821                                 break;
822                         }
823                         if (menu_line > mode_max) menu_line -= mode_max;
824                 }
825                 screen_load();
826         }
827         else
828         {
829                 screen_save();
830                 while (!mode)
831                 {
832                         int i;
833
834                         for (i = 0; i < mode_max; i++)
835                                 prt(format("  %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
836
837                         if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
838                         {
839                                 screen_load();
840                                 return 0;
841                         }
842
843                         if (isupper(choice)) choice = (char)tolower(choice);
844
845                         if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
846                                 mode = (int)choice - 'a' + 1;
847                 }
848                 screen_load();
849         }
850
851         repeat_push(mode);
852         return mode;
853 }
854
855 /*!
856  * @brief エッセンスを実際に付加する
857  * @param mode エッセンスの大別ID
858  * @return なし
859  */
860 static void add_essence(player_type *creature_ptr, ESSENCE_IDX mode)
861 {
862         OBJECT_IDX item;
863         int max_num = 0;
864         COMMAND_CODE i;
865         bool flag, redraw;
866         char choice;
867         concptr            q, s;
868         object_type *o_ptr;
869         int ask = TRUE;
870         char out_val[160];
871         int num[22];
872         GAME_TEXT o_name[MAX_NLEN];
873         int use_essence;
874         essence_type *es_ptr;
875         bool able[22] = { 0 };
876         tval_type tval = 0;
877         int menu_line = (use_menu ? 1 : 0);
878
879         for (i = 0; essence_info[i].add_name; i++)
880         {
881                 es_ptr = &essence_info[i];
882
883                 if (es_ptr->type != mode) continue;
884                 num[max_num++] = i;
885         }
886
887         if (!repeat_pull(&i) || i < 0 || i >= max_num)
888         {
889                 flag = FALSE;
890                 redraw = FALSE;
891
892                 (void)strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
893                 if (use_menu) screen_save();
894
895                 choice = (always_show_list || use_menu) ? ESCAPE : 1;
896                 while (!flag)
897                 {
898                         if (choice == ESCAPE) choice = ' ';
899                         else if (!get_com(out_val, &choice, FALSE))break;
900
901                         if (use_menu && choice != ' ')
902                         {
903                                 switch (choice)
904                                 {
905                                 case '0':
906                                 {
907                                         screen_load();
908                                         return;
909                                 }
910
911                                 case '8':
912                                 case 'k':
913                                 case 'K':
914                                 {
915                                         menu_line += (max_num - 1);
916                                         break;
917                                 }
918
919                                 case '2':
920                                 case 'j':
921                                 case 'J':
922                                 {
923                                         menu_line++;
924                                         break;
925                                 }
926
927                                 case '4':
928                                 case 'h':
929                                 case 'H':
930                                 {
931                                         menu_line = 1;
932                                         break;
933                                 }
934                                 case '6':
935                                 case 'l':
936                                 case 'L':
937                                 {
938                                         menu_line = max_num;
939                                         break;
940                                 }
941
942                                 case 'x':
943                                 case 'X':
944                                 case '\r':
945                                 case '\n':
946                                 {
947                                         i = menu_line - 1;
948                                         ask = FALSE;
949                                         break;
950                                 }
951                                 }
952                                 if (menu_line > max_num) menu_line -= max_num;
953                         }
954                         /* Request redraw */
955                         if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
956                         {
957                                 /* Show the list */
958                                 if (!redraw || use_menu)
959                                 {
960                                         byte y, x = 10;
961                                         int ctr;
962                                         char dummy[80], dummy2[80];
963                                         byte col;
964
965                                         strcpy(dummy, "");
966                                         redraw = TRUE;
967                                         if (!use_menu) screen_save();
968
969                                         for (y = 1; y < 24; y++)
970                                                 prt("", y, x);
971
972                                         /* Print header(s) */
973 #ifdef JP
974                                         prt(format("   %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
975
976 #else
977                                         prt(format("   %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
978 #endif
979                                         /* Print list */
980                                         for (ctr = 0; ctr < max_num; ctr++)
981                                         {
982                                                 es_ptr = &essence_info[num[ctr]];
983
984                                                 if (use_menu)
985                                                 {
986                                                         if (ctr == (menu_line - 1))
987                                                                 strcpy(dummy, _("》 ", ">  "));
988                                                         else strcpy(dummy, "   ");
989
990                                                 }
991                                                 /* letter/number for power selection */
992                                                 else
993                                                 {
994                                                         sprintf(dummy, "%c) ", I2A(ctr));
995                                                 }
996
997                                                 strcat(dummy, es_ptr->add_name);
998
999                                                 col = TERM_WHITE;
1000                                                 able[ctr] = TRUE;
1001
1002                                                 if (es_ptr->essence != -1)
1003                                                 {
1004                                                         strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
1005                                                         if (creature_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
1006                                                 }
1007                                                 else
1008                                                 {
1009                                                         switch (es_ptr->add)
1010                                                         {
1011                                                         case ESSENCE_SH_FIRE:
1012                                                                 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
1013                                                                 if (creature_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
1014                                                                 if (creature_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
1015                                                                 break;
1016                                                         case ESSENCE_SH_ELEC:
1017                                                                 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
1018                                                                 if (creature_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
1019                                                                 if (creature_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
1020                                                                 break;
1021                                                         case ESSENCE_SH_COLD:
1022                                                                 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
1023                                                                 if (creature_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
1024                                                                 if (creature_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
1025                                                                 break;
1026                                                         case ESSENCE_RESISTANCE:
1027                                                                 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
1028                                                                 if (creature_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
1029                                                                 if (creature_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
1030                                                                 if (creature_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
1031                                                                 if (creature_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
1032                                                                 break;
1033                                                         case ESSENCE_SUSTAIN:
1034                                                                 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
1035                                                                 if (creature_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
1036                                                                 if (creature_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
1037                                                                 if (creature_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
1038                                                                 if (creature_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
1039                                                                 break;
1040                                                         }
1041                                                 }
1042
1043                                                 if (!able[ctr]) col = TERM_RED;
1044
1045                                                 if (es_ptr->essence != -1)
1046                                                 {
1047                                                         sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)creature_ptr->magic_num1[es_ptr->essence]);
1048                                                 }
1049                                                 else
1050                                                 {
1051                                                         sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
1052                                                 }
1053
1054                                                 c_prt(col, dummy2, ctr + 2, x);
1055                                         }
1056                                 }
1057
1058                                 /* Hide the list */
1059                                 else
1060                                 {
1061                                         /* Hide list */
1062                                         redraw = FALSE;
1063                                         screen_load();
1064                                 }
1065
1066                                 /* Redo asking */
1067                                 continue;
1068                         }
1069
1070                         if (!use_menu)
1071                         {
1072                                 /* Note verify */
1073                                 ask = (isupper(choice));
1074
1075                                 /* Lowercase */
1076                                 if (ask) choice = (char)tolower(choice);
1077
1078                                 /* Extract request */
1079                                 i = (islower(choice) ? A2I(choice) : -1);
1080                         }
1081
1082                         /* Totally Illegal */
1083                         if ((i < 0) || (i >= max_num) || !able[i])
1084                         {
1085                                 bell();
1086                                 continue;
1087                         }
1088
1089                         /* Verify it */
1090                         if (ask)
1091                         {
1092                                 char tmp_val[160];
1093
1094                                 /* Prompt */
1095                                 (void)strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
1096
1097                                 /* Belay that order */
1098                                 if (!get_check(tmp_val)) continue;
1099                         }
1100
1101                         /* Stop the loop */
1102                         flag = TRUE;
1103                 }
1104                 if (redraw) screen_load();
1105
1106                 if (!flag) return;
1107
1108                 repeat_push(i);
1109         }
1110         es_ptr = &essence_info[num[i]];
1111
1112         if (es_ptr->add == ESSENCE_SLAY_GLOVE)
1113                 tval = TV_GLOVES;
1114         else if (mode == 1 || mode == 5)
1115                 item_tester_hook = item_tester_hook_melee_ammo;
1116         else if (es_ptr->add == ESSENCE_ATTACK)
1117                 item_tester_hook = object_allow_enchant_weapon;
1118         else if (es_ptr->add == ESSENCE_AC)
1119                 item_tester_hook = object_is_armour;
1120         else
1121                 item_tester_hook = object_is_weapon_armour_ammo;
1122
1123         q = _("どのアイテムを改良しますか?", "Improve which item? ");
1124         s = _("改良できるアイテムがありません。", "You have nothing to improve.");
1125
1126         o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), tval);
1127         if (!o_ptr) return;
1128
1129         if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
1130         {
1131                 msg_print(_("そのアイテムはこれ以上改良できない。", "This item can not be improved any further."));
1132                 return;
1133         }
1134
1135         object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1136
1137         use_essence = es_ptr->value;
1138         if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence + 9) / 10;
1139         if (o_ptr->number > 1)
1140         {
1141                 use_essence *= o_ptr->number;
1142                 msg_format(_("%d個あるのでエッセンスは%d必要です。", "For %d items, it will take %d essences."), o_ptr->number, use_essence);
1143         }
1144
1145         if (es_ptr->essence != -1)
1146         {
1147                 if (creature_ptr->magic_num1[es_ptr->essence] < use_essence)
1148                 {
1149                         msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1150                         return;
1151                 }
1152                 if (is_pval_flag(es_ptr->add))
1153                 {
1154                         if (o_ptr->pval < 0)
1155                         {
1156                                 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
1157                                 return;
1158                         }
1159                         else if (es_ptr->add == TR_BLOWS)
1160                         {
1161                                 if (o_ptr->pval > 1)
1162                                 {
1163                                         if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
1164                                 }
1165
1166                                 o_ptr->pval = 1;
1167                                 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1168                         }
1169                         else if (o_ptr->pval > 0)
1170                         {
1171                                 use_essence *= o_ptr->pval;
1172                                 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1173                         }
1174                         else
1175                         {
1176                                 char tmp[80];
1177                                 char tmp_val[160];
1178                                 PARAMETER_VALUE pval;
1179                                 PARAMETER_VALUE limit = MIN(5, creature_ptr->magic_num1[es_ptr->essence] / es_ptr->value);
1180
1181                                 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
1182                                 strcpy(tmp_val, "1");
1183
1184                                 if (!get_string(tmp, tmp_val, 1)) return;
1185                                 pval = (PARAMETER_VALUE)atoi(tmp_val);
1186                                 if (pval > limit) pval = limit;
1187                                 else if (pval < 1) pval = 1;
1188                                 o_ptr->pval += pval;
1189                                 use_essence *= pval;
1190                                 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1191                         }
1192
1193                         if (creature_ptr->magic_num1[es_ptr->essence] < use_essence)
1194                         {
1195                                 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1196                                 return;
1197                         }
1198                 }
1199                 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
1200                 {
1201                         char tmp_val[160];
1202                         int val;
1203                         HIT_PROB get_to_h;
1204                         HIT_POINT get_to_d;
1205
1206                         strcpy(tmp_val, "1");
1207                         if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), creature_ptr->lev / 7 + 3), tmp_val, 2)) return;
1208                         val = atoi(tmp_val);
1209                         if (val > creature_ptr->lev / 7 + 3) val = creature_ptr->lev / 7 + 3;
1210                         else if (val < 1) val = 1;
1211                         use_essence *= val;
1212                         msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1213                         if (creature_ptr->magic_num1[es_ptr->essence] < use_essence)
1214                         {
1215                                 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1216                                 return;
1217                         }
1218                         get_to_h = ((val + 1) / 2 + randint0(val / 2 + 1));
1219                         get_to_d = ((val + 1) / 2 + randint0(val / 2 + 1));
1220                         o_ptr->xtra4 = (get_to_h << 8) + get_to_d;
1221                         o_ptr->to_h += get_to_h;
1222                         o_ptr->to_d += get_to_d;
1223                 }
1224                 creature_ptr->magic_num1[es_ptr->essence] -= use_essence;
1225                 if (es_ptr->add == ESSENCE_ATTACK)
1226                 {
1227                         if ((o_ptr->to_h >= creature_ptr->lev / 5 + 5) && (o_ptr->to_d >= creature_ptr->lev / 5 + 5))
1228                         {
1229                                 msg_print(_("改良に失敗した。", "You failed to enchant."));
1230                                 take_turn(creature_ptr, 100);
1231                                 return;
1232                         }
1233                         else
1234                         {
1235                                 if (o_ptr->to_h < creature_ptr->lev / 5 + 5) o_ptr->to_h++;
1236                                 if (o_ptr->to_d < creature_ptr->lev / 5 + 5) o_ptr->to_d++;
1237                         }
1238                 }
1239                 else if (es_ptr->add == ESSENCE_AC)
1240                 {
1241                         if (o_ptr->to_a >= creature_ptr->lev / 5 + 5)
1242                         {
1243                                 msg_print(_("改良に失敗した。", "You failed to enchant."));
1244                                 take_turn(creature_ptr, 100);
1245                                 return;
1246                         }
1247                         else
1248                         {
1249                                 if (o_ptr->to_a < creature_ptr->lev / 5 + 5) o_ptr->to_a++;
1250                         }
1251                 }
1252                 else
1253                 {
1254                         o_ptr->xtra3 = es_ptr->add + 1;
1255                 }
1256         }
1257         else
1258         {
1259                 bool success = TRUE;
1260
1261                 switch (es_ptr->add)
1262                 {
1263                 case ESSENCE_SH_FIRE:
1264                         if ((creature_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (creature_ptr->magic_num1[TR_RES_FIRE] < use_essence))
1265                         {
1266                                 success = FALSE;
1267                                 break;
1268                         }
1269                         creature_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
1270                         creature_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
1271                         break;
1272                 case ESSENCE_SH_ELEC:
1273                         if ((creature_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (creature_ptr->magic_num1[TR_RES_ELEC] < use_essence))
1274                         {
1275                                 success = FALSE;
1276                                 break;
1277                         }
1278                         creature_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
1279                         creature_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
1280                         break;
1281                 case ESSENCE_SH_COLD:
1282                         if ((creature_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (creature_ptr->magic_num1[TR_RES_COLD] < use_essence))
1283                         {
1284                                 success = FALSE;
1285                                 break;
1286                         }
1287                         creature_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
1288                         creature_ptr->magic_num1[TR_RES_COLD] -= use_essence;
1289                         break;
1290                 case ESSENCE_RESISTANCE:
1291                 case ESSENCE_SUSTAIN:
1292                         if ((creature_ptr->magic_num1[TR_RES_ACID] < use_essence) || (creature_ptr->magic_num1[TR_RES_ELEC] < use_essence) || (creature_ptr->magic_num1[TR_RES_FIRE] < use_essence) || (creature_ptr->magic_num1[TR_RES_COLD] < use_essence))
1293                         {
1294                                 success = FALSE;
1295                                 break;
1296                         }
1297                         creature_ptr->magic_num1[TR_RES_ACID] -= use_essence;
1298                         creature_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
1299                         creature_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
1300                         creature_ptr->magic_num1[TR_RES_COLD] -= use_essence;
1301                         break;
1302                 }
1303                 if (!success)
1304                 {
1305                         msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1306                         return;
1307                 }
1308                 if (es_ptr->add == ESSENCE_SUSTAIN)
1309                 {
1310                         add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
1311                         add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
1312                         add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
1313                         add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
1314                 }
1315                 else
1316                 {
1317                         o_ptr->xtra3 = es_ptr->add + 1;
1318                 }
1319         }
1320
1321         take_turn(creature_ptr, 100);
1322         _(msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name),
1323           msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name));
1324         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
1325         creature_ptr->window |= (PW_INVEN);
1326 }
1327
1328 /*!
1329  * @brief エッセンスを消去する
1330  * @return なし
1331  */
1332 static void erase_essence(player_type *creature_ptr)
1333 {
1334         OBJECT_IDX item;
1335         concptr q, s;
1336         object_type *o_ptr;
1337         GAME_TEXT o_name[MAX_NLEN];
1338         BIT_FLAGS flgs[TR_FLAG_SIZE];
1339
1340         item_tester_hook = object_is_smith;
1341
1342         q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
1343         s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
1344
1345         o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
1346         if (!o_ptr) return;
1347
1348         object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1349         if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
1350
1351         take_turn(creature_ptr, 100);
1352
1353         if (o_ptr->xtra3 == 1 + ESSENCE_SLAY_GLOVE)
1354         {
1355                 o_ptr->to_h -= (o_ptr->xtra4 >> 8);
1356                 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
1357                 o_ptr->xtra4 = 0;
1358                 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
1359                 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
1360         }
1361         o_ptr->xtra3 = 0;
1362         object_flags(o_ptr, flgs);
1363         if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
1364         msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
1365         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
1366         creature_ptr->window |= (PW_INVEN);
1367 }
1368
1369 /*!
1370  * @brief 鍛冶コマンドのメインルーチン
1371  * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
1372  * @return なし
1373  */
1374 void do_cmd_kaji(player_type *creature_ptr, bool only_browse)
1375 {
1376         COMMAND_CODE mode = 0;
1377         char choice;
1378
1379         COMMAND_CODE menu_line = (use_menu ? 1 : 0);
1380
1381         if (!only_browse)
1382         {
1383                 if (cmd_limit_confused(creature_ptr)) return;
1384                 if (cmd_limit_blind(creature_ptr)) return;
1385                 if (cmd_limit_image(creature_ptr)) return;
1386         }
1387
1388         if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
1389         {
1390                 if (only_browse) screen_save();
1391                 do {
1392                         if (!only_browse) screen_save();
1393                         if (use_menu)
1394                         {
1395                                 while (!mode)
1396                                 {
1397 #ifdef JP
1398                                         prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : "  "), 2, 14);
1399                                         prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : "  "), 3, 14);
1400                                         prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : "  "), 4, 14);
1401                                         prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : "  "), 5, 14);
1402                                         prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : "  "), 6, 14);
1403                                         prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
1404 #else
1405                                         prt(format(" %s List essences", (menu_line == 1) ? "> " : "  "), 2, 14);
1406                                         prt(format(" %s Extract essence", (menu_line == 2) ? "> " : "  "), 3, 14);
1407                                         prt(format(" %s Remove essence", (menu_line == 3) ? "> " : "  "), 4, 14);
1408                                         prt(format(" %s Add essence", (menu_line == 4) ? "> " : "  "), 5, 14);
1409                                         prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : "  "), 6, 14);
1410                                         prt(format("Choose command from menu."), 0, 0);
1411 #endif
1412                                         choice = inkey();
1413                                         switch (choice)
1414                                         {
1415                                         case ESCAPE:
1416                                         case 'z':
1417                                         case 'Z':
1418                                                 screen_load();
1419                                                 return;
1420                                         case '2':
1421                                         case 'j':
1422                                         case 'J':
1423                                                 menu_line++;
1424                                                 break;
1425                                         case '8':
1426                                         case 'k':
1427                                         case 'K':
1428                                                 menu_line += 4;
1429                                                 break;
1430                                         case '\r':
1431                                         case '\n':
1432                                         case 'x':
1433                                         case 'X':
1434                                                 mode = menu_line;
1435                                                 break;
1436                                         }
1437                                         if (menu_line > 5) menu_line -= 5;
1438                                 }
1439                         }
1440
1441                         else
1442                         {
1443                                 while (!mode)
1444                                 {
1445                                         prt(_("  a) エッセンス一覧", "  a) List essences"), 2, 14);
1446                                         prt(_("  b) エッセンス抽出", "  b) Extract essence"), 3, 14);
1447                                         prt(_("  c) エッセンス消去", "  c) Remove essence"), 4, 14);
1448                                         prt(_("  d) エッセンス付加", "  d) Add essence"), 5, 14);
1449                                         prt(_("  e) 武器/防具強化", "  e) Enchant weapon/armor"), 6, 14);
1450 #ifdef JP
1451                                         if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
1452 #else
1453                                         if (!get_com("Command :", &choice, TRUE))
1454 #endif
1455                                         {
1456                                                 screen_load();
1457                                                 return;
1458                                         }
1459                                         switch (choice)
1460                                         {
1461                                         case 'A':
1462                                         case 'a':
1463                                                 mode = 1;
1464                                                 break;
1465                                         case 'B':
1466                                         case 'b':
1467                                                 mode = 2;
1468                                                 break;
1469                                         case 'C':
1470                                         case 'c':
1471                                                 mode = 3;
1472                                                 break;
1473                                         case 'D':
1474                                         case 'd':
1475                                                 mode = 4;
1476                                                 break;
1477                                         case 'E':
1478                                         case 'e':
1479                                                 mode = 5;
1480                                                 break;
1481                                         }
1482                                 }
1483                         }
1484
1485                         if (only_browse)
1486                         {
1487                                 char temp[62 * 5];
1488                                 int line, j;
1489
1490                                 /* Clear lines, position cursor  (really should use strlen here) */
1491                                 Term_erase(14, 21, 255);
1492                                 Term_erase(14, 20, 255);
1493                                 Term_erase(14, 19, 255);
1494                                 Term_erase(14, 18, 255);
1495                                 Term_erase(14, 17, 255);
1496                                 Term_erase(14, 16, 255);
1497
1498                                 roff_to_buf(kaji_tips[mode - 1], 62, temp, sizeof(temp));
1499                                 for (j = 0, line = 17; temp[j]; j += (1 + strlen(&temp[j])))
1500                                 {
1501                                         prt(&temp[j], line, 15);
1502                                         line++;
1503                                 }
1504                                 mode = 0;
1505                         }
1506                         if (!only_browse) screen_load();
1507                 } while (only_browse);
1508                 repeat_push(mode);
1509         }
1510         switch (mode)
1511         {
1512         case 1: display_essence(creature_ptr); break;
1513         case 2: drain_essence(creature_ptr); break;
1514         case 3: erase_essence(creature_ptr); break;
1515         case 4:
1516                 mode = choose_essence();
1517                 if (mode == 0)
1518                         break;
1519                 add_essence(creature_ptr, mode);
1520                 break;
1521         case 5: add_essence(creature_ptr, 10); break;
1522         }
1523 }