OSDN Git Service

Merge pull request #1446 from habu1010/feature/incorporate-object-function-into-menbe...
[hengbandforosx/hengbandosx.git] / src / spell / spells-object.cpp
1 /*!
2  * @brief アイテムに影響のある魔法の処理
3  * @date 2019/01/22
4  * @author deskull
5  */
6
7 #include "spell/spells-object.h"
8 #include "avatar/avatar.h"
9 #include "core/player-redraw-types.h"
10 #include "core/player-update-types.h"
11 #include "core/window-redrawer.h"
12 #include "flavor/flavor-describer.h"
13 #include "flavor/object-flavor-types.h"
14 #include "floor/floor-object.h"
15 #include "game-option/disturbance-options.h"
16 #include "inventory/inventory-slot-types.h"
17 #include "monster-race/monster-race.h"
18 #include "monster-race/race-flags1.h"
19 #include "object-enchant/apply-magic.h"
20 #include "object-enchant/item-apply-magic.h"
21 #include "object-enchant/item-feeling.h"
22 #include "object-enchant/object-boost.h"
23 #include "object-enchant/object-ego.h"
24 #include "object-enchant/special-object-flags.h"
25 #include "object-enchant/trc-types.h"
26 #include "object-enchant/trg-types.h"
27 #include "object-hook/hook-armor.h"
28 #include "object-hook/hook-checker.h"
29 #include "object-hook/hook-enchant.h"
30 #include "object-hook/hook-weapon.h"
31 #include "object/item-tester-hooker.h"
32 #include "object/item-use-flags.h"
33 #include "object/object-kind-hook.h"
34 #include "object/object-kind.h"
35 #include "perception/object-perception.h"
36 #include "player/player-class.h"
37 #include "player/player-damage.h"
38 #include "racial/racial-android.h"
39 #include "spell-kind/spells-perception.h"
40 #include "status/bad-status-setter.h"
41 #include "sv-definition/sv-other-types.h"
42 #include "sv-definition/sv-scroll-types.h"
43 #include "sv-definition/sv-weapon-types.h"
44 #include "system/artifact-type-definition.h"
45 #include "system/floor-type-definition.h"
46 #include "system/monster-race-definition.h"
47 #include "system/object-type-definition.h"
48 #include "system/player-type-definition.h"
49 #include "term/screen-processor.h"
50 #include "util/bit-flags-calculator.h"
51 #include "view/display-messages.h"
52
53 typedef struct {
54     tval_type tval;
55     OBJECT_SUBTYPE_VALUE sval;
56     PERCENTAGE prob;
57     byte flag;
58 } amuse_type;
59
60 /*!
61  * @brief 装備強化処理の失敗率定数(千分率) /
62  * Used by the "enchant" function (chance of failure)
63  * (modified for Zangband, we need better stuff there...) -- TY
64  */
65 static int enchant_table[16] = { 0, 10, 50, 100, 200, 300, 400, 500, 650, 800, 950, 987, 993, 995, 998, 1000 };
66
67 /*
68  * Scatter some "amusing" objects near the player
69  */
70
71 #define AMS_NOTHING 0x00 /* No restriction */
72 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
73 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
74 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
75 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
76
77 static amuse_type amuse_info[]
78     = { { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING }, { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE }, { TV_SPIKE, SV_ANY, 10, AMS_PILE }, { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
79           { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE }, { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE }, { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
80           { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING }, { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, // Fishing Pole of Taikobo
81           { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, // Broken Dagger of Magician
82           { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING }, { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING }, { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
83
84           { TV_NONE, 0, 0, 0 } };
85
86 /*!
87  * @brief 誰得ドロップを行う。
88  * @param creature_ptr プレーヤーへの参照ポインタ
89  * @param y1 配置したいフロアのY座標
90  * @param x1 配置したいフロアのX座標
91  * @param num 誰得の処理回数
92  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
93  */
94 void amusement(player_type *creature_ptr, POSITION y1, POSITION x1, int num, bool known)
95 {
96     int t = 0;
97     for (int n = 0; amuse_info[n].tval != 0; n++) {
98         t += amuse_info[n].prob;
99     }
100
101     /* Acquirement */
102     object_type *i_ptr;
103     object_type object_type_body;
104     while (num) {
105         int i;
106         KIND_OBJECT_IDX k_idx;
107         ARTIFACT_IDX a_idx = 0;
108         int r = randint0(t);
109         bool insta_art, fixed_art;
110
111         for (i = 0;; i++) {
112             r -= amuse_info[i].prob;
113             if (r <= 0)
114                 break;
115         }
116         i_ptr = &object_type_body;
117         i_ptr->wipe();
118         k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
119
120         /* Paranoia - reroll if nothing */
121         if (!k_idx)
122             continue;
123
124         /* Search an artifact index if need */
125         insta_art = k_info[k_idx].gen_flags.has(TRG::INSTA_ART);
126         fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
127
128         if (insta_art || fixed_art) {
129             for (a_idx = 1; a_idx < max_a_idx; a_idx++) {
130                 if (insta_art && !a_info[a_idx].gen_flags.has(TRG::INSTA_ART))
131                     continue;
132                 if (a_info[a_idx].tval != k_info[k_idx].tval)
133                     continue;
134                 if (a_info[a_idx].sval != k_info[k_idx].sval)
135                     continue;
136                 if (a_info[a_idx].cur_num > 0)
137                     continue;
138                 break;
139             }
140
141             if (a_idx >= max_a_idx)
142                 continue;
143         }
144
145         /* Make an object (if possible) */
146         i_ptr->prep(k_idx);
147         if (a_idx)
148             i_ptr->name1 = a_idx;
149         apply_magic_to_object(creature_ptr, i_ptr, 1, AM_NO_FIXED_ART);
150
151         if (amuse_info[i].flag & AMS_NO_UNIQUE) {
152             if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE)
153                 continue;
154         }
155
156         if (amuse_info[i].flag & AMS_MULTIPLE)
157             i_ptr->number = randint1(3);
158         if (amuse_info[i].flag & AMS_PILE)
159             i_ptr->number = randint1(99);
160
161         if (known) {
162             object_aware(creature_ptr, i_ptr);
163             object_known(i_ptr);
164         }
165
166         /* Paranoia - reroll if nothing */
167         if (!(i_ptr->k_idx))
168             continue;
169
170         (void)drop_near(creature_ptr, i_ptr, -1, y1, x1);
171
172         num--;
173     }
174 }
175
176 /*!
177  * @brief 獲得ドロップを行う。
178  * Scatter some "great" objects near the player
179  * @param caster_ptr プレーヤーへの参照ポインタ
180  * @param y1 配置したいフロアのY座標
181  * @param x1 配置したいフロアのX座標
182  * @param num 獲得の処理回数
183  * @param great TRUEならば必ず高級品以上を落とす
184  * @param special TRUEならば必ず特別品を落とす
185  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
186  */
187 void acquirement(player_type *caster_ptr, POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
188 {
189     object_type *i_ptr;
190     object_type object_type_body;
191     BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : AM_NONE) | (special ? AM_SPECIAL : AM_NONE);
192
193     /* Acquirement */
194     while (num--) {
195         i_ptr = &object_type_body;
196         i_ptr->wipe();
197
198         /* Make a good (or great) object (if possible) */
199         if (!make_object(caster_ptr, i_ptr, mode))
200             continue;
201
202         if (known) {
203             object_aware(caster_ptr, i_ptr);
204             object_known(i_ptr);
205         }
206
207         (void)drop_near(caster_ptr, i_ptr, -1, y1, x1);
208     }
209 }
210
211 /*!
212  * @brief 防具呪縛処理 /
213  * Curse the players armor
214  * @return 何も持っていない場合を除き、常にTRUEを返す
215  * @todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
216  */
217 bool curse_armor(player_type *owner_ptr)
218 {
219     /* Curse the body armor */
220     object_type *o_ptr;
221     o_ptr = &owner_ptr->inventory_list[INVEN_BODY];
222
223     if (!o_ptr->k_idx)
224         return false;
225
226     GAME_TEXT o_name[MAX_NLEN];
227     describe_flavor(owner_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
228
229     /* Attempt a saving throw for artifacts */
230     if (o_ptr->is_artifact() && (randint0(100) < 50)) {
231         /* Cool */
232 #ifdef JP
233         msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "防具", o_name);
234 #else
235         msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your armor", o_name);
236 #endif
237         return true;
238     }
239
240     /* not artifact or failed save... */
241     msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
242     chg_virtue(owner_ptr, V_ENCHANT, -5);
243
244     /* Blast the armor */
245     o_ptr->name1 = 0;
246     o_ptr->name2 = EGO_BLASTED;
247     o_ptr->to_a = 0 - randint1(5) - randint1(5);
248     o_ptr->to_h = 0;
249     o_ptr->to_d = 0;
250     o_ptr->ac = 0;
251     o_ptr->dd = 0;
252     o_ptr->ds = 0;
253
254     for (int i = 0; i < TR_FLAG_SIZE; i++)
255         o_ptr->art_flags[i] = 0;
256
257     /* Curse it */
258     o_ptr->curse_flags.set(TRC::CURSED);
259
260     /* Break it */
261     o_ptr->ident |= (IDENT_BROKEN);
262     owner_ptr->update |= (PU_BONUS | PU_MANA);
263     owner_ptr->window_flags |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
264     return true;
265 }
266
267 /*!
268  * @brief 武器呪縛処理 /
269  * Curse the players weapon
270  * @param owner_ptr 所持者の参照ポインタ
271  * @param force 無条件に呪縛を行うならばTRUE
272  * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
273  * @return 何も持っていない場合を除き、常にTRUEを返す
274  * @todo 元のreturnは間違っているが、修正後の↓文がどれくらい正しいかは要チェック
275  */
276 bool curse_weapon_object(player_type *owner_ptr, bool force, object_type *o_ptr)
277 {
278     if (!o_ptr->k_idx)
279         return false;
280
281     GAME_TEXT o_name[MAX_NLEN];
282     describe_flavor(owner_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
283
284     /* Attempt a saving throw */
285     if (o_ptr->is_artifact() && (randint0(100) < 50) && !force) {
286 #ifdef JP
287         msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!", "恐怖の暗黒オーラ", "武器", o_name);
288 #else
289         msg_format("A %s tries to %s, but your %s resists the effects!", "terrible black aura", "surround your weapon", o_name);
290 #endif
291         return true;
292     }
293
294     /* not artifact or failed save... */
295     if (!force)
296         msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
297     chg_virtue(owner_ptr, V_ENCHANT, -5);
298
299     /* Shatter the weapon */
300     o_ptr->name1 = 0;
301     o_ptr->name2 = EGO_SHATTERED;
302     o_ptr->to_h = 0 - randint1(5) - randint1(5);
303     o_ptr->to_d = 0 - randint1(5) - randint1(5);
304     o_ptr->to_a = 0;
305     o_ptr->ac = 0;
306     o_ptr->dd = 0;
307     o_ptr->ds = 0;
308
309     for (int i = 0; i < TR_FLAG_SIZE; i++)
310         o_ptr->art_flags[i] = 0;
311
312     /* Curse it */
313     o_ptr->curse_flags.set(TRC::CURSED);
314
315     /* Break it */
316     o_ptr->ident |= (IDENT_BROKEN);
317     owner_ptr->update |= (PU_BONUS | PU_MANA);
318     owner_ptr->window_flags |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
319     return true;
320 }
321
322 /*!
323  * @brief ボルトのエゴ化処理(火炎エゴのみ) /
324  * Enchant some bolts
325  * @param caster_ptr プレーヤーへの参照ポインタ
326  */
327 void brand_bolts(player_type *caster_ptr)
328 {
329     /* Use the first acceptable bolts */
330     for (int i = 0; i < INVEN_PACK; i++) {
331         object_type *o_ptr = &caster_ptr->inventory_list[i];
332
333         /* Skip non-bolts */
334         if (o_ptr->tval != TV_BOLT)
335             continue;
336
337         /* Skip artifacts and ego-items */
338         if (o_ptr->is_artifact() || o_ptr->is_ego())
339             continue;
340
341         /* Skip cursed/broken items */
342         if (o_ptr->is_cursed() || o_ptr->is_broken())
343             continue;
344
345         /* Randomize */
346         if (randint0(100) < 75)
347             continue;
348
349         msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
350
351         /* Ego-item */
352         o_ptr->name2 = EGO_FLAME;
353         enchant_equipment(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
354         return;
355     }
356
357     if (flush_failure)
358         flush();
359     msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
360 }
361
362 /*!
363  * @brief 知識の石の発動を実行する / Do activation of the stone of lore.
364  * @param user_ptr プレイヤー情報への参照ポインタ
365  * @return 実行したらTRUE、しなかったらFALSE
366  * @details
367  * 鑑定を実行した後HPを消費する。1/5で混乱し、1/20で追加ダメージ。
368  * MPがある場合はさらにMPを20消費する。不足する場合は麻痺及び混乱。
369  */
370 bool perilous_secrets(player_type *user_ptr)
371 {
372     if (!ident_spell(user_ptr, false))
373         return false;
374
375     if (user_ptr->msp > 0) {
376         if (20 <= user_ptr->csp)
377             user_ptr->csp -= 20;
378         else {
379             int oops = 20 - user_ptr->csp;
380
381             user_ptr->csp = 0;
382             user_ptr->csp_frac = 0;
383
384             msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
385
386             (void)set_paralyzed(user_ptr, user_ptr->paralyzed + randint1(5 * oops + 1));
387             (void)set_confused(user_ptr, user_ptr->confused + randint1(5 * oops + 1));
388         }
389
390         user_ptr->redraw |= (PR_MANA);
391     }
392
393     take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"));
394
395     if (one_in_(5))
396         (void)set_confused(user_ptr, user_ptr->confused + randint1(10));
397
398     if (one_in_(20))
399         take_hit(user_ptr, DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"));
400
401     return true;
402 }
403
404 /*!
405  * @brief 呪いの打ち破り処理 /
406  * Break the curse of an item
407  * @param o_ptr 呪い装備情報の参照ポインタ
408  */
409 static void break_curse(object_type *o_ptr)
410 {
411     BIT_FLAGS is_curse_broken
412         = o_ptr->is_cursed() && o_ptr->curse_flags.has_not(TRC::PERMA_CURSE) && o_ptr->curse_flags.has_not(TRC::HEAVY_CURSE) && (randint0(100) < 25);
413     if (!is_curse_broken) {
414         return;
415     }
416
417     msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
418
419     o_ptr->curse_flags.clear();
420     o_ptr->ident |= (IDENT_SENSE);
421     o_ptr->feeling = FEEL_NONE;
422 }
423
424 /*!
425  * @brief 装備修正強化処理 /
426  * Enchants a plus onto an item. -RAK-
427  * @param caster_ptr プレーヤーへの参照ポインタ
428  * @param o_ptr 強化するアイテムの参照ポインタ
429  * @param n 強化基本量
430  * @param eflag 強化オプション(命中/ダメージ/AC)
431  * @return 強化に成功した場合TRUEを返す
432  * @details
433  * <pre>
434  * Revamped!  Now takes item pointer, number of times to try enchanting,
435  * and a flag of what to try enchanting.  Artifacts resist enchantment
436  * some of the time, and successful enchantment to at least +0 might
437  * break a curse on the item. -CFT-
438  *
439  * Note that an item can technically be enchanted all the way to +15 if
440  * you wait a very, very, long time.  Going from +9 to +10 only works
441  * about 5% of the time, and from +10 to +11 only about 1% of the time.
442  *
443  * Note that this function can now be used on "piles" of items, and
444  * the larger the pile, the lower the chance of success.
445  * </pre>
446  */
447 bool enchant_equipment(player_type *caster_ptr, object_type *o_ptr, int n, int eflag)
448 {
449     /* Large piles resist enchantment */
450     int prob = o_ptr->number * 100;
451
452     /* Missiles are easy to enchant */
453     if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT)) {
454         prob = prob / 20;
455     }
456
457     /* Try "n" times */
458     int chance;
459     bool res = false;
460     bool a = o_ptr->is_artifact();
461     bool force = (eflag & ENCH_FORCE);
462     for (int i = 0; i < n; i++) {
463         /* Hack -- Roll for pile resistance */
464         if (!force && randint0(prob) >= 100)
465             continue;
466
467         /* Enchant to hit */
468         if (eflag & ENCH_TOHIT) {
469             if (o_ptr->to_h < 0)
470                 chance = 0;
471             else if (o_ptr->to_h > 15)
472                 chance = 1000;
473             else
474                 chance = enchant_table[o_ptr->to_h];
475
476             if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
477                 o_ptr->to_h++;
478                 res = true;
479
480                 /* only when you get it above -1 -CFT */
481                 if (o_ptr->to_h >= 0)
482                     break_curse(o_ptr);
483             }
484         }
485
486         /* Enchant to damage */
487         if (eflag & ENCH_TODAM) {
488             if (o_ptr->to_d < 0)
489                 chance = 0;
490             else if (o_ptr->to_d > 15)
491                 chance = 1000;
492             else
493                 chance = enchant_table[o_ptr->to_d];
494
495             if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
496                 o_ptr->to_d++;
497                 res = true;
498
499                 /* only when you get it above -1 -CFT */
500                 if (o_ptr->to_d >= 0)
501                     break_curse(o_ptr);
502             }
503         }
504
505         /* Enchant to armor class */
506         if (!(eflag & ENCH_TOAC)) {
507             continue;
508         }
509
510         if (o_ptr->to_a < 0)
511             chance = 0;
512         else if (o_ptr->to_a > 15)
513             chance = 1000;
514         else
515             chance = enchant_table[o_ptr->to_a];
516
517         if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50)))) {
518             o_ptr->to_a++;
519             res = true;
520
521             /* only when you get it above -1 -CFT */
522             if (o_ptr->to_a >= 0)
523                 break_curse(o_ptr);
524         }
525     }
526
527     /* Failure */
528     if (!res)
529         return false;
530     set_bits(caster_ptr->update, PU_BONUS | PU_COMBINE | PU_REORDER);
531     set_bits(caster_ptr->window_flags, PW_INVEN | PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
532
533     /* Success */
534     return true;
535 }
536
537 /*!
538  * @brief 装備修正強化処理のメインルーチン /
539  * Enchant an item (in the inventory or on the floor)
540  * @param caster_ptr プレーヤーへの参照ポインタ
541  * @param num_hit 命中修正量
542  * @param num_dam ダメージ修正量
543  * @param num_ac AC修正量
544  * @return 強化に成功した場合TRUEを返す
545  * @details
546  * Note that "num_ac" requires armour, else weapon
547  * Returns TRUE if attempted, FALSE if cancelled
548  */
549 bool enchant_spell(player_type *caster_ptr, HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
550 {
551     /* Assume enchant weapon */
552     FuncItemTester item_tester(&object_type::allow_enchant_weapon);
553
554     /* Enchant armor if requested */
555     if (num_ac)
556         item_tester = FuncItemTester(&object_type::is_armour);
557
558     concptr q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
559     concptr s = _("強化できるアイテムがない。", "You have nothing to enchant.");
560
561     OBJECT_IDX item;
562     object_type *o_ptr;
563     o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), item_tester);
564     if (!o_ptr)
565         return false;
566
567     GAME_TEXT o_name[MAX_NLEN];
568     describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
569 #ifdef JP
570     msg_format("%s は明るく輝いた!", o_name);
571 #else
572     msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
573 #endif
574
575     /* Enchant */
576     bool is_enchant_successful = false;
577     if (enchant_equipment(caster_ptr, o_ptr, num_hit, ENCH_TOHIT))
578         is_enchant_successful = true;
579     if (enchant_equipment(caster_ptr, o_ptr, num_dam, ENCH_TODAM))
580         is_enchant_successful = true;
581     if (enchant_equipment(caster_ptr, o_ptr, num_ac, ENCH_TOAC))
582         is_enchant_successful = true;
583
584     if (!is_enchant_successful) {
585         if (flush_failure)
586             flush();
587         msg_print(_("強化に失敗した。", "The enchantment failed."));
588         if (one_in_(3))
589             chg_virtue(caster_ptr, V_ENCHANT, -1);
590     } else
591         chg_virtue(caster_ptr, V_ENCHANT, 1);
592
593     calc_android_exp(caster_ptr);
594
595     /* Something happened */
596     return true;
597 }
598
599 /*!
600  * @brief 武器へのエゴ付加処理 /
601  * Brand the current weapon
602  * @param caster_ptr プレーヤーへの参照ポインタ
603  * @param brand_type エゴ化ID(e_info.txtとは連動していない)
604  */
605 void brand_weapon(player_type *caster_ptr, int brand_type)
606 {
607     concptr q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
608     concptr s = _("強化できる武器がない。", "You have nothing to enchant.");
609
610     OBJECT_IDX item;
611     object_type *o_ptr;
612     o_ptr = choose_object(caster_ptr, &item, q, s, USE_EQUIP | IGNORE_BOTHHAND_SLOT, FuncItemTester(&object_type::allow_enchant_melee_weapon));
613     if (!o_ptr)
614         return;
615
616     bool is_special_item = o_ptr->k_idx && !o_ptr->is_artifact() && !o_ptr->is_ego() && !o_ptr->is_cursed()
617         && !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) && !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
618         && !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE));
619     if (!is_special_item) {
620         if (flush_failure)
621             flush();
622
623         msg_print(_("属性付加に失敗した。", "The branding failed."));
624         chg_virtue(caster_ptr, V_ENCHANT, -2);
625         calc_android_exp(caster_ptr);
626         return;
627     }
628
629     GAME_TEXT o_name[MAX_NLEN];
630     describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
631
632     concptr act = NULL;
633     switch (brand_type) {
634     case 17:
635         if (o_ptr->tval == TV_SWORD) {
636             act = _("は鋭さを増した!", "becomes very sharp!");
637
638             o_ptr->name2 = EGO_SHARPNESS;
639             o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, caster_ptr->current_floor_ptr->dun_level) + 1;
640
641             if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
642                 o_ptr->pval = 2;
643         } else {
644             act = _("は破壊力を増した!", "seems very powerful.");
645             o_ptr->name2 = EGO_EARTHQUAKES;
646             o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, caster_ptr->current_floor_ptr->dun_level);
647         }
648
649         break;
650     case 16:
651         act = _("は人間の血を求めている!", "seems to be looking for humans!");
652         o_ptr->name2 = EGO_KILL_HUMAN;
653         break;
654     case 15:
655         act = _("は電撃に覆われた!", "covered with lightning!");
656         o_ptr->name2 = EGO_BRAND_ELEC;
657         break;
658     case 14:
659         act = _("は酸に覆われた!", "coated with acid!");
660         o_ptr->name2 = EGO_BRAND_ACID;
661         break;
662     case 13:
663         act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
664         o_ptr->name2 = EGO_KILL_EVIL;
665         break;
666     case 12:
667         act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
668         o_ptr->name2 = EGO_KILL_DEMON;
669         break;
670     case 11:
671         act = _("は屍を求めている!", "seems to be looking for undead!");
672         o_ptr->name2 = EGO_KILL_UNDEAD;
673         break;
674     case 10:
675         act = _("は動物の血を求めている!", "seems to be looking for animals!");
676         o_ptr->name2 = EGO_KILL_ANIMAL;
677         break;
678     case 9:
679         act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
680         o_ptr->name2 = EGO_KILL_DRAGON;
681         break;
682     case 8:
683         act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
684         o_ptr->name2 = EGO_KILL_TROLL;
685         break;
686     case 7:
687         act = _("はオークの血を求めている!", "seems to be looking for orcs!");
688         o_ptr->name2 = EGO_KILL_ORC;
689         break;
690     case 6:
691         act = _("は巨人の血を求めている!", "seems to be looking for giants!");
692         o_ptr->name2 = EGO_KILL_GIANT;
693         break;
694     case 5:
695         act = _("は非常に不安定になったようだ。", "seems very unstable now.");
696         o_ptr->name2 = EGO_TRUMP;
697         o_ptr->pval = randint1(2);
698         break;
699     case 4:
700         act = _("は血を求めている!", "thirsts for blood!");
701         o_ptr->name2 = EGO_VAMPIRIC;
702         break;
703     case 3:
704         act = _("は毒に覆われた。", "is coated with poison.");
705         o_ptr->name2 = EGO_BRAND_POIS;
706         break;
707     case 2:
708         act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
709         o_ptr->name2 = EGO_CHAOTIC;
710         break;
711     case 1:
712         act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
713         o_ptr->name2 = EGO_BRAND_FIRE;
714         break;
715     default:
716         act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
717         o_ptr->name2 = EGO_BRAND_COLD;
718         break;
719     }
720
721     msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
722     enchant_equipment(caster_ptr, o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
723     o_ptr->discount = 99;
724     chg_virtue(caster_ptr, V_ENCHANT, 2);
725     calc_android_exp(caster_ptr);
726 }