OSDN Git Service

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