OSDN Git Service

Merge remote-tracking branch 'remotes/origin/feature/Refactoring-Hourier' into For2...
[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  * @param creature_ptr プレーヤーへの参照ポインタ
515  * @return なし
516  */
517 static void drain_essence(player_type *creature_ptr)
518 {
519         int drain_value[sizeof(creature_ptr->magic_num1) / sizeof(s32b)];
520         int i;
521         OBJECT_IDX item;
522         int dec = 4;
523         bool observe = FALSE;
524         int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
525         TIME_EFFECT old_timeout;
526         BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
527         object_type *o_ptr;
528         concptr q, s;
529         POSITION iy, ix;
530         byte_hack marked;
531         ITEM_NUMBER number;
532         OBJECT_IDX next_o_idx;
533         WEIGHT weight;
534
535         for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
536                 drain_value[i] = 0;
537
538         item_tester_hook = object_is_weapon_armour_ammo;
539
540         q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
541         s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
542
543         o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
544         if (!o_ptr) return;
545
546         if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
547         {
548                 GAME_TEXT o_name[MAX_NLEN];
549                 object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
550                 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
551         }
552
553         take_turn(creature_ptr, 100);
554
555         object_flags(o_ptr, old_flgs);
556         if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
557         if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
558         if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
559         if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
560         if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
561         if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
562         if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
563         if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
564         if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
565
566         old_to_a = o_ptr->to_a;
567         old_ac = o_ptr->ac;
568         old_to_h = o_ptr->to_h;
569         old_to_d = o_ptr->to_d;
570         old_ds = o_ptr->ds;
571         old_dd = o_ptr->dd;
572         old_pval = o_ptr->pval;
573         old_name2 = o_ptr->name2;
574         old_timeout = o_ptr->timeout;
575         if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
576         if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
577         if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
578         if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
579         if (have_flag(old_flgs, TR_NO_TELE)) dec--;
580         if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
581         if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
582         if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
583         if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
584         if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
585         if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
586         if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
587         if (have_flag(old_flgs, TR_COWARDICE)) dec--;
588         if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
589         if (have_flag(old_flgs, TR_LOW_AC)) dec--;
590         if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
591         if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
592         if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
593         if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
594
595         iy = o_ptr->iy;
596         ix = o_ptr->ix;
597         next_o_idx = o_ptr->next_o_idx;
598         marked = o_ptr->marked;
599         weight = o_ptr->weight;
600         number = o_ptr->number;
601
602         object_prep(o_ptr, o_ptr->k_idx);
603
604         o_ptr->iy = iy;
605         o_ptr->ix = ix;
606         o_ptr->next_o_idx = next_o_idx;
607         o_ptr->marked = marked;
608         o_ptr->number = number;
609         if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
610         if (item >= 0) creature_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight * number);
611         o_ptr->ident |= (IDENT_MENTAL);
612         object_aware(creature_ptr, o_ptr);
613         object_known(o_ptr);
614
615         object_flags(o_ptr, new_flgs);
616
617         for (i = 0; essence_info[i].add_name; i++)
618         {
619                 essence_type *es_ptr = &essence_info[i];
620                 PARAMETER_VALUE pval = 0;
621
622                 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
623                         pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
624
625                 if (es_ptr->add < TR_FLAG_MAX &&
626                         (!have_flag(new_flgs, es_ptr->add) || pval) &&
627                         have_flag(old_flgs, es_ptr->add))
628                 {
629                         if (pval)
630                         {
631                                 drain_value[es_ptr->essence] += 10 * pval;
632                         }
633                         else if (es_ptr->essence != -2)
634                         {
635                                 drain_value[es_ptr->essence] += 10;
636                         }
637                         else if (es_ptr->add == TR_SH_FIRE)
638                         {
639                                 drain_value[TR_BRAND_FIRE] += 10;
640                                 drain_value[TR_RES_FIRE] += 10;
641                         }
642                         else if (es_ptr->add == TR_SH_ELEC)
643                         {
644                                 drain_value[TR_BRAND_ELEC] += 10;
645                                 drain_value[TR_RES_ELEC] += 10;
646                         }
647                         else if (es_ptr->add == TR_SH_COLD)
648                         {
649                                 drain_value[TR_BRAND_COLD] += 10;
650                                 drain_value[TR_RES_COLD] += 10;
651                         }
652                         else if (es_ptr->add == TR_LITE_2)
653                         {
654                                 drain_value[TR_LITE_1] += 20;
655                         }
656                         else if (es_ptr->add == TR_LITE_3)
657                         {
658                                 drain_value[TR_LITE_1] += 30;
659                         }
660                 }
661         }
662
663         if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
664         {
665                 drain_value[TR_INT] += 5;
666                 drain_value[TR_WIS] += 5;
667         }
668         if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
669         {
670                 drain_value[TR_BRAND_POIS] += 5;
671                 drain_value[TR_BRAND_ACID] += 5;
672                 drain_value[TR_BRAND_ELEC] += 5;
673                 drain_value[TR_BRAND_FIRE] += 5;
674                 drain_value[TR_BRAND_COLD] += 5;
675         }
676         if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
677         {
678                 drain_value[TR_INT] += 10;
679         }
680         if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
681         {
682                 drain_value[TR_STR] += 10;
683         }
684         if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
685         {
686                 drain_value[TR_DEX] += 10;
687         }
688         if (old_name2 == EGO_2WEAPON)
689         {
690                 drain_value[TR_DEX] += 20;
691         }
692         if (object_is_weapon_ammo(o_ptr))
693         {
694                 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds - o_ptr->ds) * 10;
695
696                 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd - o_ptr->dd) * 10;
697         }
698         if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h - o_ptr->to_h) * 10;
699         if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d - o_ptr->to_d) * 10;
700         if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac - o_ptr->ac) * 10;
701         if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a - o_ptr->to_a) * 10;
702
703         for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
704         {
705                 drain_value[i] *= number;
706                 drain_value[i] = drain_value[i] * dec / 4;
707                 drain_value[i] = MAX(drain_value[i], 0);
708                 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
709                 if (drain_value[i])
710                 {
711                         observe = TRUE;
712                 }
713         }
714         if (!observe)
715         {
716                 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
717         }
718         else
719         {
720                 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
721
722                 for (i = 0; essence_name[i]; i++)
723                 {
724                         if (!essence_name[i][0]) continue;
725                         if (!drain_value[i]) continue;
726
727                         creature_ptr->magic_num1[i] += drain_value[i];
728                         creature_ptr->magic_num1[i] = MIN(20000, creature_ptr->magic_num1[i]);
729                         msg_print(NULL);
730                         msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
731                 }
732         }
733
734         /* Apply autodestroy/inscription to the drained item */
735         autopick_alter_item(creature_ptr, item, TRUE);
736         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
737         creature_ptr->window |= (PW_INVEN);
738 }
739
740 /*!
741  * @brief 付加するエッセンスの大別を選択する
742  * @return 選んだエッセンスの大別ID
743  */
744 static COMMAND_CODE choose_essence(void)
745 {
746         COMMAND_CODE mode = 0;
747         char choice;
748         COMMAND_CODE menu_line = (use_menu ? 1 : 0);
749
750 #ifdef JP
751         concptr menu_name[] = {
752                 "武器属性",
753                 "耐性",
754                 "能力",
755                 "数値",
756                 "スレイ",
757                 "ESP",
758                 "その他"
759         };
760 #else
761         concptr menu_name[] = {
762                 "Brand weapon",
763                 "Resistance",
764                 "Ability",
765                 "Magic number",
766                 "Slay",
767                 "ESP",
768                 "Others"
769         };
770 #endif
771         const COMMAND_CODE mode_max = 7;
772
773         if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
774                 return mode;
775         mode = 0;
776         if (use_menu)
777         {
778                 screen_save();
779
780                 while (!mode)
781                 {
782                         int i;
783                         for (i = 0; i < mode_max; i++)
784 #ifdef JP
785                                 prt(format(" %s %s", (menu_line == 1 + i) ? "》" : "  ", menu_name[i]), 2 + i, 14);
786                         prt("どの種類のエッセンス付加を行いますか?", 0, 0);
787 #else
788                                 prt(format(" %s %s", (menu_line == 1 + i) ? "> " : "  ", menu_name[i]), 2 + i, 14);
789                         prt("Choose from menu.", 0, 0);
790 #endif
791
792                         choice = inkey();
793                         switch (choice)
794                         {
795                         case ESCAPE:
796                         case 'z':
797                         case 'Z':
798                                 screen_load();
799                                 return 0;
800                         case '2':
801                         case 'j':
802                         case 'J':
803                                 menu_line++;
804                                 break;
805                         case '8':
806                         case 'k':
807                         case 'K':
808                                 menu_line += mode_max - 1;
809                                 break;
810                         case '\r':
811                         case '\n':
812                         case 'x':
813                         case 'X':
814                                 mode = menu_line;
815                                 break;
816                         }
817                         if (menu_line > mode_max) menu_line -= mode_max;
818                 }
819                 screen_load();
820         }
821         else
822         {
823                 screen_save();
824                 while (!mode)
825                 {
826                         int i;
827
828                         for (i = 0; i < mode_max; i++)
829                                 prt(format("  %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
830
831                         if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
832                         {
833                                 screen_load();
834                                 return 0;
835                         }
836
837                         if (isupper(choice)) choice = (char)tolower(choice);
838
839                         if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
840                                 mode = (int)choice - 'a' + 1;
841                 }
842                 screen_load();
843         }
844
845         repeat_push(mode);
846         return mode;
847 }
848
849 /*!
850  * @brief エッセンスを実際に付加する
851  * @param mode エッセンスの大別ID
852  * @return なし
853  */
854 static void add_essence(player_type *creature_ptr, ESSENCE_IDX mode)
855 {
856         OBJECT_IDX item;
857         int max_num = 0;
858         COMMAND_CODE i;
859         bool flag, redraw;
860         char choice;
861         concptr            q, s;
862         object_type *o_ptr;
863         int ask = TRUE;
864         char out_val[160];
865         int num[22];
866         GAME_TEXT o_name[MAX_NLEN];
867         int use_essence;
868         essence_type *es_ptr;
869         bool able[22] = { 0 };
870         OBJECT_TYPE_VALUE tval = 0;
871         int menu_line = (use_menu ? 1 : 0);
872
873         for (i = 0; essence_info[i].add_name; i++)
874         {
875                 es_ptr = &essence_info[i];
876
877                 if (es_ptr->type != mode) continue;
878                 num[max_num++] = i;
879         }
880
881         if (!repeat_pull(&i) || i < 0 || i >= max_num)
882         {
883                 flag = FALSE;
884                 redraw = FALSE;
885
886                 (void)strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
887                 if (use_menu) screen_save();
888
889                 choice = (always_show_list || use_menu) ? ESCAPE : 1;
890                 while (!flag)
891                 {
892                         if (choice == ESCAPE) choice = ' ';
893                         else if (!get_com(out_val, &choice, FALSE))break;
894
895                         if (use_menu && choice != ' ')
896                         {
897                                 switch (choice)
898                                 {
899                                 case '0':
900                                 {
901                                         screen_load();
902                                         return;
903                                 }
904
905                                 case '8':
906                                 case 'k':
907                                 case 'K':
908                                 {
909                                         menu_line += (max_num - 1);
910                                         break;
911                                 }
912
913                                 case '2':
914                                 case 'j':
915                                 case 'J':
916                                 {
917                                         menu_line++;
918                                         break;
919                                 }
920
921                                 case '4':
922                                 case 'h':
923                                 case 'H':
924                                 {
925                                         menu_line = 1;
926                                         break;
927                                 }
928                                 case '6':
929                                 case 'l':
930                                 case 'L':
931                                 {
932                                         menu_line = max_num;
933                                         break;
934                                 }
935
936                                 case 'x':
937                                 case 'X':
938                                 case '\r':
939                                 case '\n':
940                                 {
941                                         i = menu_line - 1;
942                                         ask = FALSE;
943                                         break;
944                                 }
945                                 }
946                                 if (menu_line > max_num) menu_line -= max_num;
947                         }
948                         /* Request redraw */
949                         if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
950                         {
951                                 /* Show the list */
952                                 if (!redraw || use_menu)
953                                 {
954                                         byte y, x = 10;
955                                         int ctr;
956                                         char dummy[80], dummy2[80];
957                                         byte col;
958
959                                         strcpy(dummy, "");
960                                         redraw = TRUE;
961                                         if (!use_menu) screen_save();
962
963                                         for (y = 1; y < 24; y++)
964                                                 prt("", y, x);
965
966                                         /* Print header(s) */
967 #ifdef JP
968                                         prt(format("   %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
969
970 #else
971                                         prt(format("   %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
972 #endif
973                                         /* Print list */
974                                         for (ctr = 0; ctr < max_num; ctr++)
975                                         {
976                                                 es_ptr = &essence_info[num[ctr]];
977
978                                                 if (use_menu)
979                                                 {
980                                                         if (ctr == (menu_line - 1))
981                                                                 strcpy(dummy, _("》 ", ">  "));
982                                                         else strcpy(dummy, "   ");
983
984                                                 }
985                                                 /* letter/number for power selection */
986                                                 else
987                                                 {
988                                                         sprintf(dummy, "%c) ", I2A(ctr));
989                                                 }
990
991                                                 strcat(dummy, es_ptr->add_name);
992
993                                                 col = TERM_WHITE;
994                                                 able[ctr] = TRUE;
995
996                                                 if (es_ptr->essence != -1)
997                                                 {
998                                                         strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
999                                                         if (creature_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
1000                                                 }
1001                                                 else
1002                                                 {
1003                                                         switch (es_ptr->add)
1004                                                         {
1005                                                         case ESSENCE_SH_FIRE:
1006                                                                 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
1007                                                                 if (creature_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
1008                                                                 if (creature_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
1009                                                                 break;
1010                                                         case ESSENCE_SH_ELEC:
1011                                                                 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
1012                                                                 if (creature_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
1013                                                                 if (creature_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
1014                                                                 break;
1015                                                         case ESSENCE_SH_COLD:
1016                                                                 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
1017                                                                 if (creature_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
1018                                                                 if (creature_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
1019                                                                 break;
1020                                                         case ESSENCE_RESISTANCE:
1021                                                                 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
1022                                                                 if (creature_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
1023                                                                 if (creature_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
1024                                                                 if (creature_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
1025                                                                 if (creature_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
1026                                                                 break;
1027                                                         case ESSENCE_SUSTAIN:
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                                                         }
1035                                                 }
1036
1037                                                 if (!able[ctr]) col = TERM_RED;
1038
1039                                                 if (es_ptr->essence != -1)
1040                                                 {
1041                                                         sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)creature_ptr->magic_num1[es_ptr->essence]);
1042                                                 }
1043                                                 else
1044                                                 {
1045                                                         sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
1046                                                 }
1047
1048                                                 c_prt(col, dummy2, ctr + 2, x);
1049                                         }
1050                                 }
1051
1052                                 /* Hide the list */
1053                                 else
1054                                 {
1055                                         /* Hide list */
1056                                         redraw = FALSE;
1057                                         screen_load();
1058                                 }
1059
1060                                 /* Redo asking */
1061                                 continue;
1062                         }
1063
1064                         if (!use_menu)
1065                         {
1066                                 /* Note verify */
1067                                 ask = (isupper(choice));
1068
1069                                 /* Lowercase */
1070                                 if (ask) choice = (char)tolower(choice);
1071
1072                                 /* Extract request */
1073                                 i = (islower(choice) ? A2I(choice) : -1);
1074                         }
1075
1076                         /* Totally Illegal */
1077                         if ((i < 0) || (i >= max_num) || !able[i])
1078                         {
1079                                 bell();
1080                                 continue;
1081                         }
1082
1083                         /* Verify it */
1084                         if (ask)
1085                         {
1086                                 char tmp_val[160];
1087
1088                                 /* Prompt */
1089                                 (void)strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
1090
1091                                 /* Belay that order */
1092                                 if (!get_check(tmp_val)) continue;
1093                         }
1094
1095                         /* Stop the loop */
1096                         flag = TRUE;
1097                 }
1098                 if (redraw) screen_load();
1099
1100                 if (!flag) return;
1101
1102                 repeat_push(i);
1103         }
1104         es_ptr = &essence_info[num[i]];
1105
1106         if (es_ptr->add == ESSENCE_SLAY_GLOVE)
1107                 tval = TV_GLOVES;
1108         else if (mode == 1 || mode == 5)
1109                 item_tester_hook = item_tester_hook_melee_ammo;
1110         else if (es_ptr->add == ESSENCE_ATTACK)
1111                 item_tester_hook = object_allow_enchant_weapon;
1112         else if (es_ptr->add == ESSENCE_AC)
1113                 item_tester_hook = object_is_armour;
1114         else
1115                 item_tester_hook = object_is_weapon_armour_ammo;
1116
1117         q = _("どのアイテムを改良しますか?", "Improve which item? ");
1118         s = _("改良できるアイテムがありません。", "You have nothing to improve.");
1119
1120         o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), tval);
1121         if (!o_ptr) return;
1122
1123         if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
1124         {
1125                 msg_print(_("そのアイテムはこれ以上改良できない。", "This item can not be improved any further."));
1126                 return;
1127         }
1128
1129         object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1130
1131         use_essence = es_ptr->value;
1132         if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence + 9) / 10;
1133         if (o_ptr->number > 1)
1134         {
1135                 use_essence *= o_ptr->number;
1136                 msg_format(_("%d個あるのでエッセンスは%d必要です。", "For %d items, it will take %d essences."), o_ptr->number, use_essence);
1137         }
1138
1139         if (es_ptr->essence != -1)
1140         {
1141                 if (creature_ptr->magic_num1[es_ptr->essence] < use_essence)
1142                 {
1143                         msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1144                         return;
1145                 }
1146                 if (is_pval_flag(es_ptr->add))
1147                 {
1148                         if (o_ptr->pval < 0)
1149                         {
1150                                 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
1151                                 return;
1152                         }
1153                         else if (es_ptr->add == TR_BLOWS)
1154                         {
1155                                 if (o_ptr->pval > 1)
1156                                 {
1157                                         if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
1158                                 }
1159
1160                                 o_ptr->pval = 1;
1161                                 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1162                         }
1163                         else if (o_ptr->pval > 0)
1164                         {
1165                                 use_essence *= o_ptr->pval;
1166                                 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1167                         }
1168                         else
1169                         {
1170                                 char tmp[80];
1171                                 char tmp_val[160];
1172                                 PARAMETER_VALUE pval;
1173                                 PARAMETER_VALUE limit = MIN(5, creature_ptr->magic_num1[es_ptr->essence] / es_ptr->value);
1174
1175                                 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
1176                                 strcpy(tmp_val, "1");
1177
1178                                 if (!get_string(tmp, tmp_val, 1)) return;
1179                                 pval = (PARAMETER_VALUE)atoi(tmp_val);
1180                                 if (pval > limit) pval = limit;
1181                                 else if (pval < 1) pval = 1;
1182                                 o_ptr->pval += pval;
1183                                 use_essence *= pval;
1184                                 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1185                         }
1186
1187                         if (creature_ptr->magic_num1[es_ptr->essence] < use_essence)
1188                         {
1189                                 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1190                                 return;
1191                         }
1192                 }
1193                 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
1194                 {
1195                         char tmp_val[160];
1196                         int val;
1197                         HIT_PROB get_to_h;
1198                         HIT_POINT get_to_d;
1199
1200                         strcpy(tmp_val, "1");
1201                         if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), creature_ptr->lev / 7 + 3), tmp_val, 2)) return;
1202                         val = atoi(tmp_val);
1203                         if (val > creature_ptr->lev / 7 + 3) val = creature_ptr->lev / 7 + 3;
1204                         else if (val < 1) val = 1;
1205                         use_essence *= val;
1206                         msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
1207                         if (creature_ptr->magic_num1[es_ptr->essence] < use_essence)
1208                         {
1209                                 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1210                                 return;
1211                         }
1212                         get_to_h = ((val + 1) / 2 + randint0(val / 2 + 1));
1213                         get_to_d = ((val + 1) / 2 + randint0(val / 2 + 1));
1214                         o_ptr->xtra4 = (get_to_h << 8) + get_to_d;
1215                         o_ptr->to_h += get_to_h;
1216                         o_ptr->to_d += get_to_d;
1217                 }
1218                 creature_ptr->magic_num1[es_ptr->essence] -= use_essence;
1219                 if (es_ptr->add == ESSENCE_ATTACK)
1220                 {
1221                         if ((o_ptr->to_h >= creature_ptr->lev / 5 + 5) && (o_ptr->to_d >= creature_ptr->lev / 5 + 5))
1222                         {
1223                                 msg_print(_("改良に失敗した。", "You failed to enchant."));
1224                                 take_turn(creature_ptr, 100);
1225                                 return;
1226                         }
1227                         else
1228                         {
1229                                 if (o_ptr->to_h < creature_ptr->lev / 5 + 5) o_ptr->to_h++;
1230                                 if (o_ptr->to_d < creature_ptr->lev / 5 + 5) o_ptr->to_d++;
1231                         }
1232                 }
1233                 else if (es_ptr->add == ESSENCE_AC)
1234                 {
1235                         if (o_ptr->to_a >= creature_ptr->lev / 5 + 5)
1236                         {
1237                                 msg_print(_("改良に失敗した。", "You failed to enchant."));
1238                                 take_turn(creature_ptr, 100);
1239                                 return;
1240                         }
1241                         else
1242                         {
1243                                 if (o_ptr->to_a < creature_ptr->lev / 5 + 5) o_ptr->to_a++;
1244                         }
1245                 }
1246                 else
1247                 {
1248                         o_ptr->xtra3 = es_ptr->add + 1;
1249                 }
1250         }
1251         else
1252         {
1253                 bool success = TRUE;
1254
1255                 switch (es_ptr->add)
1256                 {
1257                 case ESSENCE_SH_FIRE:
1258                         if ((creature_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (creature_ptr->magic_num1[TR_RES_FIRE] < use_essence))
1259                         {
1260                                 success = FALSE;
1261                                 break;
1262                         }
1263                         creature_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
1264                         creature_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
1265                         break;
1266                 case ESSENCE_SH_ELEC:
1267                         if ((creature_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (creature_ptr->magic_num1[TR_RES_ELEC] < use_essence))
1268                         {
1269                                 success = FALSE;
1270                                 break;
1271                         }
1272                         creature_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
1273                         creature_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
1274                         break;
1275                 case ESSENCE_SH_COLD:
1276                         if ((creature_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (creature_ptr->magic_num1[TR_RES_COLD] < use_essence))
1277                         {
1278                                 success = FALSE;
1279                                 break;
1280                         }
1281                         creature_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
1282                         creature_ptr->magic_num1[TR_RES_COLD] -= use_essence;
1283                         break;
1284                 case ESSENCE_RESISTANCE:
1285                 case ESSENCE_SUSTAIN:
1286                         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))
1287                         {
1288                                 success = FALSE;
1289                                 break;
1290                         }
1291                         creature_ptr->magic_num1[TR_RES_ACID] -= use_essence;
1292                         creature_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
1293                         creature_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
1294                         creature_ptr->magic_num1[TR_RES_COLD] -= use_essence;
1295                         break;
1296                 }
1297                 if (!success)
1298                 {
1299                         msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
1300                         return;
1301                 }
1302                 if (es_ptr->add == ESSENCE_SUSTAIN)
1303                 {
1304                         add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
1305                         add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
1306                         add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
1307                         add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
1308                 }
1309                 else
1310                 {
1311                         o_ptr->xtra3 = es_ptr->add + 1;
1312                 }
1313         }
1314
1315         take_turn(creature_ptr, 100);
1316
1317 #ifdef JP
1318         msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
1319 #else
1320         msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
1321 #endif
1322         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
1323         creature_ptr->window |= (PW_INVEN);
1324 }
1325
1326 /*!
1327  * @brief エッセンスを消去する
1328  * @return なし
1329  */
1330 static void erase_essence(player_type *creature_ptr)
1331 {
1332         OBJECT_IDX item;
1333         concptr q, s;
1334         object_type *o_ptr;
1335         GAME_TEXT o_name[MAX_NLEN];
1336         BIT_FLAGS flgs[TR_FLAG_SIZE];
1337
1338         item_tester_hook = object_is_smith;
1339
1340         q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
1341         s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
1342
1343         o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
1344         if (!o_ptr) return;
1345
1346         object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1347         if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
1348
1349         take_turn(creature_ptr, 100);
1350
1351         if (o_ptr->xtra3 == 1 + ESSENCE_SLAY_GLOVE)
1352         {
1353                 o_ptr->to_h -= (o_ptr->xtra4 >> 8);
1354                 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
1355                 o_ptr->xtra4 = 0;
1356                 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
1357                 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
1358         }
1359         o_ptr->xtra3 = 0;
1360         object_flags(o_ptr, flgs);
1361         if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
1362         msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
1363         creature_ptr->update |= (PU_COMBINE | PU_REORDER);
1364         creature_ptr->window |= (PW_INVEN);
1365 }
1366
1367 /*!
1368  * @brief 鍛冶コマンドのメインルーチン
1369  * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
1370  * @return なし
1371  */
1372 void do_cmd_kaji(player_type *creature_ptr, bool only_browse)
1373 {
1374         COMMAND_CODE mode = 0;
1375         char choice;
1376
1377         COMMAND_CODE menu_line = (use_menu ? 1 : 0);
1378
1379         if (!only_browse)
1380         {
1381                 if (cmd_limit_confused(creature_ptr)) return;
1382                 if (cmd_limit_blind(creature_ptr)) return;
1383                 if (cmd_limit_image(creature_ptr)) return;
1384         }
1385
1386         if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
1387         {
1388                 if (only_browse) screen_save();
1389                 do {
1390                         if (!only_browse) screen_save();
1391                         if (use_menu)
1392                         {
1393                                 while (!mode)
1394                                 {
1395 #ifdef JP
1396                                         prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : "  "), 2, 14);
1397                                         prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : "  "), 3, 14);
1398                                         prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : "  "), 4, 14);
1399                                         prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : "  "), 5, 14);
1400                                         prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : "  "), 6, 14);
1401                                         prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
1402 #else
1403                                         prt(format(" %s List essences", (menu_line == 1) ? "> " : "  "), 2, 14);
1404                                         prt(format(" %s Extract essence", (menu_line == 2) ? "> " : "  "), 3, 14);
1405                                         prt(format(" %s Remove essence", (menu_line == 3) ? "> " : "  "), 4, 14);
1406                                         prt(format(" %s Add essence", (menu_line == 4) ? "> " : "  "), 5, 14);
1407                                         prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : "  "), 6, 14);
1408                                         prt(format("Choose command from menu."), 0, 0);
1409 #endif
1410                                         choice = inkey();
1411                                         switch (choice)
1412                                         {
1413                                         case ESCAPE:
1414                                         case 'z':
1415                                         case 'Z':
1416                                                 screen_load();
1417                                                 return;
1418                                         case '2':
1419                                         case 'j':
1420                                         case 'J':
1421                                                 menu_line++;
1422                                                 break;
1423                                         case '8':
1424                                         case 'k':
1425                                         case 'K':
1426                                                 menu_line += 4;
1427                                                 break;
1428                                         case '\r':
1429                                         case '\n':
1430                                         case 'x':
1431                                         case 'X':
1432                                                 mode = menu_line;
1433                                                 break;
1434                                         }
1435                                         if (menu_line > 5) menu_line -= 5;
1436                                 }
1437                         }
1438
1439                         else
1440                         {
1441                                 while (!mode)
1442                                 {
1443                                         prt(_("  a) エッセンス一覧", "  a) List essences"), 2, 14);
1444                                         prt(_("  b) エッセンス抽出", "  b) Extract essence"), 3, 14);
1445                                         prt(_("  c) エッセンス消去", "  c) Remove essence"), 4, 14);
1446                                         prt(_("  d) エッセンス付加", "  d) Add essence"), 5, 14);
1447                                         prt(_("  e) 武器/防具強化", "  e) Enchant weapon/armor"), 6, 14);
1448 #ifdef JP
1449                                         if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
1450 #else
1451                                         if (!get_com("Command :", &choice, TRUE))
1452 #endif
1453                                         {
1454                                                 screen_load();
1455                                                 return;
1456                                         }
1457                                         switch (choice)
1458                                         {
1459                                         case 'A':
1460                                         case 'a':
1461                                                 mode = 1;
1462                                                 break;
1463                                         case 'B':
1464                                         case 'b':
1465                                                 mode = 2;
1466                                                 break;
1467                                         case 'C':
1468                                         case 'c':
1469                                                 mode = 3;
1470                                                 break;
1471                                         case 'D':
1472                                         case 'd':
1473                                                 mode = 4;
1474                                                 break;
1475                                         case 'E':
1476                                         case 'e':
1477                                                 mode = 5;
1478                                                 break;
1479                                         }
1480                                 }
1481                         }
1482
1483                         if (only_browse)
1484                         {
1485                                 char temp[62 * 5];
1486                                 int line, j;
1487
1488                                 /* Clear lines, position cursor  (really should use strlen here) */
1489                                 Term_erase(14, 21, 255);
1490                                 Term_erase(14, 20, 255);
1491                                 Term_erase(14, 19, 255);
1492                                 Term_erase(14, 18, 255);
1493                                 Term_erase(14, 17, 255);
1494                                 Term_erase(14, 16, 255);
1495
1496                                 roff_to_buf(kaji_tips[mode - 1], 62, temp, sizeof(temp));
1497                                 for (j = 0, line = 17; temp[j]; j += (1 + strlen(&temp[j])))
1498                                 {
1499                                         prt(&temp[j], line, 15);
1500                                         line++;
1501                                 }
1502                                 mode = 0;
1503                         }
1504                         if (!only_browse) screen_load();
1505                 } while (only_browse);
1506                 repeat_push(mode);
1507         }
1508         switch (mode)
1509         {
1510         case 1: display_essence(creature_ptr); break;
1511         case 2: drain_essence(creature_ptr); break;
1512         case 3: erase_essence(creature_ptr); break;
1513         case 4:
1514                 mode = choose_essence();
1515                 if (mode == 0)
1516                         break;
1517                 add_essence(creature_ptr, mode);
1518                 break;
1519         case 5: add_essence(creature_ptr, 10); break;
1520         }
1521 }