OSDN Git Service

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