OSDN Git Service

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