OSDN Git Service

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